From 631f0c4a8bad22c9a2bb1ac6b36540f37c5816eb Mon Sep 17 00:00:00 2001 From: orbea Date: Sat, 25 Nov 2017 17:09:26 -0800 Subject: [PATCH 001/394] qb: Create a check_val function for the no pkg-config fallback path. --- qb/config.comp.sh | 1 - qb/config.libs.sh | 38 +++++++++----------------------------- qb/qb.libs.sh | 10 +++++++++- 3 files changed, 18 insertions(+), 31 deletions(-) diff --git a/qb/config.comp.sh b/qb/config.comp.sh index f0fcc84844..1ce76eeb14 100644 --- a/qb/config.comp.sh +++ b/qb/config.comp.sh @@ -4,4 +4,3 @@ USE_LANG_C="yes" if [ "$OS" = 'Win32' ]; then USE_LANG_CXX="yes" fi - diff --git a/qb/config.libs.sh b/qb/config.libs.sh index 2f6069c5e5..9ef47c2f83 100644 --- a/qb/config.libs.sh +++ b/qb/config.libs.sh @@ -119,10 +119,8 @@ fi if [ "$HAVE_EGL" != "no" ] && [ "$OS" != 'Win32' ]; then check_pkgconf EGL "$VC_PREFIX"egl # some systems have EGL libs, but no pkgconfig - if [ "$HAVE_EGL" = "no" ]; then - HAVE_EGL=auto - check_lib '' EGL "-l${VC_PREFIX}EGL $EXTRA_GL_LIBS" - else + check_val '' EGL "-l${VC_PREFIX}EGL $EXTRA_GL_LIBS" + if [ "$HAVE_EGL" = "yes" ]; then EGL_LIBS="$EGL_LIBS $EXTRA_GL_LIBS" fi fi @@ -319,11 +317,7 @@ fi if [ "$HAVE_ZLIB" != 'no' ]; then check_pkgconf ZLIB zlib - - if [ "$HAVE_ZLIB" = 'no' ]; then - HAVE_ZLIB='auto' - check_lib '' ZLIB '-lz' - fi + check_val '' ZLIB '-lz' fi if [ "$HAVE_THREADS" != 'no' ]; then @@ -382,10 +376,7 @@ if [ "$HAVE_EGL" = "yes" ]; then fi if [ "$HAVE_VG" != "no" ]; then check_pkgconf VG "$VC_PREFIX"vg - if [ "$HAVE_VG" = "no" ]; then - HAVE_VG=auto; check_lib '' VG "-l${VC_PREFIX}OpenVG $EXTRA_GL_LIBS" - [ "$HAVE_VG" = "yes" ] && VG_LIBS=-l"$VC_PREFIX"OpenVG - fi + check_val '' VG "-l${VC_PREFIX}OpenVG $EXTRA_GL_LIBS" fi else HAVE_VG=no @@ -397,9 +388,8 @@ check_pkgconf FREETYPE freetype2 check_pkgconf X11 x11 check_pkgconf XCB xcb -if [ "$HAVE_X11" = "no" ] && [ "$OS" != 'Darwin' ]; then - HAVE_X11=auto - check_lib '' X11 -lX11 +if [ "$OS" != 'Darwin' ]; then + check_val '' X11 -lX11 fi check_pkgconf WAYLAND wayland-egl @@ -411,15 +401,8 @@ check_pkgconf XEXT xext check_pkgconf XF86VM xxf86vm if [ "$HAVE_X11" != "no" ]; then - if [ "$HAVE_XEXT" = "no" ]; then - HAVE_XEXT=auto - check_lib '' XEXT -lXext - fi - - if [ "$HAVE_XF86VM" = "no" ]; then - HAVE_XF86VM=auto - check_lib '' XF86VM -lXxf86vm - fi + check_val '' XEXT -lXext + check_val '' XF86VM -lXxf86vm else HAVE_XEXT=no; HAVE_XF86VM=no; HAVE_XINERAMA=no; HAVE_XSHM=no fi @@ -435,10 +418,7 @@ fi if [ "$HAVE_UDEV" != "no" ]; then check_pkgconf UDEV libudev - if [ "$HAVE_UDEV" = "no" ]; then - HAVE_UDEV=auto - check_lib '' UDEV "-ludev" - fi + check_val '' UDEV "-ludev" fi check_header XSHM X11/Xlib.h X11/extensions/XShm.h diff --git a/qb/qb.libs.sh b/qb/qb.libs.sh index 6bbf851414..00411c9109 100644 --- a/qb/qb.libs.sh +++ b/qb/qb.libs.sh @@ -71,7 +71,7 @@ check_lib() # $1 = language $2 = HAVE_$2 $3 = lib $4 = function in lib $5 = return 0 } -check_pkgconf() #$1 = HAVE_$1 $2 = package $3 = version $4 = critical error message [checked only if non-empty] +check_pkgconf() # $1 = HAVE_$1 $2 = package $3 = version $4 = critical error message [checked only if non-empty] { tmpval="$(eval echo \$HAVE_$1)" [ "$tmpval" = 'no' ] && return 0 @@ -154,6 +154,14 @@ check_switch() # $1 = language $2 = HAVE_$2 $3 = switch $4 = critical error m } } +check_val() # $1 = language $2 = HAVE_$2 $3 = lib +{ tmpval="$(eval "printf %s \"\$HAVE_$2\"")" + if [ "$tmpval" = 'no' ]; then + eval "HAVE_$2=auto" + check_lib "$1" "$2" "$3" + fi +} + create_config_header() { outfile="$1"; shift From 771efdabc0e21b5b391ac58c52687ea67dee2f57 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 26 Nov 2017 03:01:28 +0100 Subject: [PATCH 002/394] Fix edge case issue where game's label was not being properly set when loading two games one after another from a playlist/collection - the previous game's name was being used instead --- menu/cbs/menu_cbs_ok.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 157710ec01..7fea03125c 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -1497,8 +1497,16 @@ static int action_ok_playlist_entry_collection(const char *path, if (system && string_is_equal(system->library_name, core_name)) { + global_t *global = global_get_ptr(); + if (playlist_initialized) playlist_free(tmp_playlist); + if (global) + { + global->name.label[0] = '\0'; + if (!string_is_empty(entry_label)) + strlcpy(global->name.label, entry_label, sizeof(global->name.label)); + } return action_ok_file_load(menu->deferred_path, label, type, idx, entry_idx); } From dee66ab6bb2d7892de80ab563a3252a7a8c1cbda Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 26 Nov 2017 05:04:18 +0100 Subject: [PATCH 003/394] Get rid of this - seems to be a highly problematic codepath in general --- menu/cbs/menu_cbs_ok.c | 20 -------------------- 1 file changed, 20 deletions(-) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 7fea03125c..93a4bdeb22 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -1490,26 +1490,6 @@ static int action_ok_playlist_entry_collection(const char *path, playlist_get_index(playlist, selection_ptr, &entry_path, &entry_label, &core_path, &core_name, NULL, NULL); - /* If the currently loaded core's name is equal - * to the core name from the playlist entry, - * then we directly load this game with the current core. - */ - if (system && - string_is_equal(system->library_name, core_name)) - { - global_t *global = global_get_ptr(); - - if (playlist_initialized) - playlist_free(tmp_playlist); - if (global) - { - global->name.label[0] = '\0'; - if (!string_is_empty(entry_label)) - strlcpy(global->name.label, entry_label, sizeof(global->name.label)); - } - return action_ok_file_load(menu->deferred_path, label, type, idx, entry_idx); - } - /* Is the core path / name of the playlist entry not yet filled in? */ if ( string_is_equal(core_path, file_path_str(FILE_PATH_DETECT)) && string_is_equal(core_name, file_path_str(FILE_PATH_DETECT))) From f15aaa0b2c8101098f1c78359a58af7683d4d128 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 26 Nov 2017 05:07:35 +0100 Subject: [PATCH 004/394] Reduce differences between the two functions --- menu/cbs/menu_cbs_ok.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 93a4bdeb22..4175a8302e 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -1559,6 +1559,7 @@ static int action_ok_playlist_entry(const char *path, { menu_content_ctx_playlist_info_t playlist_info; content_ctx_info_t content_info; + char new_core_path[PATH_MAX_LENGTH]; size_t selection_ptr = 0; playlist_t *playlist = g_defaults.content_history; const char *entry_path = NULL; @@ -1572,6 +1573,8 @@ static int action_ok_playlist_entry(const char *path, content_info.args = NULL; content_info.environ_get = NULL; + new_core_path[0] = '\0'; + if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu)) return menu_cbs_exit(); @@ -1584,15 +1587,10 @@ static int action_ok_playlist_entry(const char *path, && string_is_equal(core_name, file_path_str(FILE_PATH_DETECT))) { core_info_ctx_find_t core_info; - char new_core_path[PATH_MAX_LENGTH]; const char *entry_path = NULL; const char *path_base = path_basename(menu->db_playlist_file); - bool found_associated_core = false; - - new_core_path[0] = '\0'; - - found_associated_core = + bool found_associated_core = menu_content_playlist_find_associated_core( path_base, new_core_path, sizeof(new_core_path)); @@ -1614,6 +1612,8 @@ static int action_ok_playlist_entry(const char *path, NULL, new_core_path); } + else + strlcpy(new_core_path, core_path, sizeof(new_core_path)); playlist_info.data = playlist; playlist_info.idx = (unsigned)selection_ptr; @@ -1631,7 +1631,7 @@ static int action_ok_playlist_entry(const char *path, NULL, NULL); if (!task_push_load_content_from_playlist_from_menu( - core_path, path, entry_label, + new_core_path, path, entry_label, &content_info, NULL, NULL)) return -1; From bd1e06bbb79fc8de7f4e89fdfb501762f7bd2b02 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 26 Nov 2017 06:03:34 +0100 Subject: [PATCH 005/394] Group identical functions --- menu/cbs/menu_cbs_ok.c | 245 +++++++++++++++++++++-------------------- 1 file changed, 125 insertions(+), 120 deletions(-) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 4175a8302e..bea7d7aa28 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -1866,21 +1866,6 @@ static void menu_input_wifi_cb(void *userdata, const char *passphrase) menu_input_dialog_end(); } -static int action_ok_cheat(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - menu_input_ctx_line_t line; - - line.label = msg_hash_to_str(MSG_INPUT_CHEAT); - line.label_setting = label; - line.type = type; - line.idx = (unsigned)idx; - line.cb = menu_input_st_cheat_cb; - - if (!menu_input_dialog_start(&line)) - return -1; - return 0; -} static void menu_input_st_string_cb_rename_entry(void *userdata, const char *str) @@ -1987,6 +1972,30 @@ static void menu_input_st_string_cb_save_preset(void *userdata, menu_input_dialog_end(); } +static void menu_input_st_string_cb_cheat_file_save_as( + void *userdata, const char *str) +{ + if (str && *str) + { + rarch_setting_t *setting = NULL; + settings_t *settings = config_get_ptr(); + const char *label = menu_input_dialog_get_label_buffer(); + + if (!string_is_empty(label)) + setting = menu_setting_find(label); + + if (setting) + { + setting_set_with_string_representation(setting, str); + menu_setting_generic(setting, false); + } + else if (!string_is_empty(label)) + cheat_manager_save(str, settings->paths.path_cheat_database); + } + + menu_input_dialog_end(); +} + static int action_ok_shader_preset_save_as(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { @@ -2003,6 +2012,102 @@ static int action_ok_shader_preset_save_as(const char *path, return 0; } +static int action_ok_enable_settings(const char *path, + const char *label, unsigned type, size_t idx, size_t entry_idx) +{ + menu_input_ctx_line_t line; + + line.label = msg_hash_to_str(MSG_INPUT_ENABLE_SETTINGS_PASSWORD); + line.label_setting = label; + line.type = type; + line.idx = (unsigned)entry_idx; + line.cb = menu_input_st_string_cb_enable_settings; + + if (!menu_input_dialog_start(&line)) + return -1; + return 0; +} + +static int action_ok_wifi(const char *path, + const char *label, unsigned type, size_t idx, size_t entry_idx) +{ + menu_input_ctx_line_t line; + + line.label = "Passphrase"; + line.label_setting = label; + line.type = type; + line.idx = (unsigned)idx; + line.cb = menu_input_wifi_cb; + + if (!menu_input_dialog_start(&line)) + return -1; + return 0; +} + +static int action_ok_cheat_file_save_as(const char *path, + const char *label, unsigned type, size_t idx, size_t entry_idx) +{ + menu_input_ctx_line_t line; + + line.label = msg_hash_to_str(MSG_INPUT_CHEAT_FILENAME); + line.label_setting = label; + line.type = type; + line.idx = (unsigned)idx; + line.cb = menu_input_st_string_cb_cheat_file_save_as; + + if (!menu_input_dialog_start(&line)) + return -1; + return 0; +} + +static int action_ok_cheat(const char *path, + const char *label, unsigned type, size_t idx, size_t entry_idx) +{ + menu_input_ctx_line_t line; + + line.label = msg_hash_to_str(MSG_INPUT_CHEAT); + line.label_setting = label; + line.type = type; + line.idx = (unsigned)idx; + line.cb = menu_input_st_cheat_cb; + + if (!menu_input_dialog_start(&line)) + return -1; + return 0; +} + +static int action_ok_disable_kiosk_mode(const char *path, + const char *label, unsigned type, size_t idx, size_t entry_idx) +{ + menu_input_ctx_line_t line; + + line.label = msg_hash_to_str(MSG_INPUT_KIOSK_MODE_PASSWORD); + line.label_setting = label; + line.type = type; + line.idx = (unsigned)entry_idx; + line.cb = menu_input_st_string_cb_disable_kiosk_mode; + + if (!menu_input_dialog_start(&line)) + return -1; + return 0; +} + +static int action_ok_rename_entry(const char *path, + const char *label, unsigned type, size_t idx, size_t entry_idx) +{ + menu_input_ctx_line_t line; + + line.label = msg_hash_to_str(MSG_INPUT_RENAME_ENTRY); + line.label_setting = label; + line.type = type; + line.idx = (unsigned)entry_idx; + line.cb = menu_input_st_string_cb_rename_entry; + + if (!menu_input_dialog_start(&line)) + return -1; + return 0; +} + enum { ACTION_OK_SHADER_PRESET_SAVE_CORE = 0, @@ -2081,45 +2186,7 @@ static int action_ok_shader_preset_save_game(const char *path, idx, entry_idx, ACTION_OK_SHADER_PRESET_SAVE_GAME); } -static void menu_input_st_string_cb_cheat_file_save_as( - void *userdata, const char *str) -{ - if (str && *str) - { - rarch_setting_t *setting = NULL; - settings_t *settings = config_get_ptr(); - const char *label = menu_input_dialog_get_label_buffer(); - if (!string_is_empty(label)) - setting = menu_setting_find(label); - - if (setting) - { - setting_set_with_string_representation(setting, str); - menu_setting_generic(setting, false); - } - else if (!string_is_empty(label)) - cheat_manager_save(str, settings->paths.path_cheat_database); - } - - menu_input_dialog_end(); -} - -static int action_ok_cheat_file_save_as(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - menu_input_ctx_line_t line; - - line.label = msg_hash_to_str(MSG_INPUT_CHEAT_FILENAME); - line.label_setting = label; - line.type = type; - line.idx = (unsigned)idx; - line.cb = menu_input_st_string_cb_cheat_file_save_as; - - if (!menu_input_dialog_start(&line)) - return -1; - return 0; -} static int generic_action_ok_remap_file_operation(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx, @@ -3161,21 +3228,6 @@ static int action_ok_add_to_favorites_playlist(const char *path, return 0; } -static int action_ok_rename_entry(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - menu_input_ctx_line_t line; - - line.label = msg_hash_to_str(MSG_INPUT_RENAME_ENTRY); - line.label_setting = label; - line.type = type; - line.idx = (unsigned)entry_idx; - line.cb = menu_input_st_string_cb_rename_entry; - - if (!menu_input_dialog_start(&line)) - return -1; - return 0; -} static int action_ok_delete_entry(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) @@ -3230,37 +3282,6 @@ static int action_ok_delete_entry(const char *path, return 0; } -static int action_ok_disable_kiosk_mode(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - menu_input_ctx_line_t line; - - line.label = msg_hash_to_str(MSG_INPUT_KIOSK_MODE_PASSWORD); - line.label_setting = label; - line.type = type; - line.idx = (unsigned)entry_idx; - line.cb = menu_input_st_string_cb_disable_kiosk_mode; - - if (!menu_input_dialog_start(&line)) - return -1; - return 0; -} - -static int action_ok_enable_settings(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - menu_input_ctx_line_t line; - - line.label = msg_hash_to_str(MSG_INPUT_ENABLE_SETTINGS_PASSWORD); - line.label_setting = label; - line.type = type; - line.idx = (unsigned)entry_idx; - line.cb = menu_input_st_string_cb_enable_settings; - - if (!menu_input_dialog_start(&line)) - return -1; - return 0; -} static int action_ok_rdb_entry_submenu(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) @@ -3456,22 +3477,6 @@ static int action_ok_netplay_connect_room(const char *path, return 0; } -static int action_ok_wifi(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - - menu_input_ctx_line_t line; - - line.label = "Passphrase"; - line.label_setting = label; - line.type = type; - line.idx = (unsigned)idx; - line.cb = menu_input_wifi_cb; - - if (!menu_input_dialog_start(&line)) - return -1; - return 0; -} static int action_ok_netplay_lan_scan(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) @@ -4148,12 +4153,12 @@ static int action_ok_netplay_enable_client(const char *path, command_event(CMD_EVENT_NETPLAY_DEINIT, NULL); netplay_driver_ctl(RARCH_NETPLAY_CTL_ENABLE_CLIENT, NULL); - /* If no host was specified in the config, ask for one */ - memset(&line, 0, sizeof(line)); - - line.label = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_IP_ADDRESS); + line.label = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_IP_ADDRESS); line.label_setting = "no_setting"; - line.cb = action_ok_netplay_enable_client_hostname_cb; + line.type = 0; + line.idx = 0; + line.cb = action_ok_netplay_enable_client_hostname_cb; + if (menu_input_dialog_start(&line)) return 0; #endif From 99fcc63b3896cc917584c2b52fb6f29bb1a21023 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 26 Nov 2017 06:12:51 +0100 Subject: [PATCH 006/394] Cut down on code duplication --- menu/cbs/menu_cbs_ok.c | 149 +++++++++++------------------------------ 1 file changed, 40 insertions(+), 109 deletions(-) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index bea7d7aa28..92671dcb5e 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -1996,117 +1996,48 @@ static void menu_input_st_string_cb_cheat_file_save_as( menu_input_dialog_end(); } -static int action_ok_shader_preset_save_as(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - menu_input_ctx_line_t line; - - line.label = msg_hash_to_str(MSG_INPUT_PRESET_FILENAME); - line.label_setting = label; - line.type = type; - line.idx = (unsigned)idx; - line.cb = menu_input_st_string_cb_save_preset; - - if (!menu_input_dialog_start(&line)) - return -1; - return 0; +#define default_action_dialog_start(funcname, _label_setting, _idx, _cb) \ +static int (funcname)(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) \ +{ \ + menu_input_ctx_line_t line; \ + line.label = label; \ + line.label_setting = _label_setting; \ + line.type = type; \ + line.idx = (_idx); \ + line.cb = _cb; \ + if (!menu_input_dialog_start(&line)) \ + return -1; \ + return 0; \ } -static int action_ok_enable_settings(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - menu_input_ctx_line_t line; - - line.label = msg_hash_to_str(MSG_INPUT_ENABLE_SETTINGS_PASSWORD); - line.label_setting = label; - line.type = type; - line.idx = (unsigned)entry_idx; - line.cb = menu_input_st_string_cb_enable_settings; - - if (!menu_input_dialog_start(&line)) - return -1; - return 0; -} - -static int action_ok_wifi(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - menu_input_ctx_line_t line; - - line.label = "Passphrase"; - line.label_setting = label; - line.type = type; - line.idx = (unsigned)idx; - line.cb = menu_input_wifi_cb; - - if (!menu_input_dialog_start(&line)) - return -1; - return 0; -} - -static int action_ok_cheat_file_save_as(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - menu_input_ctx_line_t line; - - line.label = msg_hash_to_str(MSG_INPUT_CHEAT_FILENAME); - line.label_setting = label; - line.type = type; - line.idx = (unsigned)idx; - line.cb = menu_input_st_string_cb_cheat_file_save_as; - - if (!menu_input_dialog_start(&line)) - return -1; - return 0; -} - -static int action_ok_cheat(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - menu_input_ctx_line_t line; - - line.label = msg_hash_to_str(MSG_INPUT_CHEAT); - line.label_setting = label; - line.type = type; - line.idx = (unsigned)idx; - line.cb = menu_input_st_cheat_cb; - - if (!menu_input_dialog_start(&line)) - return -1; - return 0; -} - -static int action_ok_disable_kiosk_mode(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - menu_input_ctx_line_t line; - - line.label = msg_hash_to_str(MSG_INPUT_KIOSK_MODE_PASSWORD); - line.label_setting = label; - line.type = type; - line.idx = (unsigned)entry_idx; - line.cb = menu_input_st_string_cb_disable_kiosk_mode; - - if (!menu_input_dialog_start(&line)) - return -1; - return 0; -} - -static int action_ok_rename_entry(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - menu_input_ctx_line_t line; - - line.label = msg_hash_to_str(MSG_INPUT_RENAME_ENTRY); - line.label_setting = label; - line.type = type; - line.idx = (unsigned)entry_idx; - line.cb = menu_input_st_string_cb_rename_entry; - - if (!menu_input_dialog_start(&line)) - return -1; - return 0; -} +default_action_dialog_start(action_ok_shader_preset_save_as, + msg_hash_to_str(MSG_INPUT_PRESET_FILENAME), + (unsigned)idx, + menu_input_st_string_cb_save_preset) +default_action_dialog_start(action_ok_enable_settings, + msg_hash_to_str(MSG_INPUT_ENABLE_SETTINGS_PASSWORD), + (unsigned)entry_idx, + menu_input_st_string_cb_enable_settings) +default_action_dialog_start(action_ok_wifi, + "Passphrase", + (unsigned)idx, + menu_input_wifi_cb) +default_action_dialog_start(action_ok_cheat_file_save_as, + msg_hash_to_str(MSG_INPUT_CHEAT_FILENAME), + (unsigned)idx, + menu_input_st_string_cb_cheat_file_save_as) +default_action_dialog_start(action_ok_cheat, + msg_hash_to_str(MSG_INPUT_CHEAT), + (unsigned)idx, + menu_input_st_cheat_cb) +default_action_dialog_start(action_ok_disable_kiosk_mode, + msg_hash_to_str(MSG_INPUT_KIOSK_MODE_PASSWORD), + (unsigned)entry_idx, + menu_input_st_string_cb_disable_kiosk_mode) +default_action_dialog_start(action_ok_rename_entry, + msg_hash_to_str(MSG_INPUT_RENAME_ENTRY), + (unsigned)entry_idx, + menu_input_st_string_cb_rename_entry) enum { From ce91c082e43d610f12d64ca2ef72155289c9d28b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 26 Nov 2017 06:23:14 +0100 Subject: [PATCH 007/394] Cut down on code duplication --- menu/cbs/menu_cbs_ok.c | 71 +++++++++--------------------------------- 1 file changed, 14 insertions(+), 57 deletions(-) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 92671dcb5e..b3830a47e2 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -2276,25 +2276,6 @@ static int action_ok_core_deferred_set(const char *path, return menu_cbs_exit(); } -static int action_ok_core_deferred_set_current_core(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - char core_display_name[PATH_MAX_LENGTH]; - size_t selection = menu_navigation_get_selection(); - - core_display_name[0] = '\0'; - - core_info_get_name(path, core_display_name, sizeof(core_display_name)); - command_playlist_update_write(NULL, - rdb_entry_start_game_selection_ptr, - core_display_name, NULL, path); - - menu_entries_pop_stack(&selection, 0, 1); - menu_navigation_set_selection(selection); - - return 0; -} - static int action_ok_deferred_list_stub(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { @@ -2325,43 +2306,21 @@ static int action_ok_load_core_deferred(const char *path, return 0; } -static int action_ok_start_net_retropad_core(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - content_ctx_info_t content_info; - - content_info.argc = 0; - content_info.argv = NULL; - content_info.args = NULL; - content_info.environ_get = NULL; - - if (!task_push_start_builtin_core( - &content_info, - CORE_TYPE_NETRETROPAD, - NULL, NULL)) - return -1; - - return 0; +#define default_action_ok_start_builtin_core(funcname, _id) \ +static int (funcname)(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) \ +{ \ + content_ctx_info_t content_info; \ + content_info.argc = 0; \ + content_info.argv = NULL; \ + content_info.args = NULL; \ + content_info.environ_get = NULL; \ + if (!task_push_start_builtin_core(&content_info, _id, NULL, NULL)) \ + return -1; \ + return 0; \ } -static int action_ok_start_video_processor_core(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - content_ctx_info_t content_info; - - content_info.argc = 0; - content_info.argv = NULL; - content_info.args = NULL; - content_info.environ_get = NULL; - - if (!task_push_start_builtin_core( - &content_info, - CORE_TYPE_VIDEO_PROCESSOR, - NULL, NULL)) - return -1; - - return 0; -} +default_action_ok_start_builtin_core(action_ok_start_net_retropad_core, CORE_TYPE_NETRETROPAD) +default_action_ok_start_builtin_core(action_ok_start_video_processor_core, CORE_TYPE_VIDEO_PROCESSOR) #ifdef HAVE_FFMPEG static int action_ok_file_load_ffmpeg(const char *path, @@ -4236,10 +4195,8 @@ static int menu_cbs_init_bind_ok_compare_label(menu_file_list_cbs_t *cbs, BIND_ACTION_OK(cbs, action_ok_load_core); break; case MENU_ENUM_LABEL_FILE_BROWSER_CORE_SELECT_FROM_COLLECTION: - BIND_ACTION_OK(cbs, action_ok_core_deferred_set); - break; case MENU_ENUM_LABEL_FILE_BROWSER_CORE_SELECT_FROM_COLLECTION_CURRENT_CORE: - BIND_ACTION_OK(cbs, action_ok_core_deferred_set_current_core); + BIND_ACTION_OK(cbs, action_ok_core_deferred_set); break; case MENU_ENUM_LABEL_START_CORE: BIND_ACTION_OK(cbs, action_ok_start_core); From d5c30fd68c0a82a5c4692e3309cfde8fab9dd0ce Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 26 Nov 2017 06:35:53 +0100 Subject: [PATCH 008/394] Cleanups --- menu/cbs/menu_cbs_ok.c | 43 +++++++++++++++++++++--------------------- 1 file changed, 21 insertions(+), 22 deletions(-) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index b3830a47e2..403e2b31e6 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -1189,6 +1189,13 @@ static int set_path_generic(const char *label, const char *action_path) return 0; } +static int generic_action_ok_command(enum event_command cmd) +{ + if (!command_event(cmd, NULL)) + return menu_cbs_exit(); + return 0; +} + static int generic_action_ok(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx, unsigned id, enum msg_hash_enums flush_id) @@ -1319,7 +1326,7 @@ static int generic_action_ok(const char *path, case ACTION_OK_APPEND_DISK_IMAGE: flush_type = MENU_SETTINGS; command_event(CMD_EVENT_DISK_APPEND_IMAGE, action_path); - command_event(CMD_EVENT_RESUME, NULL); + generic_action_ok_command(CMD_EVENT_RESUME); break; case ACTION_OK_SET_DIRECTORY: flush_char = msg_hash_to_str(MENU_ENUM_LABEL_DEFERRED_DIRECTORY_SETTINGS_LIST); @@ -1747,9 +1754,7 @@ static int action_ok_playlist_entry_start_content(const char *path, static int action_ok_cheat_apply_changes(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { - command_event(CMD_EVENT_CHEATS_APPLY, NULL); - - return 0; + return generic_action_ok_command(CMD_EVENT_CHEATS_APPLY); } static int action_ok_lookup_setting(const char *path, @@ -2456,12 +2461,6 @@ static int action_ok_file_load_detect_core(const char *path, return 0; } -static int generic_action_ok_command(enum event_command cmd) -{ - if (!command_event(cmd, NULL)) - return menu_cbs_exit(); - return 0; -} static int action_ok_load_state(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) @@ -2509,10 +2508,10 @@ static void cb_decompressed(void *task_data, void *user_data, const char *err) switch (type_hash) { case CB_CORE_UPDATER_DOWNLOAD: - command_event(CMD_EVENT_CORE_INFO_INIT, NULL); + generic_action_ok_command(CMD_EVENT_CORE_INFO_INIT); break; case CB_UPDATE_ASSETS: - command_event(CMD_EVENT_REINIT, NULL); + generic_action_ok_command(CMD_EVENT_REINIT); break; } } @@ -2608,7 +2607,7 @@ static int generic_action_ok_network(const char *path, menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh); - command_event(CMD_EVENT_NETWORK_INIT, NULL); + generic_action_ok_command(CMD_EVENT_NETWORK_INIT); transf = (menu_file_transfer_t*)calloc(1, sizeof(*transf)); strlcpy(transf->path, url_path, sizeof(transf->path)); @@ -2804,7 +2803,7 @@ static void cb_generic_download(void *task_data, switch (transf->enum_idx) { case MENU_ENUM_LABEL_CB_CORE_UPDATER_DOWNLOAD: - command_event(CMD_EVENT_CORE_INFO_INIT, NULL); + generic_action_ok_command(CMD_EVENT_CORE_INFO_INIT); break; default: break; @@ -3329,7 +3328,7 @@ static int action_ok_netplay_connect_room(const char *path, tmp_hostname[0] = '\0'; if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_DATA_INITED, NULL)) - command_event(CMD_EVENT_NETPLAY_DEINIT, NULL); + generic_action_ok_command(CMD_EVENT_NETPLAY_DEINIT); netplay_driver_ctl(RARCH_NETPLAY_CTL_ENABLE_CLIENT, NULL); if (netplay_room_list[idx - 3].host_method == NETPLAY_HOST_METHOD_MITM) @@ -3384,7 +3383,7 @@ static int action_ok_netplay_lan_scan(const char *path, /* Enable Netplay client mode */ if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_DATA_INITED, NULL)) - command_event(CMD_EVENT_NETPLAY_DEINIT, NULL); + generic_action_ok_command(CMD_EVENT_NETPLAY_DEINIT); netplay_driver_ctl(RARCH_NETPLAY_CTL_ENABLE_CLIENT, NULL); /* Enable Netplay */ @@ -3794,7 +3793,7 @@ static int action_ok_load_archive(const char *path, fill_pathname_join(detect_content_path, menu_path, content_path, sizeof(detect_content_path)); - command_event(CMD_EVENT_LOAD_CORE, NULL); + generic_action_ok_command(CMD_EVENT_LOAD_CORE); if (!task_push_load_content_with_core_from_menu( detect_content_path, @@ -3947,7 +3946,7 @@ static int action_ok_video_resolution(const char *path, msg[0] = '\0'; #if defined(__CELLOS_LV2__) || defined(_WIN32) - command_event(CMD_EVENT_REINIT, NULL); + generic_action_ok_command(CMD_EVENT_REINIT); #endif video_driver_set_video_mode(width, height, true); #ifdef GEKKO @@ -3974,7 +3973,7 @@ static int action_ok_netplay_enable_host(const char *path, content_get_status(&contentless, &is_inited); if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_DATA_INITED, NULL)) - command_event(CMD_EVENT_NETPLAY_DEINIT, NULL); + generic_action_ok_command(CMD_EVENT_NETPLAY_DEINIT); netplay_driver_ctl(RARCH_NETPLAY_CTL_ENABLE_SERVER, NULL); /* If we haven't yet started, this will load on its own */ @@ -4040,7 +4039,7 @@ static int action_ok_netplay_enable_client(const char *path, #ifdef HAVE_NETWORKING menu_input_ctx_line_t line; if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_DATA_INITED, NULL)) - command_event(CMD_EVENT_NETPLAY_DEINIT, NULL); + generic_action_ok_command(CMD_EVENT_NETPLAY_DEINIT); netplay_driver_ctl(RARCH_NETPLAY_CTL_ENABLE_CLIENT, NULL); line.label = msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NETPLAY_IP_ADDRESS); @@ -4067,9 +4066,9 @@ static int action_ok_netplay_disconnect(const char *path, /* Re-enable rewind if it was enabled TODO: Add a setting for these tweaks */ if (settings->bools.rewind_enable) - command_event(CMD_EVENT_REWIND_INIT, NULL); + generic_action_ok_command(CMD_EVENT_REWIND_INIT); if (settings->uints.autosave_interval != 0) - command_event(CMD_EVENT_AUTOSAVE_INIT, NULL); + generic_action_ok_command(CMD_EVENT_AUTOSAVE_INIT); return generic_action_ok_command(CMD_EVENT_RESUME); #else From edfe5e699198e242f475fb1fbcc3562d93ece17c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 26 Nov 2017 06:49:58 +0100 Subject: [PATCH 009/394] Cut down on code duplication --- menu/cbs/menu_cbs_ok.c | 41 +++++++++-------------------------------- 1 file changed, 9 insertions(+), 32 deletions(-) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 403e2b31e6..15dd13fdd0 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -2618,40 +2618,17 @@ static int generic_action_ok_network(const char *path, label, type, idx, entry_idx, type_id2); } -static int action_ok_core_content_list(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_network(path, label, type, idx, entry_idx, - MENU_ENUM_LABEL_CB_CORE_CONTENT_LIST); +#define default_action_ok_list(funcname, _id) \ +static int (funcname)(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) \ +{ \ + return generic_action_ok_network(path, label, type, idx, entry_idx, _id); \ } -static int action_ok_core_content_dirs_list(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_network(path, label, type, idx, entry_idx, - MENU_ENUM_LABEL_CB_CORE_CONTENT_DIRS_LIST); -} - -static int action_ok_core_updater_list(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_network(path, label, type, idx, entry_idx, - MENU_ENUM_LABEL_CB_CORE_UPDATER_LIST); -} - -static int action_ok_thumbnails_updater_list(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_network(path, label, type, idx, entry_idx, - MENU_ENUM_LABEL_CB_THUMBNAILS_UPDATER_LIST); -} - -static int action_ok_lakka_list(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_network(path, label, type, idx, entry_idx, - MENU_ENUM_LABEL_CB_LAKKA_LIST); -} +default_action_ok_list(action_ok_core_content_list, MENU_ENUM_LABEL_CB_CORE_CONTENT_LIST) +default_action_ok_list(action_ok_core_content_dirs_list, MENU_ENUM_LABEL_CB_CORE_CONTENT_DIRS_LIST) +default_action_ok_list(action_ok_core_updater_list, MENU_ENUM_LABEL_CB_CORE_UPDATER_LIST) +default_action_ok_list(action_ok_thumbnails_updater_list, MENU_ENUM_LABEL_CB_THUMBNAILS_UPDATER_LIST) +default_action_ok_list(action_ok_lakka_list, MENU_ENUM_LABEL_CB_LAKKA_LIST) static void cb_generic_dir_download(void *task_data, void *user_data, const char *err) From 2e7a532c895ac1683882e0242435df699d8bb91f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 26 Nov 2017 06:57:05 +0100 Subject: [PATCH 010/394] Cut down on code duplication --- menu/cbs/menu_cbs_ok.c | 59 ++++++++---------------------------------- 1 file changed, 11 insertions(+), 48 deletions(-) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 15dd13fdd0..79acc07077 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -3859,56 +3859,19 @@ static int action_ok_load_archive_detect_core(const char *path, return ret; } -static int action_ok_help_audio_video_troubleshooting(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_help(path, label, type, idx, entry_idx, - MENU_ENUM_LABEL_HELP_AUDIO_VIDEO_TROUBLESHOOTING, - MENU_DIALOG_HELP_AUDIO_VIDEO_TROUBLESHOOTING); +#define default_action_ok_help(funcname, _id, _id2) \ +static int (funcname)(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) \ +{ \ + return generic_action_ok_help(path, label, type, idx, entry_idx, _id, _id2); \ } -static int action_ok_help(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_help(path, label, type, idx, entry_idx, - MENU_ENUM_LABEL_HELP, MENU_DIALOG_WELCOME); -} - -static int action_ok_help_controls(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_help(path, label, type, idx, entry_idx, - MENU_ENUM_LABEL_HELP_CONTROLS, MENU_DIALOG_HELP_CONTROLS); -} - -static int action_ok_help_what_is_a_core(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_help(path, label, type, idx, entry_idx, - MENU_ENUM_LABEL_HELP_WHAT_IS_A_CORE, MENU_DIALOG_HELP_WHAT_IS_A_CORE); -} - -static int action_ok_help_scanning_content(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_help(path, label, type, idx, entry_idx, - MENU_ENUM_LABEL_HELP_SCANNING_CONTENT, MENU_DIALOG_HELP_SCANNING_CONTENT); -} - -static int action_ok_help_change_virtual_gamepad(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_help(path, label, type, idx, entry_idx, - MENU_ENUM_LABEL_HELP_CHANGE_VIRTUAL_GAMEPAD, - MENU_DIALOG_HELP_CHANGE_VIRTUAL_GAMEPAD); -} - -static int action_ok_help_load_content(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_help(path, label, type, idx, entry_idx, - MENU_ENUM_LABEL_HELP_LOADING_CONTENT, MENU_DIALOG_HELP_LOADING_CONTENT); -} +default_action_ok_help(action_ok_help_audio_video_troubleshooting, MENU_ENUM_LABEL_HELP_AUDIO_VIDEO_TROUBLESHOOTING, MENU_DIALOG_HELP_AUDIO_VIDEO_TROUBLESHOOTING) +default_action_ok_help(action_ok_help, MENU_ENUM_LABEL_HELP, MENU_DIALOG_WELCOME) +default_action_ok_help(action_ok_help_controls, MENU_ENUM_LABEL_HELP_CONTROLS, MENU_DIALOG_HELP_CONTROLS) +default_action_ok_help(action_ok_help_what_is_a_core, MENU_ENUM_LABEL_HELP_WHAT_IS_A_CORE, MENU_DIALOG_HELP_WHAT_IS_A_CORE) +default_action_ok_help(action_ok_help_scanning_content, MENU_ENUM_LABEL_HELP_SCANNING_CONTENT, MENU_DIALOG_HELP_SCANNING_CONTENT) +default_action_ok_help(action_ok_help_change_virtual_gamepad, MENU_ENUM_LABEL_HELP_CHANGE_VIRTUAL_GAMEPAD, MENU_DIALOG_HELP_CHANGE_VIRTUAL_GAMEPAD) +default_action_ok_help(action_ok_help_load_content, MENU_ENUM_LABEL_HELP_LOADING_CONTENT, MENU_DIALOG_HELP_LOADING_CONTENT) static int action_ok_video_resolution(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) From 1dab4a7f83204eacd81813019d18ac981c99ccf0 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 26 Nov 2017 07:04:05 +0100 Subject: [PATCH 011/394] Cut dowon on code duplication --- menu/cbs/menu_cbs_ok.c | 113 +++++++---------------------------------- 1 file changed, 18 insertions(+), 95 deletions(-) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 79acc07077..51b784c505 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -2909,103 +2909,26 @@ static int action_ok_core_content_download(const char *path, MENU_ENUM_LABEL_CB_CORE_CONTENT_DOWNLOAD); } -static int action_ok_core_content_thumbnails(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return action_ok_download_generic(path, label, NULL, type, idx, entry_idx, - MENU_ENUM_LABEL_CB_CORE_THUMBNAILS_DOWNLOAD); +#define default_action_ok_download(funcname, _id) \ +static int (funcname)(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) \ +{ \ + return action_ok_download_generic(path, label, NULL, type, idx, entry_idx,_id); \ } -static int action_ok_thumbnails_updater_download(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return action_ok_download_generic(path, label, NULL, type, idx, entry_idx, - MENU_ENUM_LABEL_CB_THUMBNAILS_UPDATER_DOWNLOAD); -} - -static int action_ok_download_url(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return action_ok_download_generic(path, label, NULL, type, idx, entry_idx, - MENU_ENUM_LABEL_CB_DOWNLOAD_URL); -} - -static int action_ok_core_updater_download(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return action_ok_download_generic(path, label, NULL, type, idx, entry_idx, - MENU_ENUM_LABEL_CB_CORE_UPDATER_DOWNLOAD); -} - -static int action_ok_lakka_download(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return action_ok_download_generic(path, label, NULL, type, idx, entry_idx, - MENU_ENUM_LABEL_CB_LAKKA_DOWNLOAD); -} - -static int action_ok_update_assets(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return action_ok_download_generic(path, label, NULL, type, idx, entry_idx, - MENU_ENUM_LABEL_CB_UPDATE_ASSETS); -} - -static int action_ok_update_core_info_files(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return action_ok_download_generic(path, label, NULL, type, idx, entry_idx, - MENU_ENUM_LABEL_CB_UPDATE_CORE_INFO_FILES); -} - -static int action_ok_update_overlays(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return action_ok_download_generic(path, label, NULL, type, idx, entry_idx, - MENU_ENUM_LABEL_CB_UPDATE_OVERLAYS); -} - -static int action_ok_update_shaders_cg(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return action_ok_download_generic(path, label, NULL, type, idx, entry_idx, - MENU_ENUM_LABEL_CB_UPDATE_SHADERS_CG); -} - -static int action_ok_update_shaders_glsl(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return action_ok_download_generic(path, label, NULL, type, idx, entry_idx, - MENU_ENUM_LABEL_CB_UPDATE_SHADERS_GLSL); -} - -static int action_ok_update_shaders_slang(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return action_ok_download_generic(path, label, NULL, type, idx, entry_idx, - MENU_ENUM_LABEL_CB_UPDATE_SHADERS_SLANG); -} - -static int action_ok_update_databases(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return action_ok_download_generic(path, label, NULL, type, idx, entry_idx, - MENU_ENUM_LABEL_CB_UPDATE_DATABASES); -} - -static int action_ok_update_cheats(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return action_ok_download_generic(path, label, NULL, type, idx, entry_idx, - MENU_ENUM_LABEL_CB_UPDATE_CHEATS); -} - -static int action_ok_update_autoconfig_profiles(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return action_ok_download_generic(path, label, NULL, type, idx, entry_idx, - MENU_ENUM_LABEL_CB_UPDATE_AUTOCONFIG_PROFILES); -} +default_action_ok_download(action_ok_core_content_thumbnails, MENU_ENUM_LABEL_CB_CORE_THUMBNAILS_DOWNLOAD) +default_action_ok_download(action_ok_thumbnails_updater_download, MENU_ENUM_LABEL_CB_THUMBNAILS_UPDATER_DOWNLOAD) +default_action_ok_download(action_ok_download_url, MENU_ENUM_LABEL_CB_DOWNLOAD_URL) +default_action_ok_download(action_ok_core_updater_download, MENU_ENUM_LABEL_CB_CORE_UPDATER_DOWNLOAD) +default_action_ok_download(action_ok_lakka_download, MENU_ENUM_LABEL_CB_LAKKA_DOWNLOAD) +default_action_ok_download(action_ok_update_assets, MENU_ENUM_LABEL_CB_UPDATE_ASSETS) +default_action_ok_download(action_ok_update_core_info_files, MENU_ENUM_LABEL_CB_UPDATE_CORE_INFO_FILES) +default_action_ok_download(action_ok_update_overlays, MENU_ENUM_LABEL_CB_UPDATE_OVERLAYS) +default_action_ok_download(action_ok_update_shaders_cg, MENU_ENUM_LABEL_CB_UPDATE_SHADERS_CG) +default_action_ok_download(action_ok_update_shaders_glsl, MENU_ENUM_LABEL_CB_UPDATE_SHADERS_GLSL) +default_action_ok_download(action_ok_update_shaders_slang, MENU_ENUM_LABEL_CB_UPDATE_SHADERS_SLANG) +default_action_ok_download(action_ok_update_databases, MENU_ENUM_LABEL_CB_UPDATE_DATABASES) +default_action_ok_download(action_ok_update_cheats, MENU_ENUM_LABEL_CB_UPDATE_CHEATS) +default_action_ok_download(action_ok_update_autoconfig_profiles, MENU_ENUM_LABEL_CB_UPDATE_AUTOCONFIG_PROFILES) /* creates folder and core options stub file for subsequent runs */ static int action_ok_option_create(const char *path, From ec92edb998cb7c1b591b6dd798bf1f487f472d5e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 26 Nov 2017 07:10:18 +0100 Subject: [PATCH 012/394] Cut down on code duplication --- menu/cbs/menu_cbs_ok.c | 35 ++++++++++------------------------- 1 file changed, 10 insertions(+), 25 deletions(-) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 51b784c505..1f92d5143b 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -3293,33 +3293,18 @@ static int action_ok_netplay_lan_scan(const char *path, return -1; } -static int action_ok_content_collection_list(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - filebrowser_set_type(FILEBROWSER_SELECT_COLLECTION); - return generic_action_ok_displaylist_push(path, NULL, label, type, idx, - entry_idx, ACTION_OK_DL_CONTENT_COLLECTION_LIST); +#define default_action_ok_dl_push(funcname, _fbid, _id, _path) \ +static int (funcname)(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) \ +{ \ + settings_t *settings = config_get_ptr(); \ + (void)settings; \ + filebrowser_set_type(_fbid); \ + return generic_action_ok_displaylist_push(path, _path, label, type, idx, entry_idx, _id); \ } -static int action_ok_push_content_list(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - settings_t *settings = config_get_ptr(); - filebrowser_set_type(FILEBROWSER_SELECT_FILE); - return generic_action_ok_displaylist_push(path, - settings->paths.directory_menu_content, label, type, idx, - entry_idx, ACTION_OK_DL_CONTENT_LIST); -} - -static int action_ok_push_scan_file(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - settings_t *settings = config_get_ptr(); - filebrowser_set_type(FILEBROWSER_SCAN_FILE); - return generic_action_ok_displaylist_push(path, - settings->paths.directory_menu_content, label, type, idx, - entry_idx, ACTION_OK_DL_CONTENT_LIST); -} +default_action_ok_dl_push(action_ok_content_collection_list, FILEBROWSER_SELECT_COLLECTION, ACTION_OK_DL_CONTENT_COLLECTION_LIST, NULL) +default_action_ok_dl_push(action_ok_push_content_list, FILEBROWSER_SELECT_FILE, ACTION_OK_DL_CONTENT_LIST, settings->paths.directory_menu_content) +default_action_ok_dl_push(action_ok_push_scan_file, FILEBROWSER_SCAN_FILE, ACTION_OK_DL_CONTENT_LIST, settings->paths.directory_menu_content) #ifdef HAVE_NETWORKING struct netplay_host_list *lan_hosts; From e049b51a21e68fc2536d84785c0c3c90946e19da Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 26 Nov 2017 07:17:31 +0100 Subject: [PATCH 013/394] Cleanup --- menu/cbs/menu_cbs_ok.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 1f92d5143b..dd42d52f35 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -1751,12 +1751,6 @@ static int action_ok_playlist_entry_start_content(const char *path, return 0; } -static int action_ok_cheat_apply_changes(const char *path, - const char *label, unsigned type, size_t idx, size_t entry_idx) -{ - return generic_action_ok_command(CMD_EVENT_CHEATS_APPLY); -} - static int action_ok_lookup_setting(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { @@ -2981,6 +2975,7 @@ int (func_name)(const char *path, const char *label, unsigned type, size_t idx, return generic_action_ok_command(cmd); \ } +default_action_ok_cmd_func(action_ok_cheat_apply_changes,CMD_EVENT_CHEATS_APPLY) default_action_ok_cmd_func(action_ok_quit, CMD_EVENT_QUIT) default_action_ok_cmd_func(action_ok_save_new_config, CMD_EVENT_MENU_SAVE_CONFIG) default_action_ok_cmd_func(action_ok_resume_content, CMD_EVENT_RESUME) @@ -3607,7 +3602,8 @@ static int action_ok_push_downloads_dir(const char *path, settings_t *settings = config_get_ptr(); filebrowser_set_type(FILEBROWSER_SELECT_FILE); - return generic_action_ok_displaylist_push(path, settings->paths.directory_core_assets, + return generic_action_ok_displaylist_push(path, + settings->paths.directory_core_assets, msg_hash_to_str(MENU_ENUM_LABEL_FAVORITES), type, idx, entry_idx, ACTION_OK_DL_CONTENT_LIST); @@ -3928,7 +3924,12 @@ static int action_ok_netplay_disconnect(const char *path, static int action_ok_core_delete(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { - char* core_path = strdup(path_get(RARCH_PATH_CORE)); + const char *path_core = path_get(RARCH_PATH_CORE); + char *core_path = !string_is_empty(path_core) + ? strdup(path_core) : NULL; + + if (!core_path) + return 0; generic_action_ok_command(CMD_EVENT_UNLOAD_CORE); menu_entries_flush_stack(0, 0); From 064ad8145a449cb6647a4d4c53aa4ec41bedb1ff Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 26 Nov 2017 07:29:19 +0100 Subject: [PATCH 014/394] Cut down on code duplication --- menu/cbs/menu_cbs_ok.c | 108 +++++++++-------------------------------- 1 file changed, 22 insertions(+), 86 deletions(-) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index dd42d52f35..fc004a9d32 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -1361,6 +1361,19 @@ error: return menu_cbs_exit(); } +static int default_action_ok_load_content_with_core_from_menu(const char *_path, unsigned _type) +{ + content_ctx_info_t content_info; + content_info.argc = 0; + content_info.argv = NULL; + content_info.args = NULL; + content_info.environ_get = NULL; + if (!task_push_load_content_with_core_from_menu(_path, &content_info, _type, NULL, NULL)) + return -1; + return 0; +} + + #define default_action_ok_set(funcname, _id, _flush) \ static int (funcname)(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) \ { \ @@ -1385,17 +1398,11 @@ static int action_ok_file_load(const char *path, { char menu_path_new[PATH_MAX_LENGTH]; char full_path_new[PATH_MAX_LENGTH]; - content_ctx_info_t content_info; const char *menu_label = NULL; const char *menu_path = NULL; rarch_setting_t *setting = NULL; file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(0); - content_info.argc = 0; - content_info.argv = NULL; - content_info.args = NULL; - content_info.environ_get = NULL; - menu_path_new[0] = full_path_new[0] = '\0'; file_list_get_last(menu_stack, &menu_path, &menu_label, NULL, NULL); @@ -1440,14 +1447,8 @@ static int action_ok_file_load(const char *path, break; } - if (!task_push_load_content_with_core_from_menu( - full_path_new, - &content_info, - CORE_TYPE_PLAIN, - NULL, NULL)) - return -1; - - return 0; + return default_action_ok_load_content_with_core_from_menu(full_path_new, + CORE_TYPE_PLAIN); } @@ -2326,31 +2327,18 @@ static int action_ok_file_load_ffmpeg(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { char new_path[PATH_MAX_LENGTH]; - content_ctx_info_t content_info; - const char *menu_path = NULL; file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(0); + file_list_get_last(menu_stack, &menu_path, NULL, NULL, NULL); new_path[0] = '\0'; - content_info.argc = 0; - content_info.argv = NULL; - content_info.args = NULL; - content_info.environ_get = NULL; - if (!string_is_empty(menu_path)) fill_pathname_join(new_path, menu_path, path, sizeof(new_path)); - if (!task_push_load_content_with_core_from_menu( - new_path, - &content_info, - CORE_TYPE_FFMPEG, - NULL, NULL)) - return -1; - - return 0; + return default_action_ok_load_content_with_core_from_menu(new_path, CORE_TYPE_FFMPEG); } #endif @@ -2358,7 +2346,6 @@ static int action_ok_audio_run(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { char combined_path[PATH_MAX_LENGTH]; - content_ctx_info_t content_info; menu_handle_t *menu = NULL; combined_path[0] = '\0'; @@ -2369,26 +2356,13 @@ static int action_ok_audio_run(const char *path, fill_pathname_join(combined_path, menu->scratch2_buf, menu->scratch_buf, sizeof(combined_path)); - content_info.argc = 0; - content_info.argv = NULL; - content_info.args = NULL; - content_info.environ_get = NULL; - - if (!task_push_load_content_with_core_from_menu( - combined_path, - &content_info, - CORE_TYPE_FFMPEG, - NULL, NULL)) - return -1; - - return 0; + return default_action_ok_load_content_with_core_from_menu(combined_path, CORE_TYPE_FFMPEG); } static int action_ok_file_load_imageviewer(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { char fullpath[PATH_MAX_LENGTH]; - content_ctx_info_t content_info; const char *menu_path = NULL; file_list_t *menu_stack = menu_entries_get_menu_stack_ptr(0); @@ -2396,43 +2370,17 @@ static int action_ok_file_load_imageviewer(const char *path, fullpath[0] = '\0'; - content_info.argc = 0; - content_info.argv = NULL; - content_info.args = NULL; - content_info.environ_get = NULL; - if (!string_is_empty(menu_path)) fill_pathname_join(fullpath, menu_path, path, sizeof(fullpath)); - if (!task_push_load_content_with_core_from_menu( - fullpath, - &content_info, - CORE_TYPE_IMAGEVIEWER, - NULL, NULL)) - return -1; - - return 0; + return default_action_ok_load_content_with_core_from_menu(fullpath, CORE_TYPE_IMAGEVIEWER); } static int action_ok_file_load_current_core(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { - content_ctx_info_t content_info; - - content_info.argc = 0; - content_info.argv = NULL; - content_info.args = NULL; - content_info.environ_get = NULL; - - if (!task_push_load_content_with_core_from_menu( - detect_content_path, - &content_info, - CORE_TYPE_PLAIN, - NULL, NULL)) - return -1; - - return 0; + return default_action_ok_load_content_with_core_from_menu(detect_content_path, CORE_TYPE_PLAIN); } static int action_ok_file_load_detect_core(const char *path, @@ -3654,17 +3602,10 @@ static int action_ok_start_core(const char *path, static int action_ok_load_archive(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { - content_ctx_info_t content_info; - menu_handle_t *menu = NULL; const char *menu_path = NULL; const char *content_path = NULL; - content_info.argc = 0; - content_info.argv = NULL; - content_info.args = NULL; - content_info.environ_get = NULL; - if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu)) return menu_cbs_exit(); @@ -3676,14 +3617,9 @@ static int action_ok_load_archive(const char *path, generic_action_ok_command(CMD_EVENT_LOAD_CORE); - if (!task_push_load_content_with_core_from_menu( + return default_action_ok_load_content_with_core_from_menu( detect_content_path, - &content_info, - CORE_TYPE_PLAIN, - NULL, NULL)) - return -1; - - return 0; + CORE_TYPE_PLAIN); } static int action_ok_load_archive_detect_core(const char *path, From 66c7eccd91650f13054e5b68e9c2f322e544dd68 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 26 Nov 2017 07:35:06 +0100 Subject: [PATCH 015/394] Cut down on code duplication --- menu/cbs/menu_cbs_ok.c | 58 +++++++++++++----------------------------- 1 file changed, 18 insertions(+), 40 deletions(-) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index fc004a9d32..638d0e40ce 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -1373,6 +1373,21 @@ static int default_action_ok_load_content_with_core_from_menu(const char *_path, return 0; } +static int default_action_ok_load_content_from_playlist_from_menu(const char *_path, const char *path, const char *entry_label) +{ + content_ctx_info_t content_info; + content_info.argc = 0; + content_info.argv = NULL; + content_info.args = NULL; + content_info.environ_get = NULL; + if (!task_push_load_content_from_playlist_from_menu( + _path, path, entry_label, + &content_info, + NULL, NULL)) + return -1; + return 0; +} + #define default_action_ok_set(funcname, _id, _flush) \ static int (funcname)(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) \ @@ -1457,7 +1472,6 @@ static int action_ok_playlist_entry_collection(const char *path, { menu_content_ctx_playlist_info_t playlist_info; char new_core_path[PATH_MAX_LENGTH]; - content_ctx_info_t content_info; size_t selection_ptr = 0; bool playlist_initialized = false; playlist_t *playlist = NULL; @@ -1470,11 +1484,6 @@ static int action_ok_playlist_entry_collection(const char *path, rarch_system_info_t *info = runloop_get_system_info(); struct retro_system_info *system = &info->info; - content_info.argc = 0; - content_info.argv = NULL; - content_info.args = NULL; - content_info.environ_get = NULL; - if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu)) return menu_cbs_exit(); @@ -1552,21 +1561,13 @@ static int action_ok_playlist_entry_collection(const char *path, playlist_get_index(playlist, playlist_info.idx, &path, NULL, NULL, NULL, NULL, NULL); - - if (!task_push_load_content_from_playlist_from_menu( - new_core_path, path, entry_label, - &content_info, - NULL, NULL)) - return -1; - - return 0; + return default_action_ok_load_content_from_playlist_from_menu(new_core_path, path, entry_label); } static int action_ok_playlist_entry(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { menu_content_ctx_playlist_info_t playlist_info; - content_ctx_info_t content_info; char new_core_path[PATH_MAX_LENGTH]; size_t selection_ptr = 0; playlist_t *playlist = g_defaults.content_history; @@ -1576,11 +1577,6 @@ static int action_ok_playlist_entry(const char *path, const char *core_name = NULL; menu_handle_t *menu = NULL; - content_info.argc = 0; - content_info.argv = NULL; - content_info.args = NULL; - content_info.environ_get = NULL; - new_core_path[0] = '\0'; if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu)) @@ -1638,20 +1634,13 @@ static int action_ok_playlist_entry(const char *path, playlist_info.idx, &path, NULL, NULL, NULL, NULL, NULL); - if (!task_push_load_content_from_playlist_from_menu( - new_core_path, path, entry_label, - &content_info, - NULL, NULL)) - return -1; - - return 0; + return default_action_ok_load_content_from_playlist_from_menu(new_core_path, path, entry_label); } static int action_ok_playlist_entry_start_content(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { menu_content_ctx_playlist_info_t playlist_info; - content_ctx_info_t content_info; size_t selection_ptr = 0; bool playlist_initialized = false; playlist_t *playlist = NULL; @@ -1662,11 +1651,6 @@ static int action_ok_playlist_entry_start_content(const char *path, playlist_t *tmp_playlist = NULL; menu_handle_t *menu = NULL; - content_info.argc = 0; - content_info.argv = NULL; - content_info.args = NULL; - content_info.environ_get = NULL; - if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu)) return menu_cbs_exit(); @@ -1743,13 +1727,7 @@ static int action_ok_playlist_entry_start_content(const char *path, playlist_get_index(playlist, playlist_info.idx, &path, NULL, NULL, NULL, NULL, NULL); - if (!task_push_load_content_from_playlist_from_menu( - core_path, path, entry_label, - &content_info, - NULL, NULL)) - return -1; - - return 0; + return default_action_ok_load_content_from_playlist_from_menu(core_path, path, entry_label); } static int action_ok_lookup_setting(const char *path, From b190ac1943d57fc290656f1a84acdb2352182828 Mon Sep 17 00:00:00 2001 From: David Walters Date: Sun, 26 Nov 2017 11:49:37 +0000 Subject: [PATCH 016/394] Add 'mbutton' field to retro_keybind struct --- config.def.keybinds.h | 293 +++++++++++++++++++++--------------------- input/input_driver.h | 2 + 2 files changed, 150 insertions(+), 145 deletions(-) diff --git a/config.def.keybinds.h b/config.def.keybinds.h index 5ed2203f51..6a999a0e32 100644 --- a/config.def.keybinds.h +++ b/config.def.keybinds.h @@ -22,163 +22,166 @@ /* User 1 */ static const struct retro_keybind retro_keybinds_1[] = { - /* | RetroPad button | enum | keyboard key | js btn | js axis | */ + /* | RetroPad button | enum | keyboard key | m-btn | js btn | js axis | */ #ifdef __QNX__ - { true, RETRO_DEVICE_ID_JOYPAD_B, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_B, RETROK_k, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_Y, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, RETROK_i, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_SELECT, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_SELECT, RETROK_v, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_START, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_START, RETROK_b, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_UP, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_UP, RETROK_e, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_DOWN, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_DOWN, RETROK_s, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_LEFT, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_LEFT, RETROK_w, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_RIGHT, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_RIGHT, RETROK_d, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_A, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_A, RETROK_l, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_X, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_X, RETROK_o, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_L, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L, RETROK_f, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_R, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R, RETROK_j, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_L2, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L2, RETROK_r, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_R2, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R2, RETROK_u, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_L3, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L3, RETROK_g, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_R3, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R3, RETROK_h, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_B, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_B, RETROK_k, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_Y, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, RETROK_i, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_SELECT, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_SELECT, RETROK_v, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_START, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_START, RETROK_b, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_UP, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_UP, RETROK_e, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_DOWN, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_DOWN, RETROK_s, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_LEFT, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_LEFT, RETROK_w, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_RIGHT, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_RIGHT, RETROK_d, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_A, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_A, RETROK_l, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_X, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_X, RETROK_o, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_L, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L, RETROK_f, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_R, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R, RETROK_j, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_L2, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L2, RETROK_r, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_R2, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R2, RETROK_u, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_L3, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L3, RETROK_g, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_R3, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R3, RETROK_h, NO_BTN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_ANALOG_LEFT_X_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_X_PLUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_ANALOG_LEFT_X_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_X_MINUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_ANALOG_LEFT_Y_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_Y_PLUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_ANALOG_LEFT_Y_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_Y_MINUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_ANALOG_RIGHT_X_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_X_PLUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_ANALOG_RIGHT_X_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_X_MINUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_ANALOG_RIGHT_Y_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_PLUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_ANALOG_RIGHT_Y_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_ANALOG_LEFT_X_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_X_PLUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_ANALOG_LEFT_X_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_X_MINUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_ANALOG_LEFT_Y_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_Y_PLUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_ANALOG_LEFT_Y_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_Y_MINUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_ANALOG_RIGHT_X_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_X_PLUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_ANALOG_RIGHT_X_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_X_MINUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_ANALOG_RIGHT_Y_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_PLUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_ANALOG_RIGHT_Y_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_TURBO_ENABLE, MENU_ENUM_LABEL_VALUE_INPUT_TURBO_ENABLE, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_FAST_FORWARD_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_FAST_FORWARD_KEY, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_FAST_FORWARD_HOLD_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_FAST_FORWARD_HOLD_KEY,RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_LOAD_STATE_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_LOAD_STATE_KEY, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_SAVE_STATE_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_SAVE_STATE_KEY, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_FULLSCREEN_TOGGLE_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_FULLSCREEN_TOGGLE_KEY,RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_QUIT_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_QUIT_KEY, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_STATE_SLOT_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_META_STATE_SLOT_PLUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_STATE_SLOT_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_META_STATE_SLOT_MINUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_REWIND, MENU_ENUM_LABEL_VALUE_INPUT_META_REWIND, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_MOVIE_RECORD_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_MOVIE_RECORD_TOGGLE, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_PAUSE_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_PAUSE_TOGGLE, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_FRAMEADVANCE, MENU_ENUM_LABEL_VALUE_INPUT_META_FRAMEADVANCE, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_RESET, MENU_ENUM_LABEL_VALUE_INPUT_META_RESET, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_SHADER_NEXT, MENU_ENUM_LABEL_VALUE_INPUT_META_SHADER_NEXT, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_SHADER_PREV, MENU_ENUM_LABEL_VALUE_INPUT_META_SHADER_PREV, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_CHEAT_INDEX_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_META_CHEAT_INDEX_PLUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_CHEAT_INDEX_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_META_CHEAT_INDEX_MINUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_CHEAT_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_CHEAT_TOGGLE, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_SCREENSHOT, MENU_ENUM_LABEL_VALUE_INPUT_META_SCREENSHOT, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_MUTE, MENU_ENUM_LABEL_VALUE_INPUT_META_MUTE, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_OSK, MENU_ENUM_LABEL_VALUE_INPUT_META_OSK, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_NETPLAY_FLIP, MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_FLIP, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_NETPLAY_GAME_WATCH, MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_GAME_WATCH, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_SLOWMOTION, MENU_ENUM_LABEL_VALUE_INPUT_META_SLOWMOTION, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_ENABLE_HOTKEY, MENU_ENUM_LABEL_VALUE_INPUT_META_ENABLE_HOTKEY, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_VOLUME_UP, MENU_ENUM_LABEL_VALUE_INPUT_META_VOLUME_UP, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_VOLUME_DOWN, MENU_ENUM_LABEL_VALUE_INPUT_META_VOLUME_DOWN, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_OVERLAY_NEXT, MENU_ENUM_LABEL_VALUE_INPUT_META_OVERLAY_NEXT, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_DISK_EJECT_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_DISK_EJECT_TOGGLE, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_DISK_NEXT, MENU_ENUM_LABEL_VALUE_INPUT_META_DISK_NEXT, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_DISK_PREV, MENU_ENUM_LABEL_VALUE_INPUT_META_DISK_PREV, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_GRAB_MOUSE_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_GRAB_MOUSE_TOGGLE, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_GAME_FOCUS_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_GAME_FOCUS_TOGGLE, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_MENU_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_MENU_TOGGLE, RETROK_SPACE, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_TURBO_ENABLE, MENU_ENUM_LABEL_VALUE_INPUT_TURBO_ENABLE, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + + { true, RARCH_FAST_FORWARD_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_FAST_FORWARD_KEY, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_FAST_FORWARD_HOLD_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_FAST_FORWARD_HOLD_KEY,RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LOAD_STATE_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_LOAD_STATE_KEY, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_SAVE_STATE_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_SAVE_STATE_KEY, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_FULLSCREEN_TOGGLE_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_FULLSCREEN_TOGGLE_KEY,RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_QUIT_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_QUIT_KEY, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_STATE_SLOT_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_META_STATE_SLOT_PLUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_STATE_SLOT_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_META_STATE_SLOT_MINUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_REWIND, MENU_ENUM_LABEL_VALUE_INPUT_META_REWIND, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_MOVIE_RECORD_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_MOVIE_RECORD_TOGGLE, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_PAUSE_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_PAUSE_TOGGLE, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_FRAMEADVANCE, MENU_ENUM_LABEL_VALUE_INPUT_META_FRAMEADVANCE, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_RESET, MENU_ENUM_LABEL_VALUE_INPUT_META_RESET, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_SHADER_NEXT, MENU_ENUM_LABEL_VALUE_INPUT_META_SHADER_NEXT, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_SHADER_PREV, MENU_ENUM_LABEL_VALUE_INPUT_META_SHADER_PREV, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_CHEAT_INDEX_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_META_CHEAT_INDEX_PLUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_CHEAT_INDEX_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_META_CHEAT_INDEX_MINUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_CHEAT_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_CHEAT_TOGGLE, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_SCREENSHOT, MENU_ENUM_LABEL_VALUE_INPUT_META_SCREENSHOT, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_MUTE, MENU_ENUM_LABEL_VALUE_INPUT_META_MUTE, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_OSK, MENU_ENUM_LABEL_VALUE_INPUT_META_OSK, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_NETPLAY_FLIP, MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_FLIP, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_NETPLAY_GAME_WATCH, MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_GAME_WATCH, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_SLOWMOTION, MENU_ENUM_LABEL_VALUE_INPUT_META_SLOWMOTION, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_ENABLE_HOTKEY, MENU_ENUM_LABEL_VALUE_INPUT_META_ENABLE_HOTKEY, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_VOLUME_UP, MENU_ENUM_LABEL_VALUE_INPUT_META_VOLUME_UP, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_VOLUME_DOWN, MENU_ENUM_LABEL_VALUE_INPUT_META_VOLUME_DOWN, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_OVERLAY_NEXT, MENU_ENUM_LABEL_VALUE_INPUT_META_OVERLAY_NEXT, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_DISK_EJECT_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_DISK_EJECT_TOGGLE, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_DISK_NEXT, MENU_ENUM_LABEL_VALUE_INPUT_META_DISK_NEXT, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_DISK_PREV, MENU_ENUM_LABEL_VALUE_INPUT_META_DISK_PREV, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_GRAB_MOUSE_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_GRAB_MOUSE_TOGGLE, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_GAME_FOCUS_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_GAME_FOCUS_TOGGLE, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_MENU_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_MENU_TOGGLE, RETROK_SPACE, NO_BTN, NO_BTN, 0, AXIS_NONE }, #else - { true, RETRO_DEVICE_ID_JOYPAD_B, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_B, RETROK_z, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_Y, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, RETROK_a, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_SELECT, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_SELECT, RETROK_RSHIFT, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_START, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_START, RETROK_RETURN, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_UP, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_UP, RETROK_UP, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_DOWN, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_DOWN, RETROK_DOWN, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_LEFT, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_LEFT, RETROK_LEFT, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_RIGHT, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_RIGHT, RETROK_RIGHT, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_A, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_A, RETROK_x, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_X, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_X, RETROK_s, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_L, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L, RETROK_q, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_R, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R, RETROK_w, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_L2, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L2, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_R2, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R2, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_L3, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L3, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_R3, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R3, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_B, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_B, RETROK_z, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_Y, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, RETROK_a, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_SELECT, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_SELECT, RETROK_RSHIFT, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_START, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_START, RETROK_RETURN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_UP, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_UP, RETROK_UP, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_DOWN, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_DOWN, RETROK_DOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_LEFT, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_LEFT, RETROK_LEFT, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_RIGHT, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_RIGHT, RETROK_RIGHT, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_A, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_A, RETROK_x, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_X, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_X, RETROK_s, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_L, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L, RETROK_q, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_R, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R, RETROK_w, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_L2, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L2, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_R2, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R2, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_L3, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L3, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_R3, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R3, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_ANALOG_LEFT_X_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_X_PLUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_ANALOG_LEFT_X_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_X_MINUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_ANALOG_LEFT_Y_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_Y_PLUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_ANALOG_LEFT_Y_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_Y_MINUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_ANALOG_RIGHT_X_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_X_PLUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_ANALOG_RIGHT_X_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_X_MINUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_ANALOG_RIGHT_Y_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_PLUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_ANALOG_RIGHT_Y_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_ANALOG_LEFT_X_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_X_PLUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_ANALOG_LEFT_X_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_X_MINUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_ANALOG_LEFT_Y_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_Y_PLUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_ANALOG_LEFT_Y_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_Y_MINUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_ANALOG_RIGHT_X_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_X_PLUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_ANALOG_RIGHT_X_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_X_MINUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_ANALOG_RIGHT_Y_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_PLUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_ANALOG_RIGHT_Y_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_TURBO_ENABLE, MENU_ENUM_LABEL_VALUE_INPUT_TURBO_ENABLE, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_FAST_FORWARD_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_FAST_FORWARD_KEY, RETROK_SPACE, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_FAST_FORWARD_HOLD_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_FAST_FORWARD_HOLD_KEY,RETROK_l, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_LOAD_STATE_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_LOAD_STATE_KEY, RETROK_F4, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_SAVE_STATE_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_SAVE_STATE_KEY, RETROK_F2, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_FULLSCREEN_TOGGLE_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_FULLSCREEN_TOGGLE_KEY,RETROK_f, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_QUIT_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_QUIT_KEY, RETROK_ESCAPE, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_STATE_SLOT_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_META_STATE_SLOT_PLUS, RETROK_F7, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_STATE_SLOT_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_META_STATE_SLOT_MINUS, RETROK_F6, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_REWIND, MENU_ENUM_LABEL_VALUE_INPUT_META_REWIND, RETROK_r, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_MOVIE_RECORD_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_MOVIE_RECORD_TOGGLE, RETROK_o, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_PAUSE_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_PAUSE_TOGGLE, RETROK_p, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_FRAMEADVANCE, MENU_ENUM_LABEL_VALUE_INPUT_META_FRAMEADVANCE, RETROK_k, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_RESET, MENU_ENUM_LABEL_VALUE_INPUT_META_RESET, RETROK_h, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_SHADER_NEXT, MENU_ENUM_LABEL_VALUE_INPUT_META_SHADER_NEXT, RETROK_m, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_SHADER_PREV, MENU_ENUM_LABEL_VALUE_INPUT_META_SHADER_PREV, RETROK_n, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_CHEAT_INDEX_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_META_CHEAT_INDEX_PLUS, RETROK_y, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_CHEAT_INDEX_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_META_CHEAT_INDEX_MINUS, RETROK_t, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_CHEAT_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_CHEAT_TOGGLE, RETROK_u, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_SCREENSHOT, MENU_ENUM_LABEL_VALUE_INPUT_META_SCREENSHOT, RETROK_F8, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_MUTE, MENU_ENUM_LABEL_VALUE_INPUT_META_MUTE, RETROK_F9, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_OSK, MENU_ENUM_LABEL_VALUE_INPUT_META_OSK, RETROK_F12, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_NETPLAY_FLIP, MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_FLIP, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_NETPLAY_GAME_WATCH, MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_GAME_WATCH, RETROK_i, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_SLOWMOTION, MENU_ENUM_LABEL_VALUE_INPUT_META_SLOWMOTION, RETROK_e, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_ENABLE_HOTKEY, MENU_ENUM_LABEL_VALUE_INPUT_META_ENABLE_HOTKEY, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_VOLUME_UP, MENU_ENUM_LABEL_VALUE_INPUT_META_VOLUME_UP, RETROK_KP_PLUS, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_VOLUME_DOWN, MENU_ENUM_LABEL_VALUE_INPUT_META_VOLUME_DOWN, RETROK_KP_MINUS,NO_BTN, 0, AXIS_NONE }, - { true, RARCH_OVERLAY_NEXT, MENU_ENUM_LABEL_VALUE_INPUT_META_OVERLAY_NEXT, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_DISK_EJECT_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_DISK_EJECT_TOGGLE, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_DISK_NEXT, MENU_ENUM_LABEL_VALUE_INPUT_META_DISK_NEXT, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_DISK_PREV, MENU_ENUM_LABEL_VALUE_INPUT_META_DISK_PREV, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_GRAB_MOUSE_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_GRAB_MOUSE_TOGGLE, RETROK_F11, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_GAME_FOCUS_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_GAME_FOCUS_TOGGLE, RETROK_SCROLLOCK, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_MENU_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_MENU_TOGGLE, RETROK_F1, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_TURBO_ENABLE, MENU_ENUM_LABEL_VALUE_INPUT_TURBO_ENABLE, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + + { true, RARCH_FAST_FORWARD_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_FAST_FORWARD_KEY, RETROK_SPACE, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_FAST_FORWARD_HOLD_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_FAST_FORWARD_HOLD_KEY,RETROK_l, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LOAD_STATE_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_LOAD_STATE_KEY, RETROK_F4, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_SAVE_STATE_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_SAVE_STATE_KEY, RETROK_F2, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_FULLSCREEN_TOGGLE_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_FULLSCREEN_TOGGLE_KEY,RETROK_f, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_QUIT_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_QUIT_KEY, RETROK_ESCAPE, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_STATE_SLOT_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_META_STATE_SLOT_PLUS, RETROK_F7, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_STATE_SLOT_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_META_STATE_SLOT_MINUS, RETROK_F6, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_REWIND, MENU_ENUM_LABEL_VALUE_INPUT_META_REWIND, RETROK_r, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_MOVIE_RECORD_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_MOVIE_RECORD_TOGGLE, RETROK_o, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_PAUSE_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_PAUSE_TOGGLE, RETROK_p, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_FRAMEADVANCE, MENU_ENUM_LABEL_VALUE_INPUT_META_FRAMEADVANCE, RETROK_k, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_RESET, MENU_ENUM_LABEL_VALUE_INPUT_META_RESET, RETROK_h, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_SHADER_NEXT, MENU_ENUM_LABEL_VALUE_INPUT_META_SHADER_NEXT, RETROK_m, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_SHADER_PREV, MENU_ENUM_LABEL_VALUE_INPUT_META_SHADER_PREV, RETROK_n, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_CHEAT_INDEX_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_META_CHEAT_INDEX_PLUS, RETROK_y, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_CHEAT_INDEX_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_META_CHEAT_INDEX_MINUS, RETROK_t, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_CHEAT_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_CHEAT_TOGGLE, RETROK_u, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_SCREENSHOT, MENU_ENUM_LABEL_VALUE_INPUT_META_SCREENSHOT, RETROK_F8, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_MUTE, MENU_ENUM_LABEL_VALUE_INPUT_META_MUTE, RETROK_F9, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_OSK, MENU_ENUM_LABEL_VALUE_INPUT_META_OSK, RETROK_F12, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_NETPLAY_FLIP, MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_FLIP, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_NETPLAY_GAME_WATCH, MENU_ENUM_LABEL_VALUE_INPUT_META_NETPLAY_GAME_WATCH, RETROK_i, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_SLOWMOTION, MENU_ENUM_LABEL_VALUE_INPUT_META_SLOWMOTION, RETROK_e, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_ENABLE_HOTKEY, MENU_ENUM_LABEL_VALUE_INPUT_META_ENABLE_HOTKEY, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_VOLUME_UP, MENU_ENUM_LABEL_VALUE_INPUT_META_VOLUME_UP, RETROK_KP_PLUS, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_VOLUME_DOWN, MENU_ENUM_LABEL_VALUE_INPUT_META_VOLUME_DOWN, RETROK_KP_MINUS,NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_OVERLAY_NEXT, MENU_ENUM_LABEL_VALUE_INPUT_META_OVERLAY_NEXT, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_DISK_EJECT_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_DISK_EJECT_TOGGLE, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_DISK_NEXT, MENU_ENUM_LABEL_VALUE_INPUT_META_DISK_NEXT, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_DISK_PREV, MENU_ENUM_LABEL_VALUE_INPUT_META_DISK_PREV, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_GRAB_MOUSE_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_GRAB_MOUSE_TOGGLE, RETROK_F11, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_GAME_FOCUS_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_GAME_FOCUS_TOGGLE, RETROK_SCROLLOCK, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_MENU_TOGGLE, MENU_ENUM_LABEL_VALUE_INPUT_META_MENU_TOGGLE, RETROK_F1, NO_BTN, NO_BTN, 0, AXIS_NONE }, #endif }; /* Users 2 to MAX_USERS */ static const struct retro_keybind retro_keybinds_rest[] = { - /* | RetroPad button | desc | keyboard key | js btn | js axis | */ - { true, RETRO_DEVICE_ID_JOYPAD_B, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_B, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_Y, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_SELECT, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_SELECT, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_START, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_START, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_UP, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_UP, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_DOWN, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_DOWN, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_LEFT, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_LEFT, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_RIGHT, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_RIGHT, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_A, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_A, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_X, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_X, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_L, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_R, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_L2, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L2, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_R2, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R2, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_L3, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L3, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RETRO_DEVICE_ID_JOYPAD_R3, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R3, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, + /* | RetroPad button | desc | keyboard key | js btn | js axis | */ + { true, RETRO_DEVICE_ID_JOYPAD_B, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_B, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_Y, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_SELECT, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_SELECT, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_START, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_START, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_UP, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_UP, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_DOWN, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_DOWN, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_LEFT, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_LEFT, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_RIGHT, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_RIGHT, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_A, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_A, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_X, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_X, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_L, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_R, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_L2, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L2, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_R2, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R2, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_L3, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L3, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RETRO_DEVICE_ID_JOYPAD_R3, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R3, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_ANALOG_LEFT_X_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_X_PLUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_ANALOG_LEFT_X_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_X_MINUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_ANALOG_LEFT_Y_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_Y_PLUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_ANALOG_LEFT_Y_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_Y_MINUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_ANALOG_RIGHT_X_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_X_PLUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_ANALOG_RIGHT_X_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_X_MINUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_ANALOG_RIGHT_Y_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_PLUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_ANALOG_RIGHT_Y_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, - { true, RARCH_TURBO_ENABLE, MENU_ENUM_LABEL_VALUE_INPUT_TURBO_ENABLE, RETROK_UNKNOWN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_ANALOG_LEFT_X_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_X_PLUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_ANALOG_LEFT_X_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_X_MINUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_ANALOG_LEFT_Y_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_Y_PLUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_ANALOG_LEFT_Y_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_Y_MINUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_ANALOG_RIGHT_X_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_X_PLUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_ANALOG_RIGHT_X_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_X_MINUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_ANALOG_RIGHT_Y_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_PLUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_ANALOG_RIGHT_Y_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + + { true, RARCH_TURBO_ENABLE, MENU_ENUM_LABEL_VALUE_INPUT_TURBO_ENABLE, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, }; #endif diff --git a/input/input_driver.h b/input/input_driver.h index d760e6fe43..215766058c 100644 --- a/input/input_driver.h +++ b/input/input_driver.h @@ -96,6 +96,8 @@ struct retro_keybind enum msg_hash_enums enum_idx; enum retro_key key; + uint16_t mbutton; + /* Joypad key. Joypad POV (hats) * are embedded into this key as well. */ uint64_t joykey; From 56ea1253ffa3736bbe89d818ea152a26a06c7962 Mon Sep 17 00:00:00 2001 From: David Walters Date: Sun, 26 Nov 2017 11:51:07 +0000 Subject: [PATCH 017/394] msg_hash strings for mouse buttons+wheel *English Only* --- intl/msg_hash_chs.h | 18 ++++++++++++++++++ intl/msg_hash_cht.h | 18 ++++++++++++++++++ intl/msg_hash_de.h | 18 ++++++++++++++++++ intl/msg_hash_eo.h | 18 ++++++++++++++++++ intl/msg_hash_fr.h | 18 ++++++++++++++++++ intl/msg_hash_it.h | 18 ++++++++++++++++++ intl/msg_hash_ja.h | 18 ++++++++++++++++++ intl/msg_hash_ko.h | 18 ++++++++++++++++++ intl/msg_hash_nl.h | 18 ++++++++++++++++++ intl/msg_hash_pt_br.h | 18 ++++++++++++++++++ intl/msg_hash_pt_pt.h | 18 ++++++++++++++++++ intl/msg_hash_ru.h | 18 ++++++++++++++++++ intl/msg_hash_us.h | 18 ++++++++++++++++++ intl/msg_hash_vn.h | 18 ++++++++++++++++++ msg_hash.h | 9 +++++++++ 15 files changed, 261 insertions(+) diff --git a/intl/msg_hash_chs.h b/intl/msg_hash_chs.h index 142ffad5d7..db03e7ddd5 100644 --- a/intl/msg_hash_chs.h +++ b/intl/msg_hash_chs.h @@ -744,6 +744,24 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, "Y键(左侧)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEY, "(键: %s)") /*FIXME:"(Key: %s)"*/ +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_LEFT, + "MOUSE1") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_RIGHT, + "MOUSE2") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_MIDDLE, + "MOUSE3") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON4, + "MOUSE4") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON5, + "MOUSE5") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_UP, + "MWHEELUP") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_DOWN, + "MWHEELDN") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_UP, + "MWHEELLEFT") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_DOWN, + "MWHEELRIGHT") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEYBOARD_GAMEPAD_MAPPING_TYPE, "键盘控制器映射类型") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MAX_USERS, diff --git a/intl/msg_hash_cht.h b/intl/msg_hash_cht.h index 9e13d1de7d..6eeed496da 100644 --- a/intl/msg_hash_cht.h +++ b/intl/msg_hash_cht.h @@ -744,6 +744,24 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, "Y鍵(左側)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEY, "(鍵: %s)") /*FIXME:"(Key: %s)"*/ +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_LEFT, + "MOUSE1") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_RIGHT, + "MOUSE2") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_MIDDLE, + "MOUSE3") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON4, + "MOUSE4") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON5, + "MOUSE5") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_UP, + "MWHEELUP") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_DOWN, + "MWHEELDN") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_UP, + "MWHEELLEFT") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_DOWN, + "MWHEELRIGHT") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEYBOARD_GAMEPAD_MAPPING_TYPE, "鍵盤控制器映射類型") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MAX_USERS, diff --git a/intl/msg_hash_de.h b/intl/msg_hash_de.h index 44c710daff..7b8eb52625 100644 --- a/intl/msg_hash_de.h +++ b/intl/msg_hash_de.h @@ -751,6 +751,24 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, "Y-Knopf (links)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEY, "(Taste: %s)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_LEFT, + "MOUSE1") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_RIGHT, + "MOUSE2") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_MIDDLE, + "MOUSE3") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON4, + "MOUSE4") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON5, + "MOUSE5") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_UP, + "MWHEELUP") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_DOWN, + "MWHEELDN") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_UP, + "MWHEELLEFT") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_DOWN, + "MWHEELRIGHT") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEYBOARD_GAMEPAD_MAPPING_TYPE, "Typ der Keyboard-Controller-Abbildung") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MAX_USERS, diff --git a/intl/msg_hash_eo.h b/intl/msg_hash_eo.h index c17db311bb..627cabb0e4 100644 --- a/intl/msg_hash_eo.h +++ b/intl/msg_hash_eo.h @@ -660,6 +660,24 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, "Y button (left)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEY, "(Key: %s)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_LEFT, + "MOUSE1") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_RIGHT, + "MOUSE2") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_MIDDLE, + "MOUSE3") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON4, + "MOUSE4") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON5, + "MOUSE5") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_UP, + "MWHEELUP") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_DOWN, + "MWHEELDN") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_UP, + "MWHEELLEFT") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_DOWN, + "MWHEELRIGHT") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEYBOARD_GAMEPAD_MAPPING_TYPE, "Keyboard Gamepad Mapping Type") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MAX_USERS, diff --git a/intl/msg_hash_fr.h b/intl/msg_hash_fr.h index fa1094a768..ad92c95526 100644 --- a/intl/msg_hash_fr.h +++ b/intl/msg_hash_fr.h @@ -745,6 +745,24 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, "Bouton Y (gauche)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEY, "(Touche : %s)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_LEFT, + "MOUSE1") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_RIGHT, + "MOUSE2") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_MIDDLE, + "MOUSE3") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON4, + "MOUSE4") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON5, + "MOUSE5") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_UP, + "MWHEELUP") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_DOWN, + "MWHEELDN") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_UP, + "MWHEELLEFT") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_DOWN, + "MWHEELRIGHT") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEYBOARD_GAMEPAD_MAPPING_TYPE, "Type de mappage manette/clavier") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MAX_USERS, diff --git a/intl/msg_hash_it.h b/intl/msg_hash_it.h index 2ebdad385b..d8f989e0ae 100644 --- a/intl/msg_hash_it.h +++ b/intl/msg_hash_it.h @@ -751,6 +751,24 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, "Pulsante Y (sinistro)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEY, "(Tasto: %s)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_LEFT, + "MOUSE1") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_RIGHT, + "MOUSE2") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_MIDDLE, + "MOUSE3") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON4, + "MOUSE4") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON5, + "MOUSE5") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_UP, + "MWHEELUP") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_DOWN, + "MWHEELDN") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_UP, + "MWHEELLEFT") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_DOWN, + "MWHEELRIGHT") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEYBOARD_GAMEPAD_MAPPING_TYPE, "Tipo di mappatura del gamepad della tastiera") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MAX_USERS, diff --git a/intl/msg_hash_ja.h b/intl/msg_hash_ja.h index 3c772118af..eb233b64c6 100644 --- a/intl/msg_hash_ja.h +++ b/intl/msg_hash_ja.h @@ -769,6 +769,24 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, "Yボタン(左)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEY, "(キー: %s)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_LEFT, + "MOUSE1") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_RIGHT, + "MOUSE2") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_MIDDLE, + "MOUSE3") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON4, + "MOUSE4") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON5, + "MOUSE5") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_UP, + "MWHEELUP") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_DOWN, + "MWHEELDN") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_UP, + "MWHEELLEFT") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_DOWN, + "MWHEELRIGHT") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEYBOARD_GAMEPAD_MAPPING_TYPE, "キーボードのゲームパッドマッピング式") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MAX_USERS, diff --git a/intl/msg_hash_ko.h b/intl/msg_hash_ko.h index f4e980e451..f05b7b4ceb 100644 --- a/intl/msg_hash_ko.h +++ b/intl/msg_hash_ko.h @@ -731,6 +731,24 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, "Y 버튼 (좌)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEY, "(키: %s)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_LEFT, + "MOUSE1") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_RIGHT, + "MOUSE2") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_MIDDLE, + "MOUSE3") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON4, + "MOUSE4") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON5, + "MOUSE5") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_UP, + "MWHEELUP") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_DOWN, + "MWHEELDN") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_UP, + "MWHEELLEFT") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_DOWN, + "MWHEELRIGHT") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEYBOARD_GAMEPAD_MAPPING_TYPE, "키보드 게임패드 설정 형식") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MAX_USERS, diff --git a/intl/msg_hash_nl.h b/intl/msg_hash_nl.h index d414566d66..aa441fa969 100644 --- a/intl/msg_hash_nl.h +++ b/intl/msg_hash_nl.h @@ -660,6 +660,24 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, "Y knop (left)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEY, "(Key: %s)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_LEFT, + "MOUSE1") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_RIGHT, + "MOUSE2") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_MIDDLE, + "MOUSE3") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON4, + "MOUSE4") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON5, + "MOUSE5") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_UP, + "MWHEELUP") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_DOWN, + "MWHEELDN") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_UP, + "MWHEELLEFT") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_DOWN, + "MWHEELRIGHT") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEYBOARD_GAMEPAD_MAPPING_TYPE, "Keyboard Gamepad Mapping Type") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MAX_USERS, diff --git a/intl/msg_hash_pt_br.h b/intl/msg_hash_pt_br.h index dcaeaebd75..c8ce759e90 100644 --- a/intl/msg_hash_pt_br.h +++ b/intl/msg_hash_pt_br.h @@ -757,6 +757,24 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEY, "(Tecla: %s)" ) +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_LEFT, + "MOUSE1") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_RIGHT, + "MOUSE2") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_MIDDLE, + "MOUSE3") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON4, + "MOUSE4") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON5, + "MOUSE5") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_UP, + "MWHEELUP") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_DOWN, + "MWHEELDN") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_UP, + "MWHEELLEFT") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_DOWN, + "MWHEELRIGHT") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEYBOARD_GAMEPAD_MAPPING_TYPE, "Tipo de Mapeamento para Gamepad no Teclado" ) diff --git a/intl/msg_hash_pt_pt.h b/intl/msg_hash_pt_pt.h index 800463bdc5..bfb5b7cb3a 100644 --- a/intl/msg_hash_pt_pt.h +++ b/intl/msg_hash_pt_pt.h @@ -731,6 +731,24 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, "Botão Y (esquerda)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEY, "(Tecla: %s)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_LEFT, + "MOUSE1") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_RIGHT, + "MOUSE2") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_MIDDLE, + "MOUSE3") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON4, + "MOUSE4") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON5, + "MOUSE5") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_UP, + "MWHEELUP") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_DOWN, + "MWHEELDN") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_UP, + "MWHEELLEFT") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_DOWN, + "MWHEELRIGHT") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEYBOARD_GAMEPAD_MAPPING_TYPE, "Tipo de Mapeamento do Gamepad no Teclado") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MAX_USERS, diff --git a/intl/msg_hash_ru.h b/intl/msg_hash_ru.h index f2e9a9826a..dfa3f024c7 100644 --- a/intl/msg_hash_ru.h +++ b/intl/msg_hash_ru.h @@ -754,6 +754,24 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, "Кнопка Y") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEY, "(Клавиша: %s)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_LEFT, + "MOUSE1") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_RIGHT, + "MOUSE2") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_MIDDLE, + "MOUSE3") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON4, + "MOUSE4") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON5, + "MOUSE5") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_UP, + "MWHEELUP") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_DOWN, + "MWHEELDN") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_UP, + "MWHEELLEFT") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_DOWN, + "MWHEELRIGHT") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEYBOARD_GAMEPAD_MAPPING_TYPE, "Тип отображения клавиатуры для геймпада") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MAX_USERS, diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index 1cbd3d133f..565e1b85f3 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -763,6 +763,24 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, "Y button (left)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEY, "(Key: %s)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_LEFT, + "MOUSE1") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_RIGHT, + "MOUSE2") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_MIDDLE, + "MOUSE3") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON4, + "MOUSE4") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON5, + "MOUSE5") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_UP, + "MWHEELUP") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_DOWN, + "MWHEELDN") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_UP, + "MWHEELLEFT") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_DOWN, + "MWHEELRIGHT") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEYBOARD_GAMEPAD_MAPPING_TYPE, "Keyboard Gamepad Mapping Type") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MAX_USERS, diff --git a/intl/msg_hash_vn.h b/intl/msg_hash_vn.h index ca95e43315..00adb3fc70 100644 --- a/intl/msg_hash_vn.h +++ b/intl/msg_hash_vn.h @@ -743,6 +743,24 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, "Y button (left)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEY, "(Key: %s)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_LEFT, + "MOUSE1") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_RIGHT, + "MOUSE2") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_MIDDLE, + "MOUSE3") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON4, + "MOUSE4") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON5, + "MOUSE5") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_UP, + "MWHEELUP") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_DOWN, + "MWHEELDN") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_UP, + "MWHEELLEFT") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_DOWN, + "MWHEELRIGHT") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEYBOARD_GAMEPAD_MAPPING_TYPE, "Keyboard Gamepad Mapping Type") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MAX_USERS, diff --git a/msg_hash.h b/msg_hash.h index 8d43407884..8eb389a235 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -547,6 +547,15 @@ enum msg_hash_enums MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_L3, MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_R3, MENU_ENUM_LABEL_VALUE_INPUT_KEY, + MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_LEFT, + MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_RIGHT, + MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_MIDDLE, + MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON4, + MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON5, + MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_UP, + MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_DOWN, + MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_UP, + MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_DOWN, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_X, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_LEFT_Y, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_X, From 1d70fef70c84f9715d249bec9c4145665dab13bd Mon Sep 17 00:00:00 2001 From: David Walters Date: Sun, 26 Nov 2017 11:54:10 +0000 Subject: [PATCH 018/394] load/save mbutton assignments to retroarch config --- configuration.c | 52 ++++++++++++++++++++++++++++++++++++++++++++ input/input_driver.c | 49 +++++++++++++++++++++++++++++++++++++++++ input/input_driver.h | 3 +++ 3 files changed, 104 insertions(+) diff --git a/configuration.c b/configuration.c index 9d95452cdb..7f2fa1fc91 100644 --- a/configuration.c +++ b/configuration.c @@ -2143,6 +2143,24 @@ static void read_keybinds_axis(config_file_t *conf, unsigned user, input_config_bind_map_get_base(idx), bind); } +static void read_keybinds_mbutton(config_file_t *conf, unsigned user, + unsigned idx, struct retro_keybind *bind) +{ + const char *prefix = NULL; + + if (!input_config_bind_map_get_valid(idx)) + return; + if (!input_config_bind_map_get_base(idx)) + return; + + prefix = input_config_get_prefix(user, + input_config_bind_map_get_meta(idx)); + + if (prefix) + input_config_parse_mouse_button(conf, prefix, + input_config_bind_map_get_base(idx), bind); +} + static void read_keybinds_user(config_file_t *conf, unsigned user) { unsigned i; @@ -2157,6 +2175,7 @@ static void read_keybinds_user(config_file_t *conf, unsigned user) read_keybinds_keyboard(conf, user, i, bind); read_keybinds_button(conf, user, i, bind); read_keybinds_axis(conf, user, i, bind); + read_keybinds_mbutton(conf, user, i, bind); } } @@ -3349,6 +3368,38 @@ static void save_keybind_axis(config_file_t *conf, const char *prefix, } } +static void save_keybind_mbutton(config_file_t *conf, const char *prefix, + const char *base, const struct retro_keybind *bind, bool save_empty) +{ + char key[64]; + + key[0] = '\0'; + + fill_pathname_join_delim_concat(key, prefix, + base, '_', "_mbtn", sizeof(key)); + + switch ( bind->mbutton ) + { + + case RETRO_DEVICE_ID_MOUSE_LEFT: config_set_uint64(conf, key, 1); break; + case RETRO_DEVICE_ID_MOUSE_RIGHT: config_set_uint64(conf, key, 2); break; + case RETRO_DEVICE_ID_MOUSE_MIDDLE: config_set_uint64(conf, key, 3); break; + case RETRO_DEVICE_ID_MOUSE_BUTTON_4: config_set_uint64(conf, key, 4); break; + case RETRO_DEVICE_ID_MOUSE_BUTTON_5: config_set_uint64(conf, key, 5); break; + + case RETRO_DEVICE_ID_MOUSE_WHEELUP: config_set_string(conf, key, "wu"); break; + case RETRO_DEVICE_ID_MOUSE_WHEELDOWN: config_set_string(conf, key, "wd"); break; + case RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELUP: config_set_string(conf, key, "whu"); break; + case RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELDOWN: config_set_string(conf, key, "whd"); break; + + default: + if ( save_empty ) { + config_set_string(conf, key, file_path_str(FILE_PATH_NUL)); + } + break; + } +} + /** * save_keybind: * @conf : pointer to config file object @@ -3369,6 +3420,7 @@ static void save_keybind(config_file_t *conf, const char *prefix, save_keybind_key(conf, prefix, base, bind); save_keybind_joykey(conf, prefix, base, bind, save_empty); save_keybind_axis(conf, prefix, base, bind, save_empty); + save_keybind_mbutton(conf, prefix, base, bind, save_empty); } /** diff --git a/input/input_driver.c b/input/input_driver.c index 522f6caab8..e76f0189b4 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -2410,6 +2410,55 @@ void input_config_parse_joy_axis(void *data, const char *prefix, } } +void input_config_parse_mouse_button(void *data, const char *prefix, + const char *btn, struct retro_keybind *bind) +{ + int val; + char str[256]; + char tmp[64]; + char key[64]; + config_file_t *conf = (config_file_t*)data; + + str[0] = tmp[0] = key[0] = '\0'; + + fill_pathname_join_delim(str, prefix, btn, + '_', sizeof(str)); + fill_pathname_join_delim(key, str, + "mbtn", '_', sizeof(key)); + + if ( bind && config_get_array(conf, key, tmp, sizeof(tmp)) ) + { + bind->mbutton = NO_BTN; + + if ( tmp[0]=='w' ) + { + switch ( tmp[1] ) { + case 'u': bind->mbutton = RETRO_DEVICE_ID_MOUSE_WHEELUP; break; + case 'd': bind->mbutton = RETRO_DEVICE_ID_MOUSE_WHEELDOWN; break; + case 'h': + { + switch ( tmp[2] ) { + case 'u': bind->mbutton = RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELUP; break; + case 'd': bind->mbutton = RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELDOWN; break; + } + } + break; + } + } + else + { + val = atoi(tmp); + switch ( val ) { + case 1: bind->mbutton = RETRO_DEVICE_ID_MOUSE_LEFT; break; + case 2: bind->mbutton = RETRO_DEVICE_ID_MOUSE_RIGHT; break; + case 3: bind->mbutton = RETRO_DEVICE_ID_MOUSE_MIDDLE; break; + case 4: bind->mbutton = RETRO_DEVICE_ID_MOUSE_BUTTON_4; break; + case 5: bind->mbutton = RETRO_DEVICE_ID_MOUSE_BUTTON_5; break; + } + } + } +} + static void input_config_get_bind_string_joykey( char *buf, const char *prefix, const struct retro_keybind *bind, size_t size) diff --git a/input/input_driver.h b/input/input_driver.h index 215766058c..7cd3c068a6 100644 --- a/input/input_driver.h +++ b/input/input_driver.h @@ -761,6 +761,9 @@ void input_config_parse_joy_button(void *data, const char *prefix, void input_config_parse_joy_axis(void *data, const char *prefix, const char *axis, struct retro_keybind *bind); +void input_config_parse_mouse_button(void *data, const char *prefix, + const char *btn, struct retro_keybind *bind); + void input_config_set_device_name(unsigned port, const char *name); void input_config_clear_device_name(unsigned port); From 25efae063065b28263a3cef897496726c0047583 Mon Sep 17 00:00:00 2001 From: David Walters Date: Sun, 26 Nov 2017 11:56:02 +0000 Subject: [PATCH 019/394] Show mbutton binds on settings list; comma separate joy and key bins --- input/input_driver.c | 58 +++++++++++++++++++++++++++++++++++++++++--- 1 file changed, 55 insertions(+), 3 deletions(-) diff --git a/input/input_driver.c b/input/input_driver.c index e76f0189b4..d603a6a12e 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -2501,9 +2501,9 @@ static void input_config_get_bind_string_joykey( { if (bind->joykey_label && !string_is_empty(bind->joykey_label) && label_show) - snprintf(buf, size, "%s%s (btn) ", prefix, bind->joykey_label); + snprintf(buf, size, "%s%s (btn)", prefix, bind->joykey_label); else - snprintf(buf, size, "%s%u (%s) ", prefix, (unsigned)bind->joykey, + snprintf(buf, size, "%s%u (%s)", prefix, (unsigned)bind->joykey, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE)); } } @@ -2531,7 +2531,7 @@ static void input_config_get_bind_string_joyaxis(char *buf, const char *prefix, dir = '+'; axis = AXIS_POS_GET(bind->joyaxis); } - snprintf(buf, size, "%s%c%u (%s) ", prefix, dir, axis, + snprintf(buf, size, "%s%c%u (%s)", prefix, dir, axis, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE)); } } @@ -2539,6 +2539,7 @@ static void input_config_get_bind_string_joyaxis(char *buf, const char *prefix, void input_config_get_bind_string(char *buf, const struct retro_keybind *bind, const struct retro_keybind *auto_bind, size_t size) { + int delim = 0; #ifndef RARCH_CONSOLE char key[64]; char keybuf[64]; @@ -2556,17 +2557,68 @@ void input_config_get_bind_string(char *buf, const struct retro_keybind *bind, else if (auto_bind && auto_bind->joyaxis != AXIS_NONE) input_config_get_bind_string_joyaxis(buf, "Auto: ", auto_bind, size); + if ( *buf ) { + delim = 1; + } + #ifndef RARCH_CONSOLE input_keymaps_translate_rk_to_str(bind->key, key, sizeof(key)); if (string_is_equal(key, file_path_str(FILE_PATH_NUL))) *key = '\0'; /*empty?*/ if ( *key != '\0' ) { + if ( delim ) { + strlcat(buf, ", ", size); + } snprintf(keybuf, sizeof(keybuf), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_INPUT_KEY), key); strlcat(buf, keybuf, size); + delim = 1; } #endif + if ( bind->mbutton != NO_BTN ) + { + int tag = 0; + switch ( bind->mbutton ) + { + case RETRO_DEVICE_ID_MOUSE_LEFT: + tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_LEFT; + break; + case RETRO_DEVICE_ID_MOUSE_RIGHT: + tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_RIGHT; + break; + case RETRO_DEVICE_ID_MOUSE_MIDDLE: + tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_MIDDLE; + break; + case RETRO_DEVICE_ID_MOUSE_BUTTON_4: + tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON4; + break; + case RETRO_DEVICE_ID_MOUSE_BUTTON_5: + tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON5; + break; + case RETRO_DEVICE_ID_MOUSE_WHEELUP: + tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_UP; + break; + case RETRO_DEVICE_ID_MOUSE_WHEELDOWN: + tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_DOWN; + break; + case RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELUP: + tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_UP; + break; + case RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELDOWN: + tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_DOWN; + break; + } /* switch ( bind->mbutton ) */ + + if ( tag != 0 ) { + if ( delim ) { + strlcat(buf, ", ", size); + } + strlcat( buf, msg_hash_to_str(tag), size ); + delim = 1; + } + } + /*completely empty?*/ if ( *buf == '\0' ) { strlcat(buf, "---", size); From b2674195515cfce2879a2766efaa203379c69e9b Mon Sep 17 00:00:00 2001 From: David Walters Date: Sun, 26 Nov 2017 11:56:55 +0000 Subject: [PATCH 020/394] initialise/clear mbutton field --- menu/cbs/menu_cbs_scan.c | 1 + menu/menu_setting.c | 1 + setting_list.c | 2 ++ 3 files changed, 4 insertions(+) diff --git a/menu/cbs/menu_cbs_scan.c b/menu/cbs/menu_cbs_scan.c index 965e99207e..213b6b8ad1 100644 --- a/menu/cbs/menu_cbs_scan.c +++ b/menu/cbs/menu_cbs_scan.c @@ -144,6 +144,7 @@ static int action_scan_input_desc(const char *path, target->key = RETROK_UNKNOWN; target->joykey = NO_BTN; target->joyaxis = AXIS_NONE; + target->mbutton = NO_BTN; } return 0; diff --git a/menu/menu_setting.c b/menu/menu_setting.c index bb39557308..17e388340b 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -1441,6 +1441,7 @@ static int setting_action_ok_bind_defaults(void *data, bool wraparound) target->key = def_binds[i - MENU_SETTINGS_BIND_BEGIN].key; target->joykey = NO_BTN; target->joyaxis = AXIS_NONE; + target->mbutton = NO_BTN; } return 0; diff --git a/setting_list.c b/setting_list.c index ebb84273fd..1b69342c31 100644 --- a/setting_list.c +++ b/setting_list.c @@ -131,6 +131,8 @@ static int setting_bind_action_start(void *data) bind_type = setting_get_bind_type(setting); keybind->key = def_binds[bind_type - MENU_SETTINGS_BIND_BEGIN].key; + keybind->mbutton = NO_BTN; + return 0; } #endif From 9682e2777b346c9e2ff6d67a26298b89dfbdb11e Mon Sep 17 00:00:00 2001 From: David Walters Date: Sun, 26 Nov 2017 12:55:17 +0000 Subject: [PATCH 021/394] support for mouse button binds in Windows input drivers --- input/drivers/dinput.c | 52 +- input/drivers/winraw_input.c | 1481 ++++++++++++++++++---------------- 2 files changed, 814 insertions(+), 719 deletions(-) diff --git a/input/drivers/dinput.c b/input/drivers/dinput.c index f890444e46..6e525355f0 100644 --- a/input/drivers/dinput.c +++ b/input/drivers/dinput.c @@ -267,6 +267,49 @@ static bool dinput_keyboard_pressed(struct dinput_input *di, unsigned key) return di->state[sym] & 0x80; } +static bool dinput_mbutton_pressed(struct dinput_input *di, unsigned key) +{ + bool result; + + switch ( key ) + { + + case RETRO_DEVICE_ID_MOUSE_LEFT: + return di->mouse_l; + case RETRO_DEVICE_ID_MOUSE_RIGHT: + return di->mouse_r; + case RETRO_DEVICE_ID_MOUSE_MIDDLE: + return di->mouse_m; + case RETRO_DEVICE_ID_MOUSE_BUTTON_4: + return di->mouse_b4; + case RETRO_DEVICE_ID_MOUSE_BUTTON_5: + return di->mouse_b5; + + case RETRO_DEVICE_ID_MOUSE_WHEELUP: + result = di->mouse_wu; + di->mouse_wu = false; + return result; + + case RETRO_DEVICE_ID_MOUSE_WHEELDOWN: + result = di->mouse_wd; + di->mouse_wd = false; + return result; + + case RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELUP: + result = di->mouse_hwu; + di->mouse_hwu = false; + return result; + + case RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELDOWN: + result = di->mouse_hwd; + di->mouse_hwd = false; + return result; + + } + + return false; +} + static bool dinput_is_pressed(struct dinput_input *di, rarch_joypad_info_t joypad_info, const struct retro_keybind *binds, @@ -276,8 +319,13 @@ static bool dinput_is_pressed(struct dinput_input *di, if (!di->blocked && (bind->key < RETROK_LAST) && dinput_keyboard_pressed(di, bind->key)) return true; - if (binds && binds[id].valid && input_joypad_pressed(di->joypad, joypad_info, port, binds, id)) - return true; + if (binds && binds[id].valid) + { + if (dinput_mbutton_pressed(di, bind->mbutton)) + return true; + if (input_joypad_pressed(di->joypad, joypad_info, port, binds, id)) + return true; + } return false; } diff --git a/input/drivers/winraw_input.c b/input/drivers/winraw_input.c index cd844e838e..c7397d39d8 100644 --- a/input/drivers/winraw_input.c +++ b/input/drivers/winraw_input.c @@ -1,717 +1,764 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2011-2017 - Daniel De Matteis - * - * RetroArch 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 Found- - * ation, either version 3 of the License, or (at your option) any later version. - * - * RetroArch 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 RetroArch. - * If not, see . - */ - -#include - -#include "../input_driver.h" -#include "../input_keymaps.h" - -#include "../../configuration.h" -#include "../../gfx/video_driver.h" -#include "../../verbosity.h" - -typedef struct -{ - uint8_t keys[256]; -} winraw_keyboard_t; - -typedef struct -{ - HANDLE hnd; - LONG x, y, dlt_x, dlt_y; - LONG whl_u, whl_d; - bool btn_l, btn_m, btn_r, btn_b4, btn_b5; -} winraw_mouse_t; - -typedef struct -{ - bool kbd_mapp_block; - bool mouse_grab; - winraw_keyboard_t keyboard; - HWND window; - winraw_mouse_t *mice; - const input_device_driver_t *joypad; -} winraw_input_t; - -static winraw_keyboard_t *g_keyboard = NULL; -static winraw_mouse_t *g_mice = NULL; -static unsigned g_mouse_cnt = 0; -static bool g_mouse_xy_mapping_ready = false; -static double g_view_abs_ratio_x = 0.0; -static double g_view_abs_ratio_y = 0.0; - -static HWND winraw_create_window(WNDPROC wnd_proc) -{ - HWND wnd; - WNDCLASSA wc = {0}; - - wc.hInstance = GetModuleHandleA(NULL); - - if (!wc.hInstance) - { - RARCH_ERR("[WINRAW]: GetModuleHandleA failed with error %lu.\n", GetLastError()); - return NULL; - } - - wc.lpfnWndProc = wnd_proc; - wc.lpszClassName = "winraw-input"; - if (!RegisterClassA(&wc) && GetLastError() != ERROR_CLASS_ALREADY_EXISTS) - { - RARCH_ERR("[WINRAW]: RegisterClassA failed with error %lu.\n", GetLastError()); - return NULL; - } - - wnd = CreateWindowExA(0, wc.lpszClassName, NULL, 0, 0, 0, 0, 0, - HWND_MESSAGE, NULL, NULL, NULL); - if (!wnd) - { - RARCH_ERR("[WINRAW]: CreateWindowExA failed with error %lu.\n", GetLastError()); - goto error; - } - - return wnd; - -error: - UnregisterClassA(wc.lpszClassName, NULL); - return NULL; -} - -static void winraw_destroy_window(HWND wnd) -{ - BOOL r; - - if (!wnd) - return; - - r = DestroyWindow(wnd); - - if (!r) - { - RARCH_WARN("[WINRAW]: DestroyWindow failed with error %lu.\n", GetLastError()); - } - - r = UnregisterClassA("winraw-input", NULL); - - if (!r) - { - RARCH_WARN("[WINRAW]: UnregisterClassA failed with error %lu.\n", GetLastError()); - } -} - -static bool winraw_set_keyboard_input(HWND window) -{ - RAWINPUTDEVICE rid; - BOOL r; - - rid.dwFlags = window ? 0 : RIDEV_REMOVE; - rid.hwndTarget = window; - rid.usUsagePage = 0x01; /* generic desktop */ - rid.usUsage = 0x06; /* keyboard */ - - r = RegisterRawInputDevices(&rid, 1, sizeof(RAWINPUTDEVICE)); - - if (!r) - { - RARCH_ERR("[WINRAW]: RegisterRawInputDevices failed with error %lu.\n", GetLastError()); - return false; - } - - return true; -} - -static void winraw_log_mice_info(winraw_mouse_t *mice, unsigned mouse_cnt) -{ - UINT r; - unsigned i; - char name[256]; - UINT name_size = sizeof(name); - - for (i = 0; i < mouse_cnt; ++i) - { - r = GetRawInputDeviceInfoA(mice[i].hnd, RIDI_DEVICENAME, name, &name_size); - if (r == (UINT)-1 || r == 0) - name[0] = '\0'; - RARCH_LOG("[WINRAW]: Mouse #%u %s.\n", i, name); - } -} - -static bool winraw_init_devices(winraw_mouse_t **mice, unsigned *mouse_cnt) -{ - UINT i; - POINT crs_pos; - winraw_mouse_t *mice_r = NULL; - unsigned mouse_cnt_r = 0; - RAWINPUTDEVICELIST *devs = NULL; - UINT dev_cnt = 0; - UINT r = GetRawInputDeviceList( - NULL, &dev_cnt, sizeof(RAWINPUTDEVICELIST)); - - if (r == (UINT)-1) - { - RARCH_ERR("[WINRAW]: GetRawInputDeviceList failed with error %lu.\n", GetLastError()); - goto error; - } - - devs = (RAWINPUTDEVICELIST*)malloc(dev_cnt * sizeof(RAWINPUTDEVICELIST)); - if (!devs) - goto error; - - dev_cnt = GetRawInputDeviceList(devs, &dev_cnt, sizeof(RAWINPUTDEVICELIST)); - if (dev_cnt == (UINT)-1) - { - RARCH_ERR("[WINRAW]: GetRawInputDeviceList failed with error %lu.\n", GetLastError()); - goto error; - } - - for (i = 0; i < dev_cnt; ++i) - mouse_cnt_r += devs[i].dwType == RIM_TYPEMOUSE ? 1 : 0; - - if (mouse_cnt_r) - { - mice_r = (winraw_mouse_t*)calloc(1, mouse_cnt_r * sizeof(winraw_mouse_t)); - if (!mice_r) - goto error; - - if (!GetCursorPos(&crs_pos)) - goto error; - - for (i = 0; i < mouse_cnt_r; ++i) - { - mice_r[i].x = crs_pos.x; - mice_r[i].y = crs_pos.y; - } - } - - /* count is already checked, so this is safe */ - for (i = mouse_cnt_r = 0; i < dev_cnt; ++i) - { - if (devs[i].dwType == RIM_TYPEMOUSE) - mice_r[mouse_cnt_r++].hnd = devs[i].hDevice; - } - - winraw_log_mice_info(mice_r, mouse_cnt_r); - - *mice = mice_r; - *mouse_cnt = mouse_cnt_r; - - return true; - -error: - free(devs); - free(mice_r); - *mice = NULL; - *mouse_cnt = 0; - return false; -} - -static bool winraw_set_mouse_input(HWND window, bool grab) -{ - RAWINPUTDEVICE rid; - BOOL r; - - if (window) - rid.dwFlags = grab ? RIDEV_CAPTUREMOUSE : 0; - else - rid.dwFlags = RIDEV_REMOVE; - - rid.hwndTarget = window; - rid.usUsagePage = 0x01; /* generic desktop */ - rid.usUsage = 0x02; /* mouse */ - - r = RegisterRawInputDevices(&rid, 1, sizeof(RAWINPUTDEVICE)); - - if (!r) - { - RARCH_ERR("[WINRAW]: RegisterRawInputDevice failed with error %lu.\n", GetLastError()); - return false; - } - - return true; -} - -static int16_t winraw_mouse_state(winraw_input_t *wr, - unsigned port, bool abs, unsigned id) -{ - unsigned i; - settings_t *settings = config_get_ptr(); - winraw_mouse_t *mouse = NULL; - - if (port >= MAX_USERS) - return 0; - - for (i = 0; i < g_mouse_cnt; ++i) - { - if (i == settings->uints.input_mouse_index[port]) - { - mouse = &wr->mice[i]; - break; - } - } - - if (!mouse) - return 0; - - switch (id) - { - case RETRO_DEVICE_ID_MOUSE_X: - return abs ? mouse->x : mouse->dlt_x; - case RETRO_DEVICE_ID_MOUSE_Y: - return abs ? mouse->y : mouse->dlt_y; - case RETRO_DEVICE_ID_MOUSE_LEFT: - return mouse->btn_l ? 1 : 0; - case RETRO_DEVICE_ID_MOUSE_RIGHT: - return mouse->btn_r ? 1 : 0; - case RETRO_DEVICE_ID_MOUSE_WHEELUP: - return mouse->whl_u ? 1 : 0; - case RETRO_DEVICE_ID_MOUSE_WHEELDOWN: - return mouse->whl_d ? 1 : 0; - case RETRO_DEVICE_ID_MOUSE_MIDDLE: - return mouse->btn_m ? 1 : 0; - case RETRO_DEVICE_ID_MOUSE_BUTTON_4: - return mouse->btn_b4 ? 1 : 0; - case RETRO_DEVICE_ID_MOUSE_BUTTON_5: - return mouse->btn_b5 ? 1 : 0; - } - - return 0; -} - -static int16_t winraw_joypad_state(winraw_input_t *wr, - rarch_joypad_info_t joypad_info, - const struct retro_keybind *binds, - unsigned port, unsigned id) -{ - const struct retro_keybind *bind = &binds[id]; - unsigned key = rarch_keysym_lut[(enum retro_key)bind->key]; - - if (!wr->kbd_mapp_block && (bind->key < RETROK_LAST) && wr->keyboard.keys[key]) - return 1; - - return input_joypad_pressed(wr->joypad, joypad_info, port, binds, id); -} - -static void winraw_init_mouse_xy_mapping() -{ - struct video_viewport viewport; - int center_x; - int center_y; - unsigned i; - - if (video_driver_get_viewport_info(&viewport)) - { - center_x = viewport.x + viewport.width / 2; - center_y = viewport.y + viewport.height / 2; - - for (i = 0; i < g_mouse_cnt; ++i) - { - g_mice[i].x = center_x; - g_mice[i].y = center_y; - } - - g_view_abs_ratio_x = (double)viewport.full_width / 65535.0; - g_view_abs_ratio_y = (double)viewport.full_height / 65535.0; - - g_mouse_xy_mapping_ready = true; - } -} - -static int16_t winraw_lightgun_state(winraw_input_t *wr, - unsigned port, unsigned id) -{ - unsigned i; - settings_t *settings = config_get_ptr(); - winraw_mouse_t *mouse = NULL; - - if (port >= MAX_USERS) - return 0; - - for (i = 0; i < g_mouse_cnt; ++i) - { - if (i == settings->uints.input_mouse_index[port]) - { - mouse = &wr->mice[i]; - break; - } - } - - if (!mouse) - return 0; - - switch (id) - { - case RETRO_DEVICE_ID_LIGHTGUN_X: - return mouse->dlt_x; - case RETRO_DEVICE_ID_LIGHTGUN_Y: - return mouse->dlt_y; - case RETRO_DEVICE_ID_LIGHTGUN_TRIGGER: - return mouse->btn_l ? 1 : 0; - case RETRO_DEVICE_ID_LIGHTGUN_CURSOR: - return mouse->btn_m ? 1 : 0; - case RETRO_DEVICE_ID_LIGHTGUN_TURBO: - return mouse->btn_r ? 1 : 0; - case RETRO_DEVICE_ID_LIGHTGUN_START: - return (mouse->btn_m && mouse->btn_r) ? 1 : 0; - case RETRO_DEVICE_ID_LIGHTGUN_PAUSE: - return mouse->btn_m && mouse->btn_l ? 1 : 0; - } - - return 0; -} - -static void winraw_update_mouse_state(winraw_mouse_t *mouse, RAWMOUSE *state) -{ - POINT crs_pos; - - if (state->usFlags & MOUSE_MOVE_ABSOLUTE) - { - if (g_mouse_xy_mapping_ready) - { - state->lLastX = (LONG)(g_view_abs_ratio_x * state->lLastX); - state->lLastY = (LONG)(g_view_abs_ratio_y * state->lLastY); - InterlockedExchangeAdd(&mouse->dlt_x, state->lLastX - mouse->x); - InterlockedExchangeAdd(&mouse->dlt_y, state->lLastY - mouse->y); - mouse->x = state->lLastX; - mouse->y = state->lLastY; - } - else - winraw_init_mouse_xy_mapping(); - } - else if (state->lLastX || state->lLastY) - { - InterlockedExchangeAdd(&mouse->dlt_x, state->lLastX); - InterlockedExchangeAdd(&mouse->dlt_y, state->lLastY); - - if (!GetCursorPos(&crs_pos)) - { - RARCH_WARN("[WINRAW]: GetCursorPos failed with error %lu.\n", GetLastError()); - } - else if (!ScreenToClient((HWND)video_driver_window_get(), &crs_pos)) - { - RARCH_WARN("[WINRAW]: ScreenToClient failed with error %lu.\n", GetLastError()); - } - else - { - mouse->x = crs_pos.x; - mouse->y = crs_pos.y; - } - } - - if (state->usButtonFlags & RI_MOUSE_LEFT_BUTTON_DOWN) - mouse->btn_l = true; - else if (state->usButtonFlags & RI_MOUSE_LEFT_BUTTON_UP) - mouse->btn_l = false; - - if (state->usButtonFlags & RI_MOUSE_MIDDLE_BUTTON_DOWN) - mouse->btn_m = true; - else if (state->usButtonFlags & RI_MOUSE_MIDDLE_BUTTON_UP) - mouse->btn_m = false; - - if (state->usButtonFlags & RI_MOUSE_RIGHT_BUTTON_DOWN) - mouse->btn_r = true; - else if (state->usButtonFlags & RI_MOUSE_RIGHT_BUTTON_UP) - mouse->btn_r = false; - - if (state->usButtonFlags & RI_MOUSE_BUTTON_4_DOWN) - mouse->btn_b4 = true; - else if (state->usButtonFlags & RI_MOUSE_BUTTON_4_UP) - mouse->btn_b4 = false; - - if (state->usButtonFlags & RI_MOUSE_BUTTON_5_DOWN) - mouse->btn_b5 = true; - else if (state->usButtonFlags & RI_MOUSE_BUTTON_5_UP) - mouse->btn_b5 = false; - - if (state->usButtonFlags & RI_MOUSE_WHEEL) - { - if ((SHORT)state->usButtonData > 0) - InterlockedExchange(&mouse->whl_u, 1); - else if ((SHORT)state->usButtonData < 0) - InterlockedExchange(&mouse->whl_d, 1); - } -} - -static LRESULT CALLBACK winraw_callback(HWND wnd, UINT msg, WPARAM wpar, LPARAM lpar) -{ - static uint8_t data[1024]; - UINT r; - unsigned i; - RAWINPUT *ri = (RAWINPUT*)data; - UINT size = sizeof(data); - - if (msg != WM_INPUT) - return DefWindowProcA(wnd, msg, wpar, lpar); - - /* app is in the background */ - if (GET_RAWINPUT_CODE_WPARAM(wpar) != RIM_INPUT) - goto end; - - r = GetRawInputData((HRAWINPUT)lpar, RID_INPUT, - data, &size, sizeof(RAWINPUTHEADER)); - if (r == (UINT)-1) - { - RARCH_WARN("[WINRAW]: GetRawInputData failed with error %lu.\n", - GetLastError()); - goto end; - } - - if (ri->header.dwType == RIM_TYPEKEYBOARD) - { - if (ri->data.keyboard.Message == WM_KEYDOWN) - g_keyboard->keys[ri->data.keyboard.VKey] = 1; - else if (ri->data.keyboard.Message == WM_KEYUP) - g_keyboard->keys[ri->data.keyboard.VKey] = 0; - } - else if (ri->header.dwType == RIM_TYPEMOUSE) - { - for (i = 0; i < g_mouse_cnt; ++i) - { - if (g_mice[i].hnd == ri->header.hDevice) - { - winraw_update_mouse_state(&g_mice[i], &ri->data.mouse); - break; - } - } - } - -end: - DefWindowProcA(wnd, msg, wpar, lpar); - return 0; -} - -static void *winraw_init(const char *joypad_driver) -{ - bool r; - winraw_input_t *wr = (winraw_input_t *) - calloc(1, sizeof(winraw_input_t)); - g_keyboard = (winraw_keyboard_t*) - calloc(1, sizeof(winraw_keyboard_t)); - - if (!wr || !g_keyboard) - goto error; - - RARCH_LOG("[WINRAW]: Initializing input driver... \n"); - - input_keymaps_init_keyboard_lut(rarch_key_map_winraw); - - wr->window = winraw_create_window(winraw_callback); - if (!wr->window) - goto error; - - r = winraw_init_devices(&g_mice, &g_mouse_cnt); - if (!r) - goto error; - - if (!g_mouse_cnt) - { - RARCH_LOG("[WINRAW]: Mouse unavailable.\n"); - } - else - { - wr->mice = (winraw_mouse_t*) - malloc(g_mouse_cnt * sizeof(winraw_mouse_t)); - if (!wr->mice) - goto error; - - memcpy(wr->mice, g_mice, g_mouse_cnt * sizeof(winraw_mouse_t)); - } - - r = winraw_set_keyboard_input(wr->window); - if (!r) - goto error; - - r = winraw_set_mouse_input(wr->window, false); - if (!r) - goto error; - - wr->joypad = input_joypad_init_driver(joypad_driver, wr); - - return wr; - -error: - if (wr && wr->window) - { - winraw_set_mouse_input(NULL, false); - winraw_set_keyboard_input(NULL); - winraw_destroy_window(wr->window); - } - free(g_keyboard); - free(g_mice); - if (wr) - free(wr->mice); - free(wr); - return NULL; -} - -static void winraw_poll(void *d) -{ - unsigned i; - winraw_input_t *wr = (winraw_input_t*)d; - - memcpy(&wr->keyboard, g_keyboard, sizeof(winraw_keyboard_t)); - - /* following keys are not handled by windows raw input api */ - wr->keyboard.keys[VK_LCONTROL] = GetAsyncKeyState(VK_LCONTROL) >> 1 ? 1 : 0; - wr->keyboard.keys[VK_RCONTROL] = GetAsyncKeyState(VK_RCONTROL) >> 1 ? 1 : 0; - wr->keyboard.keys[VK_LMENU] = GetAsyncKeyState(VK_LMENU) >> 1 ? 1 : 0; - wr->keyboard.keys[VK_RMENU] = GetAsyncKeyState(VK_RMENU) >> 1 ? 1 : 0; - wr->keyboard.keys[VK_LSHIFT] = GetAsyncKeyState(VK_LSHIFT) >> 1 ? 1 : 0; - wr->keyboard.keys[VK_RSHIFT] = GetAsyncKeyState(VK_RSHIFT) >> 1 ? 1 : 0; - - for (i = 0; i < g_mouse_cnt; ++i) - { - wr->mice[i].x = g_mice[i].x; - wr->mice[i].y = g_mice[i].y; - wr->mice[i].dlt_x = InterlockedExchange(&g_mice[i].dlt_x, 0); - wr->mice[i].dlt_y = InterlockedExchange(&g_mice[i].dlt_y, 0); - wr->mice[i].whl_u = InterlockedExchange(&g_mice[i].whl_u, 0); - wr->mice[i].whl_d = InterlockedExchange(&g_mice[i].whl_d, 0); - wr->mice[i].btn_l = g_mice[i].btn_l; - wr->mice[i].btn_m = g_mice[i].btn_m; - wr->mice[i].btn_r = g_mice[i].btn_r; - wr->mice[i].btn_b4 = g_mice[i].btn_b4; - wr->mice[i].btn_b5 = g_mice[i].btn_b5; - } - - if (wr->joypad) - wr->joypad->poll(); -} - -static int16_t winraw_input_state(void *d, - rarch_joypad_info_t joypad_info, - const struct retro_keybind **binds, - unsigned port, unsigned device, unsigned index, unsigned id) -{ - winraw_input_t *wr = (winraw_input_t*)d; - - switch (device) - { - case RETRO_DEVICE_KEYBOARD: - if (id < RETROK_LAST) - { - unsigned key = rarch_keysym_lut[(enum retro_key)id]; - return wr->keyboard.keys[key]; - } - break; - case RETRO_DEVICE_MOUSE: - return winraw_mouse_state(wr, port, false, id); - case RARCH_DEVICE_MOUSE_SCREEN: - return winraw_mouse_state(wr, port, true, id); - case RETRO_DEVICE_JOYPAD: - return winraw_joypad_state(wr, joypad_info, binds[port], port, id); - case RETRO_DEVICE_ANALOG: - if (binds[port]) - return input_joypad_analog(wr->joypad, joypad_info, - port, index, id, binds[port]); - break; - case RETRO_DEVICE_LIGHTGUN: - return winraw_lightgun_state(wr, port, id); - } - - return 0; -} - -static bool winraw_meta_key_pressed(void *u1, int u2) -{ - return false; -} - -static void winraw_free(void *d) -{ - winraw_input_t *wr = (winraw_input_t*)d; - - if (wr->joypad) - wr->joypad->destroy(); - winraw_set_mouse_input(NULL, false); - winraw_set_keyboard_input(NULL); - winraw_destroy_window(wr->window); - free(g_mice); - free(g_keyboard); - free(wr->mice); - free(wr); - - g_mouse_xy_mapping_ready = false; -} - -static uint64_t winraw_get_capabilities(void *u) -{ - return (1 << RETRO_DEVICE_KEYBOARD) | - (1 << RETRO_DEVICE_MOUSE) | - (1 << RETRO_DEVICE_JOYPAD) | - (1 << RETRO_DEVICE_ANALOG) | - (1 << RETRO_DEVICE_LIGHTGUN); -} - -static void winraw_grab_mouse(void *d, bool grab) -{ - bool r = false; - winraw_input_t *wr = (winraw_input_t*)d; - - if (grab == wr->mouse_grab) - return; - - r = winraw_set_mouse_input(wr->window, grab); - if (!r) - return; - - wr->mouse_grab = grab; -} - -static bool winraw_set_rumble(void *d, unsigned port, - enum retro_rumble_effect effect, uint16_t strength) -{ - winraw_input_t *wr = (winraw_input_t*)d; - - return input_joypad_set_rumble(wr->joypad, port, effect, strength); -} - -static const input_device_driver_t *winraw_get_joypad_driver(void *d) -{ - winraw_input_t *wr = (winraw_input_t*)d; - - return wr->joypad; -} - -static bool winraw_keyboard_mapping_is_blocked(void *d) -{ - winraw_input_t *wr = (winraw_input_t*)d; - - return wr->kbd_mapp_block; -} - -static void winraw_keyboard_mapping_set_block(void *d, bool block) -{ - winraw_input_t *wr = (winraw_input_t*)d; - - wr->kbd_mapp_block = block; -} - -input_driver_t input_winraw = { - winraw_init, - winraw_poll, - winraw_input_state, - winraw_meta_key_pressed, - winraw_free, - NULL, - NULL, - winraw_get_capabilities, - "raw", - winraw_grab_mouse, - NULL, - winraw_set_rumble, - winraw_get_joypad_driver, - NULL, - winraw_keyboard_mapping_is_blocked, - winraw_keyboard_mapping_set_block, -}; +/* RetroArch - A frontend for libretro. + * Copyright (C) 2011-2017 - Daniel De Matteis + * + * RetroArch 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 Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch 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 RetroArch. + * If not, see . + */ + +#include + +#include "../input_driver.h" +#include "../input_keymaps.h" + +#include "../../configuration.h" +#include "../../gfx/video_driver.h" +#include "../../verbosity.h" + +typedef struct +{ + uint8_t keys[256]; +} winraw_keyboard_t; + +typedef struct +{ + HANDLE hnd; + LONG x, y, dlt_x, dlt_y; + LONG whl_u, whl_d; + bool btn_l, btn_m, btn_r, btn_b4, btn_b5; +} winraw_mouse_t; + +typedef struct +{ + bool kbd_mapp_block; + bool mouse_grab; + winraw_keyboard_t keyboard; + HWND window; + winraw_mouse_t *mice; + const input_device_driver_t *joypad; +} winraw_input_t; + +static winraw_keyboard_t *g_keyboard = NULL; +static winraw_mouse_t *g_mice = NULL; +static unsigned g_mouse_cnt = 0; +static bool g_mouse_xy_mapping_ready = false; +static double g_view_abs_ratio_x = 0.0; +static double g_view_abs_ratio_y = 0.0; + +static HWND winraw_create_window(WNDPROC wnd_proc) +{ + HWND wnd; + WNDCLASSA wc = {0}; + + wc.hInstance = GetModuleHandleA(NULL); + + if (!wc.hInstance) + { + RARCH_ERR("[WINRAW]: GetModuleHandleA failed with error %lu.\n", GetLastError()); + return NULL; + } + + wc.lpfnWndProc = wnd_proc; + wc.lpszClassName = "winraw-input"; + if (!RegisterClassA(&wc) && GetLastError() != ERROR_CLASS_ALREADY_EXISTS) + { + RARCH_ERR("[WINRAW]: RegisterClassA failed with error %lu.\n", GetLastError()); + return NULL; + } + + wnd = CreateWindowExA(0, wc.lpszClassName, NULL, 0, 0, 0, 0, 0, + HWND_MESSAGE, NULL, NULL, NULL); + if (!wnd) + { + RARCH_ERR("[WINRAW]: CreateWindowExA failed with error %lu.\n", GetLastError()); + goto error; + } + + return wnd; + +error: + UnregisterClassA(wc.lpszClassName, NULL); + return NULL; +} + +static void winraw_destroy_window(HWND wnd) +{ + BOOL r; + + if (!wnd) + return; + + r = DestroyWindow(wnd); + + if (!r) + { + RARCH_WARN("[WINRAW]: DestroyWindow failed with error %lu.\n", GetLastError()); + } + + r = UnregisterClassA("winraw-input", NULL); + + if (!r) + { + RARCH_WARN("[WINRAW]: UnregisterClassA failed with error %lu.\n", GetLastError()); + } +} + +static bool winraw_set_keyboard_input(HWND window) +{ + RAWINPUTDEVICE rid; + BOOL r; + + rid.dwFlags = window ? 0 : RIDEV_REMOVE; + rid.hwndTarget = window; + rid.usUsagePage = 0x01; /* generic desktop */ + rid.usUsage = 0x06; /* keyboard */ + + r = RegisterRawInputDevices(&rid, 1, sizeof(RAWINPUTDEVICE)); + + if (!r) + { + RARCH_ERR("[WINRAW]: RegisterRawInputDevices failed with error %lu.\n", GetLastError()); + return false; + } + + return true; +} + +static void winraw_log_mice_info(winraw_mouse_t *mice, unsigned mouse_cnt) +{ + UINT r; + unsigned i; + char name[256]; + UINT name_size = sizeof(name); + + for (i = 0; i < mouse_cnt; ++i) + { + r = GetRawInputDeviceInfoA(mice[i].hnd, RIDI_DEVICENAME, name, &name_size); + if (r == (UINT)-1 || r == 0) + name[0] = '\0'; + RARCH_LOG("[WINRAW]: Mouse #%u %s.\n", i, name); + } +} + +static bool winraw_init_devices(winraw_mouse_t **mice, unsigned *mouse_cnt) +{ + UINT i; + POINT crs_pos; + winraw_mouse_t *mice_r = NULL; + unsigned mouse_cnt_r = 0; + RAWINPUTDEVICELIST *devs = NULL; + UINT dev_cnt = 0; + UINT r = GetRawInputDeviceList( + NULL, &dev_cnt, sizeof(RAWINPUTDEVICELIST)); + + if (r == (UINT)-1) + { + RARCH_ERR("[WINRAW]: GetRawInputDeviceList failed with error %lu.\n", GetLastError()); + goto error; + } + + devs = (RAWINPUTDEVICELIST*)malloc(dev_cnt * sizeof(RAWINPUTDEVICELIST)); + if (!devs) + goto error; + + dev_cnt = GetRawInputDeviceList(devs, &dev_cnt, sizeof(RAWINPUTDEVICELIST)); + if (dev_cnt == (UINT)-1) + { + RARCH_ERR("[WINRAW]: GetRawInputDeviceList failed with error %lu.\n", GetLastError()); + goto error; + } + + for (i = 0; i < dev_cnt; ++i) + mouse_cnt_r += devs[i].dwType == RIM_TYPEMOUSE ? 1 : 0; + + if (mouse_cnt_r) + { + mice_r = (winraw_mouse_t*)calloc(1, mouse_cnt_r * sizeof(winraw_mouse_t)); + if (!mice_r) + goto error; + + if (!GetCursorPos(&crs_pos)) + goto error; + + for (i = 0; i < mouse_cnt_r; ++i) + { + mice_r[i].x = crs_pos.x; + mice_r[i].y = crs_pos.y; + } + } + + /* count is already checked, so this is safe */ + for (i = mouse_cnt_r = 0; i < dev_cnt; ++i) + { + if (devs[i].dwType == RIM_TYPEMOUSE) + mice_r[mouse_cnt_r++].hnd = devs[i].hDevice; + } + + winraw_log_mice_info(mice_r, mouse_cnt_r); + + *mice = mice_r; + *mouse_cnt = mouse_cnt_r; + + return true; + +error: + free(devs); + free(mice_r); + *mice = NULL; + *mouse_cnt = 0; + return false; +} + +static bool winraw_set_mouse_input(HWND window, bool grab) +{ + RAWINPUTDEVICE rid; + BOOL r; + + if (window) + rid.dwFlags = grab ? RIDEV_CAPTUREMOUSE : 0; + else + rid.dwFlags = RIDEV_REMOVE; + + rid.hwndTarget = window; + rid.usUsagePage = 0x01; /* generic desktop */ + rid.usUsage = 0x02; /* mouse */ + + r = RegisterRawInputDevices(&rid, 1, sizeof(RAWINPUTDEVICE)); + + if (!r) + { + RARCH_ERR("[WINRAW]: RegisterRawInputDevice failed with error %lu.\n", GetLastError()); + return false; + } + + return true; +} + +static int16_t winraw_mouse_state(winraw_input_t *wr, + unsigned port, bool abs, unsigned id) +{ + unsigned i; + settings_t *settings = config_get_ptr(); + winraw_mouse_t *mouse = NULL; + + if (port >= MAX_USERS) + return 0; + + for (i = 0; i < g_mouse_cnt; ++i) + { + if (i == settings->uints.input_mouse_index[port]) + { + mouse = &wr->mice[i]; + break; + } + } + + if (!mouse) + return 0; + + switch (id) + { + case RETRO_DEVICE_ID_MOUSE_X: + return abs ? mouse->x : mouse->dlt_x; + case RETRO_DEVICE_ID_MOUSE_Y: + return abs ? mouse->y : mouse->dlt_y; + case RETRO_DEVICE_ID_MOUSE_LEFT: + return mouse->btn_l ? 1 : 0; + case RETRO_DEVICE_ID_MOUSE_RIGHT: + return mouse->btn_r ? 1 : 0; + case RETRO_DEVICE_ID_MOUSE_WHEELUP: + return mouse->whl_u ? 1 : 0; + case RETRO_DEVICE_ID_MOUSE_WHEELDOWN: + return mouse->whl_d ? 1 : 0; + case RETRO_DEVICE_ID_MOUSE_MIDDLE: + return mouse->btn_m ? 1 : 0; + case RETRO_DEVICE_ID_MOUSE_BUTTON_4: + return mouse->btn_b4 ? 1 : 0; + case RETRO_DEVICE_ID_MOUSE_BUTTON_5: + return mouse->btn_b5 ? 1 : 0; + } + + return 0; +} + +static bool winraw_mbutton_pressed(winraw_input_t *wr, unsigned port, unsigned key) +{ + unsigned i; + bool result; + winraw_mouse_t *mouse = NULL; + settings_t *settings = config_get_ptr(); + + if (port >= MAX_USERS) + return false; + + for (i = 0; i < g_mouse_cnt; ++i) + { + if (i == settings->uints.input_mouse_index[port]) + { + mouse = &wr->mice[i]; + break; + } + } + + if (!mouse) + return false; + + switch ( key ) + { + + case RETRO_DEVICE_ID_MOUSE_LEFT: + return mouse->btn_l; + case RETRO_DEVICE_ID_MOUSE_RIGHT: + return mouse->btn_r; + case RETRO_DEVICE_ID_MOUSE_MIDDLE: + return mouse->btn_m; + case RETRO_DEVICE_ID_MOUSE_BUTTON_4: + return mouse->btn_b4; + case RETRO_DEVICE_ID_MOUSE_BUTTON_5: + return mouse->btn_b5; + case RETRO_DEVICE_ID_MOUSE_WHEELUP: + return mouse->whl_u; + case RETRO_DEVICE_ID_MOUSE_WHEELDOWN: + return mouse->whl_d; + } + + return false; +} + +static int16_t winraw_joypad_state(winraw_input_t *wr, + rarch_joypad_info_t joypad_info, + const struct retro_keybind *binds, + unsigned port, unsigned id) +{ + const struct retro_keybind *bind = &binds[id]; + unsigned key = rarch_keysym_lut[(enum retro_key)bind->key]; + + if (!wr->kbd_mapp_block && (bind->key < RETROK_LAST) && wr->keyboard.keys[key]) + return 1; + + if (binds && binds[id].valid && winraw_mbutton_pressed(wr, port, bind->mbutton)) + return 1; + + return input_joypad_pressed(wr->joypad, joypad_info, port, binds, id); +} + +static void winraw_init_mouse_xy_mapping() +{ + struct video_viewport viewport; + int center_x; + int center_y; + unsigned i; + + if (video_driver_get_viewport_info(&viewport)) + { + center_x = viewport.x + viewport.width / 2; + center_y = viewport.y + viewport.height / 2; + + for (i = 0; i < g_mouse_cnt; ++i) + { + g_mice[i].x = center_x; + g_mice[i].y = center_y; + } + + g_view_abs_ratio_x = (double)viewport.full_width / 65535.0; + g_view_abs_ratio_y = (double)viewport.full_height / 65535.0; + + g_mouse_xy_mapping_ready = true; + } +} + +static int16_t winraw_lightgun_state(winraw_input_t *wr, + unsigned port, unsigned id) +{ + unsigned i; + settings_t *settings = config_get_ptr(); + winraw_mouse_t *mouse = NULL; + + if (port >= MAX_USERS) + return 0; + + for (i = 0; i < g_mouse_cnt; ++i) + { + if (i == settings->uints.input_mouse_index[port]) + { + mouse = &wr->mice[i]; + break; + } + } + + if (!mouse) + return 0; + + switch (id) + { + case RETRO_DEVICE_ID_LIGHTGUN_X: + return mouse->dlt_x; + case RETRO_DEVICE_ID_LIGHTGUN_Y: + return mouse->dlt_y; + case RETRO_DEVICE_ID_LIGHTGUN_TRIGGER: + return mouse->btn_l ? 1 : 0; + case RETRO_DEVICE_ID_LIGHTGUN_CURSOR: + return mouse->btn_m ? 1 : 0; + case RETRO_DEVICE_ID_LIGHTGUN_TURBO: + return mouse->btn_r ? 1 : 0; + case RETRO_DEVICE_ID_LIGHTGUN_START: + return (mouse->btn_m && mouse->btn_r) ? 1 : 0; + case RETRO_DEVICE_ID_LIGHTGUN_PAUSE: + return mouse->btn_m && mouse->btn_l ? 1 : 0; + } + + return 0; +} + +static void winraw_update_mouse_state(winraw_mouse_t *mouse, RAWMOUSE *state) +{ + POINT crs_pos; + + if (state->usFlags & MOUSE_MOVE_ABSOLUTE) + { + if (g_mouse_xy_mapping_ready) + { + state->lLastX = (LONG)(g_view_abs_ratio_x * state->lLastX); + state->lLastY = (LONG)(g_view_abs_ratio_y * state->lLastY); + InterlockedExchangeAdd(&mouse->dlt_x, state->lLastX - mouse->x); + InterlockedExchangeAdd(&mouse->dlt_y, state->lLastY - mouse->y); + mouse->x = state->lLastX; + mouse->y = state->lLastY; + } + else + winraw_init_mouse_xy_mapping(); + } + else if (state->lLastX || state->lLastY) + { + InterlockedExchangeAdd(&mouse->dlt_x, state->lLastX); + InterlockedExchangeAdd(&mouse->dlt_y, state->lLastY); + + if (!GetCursorPos(&crs_pos)) + { + RARCH_WARN("[WINRAW]: GetCursorPos failed with error %lu.\n", GetLastError()); + } + else if (!ScreenToClient((HWND)video_driver_window_get(), &crs_pos)) + { + RARCH_WARN("[WINRAW]: ScreenToClient failed with error %lu.\n", GetLastError()); + } + else + { + mouse->x = crs_pos.x; + mouse->y = crs_pos.y; + } + } + + if (state->usButtonFlags & RI_MOUSE_LEFT_BUTTON_DOWN) + mouse->btn_l = true; + else if (state->usButtonFlags & RI_MOUSE_LEFT_BUTTON_UP) + mouse->btn_l = false; + + if (state->usButtonFlags & RI_MOUSE_MIDDLE_BUTTON_DOWN) + mouse->btn_m = true; + else if (state->usButtonFlags & RI_MOUSE_MIDDLE_BUTTON_UP) + mouse->btn_m = false; + + if (state->usButtonFlags & RI_MOUSE_RIGHT_BUTTON_DOWN) + mouse->btn_r = true; + else if (state->usButtonFlags & RI_MOUSE_RIGHT_BUTTON_UP) + mouse->btn_r = false; + + if (state->usButtonFlags & RI_MOUSE_BUTTON_4_DOWN) + mouse->btn_b4 = true; + else if (state->usButtonFlags & RI_MOUSE_BUTTON_4_UP) + mouse->btn_b4 = false; + + if (state->usButtonFlags & RI_MOUSE_BUTTON_5_DOWN) + mouse->btn_b5 = true; + else if (state->usButtonFlags & RI_MOUSE_BUTTON_5_UP) + mouse->btn_b5 = false; + + if (state->usButtonFlags & RI_MOUSE_WHEEL) + { + if ((SHORT)state->usButtonData > 0) + InterlockedExchange(&mouse->whl_u, 1); + else if ((SHORT)state->usButtonData < 0) + InterlockedExchange(&mouse->whl_d, 1); + } +} + +static LRESULT CALLBACK winraw_callback(HWND wnd, UINT msg, WPARAM wpar, LPARAM lpar) +{ + static uint8_t data[1024]; + UINT r; + unsigned i; + RAWINPUT *ri = (RAWINPUT*)data; + UINT size = sizeof(data); + + if (msg != WM_INPUT) + return DefWindowProcA(wnd, msg, wpar, lpar); + + /* app is in the background */ + if (GET_RAWINPUT_CODE_WPARAM(wpar) != RIM_INPUT) + goto end; + + r = GetRawInputData((HRAWINPUT)lpar, RID_INPUT, + data, &size, sizeof(RAWINPUTHEADER)); + if (r == (UINT)-1) + { + RARCH_WARN("[WINRAW]: GetRawInputData failed with error %lu.\n", + GetLastError()); + goto end; + } + + if (ri->header.dwType == RIM_TYPEKEYBOARD) + { + if (ri->data.keyboard.Message == WM_KEYDOWN) + g_keyboard->keys[ri->data.keyboard.VKey] = 1; + else if (ri->data.keyboard.Message == WM_KEYUP) + g_keyboard->keys[ri->data.keyboard.VKey] = 0; + } + else if (ri->header.dwType == RIM_TYPEMOUSE) + { + for (i = 0; i < g_mouse_cnt; ++i) + { + if (g_mice[i].hnd == ri->header.hDevice) + { + winraw_update_mouse_state(&g_mice[i], &ri->data.mouse); + break; + } + } + } + +end: + DefWindowProcA(wnd, msg, wpar, lpar); + return 0; +} + +static void *winraw_init(const char *joypad_driver) +{ + bool r; + winraw_input_t *wr = (winraw_input_t *) + calloc(1, sizeof(winraw_input_t)); + g_keyboard = (winraw_keyboard_t*) + calloc(1, sizeof(winraw_keyboard_t)); + + if (!wr || !g_keyboard) + goto error; + + RARCH_LOG("[WINRAW]: Initializing input driver... \n"); + + input_keymaps_init_keyboard_lut(rarch_key_map_winraw); + + wr->window = winraw_create_window(winraw_callback); + if (!wr->window) + goto error; + + r = winraw_init_devices(&g_mice, &g_mouse_cnt); + if (!r) + goto error; + + if (!g_mouse_cnt) + { + RARCH_LOG("[WINRAW]: Mouse unavailable.\n"); + } + else + { + wr->mice = (winraw_mouse_t*) + malloc(g_mouse_cnt * sizeof(winraw_mouse_t)); + if (!wr->mice) + goto error; + + memcpy(wr->mice, g_mice, g_mouse_cnt * sizeof(winraw_mouse_t)); + } + + r = winraw_set_keyboard_input(wr->window); + if (!r) + goto error; + + r = winraw_set_mouse_input(wr->window, false); + if (!r) + goto error; + + wr->joypad = input_joypad_init_driver(joypad_driver, wr); + + return wr; + +error: + if (wr && wr->window) + { + winraw_set_mouse_input(NULL, false); + winraw_set_keyboard_input(NULL); + winraw_destroy_window(wr->window); + } + free(g_keyboard); + free(g_mice); + if (wr) + free(wr->mice); + free(wr); + return NULL; +} + +static void winraw_poll(void *d) +{ + unsigned i; + winraw_input_t *wr = (winraw_input_t*)d; + + memcpy(&wr->keyboard, g_keyboard, sizeof(winraw_keyboard_t)); + + /* following keys are not handled by windows raw input api */ + wr->keyboard.keys[VK_LCONTROL] = GetAsyncKeyState(VK_LCONTROL) >> 1 ? 1 : 0; + wr->keyboard.keys[VK_RCONTROL] = GetAsyncKeyState(VK_RCONTROL) >> 1 ? 1 : 0; + wr->keyboard.keys[VK_LMENU] = GetAsyncKeyState(VK_LMENU) >> 1 ? 1 : 0; + wr->keyboard.keys[VK_RMENU] = GetAsyncKeyState(VK_RMENU) >> 1 ? 1 : 0; + wr->keyboard.keys[VK_LSHIFT] = GetAsyncKeyState(VK_LSHIFT) >> 1 ? 1 : 0; + wr->keyboard.keys[VK_RSHIFT] = GetAsyncKeyState(VK_RSHIFT) >> 1 ? 1 : 0; + + for (i = 0; i < g_mouse_cnt; ++i) + { + wr->mice[i].x = g_mice[i].x; + wr->mice[i].y = g_mice[i].y; + wr->mice[i].dlt_x = InterlockedExchange(&g_mice[i].dlt_x, 0); + wr->mice[i].dlt_y = InterlockedExchange(&g_mice[i].dlt_y, 0); + wr->mice[i].whl_u = InterlockedExchange(&g_mice[i].whl_u, 0); + wr->mice[i].whl_d = InterlockedExchange(&g_mice[i].whl_d, 0); + wr->mice[i].btn_l = g_mice[i].btn_l; + wr->mice[i].btn_m = g_mice[i].btn_m; + wr->mice[i].btn_r = g_mice[i].btn_r; + wr->mice[i].btn_b4 = g_mice[i].btn_b4; + wr->mice[i].btn_b5 = g_mice[i].btn_b5; + } + + if (wr->joypad) + wr->joypad->poll(); +} + +static int16_t winraw_input_state(void *d, + rarch_joypad_info_t joypad_info, + const struct retro_keybind **binds, + unsigned port, unsigned device, unsigned index, unsigned id) +{ + winraw_input_t *wr = (winraw_input_t*)d; + + switch (device) + { + case RETRO_DEVICE_KEYBOARD: + if (id < RETROK_LAST) + { + unsigned key = rarch_keysym_lut[(enum retro_key)id]; + return wr->keyboard.keys[key]; + } + break; + case RETRO_DEVICE_MOUSE: + return winraw_mouse_state(wr, port, false, id); + case RARCH_DEVICE_MOUSE_SCREEN: + return winraw_mouse_state(wr, port, true, id); + case RETRO_DEVICE_JOYPAD: + return winraw_joypad_state(wr, joypad_info, binds[port], port, id); + case RETRO_DEVICE_ANALOG: + if (binds[port]) + return input_joypad_analog(wr->joypad, joypad_info, + port, index, id, binds[port]); + break; + case RETRO_DEVICE_LIGHTGUN: + return winraw_lightgun_state(wr, port, id); + } + + return 0; +} + +static bool winraw_meta_key_pressed(void *u1, int u2) +{ + return false; +} + +static void winraw_free(void *d) +{ + winraw_input_t *wr = (winraw_input_t*)d; + + if (wr->joypad) + wr->joypad->destroy(); + winraw_set_mouse_input(NULL, false); + winraw_set_keyboard_input(NULL); + winraw_destroy_window(wr->window); + free(g_mice); + free(g_keyboard); + free(wr->mice); + free(wr); + + g_mouse_xy_mapping_ready = false; +} + +static uint64_t winraw_get_capabilities(void *u) +{ + return (1 << RETRO_DEVICE_KEYBOARD) | + (1 << RETRO_DEVICE_MOUSE) | + (1 << RETRO_DEVICE_JOYPAD) | + (1 << RETRO_DEVICE_ANALOG) | + (1 << RETRO_DEVICE_LIGHTGUN); +} + +static void winraw_grab_mouse(void *d, bool grab) +{ + bool r = false; + winraw_input_t *wr = (winraw_input_t*)d; + + if (grab == wr->mouse_grab) + return; + + r = winraw_set_mouse_input(wr->window, grab); + if (!r) + return; + + wr->mouse_grab = grab; +} + +static bool winraw_set_rumble(void *d, unsigned port, + enum retro_rumble_effect effect, uint16_t strength) +{ + winraw_input_t *wr = (winraw_input_t*)d; + + return input_joypad_set_rumble(wr->joypad, port, effect, strength); +} + +static const input_device_driver_t *winraw_get_joypad_driver(void *d) +{ + winraw_input_t *wr = (winraw_input_t*)d; + + return wr->joypad; +} + +static bool winraw_keyboard_mapping_is_blocked(void *d) +{ + winraw_input_t *wr = (winraw_input_t*)d; + + return wr->kbd_mapp_block; +} + +static void winraw_keyboard_mapping_set_block(void *d, bool block) +{ + winraw_input_t *wr = (winraw_input_t*)d; + + wr->kbd_mapp_block = block; +} + +input_driver_t input_winraw = { + winraw_init, + winraw_poll, + winraw_input_state, + winraw_meta_key_pressed, + winraw_free, + NULL, + NULL, + winraw_get_capabilities, + "raw", + winraw_grab_mouse, + NULL, + winraw_set_rumble, + winraw_get_joypad_driver, + NULL, + winraw_keyboard_mapping_is_blocked, + winraw_keyboard_mapping_set_block, +}; From 59812e95097165695e90db13b3aaf9aa2dba2f51 Mon Sep 17 00:00:00 2001 From: David Walters Date: Sun, 26 Nov 2017 13:23:39 +0000 Subject: [PATCH 022/394] include mouse buttons in block hotkey check --- input/input_driver.c | 1 + 1 file changed, 1 insertion(+) diff --git a/input/input_driver.c b/input/input_driver.c index d603a6a12e..f1abed8726 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -381,6 +381,7 @@ static const void *hid_data = NULL; #define check_input_driver_block_hotkey(normal_bind, autoconf_bind) \ ( \ (((normal_bind)->key != RETROK_UNKNOWN) \ + || ((normal_bind)->mbutton != NO_BTN) \ || ((normal_bind)->joykey != NO_BTN) \ || ((normal_bind)->joyaxis != AXIS_NONE) \ || ((autoconf_bind)->key != RETROK_UNKNOWN ) \ From cdb5a656f28eaf21181ff604dd583f5a65692560 Mon Sep 17 00:00:00 2001 From: David Walters Date: Sun, 26 Nov 2017 15:40:27 +0000 Subject: [PATCH 023/394] dinput: only support hardware mouse index 0 --- input/drivers/dinput.c | 44 +++++++++++++++++++++++++++++++++++------- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/input/drivers/dinput.c b/input/drivers/dinput.c index 6e525355f0..23fe84a719 100644 --- a/input/drivers/dinput.c +++ b/input/drivers/dinput.c @@ -49,6 +49,7 @@ #include "../../gfx/video_driver.h" +#include "../../configuration.h" #include "../../verbosity.h" /* Keep track of which pad indexes are 360 controllers. @@ -267,9 +268,18 @@ static bool dinput_keyboard_pressed(struct dinput_input *di, unsigned key) return di->state[sym] & 0x80; } -static bool dinput_mbutton_pressed(struct dinput_input *di, unsigned key) +static bool dinput_mbutton_pressed(struct dinput_input *di, unsigned port, unsigned key) { bool result; + settings_t *settings = config_get_ptr(); + + if (port >= MAX_USERS) + return false; + + /* the driver only supports one mouse */ + if ( settings->uints.input_mouse_index[ port ] != 0 ) { + return false; + } switch ( key ) { @@ -321,7 +331,7 @@ static bool dinput_is_pressed(struct dinput_input *di, return true; if (binds && binds[id].valid) { - if (dinput_mbutton_pressed(di, bind->mbutton)) + if (dinput_mbutton_pressed(di, port, bind->mbutton)) return true; if (input_joypad_pressed(di->joypad, joypad_info, port, binds, id)) return true; @@ -382,10 +392,20 @@ static int16_t dinput_lightgun_state(struct dinput_input *di, unsigned id) return 0; } -static int16_t dinput_mouse_state(struct dinput_input *di, unsigned id) +static int16_t dinput_mouse_state(struct dinput_input *di, unsigned port, unsigned id) { int16_t state = 0; + settings_t *settings = config_get_ptr(); + + if (port >= MAX_USERS) + return false; + + /* the driver only supports one mouse */ + if ( settings->uints.input_mouse_index[ port ] != 0 ) { + return 0; + } + switch (id) { case RETRO_DEVICE_ID_MOUSE_X: @@ -427,8 +447,18 @@ static int16_t dinput_mouse_state(struct dinput_input *di, unsigned id) return 0; } -static int16_t dinput_mouse_state_screen(struct dinput_input *di, unsigned id) +static int16_t dinput_mouse_state_screen(struct dinput_input *di, unsigned port, unsigned id) { + settings_t *settings = config_get_ptr(); + + if (port >= MAX_USERS) + return false; + + /* the driver only supports one mouse */ + if ( settings->uints.input_mouse_index[ port ] != 0 ) { + return 0; + } + switch (id) { case RETRO_DEVICE_ID_MOUSE_X: @@ -439,7 +469,7 @@ static int16_t dinput_mouse_state_screen(struct dinput_input *di, unsigned id) break; } - return dinput_mouse_state(di, id); + return dinput_mouse_state(di, port, id); } static int16_t dinput_pointer_state(struct dinput_input *di, @@ -542,10 +572,10 @@ static int16_t dinput_input_state(void *data, return 0; case RETRO_DEVICE_MOUSE: - return dinput_mouse_state(di, id); + return dinput_mouse_state(di, port, id); case RARCH_DEVICE_MOUSE_SCREEN: - return dinput_mouse_state_screen(di, id); + return dinput_mouse_state_screen(di, port, id); case RETRO_DEVICE_POINTER: case RARCH_DEVICE_POINTER_SCREEN: From c733f96a1670b97fa1ff4df73fedd818c9d101f4 Mon Sep 17 00:00:00 2001 From: David Walters Date: Sun, 26 Nov 2017 15:42:47 +0000 Subject: [PATCH 024/394] listen for mouse buttons/wheel when binding input --- input/input_driver.c | 35 +++++++++++++++++++++++++++ input/input_driver.h | 15 +++++++++++- menu/widgets/menu_input_bind_dialog.c | 34 +++++++++++++++++++++++++- 3 files changed, 82 insertions(+), 2 deletions(-) diff --git a/input/input_driver.c b/input/input_driver.c index f1abed8726..8a6751c06f 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -1745,6 +1745,41 @@ bool input_joypad_hat_raw(const input_device_driver_t *drv, return drv->button(port, HAT_MAP(hat, hat_dir)); } +/** + * input_mouse_button_raw: + * @port : Mouse number. + * @button : Identifier of key (libretro mouse constant). + * + * Checks if key (@button) was being pressed by user + * with mouse number @port. + * + * Returns: true (1) if key was pressed, otherwise + * false (0). + **/ +bool input_mouse_button_raw(unsigned port, unsigned id) +{ + int16_t res; + rarch_joypad_info_t joypad_info; + settings_t *settings = config_get_ptr(); + + /*ignore axes*/ + if ( id == RETRO_DEVICE_ID_MOUSE_X || id == RETRO_DEVICE_ID_MOUSE_Y ) { + return false; + } + + joypad_info.axis_threshold = input_driver_axis_threshold; + joypad_info.joy_idx = settings->uints.input_joypad_map[port]; + joypad_info.auto_binds = input_autoconf_binds[joypad_info.joy_idx]; + + res = current_input->input_state(current_input_data, + joypad_info, libretro_input_binds, port, RETRO_DEVICE_MOUSE, 0, id); + + if ( res ) { + return true; + } + return false; +} + /** * input_conv_analog_id_to_bind_id: * @idx : Analog key index. diff --git a/input/input_driver.h b/input/input_driver.h index 7cd3c068a6..c3084979a9 100644 --- a/input/input_driver.h +++ b/input/input_driver.h @@ -608,7 +608,20 @@ bool input_joypad_hat_raw(const input_device_driver_t *driver, unsigned joypad, unsigned hat_dir, unsigned hat); /** - * input_joypad_name: + * input_mouse_button_raw: + * @port : Mouse number. + * @button : Identifier of key (libretro mouse constant). + * + * Checks if key (@button) was being pressed by user + * with mouse number @port. + * + * Returns: true (1) if key was pressed, otherwise + * false (0). + **/ +bool input_mouse_button_raw(unsigned port, unsigned button); + +/** + * input_joypad_name: * @drv : Input device driver handle. * @port : Joystick number. * diff --git a/menu/widgets/menu_input_bind_dialog.c b/menu/widgets/menu_input_bind_dialog.c index 960110fcb8..456ae54b46 100644 --- a/menu/widgets/menu_input_bind_dialog.c +++ b/menu/widgets/menu_input_bind_dialog.c @@ -30,9 +30,11 @@ #define MENU_MAX_BUTTONS 219 #define MENU_MAX_AXES 32 #define MENU_MAX_HATS 4 +#define MENU_MAX_MBUTTONS 32 /*enough to cover largest libretro constant*/ struct menu_bind_state_port { + bool mbuttons[MENU_MAX_MBUTTONS]; bool buttons[MENU_MAX_BUTTONS]; int16_t axes[MENU_MAX_AXES]; uint16_t hats[MENU_MAX_HATS]; @@ -206,6 +208,7 @@ static void menu_input_key_bind_poll_bind_state( unsigned port, bool timed_out) { + unsigned b; rarch_joypad_info_t joypad_info; const input_device_driver_t *joypad = input_driver_get_joypad_driver(); @@ -217,6 +220,11 @@ static void menu_input_key_bind_poll_bind_state( memset(state->state, 0, sizeof(state->state)); + /* poll mouse (on the relevant port) */ + for (b = 0; b < MENU_MAX_MBUTTONS; b++) + state->state[port].mbuttons[b] = + input_mouse_button_raw(port, b); + joypad_info.joy_idx = 0; joypad_info.auto_binds = NULL; joypad_info.axis_threshold = 0.0f; @@ -277,6 +285,30 @@ static bool menu_input_key_bind_poll_find_trigger_pad( const struct menu_bind_state_port *o = (const struct menu_bind_state_port*) &state->state[p]; + for (b = 0; b < MENU_MAX_MBUTTONS; b++) + { + bool iterate = n->mbuttons[b] && !o->mbuttons[b]; + + if (!iterate) + continue; + + switch ( b ) + { + + case RETRO_DEVICE_ID_MOUSE_LEFT: + case RETRO_DEVICE_ID_MOUSE_RIGHT: + case RETRO_DEVICE_ID_MOUSE_MIDDLE: + case RETRO_DEVICE_ID_MOUSE_BUTTON_4: + case RETRO_DEVICE_ID_MOUSE_BUTTON_5: + case RETRO_DEVICE_ID_MOUSE_WHEELUP: + case RETRO_DEVICE_ID_MOUSE_WHEELDOWN: + case RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELUP: + case RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELDOWN: + state->target->mbutton = b; + return true; + } + } + for (b = 0; b < MENU_MAX_BUTTONS; b++) { bool iterate = n->buttons[b] && !o->buttons[b]; @@ -398,7 +430,7 @@ bool menu_input_key_bind_iterate(menu_input_ctx_bind_t *bind) } snprintf(bind->s, bind->len, - "[%s]\npress keyboard or joypad\n(timeout %d %s)", + "[%s]\npress keyboard, mouse or joypad\n(timeout %d %s)", input_config_bind_map_get_desc( menu_input_binds.begin - MENU_SETTINGS_BIND_BEGIN), rarch_timer_get_timeout(&menu_input_binds.timer), From 1003e681cc7bfb03cf883a4a077820b4ac9cf1a7 Mon Sep 17 00:00:00 2001 From: radius Date: Sun, 26 Nov 2017 11:33:02 -0500 Subject: [PATCH 025/394] don't assume the core never has content --- tasks/task_content.c | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) diff --git a/tasks/task_content.c b/tasks/task_content.c index 9877d6b375..0c8f0b4129 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -173,27 +173,21 @@ static void content_load_init_wrap( *argc = 0; argv[(*argc)++] = strdup("retroarch"); -#ifdef HAVE_DYNAMIC - if (!args->no_content) + if (args->content_path) { -#endif - if (args->content_path) - { - RARCH_LOG("Using content: %s.\n", args->content_path); - argv[(*argc)++] = strdup(args->content_path); - } + RARCH_LOG("Using content: %s.\n", args->content_path); + argv[(*argc)++] = strdup(args->content_path); + } #ifdef HAVE_MENU - else - { - RARCH_LOG("%s\n", - msg_hash_to_str(MSG_NO_CONTENT_STARTING_DUMMY_CORE)); - argv[(*argc)++] = strdup("--menu"); - } -#endif -#ifdef HAVE_DYNAMIC + else + { + RARCH_LOG("%s\n", + msg_hash_to_str(MSG_NO_CONTENT_STARTING_DUMMY_CORE)); + argv[(*argc)++] = strdup("--menu"); } #endif + if (args->sram_path) { argv[(*argc)++] = strdup("-s"); From db2ce016de8178ad953b7477a33b18df317ec044 Mon Sep 17 00:00:00 2001 From: radius Date: Sun, 26 Nov 2017 11:33:18 -0500 Subject: [PATCH 026/394] clear paths properly before loading the next core without closing content --- command.c | 1 + 1 file changed, 1 insertion(+) diff --git a/command.c b/command.c index ac088b7fdb..7f281ba546 100644 --- a/command.c +++ b/command.c @@ -1805,6 +1805,7 @@ bool command_event(enum event_command cmd, void *data) case CMD_EVENT_LOAD_CORE_PERSIST: { #ifdef HAVE_MENU + path_clear_all(); core_info_ctx_find_t info_find; rarch_system_info_t *system_info = runloop_get_system_info(); struct retro_system_info *system = &system_info->info; From 218d7f88ffdd7acac70eb14ff3c4024985052382 Mon Sep 17 00:00:00 2001 From: David Walters Date: Sun, 26 Nov 2017 16:46:33 +0000 Subject: [PATCH 027/394] New lightgun API in libretro.h --- libretro-common/include/libretro.h | 39 ++++++++++++++++++++++-------- 1 file changed, 29 insertions(+), 10 deletions(-) diff --git a/libretro-common/include/libretro.h b/libretro-common/include/libretro.h index 27b61b70b7..4cb422bfcc 100644 --- a/libretro-common/include/libretro.h +++ b/libretro-common/include/libretro.h @@ -126,8 +126,14 @@ extern "C" { */ #define RETRO_DEVICE_KEYBOARD 3 -/* Lightgun X/Y coordinates are reported relatively to last poll, - * similar to mouse. */ +/* LIGHTGUN device is similar to Guncon-2 for PlayStation 2. + * It reports X/Y coordinates in screen space (similar to the pointer) + * in the range [-0x8000, 0x7fff] in both axes, with zero being center. + * As well as reporting on/off screen state. It features a trigger, + * start/select buttons, four auxiliary action buttons and a + * directional pad. A forced off-screen shot can be requested for + * auto-reloading function in some games. + */ #define RETRO_DEVICE_LIGHTGUN 4 /* The ANALOG device is an extension to JOYPAD (RetroPad). @@ -214,14 +220,27 @@ extern "C" { #define RETRO_DEVICE_ID_MOUSE_BUTTON_4 9 #define RETRO_DEVICE_ID_MOUSE_BUTTON_5 10 -/* Id values for LIGHTGUN types. */ -#define RETRO_DEVICE_ID_LIGHTGUN_X 0 -#define RETRO_DEVICE_ID_LIGHTGUN_Y 1 -#define RETRO_DEVICE_ID_LIGHTGUN_TRIGGER 2 -#define RETRO_DEVICE_ID_LIGHTGUN_CURSOR 3 -#define RETRO_DEVICE_ID_LIGHTGUN_TURBO 4 -#define RETRO_DEVICE_ID_LIGHTGUN_PAUSE 5 -#define RETRO_DEVICE_ID_LIGHTGUN_START 6 +/* Id values for LIGHTGUN. */ +#define RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X 13 /*Absolute Position*/ +#define RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y 14 /*Absolute*/ +#define RETRO_DEVICE_ID_LIGHTGUN_IS_OFFSCREEN 15 /*Status Check*/ +#define RETRO_DEVICE_ID_LIGHTGUN_TRIGGER 2 +#define RETRO_DEVICE_ID_LIGHTGUN_RELOAD 16 /*Forced off-screen shot*/ +#define RETRO_DEVICE_ID_LIGHTGUN_AUX_A 3 +#define RETRO_DEVICE_ID_LIGHTGUN_AUX_B 4 +#define RETRO_DEVICE_ID_LIGHTGUN_START 6 +#define RETRO_DEVICE_ID_LIGHTGUN_SELECT 7 +#define RETRO_DEVICE_ID_LIGHTGUN_AUX_C 8 +#define RETRO_DEVICE_ID_LIGHTGUN_DPAD_UP 9 +#define RETRO_DEVICE_ID_LIGHTGUN_DPAD_DOWN 10 +#define RETRO_DEVICE_ID_LIGHTGUN_DPAD_LEFT 11 +#define RETRO_DEVICE_ID_LIGHTGUN_DPAD_RIGHT 12 +/* deprecated */ +#define RETRO_DEVICE_ID_LIGHTGUN_X 0 /*Relative Position*/ +#define RETRO_DEVICE_ID_LIGHTGUN_Y 1 /*Relative*/ +#define RETRO_DEVICE_ID_LIGHTGUN_CURSOR 3 /*Use Aux:A*/ +#define RETRO_DEVICE_ID_LIGHTGUN_TURBO 4 /*Use Aux:B*/ +#define RETRO_DEVICE_ID_LIGHTGUN_PAUSE 5 /*Use Start*/ /* Id values for POINTER. */ #define RETRO_DEVICE_ID_POINTER_X 0 From 70ff6db30c207180b8a16612bbe49b6cef3db548 Mon Sep 17 00:00:00 2001 From: David Walters Date: Sun, 26 Nov 2017 16:46:52 +0000 Subject: [PATCH 028/394] Lightgun input localisation strings. English only --- intl/msg_hash_chs.h | 22 ++++++++++++++++++++++ intl/msg_hash_cht.h | 22 ++++++++++++++++++++++ intl/msg_hash_de.h | 22 ++++++++++++++++++++++ intl/msg_hash_eo.h | 22 ++++++++++++++++++++++ intl/msg_hash_fr.h | 22 ++++++++++++++++++++++ intl/msg_hash_it.h | 22 ++++++++++++++++++++++ intl/msg_hash_ja.h | 22 ++++++++++++++++++++++ intl/msg_hash_ko.h | 22 ++++++++++++++++++++++ intl/msg_hash_nl.h | 22 ++++++++++++++++++++++ intl/msg_hash_pt_br.h | 22 ++++++++++++++++++++++ intl/msg_hash_pt_pt.h | 22 ++++++++++++++++++++++ intl/msg_hash_ru.h | 22 ++++++++++++++++++++++ intl/msg_hash_us.h | 22 ++++++++++++++++++++++ intl/msg_hash_vn.h | 22 ++++++++++++++++++++++ msg_hash.h | 11 +++++++++++ 15 files changed, 319 insertions(+) diff --git a/intl/msg_hash_chs.h b/intl/msg_hash_chs.h index db03e7ddd5..a153ea7f21 100644 --- a/intl/msg_hash_chs.h +++ b/intl/msg_hash_chs.h @@ -682,6 +682,28 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS, "右摇杆Y- (上)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_PLUS, "右摇杆Y+ (下)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_TRIGGER, + "Gun Trigger") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_RELOAD, + "Gun Reload") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_A, + "Gun Aux A") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_B, + "Gun Aux B") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_C, + "Gun Aux C") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_START, + "Gun Start") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_SELECT, + "Gun Select") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_UP, + "Gun D-pad Up") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_DOWN, + "Gun D-pad Down") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_LEFT, + "Gun D-pad Left") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_RIGHT, + "Gun D-pad Right") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_AUTODETECT_ENABLE, "启用自动配置") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_AXIS_THRESHOLD, diff --git a/intl/msg_hash_cht.h b/intl/msg_hash_cht.h index 6eeed496da..2f3faad0a0 100644 --- a/intl/msg_hash_cht.h +++ b/intl/msg_hash_cht.h @@ -682,6 +682,28 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS, "右搖桿Y- (上)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_PLUS, "右搖桿Y+ (下)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_TRIGGER, + "Gun Trigger") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_RELOAD, + "Gun Reload") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_A, + "Gun Aux A") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_B, + "Gun Aux B") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_C, + "Gun Aux C") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_START, + "Gun Start") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_SELECT, + "Gun Select") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_UP, + "Gun D-pad Up") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_DOWN, + "Gun D-pad Down") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_LEFT, + "Gun D-pad Left") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_RIGHT, + "Gun D-pad Right") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_AUTODETECT_ENABLE, "啟用自動設定") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_AXIS_THRESHOLD, diff --git a/intl/msg_hash_de.h b/intl/msg_hash_de.h index 7b8eb52625..88a901c924 100644 --- a/intl/msg_hash_de.h +++ b/intl/msg_hash_de.h @@ -687,6 +687,28 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS, "Rechter Analogstick Y- (nach oben)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_PLUS, "Rechter Analogstick Y+ (nach unten)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_TRIGGER, + "Gun Trigger") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_RELOAD, + "Gun Reload") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_A, + "Gun Aux A") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_B, + "Gun Aux B") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_C, + "Gun Aux C") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_START, + "Gun Start") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_SELECT, + "Gun Select") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_UP, + "Gun D-pad Up") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_DOWN, + "Gun D-pad Down") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_LEFT, + "Gun D-pad Left") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_RIGHT, + "Gun D-pad Right") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_AUTODETECT_ENABLE, "Automatische Konfiguration aktivieren") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_AXIS_THRESHOLD, diff --git a/intl/msg_hash_eo.h b/intl/msg_hash_eo.h index 627cabb0e4..dd89e15d49 100644 --- a/intl/msg_hash_eo.h +++ b/intl/msg_hash_eo.h @@ -598,6 +598,28 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS, "Right analog Y- (up)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_PLUS, "Right analog Y+ (down)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_TRIGGER, + "Gun Trigger") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_RELOAD, + "Gun Reload") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_A, + "Gun Aux A") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_B, + "Gun Aux B") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_C, + "Gun Aux C") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_START, + "Gun Start") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_SELECT, + "Gun Select") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_UP, + "Gun D-pad Up") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_DOWN, + "Gun D-pad Down") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_LEFT, + "Gun D-pad Left") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_RIGHT, + "Gun D-pad Right") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_AUTODETECT_ENABLE, "Autoconfig Enable") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_AXIS_THRESHOLD, diff --git a/intl/msg_hash_fr.h b/intl/msg_hash_fr.h index ad92c95526..3de35add8f 100644 --- a/intl/msg_hash_fr.h +++ b/intl/msg_hash_fr.h @@ -681,6 +681,28 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS, "Analogique droit Y- (haut)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_PLUS, "Analogique droit Y+ (bas)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_TRIGGER, + "Gun Trigger") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_RELOAD, + "Gun Reload") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_A, + "Gun Aux A") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_B, + "Gun Aux B") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_C, + "Gun Aux C") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_START, + "Gun Start") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_SELECT, + "Gun Select") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_UP, + "Gun D-pad Up") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_DOWN, + "Gun D-pad Down") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_LEFT, + "Gun D-pad Left") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_RIGHT, + "Gun D-pad Right") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_AUTODETECT_ENABLE, "Activer l'autoconfiguration") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_AXIS_THRESHOLD, diff --git a/intl/msg_hash_it.h b/intl/msg_hash_it.h index d8f989e0ae..74aaf27942 100644 --- a/intl/msg_hash_it.h +++ b/intl/msg_hash_it.h @@ -687,6 +687,28 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS, "Analogico Destro Y- (su)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_PLUS, "Analogico Destro Y+ (giù)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_TRIGGER, + "Gun Trigger") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_RELOAD, + "Gun Reload") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_A, + "Gun Aux A") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_B, + "Gun Aux B") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_C, + "Gun Aux C") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_START, + "Gun Start") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_SELECT, + "Gun Select") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_UP, + "Gun D-pad Up") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_DOWN, + "Gun D-pad Down") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_LEFT, + "Gun D-pad Left") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_RIGHT, + "Gun D-pad Right") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_AUTODETECT_ENABLE, "Abilita Autoconfigurazione") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_AXIS_THRESHOLD, diff --git a/intl/msg_hash_ja.h b/intl/msg_hash_ja.h index eb233b64c6..5eee3b8c8d 100644 --- a/intl/msg_hash_ja.h +++ b/intl/msg_hash_ja.h @@ -705,6 +705,28 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS, "右アナログY- (上)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_PLUS, "右アナログY+ (下)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_TRIGGER, + "Gun Trigger") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_RELOAD, + "Gun Reload") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_A, + "Gun Aux A") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_B, + "Gun Aux B") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_C, + "Gun Aux C") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_START, + "Gun Start") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_SELECT, + "Gun Select") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_UP, + "Gun D-pad Up") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_DOWN, + "Gun D-pad Down") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_LEFT, + "Gun D-pad Left") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_RIGHT, + "Gun D-pad Right") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_AUTODETECT_ENABLE, "自動コンフィグを有効") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_AXIS_THRESHOLD, diff --git a/intl/msg_hash_ko.h b/intl/msg_hash_ko.h index f05b7b4ceb..4dcb2315ff 100644 --- a/intl/msg_hash_ko.h +++ b/intl/msg_hash_ko.h @@ -669,6 +669,28 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS, "우 아날로그 Y- (상)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_PLUS, "우 아날로그 Y+ (하)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_TRIGGER, + "Gun Trigger") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_RELOAD, + "Gun Reload") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_A, + "Gun Aux A") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_B, + "Gun Aux B") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_C, + "Gun Aux C") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_START, + "Gun Start") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_SELECT, + "Gun Select") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_UP, + "Gun D-pad Up") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_DOWN, + "Gun D-pad Down") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_LEFT, + "Gun D-pad Left") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_RIGHT, + "Gun D-pad Right") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_AUTODETECT_ENABLE, "자동설정 사용") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_AXIS_THRESHOLD, diff --git a/intl/msg_hash_nl.h b/intl/msg_hash_nl.h index aa441fa969..245ae1a437 100644 --- a/intl/msg_hash_nl.h +++ b/intl/msg_hash_nl.h @@ -598,6 +598,28 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS, "Right analog Y- (up)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_PLUS, "Right analog Y+ (down)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_TRIGGER, + "Gun Trigger") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_RELOAD, + "Gun Reload") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_A, + "Gun Aux A") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_B, + "Gun Aux B") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_C, + "Gun Aux C") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_START, + "Gun Start") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_SELECT, + "Gun Select") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_UP, + "Gun D-pad Up") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_DOWN, + "Gun D-pad Down") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_LEFT, + "Gun D-pad Left") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_RIGHT, + "Gun D-pad Right") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_AUTODETECT_ENABLE, "Autoconfiguratie Activeren") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_AXIS_THRESHOLD, diff --git a/intl/msg_hash_pt_br.h b/intl/msg_hash_pt_br.h index c8ce759e90..9e98aafce8 100644 --- a/intl/msg_hash_pt_br.h +++ b/intl/msg_hash_pt_br.h @@ -661,6 +661,28 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS, MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_PLUS, "Analógico Direito Y+ (baixo)" ) +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_TRIGGER, + "Gun Trigger") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_RELOAD, + "Gun Reload") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_A, + "Gun Aux A") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_B, + "Gun Aux B") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_C, + "Gun Aux C") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_START, + "Gun Start") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_SELECT, + "Gun Select") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_UP, + "Gun D-pad Up") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_DOWN, + "Gun D-pad Down") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_LEFT, + "Gun D-pad Left") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_RIGHT, + "Gun D-pad Right") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_AUTODETECT_ENABLE, "Habilitar Autoconfiguração" ) diff --git a/intl/msg_hash_pt_pt.h b/intl/msg_hash_pt_pt.h index bfb5b7cb3a..3c35f71320 100644 --- a/intl/msg_hash_pt_pt.h +++ b/intl/msg_hash_pt_pt.h @@ -669,6 +669,28 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS, "Analógico Direito Y- (cima)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_PLUS, "Analógico Direito Y+ (baixo)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_TRIGGER, + "Gun Trigger") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_RELOAD, + "Gun Reload") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_A, + "Gun Aux A") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_B, + "Gun Aux B") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_C, + "Gun Aux C") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_START, + "Gun Start") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_SELECT, + "Gun Select") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_UP, + "Gun D-pad Up") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_DOWN, + "Gun D-pad Down") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_LEFT, + "Gun D-pad Left") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_RIGHT, + "Gun D-pad Right") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_AUTODETECT_ENABLE, "Habilitar Auto-configuração") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_AXIS_THRESHOLD, diff --git a/intl/msg_hash_ru.h b/intl/msg_hash_ru.h index dfa3f024c7..7cb859c746 100644 --- a/intl/msg_hash_ru.h +++ b/intl/msg_hash_ru.h @@ -690,6 +690,28 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS, "Правый аналоговый стик - ось Y- (вверх)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_PLUS, "Правый аналоговый стик - ось Y+ (вниз)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_TRIGGER, + "Gun Trigger") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_RELOAD, + "Gun Reload") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_A, + "Gun Aux A") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_B, + "Gun Aux B") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_C, + "Gun Aux C") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_START, + "Gun Start") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_SELECT, + "Gun Select") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_UP, + "Gun D-pad Up") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_DOWN, + "Gun D-pad Down") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_LEFT, + "Gun D-pad Left") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_RIGHT, + "Gun D-pad Right") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_AUTODETECT_ENABLE, "Автоматическая настройка включена") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_AXIS_THRESHOLD, diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index 565e1b85f3..9760de42f9 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -699,6 +699,28 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS, "Right analog Y- (up)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_PLUS, "Right analog Y+ (down)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_TRIGGER, + "Gun Trigger") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_RELOAD, + "Gun Reload") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_A, + "Gun Aux A") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_B, + "Gun Aux B") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_C, + "Gun Aux C") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_START, + "Gun Start") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_SELECT, + "Gun Select") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_UP, + "Gun D-pad Up") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_DOWN, + "Gun D-pad Down") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_LEFT, + "Gun D-pad Left") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_RIGHT, + "Gun D-pad Right") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_AUTODETECT_ENABLE, "Autoconfig Enable") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_AXIS_THRESHOLD, diff --git a/intl/msg_hash_vn.h b/intl/msg_hash_vn.h index 00adb3fc70..662a1136c1 100644 --- a/intl/msg_hash_vn.h +++ b/intl/msg_hash_vn.h @@ -681,6 +681,28 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS, "Right analog Y- (up)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_PLUS, "Right analog Y+ (down)") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_TRIGGER, + "Gun Trigger") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_RELOAD, + "Gun Reload") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_A, + "Gun Aux A") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_B, + "Gun Aux B") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_C, + "Gun Aux C") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_START, + "Gun Start") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_SELECT, + "Gun Select") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_UP, + "Gun D-pad Up") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_DOWN, + "Gun D-pad Down") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_LEFT, + "Gun D-pad Left") +MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_RIGHT, + "Gun D-pad Right") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_AUTODETECT_ENABLE, "Kích hoạt Autoconfig") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_AXIS_THRESHOLD, diff --git a/msg_hash.h b/msg_hash.h index 8eb389a235..0cce4dfd36 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -568,6 +568,17 @@ enum msg_hash_enums MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_X_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS, + MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_TRIGGER, + MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_RELOAD, + MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_A, + MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_B, + MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_C, + MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_START, + MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_SELECT, + MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_UP, + MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_DOWN, + MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_LEFT, + MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_RIGHT, MENU_ENUM_LABEL_VALUE_INPUT_TURBO_ENABLE, MENU_ENUM_LABEL_VALUE_INPUT_META_FAST_FORWARD_KEY, From dbd9bf3b46c5ab8b2eaefa6cb6ec3dc53bd7b504 Mon Sep 17 00:00:00 2001 From: David Walters Date: Sun, 26 Nov 2017 16:59:48 +0000 Subject: [PATCH 029/394] New lightgun binds --- config.def.keybinds.h | 36 ++++++++++++++++++++++++++++++++++++ input/input_defines.h | 19 ++++++++++++++++++- input/input_driver.c | 12 ++++++++++++ 3 files changed, 66 insertions(+), 1 deletion(-) diff --git a/config.def.keybinds.h b/config.def.keybinds.h index 6a999a0e32..b7f0a32e86 100644 --- a/config.def.keybinds.h +++ b/config.def.keybinds.h @@ -50,6 +50,18 @@ static const struct retro_keybind retro_keybinds_1[] = { { true, RARCH_ANALOG_RIGHT_Y_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_PLUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, { true, RARCH_ANALOG_RIGHT_Y_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_TRIGGER, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_TRIGGER, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_RELOAD, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_RELOAD, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_AUX_A, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_A, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_AUX_B, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_B, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_AUX_C, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_C, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_START, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_START, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_SELECT, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_SELECT, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_DPAD_UP, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_UP, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_DPAD_DOWN, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_DOWN, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_DPAD_LEFT, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_LEFT, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_DPAD_RIGHT, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_RIGHT, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_TURBO_ENABLE, MENU_ENUM_LABEL_VALUE_INPUT_TURBO_ENABLE, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, { true, RARCH_FAST_FORWARD_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_FAST_FORWARD_KEY, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, @@ -113,6 +125,18 @@ static const struct retro_keybind retro_keybinds_1[] = { { true, RARCH_ANALOG_RIGHT_Y_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_PLUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, { true, RARCH_ANALOG_RIGHT_Y_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_TRIGGER, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_TRIGGER, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_RELOAD, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_RELOAD, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_AUX_A, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_A, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_AUX_B, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_B, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_AUX_C, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_C, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_START, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_START, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_SELECT, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_SELECT, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_DPAD_UP, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_UP, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_DPAD_DOWN, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_DOWN, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_DPAD_LEFT, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_LEFT, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_DPAD_RIGHT, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_RIGHT, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_TURBO_ENABLE, MENU_ENUM_LABEL_VALUE_INPUT_TURBO_ENABLE, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, { true, RARCH_FAST_FORWARD_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_FAST_FORWARD_KEY, RETROK_SPACE, NO_BTN, NO_BTN, 0, AXIS_NONE }, @@ -181,6 +205,18 @@ static const struct retro_keybind retro_keybinds_rest[] = { { true, RARCH_ANALOG_RIGHT_Y_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_PLUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, { true, RARCH_ANALOG_RIGHT_Y_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_TRIGGER, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_TRIGGER, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_RELOAD, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_RELOAD, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_AUX_A, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_A, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_AUX_B, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_B, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_AUX_C, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_C, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_START, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_START, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_SELECT, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_SELECT, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_DPAD_UP, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_UP, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_DPAD_DOWN, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_DOWN, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_DPAD_LEFT, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_LEFT, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_LIGHTGUN_DPAD_RIGHT, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_RIGHT, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, + { true, RARCH_TURBO_ENABLE, MENU_ENUM_LABEL_VALUE_INPUT_TURBO_ENABLE, RETROK_UNKNOWN, NO_BTN, NO_BTN, 0, AXIS_NONE }, }; diff --git a/input/input_defines.h b/input/input_defines.h index 2d1d88d3f3..d9ef13cc37 100644 --- a/input/input_defines.h +++ b/input/input_defines.h @@ -26,6 +26,8 @@ RETRO_BEGIN_DECLS #define MAX_USERS 16 #define RARCH_FIRST_CUSTOM_BIND 16 +#define RARCH_FIRST_LIGHTGUN_BIND RARCH_ANALOG_BIND_LIST_END +#define RARCH_FIRST_MISC_CUSTOM_BIND RARCH_LIGHTGUN_BIND_LIST_END #define RARCH_FIRST_META_KEY RARCH_CUSTOM_BIND_LIST_END /* RetroArch specific bind IDs. */ @@ -42,9 +44,24 @@ enum RARCH_ANALOG_RIGHT_X_MINUS, RARCH_ANALOG_RIGHT_Y_PLUS, RARCH_ANALOG_RIGHT_Y_MINUS, + RARCH_ANALOG_BIND_LIST_END, + + /* Lightgun */ + RARCH_LIGHTGUN_TRIGGER = RARCH_FIRST_LIGHTGUN_BIND, + RARCH_LIGHTGUN_RELOAD, + RARCH_LIGHTGUN_AUX_A, + RARCH_LIGHTGUN_AUX_B, + RARCH_LIGHTGUN_AUX_C, + RARCH_LIGHTGUN_START, + RARCH_LIGHTGUN_SELECT, + RARCH_LIGHTGUN_DPAD_UP, + RARCH_LIGHTGUN_DPAD_DOWN, + RARCH_LIGHTGUN_DPAD_LEFT, + RARCH_LIGHTGUN_DPAD_RIGHT, + RARCH_LIGHTGUN_BIND_LIST_END, /* Turbo */ - RARCH_TURBO_ENABLE, + RARCH_TURBO_ENABLE = RARCH_FIRST_MISC_CUSTOM_BIND, RARCH_CUSTOM_BIND_LIST_END, diff --git a/input/input_driver.c b/input/input_driver.c index 8a6751c06f..d19414199f 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -267,6 +267,18 @@ const struct input_bind_map input_config_bind_map[RARCH_BIND_LIST_END_NULL] = { DECLARE_BIND(r_y_plus, RARCH_ANALOG_RIGHT_Y_PLUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_PLUS), DECLARE_BIND(r_y_minus, RARCH_ANALOG_RIGHT_Y_MINUS, MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_MINUS), + DECLARE_BIND( gun_trigger, RARCH_LIGHTGUN_TRIGGER, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_TRIGGER ), + DECLARE_BIND( gun_offscreen_shot, RARCH_LIGHTGUN_RELOAD, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_RELOAD ), + DECLARE_BIND( gun_aux_a, RARCH_LIGHTGUN_AUX_A, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_A ), + DECLARE_BIND( gun_aux_b, RARCH_LIGHTGUN_AUX_B, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_B ), + DECLARE_BIND( gun_aux_c, RARCH_LIGHTGUN_AUX_C, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_C ), + DECLARE_BIND( gun_start, RARCH_LIGHTGUN_START, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_START ), + DECLARE_BIND( gun_select, RARCH_LIGHTGUN_SELECT, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_SELECT ), + DECLARE_BIND( gun_dpad_up, RARCH_LIGHTGUN_DPAD_UP, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_UP ), + DECLARE_BIND( gun_dpad_down, RARCH_LIGHTGUN_DPAD_DOWN, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_DOWN ), + DECLARE_BIND( gun_dpad_left, RARCH_LIGHTGUN_DPAD_LEFT, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_LEFT ), + DECLARE_BIND( gun_dpad_right, RARCH_LIGHTGUN_DPAD_RIGHT, MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_RIGHT ), + DECLARE_BIND(turbo, RARCH_TURBO_ENABLE, MENU_ENUM_LABEL_VALUE_INPUT_TURBO_ENABLE), DECLARE_META_BIND(1, toggle_fast_forward, RARCH_FAST_FORWARD_KEY, MENU_ENUM_LABEL_VALUE_INPUT_META_FAST_FORWARD_KEY), From 816ffe6fcfa005fd470cb5ae9479fd2374146fab Mon Sep 17 00:00:00 2001 From: David Walters Date: Sun, 26 Nov 2017 17:04:30 +0000 Subject: [PATCH 030/394] Change mouse button name style in localisation strings. --- intl/msg_hash_chs.h | 18 +++++++++--------- intl/msg_hash_cht.h | 18 +++++++++--------- intl/msg_hash_de.h | 18 +++++++++--------- intl/msg_hash_eo.h | 18 +++++++++--------- intl/msg_hash_fr.h | 18 +++++++++--------- intl/msg_hash_it.h | 18 +++++++++--------- intl/msg_hash_ja.h | 18 +++++++++--------- intl/msg_hash_ko.h | 18 +++++++++--------- intl/msg_hash_nl.h | 18 +++++++++--------- intl/msg_hash_pt_br.h | 18 +++++++++--------- intl/msg_hash_pt_pt.h | 18 +++++++++--------- intl/msg_hash_ru.h | 18 +++++++++--------- intl/msg_hash_us.h | 18 +++++++++--------- intl/msg_hash_vn.h | 18 +++++++++--------- 14 files changed, 126 insertions(+), 126 deletions(-) diff --git a/intl/msg_hash_chs.h b/intl/msg_hash_chs.h index a153ea7f21..d9d5f633c1 100644 --- a/intl/msg_hash_chs.h +++ b/intl/msg_hash_chs.h @@ -767,23 +767,23 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEY, "(键: %s)") /*FIXME:"(Key: %s)"*/ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_LEFT, - "MOUSE1") + "Mouse 1") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_RIGHT, - "MOUSE2") + "Mouse 2") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_MIDDLE, - "MOUSE3") + "Mouse 3") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON4, - "MOUSE4") + "Mouse 4") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON5, - "MOUSE5") + "Mouse 5") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_UP, - "MWHEELUP") + "Wheel Up") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_DOWN, - "MWHEELDN") + "Wheel Down") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_UP, - "MWHEELLEFT") + "Wheel Left") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_DOWN, - "MWHEELRIGHT") + "Wheel Right") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEYBOARD_GAMEPAD_MAPPING_TYPE, "键盘控制器映射类型") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MAX_USERS, diff --git a/intl/msg_hash_cht.h b/intl/msg_hash_cht.h index 2f3faad0a0..3074dc5f32 100644 --- a/intl/msg_hash_cht.h +++ b/intl/msg_hash_cht.h @@ -767,23 +767,23 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEY, "(鍵: %s)") /*FIXME:"(Key: %s)"*/ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_LEFT, - "MOUSE1") + "Mouse 1") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_RIGHT, - "MOUSE2") + "Mouse 2") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_MIDDLE, - "MOUSE3") + "Mouse 3") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON4, - "MOUSE4") + "Mouse 4") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON5, - "MOUSE5") + "Mouse 5") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_UP, - "MWHEELUP") + "Wheel Up") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_DOWN, - "MWHEELDN") + "Wheel Down") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_UP, - "MWHEELLEFT") + "Wheel Left") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_DOWN, - "MWHEELRIGHT") + "Wheel Right") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEYBOARD_GAMEPAD_MAPPING_TYPE, "鍵盤控制器映射類型") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MAX_USERS, diff --git a/intl/msg_hash_de.h b/intl/msg_hash_de.h index 88a901c924..e5bf9687e8 100644 --- a/intl/msg_hash_de.h +++ b/intl/msg_hash_de.h @@ -774,23 +774,23 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEY, "(Taste: %s)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_LEFT, - "MOUSE1") + "Mouse 1") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_RIGHT, - "MOUSE2") + "Mouse 2") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_MIDDLE, - "MOUSE3") + "Mouse 3") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON4, - "MOUSE4") + "Mouse 4") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON5, - "MOUSE5") + "Mouse 5") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_UP, - "MWHEELUP") + "Wheel Up") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_DOWN, - "MWHEELDN") + "Wheel Down") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_UP, - "MWHEELLEFT") + "Wheel Left") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_DOWN, - "MWHEELRIGHT") + "Wheel Right") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEYBOARD_GAMEPAD_MAPPING_TYPE, "Typ der Keyboard-Controller-Abbildung") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MAX_USERS, diff --git a/intl/msg_hash_eo.h b/intl/msg_hash_eo.h index dd89e15d49..3f16073e95 100644 --- a/intl/msg_hash_eo.h +++ b/intl/msg_hash_eo.h @@ -683,23 +683,23 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEY, "(Key: %s)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_LEFT, - "MOUSE1") + "Mouse 1") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_RIGHT, - "MOUSE2") + "Mouse 2") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_MIDDLE, - "MOUSE3") + "Mouse 3") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON4, - "MOUSE4") + "Mouse 4") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON5, - "MOUSE5") + "Mouse 5") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_UP, - "MWHEELUP") + "Wheel Up") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_DOWN, - "MWHEELDN") + "Wheel Down") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_UP, - "MWHEELLEFT") + "Wheel Left") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_DOWN, - "MWHEELRIGHT") + "Wheel Right") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEYBOARD_GAMEPAD_MAPPING_TYPE, "Keyboard Gamepad Mapping Type") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MAX_USERS, diff --git a/intl/msg_hash_fr.h b/intl/msg_hash_fr.h index 3de35add8f..1920e13ad8 100644 --- a/intl/msg_hash_fr.h +++ b/intl/msg_hash_fr.h @@ -768,23 +768,23 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEY, "(Touche : %s)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_LEFT, - "MOUSE1") + "Mouse 1") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_RIGHT, - "MOUSE2") + "Mouse 2") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_MIDDLE, - "MOUSE3") + "Mouse 3") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON4, - "MOUSE4") + "Mouse 4") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON5, - "MOUSE5") + "Mouse 5") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_UP, - "MWHEELUP") + "Wheel Up") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_DOWN, - "MWHEELDN") + "Wheel Down") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_UP, - "MWHEELLEFT") + "Wheel Left") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_DOWN, - "MWHEELRIGHT") + "Wheel Right") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEYBOARD_GAMEPAD_MAPPING_TYPE, "Type de mappage manette/clavier") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MAX_USERS, diff --git a/intl/msg_hash_it.h b/intl/msg_hash_it.h index 74aaf27942..22232ed4f4 100644 --- a/intl/msg_hash_it.h +++ b/intl/msg_hash_it.h @@ -774,23 +774,23 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEY, "(Tasto: %s)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_LEFT, - "MOUSE1") + "Mouse 1") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_RIGHT, - "MOUSE2") + "Mouse 2") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_MIDDLE, - "MOUSE3") + "Mouse 3") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON4, - "MOUSE4") + "Mouse 4") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON5, - "MOUSE5") + "Mouse 5") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_UP, - "MWHEELUP") + "Wheel Up") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_DOWN, - "MWHEELDN") + "Wheel Down") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_UP, - "MWHEELLEFT") + "Wheel Left") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_DOWN, - "MWHEELRIGHT") + "Wheel Right") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEYBOARD_GAMEPAD_MAPPING_TYPE, "Tipo di mappatura del gamepad della tastiera") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MAX_USERS, diff --git a/intl/msg_hash_ja.h b/intl/msg_hash_ja.h index 5eee3b8c8d..ebae8a65ed 100644 --- a/intl/msg_hash_ja.h +++ b/intl/msg_hash_ja.h @@ -792,23 +792,23 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEY, "(キー: %s)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_LEFT, - "MOUSE1") + "Mouse 1") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_RIGHT, - "MOUSE2") + "Mouse 2") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_MIDDLE, - "MOUSE3") + "Mouse 3") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON4, - "MOUSE4") + "Mouse 4") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON5, - "MOUSE5") + "Mouse 5") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_UP, - "MWHEELUP") + "Wheel Up") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_DOWN, - "MWHEELDN") + "Wheel Down") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_UP, - "MWHEELLEFT") + "Wheel Left") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_DOWN, - "MWHEELRIGHT") + "Wheel Right") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEYBOARD_GAMEPAD_MAPPING_TYPE, "キーボードのゲームパッドマッピング式") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MAX_USERS, diff --git a/intl/msg_hash_ko.h b/intl/msg_hash_ko.h index 4dcb2315ff..9a22edd4c8 100644 --- a/intl/msg_hash_ko.h +++ b/intl/msg_hash_ko.h @@ -754,23 +754,23 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEY, "(키: %s)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_LEFT, - "MOUSE1") + "Mouse 1") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_RIGHT, - "MOUSE2") + "Mouse 2") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_MIDDLE, - "MOUSE3") + "Mouse 3") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON4, - "MOUSE4") + "Mouse 4") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON5, - "MOUSE5") + "Mouse 5") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_UP, - "MWHEELUP") + "Wheel Up") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_DOWN, - "MWHEELDN") + "Wheel Down") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_UP, - "MWHEELLEFT") + "Wheel Left") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_DOWN, - "MWHEELRIGHT") + "Wheel Right") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEYBOARD_GAMEPAD_MAPPING_TYPE, "키보드 게임패드 설정 형식") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MAX_USERS, diff --git a/intl/msg_hash_nl.h b/intl/msg_hash_nl.h index 245ae1a437..dcd21e2962 100644 --- a/intl/msg_hash_nl.h +++ b/intl/msg_hash_nl.h @@ -683,23 +683,23 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEY, "(Key: %s)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_LEFT, - "MOUSE1") + "Mouse 1") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_RIGHT, - "MOUSE2") + "Mouse 2") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_MIDDLE, - "MOUSE3") + "Mouse 3") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON4, - "MOUSE4") + "Mouse 4") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON5, - "MOUSE5") + "Mouse 5") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_UP, - "MWHEELUP") + "Wheel Up") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_DOWN, - "MWHEELDN") + "Wheel Down") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_UP, - "MWHEELLEFT") + "Wheel Left") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_DOWN, - "MWHEELRIGHT") + "Wheel Right") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEYBOARD_GAMEPAD_MAPPING_TYPE, "Keyboard Gamepad Mapping Type") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MAX_USERS, diff --git a/intl/msg_hash_pt_br.h b/intl/msg_hash_pt_br.h index 9e98aafce8..2603504428 100644 --- a/intl/msg_hash_pt_br.h +++ b/intl/msg_hash_pt_br.h @@ -780,23 +780,23 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEY, "(Tecla: %s)" ) MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_LEFT, - "MOUSE1") + "Mouse 1") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_RIGHT, - "MOUSE2") + "Mouse 2") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_MIDDLE, - "MOUSE3") + "Mouse 3") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON4, - "MOUSE4") + "Mouse 4") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON5, - "MOUSE5") + "Mouse 5") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_UP, - "MWHEELUP") + "Wheel Up") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_DOWN, - "MWHEELDN") + "Wheel Down") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_UP, - "MWHEELLEFT") + "Wheel Left") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_DOWN, - "MWHEELRIGHT") + "Wheel Right") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEYBOARD_GAMEPAD_MAPPING_TYPE, "Tipo de Mapeamento para Gamepad no Teclado" ) diff --git a/intl/msg_hash_pt_pt.h b/intl/msg_hash_pt_pt.h index 3c35f71320..9e6cb8641d 100644 --- a/intl/msg_hash_pt_pt.h +++ b/intl/msg_hash_pt_pt.h @@ -754,23 +754,23 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEY, "(Tecla: %s)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_LEFT, - "MOUSE1") + "Mouse 1") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_RIGHT, - "MOUSE2") + "Mouse 2") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_MIDDLE, - "MOUSE3") + "Mouse 3") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON4, - "MOUSE4") + "Mouse 4") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON5, - "MOUSE5") + "Mouse 5") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_UP, - "MWHEELUP") + "Wheel Up") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_DOWN, - "MWHEELDN") + "Wheel Down") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_UP, - "MWHEELLEFT") + "Wheel Left") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_DOWN, - "MWHEELRIGHT") + "Wheel Right") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEYBOARD_GAMEPAD_MAPPING_TYPE, "Tipo de Mapeamento do Gamepad no Teclado") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MAX_USERS, diff --git a/intl/msg_hash_ru.h b/intl/msg_hash_ru.h index 7cb859c746..84aec3c7ba 100644 --- a/intl/msg_hash_ru.h +++ b/intl/msg_hash_ru.h @@ -777,23 +777,23 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEY, "(Клавиша: %s)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_LEFT, - "MOUSE1") + "Mouse 1") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_RIGHT, - "MOUSE2") + "Mouse 2") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_MIDDLE, - "MOUSE3") + "Mouse 3") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON4, - "MOUSE4") + "Mouse 4") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON5, - "MOUSE5") + "Mouse 5") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_UP, - "MWHEELUP") + "Wheel Up") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_DOWN, - "MWHEELDN") + "Wheel Down") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_UP, - "MWHEELLEFT") + "Wheel Left") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_DOWN, - "MWHEELRIGHT") + "Wheel Right") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEYBOARD_GAMEPAD_MAPPING_TYPE, "Тип отображения клавиатуры для геймпада") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MAX_USERS, diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index 9760de42f9..f877546905 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -786,23 +786,23 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEY, "(Key: %s)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_LEFT, - "MOUSE1") + "Mouse 1") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_RIGHT, - "MOUSE2") + "Mouse 2") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_MIDDLE, - "MOUSE3") + "Mouse 3") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON4, - "MOUSE4") + "Mouse 4") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON5, - "MOUSE5") + "Mouse 5") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_UP, - "MWHEELUP") + "Wheel Up") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_DOWN, - "MWHEELDN") + "Wheel Down") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_UP, - "MWHEELLEFT") + "Wheel Left") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_DOWN, - "MWHEELRIGHT") + "Wheel Right") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEYBOARD_GAMEPAD_MAPPING_TYPE, "Keyboard Gamepad Mapping Type") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MAX_USERS, diff --git a/intl/msg_hash_vn.h b/intl/msg_hash_vn.h index 662a1136c1..efea88ed20 100644 --- a/intl/msg_hash_vn.h +++ b/intl/msg_hash_vn.h @@ -766,23 +766,23 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_JOYPAD_Y, MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEY, "(Key: %s)") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_LEFT, - "MOUSE1") + "Mouse 1") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_RIGHT, - "MOUSE2") + "Mouse 2") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_MIDDLE, - "MOUSE3") + "Mouse 3") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON4, - "MOUSE4") + "Mouse 4") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON5, - "MOUSE5") + "Mouse 5") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_UP, - "MWHEELUP") + "Wheel Up") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_DOWN, - "MWHEELDN") + "Wheel Down") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_UP, - "MWHEELLEFT") + "Wheel Left") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_DOWN, - "MWHEELRIGHT") + "Wheel Right") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEYBOARD_GAMEPAD_MAPPING_TYPE, "Keyboard Gamepad Mapping Type") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MAX_USERS, From 59c188f75cb3e758b10077a1aa9de16382606103 Mon Sep 17 00:00:00 2001 From: David Walters Date: Sun, 26 Nov 2017 17:09:15 +0000 Subject: [PATCH 031/394] Implement new lightgun API --- input/drivers/dinput.c | 121 ++++++++++++++++++++++++++++++++++------- 1 file changed, 101 insertions(+), 20 deletions(-) diff --git a/input/drivers/dinput.c b/input/drivers/dinput.c index 23fe84a719..9b2e14f66e 100644 --- a/input/drivers/dinput.c +++ b/input/drivers/dinput.c @@ -369,27 +369,67 @@ static bool dinput_meta_key_pressed(void *data, int key) return false; } -static int16_t dinput_lightgun_state(struct dinput_input *di, unsigned id) +static int16_t dinput_lightgun_aiming_state( struct dinput_input *di, unsigned idx, unsigned id ) { - switch (id) - { - case RETRO_DEVICE_ID_LIGHTGUN_X: - return di->mouse_rel_x; - case RETRO_DEVICE_ID_LIGHTGUN_Y: - return di->mouse_rel_y; - case RETRO_DEVICE_ID_LIGHTGUN_TRIGGER: - return di->mouse_l; - case RETRO_DEVICE_ID_LIGHTGUN_CURSOR: - return di->mouse_m; - case RETRO_DEVICE_ID_LIGHTGUN_TURBO: - return di->mouse_r; - case RETRO_DEVICE_ID_LIGHTGUN_START: - return di->mouse_m && di->mouse_r; - case RETRO_DEVICE_ID_LIGHTGUN_PAUSE: - return di->mouse_m && di->mouse_l; - } + const int edge_detect = 32700; + struct video_viewport vp; + bool inside = false; + int x = 0; + int y = 0; + int16_t res_x = 0; + int16_t res_y = 0; + int16_t res_screen_x = 0; + int16_t res_screen_y = 0; + unsigned num = 0; - return 0; + struct pointer_status* check_pos = di->pointer_head.next; + + vp.x = 0; + vp.y = 0; + vp.width = 0; + vp.height = 0; + vp.full_width = 0; + vp.full_height = 0; + + while ( check_pos && num < idx ) + { + num++; + check_pos = check_pos->next; + } + + if ( !check_pos && idx > 0 ) /* idx = 0 has mouse fallback. */ + return 0; + + x = di->mouse_x; + y = di->mouse_y; + + if ( check_pos ) + { + x = check_pos->pointer_x; + y = check_pos->pointer_y; + } + + if ( !( video_driver_translate_coord_viewport_wrap( + &vp, x, y, &res_x, &res_y, &res_screen_x, &res_screen_y ) ) ) + { + return 0; + } + + inside = (res_x >= -edge_detect) && (res_y >= -edge_detect) && (res_x <= edge_detect) && (res_y <= edge_detect); + + switch ( id ) + { + case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X: + return inside ? res_x : 0; + case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y: + return inside ? res_y : 0; + case RETRO_DEVICE_ID_LIGHTGUN_IS_OFFSCREEN: + return !inside; + default: + break; + } + + return 0; } static int16_t dinput_mouse_state(struct dinput_input *di, unsigned port, unsigned id) @@ -583,7 +623,48 @@ static int16_t dinput_input_state(void *data, device == RARCH_DEVICE_POINTER_SCREEN); case RETRO_DEVICE_LIGHTGUN: - return dinput_lightgun_state(di, id); + switch ( id ) + { + /*aiming*/ + case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X: + case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y: + case RETRO_DEVICE_ID_LIGHTGUN_IS_OFFSCREEN: + return dinput_lightgun_aiming_state( di, idx, id ); + + /*buttons*/ + case RETRO_DEVICE_ID_LIGHTGUN_TRIGGER: + return dinput_is_pressed(di, joypad_info, binds[port], port, RARCH_LIGHTGUN_TRIGGER); + case RETRO_DEVICE_ID_LIGHTGUN_RELOAD: + return dinput_is_pressed(di, joypad_info, binds[port], port, RARCH_LIGHTGUN_RELOAD); + case RETRO_DEVICE_ID_LIGHTGUN_AUX_A: + return dinput_is_pressed(di, joypad_info, binds[port], port, RARCH_LIGHTGUN_AUX_A); + case RETRO_DEVICE_ID_LIGHTGUN_AUX_B: + return dinput_is_pressed(di, joypad_info, binds[port], port, RARCH_LIGHTGUN_AUX_B); + case RETRO_DEVICE_ID_LIGHTGUN_AUX_C: + return dinput_is_pressed(di, joypad_info, binds[port], port, RARCH_LIGHTGUN_AUX_C); + case RETRO_DEVICE_ID_LIGHTGUN_START: + return dinput_is_pressed(di, joypad_info, binds[port], port, RARCH_LIGHTGUN_START); + case RETRO_DEVICE_ID_LIGHTGUN_SELECT: + return dinput_is_pressed(di, joypad_info, binds[port], port, RARCH_LIGHTGUN_SELECT); + case RETRO_DEVICE_ID_LIGHTGUN_DPAD_UP: + return dinput_is_pressed(di, joypad_info, binds[port], port, RARCH_LIGHTGUN_DPAD_UP); + case RETRO_DEVICE_ID_LIGHTGUN_DPAD_DOWN: + return dinput_is_pressed(di, joypad_info, binds[port], port, RARCH_LIGHTGUN_DPAD_DOWN); + case RETRO_DEVICE_ID_LIGHTGUN_DPAD_LEFT: + return dinput_is_pressed(di, joypad_info, binds[port], port, RARCH_LIGHTGUN_DPAD_LEFT); + case RETRO_DEVICE_ID_LIGHTGUN_DPAD_RIGHT: + return dinput_is_pressed(di, joypad_info, binds[port], port, RARCH_LIGHTGUN_DPAD_RIGHT); + + /*deprecated*/ + case RETRO_DEVICE_ID_LIGHTGUN_X: + return di->mouse_rel_x; + case RETRO_DEVICE_ID_LIGHTGUN_Y: + return di->mouse_rel_y; + case RETRO_DEVICE_ID_LIGHTGUN_PAUSE: + return dinput_is_pressed(di, joypad_info, binds[port], port, RARCH_LIGHTGUN_START); + + } + break; } return 0; From 6168db8aebe19639d7afef7a74ea2081dd8b24f5 Mon Sep 17 00:00:00 2001 From: David Walters Date: Sun, 26 Nov 2017 17:20:41 +0000 Subject: [PATCH 032/394] correct lightgun api comment --- libretro-common/include/libretro.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libretro-common/include/libretro.h b/libretro-common/include/libretro.h index 4cb422bfcc..b900ac93e6 100644 --- a/libretro-common/include/libretro.h +++ b/libretro-common/include/libretro.h @@ -130,7 +130,7 @@ extern "C" { * It reports X/Y coordinates in screen space (similar to the pointer) * in the range [-0x8000, 0x7fff] in both axes, with zero being center. * As well as reporting on/off screen state. It features a trigger, - * start/select buttons, four auxiliary action buttons and a + * start/select buttons, auxiliary action buttons and a * directional pad. A forced off-screen shot can be requested for * auto-reloading function in some games. */ From 461b884dc0cc9e13ee5caaf7112558c7e0f6fb36 Mon Sep 17 00:00:00 2001 From: Brian Koropoff Date: Sun, 26 Nov 2017 09:58:24 -0800 Subject: [PATCH 033/394] Remove commited Mac binaries --- libretro-db/c_converter | Bin 69288 -> 0 bytes libretro-db/libretrodb_tool | Bin 58068 -> 0 bytes libretro-db/rmsgpack_test | Bin 25792 -> 0 bytes 3 files changed, 0 insertions(+), 0 deletions(-) delete mode 100755 libretro-db/c_converter delete mode 100755 libretro-db/libretrodb_tool delete mode 100755 libretro-db/rmsgpack_test diff --git a/libretro-db/c_converter b/libretro-db/c_converter deleted file mode 100755 index 3887af551f1c685a4f6c022f8b6cb2908f140de1..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 69288 zcmeEvd3+RA_HTFAP9RiNmLLHF1|fn-D@XzX($Edn(9I$s4iZ^H!XgAnx+N%q#7;|! zvYj}}3^Oi+qt1`f8N~$%Tj)+89b6zRvM&)4s%>N!!rJe9ZdGpqX6Aj~`+VL%uRouv zx^ zRT?w~@ukb;JoFwF%uX*Qp|6uC7h0^-3IkD1;dQQ%;SE$8>3{bZ&?xYN_z}FxGjr$6 z&n-Zvrtqe`DZ}eb#Kw=_m7pAP7k)YO@(Y6vZVIpBEg9YqL?ry^J*>TQbl^UDa!#S8 zU{?MNC8jC7`G1z-MJw>=JrrITu7ELlvNeCd!v@7d$6Vo-r@j3-lfiFL9NOUy4$O-kZYftEACm^5i*F{~dn4P@YJ(TA>@g zhr*-w_Q&P_O`be`s%5JG?QZ-UK9J!R#mRZ-J+xngCFRiM$y-lJkyl-UZBr&2><`z|EIwJ z2?fUU!q2*A$MUwbiNa;0a7W0NY&W@u+R|?;02Xh&!zyj05p5E#Nh4o{R1jR1^v>I^ z`#3w)m&#L)8@IkD|XNis`BhJ0DeZHsZXi{#+zi!8qo!NfurXPZlyPUxG$tWNb=)o5`5B1XRvfTb)@HA+yDx&7G?p|PDBRsn~|UO#mh=}9tXJNN_YCCo=Dy# z_hqBcI>0*)<$oVqKEYqUANA!y6h5f*rBAxJ6ouuEL}#}Z$2S0ZlW3A`tKxkw3$|6V^-YIN&^ITO8kM8XcG`srIB=PV*m8S;OQAGi;%M`FO<3sAK_5Kgf zZDlZq1I8(Ppv$jG6a6sClrBFDSZ4zgtiJ+F=6Vu|xjvuIGY&UChd~?xh;M~L)F=?S zvYyD*lsB$P(qg&Qexb(MA0&`!0_o^u3K|tG<5*ldgQvNdN}@yOo^BNmc(=icMyP5H z2UG~Jp)lxqfZ@Rl#g)=qFUt+#%3cIb_1wC-2MlGu7IiR+rqo2n2w>vE@^>Y4tL^zYvc|&&QNra{I3f=NL=3&qqN&j_LQr@g*uoIPO7{v`2te zWl;W^gfqNoU1bt3NpFIs{m2bQ8D9-5(`R@Kj(DDuYuvhUp4qWw3ahc$iOQ$4;CZPB zNn@b~gJ%tIKf;ws)Ez*Y7mk~R8&d2de_tFxLTyx}ih2P8?F8!xOfghKEl`mAp%$;y z%ql$5%!Yz4!9LqeaSpo*_3}B5o-CkDS>aSr=>;h&E3+fFtQWX_Loeju);W1ctJzVg zJSXZ^US02N&^b&AQL^se`xDSb25X&+>0xO~ksnPD+N<^PzHcE}W4UE3(aXFenjAfR zPV<$#+U5I^TUT7?SxPLk^$P0pK160q48*#$0OE-#*F9Y?G(wc~&+8`XvSlrcc&|q~ zA?NU((5pT7LuT(nKQar#k?AKRGnO?=K?VXG*rX6P4o4=?VG@6D1D^wfYy2ACVRlj@ zr58}h-^G)WjTpNdn8vE}+@LOYIJ(}yaHo*Mot45VD9n{rp)BC95v@+@MH(F*>LS2P zC3wI~MaYo75}@{_m;4R9h~xmRC(6wmhfWNkwV}>400}h00F-LKH_-P2K)(zHI-d}9 zM4uqo!43q_u}F}dkV>|6HCLtsJAs@2fuho<{>UD3WDO#XVpJ+?@b`Fua*$iv8X1U? z8kR)$qLUvA#;iijR@8$MSLG6?Zu@-FaJd3Ra%FXh@Z=CKz2#Vp$<>fh6kUmu+);D@vh{bi>E^jOdUdMC0sGcP1!Y91_{Mn$38@;VWLmgL#QQ~c;WQAO;qwElW zPD?@nn`coA^&WVWhfFIQO4wxr4^JjSewf^Prw4Or6@%&_fg6$nq^L4N$^fM5c)vsdaejuW_ob)Hg0lVn(gX9!Ygv|f}2Iun);K%fV)GEpJ>ua;i2lnjxL){q(> zMXnIp*hZ;|!!xhq7)Z7r3~>$5I6O-b>%SGfAk6hg0_$RBz&%}?)JkjH-|pdPwj zP_D=Dd=Yt;<0?{~6sBt_uC*wu#nXq2*qxsK>k7i_fX^1dXu$QY@}w|bKj4Z(`b&7e ziOZ%uDNNULTx>q<*Vm(s!cL=bfElj0F!t+7)7^mEnOPW*7_`4C!+xO=qw_uRRA6+H z!mjr|DWyUtBOivRwTsjSFW%|kyLuW7dTzbsO+$vZ|vFP}EBlo@0QLL8UMMk3# zOC3mx@54rMkTjZdyJJzkO8OdN7YX|A-JnmH9Uc_kb3m$P zxIV_ULU~e{uJ>_O;OB4uShW3)PK>cRZ`m3n7q;dd33B_QN_lmiufZrTN%R)W6|ni2 z&bCAY0kb60GDCYLsGnh`xf-HOj?65R+9y#hMsaB3aL3~GB&h;#z8Wf{>;HnLV4wH# zAdt@5BV0#4GxHo#S-d0DEs?Sg$^LV&a?eP#IylJ;^MbGYJ=( zP&bd^>!%-Cdl}cbvLpyak?Y@rv$sIVb{*Q7Y-g=g*a6)hk04lPIj`RB`;iw%X)yQe zKT^Z3aC%Mw0~VpY@1yq#n*Psfm~Q0kB+z+rX(BJa1SiKNrk_1Kpg+QLu}*86%ZOZh zaj8b%e~HGr2m;MwF^LNS>4ijt_7oHY>>lY!P!M8yveB_5iFXtxNuA_~kviWt-d5Ag zXshjI$hcKd@9i6a^*F)mMzBm`9;gaXun(m(7?=RnlBl^Y2?dk%88-_~vWECkugR@^c7`reTEP9yHQ(;lwG2k2w6=rre=_{RWajHhe zm5G$!G2mOu_8P)Q(E>H-81M}uXl%)E>*=jIy(J>;E4d- zEaQ+z!6D_L973EP-jDw}2ihI+j7BbQZs7pAaCu@T1)Sz3Ygh7cp=}2?S`Hq5lj`!C`NNP{X`+A!DYdq7)h5$5n}I z4=(D*c=Tg8T%?l%{R#g>>Dfe>?{JU0?Gp1%lBiyL0YS{*7rsiovw{*N5#2y-TtuXn z9*5n7ic7aqY1tKgxBn|RKQBG2!5pc~Y3akI*%JwcG)D@1tmwra?`5&a$D`TfUsKp) z?R@qqE-?uX4T2^?p5O_NMzn|*R$O3@wGutVXmts&6*1p5)bkE|151Os=`bWBs?u%v zx)(YXJ^}LJxa|jFMIwOq8CLRwy#cRivAvYFm=dKwpO;(AmG{Q{z*f96hO@Uv2m|(6 zJUmmt%ur6Ue$yWD_6Qxngorpo!wVWuIt>k5O;XtS79)Liw#F!K*|$hF=0v?_QeVI{ z)OM>Iw~QbfbGGr32B!|gNH65B@qSK83zsyFUWDkh!eU-DJB>N}bPk9c!LWuGGas-u zc3WuSS1LfjO8_#Tf@7XW*txu;c%{T$C28l4V=obS0e9v={u5L5H`H5OvY|sm zBB<(Wq*-&ZyxA5&?*I;6y%2r@mw&wSIhaS8+!{xgPl$DcZ%Cw*hh8uH=lPr%q}Q_a z7`K`-2#cT&;hbjnXOncyq(K-t!@bhM<4w~e0Kb~Sk8rDru)+dx$D%}5M_7N5y~gK+ zeg1&FfQ@`bC-{sx$*E>>&QXnH2pmvRsXDiT?UOJF#TujAkO+7xgK(#c#x)5g z(;PzBRY`sqIFKw;jeBQtzUyTgQTIG#ss!y>75Vn5s-?WEj7fsuf zgg9!?;upi)WAL}9pVFS*!S={)!Ahg)iY5f-q%fSJFYdybCMWm>>}$oJnr;++FbbsQ zp^vmzng3LBPbGv5PQ|;r3wXlQx^r-z+wdK)cN^-S(LFPyiu#4+r#8HeB5uPfL_yM$ zKk>ZIcYyQ=S2h<6if8$EctZ3px67^m1BMsNQ2rGXl&T4o5unV%Z$_aO>Nh=*a9-+# z1f$?KmYz{Tq#Iplx|!pyg`_94^jc%-X_$nhyOYduca(H9Ic|N@uTy}7t3hMjLYR_b zFm~E*j{7YD#b*}oNN(h!id^S4I#h;?=D70#K)<1J(nl-{Fg%x}lj{rCMd@V$5Zwp_ zY6?_wUYdbK-X*1*;u=kH7eMKH@}Pki&P(r}B-zrZ2J_X8G>|AR=_kMQLvoyf#My&L zcvqZKM}h;F+D7UM%6Tpaw&x5J{NHFVXh^dW^hOB35`kwTH#1`fpbR`BQY=Ili|9eg z85ey%r7MlTZSoqTZ+sOMa#exULdD}p-yMJ9%X&ZzQ^)tNk*!rldZTe#`*wt_+r!r@Xc98z8XDD^mj22 z)wAg*R=?zVUrj*26TWOcj~DyH8)k`?mJ^Z1SK#UNS>j6usSwo>6y)7QQb0#MNxsU~ zcy>*2eEHjZ6>H^eXz^~EQ~RVFFEHjZldEkLN@D&V3cF?ofI*EtjyjCO&=l>F0OMeN zn3WxhDORAyLS$ZuG6XEVD-Up?{2z7@w z?2{%=hIK6*)kBZlwgoBNWPMp)&nZ1yPP7xS?6!i8KqiT9^I~*+^5e=jo>45Ou|rx) z>d9)ar6{9lP15d>k`Y65Tc0W80_Ql3VZ;mXJxA}3+;V1L7o&^pWN$u6RoTvxkHFDq zCK(;VN#5b0B$Fe05=FpIJ{ttdt{clc+K)xdSg9Rm)zlC&^gl);*?7Q`O||qM-oRR& z2pbT$PL`eGB;?7su=q8Gm1iO_G9i%$RtyS2tgxQH0%Xj>EwlaV5^dQ0*3tU}0fZl& zPdhAq4`O1<@;C5K%bF5L{6y%ZrUB)Ar_)9 z)4VreZ`EO{LM#;`jHK%jiecm1J&fcfN(}>mQ7OC#Yo0CP6W`W1hgf>?_*cBHScXR}VpiWd;&Umq8;F+)9Xn6-+U2Vvn3GjNC&Q zXox5h1MqDQRh}{Q%BFFC`^Yb!seM>jh3AS@G|eyZen%2-TovuP^9!&H5XdNic3}Q~ zMqzS_&K*lF(FN#QDAV%@qo}m#cf{%olfdhihnW892u_HTjMLDG{%t7!#{2Q{%ZEAu z=7qhyu$E?ySWQKjtH_xv3x`_6GR7$o>57n&;!z!#oH4ayz*$IVNXuo?WoT2Qu+44f z0f)!{&eUzC09W=7S_gh(VmO@|{8U(jc|e3ULiod{WmTAkTJrvLXf|8h@wSl`O(kD~ z&z7#z(bA=gvkw7Ww>=3JM&X^LdJftw*i#ULao3F=jIB^Hkz_A zv*D7&BZ*sQSjLMEHt+@0b|i0+kvk`8L3-3?r-g2%1w?|wk`G4K&up|S_U42Mgg)ys zlgL^HdXOL(h^e{VX%gjji>%#6Eds=`lc!Sw1k@lG2#}+=d?SqB@WpdU>DJu;w zDn6g$V3$$&)G-E%3k5Y=POqc%ZAdo>|LTSAf@h)}txspcJ|h^ln7f3;-DV=WV+(b^ zv+{66PbJF9NG&$rk68PDVo8a&>0vdhx6&dCZe2uH&BG$E8RxpDMUEJWBAKV z5bhn6@%{;KbLh=MZvx&vqqn7a^H8TEVmU?RQ^X8JD4pfaK?>O#TBkG=Y1F>A;qKZR zkIJNe6r;4@_-ShOdFeRp7=KTPbuO9*=LuO-bQf(hT>J7Zvsa3l2&j~Bzjvlp~oUCxukfp9iUjNwMS&!QmA91Q9s&l zfnA-jmY78VQJ&MVxuY;7F(l^^*fjFSI!Fv;Z}l3>{s1rhj=L~F@+x@odFIr4f)^wC{?YAGk>wF6 zBQ*3hZ6(oO0oWiMr#}m4H&oCHPT*a_0axd{(;i7D?usfUsygU zx-3v*y&bz2ZXyknwnUw9g?#8tf7tq~Ir}mskYk${3?)V})`)dDUT`oGBG^fV@#2sq zB(B1fGOZ-KFfXdP01Y2=Mq&3!Us30j1VZvZItQFGtm>O$$ zK+C-C5)I$6T?dA308t4>9p%l>tAMuR#j!~;HrV^UIh8>^9(n2o)v zMZ?!JuzwOTYm|M5wUg1e9b+lQobfaFYAY1cxnm%!VfM(@mA9EcLKq3EJ9WZPB6}rf zOGNe&&;))vwH2*?mTn{3hR9-RH0%uj`1jjCVf2qxV8CHO^rsck|Ht$Y zpW52X_Hv5a`k3uyO{6u|_HwsKYX_+FL{VeA9$^_~yB=wU-pSJN{Rbx&^IE5Oggh?Y z!!+o7?4@ZkHXjWj*l6t;7@Gt^aPj?zCl*ElMl7K9;@)>+ds|?Xd%u<*B+Qxrf%Zva zc-;io{eUT_EF&)1?x+JeYv3#)JZThtAi+63ylwZ2CkKBTG+t zH8ezCvpH-uuWrO#OzH>>*p7uHY;Z^{_(}RZV8S#cD4xGGg>M_EvLs@0oGc@jWBzev zs>bSKJ0fV?tE<5ee=CiA+CZVeXQc)c+%SC~@b7}IGvTa|x1ffoj7{UoMwTb`^B|&> z2@$60PV88#!v@uQ>Tc{etW>1F_6XT}+_)=w*37#Z=r537T4Iuy79RSMblri{zh_#w-qdY3sD<#-qC zmPaLLzG58@wTam-Od%|v3A7muvI;9jb-WM|iN)n`2UOB#o!exMinMZu+#>8$kt8%_ zCOf)6&2f;!TU_QWYKKjT0F*Ehb92#D3e+_+>JNKg;Hny{=(9HI`Ej9$5B+a&S;dRv zD)Hc;cpcXq}o9Fi6T8gRuX;1qN}Vu2d^ zL+9hHOE;vh* z#dlE$`5xZJ6O&F8)8jKkw26@xxUFY^afXcXHJE$%!}yzL0vHn_pLq%}FaqmMLH;j2 zdk`)JIP1!fM4A9A|w!f&@uzg&#hOe?M6?t7-ci^J(jKN5dXo%XZ(EE8jXNs!6(EeH2stSdN%tTdrm!CAtufRz z2F)a3B_*_K>SE4b1#&4!j7Nh9PE{HlkT3sTds9)-z1vHB9Mj?2@Xrr|@X#5%rqEEV zREDCrCG0zS815S#0?#D=i|E0Xk&u%2hmu^N&91cZS`#7|wj?1VybRQ@*f1~!4-@Ec zErHRY8(xjFNU^hwq9cVx0f-T!$7m}CqV}agR}byv`YGC7)_x^&&|DkSK?0{2zHYyY z3Sp6sEs97l09RfpYrh(?u*w`vBC4grp#jO1jGpR(NwVBiio8GI4dwULQ6c?h-4xP3vw&K_>L4&`k;PRzCa!Fa z{j54v=V$jN%J>0pp)$)L+yb+=f@KeJf}v0kBh;G#WXsS77y$B^=!f84qd+ct7)GgF z^x$)(1|k1OGU^diVOSUh2%%gI#Vuus(AjpW!*Qm8Vrk~d#{?1lc^~>jL)`uw`b43| z!1(w#^wHUTPja>%P|+cLK^^uV_<~0kUVM*QL|SoKB5UAtR8V0LIfr93i&EG_R*)-D z8~ohh1(Hf&h(vEf(7p(Wu0lg#=t4zAw}i9~Yw&(D0J6{tS)~8X_iJys5K=_XV~YIi zVI58NiL56SzVMWwYlHaQ)yZIvMp&hC4}S$46U-69e+qx}xEFt*=$1gyO)#rSW==MR zGKYeT&gPB?$DDCRE4I&^G(IzP zWNa9HJFVyCZ*N5VOvd{>)Iv+YTA&?6(D@1T;X2^OIKIERo@1ZDVs1-zLWniOJEEsO zNV(pd&)`Jr;YR@iSfr08bH+OyiEuiRcL(1i_wj2lwe5l z+stUV8Ivpwb;XT9njxqfWpW*ojuL!0tXX?dTC}r#qJwk`3|N4GBbr<+h@>dORT zvId_15(bs5r>9I}j>aUuC>u2mg=9~hgT!S9RA79Jfc@0-KiW_G_>l2n3D{2!1x~o} zOakf=0`;^W0^_MCwwc{!JT<_=27A5_6Et8vk=GRCe!HAh3p?#D&QT`y74U0F zz05ckS<7J*5IH#evrw_TIG_V@8hE$232OmJz{&t4w4;4Xq>y}6+=Oa$JXq-ga+ks_ ziZWKLIK|$v$NZNo`xMgIB&L|enV1nhrzlXPN$m3$L>=@|*nF%i)E*6; zkChDzrDw?e0f2@B5Lsy_AwBXcn&=&@HG`4B_p%yMykJ458qFH{aXCGNlTwR#Mzbk+ zWury3QwEqNq>A8$1usS#v9khJ)^*mfN5C*>*z@C)YBFI$Ig68`nF?HCo7mgfn%TQS!@bJ_Te)}fe-uQ3n@wVZ= zq=zx%n5CJnBr`dUEBh5gLslyEaS)`L8&+MIH2eJ&v;)%24Dia(fKmaklN4YdVPZhY zeE%`=JqFq&6anFW0;u~9v|sg5Tenepnv2ibVaoUsAL1?HjE>BXSUe!EI*jT}>YFC@ zPe7{Bj}-5AL4<;D$ibseL3)4|kQVTLqos}N@3fpjja3h25t zKttTyu;lJ;h@+1M1~Pbrdb>Tt#^2klPMT=T49NNzUt=(mk(%omRCC0C)SNo(2@mKu zDvz}dUeqNjww#(5jWDPEMw}R3!RGVIO4>VwC-%0KZX?wZs^Vnb#uS?!l8Iqpc_Ku~ z#Sr2UJkWENj^Rq~_7Et!1w?MF-J=FLx%;R=iZJ$=41gKB z7exRd=8fV=bl@mlv9e3H+n8fjQCi2k*k)Ujr zL|aY0?Ph#|hQ4L5!g8odm@T8id>*D@+`81qm~{zP49&61JS!=eqfa-uG%(ao!(dd% zx-Xop*Q5IbBp?md3DJypghEhGWf~PCWhTA9M_LuE!H=}R~ zmY2yfS78=&icHHwd{~y9IBa=lGo#~oIEkho*>{Onv#!K9&05IZorSLqTfVrN+Guk{ z;4@O;ThEuEKHA4)E`autLCo3*`>tvG4h^FAJ!KRP@~B4ulQeU1*wYZVZR-}oH`rma z1C@8SzTjC;z3dp!0Gk8#ybs$`sb_p0tH=bdR(KQw%Pbs_W}!X|>CdPH_y;b{ICQk_)etI% z&jtL|fsHCrA0r%Rdjr*(9Z~Ic%W1~VYQl<=oxULP(gzFyds4@(i)yE2(Wf_ZWe${N zKnie@(12qwmx0(je#Ee*dk+dovl&j&pCdQMByopPFko<5LGbKEk5%T&3K`hQroaNj zor(VrfMpi?vVxf?$YWqRbWu7X!l*vNc2i-v)tl04OzI;#VWP(IihA#P=1MZt4yRpG z0t0Z-DCpR9V-^X}ve(fp+Ai}aJhgjt?9)1vSX_?}7NHq*KBur7q-f4L3eK8|Ru|stz%XvBqFiSrgB3!C8{VOik$2yLO= zJ^1n!G@Ax1Wn(0wq*PFZ9D#?at+ty{1w(_mvM5&+<+_8qDA(6=uIPf4V6KjoE1Gg0 zRC3XP2&T`3K`HMztz_wzf?(RHK-#-<+OyP6$^;P$D<-83iUmTC>?!JW>`;-{ ztM0qLGQHou_y_A%R6XyQ4|5|M0`ZD5?I^wiiY!wz&IKE(|)UChV zt6hOIvPOaSYYKQ|8%Eiv<9QL;)JnF`K#i;{>>R#DcBbvYlbuswB9{fLmY_xLy*jUPQdVBi#}35;1G<@kVxiks=we) zM34duk*8Jqj%o;0mLtC4yysIYvplL}W@n2gv#TX4bDDLkED7Yrxk{4ap*)oC@7*) zI<|S27o)dfrmpyR+-x5v71mvKW7o>3sLBLSHTyJyv$NB7NHvgd4(xA%1COmIh^9!m zZp^FjVL~L@WnRgP%`tn|N1{<6j9@OOEi9b9h=Af40@|#y#))nr#{>H&lIQd;9V|%R z^&{AGTr+?h4{+m}0o-_iYl&k!Ow9m}R$Rv`;QmF;5qV@`TQ2E)JKA0#*q>uv&Nj0X zwUypjiIgHr2`t^Rk&jp+7q;23z1?c-)3z-nej=<7$y;tBt?_QQQ3nzN`idp;4z`6{ znut~~WBBeZH`Yn)D8o>G7p-UtwTp13lb8G$V_kt4n$!LpVp`w$3b@4Zw6WKw`)~SS zm0PQWC2h#K&Am$JT6nwrcY63Ye{>0nAg1xQ)b8*`%Z8P*Q|F$WLcWA9Ada99_LPk| z#55rsDXs5=FZSeLxW2WWEyA8@;im1TntP*jECdMcDaQ^b$A~*-$Baaw4*NhBrx?Y| zRN7YDM%qGogj!q8ZKKVNk0@^GgcIHvY=Fa&ImVn5`0V8v>Q+fdP$L+9r5$_yt*i7x zG3`UD;L744x}egXdf^6byE9{VQEixff$FE)Af0SFz{zHCwqmEs%7OMyTJpeA7Q^9l^BKP5)(s)CUFNjD>z!R2NoF%* zy@_&ALCyy$tY8hyxOIf5eHPf-+ZXweAEkhyj(fY-pU-+Iq^{#};M=;;_P_djgG}QB1tG-L#uq)UFyVy)A~n- zLj@}8N)JPNfB(2iDrL9TxBoV^tycno0z3qQ#k$wsbOOgwZ~ zYt`08Y`c6h@Uf*wK*hd{Qk?y5ykohX&lwFQ_Hb_y#w5Pk_b1LoE$Od}`HdFLxA3*G zGl|bQu=u=pYFPW>o5HMRheZdH0=DH#uP!_t+oo{lyUIfbt)DfZy`i58t|D^5huT2+>=@L|Bo>m_@S?44`U6r`KP?nZd8 z1KF&npk>yGquKXW170UE8OTO_;AsB>Uj5bJ06O#p>!y0C@?;8?+oW1o;45=8}kZY){VmeCxxDGaIISH{pb|n!)Uu z8F&`%PhApE$KkjdBKb%iNoptDOd8C_=<~w?+#K0j3*k2srcx}b7%oK7Qi6s~VBt$| zHUe=gJ|F8df*8Ruo{{CR+h~?{DwJPGh{B1Ae9A}W3HQvh^(JYTH&6q5x_6TKY>*%;?gk zcL)|p=@^g-8=Jb|I4^u7jYPDx6-e_qE(7Ouh@+aD#8~8di{+AfQu<%1QDR@j*3yK) zDJ4;?fLJM0hCUzwJp$#tt1AA8_16z@%~vjZ_lN&apMF?70Mjo&n7^2tmkOqtF50Troc`KB4pW4dJKSA^0*GXHJ#1 zz|eq_lR=yXaOV6Jl6V-qfQnc5@<^x)8r>n~akfTt=oKVn_OxE|VjvBY(iK>NGnM4e z$XNeUd;I&)xv~`iEJor$D$8tJV}!Lp9FgSE`Gg@!kSLg<=&8{oG<*)`WG$buE#BQ+ zO*`!u?@pAy#$d#zZM%~WB^Z)qJwSW%rJfpeQj_yAP<|yFWMZaEDyCw=N~{eirjbtc zATs%Px$mYojB{)nmG`d(?RWT-kBKKIaPp|(Ykwe~ek5~)cG zmVJaUopS(Dts3EIz7%>2Gw;Q9kV(ZDQ-*pe9nI1S1{nCo_|ltbgb654;Q2dBq77q* zP^)Q9Z>`gbmJ3)!z7xqU%b+@PdVj&Iclu7Ff+VWItDz8^^}-iJfBEnWbo zo98<61#(eJB~tj^5>QBiP8m*bh^D+*%ll@PT?G!i27``ewI~Ty7_oeUuWS!jM$S>; zVu@>O$@S=kFiB_Zoc%j&`Es7^>3M$K*iC;#l7x z>w`eQPMVH5VBQLtdmoW*rLoqhASMzqbXHlD@rHvxj5c3KoDvQlW$upMJ4V;9QMy^% zKmFvBPjs|Wi5=O|%v}f`4qa!+W9ReCqX7UN`voqN&usoc`=RN(a15yaLz1n@YNs#+ zyTI^i=SrrU9KExoR)oATL?cGx>?L&U->6lNgjMwL+pJhQ#$X)*oz~oF5_;Epi;Y;q z!D`QFDHY}jzCgg2;!M8NMv77@ibe6~k4hty)ALZ>5T9Z+H7DdL@p-5{KM{WzTZOb~}5VRks#qUL%$>@DWd4|fbu=&$y zc_%gd%n3(yKs${#i20h({Nj)(eVSx#!zNZa&Dc3fVkU;l(~_?nIbDhp@L3J?vNuka zUs&xo3P(v}0iM+<@6u*+x)t)%Hbl=R5F!MgZE;<5%+!}77CX}^xRPa9l4x6+q*^i^ zv-&y=vxR7*TOyA$=tM~oi;cQ17;dUf1YVIR1ee*JIXD#tXL<$7s-Y&`(rs`N)?^3* zpEE28h$k5{wl9WdIV{NyC{QQEp^d!wZumY#X381g9R=327{dnqOJVfIe)V*)nLHOL zXExDxj1cw*8Z=U02^dwF6_4AR_{6 zcR;ot#uNfJ)FSrCUE`lmkv(t8fSGN@fW;SFO~x1O?WuR!+haX;V8;5h42xS|;e{2x zMD{snU(MbFbAYon2jJ{~L9Ayau%Q|P^Z;tY4O9X_fzRN8x7)Cp`V2OEy|jyrU$!<uW_k$kg_S%4Yu~#qEb0zLeG%Fpq4tO+g&7g}QWTiL zENGxWz%1C9iU!GMLC7bP;rxy7)6khrir~B$tP*UY6QQeSB2qf_2oWT@h7^}zco)Gn za`0^g-;;x{Be+}+meG+Qf?+ilS@31X1e4=q0#&go3sg(1!NIaRZt!sd6UEKZlmO2F z?F2OdNnP4;;b5e_1hE3U+Zwa1n406fI4EDE`WOI;EW!GPgI5a8UHFl=9QYX21m#00q17F)A8PgoD zPOvXV&=17~D3`f;hO#_vUc#tHX&R8Oa^-PL4QnX+?ZB%OL;AyB;Dzw>3h`aIsr?%E z#WeF1E4xI98?g)Vf>c77&^eXv2rSK{Sa;EPZs?8>rU@IL)Sp@0x?Mt}OVVgBVupPK zocC1J^3e0H&>^j|XkPtLC0GRBN7y>}>dN~fI~Hpl$CqC8fejMh3p!~%g)KLyrqar9x|FP!x*yh3^g(E-E^bigsA0B7_f*PJ<*i2*2ycxrd zFfS1en{AEhi~HFc2Q7U#uR>1bS1QRWmYlU%!gyistz@9=jh5D8y1|nAE`6|R5$|bv zg-vj|JW1u|uj!dsZeClSyRO`@UM7{2R;i?ID9_zkZrJ3nWPJpQa3}SHUS1Q_i;n5Q zRxhp~N4;Krk9=`@vVeU6?nzpPAtJ6xCHChi~41} zUZ{1|w$%$Yu9_BlVDw9*_OSMnXj!&cCtTFIT%2&(Rg>U47q308*Y1ooEt{#{t-dI{ z&Q4e)@1Cu(mtJsLzeHuf*MrQMWYr_QY#hR<@tZsy*RS>WYWDapA`dU$Mk2nJML5+I z;f!D}?nv#9Q2H5!a|Yoj;hI6H)(I}1@BW8$|df}X_HeS15FC5luFX=n| zq8AS8J6+J$t1k#QT-6T?cU-ltwEHO>i*#Xsr#m{~pm6irUVW!;wU_nk8|uUGFvUS) zMYhCYOxF6yaV_*9hI+rc8j>lBFTGAnw+3OCUcjOIje6mTLAb)%>1>8PE`JYU-1!IA ztj_xx{+;)tU3b2Lu0Z>jmJ=?rXD|-$9WGievuhXCd1=61i=3%eN<8lZr3S-1?OteZp6!y>*0K9?Xk2^~qEuwK8;bwtL_J7m_Tq0Lx3)}XG}W5=L- z*d*d^uewQ1JZ3v7)PG+)?(1RYlYxU$a?vNcXz($3a6$?~YJ@p)@^I1l)+{)AexY(iOUqIVq4 z50(#6W5Q4bn7V$kmJe{G0s95#H%?tY4x2OSAbmIsE4X#dAk6ua>)BjcF362Y9GBto z9#G~p$}(2wW0v0lH@Si^!&wx<378G&Eh!mg&<2$GIn=S?Kj;D-Oifwg^!^gE9x8v| zy*vgGQ;m)n)FJ#2`$}4liDvl_{2dFqEip;*!coZ_1%7|(e<-j2ugb%9?M+1cUr|eK zSpizEL!Fr^mS2EaG~T=yV9pGbZa^36%47Ukgwa2Ieu4do?Bft@g1C)i+bl-%QRvB~ z{ufjM!;Y+)-?LyXn|0lh{){(Fj4{<*!~RD?-GGWQ^(V8eSWdJ4;>BF*JXCYY{z6YC z66wVE^U^?sXqgieJepOYMf18r3c!@owhAH(Pe|IQt@24kZ!u)ISVJhDXy(t5`4SOsou zB}&6A1ZP#s<;#u~CFAe2@JT{h@MDY4-Y5L>iCcG5{v_dn)*u%hRlq)h=ZwBx=-X^H zEX%SZ)(z&2-z*P+k7bnU;Fu4PKj0t_I8OrSHPZPoGOmAO<8>g$t3yHcGZZDFivws@ z96tUaN!6CVsCsb+A8jh;fVuy(W$#0I6*98ZVOJ^0VxZ!4{yLNTvKNQRT;|sGr(y}A z#jsf}i`Er_g=`nqwNcH2_%n$V?%!wsHvo2&r_3G;1UB`5SbxAD)J-tg3*+}0>3r2& z#B94!3siL-9ONX%=oEij@jkTvDq7F{nqlKZ-@mvHI)*EoLCT&j1)H5_hb2L!9AS#{ zL*b~`r(Mv~Nv3{y9S+r03%<}z7we1CJn%NOwROu<8%3Ht!GW5xl-q_ zsPVCAV`M?Nd<@O+SVVg z_CG?L{z8B2KH&oQ8p%I{;2To1cz`O!+G$8_RA#&Z+aajk+^Z)+Rc{zQuz7UJ2xAUD zH5sioIxNxX=CJgV%oZs)GRd(x9-@3t33k68jhc@Mzy2phV5nyx9nYF6>NMddkX=*qY!`S zqv!OO4Nw5)jDy^(ixF+$*6kkRX#TVwzR(S^0Gf74J}*zV_l&O8P19aOrvs=3?}4;QM_*_4g>@Pg;?uB{%XoEYt)Qi zz5q38%dp8Yna=ZaM4y7SW6;^lwb;55tc^_BlZIwo)D(I)%fElw&R|;>sO7&8A z-3H9k=~bmlQ57T`uu-3qd=LVEa_MY4qJr%=IHqC`p3l+-gzg;$){FyZq7i$&>dS-6 zliTR7y6{cMUW2fcOqq#Ttn*otkS&#EJGb{-R>|o>StUD5u(unZ7M;ey!)i-5wwfc) zOL~VXPIhny#xs@2zXqN|KZlkrglwz5!xD84;|*j8O{E2m2(Z%?3(K5FwwLucv#*#N`wyTKwvWK5vGC-Irof;~d|t5| zqirwjF<#geCXW<*QE-*~=q$NjVmXh@!gZFPSOM1D_p~P{4J(r)eSAjUOYL~|e*EE+ zpTAKag74c@XJ(1zGM~1W3=aVr4omSIx~w*;g9=;dj{pX<2$??S;UapOcMJte7kS%{ zk(N%u_HgSaz^-$boOG7lD6w1wvqP*}J+wwvFckPNA4bWnx+|prxOKq@AocIx;pw|& z-GXzM$kkT{Qpx9WQ8#IsljI4&4xitFEZRLF47Z{he=r#EkVx4zjyXv3{rpthYJl-W?w+jTkyk?`gta!iEnmpC#mrN&W&noEWTXD5QbW#?MYeiBtGrL+M5UE%?fDC@NCX2=WI>Gn$jhODCOLGO$$&V+zYCCu!588$d9Hc!b<0x>|iS z#*qARWYDhuOEZ<~D>bn)8C7@ihEYMQ7r}+PfW1ci)Qsj`I7D(NDrH{mCj914fAk*d z%-=Ga4*0@s#9V@}=XmUP)8b%wIy3d}s2iI{VEkHoS4Dx=G+k-SB5Uc;sbn?;+5d9B zf>?|kpS2lTiY+lpXCi$q4n9q>N|uy z_pFcTgMYXfmJ}R70eMRJP^g!F&T^)i-X{A1iw#!QGQ7=VV+Ih9I-Ccu&;#pElCCQ4_HOei2O>#C)DbU87 z!g9*dXOw6wHm=|h$nWs#eMn9xf=X^g;4JS!JiZ)dDBuel83o1Ke;XN;nnPmz_CL`p zmC*~kQkEu3c?51HXtgv&nnPi%qT^t>>>A$f#CY(5fMN7T`vIXlgTN64rH)jpb!kfA zgnFr?3~W&>@2(+0q#5KDJPg*LJeB#E{hPJCJdcHWmGlw@H`|BI&PTtDDB)liAJn)` zh%LE^9S|!KMgOeqNH~K~U=xJ)Dt7O~VoAg-&D-4nW^aisoS_zNv+BK5gyXK$ZCrOc zYMm@|!fBfIU;}>X=~7swl&Pb)KmJtiIHVUyjyl{*4%fL@BwISbZb5>zH5)y(QWV1$ zEBGkd#+#+xBX5kI=oAY{EQu>Xo=%vSWNN*aNT=o||w9BM#0-xm2> zveAKUB1@TQ$o8mFf(?yJvA$dmBWcYqmukP?Xx`_n1)ftB1Ra_ zD$e%Y3D(EzpB;Rc;oTF|Yxe?0xGD1uKRqz6hb571hMIb#j3Q2D`+?4%uZJ-P7YTL< zcv7f$A<|R`7zL-a23iIpq?^S^`lTDT59+QCg`n(;@367SXh0?MvBpV_$mvaC>v-N| zMM&TnPZ9rs;pp=wvPpS_Fa6mWGY6IZfNXVv>=pL0@Exe)G^~lz7c2OGF8zpJMcZlu2OTXI^lmC0o(BSe*F-!A*wWB$xk_$ z-O#|ZLjep2-G+U=P%Vt5L_E-xU$Ig_TZIkvO8ZU1ZfOl>AOE)fD5SKXRuk{req@vK zKq0grm_4ju*54pmTd-A5q5va{MBCA2`-k-(;|Kc3~EkxY;}{z6soJUI5^v&78bixCmq1a1GKm@v^1;EH%@+4+cOa)Pw z%tflFJrF^K4C@p`5Y~D0gapR7`S5J@mi>E7WIu!4_^R479M91C0P&Zsuh}k}Yizf@ z^fVkW3NIxyT=9iRfY2Cgm!uY`3HGOwa9!7IoIB81r#fS^id>VBm zuwRX*8Gj0k)edG^GXu54*F^(%^mU16_vY;0g549@{Xuqb$?mP$J&D~PX7^-v@4)UU z?B1E(Q`!AdcJIdSkFk3XcJImVz1aOpcJIyZPqTYEyZ2-FOm-j0?zFMn*JUuf>)D<5 zi2J(m>^_{`P3%6B-AA+gGweQ&-JfOm=h%HByH8^G7ubCYyH8{H>Fl1z?lakaHoMPZ z_k4DrkGsjy{sY=RKGxUeO*|`Rg2pNjj_LQ!1V^bnM=6AT1S-!S3iYB;9fgKcsER_* zQ;7D5&n%?SClo5D&?*Z3nL>Z0&?gjnokC6uy-J~-6e^<7F$(2V$V(yG{V)^rNR?+I zh3F4PJS6aEwxrNd3Oz!hObR_op(iPnMWJpKqMd-A4iw6!P)iEENTGNNy+R=sg#-#+ zg;!2Px#F&`t{NqR=)99iz}j3Z118tvAoSO`*S2i2g0Z z^Dc$jQRoj8>Q13@3Z+ws{(*JoFba{se&z%U&8EPN;-m~|+?{|_{Ht>tYKNZEsL`OA?kJE515}K!&qZ?PgH15en_-#S;Xk2l)67bC_9x=G6TUyAq{jpc*BU7{$fe&L*Y@nnIS)Bkzc~Hn>(g$Z-I2R|)FgGw zLvvzsat3fWeoN3e>QeG?)buRVDczJG3Kq=x+wN15nZx!)jks-3*z@Ar_>XU_UfXBR z$}b1+-?8aP*7eQ*{Atd?C#{oC7Kl-}?yFdMBuS1XaQym{uGUh;C>#6ly*IxO$ z(<9rydiKvNHtym+-ctE~WkfekdGzEj4>hk%^)&lp+2VOmJYbsn+^6lQx&}O+x2{5W z^re^uN7S2B_N;s?@rUz*{fh-1*RG5C_|(?FKDDn>`rD4!qTbh4+#9Ro{+P6~#gCg3 zW-onwz+BCr=1hN6Jt^n(l`${AIBn{j)-r1g6Lv9_)?>)49#=q(-ryMSPJWBs_`^cvzo8mv&u{hya z=7Q+apXegGCMGtkdM%~-jxK9wPWZ|`FC}hY-iE)Pn!2;a_2VzB+;J$a^UC@)U#~vk zZZqJk-<2kO-LwCsE$ja^XQMO4R{86?ueScB`N?&Wf7$beC1cnRzkI%M&wH&NJrZSW zeYEhwW;s8V^`HLsz}a&XR!^M$a-u<^Qt}bx;%Yy<})i6HvcYiShGzV zT1Rw#;?d~wRsA<^@78R~mw%Y}b@!;*UrqWS-+^lFuKKm&`-gh8|LpklYpSQe^XR3V zv+sU5+ZzAY+=zd~#JxM{=@wr5jM##QCa9uc9lmu%%aBNy{`}XX8ZScu`7aPAiHZ$LLxa0S&t4g1Lbi>sj7p|GNaM=2!(-Sr2 z^JjCuZ~DjNO=_lo!1sRc?`M5Bt#PmK#i@o}b6OXjj9+zbPr`w5wy2TSUqxn2eRRhE zTx&h0-aKrU@yNpbfx~C-{_N<){fF|JoyfY-|6t#-pKbof_V+g(U%KndVIJSwUdflX zY*}8t@ta<6eKq#)AAX%0{dE1tw_*-_pElw6xUDk|J<{{#yss*UPu&*LZf5q|-RC{l zx2oCKAH31Lrrn9?iH`FTkIy(AH{1T%j7XZ+o!Hu1&2e zZa&_UT~%=Bi{mB#6La((%f)wGu37J#dTm(M`P%nf+;<-|Po3Ap^Y|xamf=VLv1ZcY z^6M`>GiKn*xwYEWbzLLZxR?HJ>*Zz*wZq>0pC88Ld=oPxEv=i|uBdR|fGsoRl`or$jm_P5g_i1ru z{;JuDtz93r)y(PJ!L*R?x_0xL-d{CO&KUm5!I7iBdH4Ct^Loxa_v-I0^Kw2eYFSiQ zripOBe#2K);hi)3qiY{tuewyUpqAX3S8(Akv3(LQ{QrWFbo72)^|%H>5{F(SzC$mS z3XaE+%h_eB1U=T!YtR6SDs z1?ZnZdHrD3vs33-b5mv&rsU7Fq*(K3EwJVyU(P&hzD1Qkb#AWe#oR@c3unEYtIE$U zviM75#xg5+&U98N4|%7j%*s!hWyzfz$RMXHaOdTvXS@ZH!a;DCi)3YgzLQBD{{28igomJDis=78!&9}~-_P^RY7dXj^`rcPRW_EXG zk=ZNZDwxm+2nyMq<#m@uO|KUS;<7gE;sunP?&&_WGw#fE)7`TV6lh>Up3=M*L}<{f zM2NRPUNDA)IN|Drc!{=N64wxMxIrb6!~q|m7|rij_5XKQpXpuZn&m$H?Abl1&i7yS ztEy9{`aG&m)r4j9-sx%zhdmii7I7pz6RTIBHMMD~xW$Wpp7`YVp5o_DWuayt{-zLC z^5yXo^Jg}OQ{~W7>z^e}{@PBGF zSIteN!g9G-UY+Vx@FP0)yK?w|dF!qeXW{p(KMH8Zrz+JjS74n*;=4@8SG~1MwV4-^ zUF!7k4u@#8SWX>&1oDQf(pGF%ogH0GdBkkN|0B&QIh0l*RV}9MIl$4USnwTlnVD8I zE*5x-H*dm_|34l;?Ml<6Bj*qG)aCN_JBiDwTr$(chPTpgG<}UD zO?>Dm6H6Us5+%5;ql}qdVPf@RlSr*J$=Q`i=OpCgWMeS(du;9;6K|Yr5*fVJ4gY~j z4hL}a(B_Rvhwu-LnHfX)aU97e6i3k{TSeH;H}P88BpPMJx78#w+f1x+0kj`BvC@Z; zw+l^d_Coky1otA77{1uVOEr^d)o>h_z;>xg*0v*G=q8xG0`dNuOX&u8?k*5_ySN_} zcZaz5iu-`LpBHyV+^>lHq_|Iu`<%Ehiu((3`)_pV4vBk!xQB|nT-;USzDwM-;=WJZ zthgT(w<_*M;$A84jpE)Z?x)0UiuSKNZQQ{rwFS5NQUo2A?iaqh6V8F5SEHpFcyAL_!V?scxlH*tr= zcbs#p!X@D?!gI$v{|^b*Ryn>*c=!az8t-0rZwc%zfxRWLw*-E(OW;drujXT#x_Y$d ze$3g`Rr{#e)m8h1*r&x+`$fVZ5!XEu8gs3%x@x~s?CPrhZn3MY_WQ-IuG&8*c6HVM zCt_Du?T?FHU9~?cc6HVM9kHvc$NK}ZtE={(i(Or{$M1CItghN$Cw6t!exTUZRr}#$ zS6A)Fh+SQ^zeDWms{QxHuCCh85WBi+KU?hTYWbWec6HT0F81@qO-Mx3!WTyDmk3`S zv0pE&u0BBDx(mDJcdxs*1ooD|-V*qKwFH*Ec{qFAnse5iJ3Kdtw&q{|pB&(_bP${r zj^?H(s%K75g=>pwnhnhv<)Jz}f=V@)-xTD>HU%4}bLD~&V*#yWr8X3&tAxU~i2?-E zBLSM35yI5i{%)68-IRx!QZRA>8YT^Jl||diMoe3r%vCm(kqcT*wU)|M35~+lQRacx zjI(wd&vwRkUPsZm#lTsymnZV2Z5qRvHCBrg#VyDqLY2gTW^ZTMY7Lt!-HFsin1hHC{EM2MSvQ!r= zOxq0a5Ny}ih8S=Hn2Y-arzEy!n_YBY5H9D(Y_4a7kv`>*6H!#v;^c@sz1ARQ?S84T z!1S5HU~&vKE6h(9FA=pyRmCT)sr>mpp-oE3<7(56shXSC4N=*o@tgFv(FA zow+2zoY+9-iUiN)H3?hwOg)h>&6SMi7;NUaX&ukK)!59uGZr9kMe}KdYM?tYK0Zz_=Hnm zhB?IPx*=&VAa^IH%avj|FpnmYfzz05A>3-N=|fI3$Vu}ITONe~eMaaWdnC!Dx*NW& z^~Us}OY6HycO|-{&!%}rAJeP%*`vRu&%`TX)x4C<6$0Do_zR|THsY`7o$V&>xjy8Y4cuQ_#leuLHDyRAK5=8cMMx!BCnSWVKpO3+(^-G(~rEzBO zGHz>^bKAle3S5k(W}7cAnP1N@8$cGXU`X6A@nh)v5xhVFvfX9;7p8fYP0eoWSKBnN zK^%j)Bbxs?fLray2kp)2PX=vW{^Fpk+Fu?F&9?_p*IyWPx6+%Ix?lV4OH1a{OE=5C zzM_U(apJZtFL4f6i`OH`{$|QC&vyp}u_%_{*h; zpMN7az6C#S^Q%GJr!R-C0UKhuB_0cSoi<-%xLav!+^V*}UWy8ayZj$7wGU0^zah-5 z4O6>~A!|Eq_&d05+HDOV%wZqbWaO%acqTWQe}bxZyS#Wemd(ZLu~vL8md-X3v+?G> zwRkI5nvFM-twgrfpTaUc+=?}0bIE2b-H6xvhHJ5GJvOs=XqcX@*ifl7l*!f-^+Xd< zWwW*Z*0Q;MhBD1$tG_-lo1EP@)r5YwuNFtNed$&rg%tbJwd7o1J)TZyX5!7*Oe{5< zXeQ@u9GOx*kxG?HDWotHV}R^zER`A>P7kG1wOAuQ)WT=uc4=Z1jEN=9wQn#cg@c@U zqcKBpk2=ut+TV8Wn+|gB&NmygAN) zCSvBQpDa6<{`g^;<=C)Kl=~0D|4@%g&+a@9Uyhrj7bKRxV`f zeWpHzaai=@$SbC=OdItX?qH!qz0cH_Fl3E>3B*IaGHnaVe|D+U|9jCZt3Hi*xR9BC znt+AO^c$i-QuNC7XZl&JT*%aC30TO~n|<7VTJ*~FqQ1c$EOe;%*`|+=g6X$G(-)@A zrq3NLbZq(_+w_N=-?*kPtokPUy}78~XX=~i|EAwo(JQO|7gpWTD|0&jwMwTPxvO`&k5fw{D|-^!jB8zD*O%M+l0R@yhHdo;oF5@5WYkB72%Hw_oLo1 z|91)x34dJpK;gTD-y(ds@Jiu^@Y{v&5k6J;Uf~VGpAcsG7Pyfm`uoo!d_g_o7Qy`e zUmf}VH*pX`?=il?$2rECCCd`iAJw5WO<}sm~;^!9u3qXX>?oeq8j*s!vgjMfE95 zo%Dwear;|Due?zGu;{N4z4Ai!8PVS?dgX=cOQQdT=#^DJ>>V%5&u3fyqJL2I`W?eU z^)1mqDtcwrw<78LY}3a{X4t>c^o3RbhY`K<^9cVIT$5(+ae9W|-Sr@j`%FRNqO&i! z*Y$wkC^4=8{`U7ItobQLeosF0cxDcF`m*SiRo|36ka<3QroME9)7M3>d@p#rXz6Ht zX|ZX1J~O_i#MhGelvSVN4i?q>OnvLE&hHt~E33X1DG#5i&m86SFNgy4`&(zO}J`laK>eERV z0eKxZK2tw@w9Efi(JQNdD3ZR<)Tc#%h3J)4KOE8fOnpi89DK#{S5|#0qW78ly6Eo{ zz4Ai!P0`PYUU{MVmgrleS62P9NdA?dL3lp1Wbb$7&+xmuzWe~;{p-t5z`d?7bCRET zVe}fyQ(5!VisZ*~!(J$Q<%Q~- zqQ6@7%BuJCyADR5?eU9#haSJM>Q9a2U-^E7=lw#z$7A^2ozI65-ans@fP0v zsn_ocPZzy1!&BeH%0=})Q?K74=0vZo`nr?1^*&QSbApSzEP7?tXCr!_sZXtT`m02* zyik2j^mmC~`3vCfk~STU&m^3Yyp9`>nV;G_T-d+T_=Hv8THLMonfeUItuidXv*!6! zR{b15_{KtJ`aV;iKHd5KO!UgChuJQw_t~Z|`q$$^Xww%~eI}y!nfiu=KT7n%A`j?-0GR>iy^cbuju&eQLeapCNi>)erSWj^AVIhtGEUjiOgp{W+2RD}M;# zQ&Ki`ZUFQCQCr~s;~s?fuQ&e%%ZY*S$Z;F70OnqJS2Wa}j^k2yJBAs_}trorVLiKZ^UoU!P)z3!GkI&413+;yt zd%ozERc}4zczOIjTRqwxX}(tV!m7`52MZnQeWreR-1&V*^vVp+@@qu$@3T#Rlhgm1 zrZ22|+>Y!*X8OuI5kBR-?Dl&RX7~a(vb+R;zdoMv`fff4+^c>LO}P9$41Zoflph0c z*T~_1Kf+9!$M3fHBQ; z6&Kft>V;MR&k?=yhY+6aeRDTC{dLNij+ojTg@<-Hrp>QUx52-_{K@j82q%B5_w!YK zvx~0;f7U1E4}-UBWNKl8=w99bPDu-{rS%keh}QNKBX>n`9Js#?)a6D2KTB@{__&^<1>#Z zbFqu>4_r?NaA= zspyqepRwwW-e>AtqQ6G;%Bn9#^gi3;zs$vbs~*3w>g(LWLdWLcW1Bus8ch#q`ogra z{8CuCkf~1*u#l;rlkks=UYY(2(GOkj;(Au}%BuH|m+AY=^lPFw=$GK{QTf&MZ$fz9 zAF{W*^cmj&eVhRQ0&Ke68sSfZ`TL0W&(2AHUUz`YkMhA_6jgiC{H4S~?p3}+SGfG0 zCh;k&emJ7{ndOrf{duBSR{g7`pB4T2qE}w1z9#xBM6ay+nMnS9w)y{vJN}Pp{)JVa zj_7^1^+Uoxpy@~SnTXzJ>RS^25z#BR)8`HrI_t1WdrbY%RnG6LqE}`x{ywr;xsa*P z60ne|FNvOi%Zv3}nf}zzV&y`newKiROnv5RxBp|&E7PC)6jm-|>Qe+PWShR|`_OM^ z(-)@yLiBYBzrW~}RX@bUu#lO)&rH7|`nQN)S@pwK-O>9@eM|Hwh+bLs>4@HE>W8jz zai1o7W!3xn?UnzO=szHOW!3xXQSUR;&x(FZ^vbGF8MlzB_nG>d=r0z%GQ;!y)v$6Q zQ(q%sAyaRzb^AAoUYTC@{Bs8j9h<(#)TgdrT9|A&ROKjq89+MfO$)gSA^ zzbLHj!~N)Y=kaQL@9zj}d+vV_*7n%<2y6T52ZXh~^L!2e4wv3`VQoMBxUjazeO6f8 z*B%wt_OhMA+Wz&tu(lT&%(=(>YkN>iSle?>5Z3mY|0JyKEoJ46F28kQZ4bFu{Wm%P zKNr^b-6xdg{q?)#B=RHgr!NZY_cXr}*6(Qs@ZAB!>-RMK3G4SX2MOOI@x4u0zo$7? zSih(FJz@Qx<}_jbo@TwUeou3ruzpW7CamAnl!f(snhS;XdzveS^?RC|g!OxxyM*<7 zn$HO9_cWgu*6(Q^71sCrCzWq=<^L^VeZPNNSfBS^ArIhwd5;UfEah1HTMi@-;`)2P z^FK^j+eeR6mg@sAL;J?u)r`MKyk3HFeURT1ex{bS{|si!+8=hZu=Y=#DXi^9Sz&Ge zL9>e0YkSNk!uouHYGD2Ke)|bwy&gZL;pP7Dm~dL2*Pc>;;eQs^=h+yJjmM|YgZm3- zq5qJKc5Z33< zXOzYNMP(_EewN`&L+NA}Bq zAi~Qcd_aT`j_?r?ULN7&BK-CUpA_NuM0kCK&x>#v;mHW|uW$Ir`{4+0kMMO7zA3`D zNBG_de=k8i|`L4{8EHtOS;QrafEl`e)cV_e~a}gtbd1< zlPo`jm9yIaJ=SNjei!Tauznxwb6EcYEANFr!1_E^PRGnXpdVtL!}yNSi z1nW<+zJ&EI}0BA_G$Gs3wd78)*g{K z4_EX2$erC*vH50K-t+A&Qa7lzN8;s><6eD_QH;HlL9|_F4o3A2(Ok?+-i_qdk*&Ve z`JircU~3PLXi_e`j*Jc5NXnkWiZKWqW1@qyKODP@ILZ&>YkQ304$7TT-a%Ohe{4=M-3jfA$O$@QuY1YdIP7j8siN(;B6+mlLDyLGj^26V`sQU) zY#d7-4al+QQJXhxJ?h1A>rtDG4vw1bu=aqn>3SoS$?d_*Iy83vNMrRuHE;upJ%bx* z+%`nUBJaW;*uloT@^nLx)mMi=b2Kr=?{ZxPfmjUu4zfg?y7F* z7$J5~Mbc$)6RB8}n?}X$+DTOGZfCXk%2sNO8?i@2HuM>alsXunrf8D#+I{Ah(&pO%dow8=_df9#Vx(%Yno~p5{ zYV00=tW%xU3Cmp#%zX{beFSeGHSVQ*wju zzr=R?$UpB5A^K460#q<34*piagpqgJJ#&^dGMr-B#eu!b+cA%iCmVGc`%189j>AQTqmb7U{H2aS|Ne(>!`VdMF$EE(EbD3KUkdR( z^sk2aHv1Pu{1YsR+E*U8uYWfrn0I!azrInen68xDzk_^rTPbAacVSSaDq&E~@vm@n znI^;PSg~M#`(5?S$vUrCop)U4qc3ZY*p@I}K&|SITrW<39`tB5Bqz<{98jDti_bZ| z-o&btCHL^@?v8o;c#LM3u)Jr^xE~?TyL)HEMW~aGo5L>Xw%HlL0{-rY*?GE*+*5%=j>@n>S*FFkv+ zsjk4^p}|cDb=6I3_ZpolNi32U&YIWI(&MD`mhFibi23CqPY~&;lEA7a-n?2f15)xoHEhgRVA^$t=9>{Xnv~FHw!fSCk38(O9pE#xB z3j9SVx66i%*QmZ~5|tIYXA{GziZ;>oI8`c%h;hPPQ%!dh(W-XijBAr&0_|p+pxuUp zrllS&Nvmk=F`L|O+ePgmu&&LYa87K_GcrwMH22FlorSEf9p@kPdQGlSsJ-Y0!3k&2 z1uHw~H9Fs#l%En#Hqm(nw#%esdYtZF+U|}FtDWE7(yLcyUVjUkURZsujZyC)~w1yv5`^}e_k4X^C9ovo7_X({u{^PuZU4VLuL_`v@!(kmXjdzPU>HoBiECE1%dlj7ytkO diff --git a/libretro-db/libretrodb_tool b/libretro-db/libretrodb_tool deleted file mode 100755 index 6103a09b3cd9a6444fa398e76a366952b602b812..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 58068 zcmeFa3v^UPwm*D24+sG~K~bZkGzbc!m?(_ANlRKzYe%Dq@0f&;02-2*bPFh8u#z#)a?^Q%cFd<07IBI;1qBs)Yr)`w@f+$G;f4@3a-6st={@41} z`o8ro&q|-FT~&M6u3fu!)!9|&YRZW|x)*Dpv+1 zfFPA#9}1G5tIjS%I3rn{K%)~ZEo}${7d0f3Qt5qmyG_q68>wK0kR|CQ`6Ip3rIpon zmGvl;N^j&!n_i!!N0@R?Tu1O%QCriHY;Y>QoI7lKK}mq{fc7Q`+mX`JiiSY_vYI6_ zJ(XUIq<5kuLfA=f0I#4?S{kfbv8-ls>9U%tS^*F2--p)P{1wag5>BNdSrGyCWEaYo zmKJ)h_Be7HZ8}<>Oam;g96O+%K!=5{Fr~D#rnAS|z?DP;8h7&EOZI!}^MI);-^dWI&+%g<#t-_gL>Q6GRdXC13jUX0Q*; z#cq@BW5K6bknI}{{64`KlOL4$4!(X~pF#$nO@Qx z8)99$T+{M*Ps%lSp@VbL!JbkIvk`nBQ=a-Js^>)Tljr2;nl8D$mi*I;K%`r6w<` zmax!d)zB(l1N0g7-mL1iCfP)inmf!oHAx3U;YfTj9-8+DP6eTp6d`Kyo+?{9fw9Q> z2Kp!EZAR}4M`{qrZ-o{zAocEH%K4 z%&zF=DCcSX=Er`svQ=MyKXQGcXBz$H@^)Xia9p0z+#VQNXqWFnd2e%E-*75$yv-l$ zO_!lV{bukXZ~lHGyk;}7Hu}Srtt~$D8^8I15iWViFyFAKuL^aKz(DmMFlVGA=NaU9 z;yb+gaesLEM(^}bNU{F0=%0~}#OQ;}Z~W#rE2@3#o~Z+(;&IwhdAyxyh$hg~Z^~8HU5&!TEd+vYvU9gJ+!ET$=H>}<=#by-k&5s-LXJJ_f>+3h7myJj! z9|nzzVH*usNBnJl)0*z+T~wK;zd&8F6KK|JU>L0!ECwYvX^x*b|^MK~MB+c5x(f_OX%2IFQFmWH*rYrmesQ{kCwhoxRA>5oH&F z-Z;_&UmBU=dL<$4`cftBPm!IF^$m9Ou0|(1WbN&a&PE1D7>Kg=qZ2(nLG*u|MC-_4 zBy$gGCp!>C7a+r$u~^eW(_DI!2kHcE`fs3G<5l9hc48+Iec_C8qQTDrz~o@J^duCZ zAhSdk>qXa|kW6Vs%G0O^82fFE_r8h8t?d<}RwU|8-AIU5ke7$;RE)`oV4;}28JPOx z-tMZ7_ALGJ{@8KhHQo9PvB3~{x1qnldUDx?=f`HKVwj8jV<(2a-Fi1hNo=Sr3cJ|N z;xK>hf#C^mu0bvAJ!qr>o7Qv*x%(aXh|WSx(bOMrk3I=j1l1@Ft|JFbu`)8{1ykLI z>4m}t9}1TwZD)?TN3>qp&36vP2HvhahZ3s`@cK_4gY*C^&zUQQrAWEl+q0%BbIP z)WhG+@^=oxTT$j7{8q}4asKYY?=j%!BaGumb!Vu4Um(5-{A>Y@Ui_YwA>;i01HU22 zza8OE@C(V1asKYXPdpE+`MTI=KJPPM6ARZv82de(>F&4@gOE>rXL|ELmcxF952Nz| z=u~2Ka>DM3U10sXjHdEq4A0n8wWi=lTt91Ml}<5nyO-Pz;OpNkDf$M^X3=X{Yh zE-RxPgVh|&4&=o0k(H?`)qUn5Us&If;Ud}CslM=BYct6Dx(1_q&6>m&!KK>20Bt|)2@eXj9}4xSuQ*5V6al5=Tf^|V~81yH<` zIG&j|XVt$FJ1l{Ha*uyGitpICGy!pIzt`a;j-6;6M*{)5;s zV8jLk&Mh)O@tb`q(ybEwD*17>H~oO#lnbL6)@L54Hy?*s=qt>|Ts!Btn>#VLXCn%g zxyNw57=POcUy+4pznPb3>G!oq-vb9CLBg*PzBX&-HCbYA)SGG0jqqJLM)-C(Ic^g3 zb952}F`$&_wA50M+>GT$_^zzNnQOCxt6b&AmgDyXen;!iLmtj)q5i=uMnOg25b~5N zYD8vlEyFCpWoJrXc|xnlWodd-m|2n8_p{g!5%+}ymgk+yY;C^|&0rYoGNxq;1oF`zAIC6DG#n zgj}l~86Hmb5hFhR*#@13;?`3rBvRv@(>v?`^7I;199#4>431{~o_Ru6fy+?;eb6p6 z#_4~M?J*+5U;<}#TQ?o0jsw)jkES07gc%zwG~_I3$Ofl|P}2wY~=@FJL3tj$U3sX-%-GK z)SUn6J62A=jg#ZS$UKtb*D-;2jNEfSW}gX8tOAt8a&-e2FP_j{RNw~@g}HawTkk7g z^W!4(iz_05<(jYKgA8yBwb+lj#M%QvnVrqMS2p;<^Pv=hyj&)CBe}V~$oydC_30(A zxH>)YXS_3Ov&>!fkHmbc@|U9$_aaesAP<%TeL_No=G%7vPwA#cuM*@|4kw}Q-kD3X z>feZ^nVrI0=bVmO)}i39@!O2wOZc%Lv(b+e@Z+46=uh}3*6q#7;GDR>tJxC1Nt)`% z`Vhqv`~fWXjL3b=u)^pDws93jZJmd84=P@_o!GW3_(=a(^7(w--Yh&LHMIw(>JyuD z$il>kTLkyziQs_(5j&iNFY%-ZmpVYecAj!is>gQ4)bJfk>Swz4jQTgDItN!}@r$5i!t+ zqRr7s=m2K|8i@9pS+Sc2rcN6OYT*T0@oh#p%b5N*L!bX*Y|Oy?qZBtx%$N;1*0O6M z>x#-YA6q`!Z}ze+-pJx{wnR=DAkTqR@!+#N5U@KL3JRUrV=V$X+0W(!7CPAO(Rt7l ztQA{}=n46O(4-Q0YvMwkljGlrY@t$c0>ABmFc(b|P}mpm;+$PHeP8`Qqy1Rt8j&>{ zEqy<&U2KQ|(f~j^Pk;fYQq1)B1V@UY!y(~VMOyz{sA(;yfaqb+;V%#IoAFcQ)u_O8 zl)o!0QV=%>cR_Dx(&?cuwEgo&#USMG5cz|;Tr6O&!gL7dv{-+pNm3@ z^WcEW80YEoit`y>b4`}7%bNpwn%6wMmE)R5=}GMM(u+vH3miy+a-Uh0!kc-e zOrSXbB{g1+$ZfeEbJRGa;-JqA9Ln-lOc@th>sl8V1<&@Fv&Q*M{}(w%e4BszXAL8b zP)D98JZfCL)20>N8cR!^Pq7CuVE^E|w1-a@sqNujE8FuCHj16?@v8RBknNe0Y>(X* z>@@nn$a3(UJAh}*7f0~ShZ9_h^|kb;PQ$~Q$Na_<`X=qJtBml4SVDYt4fV}>k6cA& zUv?eVF*3e@@m+Shi2vP=uV8w+9S<}9DB{s|w4vdKEPwdU94liwXP@oXQ`0o9sQEp; z=^W$=hshX5V9Oy1u61`$7Ecc259~6#tQOKVJHW=z1XFl?H_X3TK9YYQdhb~`w|ZGa zAaErjRX8;gxD&ShOB8*Q9%io22B9cjRDS}Dyi;Kuo*X9gKDx@z6NVd>2-VC(ezXac z^Ix)`{(G#iFR)8J0W87PL7>@8jT1~6=JUdj1Q}-N&3jl;_{Lm#rMnSD$vxH!#E2AO zcE|JRTZXyKYR+aUIB@82sYZQ<*=em6gkO&iWy=JyT}L5y_YuUVC5b_hXzU^ou<}?A z^F{P25COS#z4<hpN~X%N$_kFO+4d#v+5<#a5b zXO0(z1Fyx-vel#w~Gqcs2hRCbu8PCuSGhPu#|j+y*6>nl0sH}ypfDJu=U zKy`92i>#iSYyBQ-Vk^$0SMbqzOW zG-l5J{q?ZoQ+(lTb1>pP@oTf1+t;3m2{$6~S*+((`{2KT=Zia4=0WZWfxF?c8C5O9G@!xf8{u?gX66=H z%fOiiEF^3nw@RJ@UC4E~5uWLX11bIr8t|;g+)-%uC7<+dv>%{#I1hb>f(8=|=b=Q|^%y<-2H)m&&d%7PIMoMLoQ zBpAK0{;yKa!*}Ld&oP2+A3imfMCXzf5$#kuBGwb3y>6_ecESYM>-_%w_U8S;VKAXN zq3Nz*df1cIH5fKdGv{Z8yMjgo9XQj4l%?IjJu@MTH+trKVtq{ zw|661rh90K~^}zr>&3xU19H|HnBgESTLh`XK;)!{tU*FyJ-6R`rRj@sHbZXW$fv?gilgh zY^X{wFNf6IJ?148`(~ec3B`UI7iDtYdm_Di>$X$24zp{$cWLr`iM^kjBLCMo-P=!g zls`Rw|1ZmbIa~(Ekbm%sSn2;$@;?dPd3>t;V<#wqs~#Ahzf&b0wGVzFrhNO^;~0HV z=EK8miv7U0x*I)sy~H-X{h`BY!KtAcu3%p14!0|KPUw!T^x(MA9TU=nXYfHgoE7>i zEigayReJC^BV3SW%)B^fjgj9TyUZS!UGs&?95FWci|L#U_6H{?#wICX!ku|(PD2K0 z3t_06n8NqYNXJ}eR5D%hv zV1lU2$$!b(ip8bu&aQM}KrYLQ4Y#9R^CZuE&3RPp_Y89$75m}@&wasc+brhd@R@Z| zf*+hdqn9jxTp&}pNZ^Iffqht;8<=c+`yBFyS?%b}G+g~yvsj}sK!is=7Y_WK`gg6# zpoy8CRH9>3>4)ZMfgCu0>6j5ET0X=eP1Gek{yf%^r2jNVv6H^Q`rCZS@#xPlkn2(` zr0gRWjw!f&KK&((32$F2aGREB)c~4q`#z zXunV2I%^bGy(>@hg#BA)bwrN~z3qba85J8R?CVyo08{tFm&ks)uLC0^+la&a<)7YH z-;t=&Ea~x2|2&vI@1Be)P3@~HVyiv(WQ>}1XK*2=O#?zg5B3-)H#=dgu;}VG%!El? zvjGP(HghxT8z=z^Y&7Uh3VV@G3(dkn3eD8?=6NU)Thr9O@-%F+gV6AE(4eq?9azt@ zSwA&)v%a-|D~}ahUwWO4U-DgeX*I$NH(P~b4G))&%?J{U9#V{8{nn0k8FtP~dMF30 z!SIL2{}zjusus%g3?P8Tn}CyJB>L;Xqx8C!UGyIFY<<$;5q%h zqVS5`z^Ry0{pRO<$jF5c1U^$vKHll?*YD+GcpU2B^V=wd@X}y?i-p2c$86%G12^~~ zIOaM591r;xju*poA~_}_4@c`UFcSWh#Pd76q`L-DkMG+6zo%h7RwsfjOA+`Zl~AS3 zDO|GHQ9d4|)bWHo;uhRLD{)Z;MQ~` z^BqhrvFQnaK3dN)F#`=cViee@wXoRHcIY-*RbA!dKFD!aO_E5ADU7O_Rh)#xbY`~0eE5|dKC!ib- z{ge6u=hcz=0o0-d>T|G_w3%Pcb}EPD#S`jE8_2oPiW9{-D$WoIdwDE*Jqooww!GG& zQn9Y(dTGG;8CYx4^iKkVFK(PQX-#0E(3QLYWbcPf2KP^Lk{2_*5ji~|Tq1j{A0(S& zn7Pr1AO|T}qYLrWu1}ee)&x&laU;C1Di*o`pjnnx6zq(7PbtG$OF`VhkUu-cnBK@Tx|H_&jfwk!Kd(Vz}a>P<1PRVKXU!z>q0SRc-?BvjD{ECAqzuYx)C@t zB&SAOT(4Vil76^ZmoId-&)F7`ur+@3!A3!qtEUV7 z;R@^(+-fgsdK)YYR^P8y0Ow@DIJS?6j zV;l8|#Zw)Y7f{c(0>|QMf>7Dn3+=33u**kiuGH7Q=|VCa&_L*`qh4yMKP*~~MFGX3 zH(!G()BqMI#@yh4hYfoOlXqE<>sqE#YPsz_Nr> z5xlU_#dKe2);O%Pz7h>P6AFWd-FS@khj`K)g(po%%l;XgLIQ9DE}els63|22Kqp`C8on60u?>gvr zy$hzA6;no62TUlmYL9hgk{=FLdu&Fxfu!Qnp6i6XQwP&YQW+)&Pjo1Q0j5`=s>ED3 z5!8_Odsyrv8xonC!FHNBZS}hK_*7?aAFYpZ+EADePIIG^(;W4W&FRLOr^Nh5d~QXB zJvnkM=Q6@RET`2XE}U5gt(2}?z4?Cfi8C1MwsY!mPI30!CMLFKSSG@V{*e`4JDXP!BQXoeb1yK5o`; zkm(q|V!r@lNQ)2V2???P0ykD34};P}AHEj8zqOD64)+=1IXLWzam-_h*!ah>4a?jS ze=)Sia_K*B53T9b^!qy89r~sYI2-a3^pgGo;dg|8tOq++c(Ee&ng3jW`1s2r8Rr-{ zV=OfWei6=ofn`ScVsrpG!eNO^vto1MxzMq&fKFTiV=i<8j<+W%oTR&j3!neGkUerH z&;61B%)BprIXdtP{BXpXjuE`un0Up6Gvql1P4Sf{V7gxe6||R)bXLX2h-&<1XOa1e zfhCD^JJ7vK?!uL+IqBx6IRcs5E$XY^q=bJ-y=sG%dWa+fN@| zk_i?IyFP@P0@`k6`8sjs|JX* zA4Xk@^_78QJzyP#XXtuIa!c%NaR)Pq?edNyzeu1^N8ze0N_ z_{`6+^72QPOJyl?+p=uH!ReBm`S;8k>Wf^DH?3!IeU}p~@-)U51sjCBv*FJ9_pBc3 z@`XCm@S24AZ1jI1eY9^EW?Zx{SFwuqU26Lp^4Y!%ePORX>Jh<1T2XS?bBKqwPjKi> z{(kH(G{(mUZ;n3BUXIMJv+HSt`4n#2e%2J6X zhPyETo6qO4yhtF<0wSdz@nm?+G@ontUoq-15TJb%JN>TR9`lB*$epg2_X$^05nqjb z!Ma}%_|#{5#N);?8qlU6p;>%0?-vO3U-F1!5&rO+9vsNW%;1T)n=e8X!}LhK3*o4X z8o!#cIEwnAoGxN%<`pvP6 zu}qy^AUbCn%)P_3W2AqAofpWZn-7sySRR;f@X!VhCRn$C-RJ@&dGp)7rY9>pAMwQc zW#D*Pw|6u6heRGSOukLBrd19s46ZdW^d)X~UBB>;-wn0>uKw{k;4WbR6Z;MQ^&RL! zbOw&0p&JtpEgIHwpzbiNBZS&o`_FUGDGCSS4_Sjn_y`wARWw2DEEcK{eDzo05ETyv) z9=9~>23hJ}0LlD2VEUg-WBv@0AE-~}l_&Dfu=B2AH^~P?Y^>0xh~>PpDb9yPp6kWn zf5-~pLRrIHqd(V?Zq2#wkf2|0lXQSgI};6+S6^D-Al2%QV0#^dWxNn6Dsz8 z)iL*14o`CQdqRJ(U&ZQ;NFA0NB`}Cz_$I!IQ?BXtE1?Rar7Adx}==8UO z4Oc|QU4(73i?E#)YVQg457F22#2LD+r|aS@YM>F?2FpD41@ynz^s)A%eWdX)GP&Fx zrx2e<0w+L+J>6P3+699uN@UmXi~f-~_hgKoH8zkn>+C?rtVO|c+Y;EDbDL?!ojNp4 z^=@0g=v{*_Iu1HyXW?8dQ|#`GU4^A?I^_$ZZT6}wHm4{uZgliC6vK4+-&lgchTjVt zEk%itwyD`r=y7yU;I zp=w3waoc@_buo19Yv=jO!u7C7+4enQxv z4%balD-Hsuqg_QCjqor$y%(mVVGxX2w1G!h^yZZ$iersDtkSa+-9pEMIP-7lg&iKO zAdQZ-jUSKv~C%Qah z8xe1-?2V1cS;?Hl)~y)%NTs-N%w`KiSMUd+EyPRKye@$lY9;RTSxml&SExT?$h zccTyoU$639HE(MUQbl<>K)*Ph?_{(h3G(Lm2KIU4ukk$-y=ggGgK)#&5yI+xJ&hW5 zz^Z>%y_WI6$dFYt6nyJG)S&jhjt?gk4LRV*uM_z@ zeCs~Iu?xQ2lUp?8u*@&whaKWp5sEng{ zG0D6AW3O<|1W0QaBe_O6Fvo2#6TRJ@&{sGT z)cjK5tj6i%0%JmJx(5YEu)|lQE|4E4D&nEl&iY^Bye5uYf@e1eiG2W4`P0a+eclnC zSNI(=t&b?=@SSc#*^P5GBrO?-q^@}oHbc&+m{NJ-u`_x8UbPno+HpV>L(AymJGXJ` zhSP**h{HC21tty>IcX0iZ7is35#s2bJAZdVapKm!r;0?J(oJ-F+!}(>%J;2#HvSv9 zq0legPiBF#H5)YkN@?T7>0)S1kD)(LiIE>DQQVpXdcb;LU@hF0zteu@aq!=WvN9iL zcNcibad0rq<^Zqw&WVk(ddFfXa*{iCy!9$#lW>SOZasbixvSV}vvRj0K6D=D2bN1GMDUy{EAKJDB9daSWXJT8)$^C|9~KB713K z%m+A`U?$u^|2K-_AO|M^%$(?^y?lo_GIj4+95L@;E@Kv!4|^vd0pHQM1p+DQUVvwv zcagHdI@k?OhpJ!_v_3>5#dyFcUA9?!0713Jh$_P95LAw@gXE&j^uE&BHdq@yFN5;fAtn;9JSeV_L#)jd;B%N5{-G$eN zD;tZ#l{xyRg&2?@_+G?E<8Huo#Is=-5@K@n>3`W_bo8I@b72<>6R4Q{46{ehsMd31 z1oyW?TwKIsb=(-cs;UJCu`epB_`s%G1gEzC7cs~BI^rO;$3ZH5A7^H(SCQPqN@@WDS~t=ec^fP%4!Pl%7H%tu*bV_z8$iO4(=nQV6cOMEly zzfQIxaLul?PVRz{>4;%Ke`v+r5b{#o@^?;xS;!1gcjfdq((Hy`lPcw${fba{!1HF; zeA-K3%?E)i+(sBLKZSPS{2(4#OQPqX^5l9~*)N{I<`PUipo>F!!AoP=RV~zb>uI)R zEjFDFTh%+1DfNV4D^B4t!TjB{9j7sSws=J~uroFs$8N=Cv=;WH#OOADxHc`7VmmmysNkJn~}tK4FHZvB4J( zXz)Xz2&+T>@y>ftDhpe3cqD9{I7k^g*?JjE0&JAQRq5F(=r+#--LB?bRG5JTTJ;Cf zW>c)&G43WH!-zaahDan)xLJNeHZIRt*V7)@*oE*!r;08EZCLu*3TVS`1djxzF}2SV!e8DABfx zXJW7x{}Vf8YL8nziX-jLKQnF3274Vq83#AO_%9a8Q#Xx8(Ja}y#Z0580chJF5u|>@ zeAW4Rc78YWe}{a(`R6<|$cW%vs%by_My6gSq$OUbrny`F91Cn=_gjsy72FaUPECZh z!Hfd^gB}z3(DFP_k{?<-F#%(g+%k@VcrMVJUj&Po_ttIacybs=xIpg!i`KiqiTwi5 zp)r8|LC6F&hk0FqqLe%mPG!O-CM-dM?5tP?a>78w3tjgjkL?R=QEv?0%@o;!txuB0 zeb!k>Q$0PPbH!%R=^z~)Z&&yu^5Yf7ok|epyW&;@79;ddq^vjfO~;o+KSrL~FTx&5 z80Xlpfw`Y+#-%)SJ6xSqkTaJ*CBnjY#u zCvbcdGIk=v1EZxk{ROd5{|#$T3-#X=I4jhDV{j6V+ZzMq6Y8HE_$zROIkBth|GH~i$CzNz0@i>YwKJbVr=9W^(#2V;0WMNV?|{Pr*Kr+p`UICx_@ zX#brqYq&sQJ5lE>cil3UXJR1fnE(XYd;QWUDBXM{KD~oUNKoIbW zNuFzp)u;l~6^GJoBDzBu-NV+MfS|GPBDIO{Sh;#pu{dgU*ebR2f*-}O65oeat7HEs zdImE2#hHDU8!?>T#tzq~Sm*gCzHR7#dDe)m&T?6Q1nZbNWL-K6f(cj{I;{dX@xju^ zt`y$X9_kMW6ivj}elVo3H3orCeptthhE0#ph;Jo{lR z4+f4u><_pC7oqCaXT-VbtAlfOtUPu?Rg2B+&BBnuOx)Ljfr=x7-G0~SF}&>exxQ&8 z(S|$Gu$fT+t2!}>6#CS)BV%Zif3XftoSzrZ!{U2KP)E_gl4t<-m;FDWKk#%l!7S=A z7rx@7|K<>t?SD}VX5DVAjA+LA6`|0YSJ3+XXuTNz1I9<;%r)JG=2v>t5)=g9X7~@= ziz0#HnskvIu%-{fL+8Z4LViABN9Y3_#rw+K7C7g?TOuOFmt4P_?6#X`V?2(U75`hj zBfcZJ*B>t0?1=tbHgt+!HUj>c=6}xctn(KzOwd zV~Hza&+U5dKs`9g<=K&up~W&03`5`drVKb?fCu!i&+N{}%gyLU@jSqhcL3d#-(FRy z*Jh4@8Z$CHml3`8#5@u1K2gG_6E3_b+uOABujqSi)hYSA3r*3SB!BTvZRg6bLk9=x z>wiU6If&0T{tS`ANCQ47Sg03%?!^R9G<}zT_i7}2^-V9%iwyfgA-=El#9$De_`1Cw z_q_a}XI&Q;`ra|Gp%%dY$Rd}QJWl|kCvr2E$ge}Yy8V#_*n|H%OTU|r&LZ<4#uNSM zB@}{l@HsyoKE^z&H~lX_&#ljWUFh0b6ymu%vr6BGZ-T9XImG&z8J||^ zb^9rS!+;L=^M<5p`ST9(KD0{Ty$!#=Rq6EyPOj1qAN*Xu5gVe@3i^?S)Ncwk1y2KAG{wa@1u_Gmm{(rk#0b-Zq&2(1^>*2J($}sRQ3!_hwnes z@wJ?vp|+#Oh2EX}^1GfPd+<^YJbcLXPXDt0ee8I28@j=IPE z(qsGC*L|a5F<(E!^F$iEdmVPFHSP9Eo+tQ(08rE1TKy<54pJ~H4kPf34o_%jMza0h zNICXM;(?PP=qVXc%^}cCG~(r$>+_2@j5^t~zXNA(UiO;Lb18F!i)C|BY@8_e$;+P< zG=4C*pz--e?7idY*9UNHx&kFQ3V<@V7e@R;z8*N9iI1-qe}aB?;x@px?KmtlJrUp6 zDB#S+o9>-yP^T|29D-Y}h+I834PwRD5A^10bSx(5o;Fu(DEbF)j<*x^ne3B-e{(N8{V=jbAke z_Mx!(l_*bDz-sO}`n4uvm-X_vF}?ft(+trK7DgPd<juK5fgH}l=ztwY$@AZUrBjSM^2kV=#x?hDai(i>$ zm?!I-ZgYh`m^-VteoDs&__X|$*j7d2m1&`O<_`I6R$u+u9q%CdHf&#Bq;K-2hu)qW z>K)wCd;E}|A>AdNq2AFQy@Q7IF{XF)4ja zO&b2cM87LI7$=J{gfXqtisRAP=p)EY_K*20c3Wr;4hwT|89s8Z zH~l+`=#OukZ5x9h0RoADKh5kLPh&7!gDnWIq#fvZCwtwtq!k$Qs%-=ev)lY^-Paua z4a0>gi2cA`FRsJ;6Zl6DgM~qejX@chfQG@sAjFQ(-^u)VI?R9pGl2fb9E?df4Q%01 zCY&zFMI*5F-(y`dj7wg6QUcTAMZlQCmd-nvgsd(Q!6U?(STyu_b`)ZJUmjjfuB-1I zs%ii0qAGJy^#LH|GfW%|Osvf;VxXfD==j%T^oE{87vZoi)@q_g5ta26-dR%i3f*rnVSy?bP|hXvB*^O zMY2AgrgYZV;;awmT-5gq93+=6IY)h!1M2HQnWNUn_Tvj%^K+8}D6u|L^2ymh-{lJ8 z{QX_ICDH3aNw^3~I>Ynvu?ffcROLx8>s#nCKj#?viMF4%e;z8u`*e5aLf$V~nW&dZ zfzx97_PV+3Qf8-UJ8aO%T7A5U%lNVHBY{}yz9ghNxonYrvpw?fI zfW3mbJlQK)zzHau1-aT^jRLY}M~YhiQ=a35yzp6*yK=3|Np2%#b(h<^nsMwU;l=-w zPNSgwgn4gW#(HQADrBAcyxZdC_MZUkzLra?t^t$m9o(2*i3xX_AOX1 zh#YmCElYHKG8ox`Gq7$!M(`vtdUjZQfd(hL`11G3v4Z@UxHEUanutbt%=vEa_f6v0 z4lo)HSmj715ljx4al5PwMN{X)D;T%#M+;*Ze{pLJO5-WaK2fY3F8tIwosj&FEWZ&- zeNO1(M5uw-Zjk$)wO~r<$H~+WcG{`dDM*W*AVx>*BkXxc^vm-rb1j@Af=} zX2MfY)PuESJUBL1%Jl^gWQAAeTE8R<%rl?CV=zku=Hi|mnC_qcZgA9Pk-#`C#NyVM zEC<<5EONaE^&kqiRj@AG>D_SdXrgXGEm~kp>~~mAjK*hDh*b$Jrz{gjSlI)7=8Bf% z1e6n#v{OGRxZ`Pm4D$fjD%(n;pTg#|oV`8~s5_7(zdwZXBgN>z7WiGlG?YZ6$QDD4 z=Ab0H7hqyM!VLkG)7h+CfrmFTugDb-&|-`0KTtR^7BRx$3oVI$kgQMCe^nB;=^d3+ z&Cy7`i$uqMFPXu(o}bIL8EP7ZY-vty{|NWDurY}vt$3qv_E&gJ6uaJvwqi_}2CVNwyy)kKKM0vkXXxTSMW@OC@JBy;krz z7}9myDFGoC>r~LO*FQp^g+9z;TEd?t_UEwPdrf@i>zn-j*4=~u&EyPb{SA5cGGWyzv1);r*eB%F2)vaGMS19_oOJn(rr0n! z+gU#+1-#2|{X~$WFVt?H-b{;xuRhu13L7tUf6hm#Xb2f#5ZnGRMFR}zWMqr#FpzBn zdV;kJEfVz!%efs8EoTNwCU$n{WPu0*gYgx6Xjfcr(nnmpj;natUcyg!_0@#|aYl0F1>m;4mAR!l+cl7&c)o(@J(q2T&B zQErcQIYU@rygLEU))d>nCrtKLD2-F^(Mu6Jp9iR4_Iz#cKW_!&n)QSJgf5K|yq@Y1 zG{)Lz)_xSj`nx@LwP-XP&YxM;s9l)w0WyCQB~xX-nAq%N!F@3x%A5*Rgpbl=w?lYw z#R9b@K0XgqRDApe;yy*(e<1GD#C?Xi&l2}J;$9%`7mItLxL+dfhPYoU?tXFSN+~|R zSlq7?cdnP>%{#Aalc92Zx;75abG0vi^aW4+?R^`E#h7+?lt0GC+_v)9uW82 z#eJo?-y!Z?;l;j&Da%;ZDoud5`C1hAY*@E?1zlCGWILR{*AFeF!m$H z9%t-s#-3qpC1czpi`FpqHe-t!>tpN&#tt(^qrP+)6eW5IW2Z4Ti?NA}UBK9M#wIW} zpRqF-6B<8~F@Ae9n$1`pV;W;?8QTxf$)Py!g_~e}C@z7ZRC>@bQ>Oe(;I+xP{+4_)#BT#jgjyxhUiOk+}1R ze`kv9&xBc^-CHiPo7+ot<9?q zRxftf)CSzOb(J-4iQ+zce8br!lCAOcw5g>kg7pox^>+Tz>LX6J#_!o`N6Ti0d)95i z%KBCA%9VBXl?@HcYHQ|XYfCBv=hc)iuWUFbn#evXF7dRA`pWV^<$0iAx$>wqoCVyo zL^(GxA)~5gm6Qa5Y;9r9tu?hPYTQzALK3!wJ-3%Ht1e$uUFn`@3$Y zI$JwCHMb_Xd=dV~_Z2}XQGr==x(iCRobxZj!F$QWD+xEH$&lVS)k3! z@K1qloJ78)i)K{R*4Kjrw;*LBBeQaOU0{{KNhEO$Em~Gnjy5~5D{87&LC$q<@Y4WU zSGpU5b#=A%=n}17t6!w8z~3b85@;1VDNt*V!|@IF=t?F-vll}R?POE{3#yI656@qT z|Ia)Hao8|kt{1P%bd|f(v7B_d#%O7-5koUv{NL|>Wb()V+s=z|tV{8Kn&)WvpF+Gc zFr}n7y0o-*W@KpTWf@vV*y>E!n-aBYbyPlbS>adBmReI0row3riqk>n!5UBHGwKt#?%5kHBo;R97s$zWO{vdMcpb@ zxL70xYO8BkfC-ekPA0$=Wha!0gxebiRkhYyf=eFWiWw~O`@TApZsV;aFl4T0Jf z6@uLjBB645#d37ER^Ot)x>W=>N^p7Y?SghIVbz$22qfFmCO|Z0X}Rd1%@P*Xv=dM* z>z07(lpewj4He}zLiW1^7^p|*lZRdjE)EI~EeR&HtxqOE;w;`T!5Z13#&i-7)YnLI z8zfv`u~e|xB4HE}EhY%r1Zp8ACbWtKDO_9MHCL&YsSPPzzO=M*Wo1P$P+7VZodzwu zxn5heynI=Wc27D+OQ628vQ+zVdbPGQ-F7>dYCj*eqPBi<>5BUDI_>v^gMljTPlLI` zf&9wy<)zxsh6p!a`tpV)bsU%4Ph8cdRW-}YAy@6*L6u9eFHu=vxwurhp&PXKhid7f z_e-@uxP*)!NLySBTE9)x2A9{@m#8a@&c_zUFvHmnIqY6^d_N0*$QAm3)ja?N@6RMAzY^UJkPAFQ8@_kqGb`@^D z3)rGX^_7A8+Qo}XwJ*|X7fS=RrRbGuRGDQpOG@pLvu=o%DK>l1ff*IrD;Z)8gfgo% zGm{nHJxEKh(jLyhUP~Q1Q|ruFR#O3euhP0RG&H?Z+nTYg8oX%FXQ28LRNqz#=WQSU z&0&Vt*bFaQIs^npKgkf*>6;9(KUJ#zXJ&@h{u>vY%?+VGfV~eAsrC0jLXRvi#l8m| z_77yTnhk?c{2}B3(spFp#_hdK!R|+b)%}@5Mu#%Bw1&!nwkxxIajDonc#AdRgGAuU zzCX-(558`ND%->zr*6S5zM+8X#l2nJdvVv&1KQ?6!3t`3gZ9aw`pUZM@`}pRh9Ha$ zC8>QeNK30N)p`ciFI!%^VkzoufQDCUUnAYN;qMHxjk|?L^gYE|+P3iCC+_V$K9g3e zg$8S_gSE8k%Bq0&^TGAYmMjfu|2`OebqI`Y0;7}n79P|{o2G3Zod1JT?eoD}MydAV zVA_F5R>Q5!>a?F_(P;cKOG~e)t+}23e&Ge$$AedtSKq4rCJUONy^w|KyGTZrn5L~4 zIS(SI_3xsZ9^Ttu!Fbo$P0TL)gquGBuvhEg2Nwx_WNhT0?Z zKZn+7j|{zC+VQTT6w+td4aCI#kL(IZ zo}`qWp)vH(DZnuZTCv9hJV}eXbT)Pg+0Mn)9zw{vR;?l zos(CPQ{ZlNwWj6t;IJ4DjcNE7!EfU5oEwdJ3a?e>Amn#f2>bmTlwnybkddtndp!hZkYiUqApCVbaP@ghw8G6J{=6TcW| z^B8|X;wzYG#BXH;7X#uuVNw4uJMR%yzl0TjSqi=r7WE%z z_!{(;!9OIvf|*AC58=m)F!2@Ki}Gh>KzHx3^FEgF2nl~J;o~LDBl;|Vf`oMmkCgDK z5w_(2JemGC1HK2yS!=VIREl{)^np!{N$iSX}$IsWfS8UNTf7kzUE z^pN_iU`E-0J^1k=%>Hx2?EfB#f04vju)?ns*hzdRO#FgeJ8z-HSFpk_V+0oi*6)Og z-wON4yyX&K!Av9nZfXAs6W<9Fza4g!dFv&CC#K$^8TnvcMZ{;z5zrcz_MjBy7fV_UZUcNYd(e8OO>c+fN5P7pK!#0(Fy-llzpehir_}%IG3s|uu?icW2@_wNXxCpT@fED_>r(KYF!Ado{>>6! z!QU0XSK{9)@fED_o&2)>PFS>G;;&Nem$1S&QutT!k5Hca)VJ=t>C?ZVyi=ck4ftsK zq|UEIB|i#Q{FJ5eBOCQEz;vpn(J@Z+WMoiOp$`J0O+zJe8gi;bSZcf!Q)n{3lwAn_Hf@XJ#0 zoiOo>&$sb!k@yP!uJ~;d|1OEI;9ml6l65ms^t6=u$_Wd3;)`J{`>>)XVTIq5WfLWQ zIc`pv_&lq}ybg)4V5YG@_&mdlF!7x*@%g_PnD>UnS1{9vpMxJS!o+vNqJD}0g{oh| z3cpxjC-I#y@q1+X;X3MbzzRPv%_cyY^*dqWYhIi784_Q?3g5XtAifhOelZ3-%U&Sy z6|C@c@ZJ_L!o+vN#4jtd^9+fvV1<8u3jYee3FX}+EU$XNXJO7S*kIEm{@U%@O-{Kgb{IAP+q zUt{C1l=uo(_<5kgi!keV!o=^B_&<^O3Rd`yM8>7?8wF&;#IL*7jz28%6|C^f9OYTR z6DEF-#P5>$3Rd_nDfmv9_+{7G_3x4R3Rd_988!jJtltR}zx5^?zhB}jSm7gCTngU_ z6TeO34;o?XlY$j~UJAYwCVsEPA0hD-tnl3__)eJkT8Yj71c|TU?~3o1_yrPQ!QU0X zK;q-9w-`?fR`^I37valsQ*b#V!oHX`|IByVms^p)*hUrit`v9|;G@}>GRaTj@ispS zE(YA>pr`oDW&{@l^5=w|{M-qACqJ*H!0!SkKjD<;_qv;H+LxYS^P}J!0UwQ@0y2Y3 z@lzlm8)kpENqXxfJq5G;IQ*RD*&ZiM{62~QQ;Dx&gXr1KWC9mTOVonr-Bv!Zboo1xEwbp?9``If$!9(RVnZWz(>=kz6zW6m$H5Z z4}yRCX!_(_pO7CX%=WmeY}pYyST5f%N>#|SP4#CO8P&sl2c&6D^FX8G^ZpY0Og zFYy(u@LO0pF2bze3A28@ry=sLk@yN$_{9P{iSLAo-zxD-CBA|ceq9Q_6Bg~i#iq@# zEmM9u5?1)m=M}*}GjK5w_1|j88&&-hR`_lf#zmO;ZUVRn6Te-S|CPj7F!L#YH-5Yb z9}T}(;%}Dt3Rd{e_7dL-v;N|0oAxUbU%~$hAN$$DU)*>Mf9Y`et)1iJmK1m;V2+Q} z{gQUc&pXIxe<=7%z(*S&ZVCq%`8}$9B)v1>M;5%XB7t8XE zs{R!G;uL%*O#D_^{wES&!HN1A!NuTm+zK2p@q26Syx&TE1+y5(M;U&+2ot}I04~DB zFQ~KQ{7x&|uVCgAzZXAVgo)ov02g86yKl4O-4b8H%qPAZKVF21?vYDU%?7LPhcnUoiOoRB|bkDO!+BT;TNRf zJ7MDYN_>8`SByUiD|{!vN8`Uwmd}&;3Rd{e`iSp@S$|%=-L{J*zJe9LTeC01#CO8P zFP8ZHHwENh!HA0fYedM4F!37+;37=?9*Mt1;wzZ>qW>Ae#X!{WfQjGNVCUVT+Am=i zBmTdVpBAw3eU&|LT8ASour;Dq-dSd_}^_pJ_>0`6s`Uu<{okcdA`q+XZ%g z{HQwXSN^vd5?21L%OtG)Q>7AC{-&UWmH)_;u=2P3mxR^x@?#QK&%f=2GoW90*!(;v zVYPq!hJ@Ar@%s{1`^WnvtoDz;may7C&cwbT>8t%?UBYVr_*4n2{p0ZxR{O`3C9L+3 zr%71tAJ3Dp+CMImu-ZSqPQq&cxI)5e|F}lNYX5kZgw_6WvxL?D@lPbI_KzQsuv#DS zzX|bkKx#j!N5X19;0?kUFUnu{k%Hy;`9i{KJaO3SE_?JtO*o7I!`@1LrEMUr_IIX8 zSnb!q%_;KL{>fDeU(UCSC9LKfm=RH4*`pt-^3pzUlyHt*ulz~n%k|dN5?1TEmn5v# zLmx`mE$Q`3Sk2e`)Ct>DAoEX`uv$+{mawv~9tr13`+JotFYzlRtnA?`39I?>M-tAF z>z4;4tkz%uqhOiesbEy@b{Ih2;`1KF;Q6wS?7quV1S2L+t!N zt9-P9{k=`$W6TqNRl>bE4@CG=39Iu`nbCz3Y-2o3Af7U z*8&Nv=hvH5{xZA#5(z8+M4g0{zhISwmH#26$}h6OVN<@VCs;aAx>Ymw!9fM%y(sWgy?{&TIs#brshJVxW z?;HNA;jbBMDXhX390e;EFjTl4YWX879;e}~~I zU~2ljXAFOj;qN#6mf?2||A^r`!&AVmCqPevo&r4!qPxFWK(yC92YMd#0_a81OCSo( z^)l!c(5s-=K(B+|0MY-{MKKBA0=*4-2lOuJJrKoF`~XA&y*>od-t`gaW6)I)FdNM$ zpie=cfj$R)0s0bj4fGZ0YY>G2`v&wa=sOVp-TOFxp9Vbx`maCJosFyDYY2nJs2avF z1nyAK9+CH`k02n7244`zb$Wu?$es99Lb$Jt=WFMwM6S)J5?r|l0BD}oBiV3JiYA4K z@6ns)`nD9`!#9OySs}jVpO)}9`7;q+e@_Jr#<2qCO)!t~6BCFh71&V}-3u&9fk$ao$pI{aa7UF4+m)18;F1$iN)-+TKp~)D zz&BOUXl@$uYHq49Ho~Kc(iI{Bbmc__Jw~vwnp|cqYe*_YOj)g(;LGwHuY;j2Ge*vK z8HO&_mrSfk$soOqFmkpaVd|_bf#caM!sA()M^afa!}Sy?R06Lw2U98dsze~bs~|AY ztOat%*sDdEg2>WbMT8N!3UH=~qVfU^iU6a&coU^1UW)S8LJL4@iGUxgz)yv|3XDqf z80E!DLWFUG&|sWkbeM}s%^H3>AfAy3SZBghrzmIQb9{3q5yUl%1aHmBh2fYZIV-+7Y-_r`$)+YqSvS-TjB(3uh#$X`0IBSTejf?D$3*rF`5@$r8~VlHukQZa z5vZ|Zj3c<%A$lTz!SqXS7{81o767p#haGi9kYP$-K>iEt1bC^iVA2n61iu6XCf+|6 zQao??Wy~*SG1!+9jPj)f{+fvE1^$-M(gn7?eQ11yK$5eT*3$3BpdcQyK zf(~wUX_G}M3_48fz#W_nVQXEuc;2n=?5sb0=4`^yS4}w=)-P)E((cZh2$9mlNNWCl zo7+AgDa}Vx^S3v*r26j8-Z@E~U*EdqlbhSSzBW=?8%eE=%@2RF_&Y$C4aIix8(g*Q_X zwAX1U;8ccv31c5m9b$`AdOFEW8;02)Hr$y-R~Qu5WpZck>@7Dn>X z$)Icd^T#G#@3Qtk*`LljH>c3bxoFhQFOLVTe-%qSn%q$<{af+IyKv-N9u5Ha&l}ed zL<-3m^l7vtMT?+V22e<{sjG(jd^C|5F0w+$H?W!sPujz*N6tyK=}d$b?QlREI~eyl zuyd9x=1s2`cV0}+XnY)|Mczm|n-3&KGn8~#_)rU+F^Lh5w`HBTkg>$&Tj*~Vz032f z=Sp83jNB3C5lX}yeZJWP`2MYL=*5Ks+j3H121P=w=c5(aDdkM?1I$|lv&MtqL_`9Z ztVEF(c4qp5k|nNaMO*wBO|@0nZRHTXMmA9;Pqm-e4c>zE&4EogR8r+t6dw$Zi(<9h zYYZNpFR;Yn%-zYq;x@ua&4Pp^zSzy1)#dbb$NljDX7Q|TG)aEoDe0?rF>5u&onfl1 zhg+E{tzs%;!o<_fJ?ypM+los|9Rx4e1s52edBqW5BVi>r$?aQ$r39@PRz4XZAr7fH*i~AdV zm4DAMQbT{ScR+@McLBUT`VUy?(vupn-W*SD+w0laQg&s=a$-1E%+iJC+W+}{W9ecY X-0;ldjy|L_eufK%Xu1fQPpA14D$>%5 diff --git a/libretro-db/rmsgpack_test b/libretro-db/rmsgpack_test deleted file mode 100755 index 2f694d014fcb9fb954d818043fcfea173e95e8da..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 25792 zcmeHv4S1B*nf5zL5L9r&j}q~RK|w(@BvxHesflLbjRu+mwyri#{wBgUAu*W|tVIV& zl-Fr&>{ex4yPI~q{a8P@ja^0jgTVmFE*0a?u2d_g)x~!@sPU%(t1#bvpZ7U4ZzjQu z>-u_q-(Gv=y>fo;bDrlp&pGEgKkqqj=A}Qse{`&2c(M&6l4Tf%7j9sTVYC@O#0=wf zI1?@qC@)^@ztO+!YfK&bc!t6e5#`KA0fE2@{|zgKk|_Ryp=pL-=w?72;{?eL1VX{J zp)_r#ybe@=@+O|;&=BXO$q6EE7znh4!qqLQq)d4~yU>vr6AFzr!#I(b){pW6D}(h- z!DbL;%B#J|kykE_M$C3kJ;U^?XC{tdq z$csomvHKaKD>4Fs@ai?IR@Vkrt*&cScxeBc^Bn!UL#U4h`)DHmq!gDS^Q1`asL=4b_eHfu>ONG35!nL3<;=e%PNr4G;zbw=|}E zVYq&|;HQ3C9&x6;bB4&Pulh3md?L@OG<3<3$NJ73BCob8RFzK1Y(HP2qhFDb5WDqD zb2_m=pt>bJDu&m$QslWC$vw{47ValKkCc@zz0O}!xq!Jqr@;SMf$)EhS7JjVc^dw7p4J(bdYUK z0?oOSK2p&CO~ZhwVb3W@@xhIUn-^|ro>#xBdS31A^|io!&VZvHHQ)5-TzkhA2OlfA zb=HF)ANqvV%!M;1oTS_Z8Z!;gY}A*0ozoRec`Ro>9P?03Jn!bPrBY?1{N=Z|gn|wE zSLZ{IRn>~fI1d5Kn~zEqA)F(4Eih$`KBFx#+5)33Fxmp6Eil>wqb)Gn0{?GY;Cj>g zui|ekH#Z#2wLU4ej#?G=hR?lg3fJ%HfFeLcPp_`x&WLQ-J62;{2) z1%}HKUxkRMTf{0YVy1VGRq-zP-+cyqPsP7P`1#7N_{ZB>FP7mZ+ua;VarB>3a z=-=&s&)D$!^fhxMdpb8(ya(a$Nt-6^8zB5yrwb0F3tol(@%P}Z|2zqQ4f~)>>sV$b z?b)KEw{-{dA*w$mY63;EGgt?28#^-o2t0^_tTjatmE{)o)~Qn6??`vo~K8z?}zeb)}XyoGmXiv z=uezz-#E=M3g4WYXYE4==b?j(18mF)^gd>LdbiL#=RluJ-152=Wq+viT=k4Fjg~8x z+>Dplw8iL(*6|r)&nUNAmup|)2uWM+c>99191Mlw{AxV34Th#c&@?TGR{Y^)sqHz) z@wjvTgE_8=AUxjQiPyQbwnOY&%`ZMvO)#c1?hnz5pWn6S1h#l07xCXWUmn@hzp>&& zq#rIM$LSjX@&>pYqGU#54v zl5s6$macQU63k%lSuTo z=7TEJHV)ZqMWmiQyls;x(nFE$m#%Y*T9Oj=&Qaug_po_YUB|(mIm6BsVJFhQ)s(#p zl<_CvrRJZ^{=r~jb1p(@x$e^5p6E1%w{;ArpCL`UlUZm6-K5^O4^UwIEqEA8l(rPo zy3u*5W_Tba?I}==xIC;Dsp-buM5*_}!{CQdPEd_*p;wB~P~Gr$^@%jyuHmH#@)x-I zzrbOI8sO)R)R_C3i(2Z&gxSBy86>sbIQEz^J~_V^Uthd}tE^dS{b#B5soCR?p%TV! z|LX?gU5ukWUssJ|TI;sj=ZYfU)^DRtOT1eeUiY`YzxM3XXxYqMv+du!t&fAJ%=!>B zWb)-=t0%q`bj6V)-!HR*o!)zYjNH-_qQdz8>fNC z-}b(@^*VHDnHApbFB~+Z>$ZYxQ&}|F*->g8DYFik(TdHc^@dG*)vRwT4itZYIa6FY zyO2|y-0d$+mPH#j`4@aZiOo;O{{`ttjQ;_~tw;@C|`{aYlLSawd)mD9cV7Qot{E&zph zOU!IP^>47(F>7+}Ha&gG{^Its2|3Q%|LQwX7X;y6N7Fa#feBj8IO;WkezDl8=dN{KqtD|+TR;rhzyP}2xaLb z3%w{M^w(~oO;oUb%-fWm?m!4#jtu)+%xfFwd%Ug1Feg~kKZDi2R3~2OBz7aQG@3J0 zRro~!EDlahPXhrPa-7Oyx#-%->6A{SY)3iZ7<4$^J(5h?uVI2hsYvv;_97u(LtVBx zsTh-+F+(wVD>%JR`Frbj#Kw7_I-EEqx~|vzQerF`yw~);#B%c3h4T`ZYcj0GhZCnp z{k`5^jFQC3LW+5@m*klKVxb8sZN7n0*n6-@6LVVYB5L;#^oU=Hn3m~%Di(hRswk=P zt|3arpcD(EQhq4aYg&F7TzGS|B0YEJT5qe`t9kPeUnG-lZ-y!`U1E;gYE`J&Qq9Jx z$$s~1C?uToGK-G5!Q9Qg(iCn25|`Ci3lS|)sE?z?jP`? z;CA_-ce_k_;^#r5-2{|FceA()5Plmp_ra}|ka4=Z;GP6;A;Kga&7GlkpCY~m`aBOA z{cw9EWSs6l;7&yTZ3rKL+aMw1boarj_hG$WmzP?5ORd+{#`Oz~{XVXA_hDzHb_nPC z3*VPvzorzU^Cz&W)ac}b-Iuu7{w1bC&|#p2XW2gmNYuh2`#2a%yieJQTy$q&vG>Kq zSaf_}srSXw_H`b65QL@HSau*6mOt93>O#Gx)(NFi@9rEA#U`eeMz69TC3O#Pt_=ID zPI)DBXJb9V@mXdIOY?+3!x5ty=!HusrUC!+LECY!4m}!hHd-8dmZLpPM|0) zlCx6 zWOpv~gIP+72i^1C-MQQEK%)IKB|*Is4t<~0)QX>rUy2`%W|e{eCh}JwgI~Q*Mza%M z?{vdn2%>2AhS*Un+uUSE$9Ll;Br7xkm`1m^OexX3hXvdv^!_c$>Y8nQfWPpk@|6U^x1yo&C^ znDYiaw7$sC9bD}3geRKOyYedHS3u-e42Wb!cXY9j9K+}-Z`_y2V}9;2@>Tm_pBXx1 z@ER0)rWw5>PYts7@Ls{B&>0D|h_d_W9X^${U$Vk^4z+s!w6|!6sR^H=bdn#}#8^4+ z$g>{;OiXt2X$|%RNHBLCzRI+&$yF*$)+#uq#%~6JlevBF>PG)Qd zsIi48Q=53K1L~NJTTi}QEQaHHpyqp?hteMBzznbpOomR1TxEpD*k6ZSWgk;%AIz9$ ze~vFz5|h>FNSp>6X-nQY#_mTV=QJM}TvN8p@2U4+ma`oOV%VoDjeAfiUSj$}rztz# z3Ms|bF7#J;V*Gxk{rjr(?nb=u&En@!ZS2#R^c7>}4xf_I3e2;1 zm06#VB6Jn}lR^v17Q7Qa^SbuXOzc&Y_IA>t1LiF8ybJRnOIdr12QPB|jTcTQ>+>kZ z2tA+pdGYR?>4wvmi^1h?%hU^zo?lLKW{y9pMJ~fW*>ICM|CrVxt_v?z#9tLUwZ1s4 zn~_xKV9-xdqa&AD9RC&ZJ;+u=%z=9WQ{&MZU=e4rT6v1^3^V$*JigVSS9&Vq8$g^I zix^=rxQcjJx;!=MU6RI*yb(o}k0grnUFWY<2IG2ho-*x<_|crybgJsd({8KJv_8Up z119uRScDq$hL2+)X5RyPOd+#FrAu%sIoqu1D;`{giSqo?=+Zne1u>o6+YO=Oi>ZAA!7t9`x-9^{}hqhl_FVVhAD z>Br4Un@{EW`^|QLE|T{3_+KkPu|57iyq;iIShxf_Vzb`v@57wO`j=TR+xOtz@k{Fu zCaFItk6nMLV%vNVwYs6%57YoL%q#qM_!LZ}>vysRRI}KpfGWKobL{bKraA59+7G|3 zZYYiv4%&C)^@fr$Z=9dH^X+1# z+79%T2lm5F&fDDT{yTCx>f5-@jC)|jm}OjIUqe1D-Mg^^`FNr3ORr$|W5_GDcEfCL zKRr>e_y+Z2@`%H?_IgDR`;XK2C_4OPF9y`sysDw{sQ&m%y|GI%fcM~p8Z<| zlA*EK)x(04r9Egl)kH%#^iUedZ`9)*a5xoTn>mSp4_QiwtF;b(`!b~AqAfb64a1`> zT40Yw0=ndv2ymE*E@?yOs3nM9@>fWXp9MuwpwfDPO#!V7NRJt~%<^5cJLeKZ9owiW zdl{&gSbr727NL7Tr}nq7r{#FJ!a?YvZD=9GzU*+ymd;eVPIEOh#@fgBK9D6Q6~+=P zRHctHZ9Ga>Q}~cY>k&|9w)rA*vyYYb7XwlIW`s)?9P<9qdC71V$d2T!wWxb?)_0Wu zUFF}Y{D|`JR(`AUIZ~6eHY)!<<$q84_bb0c`9Dzp50(Fr@;52}N6LRh`G2qcPUZhh z`9D|wFO$tmN5a{2*g@GWG|?qKxfh?8l7lW$aPLb~48E%=j~m?P077 zvERM*_HW;KbLXzzvF;c8UVi1(-@Lf@rBJXXl;6;DOH)W#~N#)Up3)Eo{P zbyf8(L1R`uKE{L>HqM{ba=uZm{1ssHwS;SGg2CEgZNAZLG*=sI@Hf|3RJE!;SnCTl z`Wl;pt9`RtE{8kGmE0Vxs!b(BHv<=w>igpYgnSrsIC%`tnuceFk>#oKWP4t|VT_00 zrJG2k<2U7e7^lIEH>MgZnE-ZnMZ{xd$Fd;?lS5^WkySa?$jQyc_p1|)tiFkcr+kuO z^iMK8O*jTFn1T?e=dmdeh0Em1(~O*=sYuH+vT~;x9^W)0r|C@O9p@9ei257Gof2-8 z@COn;BH=G2?2_;q33p1kSHgV~{z1Zn5)MjeU{B5RPLgnngl9`QTf&Payi&qN5|&GN zqlD;FC2zHaYbCr}!tY7=kc6EQJ}P0Z&*3kUFd|`>g#8lwW;k?}5_U>xj6S0+Fxmp6 zEil>wqb)Gn0;4T3+5)33Fxmp6Eil>wqb=~?pamwLaHK@ZVJg&ft0I~*K##B5TCr$5Z= z6r_~gtUyaJsA|)tP$*chYP?mUHO;F+iZn)ub18?km#86C^FBhY%|3#(GW`ldmz7nj zg>AvARs#fDwZj5*dq%R5iU0nu4WlbjOM$7r>X3xy8k{YHU=y)cSlg;6fHSU~K*P#F zaBZ+A917yM4ytGgS2WAnF{?;QuRj|oZZT!T;Q@vk#U@pefo-l)L_|=Mz={U=Z%z)Q%4y2>l zM?H;=^~Mv(>z|3_zVn!OKD+^X9djAG2wvw^_%CpnhVgI~EbOf;)lY}ARI7iHrc5~3!ob8xYZ?@AOFJ?CxZ)D#lz4Bo;TEuuPtA5q$pm9%j4L-0yZ)6+Ub;kBA z{#?bYSuLx+6EyZ^8Cgxnzh%`Ld$XWL3H9;Ai_z=%L;p}f5x$=Vv-lV^kwwg23@>8B z>!a6k9lQa0eM=Zy0zQm{f6P`x;InK{EM-GufErt}VWrO^sdFjmmwJ@V8%Ig>HKcTY zO;R@CT#@$u$80qqjZZ<*Pl`x6y|0sYIlL}QF$z@vftzL7WpEc&aB)%9Ae_>JPV#D$N27a!|>r?Gct?+ zm!4z1fRo8uMd5fkAa`Rga9y^?u>LghMpAg-^5N;<{is0xOc!SUOgNsS@*!Rd&yC3+ z$#wF+Bm5d`{tm^R=67TA=i-Aa(mp8s8f$+2dmqFs-;K#%i8Ea0Jtq7bGwpcvFUQ$0 zX=B2#vF0yA9v@dezAtwKT@W+K;W9E~;lMy@& z$nVCge0;Xgyd%1N!Aw)-GlGYKD&K`w`8exl(j;76vi}DJGmZRRxP0Y9Onx^ee<%LK zjd?SKUt^|`{|h)i#N^lbLeQTFo%QdqED-#poF6X|yhZTW1wSSDCc#?;*9m@F@U4QM z5qyW>X9eFQ_&LE32!3Ahj|B5u73%(T!P^D@N^nf@(}H&h-YNJ6!7mB!7W{_bor3>M z@Gik03EnOEh~OT<)Tx%9JelMFMBKF2>P&>E1CKQR`TH0YQ;&T1zs5{s|24t!A!h%% zG5cSi^EV5>#+tuCai{s+nEXXPCvUy*YpnT;GWgw?{1M@QK=?J*{OompcVm{X?>}A;evOZpzjB7telH8Z#>dOwDf|b7U*qHD?-%|f zy8ePSf1BYv#H_!@Q!uZbhfm4)dpgXcbKCPw0~SU zls6#qJ`;HwYyN&0J^9_3{Mc42SrhQ>7wt)7&F{p2Klgm6{CUE! zvF6XsDBq1)zEAkC5`K*}e?bPn8y=zs8#1T^{+}nEd_1f3NUstoeP0^AMBYjmgg+red&3_%&u4?JokyhnV~k0zAaz zj|l%`!mly&$?szX4+B-c3zNTdj+4jFS80D5lZ^cC_9DL)gy112 zzZ;X^z&9HV_=z~n*O*b3|5G?V#N^lbDCp0_C;0mJ)0kgNPoC4UmYf2t_n$Kb>;1@A z1Q+=n+1Ch;2wo;wum9D8`z1dl*f+!B-ypbB@Fu}}{rr{Ym;BwtIqCiGtAh1@w_mW{ z?-{c&h>h~}e)nX-dcS+BV7=e<3D*1Fxq|h6_Y%Q+zx!3edcRvLSnqe2 z3)cJHn+5Cr?kd50zZ(*)_q%rq*8AP4V7=dcSg_vj{v$EkK<^j+l^9Oj1I^CsajeyY zI9_9b)AK)ujl#Jye&-9;_J6IWm;7%D*6VeX&X@IggJ8YCcu25bpZ~XDJ-j^BymIkN8m|p9 z33<(sndZ8o$jssuMP{1ZVPqz&8w}jJIkzuEF5lE0*^m_HI!+}yH*ts#xjWOhW^!Mq zZ_1oIGWcS#+D_Gtn7SAfgTXDBTz>`XQby9`n1&ccb1(=R>0{|c=_cnIOW$8P7gzem zDnKc`s$vACNoNI}yDohl#ZZ()OkF_9&C{?O$9dmqtPeK?Tjtd?HZ++fCG%>+EuqGS z=3uC~u?n2?nj0JH)aB&7WlSq(8h-y)5nNPTJYCa>b+`_5-jeb~f#PM$ivPOsG8g#D#SU0fT&|gLlGev{yC!MaJK;i*lF5=`DR3trp@YBmek#hc1uDSj0zK>xZr4E!Y5z zkchipw|2u8$YIO4vqc#}{Z*@L>ch1`wl;p^A3?1X%U?O91k_=q&BL&Y4&6;;ZiAYG z!*&494B~2Oz2KzVUX~0OjVv>1l94t9sYNMGrWdtziW+2;JfybH@;)qCO3CL`htC(( f!X)!vdi4Bv9kKtDXJ%*eN>4}bv60bfhVg#@f^8^n From 3991f9b316548064041c210d41f8eee4defe3a03 Mon Sep 17 00:00:00 2001 From: radius Date: Sun, 26 Nov 2017 12:15:51 -0500 Subject: [PATCH 034/394] add frontend name to netplay announce --- network/netplay/netplay_frontend.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/network/netplay/netplay_frontend.c b/network/netplay/netplay_frontend.c index 49026cb10f..b393865a7a 100644 --- a/network/netplay/netplay_frontend.c +++ b/network/netplay/netplay_frontend.c @@ -613,9 +613,12 @@ static void netplay_announce(void) char *corename = NULL; char *gamename = NULL; char *coreversion = NULL; + char *frontend_ident = NULL; settings_t *settings = config_get_ptr(); rarch_system_info_t *system = runloop_get_system_info(); uint32_t content_crc = content_get_crc(); + const frontend_ctx_driver_t + *frontend = frontend_get_ptr(); net_http_urlencode_full(&username, settings->paths.username); net_http_urlencode_full(&corename, system->info.library_name); @@ -623,18 +626,19 @@ static void netplay_announce(void) !string_is_empty(path_basename(path_get(RARCH_PATH_BASENAME))) ? path_basename(path_get(RARCH_PATH_BASENAME)) : "N/A"); net_http_urlencode_full(&coreversion, system->info.library_version); + net_http_urlencode_full(&frontend_ident, frontend->ident); buf[0] = '\0'; snprintf(buf, sizeof(buf), "username=%s&core_name=%s&core_version=%s&" "game_name=%s&game_crc=%08X&port=%d" - "&has_password=%d&has_spectate_password=%d&force_mitm=%d&retroarch_version=%s", + "&has_password=%d&has_spectate_password=%d&force_mitm=%d&retroarch_version=%s&frontend=%s", username, corename, coreversion, gamename, content_crc, settings->uints.netplay_port, *settings->paths.netplay_password ? 1 : 0, *settings->paths.netplay_spectate_password ? 1 : 0, settings->bools.netplay_use_mitm_server, - PACKAGE_VERSION); + PACKAGE_VERSION, frontend_ident); #if 0 RARCH_LOG("[netplay] announcement URL: %s\n", buf); #endif From bc69737dae395b9b92de1ab7a5130cf2396f4c39 Mon Sep 17 00:00:00 2001 From: radius Date: Sun, 26 Nov 2017 13:00:30 -0500 Subject: [PATCH 035/394] remove this, it's causing issues with the history list --- command.c | 1 - 1 file changed, 1 deletion(-) diff --git a/command.c b/command.c index 7f281ba546..ac088b7fdb 100644 --- a/command.c +++ b/command.c @@ -1805,7 +1805,6 @@ bool command_event(enum event_command cmd, void *data) case CMD_EVENT_LOAD_CORE_PERSIST: { #ifdef HAVE_MENU - path_clear_all(); core_info_ctx_find_t info_find; rarch_system_info_t *system_info = runloop_get_system_info(); struct retro_system_info *system = &system_info->info; From 2dda04787a79aa2c66016e39847ce1c58f79820a Mon Sep 17 00:00:00 2001 From: radius Date: Sun, 26 Nov 2017 13:39:39 -0500 Subject: [PATCH 036/394] only disable states when hardcore mode is enabled --- command.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/command.c b/command.c index ac088b7fdb..019dd62a27 100644 --- a/command.c +++ b/command.c @@ -1102,7 +1102,7 @@ static void command_event_load_auto_state(void) #endif #ifdef HAVE_CHEEVOS - if (settings->bools.cheevos_hardcore_mode_enable) + if (cheevos_loaded && settings->bools.cheevos_hardcore_mode_enable) goto error; #endif @@ -1356,7 +1356,7 @@ static bool command_event_save_auto_state(void) goto error; #ifdef HAVE_CHEEVOS - if (settings->bools.cheevos_hardcore_mode_enable) + if (cheevos_loaded && settings->bools.cheevos_hardcore_mode_enable) goto error; #endif @@ -1845,7 +1845,7 @@ bool command_event(enum event_command cmd, void *data) #ifdef HAVE_CHEEVOS { settings_t *settings = config_get_ptr(); - if (settings->bools.cheevos_hardcore_mode_enable) + if (cheevos_loaded && settings->bools.cheevos_hardcore_mode_enable) return false; } #endif @@ -1887,7 +1887,7 @@ bool command_event(enum event_command cmd, void *data) { settings_t *settings = config_get_ptr(); #ifdef HAVE_CHEEVOS - if (settings->bools.cheevos_hardcore_mode_enable) + if (cheevos_loaded && settings->bools.cheevos_hardcore_mode_enable) return false; #endif @@ -1978,7 +1978,7 @@ bool command_event(enum event_command cmd, void *data) { #ifdef HAVE_CHEEVOS settings_t *settings = config_get_ptr(); - if (settings->bools.cheevos_hardcore_mode_enable) + if (cheevos_loaded && settings->bools.cheevos_hardcore_mode_enable) return false; #endif @@ -1989,7 +1989,7 @@ bool command_event(enum event_command cmd, void *data) { settings_t *settings = config_get_ptr(); #ifdef HAVE_CHEEVOS - if (settings->bools.cheevos_hardcore_mode_enable) + if (cheevos_loaded && settings->bools.cheevos_hardcore_mode_enable) return false; #endif if (settings->bools.rewind_enable) From 6e67a6ba632e1fa7cc941fd1c40a793c7b6b3537 Mon Sep 17 00:00:00 2001 From: radius Date: Sun, 26 Nov 2017 13:43:00 -0500 Subject: [PATCH 037/394] let's just clear basename instead (used to populate override, remaps, shader preset paths --- command.c | 1 + 1 file changed, 1 insertion(+) diff --git a/command.c b/command.c index 019dd62a27..c1e83e008d 100644 --- a/command.c +++ b/command.c @@ -1805,6 +1805,7 @@ bool command_event(enum event_command cmd, void *data) case CMD_EVENT_LOAD_CORE_PERSIST: { #ifdef HAVE_MENU + path_clear(RARCH_PATH_BASENAME); core_info_ctx_find_t info_find; rarch_system_info_t *system_info = runloop_get_system_info(); struct retro_system_info *system = &system_info->info; From fec63ae8edec7f547c3f4ad6bbe0d4c025452542 Mon Sep 17 00:00:00 2001 From: orbea Date: Sun, 26 Nov 2017 12:26:33 -0800 Subject: [PATCH 038/394] qb: Set configure paths without unset variables. --- qb/config.libs.sh | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/qb/config.libs.sh b/qb/config.libs.sh index 9ef47c2f83..d93a6f2732 100644 --- a/qb/config.libs.sh +++ b/qb/config.libs.sh @@ -150,14 +150,9 @@ fi add_define MAKEFILE libretro "$LIBRETRO" } -[ -z "$ASSETS_DIR" ] && ASSETS_DIR="${PREFIX}/share" -add_define MAKEFILE ASSETS_DIR "$ASSETS_DIR" - -[ -z "$BIN_DIR" ] && BIN_DIR="${PREFIX}/bin" -add_define MAKEFILE BIN_DIR "$BIN_DIR" - -[ -z "$MAN_DIR" ] && MAN_DIR="${PREFIX}/share/man" -add_define MAKEFILE MAN_DIR "$MAN_DIR" +add_define MAKEFILE ASSETS_DIR "${ASSETS_DIR:-${PREFIX}/share}" +add_define MAKEFILE BIN_DIR "${BIN_DIR:-${PREFIX}/bin}" +add_define MAKEFILE MAN_DIR "${MAN_DIR:-${PREFIX}/share/man}" if [ "$OS" = 'DOS' ]; then HAVE_SHADERPIPELINE=no From 97f971fd46e850b7f233fdce6374cc0e96179a93 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 26 Nov 2017 22:38:12 +0100 Subject: [PATCH 039/394] Fix C89 build --- command.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/command.c b/command.c index c1e83e008d..41f23e6ff7 100644 --- a/command.c +++ b/command.c @@ -1805,11 +1805,15 @@ bool command_event(enum event_command cmd, void *data) case CMD_EVENT_LOAD_CORE_PERSIST: { #ifdef HAVE_MENU - path_clear(RARCH_PATH_BASENAME); core_info_ctx_find_t info_find; - rarch_system_info_t *system_info = runloop_get_system_info(); - struct retro_system_info *system = &system_info->info; - const char *core_path = path_get(RARCH_PATH_CORE); + rarch_system_info_t *system_info = NULL; + struct retro_system_info *system = NULL; + const char *core_path = NULL; + + path_clear(RARCH_PATH_BASENAME); + system_info = runloop_get_system_info(); + system = &system_info->info; + core_path = path_get(RARCH_PATH_CORE); #if defined(HAVE_DYNAMIC) if (string_is_empty(core_path)) From e35394d4bdcf738f412f7515a25aa9a66593b9d4 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 26 Nov 2017 22:41:34 +0100 Subject: [PATCH 040/394] Fix MSVC 2003 build --- input/input_driver.c | 8 ++++---- libretro-common/compat/compat_strl.c | 2 +- libretro-common/file/nbio/nbio_windowsmmap.c | 2 +- menu/cbs/menu_cbs_ok.c | 2 +- tasks/task_file_transfer.c | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/input/input_driver.c b/input/input_driver.c index d19414199f..931da37956 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -2658,11 +2658,11 @@ void input_config_get_bind_string(char *buf, const struct retro_keybind *bind, break; } /* switch ( bind->mbutton ) */ - if ( tag != 0 ) { - if ( delim ) { + if (tag != 0) + { + if (delim) strlcat(buf, ", ", size); - } - strlcat( buf, msg_hash_to_str(tag), size ); + strlcat(buf, msg_hash_to_str((msg_hash_enums)tag), size ); delim = 1; } } diff --git a/libretro-common/compat/compat_strl.c b/libretro-common/compat/compat_strl.c index 3473ba56d3..9886b22ed2 100644 --- a/libretro-common/compat/compat_strl.c +++ b/libretro-common/compat/compat_strl.c @@ -64,7 +64,7 @@ size_t strlcat(char *dest, const char *source, size_t size) char *strldup(const char *s, size_t n) { - char *dst = malloc(sizeof(char) * (n + 1)); + char *dst = (char*)malloc(sizeof(char) * (n + 1)); strlcpy(dst, s, n); return dst; } diff --git a/libretro-common/file/nbio/nbio_windowsmmap.c b/libretro-common/file/nbio/nbio_windowsmmap.c index 1777398136..17e2a2332d 100644 --- a/libretro-common/file/nbio/nbio_windowsmmap.c +++ b/libretro-common/file/nbio/nbio_windowsmmap.c @@ -79,7 +79,7 @@ static void *nbio_mmap_win32_open(const char * filename, unsigned mode) ptr = MapViewOfFile(mem, is_write ? (FILE_MAP_READ|FILE_MAP_WRITE) : FILE_MAP_READ, 0, 0, len.QuadPart); CloseHandle(mem); - handle = malloc(sizeof(struct nbio_mmap_win32_t)); + handle = (nbio_mmap_win32_t*)malloc(sizeof(struct nbio_mmap_win32_t)); handle->file = file; handle->is_write = is_write; diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 638d0e40ce..588c705ed2 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -1368,7 +1368,7 @@ static int default_action_ok_load_content_with_core_from_menu(const char *_path, content_info.argv = NULL; content_info.args = NULL; content_info.environ_get = NULL; - if (!task_push_load_content_with_core_from_menu(_path, &content_info, _type, NULL, NULL)) + if (!task_push_load_content_with_core_from_menu(_path, &content_info, (rarch_core_type)_type, NULL, NULL)) return -1; return 0; } diff --git a/tasks/task_file_transfer.c b/tasks/task_file_transfer.c index de00534f4d..9d8ed3976a 100644 --- a/tasks/task_file_transfer.c +++ b/tasks/task_file_transfer.c @@ -67,7 +67,7 @@ void task_file_load_handler(retro_task_t *task) case NBIO_STATUS_INIT: if (nbio && !string_is_empty(nbio->path)) { - struct nbio_t *handle = nbio_open(nbio->path, NBIO_READ); + struct nbio_t *handle = (struct nbio_t*)nbio_open(nbio->path, NBIO_READ); if (handle) { From 493d442f8c79191f4a921a1a07c9248b7f77a13d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 26 Nov 2017 22:43:58 +0100 Subject: [PATCH 041/394] Silence some warnings --- menu/cbs/menu_cbs_ok.c | 4 ++-- network/netplay/netplay_discovery.c | 12 ++++++------ 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 588c705ed2..d5615dabe8 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -3388,12 +3388,12 @@ static void netplay_refresh_rooms_cb(void *task_data, void *user_data, const cha calloc(netplay_room_count + lan_room_count, sizeof(struct netplay_room)); - for (i = 0; i < netplay_room_count; i++) + for (i = 0; i < (unsigned)netplay_room_count; i++) memcpy(&netplay_room_list[i], netplay_room_get(i), sizeof(netplay_room_list[i])); if (lan_room_count != 0) { - for (i = netplay_room_count; i < netplay_room_count + lan_room_count; i++) + for (i = netplay_room_count; i < (unsigned)(netplay_room_count + lan_room_count); i++) { struct netplay_host *host = &lan_hosts->hosts[j++]; diff --git a/network/netplay/netplay_discovery.c b/network/netplay/netplay_discovery.c index 6ab0591318..82e63ada7a 100644 --- a/network/netplay/netplay_discovery.c +++ b/network/netplay/netplay_discovery.c @@ -128,8 +128,8 @@ bool netplay_discovery_driver_ctl(enum rarch_netplay_discovery_ctl_state state, { #ifndef RARCH_CONSOLE char port_str[6]; - int k = 0; int ret; + unsigned k = 0; if (lan_ad_client_fd < 0) return false; @@ -138,10 +138,9 @@ bool netplay_discovery_driver_ctl(enum rarch_netplay_discovery_ctl_state state, { case RARCH_NETPLAY_DISCOVERY_CTL_LAN_SEND_QUERY: { - struct addrinfo hints = {0}, *addr; - int canBroadcast = 1; - net_ifinfo_t interfaces; + struct addrinfo hints = {0}, *addr; + int canBroadcast = 1; if (!net_ifinfo_new(&interfaces)) return false; @@ -162,7 +161,7 @@ bool netplay_discovery_driver_ctl(enum rarch_netplay_discovery_ctl_state state, memcpy((void *) &ad_packet_buffer, "RANQ", 4); ad_packet_buffer.protocol_version = htonl(NETPLAY_PROTOCOL_VERSION); - for (k=0; k < interfaces.size; k++) + for (k = 0; k < (unsigned)interfaces.size; k++) { strlcpy(ad_packet_buffer.address, interfaces.entries[k].host, NETPLAY_HOST_STR_LEN); @@ -233,11 +232,12 @@ bool netplay_lan_ad_server(netplay_t *netplay) /* Todo: implement net_ifinfo and ntohs for consoles */ #ifndef RARCH_CONSOLE fd_set fds; + int ret; struct timeval tmp_tv = {0}; struct sockaddr their_addr; socklen_t addr_size; rarch_system_info_t *info = NULL; - int ret, k = 0; + unsigned k = 0; char reply_addr[NETPLAY_HOST_STR_LEN], port_str[6]; struct addrinfo *our_addr, hints = {0}; From 00d57af00508b1632701c594ce2c57fd607e0805 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 26 Nov 2017 22:53:42 +0100 Subject: [PATCH 042/394] C89_BUILD fixes --- gfx/video_driver.c | 2 +- input/input_driver.c | 2 +- libretro-common/file/nbio/nbio_linux.c | 15 ++++++++++++++- libretro-common/file/nbio/nbio_unixmmap.c | 16 ++++++++++++++-- libretro-common/file/nbio/nbio_windowsmmap.c | 17 +++++++++++++++-- retroarch.c | 5 ++--- 6 files changed, 47 insertions(+), 10 deletions(-) diff --git a/gfx/video_driver.c b/gfx/video_driver.c index b4ae34c571..1656d11bab 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -2409,7 +2409,7 @@ void video_driver_frame(const void *data, unsigned width, video_driver_frame_count++; - // Display the FPS, with a higher priority. + /* Display the FPS, with a higher priority. */ if (video_info.fps_show) runloop_msg_queue_push(video_info.fps_text, 2, 1, true); } diff --git a/input/input_driver.c b/input/input_driver.c index 931da37956..0506b90a23 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -2662,7 +2662,7 @@ void input_config_get_bind_string(char *buf, const struct retro_keybind *bind, { if (delim) strlcat(buf, ", ", size); - strlcat(buf, msg_hash_to_str((msg_hash_enums)tag), size ); + strlcat(buf, msg_hash_to_str((enum msg_hash_enums)tag), size ); delim = 1; } } diff --git a/libretro-common/file/nbio/nbio_linux.c b/libretro-common/file/nbio/nbio_linux.c index e6eba48620..7b40551194 100644 --- a/libretro-common/file/nbio/nbio_linux.c +++ b/libretro-common/file/nbio/nbio_linux.c @@ -20,6 +20,8 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +#include + #if defined(__linux__) #define _GNU_SOURCE @@ -28,7 +30,6 @@ #include #include -#include #include #include @@ -226,5 +227,17 @@ nbio_intf_t nbio_linux = { nbio_linux_free, "nbio_linux", }; +#else +nbio_intf_t nbio_linux = { + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + "nbio_linux", +}; #endif diff --git a/libretro-common/file/nbio/nbio_unixmmap.c b/libretro-common/file/nbio/nbio_unixmmap.c index 869a3864ad..25ec106cd8 100644 --- a/libretro-common/file/nbio/nbio_unixmmap.c +++ b/libretro-common/file/nbio/nbio_unixmmap.c @@ -20,13 +20,13 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +#include + #if defined(HAVE_MMAP) && defined(BSD) #include #include -#include - #ifdef _WIN32 #include #else @@ -157,5 +157,17 @@ nbio_intf_t nbio_mmap_unix = { nbio_mmap_unix_free, "nbio_mmap_unix", }; +#else +nbio_intf_t nbio_mmap_unix = { + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + "nbio_mmap_unix", +}; #endif diff --git a/libretro-common/file/nbio/nbio_windowsmmap.c b/libretro-common/file/nbio/nbio_windowsmmap.c index 17e2a2332d..42a22a16d6 100644 --- a/libretro-common/file/nbio/nbio_windowsmmap.c +++ b/libretro-common/file/nbio/nbio_windowsmmap.c @@ -20,12 +20,13 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +#include + #if defined(_WIN32) && !defined(_XBOX) #include #include -#include #include #include @@ -79,7 +80,7 @@ static void *nbio_mmap_win32_open(const char * filename, unsigned mode) ptr = MapViewOfFile(mem, is_write ? (FILE_MAP_READ|FILE_MAP_WRITE) : FILE_MAP_READ, 0, 0, len.QuadPart); CloseHandle(mem); - handle = (nbio_mmap_win32_t*)malloc(sizeof(struct nbio_mmap_win32_t)); + handle = (struct nbio_mmap_win32_t*)malloc(sizeof(struct nbio_mmap_win32_t)); handle->file = file; handle->is_write = is_write; @@ -182,5 +183,17 @@ nbio_intf_t nbio_mmap_win32 = { nbio_mmap_win32_free, "nbio_mmap_win32", }; +#else +nbio_intf_t nbio_mmap_win32 = { + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + NULL, + "nbio_mmap_win32", +}; #endif diff --git a/retroarch.c b/retroarch.c index f6f4061846..88173a0266 100644 --- a/retroarch.c +++ b/retroarch.c @@ -2799,11 +2799,10 @@ static enum runloop_state runloop_check_state( driver_set_nonblock_state(); } - // Display the fast forward state to the user, if needed. - if (runloop_fastmotion) { + /* Display the fast forward state to the user, if needed. */ + if (runloop_fastmotion) runloop_msg_queue_push( msg_hash_to_str(MSG_FAST_FORWARD), 1, 1, false); - } old_button_state = new_button_state; old_hold_button_state = new_hold_button_state; From dfebea910910b9277e02b1706a4e62580f326308 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 26 Nov 2017 22:58:36 +0100 Subject: [PATCH 043/394] Cleanups --- input/input_driver.c | 144 ++++++++++++++++++++++------------------- menu/cbs/menu_cbs_ok.c | 2 +- 2 files changed, 80 insertions(+), 66 deletions(-) diff --git a/input/input_driver.c b/input/input_driver.c index 0506b90a23..eabb1bd733 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -1775,9 +1775,8 @@ bool input_mouse_button_raw(unsigned port, unsigned id) settings_t *settings = config_get_ptr(); /*ignore axes*/ - if ( id == RETRO_DEVICE_ID_MOUSE_X || id == RETRO_DEVICE_ID_MOUSE_Y ) { + if ( id == RETRO_DEVICE_ID_MOUSE_X || id == RETRO_DEVICE_ID_MOUSE_Y ) return false; - } joypad_info.axis_threshold = input_driver_axis_threshold; joypad_info.joy_idx = settings->uints.input_joypad_map[port]; @@ -1786,9 +1785,8 @@ bool input_mouse_button_raw(unsigned port, unsigned id) res = current_input->input_state(current_input_data, joypad_info, libretro_input_binds, port, RETRO_DEVICE_MOUSE, 0, id); - if ( res ) { + if (res) return true; - } return false; } @@ -2480,28 +2478,47 @@ void input_config_parse_mouse_button(void *data, const char *prefix, if ( tmp[0]=='w' ) { - switch ( tmp[1] ) { - case 'u': bind->mbutton = RETRO_DEVICE_ID_MOUSE_WHEELUP; break; - case 'd': bind->mbutton = RETRO_DEVICE_ID_MOUSE_WHEELDOWN; break; - case 'h': - { - switch ( tmp[2] ) { - case 'u': bind->mbutton = RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELUP; break; - case 'd': bind->mbutton = RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELDOWN; break; - } - } - break; - } + switch ( tmp[1] ) + { + case 'u': + bind->mbutton = RETRO_DEVICE_ID_MOUSE_WHEELUP; + break; + case 'd': + bind->mbutton = RETRO_DEVICE_ID_MOUSE_WHEELDOWN; + break; + case 'h': + switch ( tmp[2] ) + { + case 'u': + bind->mbutton = RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELUP; + break; + case 'd': + bind->mbutton = RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELDOWN; + break; + } + break; + } } else { val = atoi(tmp); - switch ( val ) { - case 1: bind->mbutton = RETRO_DEVICE_ID_MOUSE_LEFT; break; - case 2: bind->mbutton = RETRO_DEVICE_ID_MOUSE_RIGHT; break; - case 3: bind->mbutton = RETRO_DEVICE_ID_MOUSE_MIDDLE; break; - case 4: bind->mbutton = RETRO_DEVICE_ID_MOUSE_BUTTON_4; break; - case 5: bind->mbutton = RETRO_DEVICE_ID_MOUSE_BUTTON_5; break; + switch ( val ) + { + case 1: + bind->mbutton = RETRO_DEVICE_ID_MOUSE_LEFT; + break; + case 2: + bind->mbutton = RETRO_DEVICE_ID_MOUSE_RIGHT; + break; + case 3: + bind->mbutton = RETRO_DEVICE_ID_MOUSE_MIDDLE; + break; + case 4: + bind->mbutton = RETRO_DEVICE_ID_MOUSE_BUTTON_4; + break; + case 5: + bind->mbutton = RETRO_DEVICE_ID_MOUSE_BUTTON_5; + break; } } } @@ -2605,22 +2622,21 @@ void input_config_get_bind_string(char *buf, const struct retro_keybind *bind, else if (auto_bind && auto_bind->joyaxis != AXIS_NONE) input_config_get_bind_string_joyaxis(buf, "Auto: ", auto_bind, size); - if ( *buf ) { + if (*buf) delim = 1; - } #ifndef RARCH_CONSOLE input_keymaps_translate_rk_to_str(bind->key, key, sizeof(key)); if (string_is_equal(key, file_path_str(FILE_PATH_NUL))) *key = '\0'; /*empty?*/ - if ( *key != '\0' ) { - if ( delim ) { - strlcat(buf, ", ", size); - } - snprintf(keybuf, sizeof(keybuf), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_INPUT_KEY), key); - strlcat(buf, keybuf, size); - delim = 1; + if (*key != '\0') + { + if (delim ) + strlcat(buf, ", ", size); + snprintf(keybuf, sizeof(keybuf), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_INPUT_KEY), key); + strlcat(buf, keybuf, size); + delim = 1; } #endif @@ -2628,35 +2644,35 @@ void input_config_get_bind_string(char *buf, const struct retro_keybind *bind, { int tag = 0; switch ( bind->mbutton ) - { - case RETRO_DEVICE_ID_MOUSE_LEFT: - tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_LEFT; - break; - case RETRO_DEVICE_ID_MOUSE_RIGHT: - tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_RIGHT; - break; - case RETRO_DEVICE_ID_MOUSE_MIDDLE: - tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_MIDDLE; - break; - case RETRO_DEVICE_ID_MOUSE_BUTTON_4: - tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON4; - break; - case RETRO_DEVICE_ID_MOUSE_BUTTON_5: - tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON5; - break; - case RETRO_DEVICE_ID_MOUSE_WHEELUP: - tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_UP; - break; - case RETRO_DEVICE_ID_MOUSE_WHEELDOWN: - tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_DOWN; - break; - case RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELUP: - tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_UP; - break; - case RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELDOWN: - tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_DOWN; - break; - } /* switch ( bind->mbutton ) */ + { + case RETRO_DEVICE_ID_MOUSE_LEFT: + tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_LEFT; + break; + case RETRO_DEVICE_ID_MOUSE_RIGHT: + tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_RIGHT; + break; + case RETRO_DEVICE_ID_MOUSE_MIDDLE: + tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_MIDDLE; + break; + case RETRO_DEVICE_ID_MOUSE_BUTTON_4: + tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON4; + break; + case RETRO_DEVICE_ID_MOUSE_BUTTON_5: + tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON5; + break; + case RETRO_DEVICE_ID_MOUSE_WHEELUP: + tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_UP; + break; + case RETRO_DEVICE_ID_MOUSE_WHEELDOWN: + tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_DOWN; + break; + case RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELUP: + tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_UP; + break; + case RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELDOWN: + tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_DOWN; + break; + } /* switch ( bind->mbutton ) */ if (tag != 0) { @@ -2668,9 +2684,8 @@ void input_config_get_bind_string(char *buf, const struct retro_keybind *bind, } /*completely empty?*/ - if ( *buf == '\0' ) { + if ( *buf == '\0' ) strlcat(buf, "---", size); - } } const char *input_config_get_device_name(unsigned port) @@ -2683,11 +2698,9 @@ const char *input_config_get_device_name(unsigned port) void input_config_set_device_name(unsigned port, const char *name) { if (!string_is_empty(name)) - { strlcpy(input_device_names[port], name, sizeof(input_device_names[port])); - } } void input_config_clear_device_name(unsigned port) @@ -2727,7 +2740,8 @@ bool input_config_get_bind_idx(unsigned port, unsigned *joy_idx_real) return true; } -const struct retro_keybind *input_config_get_bind_auto(unsigned port, unsigned id) +const struct retro_keybind *input_config_get_bind_auto( + unsigned port, unsigned id) { settings_t *settings = config_get_ptr(); unsigned joy_idx = settings->uints.input_joypad_map[port]; diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index d5615dabe8..1b8172c6e5 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -1368,7 +1368,7 @@ static int default_action_ok_load_content_with_core_from_menu(const char *_path, content_info.argv = NULL; content_info.args = NULL; content_info.environ_get = NULL; - if (!task_push_load_content_with_core_from_menu(_path, &content_info, (rarch_core_type)_type, NULL, NULL)) + if (!task_push_load_content_with_core_from_menu(_path, &content_info, (enum rarch_core_type)_type, NULL, NULL)) return -1; return 0; } From 6903602665e97d41e57261a6e8782d3ed51c3453 Mon Sep 17 00:00:00 2001 From: Andre Leiradella Date: Sun, 26 Nov 2017 22:03:59 +0000 Subject: [PATCH 044/394] Set cheevos_loaded to false if the cheevos and leaderboard lists are empty --- cheevos/cheevos.c | 41 +++++------------------------------------ 1 file changed, 5 insertions(+), 36 deletions(-) diff --git a/cheevos/cheevos.c b/cheevos/cheevos.c index d04aafaf16..d1f392885d 100644 --- a/cheevos/cheevos.c +++ b/cheevos/cheevos.c @@ -213,42 +213,6 @@ typedef struct cheevos_expr_t value; } cheevos_leaderboard_t; -/* -typedef struct -{ - bool is_lookup; - char* prestring; - cheevos_expr_t expression; -} cheevos_rps_element_t; - -typedef struct -{ - char* name; - unsigned type; -} cheevos_rps_format_t; - -typedef struct -{ - unsigned compare; - char* result; -} cheevos_rps_lookup_value; - -typedef struct -{ - char* name; - cheevos_rps_lookup_value* values; -} cheevos_rps_lookup_t; - -typedef struct -{ - cheevos_rps_element_t* elements; - cheevos_rps_format_t* formats; - unsigned format_count; - cheevos_rps_lookup_t* lookups; - unsigned lookup_count; -} cheevos_rps_t; -*/ - typedef struct { int console_id; @@ -2847,6 +2811,11 @@ static int cheevos_iterate(coro_t* coro) runloop_msg_queue_push(msg, 0, 6 * 60, false); } + if ( cheevos_locals.core.count == 0 + && cheevos_locals.unofficial.count == 0 + && cheevos_locals.lboard_count == 0) + cheevos_unload(); + CORO_STOP(); /************************************************************************** From 5361950d1cf768d09390238519d188dea5b7ac5f Mon Sep 17 00:00:00 2001 From: orbea Date: Sun, 26 Nov 2017 13:54:53 -0800 Subject: [PATCH 045/394] qb: Use printf and safer quoting in the check_pkgconf and check_header functions. --- qb/qb.libs.sh | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/qb/qb.libs.sh b/qb/qb.libs.sh index 00411c9109..1564ec7635 100644 --- a/qb/qb.libs.sh +++ b/qb/qb.libs.sh @@ -72,15 +72,15 @@ check_lib() # $1 = language $2 = HAVE_$2 $3 = lib $4 = function in lib $5 = } check_pkgconf() # $1 = HAVE_$1 $2 = package $3 = version $4 = critical error message [checked only if non-empty] -{ tmpval="$(eval echo \$HAVE_$1)" +{ tmpval="$(eval "printf %s \"\$HAVE_$1\"")" [ "$tmpval" = 'no' ] && return 0 ECHOBUF="Checking presence of package $2" [ "$3" ] && ECHOBUF="$ECHOBUF >= $3" [ "$PKG_CONF_PATH" = "none" ] && { - eval HAVE_$1="no" - echo "$ECHOBUF ... no" + eval "HAVE_$1=no" + printf %s\\n "$ECHOBUF ... no" return 0 } @@ -88,13 +88,13 @@ check_pkgconf() # $1 = HAVE_$1 $2 = package $3 = version $4 = critical error version='no' $PKG_CONF_PATH --atleast-version="${3:-0.0}" "$2" && { answer='yes' - version=$($PKG_CONF_PATH --modversion "$2") - eval $1_CFLAGS=\"$($PKG_CONF_PATH $2 --cflags)\" - eval $1_LIBS=\"$($PKG_CONF_PATH $2 --libs)\" + version="$("$PKG_CONF_PATH" --modversion "$2")" + eval "$1_CFLAGS=\"$("$PKG_CONF_PATH" "$2" --cflags)\"" + eval "$1_LIBS=\"$("$PKG_CONF_PATH" "$2" --libs)\"" } - eval HAVE_$1="$answer"; - echo "$ECHOBUF ... $version" + eval "HAVE_$1=\"$answer\"" + printf %s\\n "$ECHOBUF ... $version" if [ "$answer" = 'no' ]; then [ "$4" ] && die 1 "$4" [ "$tmpval" = 'yes' ] && \ @@ -104,18 +104,19 @@ check_pkgconf() # $1 = HAVE_$1 $2 = package $3 = version $4 = critical error fi } -check_header() #$1 = HAVE_$1 $2..$5 = header files -{ tmpval="$(eval echo \$HAVE_$1)" +check_header() #$1 = HAVE_$1 $2..$5 = header files +{ tmpval="$(eval "printf %s \"\$HAVE_$1\"")" [ "$tmpval" = 'no' ] && return 0 CHECKHEADER="$2" - echo "#include <$2>" > "$TEMP_C" - [ "$3" != "" ] && CHECKHEADER="$3" && echo "#include <$3>" >> "$TEMP_C" - [ "$4" != "" ] && CHECKHEADER="$4" && echo "#include <$4>" >> "$TEMP_C" - [ "$5" != "" ] && CHECKHEADER="$5" && echo "#include <$5>" >> "$TEMP_C" - echo "int main(void) { return 0; }" >> "$TEMP_C" + printf %s\\n "#include <$2>" > "$TEMP_C" + [ "$3" != '' ] && CHECKHEADER="$3" && printf %s\\n "#include <$3>" >> "$TEMP_C" + [ "$4" != '' ] && CHECKHEADER="$4" && printf %s\\n "#include <$4>" >> "$TEMP_C" + [ "$5" != '' ] && CHECKHEADER="$5" && printf %s\\n "#include <$5>" >> "$TEMP_C" + printf %s\\n "int main(void) { return 0; }" >> "$TEMP_C" answer='no' "$CC" -o "$TEMP_EXE" "$TEMP_C" $INCLUDE_DIRS >>config.log 2>&1 && answer='yes' - eval HAVE_$1="$answer"; echo "Checking presence of header file $CHECKHEADER ... $answer" + eval "HAVE_$1=\"$answer\"" + printf %s\\n "Checking presence of header file $CHECKHEADER ... $answer" rm -f -- "$TEMP_C" "$TEMP_EXE" [ "$tmpval" = 'yes' ] && [ "$answer" = 'no' ] && \ die 1 "Build assumed that $2 exists, but cannot locate. Exiting ..." From bb5f7d1cc1dd54d5d32a7cbf7dba453b8c374ee2 Mon Sep 17 00:00:00 2001 From: radius Date: Sun, 26 Nov 2017 18:22:59 -0500 Subject: [PATCH 046/394] remove this again, it causes issues saving remaps/presets/overrides --- command.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/command.c b/command.c index 41f23e6ff7..67fa8014c5 100644 --- a/command.c +++ b/command.c @@ -1809,11 +1809,9 @@ bool command_event(enum event_command cmd, void *data) rarch_system_info_t *system_info = NULL; struct retro_system_info *system = NULL; const char *core_path = NULL; - - path_clear(RARCH_PATH_BASENAME); - system_info = runloop_get_system_info(); - system = &system_info->info; - core_path = path_get(RARCH_PATH_CORE); + system_info = runloop_get_system_info(); + system = &system_info->info; + core_path = path_get(RARCH_PATH_CORE); #if defined(HAVE_DYNAMIC) if (string_is_empty(core_path)) From 6dfb6da4ecf5eb1c9125ebaeea31a475c09faad8 Mon Sep 17 00:00:00 2001 From: radius Date: Sun, 26 Nov 2017 18:33:05 -0500 Subject: [PATCH 047/394] clear the paths here instead --- menu/cbs/menu_cbs_ok.c | 1 + 1 file changed, 1 insertion(+) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 1b8172c6e5..90f2a1d4e4 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -3571,6 +3571,7 @@ static int action_ok_start_core(const char *path, content_info.args = NULL; content_info.environ_get = NULL; + path_clear(RARCH_PATH_BASENAME); if (!task_push_start_current_core(&content_info)) return -1; From 88905661e3a15ec1b36acfa1ffda0678babbe0a6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 27 Nov 2017 03:50:33 +0100 Subject: [PATCH 048/394] Cleanup --- menu/cbs/menu_cbs_ok.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 90f2a1d4e4..95e5d0d0c6 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -1481,8 +1481,6 @@ static int action_ok_playlist_entry_collection(const char *path, const char *core_name = NULL; playlist_t *tmp_playlist = NULL; menu_handle_t *menu = NULL; - rarch_system_info_t *info = runloop_get_system_info(); - struct retro_system_info *system = &info->info; if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu)) return menu_cbs_exit(); From d93b9ebf4db7bc3ea82c813dc25f67f5fbbe17b7 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Mon, 27 Nov 2017 03:53:25 +0100 Subject: [PATCH 049/394] Silence warning --- input/input_driver.c | 1 - 1 file changed, 1 deletion(-) diff --git a/input/input_driver.c b/input/input_driver.c index eabb1bd733..dfb30516ff 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -2679,7 +2679,6 @@ void input_config_get_bind_string(char *buf, const struct retro_keybind *bind, if (delim) strlcat(buf, ", ", size); strlcat(buf, msg_hash_to_str((enum msg_hash_enums)tag), size ); - delim = 1; } } From cdf1d9a417ccbdda2fa222fa3eeaf89285e5142f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 27 Nov 2017 03:53:46 +0100 Subject: [PATCH 050/394] Indent nits --- input/input_driver.c | 300 +++++++++++++++++++++---------------------- 1 file changed, 150 insertions(+), 150 deletions(-) diff --git a/input/input_driver.c b/input/input_driver.c index dfb30516ff..abfba95a91 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -480,9 +480,9 @@ const input_device_driver_t *input_driver_get_joypad_driver(void) const input_device_driver_t *input_driver_get_sec_joypad_driver(void) { - if (!current_input || !current_input->get_sec_joypad_driver) - return NULL; - return current_input->get_sec_joypad_driver(current_input_data); + if (!current_input || !current_input->get_sec_joypad_driver) + return NULL; + return current_input->get_sec_joypad_driver(current_input_data); } uint64_t input_driver_get_capabilities(void) @@ -499,7 +499,7 @@ void input_driver_set(const input_driver_t **input, void **input_data) *input = current_input; *input_data = current_input_data; } - + input_driver_set_own_driver(); } @@ -548,7 +548,7 @@ void input_poll(void) size_t i; settings_t *settings = config_get_ptr(); uint8_t max_users = (uint8_t)input_driver_max_users; - + current_input->poll(current_input_data); input_driver_turbo_btns.count++; @@ -804,8 +804,8 @@ void input_menu_keys_pressed(void *data, retro_bits_t* p_new_state) const struct retro_keybind *binds_auto = NULL; uint8_t max_users = (uint8_t)input_driver_max_users; uint8_t port_max = - settings->bools.input_all_users_control_menu - ? max_users : 1; + settings->bools.input_all_users_control_menu + ? max_users : 1; RARCH_INPUT_STATE_CLEAR_PTR( p_new_state ); @@ -882,7 +882,7 @@ void input_menu_keys_pressed(void *data, retro_bits_t* p_new_state) ? input_config_binds[port][i].joykey : joypad_info.auto_binds[i].joykey; joyaxis = (input_config_binds[port][i].joyaxis != AXIS_NONE) ? input_config_binds[port][i].joyaxis : joypad_info.auto_binds[i].joyaxis; - + if (sec) { if ((uint16_t)joykey == NO_BTN || !sec->button(joypad_info.joy_idx, (uint16_t)joykey)) @@ -1038,7 +1038,7 @@ void input_keys_pressed(void *data, retro_bits_t* p_new_state) joypad_info.joy_idx = settings->uints.input_joypad_map[0]; joypad_info.auto_binds = input_autoconf_binds[joypad_info.joy_idx]; joypad_info.axis_threshold = input_driver_axis_threshold; - + input_driver_block_libretro_input = false; input_driver_block_hotkey = false; @@ -1052,9 +1052,9 @@ void input_keys_pressed(void *data, retro_bits_t* p_new_state) && current_input->input_state( current_input_data, joypad_info, &binds, 0, RETRO_DEVICE_JOYPAD, 0, RARCH_ENABLE_HOTKEY)) - input_driver_block_libretro_input = true; - else - input_driver_block_hotkey = true; + input_driver_block_libretro_input = true; + else + input_driver_block_hotkey = true; } game_focus_toggle_valid = binds[RARCH_GAME_FOCUS_TOGGLE].valid; @@ -1073,7 +1073,7 @@ void input_keys_pressed(void *data, retro_bits_t* p_new_state) { if ( ((!input_driver_block_libretro_input && ((i < RARCH_FIRST_META_KEY))) - || !input_driver_block_hotkey) && + || !input_driver_block_hotkey) && binds[i].valid && current_input->input_state(current_input_data, joypad_info, &binds, 0, RETRO_DEVICE_JOYPAD, 0, i) @@ -1085,7 +1085,7 @@ void input_keys_pressed(void *data, retro_bits_t* p_new_state) if ((i >= RARCH_FIRST_META_KEY) && current_input->meta_key_pressed(current_input_data, i) - ) + ) { RARCH_INPUT_STATE_BIT_SET_PTR(p_new_state, i); continue; @@ -1317,7 +1317,7 @@ bool input_driver_init_command(void) } input_driver_command = command_new(); - + if (command_network_new( input_driver_command, stdin_cmd_enable && !grab_stdin, @@ -1582,7 +1582,7 @@ bool input_joypad_set_rumble(const input_device_driver_t *drv, if (!input_config_get_bind_idx(port, &joy_idx)) return false; - + if (!drv || !drv->set_rumble) return false; @@ -1613,99 +1613,99 @@ int16_t input_joypad_analog(const input_device_driver_t *drv, unsigned port, unsigned idx, unsigned ident, const struct retro_keybind *binds) { - int16_t res; + int16_t res; - if ( idx == RETRO_DEVICE_INDEX_ANALOG_BUTTON ) - { - /* A RETRO_DEVICE_JOYPAD button? */ - if ( ident < RARCH_FIRST_CUSTOM_BIND ) - { - uint32_t axis = 0; - const struct retro_keybind *bind = NULL; + if ( idx == RETRO_DEVICE_INDEX_ANALOG_BUTTON ) + { + /* A RETRO_DEVICE_JOYPAD button? */ + if ( ident < RARCH_FIRST_CUSTOM_BIND ) + { + uint32_t axis = 0; + const struct retro_keybind *bind = NULL; - bind = &binds[ ident ]; - if (!bind->valid) - return 0; + bind = &binds[ ident ]; + if (!bind->valid) + return 0; - axis = bind->joyaxis; - if ( axis == AXIS_NONE ) - axis = joypad_info.auto_binds[ ident ].joyaxis; + axis = bind->joyaxis; + if ( axis == AXIS_NONE ) + axis = joypad_info.auto_binds[ ident ].joyaxis; - /* Analog button. */ - res = abs( drv->axis( joypad_info.joy_idx, axis ) ); + /* Analog button. */ + res = abs( drv->axis( joypad_info.joy_idx, axis ) ); - /* If the result is zero, it's got a digital button attached to it */ - if ( res == 0 ) - { - uint64_t key = bind->joykey; + /* If the result is zero, it's got a digital button attached to it */ + if ( res == 0 ) + { + uint64_t key = bind->joykey; - if ( key == NO_BTN ) - key = joypad_info.auto_binds[ ident ].joykey; + if ( key == NO_BTN ) + key = joypad_info.auto_binds[ ident ].joykey; - if ( drv->button(joypad_info.joy_idx, (uint16_t)key)) - res = 0x7fff; - } - } - else - { - /* not a suitable button */ - res = 0; - } - } - else - { - /* Analog sticks. Either RETRO_DEVICE_INDEX_ANALOG_LEFT - * or RETRO_DEVICE_INDEX_ANALOG_RIGHT */ + if ( drv->button(joypad_info.joy_idx, (uint16_t)key)) + res = 0x7fff; + } + } + else + { + /* not a suitable button */ + res = 0; + } + } + else + { + /* Analog sticks. Either RETRO_DEVICE_INDEX_ANALOG_LEFT + * or RETRO_DEVICE_INDEX_ANALOG_RIGHT */ - uint32_t axis_minus, axis_plus; - int16_t pressed_minus, pressed_plus; - unsigned ident_minus = 0; - unsigned ident_plus = 0; - const struct retro_keybind *bind_minus = NULL; - const struct retro_keybind *bind_plus = NULL; + uint32_t axis_minus, axis_plus; + int16_t pressed_minus, pressed_plus; + unsigned ident_minus = 0; + unsigned ident_plus = 0; + const struct retro_keybind *bind_minus = NULL; + const struct retro_keybind *bind_plus = NULL; - input_conv_analog_id_to_bind_id(idx, ident, &ident_minus, &ident_plus); + input_conv_analog_id_to_bind_id(idx, ident, &ident_minus, &ident_plus); - bind_minus = &binds[ident_minus]; - bind_plus = &binds[ident_plus]; + bind_minus = &binds[ident_minus]; + bind_plus = &binds[ident_plus]; - if (!bind_minus->valid || !bind_plus->valid) - return 0; + if (!bind_minus->valid || !bind_plus->valid) + return 0; - axis_minus = bind_minus->joyaxis; - axis_plus = bind_plus->joyaxis; + axis_minus = bind_minus->joyaxis; + axis_plus = bind_plus->joyaxis; - if (axis_minus == AXIS_NONE) - axis_minus = joypad_info.auto_binds[ident_minus].joyaxis; - if (axis_plus == AXIS_NONE) - axis_plus = joypad_info.auto_binds[ident_plus].joyaxis; + if (axis_minus == AXIS_NONE) + axis_minus = joypad_info.auto_binds[ident_minus].joyaxis; + if (axis_plus == AXIS_NONE) + axis_plus = joypad_info.auto_binds[ident_plus].joyaxis; - pressed_minus = abs(drv->axis(joypad_info.joy_idx, axis_minus)); - pressed_plus = abs(drv->axis(joypad_info.joy_idx, axis_plus)); - res = pressed_plus - pressed_minus; + pressed_minus = abs(drv->axis(joypad_info.joy_idx, axis_minus)); + pressed_plus = abs(drv->axis(joypad_info.joy_idx, axis_plus)); + res = pressed_plus - pressed_minus; - if (res == 0) - { - int16_t digital_left = 0; - int16_t digital_right = 0; - uint64_t key_minus = bind_minus->joykey; - uint64_t key_plus = bind_plus->joykey; + if (res == 0) + { + int16_t digital_left = 0; + int16_t digital_right = 0; + uint64_t key_minus = bind_minus->joykey; + uint64_t key_plus = bind_plus->joykey; - if (key_minus == NO_BTN) - key_minus = joypad_info.auto_binds[ident_minus].joykey; - if (key_plus == NO_BTN) - key_plus = joypad_info.auto_binds[ident_plus].joykey; + if (key_minus == NO_BTN) + key_minus = joypad_info.auto_binds[ident_minus].joykey; + if (key_plus == NO_BTN) + key_plus = joypad_info.auto_binds[ident_plus].joykey; - if (drv->button(joypad_info.joy_idx, (uint16_t)key_minus)) - digital_left = -0x7fff; - if (drv->button(joypad_info.joy_idx, (uint16_t)key_plus)) - digital_right = 0x7fff; + if (drv->button(joypad_info.joy_idx, (uint16_t)key_minus)) + digital_left = -0x7fff; + if (drv->button(joypad_info.joy_idx, (uint16_t)key_plus)) + digital_right = 0x7fff; - return digital_right + digital_left; - } - } + return digital_right + digital_left; + } + } - return res; + return res; } /** @@ -1770,24 +1770,24 @@ bool input_joypad_hat_raw(const input_device_driver_t *drv, **/ bool input_mouse_button_raw(unsigned port, unsigned id) { - int16_t res; - rarch_joypad_info_t joypad_info; - settings_t *settings = config_get_ptr(); + int16_t res; + rarch_joypad_info_t joypad_info; + settings_t *settings = config_get_ptr(); - /*ignore axes*/ - if ( id == RETRO_DEVICE_ID_MOUSE_X || id == RETRO_DEVICE_ID_MOUSE_Y ) - return false; + /*ignore axes*/ + if ( id == RETRO_DEVICE_ID_MOUSE_X || id == RETRO_DEVICE_ID_MOUSE_Y ) + return false; - joypad_info.axis_threshold = input_driver_axis_threshold; - joypad_info.joy_idx = settings->uints.input_joypad_map[port]; - joypad_info.auto_binds = input_autoconf_binds[joypad_info.joy_idx]; + joypad_info.axis_threshold = input_driver_axis_threshold; + joypad_info.joy_idx = settings->uints.input_joypad_map[port]; + joypad_info.auto_binds = input_autoconf_binds[joypad_info.joy_idx]; - res = current_input->input_state(current_input_data, - joypad_info, libretro_input_binds, port, RETRO_DEVICE_MOUSE, 0, id); + res = current_input->input_state(current_input_data, + joypad_info, libretro_input_binds, port, RETRO_DEVICE_MOUSE, 0, id); - if (res) - return true; - return false; + if (res) + return true; + return false; } /** @@ -2024,8 +2024,8 @@ bool input_keyboard_line_append(const char *word) unsigned i = 0; unsigned len = (unsigned)strlen(word); char *newbuf = (char*) - realloc(g_keyboard_line->buffer, - g_keyboard_line->size + len*2); + realloc(g_keyboard_line->buffer, + g_keyboard_line->size + len*2); if (!newbuf) return false; @@ -2459,26 +2459,26 @@ void input_config_parse_joy_axis(void *data, const char *prefix, void input_config_parse_mouse_button(void *data, const char *prefix, const char *btn, struct retro_keybind *bind) { - int val; - char str[256]; - char tmp[64]; - char key[64]; - config_file_t *conf = (config_file_t*)data; + int val; + char str[256]; + char tmp[64]; + char key[64]; + config_file_t *conf = (config_file_t*)data; - str[0] = tmp[0] = key[0] = '\0'; + str[0] = tmp[0] = key[0] = '\0'; - fill_pathname_join_delim(str, prefix, btn, - '_', sizeof(str)); - fill_pathname_join_delim(key, str, - "mbtn", '_', sizeof(key)); + fill_pathname_join_delim(str, prefix, btn, + '_', sizeof(str)); + fill_pathname_join_delim(key, str, + "mbtn", '_', sizeof(key)); - if ( bind && config_get_array(conf, key, tmp, sizeof(tmp)) ) - { - bind->mbutton = NO_BTN; + if ( bind && config_get_array(conf, key, tmp, sizeof(tmp)) ) + { + bind->mbutton = NO_BTN; - if ( tmp[0]=='w' ) - { - switch ( tmp[1] ) + if ( tmp[0]=='w' ) + { + switch ( tmp[1] ) { case 'u': bind->mbutton = RETRO_DEVICE_ID_MOUSE_WHEELUP; @@ -2498,30 +2498,30 @@ void input_config_parse_mouse_button(void *data, const char *prefix, } break; } - } - else - { - val = atoi(tmp); - switch ( val ) + } + else + { + val = atoi(tmp); + switch ( val ) { - case 1: + case 1: bind->mbutton = RETRO_DEVICE_ID_MOUSE_LEFT; break; - case 2: + case 2: bind->mbutton = RETRO_DEVICE_ID_MOUSE_RIGHT; break; - case 3: + case 3: bind->mbutton = RETRO_DEVICE_ID_MOUSE_MIDDLE; break; - case 4: + case 4: bind->mbutton = RETRO_DEVICE_ID_MOUSE_BUTTON_4; break; - case 5: + case 5: bind->mbutton = RETRO_DEVICE_ID_MOUSE_BUTTON_5; break; - } - } - } + } + } + } } static void input_config_get_bind_string_joykey( @@ -2604,7 +2604,7 @@ static void input_config_get_bind_string_joyaxis(char *buf, const char *prefix, void input_config_get_bind_string(char *buf, const struct retro_keybind *bind, const struct retro_keybind *auto_bind, size_t size) { - int delim = 0; + int delim = 0; #ifndef RARCH_CONSOLE char key[64]; char keybuf[64]; @@ -2623,7 +2623,7 @@ void input_config_get_bind_string(char *buf, const struct retro_keybind *bind, input_config_get_bind_string_joyaxis(buf, "Auto: ", auto_bind, size); if (*buf) - delim = 1; + delim = 1; #ifndef RARCH_CONSOLE input_keymaps_translate_rk_to_str(bind->key, key, sizeof(key)); @@ -2640,10 +2640,10 @@ void input_config_get_bind_string(char *buf, const struct retro_keybind *bind, } #endif - if ( bind->mbutton != NO_BTN ) - { - int tag = 0; - switch ( bind->mbutton ) + if ( bind->mbutton != NO_BTN ) + { + int tag = 0; + switch ( bind->mbutton ) { case RETRO_DEVICE_ID_MOUSE_LEFT: tag = MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_LEFT; @@ -2674,17 +2674,17 @@ void input_config_get_bind_string(char *buf, const struct retro_keybind *bind, break; } /* switch ( bind->mbutton ) */ - if (tag != 0) - { - if (delim) - strlcat(buf, ", ", size); - strlcat(buf, msg_hash_to_str((enum msg_hash_enums)tag), size ); - } - } + if (tag != 0) + { + if (delim) + strlcat(buf, ", ", size); + strlcat(buf, msg_hash_to_str((enum msg_hash_enums)tag), size ); + } + } /*completely empty?*/ if ( *buf == '\0' ) - strlcat(buf, "---", size); + strlcat(buf, "---", size); } const char *input_config_get_device_name(unsigned port) @@ -2782,7 +2782,7 @@ void input_config_reset(void) for (i = 1; i < MAX_USERS; i++) memcpy(input_config_binds[i], retro_keybinds_rest, sizeof(retro_keybinds_rest)); - + for (i = 0; i < MAX_USERS; i++) { input_config_vid[i] = 0; From a78f72ccd3fb83b2b9326c9def708d24537da63c Mon Sep 17 00:00:00 2001 From: orbea Date: Sun, 26 Nov 2017 18:23:10 -0800 Subject: [PATCH 051/394] qb: Used explicit word splitting to silence shellcheck warnings. --- qb/qb.libs.sh | 29 +++++++++++++---------------- 1 file changed, 13 insertions(+), 16 deletions(-) diff --git a/qb/qb.libs.sh b/qb/qb.libs.sh index 1564ec7635..0391a3bbc5 100644 --- a/qb/qb.libs.sh +++ b/qb/qb.libs.sh @@ -44,28 +44,25 @@ check_lib() # $1 = language $2 = HAVE_$2 $3 = lib $4 = function in lib $5 = ECHOBUF="Checking existence of ${3% }" printf %s\\n 'int main(void) { return 0; }' > "$TEMP_CODE" fi + + val="$2" + lib="$3" + error="${7:-}" answer='no' - "$COMPILER" -o \ - "$TEMP_EXE" \ - "$TEMP_CODE" \ - $INCLUDE_DIRS \ - $LIBRARY_DIRS \ - $(printf %s "$5") \ - $CFLAGS \ - $LDFLAGS \ - $(printf %s "$3") >>config.log 2>&1 && answer='yes' - eval "HAVE_$2=\"$answer\"" + eval "set -- $INCLUDE_DIRS $LIBRARY_DIRS $5 $CFLAGS $LDFLAGS $3" + "$COMPILER" -o "$TEMP_EXE" "$TEMP_CODE" "$@" >>config.log 2>&1 && answer='yes' + eval "HAVE_$val=\"$answer\"" printf %s\\n "$ECHOBUF ... $answer" rm -f -- "$TEMP_CODE" "$TEMP_EXE" if [ "$answer" = 'no' ]; then - [ "$7" ] && die 1 "$7" + [ "$error" ] && die 1 "$error" [ "$tmpval" = 'yes' ] && { - die 1 "Forced to build with library $3, but cannot locate. Exiting ..." + die 1 "Forced to build with library $lib, but cannot locate. Exiting ..." } else - eval "${2}_LIBS=\"$3\"" - PKG_CONF_USED="$PKG_CONF_USED $2" + eval "${val}_LIBS=\"$lib\"" + PKG_CONF_USED="$PKG_CONF_USED $val" fi return 0 @@ -228,9 +225,9 @@ create_config_make() case "$PKG_CONF_USED" in *$1*) - FLAGS="$(eval "printf %s \"\$$1_CFLAGS\"")" + FLAG="$(eval "printf %s \"\$$1_CFLAGS\"")" LIBS="$(eval "printf %s \"\$$1_LIBS\"")" - [ "${FLAGS}" ] && printf %s\\n "$1_CFLAGS = ${FLAGS%"${FLAGS##*[! ]}"}" + [ "${FLAG}" ] && printf %s\\n "$1_CFLAGS = ${FLAG%"${FLAG##*[! ]}"}" [ "${LIBS}" ] && printf %s\\n "$1_LIBS = ${LIBS%"${LIBS##*[! ]}"}" ;; esac From 311b7862795492cf44ef276f43985e62e0cc3f51 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 27 Nov 2017 04:34:45 +0100 Subject: [PATCH 052/394] Silence Coverity warning --- network/netplay/netplay_frontend.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/network/netplay/netplay_frontend.c b/network/netplay/netplay_frontend.c index b393865a7a..86c8234849 100644 --- a/network/netplay/netplay_frontend.c +++ b/network/netplay/netplay_frontend.c @@ -644,10 +644,16 @@ static void netplay_announce(void) #endif task_push_http_post_transfer(url, buf, true, NULL, netplay_announce_cb, NULL); - free(username); - free(corename); - free(gamename); - free(coreversion); + if (username) + free(username); + if (corename) + free(corename); + if (gamename) + free(gamename); + if (coreversion) + free(coreversion); + if (frontend_ident) + free(frontend_ident); } int16_t input_state_net(unsigned port, unsigned device, From 2dc9c8ead7f1c789c141e9c481ff5336eed15b7e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 27 Nov 2017 04:43:13 +0100 Subject: [PATCH 053/394] Comment out unused code --- menu/drivers/rgui.c | 55 +++++++++++++++++++++++++-------------------- 1 file changed, 31 insertions(+), 24 deletions(-) diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index 0839610c25..0901e15beb 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -83,30 +83,6 @@ static uint16_t argb32_to_rgba4444(uint32_t col) } #endif -static void rgui_copy_glyph(uint8_t *glyph, const uint8_t *buf) -{ - int x, y; - - if (!glyph) - return; - - for (y = 0; y < FONT_HEIGHT; y++) - { - for (x = 0; x < FONT_WIDTH; x++) - { - uint32_t col = - ((uint32_t)buf[3 * (-y * 256 + x) + 0] << 0) | - ((uint32_t)buf[3 * (-y * 256 + x) + 1] << 8) | - ((uint32_t)buf[3 * (-y * 256 + x) + 2] << 16); - - uint8_t rem = 1 << ((x + y * FONT_WIDTH) & 7); - unsigned offset = (x + y * FONT_WIDTH) >> 3; - - if (col != 0xff) - glyph[offset] |= rem; - } - } -} static uint16_t rgui_gray_filler(unsigned x, unsigned y) { @@ -190,6 +166,32 @@ static void blit_line(int x, int y, } } +#if 0 +static void rgui_copy_glyph(uint8_t *glyph, const uint8_t *buf) +{ + int x, y; + + if (!glyph) + return; + + for (y = 0; y < FONT_HEIGHT; y++) + { + for (x = 0; x < FONT_WIDTH; x++) + { + uint32_t col = + ((uint32_t)buf[3 * (-y * 256 + x) + 0] << 0) | + ((uint32_t)buf[3 * (-y * 256 + x) + 1] << 8) | + ((uint32_t)buf[3 * (-y * 256 + x) + 2] << 16); + + uint8_t rem = 1 << ((x + y * FONT_WIDTH) & 7); + unsigned offset = (x + y * FONT_WIDTH) >> 3; + + if (col != 0xff) + glyph[offset] |= rem; + } + } +} + static bool init_font(menu_handle_t *menu, const uint8_t *font_bmp_buf) { unsigned i; @@ -213,17 +215,22 @@ static bool init_font(menu_handle_t *menu, const uint8_t *font_bmp_buf) return true; } +#endif static bool rguidisp_init_font(menu_handle_t *menu) { +#if 0 const uint8_t *font_bmp_buf = NULL; +#endif const uint8_t *font_bin_buf = bitmap_bin; if (!menu) return false; +#if 0 if (font_bmp_buf) return init_font(menu, font_bmp_buf); +#endif menu_display_set_font_framebuffer(font_bin_buf); From 09c39a91d777567d15fa230155a646ad4c880770 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 27 Nov 2017 04:49:21 +0100 Subject: [PATCH 054/394] Cleanups --- menu/drivers/xmb.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 6301b86cd1..0392da6f34 100755 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -2243,15 +2243,17 @@ static uintptr_t xmb_icon_get_id(xmb_handle_t *xmb, } #ifdef HAVE_CHEEVOS - if ((type >= MENU_SETTINGS_CHEEVOS_START) && - (type < MENU_SETTINGS_NETPLAY_ROOMS_START)) - { + if ( + (type >= MENU_SETTINGS_CHEEVOS_START) && + (type < MENU_SETTINGS_NETPLAY_ROOMS_START) + ) + { int new_id = type - MENU_SETTINGS_CHEEVOS_START; - if ( get_badge_texture(new_id) != 0 ) - return get_badge_texture( new_id ); - else - return xmb->textures.list[XMB_TEXTURE_SUBSETTING]; // Should be replaced with placeholder badge icon. - } + if (get_badge_texture(new_id) != 0) + return get_badge_texture(new_id); + /* Should be replaced with placeholder badge icon. */ + return xmb->textures.list[XMB_TEXTURE_SUBSETTING]; + } #endif return xmb->textures.list[XMB_TEXTURE_SUBSETTING]; From 768b1b433caa266a1a9f642cff482e312c8c6fc2 Mon Sep 17 00:00:00 2001 From: orbea Date: Sun, 26 Nov 2017 20:14:06 -0800 Subject: [PATCH 055/394] libretro-common: Silence redefined warning. --- libretro-common/file/nbio/nbio_linux.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libretro-common/file/nbio/nbio_linux.c b/libretro-common/file/nbio/nbio_linux.c index 7b40551194..3395a2cef7 100644 --- a/libretro-common/file/nbio/nbio_linux.c +++ b/libretro-common/file/nbio/nbio_linux.c @@ -24,7 +24,9 @@ #if defined(__linux__) +#ifndef _GNU_SOURCE #define _GNU_SOURCE +#endif #include #include #include From 9f83175182e44d3d31d0c6503a70561c86183cfd Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 27 Nov 2017 06:47:08 +0100 Subject: [PATCH 056/394] Add Automatically Load Content To Playlist feature --- config.def.h | 6 ++++++ configuration.c | 1 + configuration.h | 2 ++ intl/msg_hash_chs.h | 4 ++++ intl/msg_hash_cht.h | 4 ++++ intl/msg_hash_de.h | 4 ++++ intl/msg_hash_eo.h | 4 ++++ intl/msg_hash_fr.h | 4 ++++ intl/msg_hash_it.h | 4 ++++ intl/msg_hash_ja.h | 4 ++++ intl/msg_hash_ko.h | 4 ++++ intl/msg_hash_lbl.h | 2 ++ intl/msg_hash_nl.h | 4 ++++ intl/msg_hash_pt_br.h | 4 ++++ intl/msg_hash_pt_pt.h | 4 ++++ intl/msg_hash_ru.h | 4 ++++ intl/msg_hash_us.h | 4 ++++ intl/msg_hash_vn.h | 4 ++++ menu/cbs/menu_cbs_ok.c | 21 ++++++++++++++++++++- menu/cbs/menu_cbs_scan.c | 2 +- menu/cbs/menu_cbs_sublabel.c | 4 ++++ menu/menu_displaylist.c | 3 +++ menu/menu_setting.c | 17 +++++++++++++++++ msg_hash.h | 1 + 24 files changed, 113 insertions(+), 2 deletions(-) diff --git a/config.def.h b/config.def.h index cbbffb0ffb..c3fb49f6f6 100644 --- a/config.def.h +++ b/config.def.h @@ -293,6 +293,12 @@ static bool xmb_show_add = true; #endif #endif +#if defined(HAVE_LIBRETRODB) && !defined(RARCH_CONSOLE) +static bool automatically_add_content_to_playlist = true; +#else +static bool automatically_add_content_to_playlist = false; +#endif + static float menu_framebuffer_opacity = 0.900; static float menu_wallpaper_opacity = 0.300; diff --git a/configuration.c b/configuration.c index 7f2fa1fc91..14b8d82c0a 100644 --- a/configuration.c +++ b/configuration.c @@ -1114,6 +1114,7 @@ static struct config_bool_setting *populate_settings_bool(settings_t *settings, unsigned count = 0; global_t *global = global_get_ptr(); + SETTING_BOOL("automatically_add_content_to_playlist", &settings->bools.automatically_add_content_to_playlist, true, automatically_add_content_to_playlist, false); SETTING_BOOL("ui_companion_start_on_boot", &settings->bools.ui_companion_start_on_boot, true, ui_companion_start_on_boot, false); SETTING_BOOL("ui_companion_enable", &settings->bools.ui_companion_enable, true, ui_companion_enable, false); SETTING_BOOL("video_gpu_record", &settings->bools.video_gpu_record, true, gpu_record, false); diff --git a/configuration.h b/configuration.h index 7dd74b9282..31dbeebff3 100644 --- a/configuration.h +++ b/configuration.h @@ -243,6 +243,8 @@ typedef struct settings bool ssh_enable; bool samba_enable; bool bluetooth_enable; + + bool automatically_add_content_to_playlist; } bools; struct diff --git a/intl/msg_hash_chs.h b/intl/msg_hash_chs.h index d9d5f633c1..63aa35cfb5 100644 --- a/intl/msg_hash_chs.h +++ b/intl/msg_hash_chs.h @@ -3201,3 +3201,7 @@ MSG_HASH(MSG_INPUT_KIOSK_MODE_PASSWORD_OK, "Password correct.") MSG_HASH(MSG_INPUT_KIOSK_MODE_PASSWORD_NOK, "Password incorrect.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Automatically add content to playlist") +MSG_HASH(MENU_ENUM_SUBLABEL_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Automatically scans loaded content so they appear inside playlists.") diff --git a/intl/msg_hash_cht.h b/intl/msg_hash_cht.h index 3074dc5f32..a5be0c3d3a 100644 --- a/intl/msg_hash_cht.h +++ b/intl/msg_hash_cht.h @@ -3201,3 +3201,7 @@ MSG_HASH(MSG_INPUT_KIOSK_MODE_PASSWORD_OK, "Password correct.") MSG_HASH(MSG_INPUT_KIOSK_MODE_PASSWORD_NOK, "Password incorrect.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Automatically add content to playlist") +MSG_HASH(MENU_ENUM_SUBLABEL_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Automatically scans loaded content so they appear inside playlists.") diff --git a/intl/msg_hash_de.h b/intl/msg_hash_de.h index e5bf9687e8..9e03d9f147 100644 --- a/intl/msg_hash_de.h +++ b/intl/msg_hash_de.h @@ -3311,3 +3311,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_MESSAGE_COLOR_BLUE, "Blau-Anteil der Bildschirmmeldungen") MSG_HASH(MENU_ENUM_LABEL_VALUE_FRAMECOUNT_SHOW, "Zeige die aktuelle Anzahl an Einzelbildern an") +MSG_HASH(MENU_ENUM_LABEL_VALUE_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Automatically add content to playlist") +MSG_HASH(MENU_ENUM_SUBLABEL_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Automatically scans loaded content so they appear inside playlists.") diff --git a/intl/msg_hash_eo.h b/intl/msg_hash_eo.h index 3f16073e95..133ef8253d 100644 --- a/intl/msg_hash_eo.h +++ b/intl/msg_hash_eo.h @@ -3064,3 +3064,7 @@ MSG_HASH(MSG_INPUT_KIOSK_MODE_PASSWORD_OK, "Password correct.") MSG_HASH(MSG_INPUT_KIOSK_MODE_PASSWORD_NOK, "Password incorrect.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Automatically add content to playlist") +MSG_HASH(MENU_ENUM_SUBLABEL_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Automatically scans loaded content so they appear inside playlists.") diff --git a/intl/msg_hash_fr.h b/intl/msg_hash_fr.h index 1920e13ad8..d27634fae8 100644 --- a/intl/msg_hash_fr.h +++ b/intl/msg_hash_fr.h @@ -3233,3 +3233,7 @@ MSG_HASH(MSG_INPUT_KIOSK_MODE_PASSWORD_OK, "Password correct.") MSG_HASH(MSG_INPUT_KIOSK_MODE_PASSWORD_NOK, "Password incorrect.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Automatically add content to playlist") +MSG_HASH(MENU_ENUM_SUBLABEL_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Automatically scans loaded content so they appear inside playlists.") diff --git a/intl/msg_hash_it.h b/intl/msg_hash_it.h index 22232ed4f4..b403f7bffd 100644 --- a/intl/msg_hash_it.h +++ b/intl/msg_hash_it.h @@ -3291,3 +3291,7 @@ MSG_HASH(MSG_INPUT_KIOSK_MODE_PASSWORD_OK, "Password corretta.") MSG_HASH(MSG_INPUT_KIOSK_MODE_PASSWORD_NOK, "Password non corretta.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Automatically add content to playlist") +MSG_HASH(MENU_ENUM_SUBLABEL_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Automatically scans loaded content so they appear inside playlists.") diff --git a/intl/msg_hash_ja.h b/intl/msg_hash_ja.h index ebae8a65ed..6ccf4feb78 100644 --- a/intl/msg_hash_ja.h +++ b/intl/msg_hash_ja.h @@ -3243,3 +3243,7 @@ MSG_HASH(MSG_GAME_REMAP_FILE_LOADED, "ゲームの優先ファイルをロードしました。") MSG_HASH(MSG_CORE_REMAP_FILE_LOADED, "コアの優先ファイルをロードしました。") +MSG_HASH(MENU_ENUM_LABEL_VALUE_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Automatically add content to playlist") +MSG_HASH(MENU_ENUM_SUBLABEL_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Automatically scans loaded content so they appear inside playlists.") diff --git a/intl/msg_hash_ko.h b/intl/msg_hash_ko.h index 9a22edd4c8..86d3798887 100644 --- a/intl/msg_hash_ko.h +++ b/intl/msg_hash_ko.h @@ -3196,3 +3196,7 @@ MSG_HASH(MSG_INPUT_KIOSK_MODE_PASSWORD_OK, "Password correct.") MSG_HASH(MSG_INPUT_KIOSK_MODE_PASSWORD_NOK, "Password incorrect.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Automatically add content to playlist") +MSG_HASH(MENU_ENUM_SUBLABEL_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Automatically scans loaded content so they appear inside playlists.") diff --git a/intl/msg_hash_lbl.h b/intl/msg_hash_lbl.h index 32cd47b828..a097ee5c90 100644 --- a/intl/msg_hash_lbl.h +++ b/intl/msg_hash_lbl.h @@ -1375,3 +1375,5 @@ MSG_HASH(MENU_ENUM_LABEL_VIDEO_MESSAGE_COLOR_BLUE, "video_msg_color_blue") MSG_HASH(MENU_ENUM_LABEL_FRAMECOUNT_SHOW, "framecount_show") +MSG_HASH(MENU_ENUM_LABEL_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "automatically_add_content_to_playlist") diff --git a/intl/msg_hash_nl.h b/intl/msg_hash_nl.h index dcd21e2962..6040e5470e 100644 --- a/intl/msg_hash_nl.h +++ b/intl/msg_hash_nl.h @@ -3064,3 +3064,7 @@ MSG_HASH(MSG_INPUT_KIOSK_MODE_PASSWORD_OK, "Wachtwoord correct.") MSG_HASH(MSG_INPUT_KIOSK_MODE_PASSWORD_NOK, "Verkeerde wachtwoord.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Automatically add content to playlist") +MSG_HASH(MENU_ENUM_SUBLABEL_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Automatically scans loaded content so they appear inside playlists.") diff --git a/intl/msg_hash_pt_br.h b/intl/msg_hash_pt_br.h index 2603504428..21b574287b 100644 --- a/intl/msg_hash_pt_br.h +++ b/intl/msg_hash_pt_br.h @@ -4181,3 +4181,7 @@ MSG_HASH(MSG_INPUT_KIOSK_MODE_PASSWORD_OK, MSG_HASH(MSG_INPUT_KIOSK_MODE_PASSWORD_NOK, "Password incorrect." ) +MSG_HASH(MENU_ENUM_LABEL_VALUE_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Automatically add content to playlist") +MSG_HASH(MENU_ENUM_SUBLABEL_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Automatically scans loaded content so they appear inside playlists.") diff --git a/intl/msg_hash_pt_pt.h b/intl/msg_hash_pt_pt.h index 9e6cb8641d..757e1d4058 100644 --- a/intl/msg_hash_pt_pt.h +++ b/intl/msg_hash_pt_pt.h @@ -3171,3 +3171,7 @@ MSG_HASH(MSG_INPUT_KIOSK_MODE_PASSWORD_OK, "Password correct.") MSG_HASH(MSG_INPUT_KIOSK_MODE_PASSWORD_NOK, "Password incorrect.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Automatically add content to playlist") +MSG_HASH(MENU_ENUM_SUBLABEL_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Automatically scans loaded content so they appear inside playlists.") diff --git a/intl/msg_hash_ru.h b/intl/msg_hash_ru.h index 84aec3c7ba..5e11949ec3 100644 --- a/intl/msg_hash_ru.h +++ b/intl/msg_hash_ru.h @@ -3254,3 +3254,7 @@ MSG_HASH(MSG_INPUT_KIOSK_MODE_PASSWORD_OK, "Пароль верен.") MSG_HASH(MSG_INPUT_KIOSK_MODE_PASSWORD_NOK, "Пароль неверен.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Automatically add content to playlist") +MSG_HASH(MENU_ENUM_SUBLABEL_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Automatically scans loaded content so they appear inside playlists.") diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index f877546905..c3ec369eb3 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -3333,3 +3333,7 @@ MSG_HASH(MSG_GAME_REMAP_FILE_LOADED, "Game remap file loaded.") MSG_HASH(MSG_CORE_REMAP_FILE_LOADED, "Core remap file loaded.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Automatically add content to playlist") +MSG_HASH(MENU_ENUM_SUBLABEL_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Automatically scans loaded content so they appear inside playlists.") diff --git a/intl/msg_hash_vn.h b/intl/msg_hash_vn.h index efea88ed20..41a38b6e28 100644 --- a/intl/msg_hash_vn.h +++ b/intl/msg_hash_vn.h @@ -3225,3 +3225,7 @@ MSG_HASH(MSG_INPUT_KIOSK_MODE_PASSWORD_OK, "Password correct.") MSG_HASH(MSG_INPUT_KIOSK_MODE_PASSWORD_NOK, "Password incorrect.") +MSG_HASH(MENU_ENUM_LABEL_VALUE_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Automatically add content to playlist") +MSG_HASH(MENU_ENUM_SUBLABEL_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + "Automatically scans loaded content so they appear inside playlists.") diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 95e5d0d0c6..876258f0f8 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -1032,6 +1032,23 @@ static bool menu_content_find_first_core(menu_content_ctx_defer_info_t *def_info return true; } +#ifdef HAVE_LIBRETRODB +void handle_dbscan_finished(void *task_data, void *user_data, const char *err); +#endif + +static void content_add_to_playlist(const char *path) +{ +#ifdef HAVE_LIBRETRODB + settings_t *settings = config_get_ptr(); + if (!settings || !settings->bools.automatically_add_content_to_playlist) + return; + task_push_dbscan( + settings->paths.directory_playlist, + settings->paths.path_content_database, + path, false, handle_dbscan_finished); +#endif +} + static int file_load_with_detect_core_wrapper( enum msg_hash_enums enum_label_idx, enum msg_hash_enums enum_idx, @@ -1118,6 +1135,7 @@ static int file_load_with_detect_core_wrapper( free(new_core_path); return -1; } + content_add_to_playlist(def_info.s); ret = 0; break; @@ -2372,9 +2390,10 @@ static int action_ok_file_load_detect_core(const char *path, if (!task_push_load_content_with_new_core_from_menu( path, detect_content_path, &content_info, - CORE_TYPE_FFMPEG, + CORE_TYPE_PLAIN, NULL, NULL)) return -1; + content_add_to_playlist(detect_content_path); return 0; } diff --git a/menu/cbs/menu_cbs_scan.c b/menu/cbs/menu_cbs_scan.c index 213b6b8ad1..8e0168fc86 100644 --- a/menu/cbs/menu_cbs_scan.c +++ b/menu/cbs/menu_cbs_scan.c @@ -37,7 +37,7 @@ #endif #ifdef HAVE_LIBRETRODB -static void handle_dbscan_finished(void *task_data, void *user_data, const char *err) +void handle_dbscan_finished(void *task_data, void *user_data, const char *err) { menu_ctx_environment_t menu_environ; menu_environ.type = MENU_ENVIRON_RESET_HORIZONTAL_LIST; diff --git a/menu/cbs/menu_cbs_sublabel.c b/menu/cbs/menu_cbs_sublabel.c index 06170be390..2dd471d3cc 100644 --- a/menu/cbs/menu_cbs_sublabel.c +++ b/menu/cbs/menu_cbs_sublabel.c @@ -44,6 +44,7 @@ return 0; \ } +default_sublabel_macro(action_bind_sublabel_automatically_add_content_to_playlist, MENU_ENUM_SUBLABEL_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST) default_sublabel_macro(action_bind_sublabel_driver_settings_list, MENU_ENUM_SUBLABEL_DRIVER_SETTINGS) default_sublabel_macro(action_bind_sublabel_retro_achievements_settings_list, MENU_ENUM_SUBLABEL_RETRO_ACHIEVEMENTS_SETTINGS) default_sublabel_macro(action_bind_sublabel_saving_settings_list, MENU_ENUM_SUBLABEL_SAVING_SETTINGS) @@ -1376,6 +1377,9 @@ int menu_cbs_init_bind_sublabel(menu_file_list_cbs_t *cbs, case MENU_ENUM_LABEL_CORE_SETTINGS: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_core_settings_list); break; + case MENU_ENUM_LABEL_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST: + BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_automatically_add_content_to_playlist); + break; case MENU_ENUM_LABEL_DRIVER_SETTINGS: BIND_ACTION_SUBLABEL(cbs, action_bind_sublabel_driver_settings_list); break; diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 61d3ccc919..2fddc1669c 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -5304,6 +5304,9 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) menu_displaylist_parse_settings_enum(menu, info, MENU_ENUM_LABEL_FILTER_BY_CURRENT_CORE, PARSE_ONLY_BOOL, false); + menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + PARSE_ONLY_BOOL, false); info->need_refresh = true; info->need_push = true; break; diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 17e388340b..22e36c4b68 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -5985,6 +5985,23 @@ static bool setting_append_list( START_SUB_GROUP(list, list_info, "State", &group_info, &subgroup_info, parent_group); +#ifdef HAVE_LIBRETRODB + CONFIG_BOOL( + list, list_info, + &settings->bools.automatically_add_content_to_playlist, + MENU_ENUM_LABEL_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + MENU_ENUM_LABEL_VALUE_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, + true, + MENU_ENUM_LABEL_VALUE_OFF, + MENU_ENUM_LABEL_VALUE_ON, + &group_info, + &subgroup_info, + parent_group, + general_write_handler, + general_read_handler, + SD_FLAG_NONE); +#endif + CONFIG_BOOL( list, list_info, &settings->bools.multimedia_builtin_mediaplayer_enable, diff --git a/msg_hash.h b/msg_hash.h index 0cce4dfd36..daffdcfc92 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -1023,6 +1023,7 @@ enum msg_hash_enums MENU_LABEL(INFORMATION), MENU_LABEL(INFORMATION_LIST), MENU_LABEL(USE_BUILTIN_PLAYER), + MENU_LABEL(AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST), MENU_LABEL(NETPLAY_SETTINGS), MENU_LABEL(CONTENT_SETTINGS), MENU_LABEL(LOAD_CONTENT_LIST), From d75c187c5b68a3a38c67ab5e469d9e5ba91f9a01 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 27 Nov 2017 07:04:52 +0100 Subject: [PATCH 057/394] Don't show 'Scanning of Directory Finished' if we are scanning a file instead --- intl/msg_hash_chs.h | 2 ++ intl/msg_hash_cht.h | 2 ++ intl/msg_hash_de.h | 2 ++ intl/msg_hash_eo.h | 2 ++ intl/msg_hash_fr.h | 2 ++ intl/msg_hash_it.h | 2 ++ intl/msg_hash_ja.h | 2 ++ intl/msg_hash_ko.h | 2 ++ intl/msg_hash_nl.h | 2 ++ intl/msg_hash_pt_br.h | 2 ++ intl/msg_hash_pt_pt.h | 2 ++ intl/msg_hash_ru.h | 2 ++ intl/msg_hash_us.h | 2 ++ intl/msg_hash_vn.h | 2 ++ msg_hash.h | 1 + tasks/task_database.c | 11 ++++++++--- 16 files changed, 37 insertions(+), 3 deletions(-) diff --git a/intl/msg_hash_chs.h b/intl/msg_hash_chs.h index 63aa35cfb5..14bb988f19 100644 --- a/intl/msg_hash_chs.h +++ b/intl/msg_hash_chs.h @@ -3205,3 +3205,5 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, "Automatically add content to playlist") MSG_HASH(MENU_ENUM_SUBLABEL_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, "Automatically scans loaded content so they appear inside playlists.") +MSG_HASH(MSG_SCANNING_OF_FILE_FINISHED, + "Scanning of file finished") diff --git a/intl/msg_hash_cht.h b/intl/msg_hash_cht.h index a5be0c3d3a..5a70c2d652 100644 --- a/intl/msg_hash_cht.h +++ b/intl/msg_hash_cht.h @@ -3205,3 +3205,5 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, "Automatically add content to playlist") MSG_HASH(MENU_ENUM_SUBLABEL_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, "Automatically scans loaded content so they appear inside playlists.") +MSG_HASH(MSG_SCANNING_OF_FILE_FINISHED, + "Scanning of file finished") diff --git a/intl/msg_hash_de.h b/intl/msg_hash_de.h index 9e03d9f147..26ac4331ac 100644 --- a/intl/msg_hash_de.h +++ b/intl/msg_hash_de.h @@ -3315,3 +3315,5 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, "Automatically add content to playlist") MSG_HASH(MENU_ENUM_SUBLABEL_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, "Automatically scans loaded content so they appear inside playlists.") +MSG_HASH(MSG_SCANNING_OF_FILE_FINISHED, + "Scanning of file finished") diff --git a/intl/msg_hash_eo.h b/intl/msg_hash_eo.h index 133ef8253d..d5d1d0258b 100644 --- a/intl/msg_hash_eo.h +++ b/intl/msg_hash_eo.h @@ -3068,3 +3068,5 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, "Automatically add content to playlist") MSG_HASH(MENU_ENUM_SUBLABEL_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, "Automatically scans loaded content so they appear inside playlists.") +MSG_HASH(MSG_SCANNING_OF_FILE_FINISHED, + "Scanning of file finished") diff --git a/intl/msg_hash_fr.h b/intl/msg_hash_fr.h index d27634fae8..7fe0883274 100644 --- a/intl/msg_hash_fr.h +++ b/intl/msg_hash_fr.h @@ -3237,3 +3237,5 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, "Automatically add content to playlist") MSG_HASH(MENU_ENUM_SUBLABEL_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, "Automatically scans loaded content so they appear inside playlists.") +MSG_HASH(MSG_SCANNING_OF_FILE_FINISHED, + "Scanning of file finished") diff --git a/intl/msg_hash_it.h b/intl/msg_hash_it.h index b403f7bffd..dfa0290a1e 100644 --- a/intl/msg_hash_it.h +++ b/intl/msg_hash_it.h @@ -3295,3 +3295,5 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, "Automatically add content to playlist") MSG_HASH(MENU_ENUM_SUBLABEL_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, "Automatically scans loaded content so they appear inside playlists.") +MSG_HASH(MSG_SCANNING_OF_FILE_FINISHED, + "Scanning of file finished") diff --git a/intl/msg_hash_ja.h b/intl/msg_hash_ja.h index 6ccf4feb78..7d502db12d 100644 --- a/intl/msg_hash_ja.h +++ b/intl/msg_hash_ja.h @@ -3247,3 +3247,5 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, "Automatically add content to playlist") MSG_HASH(MENU_ENUM_SUBLABEL_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, "Automatically scans loaded content so they appear inside playlists.") +MSG_HASH(MSG_SCANNING_OF_FILE_FINISHED, + "Scanning of file finished") diff --git a/intl/msg_hash_ko.h b/intl/msg_hash_ko.h index 86d3798887..8b6daaccfd 100644 --- a/intl/msg_hash_ko.h +++ b/intl/msg_hash_ko.h @@ -3200,3 +3200,5 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, "Automatically add content to playlist") MSG_HASH(MENU_ENUM_SUBLABEL_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, "Automatically scans loaded content so they appear inside playlists.") +MSG_HASH(MSG_SCANNING_OF_FILE_FINISHED, + "Scanning of file finished") diff --git a/intl/msg_hash_nl.h b/intl/msg_hash_nl.h index 6040e5470e..f912f35260 100644 --- a/intl/msg_hash_nl.h +++ b/intl/msg_hash_nl.h @@ -3068,3 +3068,5 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, "Automatically add content to playlist") MSG_HASH(MENU_ENUM_SUBLABEL_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, "Automatically scans loaded content so they appear inside playlists.") +MSG_HASH(MSG_SCANNING_OF_FILE_FINISHED, + "Scanning of file finished") diff --git a/intl/msg_hash_pt_br.h b/intl/msg_hash_pt_br.h index 21b574287b..376860a968 100644 --- a/intl/msg_hash_pt_br.h +++ b/intl/msg_hash_pt_br.h @@ -4185,3 +4185,5 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, "Automatically add content to playlist") MSG_HASH(MENU_ENUM_SUBLABEL_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, "Automatically scans loaded content so they appear inside playlists.") +MSG_HASH(MSG_SCANNING_OF_FILE_FINISHED, + "Scanning of file finished") diff --git a/intl/msg_hash_pt_pt.h b/intl/msg_hash_pt_pt.h index 757e1d4058..b48e9717cd 100644 --- a/intl/msg_hash_pt_pt.h +++ b/intl/msg_hash_pt_pt.h @@ -3175,3 +3175,5 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, "Automatically add content to playlist") MSG_HASH(MENU_ENUM_SUBLABEL_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, "Automatically scans loaded content so they appear inside playlists.") +MSG_HASH(MSG_SCANNING_OF_FILE_FINISHED, + "Scanning of file finished") diff --git a/intl/msg_hash_ru.h b/intl/msg_hash_ru.h index 5e11949ec3..25d792c7eb 100644 --- a/intl/msg_hash_ru.h +++ b/intl/msg_hash_ru.h @@ -3258,3 +3258,5 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, "Automatically add content to playlist") MSG_HASH(MENU_ENUM_SUBLABEL_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, "Automatically scans loaded content so they appear inside playlists.") +MSG_HASH(MSG_SCANNING_OF_FILE_FINISHED, + "Scanning of file finished") diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index c3ec369eb3..5fb03ee34b 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -3337,3 +3337,5 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, "Automatically add content to playlist") MSG_HASH(MENU_ENUM_SUBLABEL_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, "Automatically scans loaded content so they appear inside playlists.") +MSG_HASH(MSG_SCANNING_OF_FILE_FINISHED, + "Scanning of file finished") diff --git a/intl/msg_hash_vn.h b/intl/msg_hash_vn.h index 41a38b6e28..8be07e4d75 100644 --- a/intl/msg_hash_vn.h +++ b/intl/msg_hash_vn.h @@ -3229,3 +3229,5 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, "Automatically add content to playlist") MSG_HASH(MENU_ENUM_SUBLABEL_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, "Automatically scans loaded content so they appear inside playlists.") +MSG_HASH(MSG_SCANNING_OF_FILE_FINISHED, + "Scanning of file finished") diff --git a/msg_hash.h b/msg_hash.h index daffdcfc92..fdd00470e1 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -357,6 +357,7 @@ enum msg_hash_enums MSG_PREPARING_FOR_CONTENT_SCAN, MSG_SCANNING, MSG_SCANNING_OF_DIRECTORY_FINISHED, + MSG_SCANNING_OF_FILE_FINISHED, MSG_LOADED_STATE_FROM_SLOT, MSG_LOADED_STATE_FROM_SLOT_AUTO, MSG_REMOVING_TEMPORARY_CONTENT_FILE, diff --git a/tasks/task_database.c b/tasks/task_database.c index ddb079077d..afe42dd83e 100644 --- a/tasks/task_database.c +++ b/tasks/task_database.c @@ -1254,9 +1254,14 @@ static void task_database_handler(retro_task_t *task) } else { - runloop_msg_queue_push( - msg_hash_to_str(MSG_SCANNING_OF_DIRECTORY_FINISHED), - 0, 180, true); + if (db->is_directory) + runloop_msg_queue_push( + msg_hash_to_str(MSG_SCANNING_OF_DIRECTORY_FINISHED), + 0, 180, true); + else + runloop_msg_queue_push( + msg_hash_to_str(MSG_SCANNING_OF_FILE_FINISHED), + 0, 180, true); goto task_finished; } break; From 70769e435cbd54f3206c0e6c3c9650393923673b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 27 Nov 2017 07:23:43 +0100 Subject: [PATCH 058/394] Add another edge case --- menu/cbs/menu_cbs_ok.c | 1 + 1 file changed, 1 insertion(+) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 876258f0f8..9293256aaa 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -1388,6 +1388,7 @@ static int default_action_ok_load_content_with_core_from_menu(const char *_path, content_info.environ_get = NULL; if (!task_push_load_content_with_core_from_menu(_path, &content_info, (enum rarch_core_type)_type, NULL, NULL)) return -1; + content_add_to_playlist(_path); return 0; } From fc9943476c1465047e240f522a8c9167b2d12021 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 27 Nov 2017 07:25:01 +0100 Subject: [PATCH 059/394] Add another edge case --- menu/cbs/menu_cbs_ok.c | 1 + 1 file changed, 1 insertion(+) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 9293256aaa..dedf26bd8e 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -2297,6 +2297,7 @@ static int action_ok_load_core_deferred(const char *path, CORE_TYPE_PLAIN, NULL, NULL)) return -1; + content_add_to_playlist(path); return 0; } From e06290a06c79d2311a195f185a8ace42d2e84898 Mon Sep 17 00:00:00 2001 From: David Walters Date: Mon, 27 Nov 2017 12:51:06 +0000 Subject: [PATCH 060/394] updated winraw driver for new lightgun/mouse binding api --- input/drivers/winraw_input.c | 1620 ++++++++++++++++++---------------- 1 file changed, 857 insertions(+), 763 deletions(-) diff --git a/input/drivers/winraw_input.c b/input/drivers/winraw_input.c index c7397d39d8..31f86cadb5 100644 --- a/input/drivers/winraw_input.c +++ b/input/drivers/winraw_input.c @@ -1,764 +1,858 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2011-2017 - Daniel De Matteis - * - * RetroArch 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 Found- - * ation, either version 3 of the License, or (at your option) any later version. - * - * RetroArch 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 RetroArch. - * If not, see . - */ - -#include - -#include "../input_driver.h" -#include "../input_keymaps.h" - -#include "../../configuration.h" -#include "../../gfx/video_driver.h" -#include "../../verbosity.h" - -typedef struct -{ - uint8_t keys[256]; -} winraw_keyboard_t; - -typedef struct -{ - HANDLE hnd; - LONG x, y, dlt_x, dlt_y; - LONG whl_u, whl_d; - bool btn_l, btn_m, btn_r, btn_b4, btn_b5; -} winraw_mouse_t; - -typedef struct -{ - bool kbd_mapp_block; - bool mouse_grab; - winraw_keyboard_t keyboard; - HWND window; - winraw_mouse_t *mice; - const input_device_driver_t *joypad; -} winraw_input_t; - -static winraw_keyboard_t *g_keyboard = NULL; -static winraw_mouse_t *g_mice = NULL; -static unsigned g_mouse_cnt = 0; -static bool g_mouse_xy_mapping_ready = false; -static double g_view_abs_ratio_x = 0.0; -static double g_view_abs_ratio_y = 0.0; - -static HWND winraw_create_window(WNDPROC wnd_proc) -{ - HWND wnd; - WNDCLASSA wc = {0}; - - wc.hInstance = GetModuleHandleA(NULL); - - if (!wc.hInstance) - { - RARCH_ERR("[WINRAW]: GetModuleHandleA failed with error %lu.\n", GetLastError()); - return NULL; - } - - wc.lpfnWndProc = wnd_proc; - wc.lpszClassName = "winraw-input"; - if (!RegisterClassA(&wc) && GetLastError() != ERROR_CLASS_ALREADY_EXISTS) - { - RARCH_ERR("[WINRAW]: RegisterClassA failed with error %lu.\n", GetLastError()); - return NULL; - } - - wnd = CreateWindowExA(0, wc.lpszClassName, NULL, 0, 0, 0, 0, 0, - HWND_MESSAGE, NULL, NULL, NULL); - if (!wnd) - { - RARCH_ERR("[WINRAW]: CreateWindowExA failed with error %lu.\n", GetLastError()); - goto error; - } - - return wnd; - -error: - UnregisterClassA(wc.lpszClassName, NULL); - return NULL; -} - -static void winraw_destroy_window(HWND wnd) -{ - BOOL r; - - if (!wnd) - return; - - r = DestroyWindow(wnd); - - if (!r) - { - RARCH_WARN("[WINRAW]: DestroyWindow failed with error %lu.\n", GetLastError()); - } - - r = UnregisterClassA("winraw-input", NULL); - - if (!r) - { - RARCH_WARN("[WINRAW]: UnregisterClassA failed with error %lu.\n", GetLastError()); - } -} - -static bool winraw_set_keyboard_input(HWND window) -{ - RAWINPUTDEVICE rid; - BOOL r; - - rid.dwFlags = window ? 0 : RIDEV_REMOVE; - rid.hwndTarget = window; - rid.usUsagePage = 0x01; /* generic desktop */ - rid.usUsage = 0x06; /* keyboard */ - - r = RegisterRawInputDevices(&rid, 1, sizeof(RAWINPUTDEVICE)); - - if (!r) - { - RARCH_ERR("[WINRAW]: RegisterRawInputDevices failed with error %lu.\n", GetLastError()); - return false; - } - - return true; -} - -static void winraw_log_mice_info(winraw_mouse_t *mice, unsigned mouse_cnt) -{ - UINT r; - unsigned i; - char name[256]; - UINT name_size = sizeof(name); - - for (i = 0; i < mouse_cnt; ++i) - { - r = GetRawInputDeviceInfoA(mice[i].hnd, RIDI_DEVICENAME, name, &name_size); - if (r == (UINT)-1 || r == 0) - name[0] = '\0'; - RARCH_LOG("[WINRAW]: Mouse #%u %s.\n", i, name); - } -} - -static bool winraw_init_devices(winraw_mouse_t **mice, unsigned *mouse_cnt) -{ - UINT i; - POINT crs_pos; - winraw_mouse_t *mice_r = NULL; - unsigned mouse_cnt_r = 0; - RAWINPUTDEVICELIST *devs = NULL; - UINT dev_cnt = 0; - UINT r = GetRawInputDeviceList( - NULL, &dev_cnt, sizeof(RAWINPUTDEVICELIST)); - - if (r == (UINT)-1) - { - RARCH_ERR("[WINRAW]: GetRawInputDeviceList failed with error %lu.\n", GetLastError()); - goto error; - } - - devs = (RAWINPUTDEVICELIST*)malloc(dev_cnt * sizeof(RAWINPUTDEVICELIST)); - if (!devs) - goto error; - - dev_cnt = GetRawInputDeviceList(devs, &dev_cnt, sizeof(RAWINPUTDEVICELIST)); - if (dev_cnt == (UINT)-1) - { - RARCH_ERR("[WINRAW]: GetRawInputDeviceList failed with error %lu.\n", GetLastError()); - goto error; - } - - for (i = 0; i < dev_cnt; ++i) - mouse_cnt_r += devs[i].dwType == RIM_TYPEMOUSE ? 1 : 0; - - if (mouse_cnt_r) - { - mice_r = (winraw_mouse_t*)calloc(1, mouse_cnt_r * sizeof(winraw_mouse_t)); - if (!mice_r) - goto error; - - if (!GetCursorPos(&crs_pos)) - goto error; - - for (i = 0; i < mouse_cnt_r; ++i) - { - mice_r[i].x = crs_pos.x; - mice_r[i].y = crs_pos.y; - } - } - - /* count is already checked, so this is safe */ - for (i = mouse_cnt_r = 0; i < dev_cnt; ++i) - { - if (devs[i].dwType == RIM_TYPEMOUSE) - mice_r[mouse_cnt_r++].hnd = devs[i].hDevice; - } - - winraw_log_mice_info(mice_r, mouse_cnt_r); - - *mice = mice_r; - *mouse_cnt = mouse_cnt_r; - - return true; - -error: - free(devs); - free(mice_r); - *mice = NULL; - *mouse_cnt = 0; - return false; -} - -static bool winraw_set_mouse_input(HWND window, bool grab) -{ - RAWINPUTDEVICE rid; - BOOL r; - - if (window) - rid.dwFlags = grab ? RIDEV_CAPTUREMOUSE : 0; - else - rid.dwFlags = RIDEV_REMOVE; - - rid.hwndTarget = window; - rid.usUsagePage = 0x01; /* generic desktop */ - rid.usUsage = 0x02; /* mouse */ - - r = RegisterRawInputDevices(&rid, 1, sizeof(RAWINPUTDEVICE)); - - if (!r) - { - RARCH_ERR("[WINRAW]: RegisterRawInputDevice failed with error %lu.\n", GetLastError()); - return false; - } - - return true; -} - -static int16_t winraw_mouse_state(winraw_input_t *wr, - unsigned port, bool abs, unsigned id) -{ - unsigned i; - settings_t *settings = config_get_ptr(); - winraw_mouse_t *mouse = NULL; - - if (port >= MAX_USERS) - return 0; - - for (i = 0; i < g_mouse_cnt; ++i) - { - if (i == settings->uints.input_mouse_index[port]) - { - mouse = &wr->mice[i]; - break; - } - } - - if (!mouse) - return 0; - - switch (id) - { - case RETRO_DEVICE_ID_MOUSE_X: - return abs ? mouse->x : mouse->dlt_x; - case RETRO_DEVICE_ID_MOUSE_Y: - return abs ? mouse->y : mouse->dlt_y; - case RETRO_DEVICE_ID_MOUSE_LEFT: - return mouse->btn_l ? 1 : 0; - case RETRO_DEVICE_ID_MOUSE_RIGHT: - return mouse->btn_r ? 1 : 0; - case RETRO_DEVICE_ID_MOUSE_WHEELUP: - return mouse->whl_u ? 1 : 0; - case RETRO_DEVICE_ID_MOUSE_WHEELDOWN: - return mouse->whl_d ? 1 : 0; - case RETRO_DEVICE_ID_MOUSE_MIDDLE: - return mouse->btn_m ? 1 : 0; - case RETRO_DEVICE_ID_MOUSE_BUTTON_4: - return mouse->btn_b4 ? 1 : 0; - case RETRO_DEVICE_ID_MOUSE_BUTTON_5: - return mouse->btn_b5 ? 1 : 0; - } - - return 0; -} - -static bool winraw_mbutton_pressed(winraw_input_t *wr, unsigned port, unsigned key) -{ - unsigned i; - bool result; - winraw_mouse_t *mouse = NULL; - settings_t *settings = config_get_ptr(); - - if (port >= MAX_USERS) - return false; - - for (i = 0; i < g_mouse_cnt; ++i) - { - if (i == settings->uints.input_mouse_index[port]) - { - mouse = &wr->mice[i]; - break; - } - } - - if (!mouse) - return false; - - switch ( key ) - { - - case RETRO_DEVICE_ID_MOUSE_LEFT: - return mouse->btn_l; - case RETRO_DEVICE_ID_MOUSE_RIGHT: - return mouse->btn_r; - case RETRO_DEVICE_ID_MOUSE_MIDDLE: - return mouse->btn_m; - case RETRO_DEVICE_ID_MOUSE_BUTTON_4: - return mouse->btn_b4; - case RETRO_DEVICE_ID_MOUSE_BUTTON_5: - return mouse->btn_b5; - case RETRO_DEVICE_ID_MOUSE_WHEELUP: - return mouse->whl_u; - case RETRO_DEVICE_ID_MOUSE_WHEELDOWN: - return mouse->whl_d; - } - - return false; -} - -static int16_t winraw_joypad_state(winraw_input_t *wr, - rarch_joypad_info_t joypad_info, - const struct retro_keybind *binds, - unsigned port, unsigned id) -{ - const struct retro_keybind *bind = &binds[id]; - unsigned key = rarch_keysym_lut[(enum retro_key)bind->key]; - - if (!wr->kbd_mapp_block && (bind->key < RETROK_LAST) && wr->keyboard.keys[key]) - return 1; - - if (binds && binds[id].valid && winraw_mbutton_pressed(wr, port, bind->mbutton)) - return 1; - - return input_joypad_pressed(wr->joypad, joypad_info, port, binds, id); -} - -static void winraw_init_mouse_xy_mapping() -{ - struct video_viewport viewport; - int center_x; - int center_y; - unsigned i; - - if (video_driver_get_viewport_info(&viewport)) - { - center_x = viewport.x + viewport.width / 2; - center_y = viewport.y + viewport.height / 2; - - for (i = 0; i < g_mouse_cnt; ++i) - { - g_mice[i].x = center_x; - g_mice[i].y = center_y; - } - - g_view_abs_ratio_x = (double)viewport.full_width / 65535.0; - g_view_abs_ratio_y = (double)viewport.full_height / 65535.0; - - g_mouse_xy_mapping_ready = true; - } -} - -static int16_t winraw_lightgun_state(winraw_input_t *wr, - unsigned port, unsigned id) -{ - unsigned i; - settings_t *settings = config_get_ptr(); - winraw_mouse_t *mouse = NULL; - - if (port >= MAX_USERS) - return 0; - - for (i = 0; i < g_mouse_cnt; ++i) - { - if (i == settings->uints.input_mouse_index[port]) - { - mouse = &wr->mice[i]; - break; - } - } - - if (!mouse) - return 0; - - switch (id) - { - case RETRO_DEVICE_ID_LIGHTGUN_X: - return mouse->dlt_x; - case RETRO_DEVICE_ID_LIGHTGUN_Y: - return mouse->dlt_y; - case RETRO_DEVICE_ID_LIGHTGUN_TRIGGER: - return mouse->btn_l ? 1 : 0; - case RETRO_DEVICE_ID_LIGHTGUN_CURSOR: - return mouse->btn_m ? 1 : 0; - case RETRO_DEVICE_ID_LIGHTGUN_TURBO: - return mouse->btn_r ? 1 : 0; - case RETRO_DEVICE_ID_LIGHTGUN_START: - return (mouse->btn_m && mouse->btn_r) ? 1 : 0; - case RETRO_DEVICE_ID_LIGHTGUN_PAUSE: - return mouse->btn_m && mouse->btn_l ? 1 : 0; - } - - return 0; -} - -static void winraw_update_mouse_state(winraw_mouse_t *mouse, RAWMOUSE *state) -{ - POINT crs_pos; - - if (state->usFlags & MOUSE_MOVE_ABSOLUTE) - { - if (g_mouse_xy_mapping_ready) - { - state->lLastX = (LONG)(g_view_abs_ratio_x * state->lLastX); - state->lLastY = (LONG)(g_view_abs_ratio_y * state->lLastY); - InterlockedExchangeAdd(&mouse->dlt_x, state->lLastX - mouse->x); - InterlockedExchangeAdd(&mouse->dlt_y, state->lLastY - mouse->y); - mouse->x = state->lLastX; - mouse->y = state->lLastY; - } - else - winraw_init_mouse_xy_mapping(); - } - else if (state->lLastX || state->lLastY) - { - InterlockedExchangeAdd(&mouse->dlt_x, state->lLastX); - InterlockedExchangeAdd(&mouse->dlt_y, state->lLastY); - - if (!GetCursorPos(&crs_pos)) - { - RARCH_WARN("[WINRAW]: GetCursorPos failed with error %lu.\n", GetLastError()); - } - else if (!ScreenToClient((HWND)video_driver_window_get(), &crs_pos)) - { - RARCH_WARN("[WINRAW]: ScreenToClient failed with error %lu.\n", GetLastError()); - } - else - { - mouse->x = crs_pos.x; - mouse->y = crs_pos.y; - } - } - - if (state->usButtonFlags & RI_MOUSE_LEFT_BUTTON_DOWN) - mouse->btn_l = true; - else if (state->usButtonFlags & RI_MOUSE_LEFT_BUTTON_UP) - mouse->btn_l = false; - - if (state->usButtonFlags & RI_MOUSE_MIDDLE_BUTTON_DOWN) - mouse->btn_m = true; - else if (state->usButtonFlags & RI_MOUSE_MIDDLE_BUTTON_UP) - mouse->btn_m = false; - - if (state->usButtonFlags & RI_MOUSE_RIGHT_BUTTON_DOWN) - mouse->btn_r = true; - else if (state->usButtonFlags & RI_MOUSE_RIGHT_BUTTON_UP) - mouse->btn_r = false; - - if (state->usButtonFlags & RI_MOUSE_BUTTON_4_DOWN) - mouse->btn_b4 = true; - else if (state->usButtonFlags & RI_MOUSE_BUTTON_4_UP) - mouse->btn_b4 = false; - - if (state->usButtonFlags & RI_MOUSE_BUTTON_5_DOWN) - mouse->btn_b5 = true; - else if (state->usButtonFlags & RI_MOUSE_BUTTON_5_UP) - mouse->btn_b5 = false; - - if (state->usButtonFlags & RI_MOUSE_WHEEL) - { - if ((SHORT)state->usButtonData > 0) - InterlockedExchange(&mouse->whl_u, 1); - else if ((SHORT)state->usButtonData < 0) - InterlockedExchange(&mouse->whl_d, 1); - } -} - -static LRESULT CALLBACK winraw_callback(HWND wnd, UINT msg, WPARAM wpar, LPARAM lpar) -{ - static uint8_t data[1024]; - UINT r; - unsigned i; - RAWINPUT *ri = (RAWINPUT*)data; - UINT size = sizeof(data); - - if (msg != WM_INPUT) - return DefWindowProcA(wnd, msg, wpar, lpar); - - /* app is in the background */ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2011-2017 - Daniel De Matteis + * + * RetroArch 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 Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch 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 RetroArch. + * If not, see . + */ + +#include + +#include "../input_driver.h" +#include "../input_keymaps.h" + +#include "../../configuration.h" +#include "../../gfx/video_driver.h" +#include "../../verbosity.h" + +typedef struct +{ + uint8_t keys[256]; +} winraw_keyboard_t; + +typedef struct +{ + HANDLE hnd; + LONG x, y, dlt_x, dlt_y; + LONG whl_u, whl_d; + bool btn_l, btn_m, btn_r, btn_b4, btn_b5; +} winraw_mouse_t; + +typedef struct +{ + bool kbd_mapp_block; + bool mouse_grab; + winraw_keyboard_t keyboard; + HWND window; + winraw_mouse_t *mice; + const input_device_driver_t *joypad; +} winraw_input_t; + +static winraw_keyboard_t *g_keyboard = NULL; +static winraw_mouse_t *g_mice = NULL; +static unsigned g_mouse_cnt = 0; +static bool g_mouse_xy_mapping_ready = false; +static double g_view_abs_ratio_x = 0.0; +static double g_view_abs_ratio_y = 0.0; + +static HWND winraw_create_window(WNDPROC wnd_proc) +{ + HWND wnd; + WNDCLASSA wc = {0}; + + wc.hInstance = GetModuleHandleA(NULL); + + if (!wc.hInstance) + { + RARCH_ERR("[WINRAW]: GetModuleHandleA failed with error %lu.\n", GetLastError()); + return NULL; + } + + wc.lpfnWndProc = wnd_proc; + wc.lpszClassName = "winraw-input"; + if (!RegisterClassA(&wc) && GetLastError() != ERROR_CLASS_ALREADY_EXISTS) + { + RARCH_ERR("[WINRAW]: RegisterClassA failed with error %lu.\n", GetLastError()); + return NULL; + } + + wnd = CreateWindowExA(0, wc.lpszClassName, NULL, 0, 0, 0, 0, 0, + HWND_MESSAGE, NULL, NULL, NULL); + if (!wnd) + { + RARCH_ERR("[WINRAW]: CreateWindowExA failed with error %lu.\n", GetLastError()); + goto error; + } + + return wnd; + +error: + UnregisterClassA(wc.lpszClassName, NULL); + return NULL; +} + +static void winraw_destroy_window(HWND wnd) +{ + BOOL r; + + if (!wnd) + return; + + r = DestroyWindow(wnd); + + if (!r) + { + RARCH_WARN("[WINRAW]: DestroyWindow failed with error %lu.\n", GetLastError()); + } + + r = UnregisterClassA("winraw-input", NULL); + + if (!r) + { + RARCH_WARN("[WINRAW]: UnregisterClassA failed with error %lu.\n", GetLastError()); + } +} + +static bool winraw_set_keyboard_input(HWND window) +{ + RAWINPUTDEVICE rid; + BOOL r; + + rid.dwFlags = window ? 0 : RIDEV_REMOVE; + rid.hwndTarget = window; + rid.usUsagePage = 0x01; /* generic desktop */ + rid.usUsage = 0x06; /* keyboard */ + + r = RegisterRawInputDevices(&rid, 1, sizeof(RAWINPUTDEVICE)); + + if (!r) + { + RARCH_ERR("[WINRAW]: RegisterRawInputDevices failed with error %lu.\n", GetLastError()); + return false; + } + + return true; +} + +static void winraw_log_mice_info(winraw_mouse_t *mice, unsigned mouse_cnt) +{ + UINT r; + unsigned i; + char name[256]; + UINT name_size = sizeof(name); + + for (i = 0; i < mouse_cnt; ++i) + { + r = GetRawInputDeviceInfoA(mice[i].hnd, RIDI_DEVICENAME, name, &name_size); + if (r == (UINT)-1 || r == 0) + name[0] = '\0'; + RARCH_LOG("[WINRAW]: Mouse #%u %s.\n", i, name); + } +} + +static bool winraw_init_devices(winraw_mouse_t **mice, unsigned *mouse_cnt) +{ + UINT i; + POINT crs_pos; + winraw_mouse_t *mice_r = NULL; + unsigned mouse_cnt_r = 0; + RAWINPUTDEVICELIST *devs = NULL; + UINT dev_cnt = 0; + UINT r = GetRawInputDeviceList( + NULL, &dev_cnt, sizeof(RAWINPUTDEVICELIST)); + + if (r == (UINT)-1) + { + RARCH_ERR("[WINRAW]: GetRawInputDeviceList failed with error %lu.\n", GetLastError()); + goto error; + } + + devs = (RAWINPUTDEVICELIST*)malloc(dev_cnt * sizeof(RAWINPUTDEVICELIST)); + if (!devs) + goto error; + + dev_cnt = GetRawInputDeviceList(devs, &dev_cnt, sizeof(RAWINPUTDEVICELIST)); + if (dev_cnt == (UINT)-1) + { + RARCH_ERR("[WINRAW]: GetRawInputDeviceList failed with error %lu.\n", GetLastError()); + goto error; + } + + for (i = 0; i < dev_cnt; ++i) + mouse_cnt_r += devs[i].dwType == RIM_TYPEMOUSE ? 1 : 0; + + if (mouse_cnt_r) + { + mice_r = (winraw_mouse_t*)calloc(1, mouse_cnt_r * sizeof(winraw_mouse_t)); + if (!mice_r) + goto error; + + if (!GetCursorPos(&crs_pos)) + goto error; + + for (i = 0; i < mouse_cnt_r; ++i) + { + mice_r[i].x = crs_pos.x; + mice_r[i].y = crs_pos.y; + } + } + + /* count is already checked, so this is safe */ + for (i = mouse_cnt_r = 0; i < dev_cnt; ++i) + { + if (devs[i].dwType == RIM_TYPEMOUSE) + mice_r[mouse_cnt_r++].hnd = devs[i].hDevice; + } + + winraw_log_mice_info(mice_r, mouse_cnt_r); + + *mice = mice_r; + *mouse_cnt = mouse_cnt_r; + + return true; + +error: + free(devs); + free(mice_r); + *mice = NULL; + *mouse_cnt = 0; + return false; +} + +static bool winraw_set_mouse_input(HWND window, bool grab) +{ + RAWINPUTDEVICE rid; + BOOL r; + + if (window) + rid.dwFlags = grab ? RIDEV_CAPTUREMOUSE : 0; + else + rid.dwFlags = RIDEV_REMOVE; + + rid.hwndTarget = window; + rid.usUsagePage = 0x01; /* generic desktop */ + rid.usUsage = 0x02; /* mouse */ + + r = RegisterRawInputDevices(&rid, 1, sizeof(RAWINPUTDEVICE)); + + if (!r) + { + RARCH_ERR("[WINRAW]: RegisterRawInputDevice failed with error %lu.\n", GetLastError()); + return false; + } + + return true; +} + +static int16_t winraw_lightgun_aiming_state(winraw_input_t *wr, + unsigned port, unsigned id) +{ + const int edge_detect = 32700; + struct video_viewport vp; + bool inside = false; + unsigned i; + settings_t *settings = config_get_ptr(); + winraw_mouse_t *mouse = NULL; + int16_t res_x = 0; + int16_t res_y = 0; + int16_t res_screen_x = 0; + int16_t res_screen_y = 0; + + if (port >= MAX_USERS) + return 0; + + for (i = 0; i < g_mouse_cnt; ++i) + { + if (i == settings->uints.input_mouse_index[port]) + { + mouse = &wr->mice[i]; + break; + } + } + + if (!mouse) + return 0; + + vp.x = 0; + vp.y = 0; + vp.width = 0; + vp.height = 0; + vp.full_width = 0; + vp.full_height = 0; + + if ( !( video_driver_translate_coord_viewport_wrap( + &vp, mouse->x, mouse->y, &res_x, &res_y, &res_screen_x, &res_screen_y ) ) ) + { + return 0; + } + + inside = (res_x >= -edge_detect) && (res_y >= -edge_detect) && (res_x <= edge_detect) && (res_y <= edge_detect); + + switch ( id ) + { + case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X: + return inside ? res_x : 0; + case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y: + return inside ? res_y : 0; + case RETRO_DEVICE_ID_LIGHTGUN_IS_OFFSCREEN: + return !inside; + default: + break; + } + + return 0; +} + +static int16_t winraw_mouse_state(winraw_input_t *wr, + unsigned port, bool abs, unsigned id) +{ + unsigned i; + settings_t *settings = config_get_ptr(); + winraw_mouse_t *mouse = NULL; + + if (port >= MAX_USERS) + return 0; + + for (i = 0; i < g_mouse_cnt; ++i) + { + if (i == settings->uints.input_mouse_index[port]) + { + mouse = &wr->mice[i]; + break; + } + } + + if (!mouse) + return 0; + + switch (id) + { + case RETRO_DEVICE_ID_MOUSE_X: + return abs ? mouse->x : mouse->dlt_x; + case RETRO_DEVICE_ID_MOUSE_Y: + return abs ? mouse->y : mouse->dlt_y; + case RETRO_DEVICE_ID_MOUSE_LEFT: + return mouse->btn_l ? 1 : 0; + case RETRO_DEVICE_ID_MOUSE_RIGHT: + return mouse->btn_r ? 1 : 0; + case RETRO_DEVICE_ID_MOUSE_WHEELUP: + return mouse->whl_u ? 1 : 0; + case RETRO_DEVICE_ID_MOUSE_WHEELDOWN: + return mouse->whl_d ? 1 : 0; + case RETRO_DEVICE_ID_MOUSE_MIDDLE: + return mouse->btn_m ? 1 : 0; + case RETRO_DEVICE_ID_MOUSE_BUTTON_4: + return mouse->btn_b4 ? 1 : 0; + case RETRO_DEVICE_ID_MOUSE_BUTTON_5: + return mouse->btn_b5 ? 1 : 0; + } + + return 0; +} + +static bool winraw_keyboard_pressed(winraw_input_t *wr, unsigned key) +{ + unsigned k = rarch_keysym_lut[(enum retro_key)key]; + return wr->keyboard.keys[k]; +} + +static bool winraw_mbutton_pressed(winraw_input_t *wr, unsigned port, unsigned key) +{ + unsigned i; + bool result; + winraw_mouse_t *mouse = NULL; + settings_t *settings = config_get_ptr(); + + if (port >= MAX_USERS) + return false; + + for (i = 0; i < g_mouse_cnt; ++i) + { + if (i == settings->uints.input_mouse_index[port]) + { + mouse = &wr->mice[i]; + break; + } + } + + if (!mouse) + return false; + + switch ( key ) + { + + case RETRO_DEVICE_ID_MOUSE_LEFT: + return mouse->btn_l; + case RETRO_DEVICE_ID_MOUSE_RIGHT: + return mouse->btn_r; + case RETRO_DEVICE_ID_MOUSE_MIDDLE: + return mouse->btn_m; + case RETRO_DEVICE_ID_MOUSE_BUTTON_4: + return mouse->btn_b4; + case RETRO_DEVICE_ID_MOUSE_BUTTON_5: + return mouse->btn_b5; + case RETRO_DEVICE_ID_MOUSE_WHEELUP: + return mouse->whl_u; + case RETRO_DEVICE_ID_MOUSE_WHEELDOWN: + return mouse->whl_d; + } + + return false; +} + +static bool winraw_is_pressed(winraw_input_t *wr, + rarch_joypad_info_t joypad_info, + const struct retro_keybind *binds, + unsigned port, unsigned id) +{ + const struct retro_keybind *bind = &binds[id]; + + if (!wr->kbd_mapp_block && (bind->key < RETROK_LAST) && winraw_keyboard_pressed(wr, bind->key)) + return true; + if (binds && binds[id].valid) + { + if (winraw_mbutton_pressed(wr, port, bind->mbutton)) + return true; + if (input_joypad_pressed(wr->joypad, joypad_info, port, binds, id)) + return true; + } + + return false; +} + +static void winraw_init_mouse_xy_mapping() +{ + struct video_viewport viewport; + int center_x; + int center_y; + unsigned i; + + if (video_driver_get_viewport_info(&viewport)) + { + center_x = viewport.x + viewport.width / 2; + center_y = viewport.y + viewport.height / 2; + + for (i = 0; i < g_mouse_cnt; ++i) + { + g_mice[i].x = center_x; + g_mice[i].y = center_y; + } + + g_view_abs_ratio_x = (double)viewport.full_width / 65535.0; + g_view_abs_ratio_y = (double)viewport.full_height / 65535.0; + + g_mouse_xy_mapping_ready = true; + } +} + +static int16_t winraw_deprecated_lightgun_state(winraw_input_t *wr, + unsigned port, unsigned id) +{ + unsigned i; + settings_t *settings = config_get_ptr(); + winraw_mouse_t *mouse = NULL; + + if (port >= MAX_USERS) + return 0; + + for (i = 0; i < g_mouse_cnt; ++i) + { + if (i == settings->uints.input_mouse_index[port]) + { + mouse = &wr->mice[i]; + break; + } + } + + if (!mouse) + return 0; + + switch (id) + { + case RETRO_DEVICE_ID_LIGHTGUN_X: + return mouse->dlt_x; + case RETRO_DEVICE_ID_LIGHTGUN_Y: + return mouse->dlt_y; + } + + return 0; +} + +static void winraw_update_mouse_state(winraw_mouse_t *mouse, RAWMOUSE *state) +{ + POINT crs_pos; + + if (state->usFlags & MOUSE_MOVE_ABSOLUTE) + { + if (g_mouse_xy_mapping_ready) + { + state->lLastX = (LONG)(g_view_abs_ratio_x * state->lLastX); + state->lLastY = (LONG)(g_view_abs_ratio_y * state->lLastY); + InterlockedExchangeAdd(&mouse->dlt_x, state->lLastX - mouse->x); + InterlockedExchangeAdd(&mouse->dlt_y, state->lLastY - mouse->y); + mouse->x = state->lLastX; + mouse->y = state->lLastY; + } + else + winraw_init_mouse_xy_mapping(); + } + else if (state->lLastX || state->lLastY) + { + InterlockedExchangeAdd(&mouse->dlt_x, state->lLastX); + InterlockedExchangeAdd(&mouse->dlt_y, state->lLastY); + + if (!GetCursorPos(&crs_pos)) + { + RARCH_WARN("[WINRAW]: GetCursorPos failed with error %lu.\n", GetLastError()); + } + else if (!ScreenToClient((HWND)video_driver_window_get(), &crs_pos)) + { + RARCH_WARN("[WINRAW]: ScreenToClient failed with error %lu.\n", GetLastError()); + } + else + { + mouse->x = crs_pos.x; + mouse->y = crs_pos.y; + } + } + + if (state->usButtonFlags & RI_MOUSE_LEFT_BUTTON_DOWN) + mouse->btn_l = true; + else if (state->usButtonFlags & RI_MOUSE_LEFT_BUTTON_UP) + mouse->btn_l = false; + + if (state->usButtonFlags & RI_MOUSE_MIDDLE_BUTTON_DOWN) + mouse->btn_m = true; + else if (state->usButtonFlags & RI_MOUSE_MIDDLE_BUTTON_UP) + mouse->btn_m = false; + + if (state->usButtonFlags & RI_MOUSE_RIGHT_BUTTON_DOWN) + mouse->btn_r = true; + else if (state->usButtonFlags & RI_MOUSE_RIGHT_BUTTON_UP) + mouse->btn_r = false; + + if (state->usButtonFlags & RI_MOUSE_BUTTON_4_DOWN) + mouse->btn_b4 = true; + else if (state->usButtonFlags & RI_MOUSE_BUTTON_4_UP) + mouse->btn_b4 = false; + + if (state->usButtonFlags & RI_MOUSE_BUTTON_5_DOWN) + mouse->btn_b5 = true; + else if (state->usButtonFlags & RI_MOUSE_BUTTON_5_UP) + mouse->btn_b5 = false; + + if (state->usButtonFlags & RI_MOUSE_WHEEL) + { + if ((SHORT)state->usButtonData > 0) + InterlockedExchange(&mouse->whl_u, 1); + else if ((SHORT)state->usButtonData < 0) + InterlockedExchange(&mouse->whl_d, 1); + } +} + +static LRESULT CALLBACK winraw_callback(HWND wnd, UINT msg, WPARAM wpar, LPARAM lpar) +{ + static uint8_t data[1024]; + UINT r; + unsigned i; + RAWINPUT *ri = (RAWINPUT*)data; + UINT size = sizeof(data); + + if (msg != WM_INPUT) + return DefWindowProcA(wnd, msg, wpar, lpar); + + /* app is in the background */ if (GET_RAWINPUT_CODE_WPARAM(wpar) != RIM_INPUT) - goto end; - - r = GetRawInputData((HRAWINPUT)lpar, RID_INPUT, - data, &size, sizeof(RAWINPUTHEADER)); - if (r == (UINT)-1) - { - RARCH_WARN("[WINRAW]: GetRawInputData failed with error %lu.\n", - GetLastError()); - goto end; - } - - if (ri->header.dwType == RIM_TYPEKEYBOARD) - { - if (ri->data.keyboard.Message == WM_KEYDOWN) - g_keyboard->keys[ri->data.keyboard.VKey] = 1; - else if (ri->data.keyboard.Message == WM_KEYUP) - g_keyboard->keys[ri->data.keyboard.VKey] = 0; - } - else if (ri->header.dwType == RIM_TYPEMOUSE) - { - for (i = 0; i < g_mouse_cnt; ++i) - { - if (g_mice[i].hnd == ri->header.hDevice) - { - winraw_update_mouse_state(&g_mice[i], &ri->data.mouse); - break; - } - } - } - -end: - DefWindowProcA(wnd, msg, wpar, lpar); - return 0; -} - -static void *winraw_init(const char *joypad_driver) -{ - bool r; - winraw_input_t *wr = (winraw_input_t *) - calloc(1, sizeof(winraw_input_t)); - g_keyboard = (winraw_keyboard_t*) - calloc(1, sizeof(winraw_keyboard_t)); - - if (!wr || !g_keyboard) - goto error; - - RARCH_LOG("[WINRAW]: Initializing input driver... \n"); - - input_keymaps_init_keyboard_lut(rarch_key_map_winraw); - - wr->window = winraw_create_window(winraw_callback); - if (!wr->window) - goto error; - - r = winraw_init_devices(&g_mice, &g_mouse_cnt); - if (!r) - goto error; - - if (!g_mouse_cnt) - { - RARCH_LOG("[WINRAW]: Mouse unavailable.\n"); - } - else - { - wr->mice = (winraw_mouse_t*) - malloc(g_mouse_cnt * sizeof(winraw_mouse_t)); - if (!wr->mice) - goto error; - - memcpy(wr->mice, g_mice, g_mouse_cnt * sizeof(winraw_mouse_t)); - } - - r = winraw_set_keyboard_input(wr->window); - if (!r) - goto error; - - r = winraw_set_mouse_input(wr->window, false); - if (!r) - goto error; - - wr->joypad = input_joypad_init_driver(joypad_driver, wr); - - return wr; - -error: - if (wr && wr->window) - { - winraw_set_mouse_input(NULL, false); - winraw_set_keyboard_input(NULL); - winraw_destroy_window(wr->window); - } - free(g_keyboard); - free(g_mice); - if (wr) - free(wr->mice); - free(wr); - return NULL; -} - -static void winraw_poll(void *d) -{ - unsigned i; - winraw_input_t *wr = (winraw_input_t*)d; - - memcpy(&wr->keyboard, g_keyboard, sizeof(winraw_keyboard_t)); - - /* following keys are not handled by windows raw input api */ - wr->keyboard.keys[VK_LCONTROL] = GetAsyncKeyState(VK_LCONTROL) >> 1 ? 1 : 0; - wr->keyboard.keys[VK_RCONTROL] = GetAsyncKeyState(VK_RCONTROL) >> 1 ? 1 : 0; - wr->keyboard.keys[VK_LMENU] = GetAsyncKeyState(VK_LMENU) >> 1 ? 1 : 0; - wr->keyboard.keys[VK_RMENU] = GetAsyncKeyState(VK_RMENU) >> 1 ? 1 : 0; - wr->keyboard.keys[VK_LSHIFT] = GetAsyncKeyState(VK_LSHIFT) >> 1 ? 1 : 0; - wr->keyboard.keys[VK_RSHIFT] = GetAsyncKeyState(VK_RSHIFT) >> 1 ? 1 : 0; - - for (i = 0; i < g_mouse_cnt; ++i) - { - wr->mice[i].x = g_mice[i].x; - wr->mice[i].y = g_mice[i].y; - wr->mice[i].dlt_x = InterlockedExchange(&g_mice[i].dlt_x, 0); - wr->mice[i].dlt_y = InterlockedExchange(&g_mice[i].dlt_y, 0); - wr->mice[i].whl_u = InterlockedExchange(&g_mice[i].whl_u, 0); - wr->mice[i].whl_d = InterlockedExchange(&g_mice[i].whl_d, 0); - wr->mice[i].btn_l = g_mice[i].btn_l; - wr->mice[i].btn_m = g_mice[i].btn_m; - wr->mice[i].btn_r = g_mice[i].btn_r; - wr->mice[i].btn_b4 = g_mice[i].btn_b4; - wr->mice[i].btn_b5 = g_mice[i].btn_b5; - } - - if (wr->joypad) - wr->joypad->poll(); -} - -static int16_t winraw_input_state(void *d, - rarch_joypad_info_t joypad_info, - const struct retro_keybind **binds, - unsigned port, unsigned device, unsigned index, unsigned id) -{ - winraw_input_t *wr = (winraw_input_t*)d; - - switch (device) - { - case RETRO_DEVICE_KEYBOARD: - if (id < RETROK_LAST) - { - unsigned key = rarch_keysym_lut[(enum retro_key)id]; - return wr->keyboard.keys[key]; - } - break; - case RETRO_DEVICE_MOUSE: - return winraw_mouse_state(wr, port, false, id); - case RARCH_DEVICE_MOUSE_SCREEN: - return winraw_mouse_state(wr, port, true, id); - case RETRO_DEVICE_JOYPAD: - return winraw_joypad_state(wr, joypad_info, binds[port], port, id); - case RETRO_DEVICE_ANALOG: - if (binds[port]) - return input_joypad_analog(wr->joypad, joypad_info, - port, index, id, binds[port]); - break; - case RETRO_DEVICE_LIGHTGUN: - return winraw_lightgun_state(wr, port, id); - } - - return 0; -} - -static bool winraw_meta_key_pressed(void *u1, int u2) -{ - return false; -} - -static void winraw_free(void *d) -{ - winraw_input_t *wr = (winraw_input_t*)d; - - if (wr->joypad) - wr->joypad->destroy(); - winraw_set_mouse_input(NULL, false); - winraw_set_keyboard_input(NULL); - winraw_destroy_window(wr->window); - free(g_mice); - free(g_keyboard); - free(wr->mice); - free(wr); - - g_mouse_xy_mapping_ready = false; -} - -static uint64_t winraw_get_capabilities(void *u) -{ - return (1 << RETRO_DEVICE_KEYBOARD) | - (1 << RETRO_DEVICE_MOUSE) | - (1 << RETRO_DEVICE_JOYPAD) | - (1 << RETRO_DEVICE_ANALOG) | - (1 << RETRO_DEVICE_LIGHTGUN); -} - -static void winraw_grab_mouse(void *d, bool grab) -{ - bool r = false; - winraw_input_t *wr = (winraw_input_t*)d; - - if (grab == wr->mouse_grab) - return; - - r = winraw_set_mouse_input(wr->window, grab); - if (!r) - return; - - wr->mouse_grab = grab; -} - -static bool winraw_set_rumble(void *d, unsigned port, - enum retro_rumble_effect effect, uint16_t strength) -{ - winraw_input_t *wr = (winraw_input_t*)d; - - return input_joypad_set_rumble(wr->joypad, port, effect, strength); -} - -static const input_device_driver_t *winraw_get_joypad_driver(void *d) -{ - winraw_input_t *wr = (winraw_input_t*)d; - - return wr->joypad; -} - -static bool winraw_keyboard_mapping_is_blocked(void *d) -{ - winraw_input_t *wr = (winraw_input_t*)d; - - return wr->kbd_mapp_block; -} - -static void winraw_keyboard_mapping_set_block(void *d, bool block) -{ - winraw_input_t *wr = (winraw_input_t*)d; - - wr->kbd_mapp_block = block; -} - -input_driver_t input_winraw = { - winraw_init, - winraw_poll, - winraw_input_state, - winraw_meta_key_pressed, - winraw_free, - NULL, - NULL, - winraw_get_capabilities, - "raw", - winraw_grab_mouse, - NULL, - winraw_set_rumble, - winraw_get_joypad_driver, - NULL, - winraw_keyboard_mapping_is_blocked, - winraw_keyboard_mapping_set_block, -}; + goto end; + + r = GetRawInputData((HRAWINPUT)lpar, RID_INPUT, + data, &size, sizeof(RAWINPUTHEADER)); + if (r == (UINT)-1) + { + RARCH_WARN("[WINRAW]: GetRawInputData failed with error %lu.\n", + GetLastError()); + goto end; + } + + if (ri->header.dwType == RIM_TYPEKEYBOARD) + { + if (ri->data.keyboard.Message == WM_KEYDOWN) + g_keyboard->keys[ri->data.keyboard.VKey] = 1; + else if (ri->data.keyboard.Message == WM_KEYUP) + g_keyboard->keys[ri->data.keyboard.VKey] = 0; + } + else if (ri->header.dwType == RIM_TYPEMOUSE) + { + for (i = 0; i < g_mouse_cnt; ++i) + { + if (g_mice[i].hnd == ri->header.hDevice) + { + winraw_update_mouse_state(&g_mice[i], &ri->data.mouse); + break; + } + } + } + +end: + DefWindowProcA(wnd, msg, wpar, lpar); + return 0; +} + +static void *winraw_init(const char *joypad_driver) +{ + bool r; + winraw_input_t *wr = (winraw_input_t *) + calloc(1, sizeof(winraw_input_t)); + g_keyboard = (winraw_keyboard_t*) + calloc(1, sizeof(winraw_keyboard_t)); + + if (!wr || !g_keyboard) + goto error; + + RARCH_LOG("[WINRAW]: Initializing input driver... \n"); + + input_keymaps_init_keyboard_lut(rarch_key_map_winraw); + + wr->window = winraw_create_window(winraw_callback); + if (!wr->window) + goto error; + + r = winraw_init_devices(&g_mice, &g_mouse_cnt); + if (!r) + goto error; + + if (!g_mouse_cnt) + { + RARCH_LOG("[WINRAW]: Mouse unavailable.\n"); + } + else + { + wr->mice = (winraw_mouse_t*) + malloc(g_mouse_cnt * sizeof(winraw_mouse_t)); + if (!wr->mice) + goto error; + + memcpy(wr->mice, g_mice, g_mouse_cnt * sizeof(winraw_mouse_t)); + } + + r = winraw_set_keyboard_input(wr->window); + if (!r) + goto error; + + r = winraw_set_mouse_input(wr->window, false); + if (!r) + goto error; + + wr->joypad = input_joypad_init_driver(joypad_driver, wr); + + return wr; + +error: + if (wr && wr->window) + { + winraw_set_mouse_input(NULL, false); + winraw_set_keyboard_input(NULL); + winraw_destroy_window(wr->window); + } + free(g_keyboard); + free(g_mice); + if (wr) + free(wr->mice); + free(wr); + return NULL; +} + +static void winraw_poll(void *d) +{ + unsigned i; + winraw_input_t *wr = (winraw_input_t*)d; + + memcpy(&wr->keyboard, g_keyboard, sizeof(winraw_keyboard_t)); + + /* following keys are not handled by windows raw input api */ + wr->keyboard.keys[VK_LCONTROL] = GetAsyncKeyState(VK_LCONTROL) >> 1 ? 1 : 0; + wr->keyboard.keys[VK_RCONTROL] = GetAsyncKeyState(VK_RCONTROL) >> 1 ? 1 : 0; + wr->keyboard.keys[VK_LMENU] = GetAsyncKeyState(VK_LMENU) >> 1 ? 1 : 0; + wr->keyboard.keys[VK_RMENU] = GetAsyncKeyState(VK_RMENU) >> 1 ? 1 : 0; + wr->keyboard.keys[VK_LSHIFT] = GetAsyncKeyState(VK_LSHIFT) >> 1 ? 1 : 0; + wr->keyboard.keys[VK_RSHIFT] = GetAsyncKeyState(VK_RSHIFT) >> 1 ? 1 : 0; + + for (i = 0; i < g_mouse_cnt; ++i) + { + wr->mice[i].x = g_mice[i].x; + wr->mice[i].y = g_mice[i].y; + wr->mice[i].dlt_x = InterlockedExchange(&g_mice[i].dlt_x, 0); + wr->mice[i].dlt_y = InterlockedExchange(&g_mice[i].dlt_y, 0); + wr->mice[i].whl_u = InterlockedExchange(&g_mice[i].whl_u, 0); + wr->mice[i].whl_d = InterlockedExchange(&g_mice[i].whl_d, 0); + wr->mice[i].btn_l = g_mice[i].btn_l; + wr->mice[i].btn_m = g_mice[i].btn_m; + wr->mice[i].btn_r = g_mice[i].btn_r; + wr->mice[i].btn_b4 = g_mice[i].btn_b4; + wr->mice[i].btn_b5 = g_mice[i].btn_b5; + } + + if (wr->joypad) + wr->joypad->poll(); +} + +static int16_t winraw_input_state(void *d, + rarch_joypad_info_t joypad_info, + const struct retro_keybind **binds, + unsigned port, unsigned device, unsigned index, unsigned id) +{ + winraw_input_t *wr = (winraw_input_t*)d; + + switch (device) + { + case RETRO_DEVICE_JOYPAD: + if (id < RARCH_BIND_LIST_END) + return winraw_is_pressed(wr, joypad_info, binds[port], port, id); + break; + case RETRO_DEVICE_KEYBOARD: + return (id < RETROK_LAST) && winraw_keyboard_pressed(wr, id); + case RETRO_DEVICE_MOUSE: + return winraw_mouse_state(wr, port, false, id); + case RARCH_DEVICE_MOUSE_SCREEN: + return winraw_mouse_state(wr, port, true, id); + case RETRO_DEVICE_ANALOG: + if (binds[port]) + return input_joypad_analog(wr->joypad, joypad_info, + port, index, id, binds[port]); + break; + case RETRO_DEVICE_LIGHTGUN: + switch ( id ) + { + /*aiming*/ + case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X: + case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y: + case RETRO_DEVICE_ID_LIGHTGUN_IS_OFFSCREEN: + return winraw_lightgun_aiming_state( wr, port, id ); + + /*buttons*/ + case RETRO_DEVICE_ID_LIGHTGUN_TRIGGER: + return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_TRIGGER); + case RETRO_DEVICE_ID_LIGHTGUN_RELOAD: + return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_RELOAD); + case RETRO_DEVICE_ID_LIGHTGUN_AUX_A: + return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_AUX_A); + case RETRO_DEVICE_ID_LIGHTGUN_AUX_B: + return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_AUX_B); + case RETRO_DEVICE_ID_LIGHTGUN_AUX_C: + return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_AUX_C); + case RETRO_DEVICE_ID_LIGHTGUN_START: + return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_START); + case RETRO_DEVICE_ID_LIGHTGUN_SELECT: + return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_SELECT); + case RETRO_DEVICE_ID_LIGHTGUN_DPAD_UP: + return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_DPAD_UP); + case RETRO_DEVICE_ID_LIGHTGUN_DPAD_DOWN: + return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_DPAD_DOWN); + case RETRO_DEVICE_ID_LIGHTGUN_DPAD_LEFT: + return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_DPAD_LEFT); + case RETRO_DEVICE_ID_LIGHTGUN_DPAD_RIGHT: + return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_DPAD_RIGHT); + + /*deprecated*/ + case RETRO_DEVICE_ID_LIGHTGUN_X: + case RETRO_DEVICE_ID_LIGHTGUN_Y: + return winraw_deprecated_lightgun_state(wr, port, id); + case RETRO_DEVICE_ID_LIGHTGUN_PAUSE: + return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_START); + } + break; + } + + return 0; +} + +static bool winraw_meta_key_pressed(void *u1, int u2) +{ + return false; +} + +static void winraw_free(void *d) +{ + winraw_input_t *wr = (winraw_input_t*)d; + + if (wr->joypad) + wr->joypad->destroy(); + winraw_set_mouse_input(NULL, false); + winraw_set_keyboard_input(NULL); + winraw_destroy_window(wr->window); + free(g_mice); + free(g_keyboard); + free(wr->mice); + free(wr); + + g_mouse_xy_mapping_ready = false; +} + +static uint64_t winraw_get_capabilities(void *u) +{ + return (1 << RETRO_DEVICE_KEYBOARD) | + (1 << RETRO_DEVICE_MOUSE) | + (1 << RETRO_DEVICE_JOYPAD) | + (1 << RETRO_DEVICE_ANALOG) | + (1 << RETRO_DEVICE_LIGHTGUN); +} + +static void winraw_grab_mouse(void *d, bool grab) +{ + bool r = false; + winraw_input_t *wr = (winraw_input_t*)d; + + if (grab == wr->mouse_grab) + return; + + r = winraw_set_mouse_input(wr->window, grab); + if (!r) + return; + + wr->mouse_grab = grab; +} + +static bool winraw_set_rumble(void *d, unsigned port, + enum retro_rumble_effect effect, uint16_t strength) +{ + winraw_input_t *wr = (winraw_input_t*)d; + + return input_joypad_set_rumble(wr->joypad, port, effect, strength); +} + +static const input_device_driver_t *winraw_get_joypad_driver(void *d) +{ + winraw_input_t *wr = (winraw_input_t*)d; + + return wr->joypad; +} + +static bool winraw_keyboard_mapping_is_blocked(void *d) +{ + winraw_input_t *wr = (winraw_input_t*)d; + + return wr->kbd_mapp_block; +} + +static void winraw_keyboard_mapping_set_block(void *d, bool block) +{ + winraw_input_t *wr = (winraw_input_t*)d; + + wr->kbd_mapp_block = block; +} + +input_driver_t input_winraw = { + winraw_init, + winraw_poll, + winraw_input_state, + winraw_meta_key_pressed, + winraw_free, + NULL, + NULL, + winraw_get_capabilities, + "raw", + winraw_grab_mouse, + NULL, + winraw_set_rumble, + winraw_get_joypad_driver, + NULL, + winraw_keyboard_mapping_is_blocked, + winraw_keyboard_mapping_set_block, +}; From ab0e1611e737e65c406134372e6d433e64c8935f Mon Sep 17 00:00:00 2001 From: Alcaro Date: Mon, 27 Nov 2017 16:57:15 +0100 Subject: [PATCH 061/394] fix #5497 close #5802 according to https://github.com/libretro/RetroArch/issues/5497#issuecomment-336640951, this header exists on everything we care about except various microsoft platforms, and all of them have constant printf strings --- libretro-common/include/retro_common_api.h | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) diff --git a/libretro-common/include/retro_common_api.h b/libretro-common/include/retro_common_api.h index 659f90d76e..6967d31adb 100644 --- a/libretro-common/include/retro_common_api.h +++ b/libretro-common/include/retro_common_api.h @@ -75,19 +75,16 @@ typedef int ssize_t; #include #endif -#ifdef _WIN32 -#define STRING_REP_INT64 "%I64d" -#define STRING_REP_UINT64 "%I64u" -#define STRING_REP_USIZE "%Iu" -#elif defined(__STDC_VERSION__) && __STDC_VERSION__>=199901L && !defined(VITA) && !defined(WIIU) -#define STRING_REP_INT64 "%lld" -#define STRING_REP_UINT64 "%llu" -#define STRING_REP_USIZE "%zu" +#ifndef _WIN32 +#include #else -#define STRING_REP_INT64 "%lld" -#define STRING_REP_UINT64 "%llu" -#define STRING_REP_USIZE "%lu" +#define PRId64 "%I64d" +#define PRIu64 "%I64u" +#define PRIuPTR "%Iu" #endif +#define STRING_REP_INT64 PRId64 +#define STRING_REP_UINT64 PRIu64 +#define STRING_REP_USIZE PRIuPTR /* I would like to see retro_inline.h moved in here; possibly boolean too. From 0f695f074ff3c6dc7bb44930b7dee5f27975caa0 Mon Sep 17 00:00:00 2001 From: Alcaro Date: Mon, 27 Nov 2017 17:07:31 +0100 Subject: [PATCH 062/394] #5802 aren't most of the memdesc fields size_t aka uintptr_t rather than uint64_t? whatever, good enough --- network/httpserver/httpserver.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/network/httpserver/httpserver.c b/network/httpserver/httpserver.c index 050604d0e6..17fe48f427 100644 --- a/network/httpserver/httpserver.c +++ b/network/httpserver/httpserver.c @@ -247,10 +247,10 @@ static int httpserver_handle_basic_info(struct mg_connection* conn, void* cbdata "\"frontendSupportsAchievements\":false," "\"coreSupportsAchievements\":null," #endif - "\"saveRam\":{\"pointer\":\"%" PRIXPTR "\",\"size\":" STRING_REP_UINT64 "}," - "\"rtcRam\":{\"pointer\":\"%" PRIXPTR "\",\"size\":" STRING_REP_UINT64 "}," - "\"systemRam\":{\"pointer\":\"%" PRIXPTR "\",\"size\":" STRING_REP_UINT64 "}," - "\"videoRam\":{\"pointer\":\"%" PRIXPTR "\",\"size\":" STRING_REP_UINT64 "},", + "\"saveRam\":{\"pointer\":\"%" PRIXPTR "\",\"size\":" PRIu64 "}," + "\"rtcRam\":{\"pointer\":\"%" PRIXPTR "\",\"size\":" PRIu64 "}," + "\"systemRam\":{\"pointer\":\"%" PRIXPTR "\",\"size\":" PRIu64 "}," + "\"videoRam\":{\"pointer\":\"%" PRIXPTR "\",\"size\":" PRIu64 "},", core_path, api.version, system->info.library_name, @@ -428,13 +428,13 @@ static int httpserver_handle_get_mmaps(struct mg_connection* conn, void* cbdata) mg_printf(conn, "%s{" "\"id\":%u," - "\"flags\":" STRING_REP_UINT64 "," + "\"flags\":" PRIu64 "," "\"ptr\":\"%" PRIXPTR "\"," - "\"offset\":" STRING_REP_UINT64 "," - "\"start\":" STRING_REP_UINT64 "," - "\"select\":" STRING_REP_UINT64 "," - "\"disconnect\":" STRING_REP_UINT64 "," - "\"len\":" STRING_REP_UINT64 "," + "\"offset\":" PRIu64 "," + "\"start\":" PRIu64 "," + "\"select\":" PRIu64 "," + "\"disconnect\":" PRIu64 "," + "\"len\":" PRIu64 "," "\"addrspace\":\"%s\"" "}", comma, From da9cddd833b5f9b1ffaf49bf84998693cca523ff Mon Sep 17 00:00:00 2001 From: Alcaro Date: Mon, 27 Nov 2017 17:08:41 +0100 Subject: [PATCH 063/394] #5802 --- libretro-db/query.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libretro-db/query.c b/libretro-db/query.c index 339a62d192..821b603032 100644 --- a/libretro-db/query.c +++ b/libretro-db/query.c @@ -289,7 +289,7 @@ struct registered_func registered_functions[100] = { static void query_raise_expected_number(ssize_t where, const char **error) { snprintf(tmp_error_buff, MAX_ERROR_LEN, - STRING_REP_UINT64 "::Expected number", + PRIu64 "::Expected number", (uint64_t)where); *error = tmp_error_buff; } @@ -297,7 +297,7 @@ static void query_raise_expected_number(ssize_t where, const char **error) static void query_raise_expected_string(ssize_t where, const char ** error) { snprintf(tmp_error_buff, MAX_ERROR_LEN, - STRING_REP_UINT64 "::Expected string", + PRIu64 "::Expected string", (uint64_t)where); *error = tmp_error_buff; } @@ -305,7 +305,7 @@ static void query_raise_expected_string(ssize_t where, const char ** error) static void query_raise_unexpected_eof(ssize_t where, const char ** error) { snprintf(tmp_error_buff, MAX_ERROR_LEN, - STRING_REP_UINT64 "::Unexpected EOF", + PRIu64 "::Unexpected EOF", (uint64_t)where ); *error = tmp_error_buff; @@ -321,7 +321,7 @@ static void query_raise_unknown_function(ssize_t where, const char *name, ssize_t len, const char **error) { int n = snprintf(tmp_error_buff, MAX_ERROR_LEN, - STRING_REP_UINT64 "::Unknown function '", + PRIu64 "::Unknown function '", (uint64_t)where ); @@ -336,7 +336,7 @@ static void query_raise_expected_eof( ssize_t where, char found, const char **error) { snprintf(tmp_error_buff, MAX_ERROR_LEN, - STRING_REP_UINT64 "::Expected EOF found '%c'", + PRIu64 "::Expected EOF found '%c'", (uint64_t)where, found ); @@ -348,7 +348,7 @@ static void query_raise_unexpected_char( const char **error) { snprintf(tmp_error_buff, MAX_ERROR_LEN, - STRING_REP_UINT64 "::Expected '%c' found '%c'", + PRIu64 "::Expected '%c' found '%c'", (uint64_t)where, expected, found); *error = tmp_error_buff; } From 4275dd8f1f44cfa9ad78dbcd53b98d199e1a2cee Mon Sep 17 00:00:00 2001 From: Alcaro Date: Mon, 27 Nov 2017 17:09:03 +0100 Subject: [PATCH 064/394] #5802 --- libretro-db/rmsgpack_dom.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libretro-db/rmsgpack_dom.c b/libretro-db/rmsgpack_dom.c index f7d6d3d916..48bde6e1d6 100644 --- a/libretro-db/rmsgpack_dom.c +++ b/libretro-db/rmsgpack_dom.c @@ -315,10 +315,10 @@ void rmsgpack_dom_value_print(struct rmsgpack_dom_value *obj) printf("false"); break; case RDT_INT: - printf(STRING_REP_INT64, (int64_t)obj->val.int_); + printf(PRId64, (int64_t)obj->val.int_); break; case RDT_UINT: - printf(STRING_REP_UINT64, (uint64_t)obj->val.uint_); + printf(PRIu64, (uint64_t)obj->val.uint_); break; case RDT_STRING: printf("\"%s\"", obj->val.string.buff); From 4fb12c4bd314a3bc682cdce960ec2c7c0c22e504 Mon Sep 17 00:00:00 2001 From: Alcaro Date: Mon, 27 Nov 2017 17:09:16 +0100 Subject: [PATCH 065/394] #5802 --- libretro-common/file/config_file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libretro-common/file/config_file.c b/libretro-common/file/config_file.c index 87f72238fb..3d3189dd86 100644 --- a/libretro-common/file/config_file.c +++ b/libretro-common/file/config_file.c @@ -892,7 +892,7 @@ void config_set_uint64(config_file_t *conf, const char *key, uint64_t val) char buf[128]; buf[0] = '\0'; - snprintf(buf, sizeof(buf), STRING_REP_UINT64, val); + snprintf(buf, sizeof(buf), PRIu64, val); config_set_string(conf, key, buf); } From 6eaa65ebc075e7db9d13f167d6287d73443dd9fa Mon Sep 17 00:00:00 2001 From: Alcaro Date: Mon, 27 Nov 2017 17:09:33 +0100 Subject: [PATCH 066/394] #5802 --- menu/cbs/menu_cbs_get_value.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/menu/cbs/menu_cbs_get_value.c b/menu/cbs/menu_cbs_get_value.c index 508121696a..25c9e1e5e6 100644 --- a/menu/cbs/menu_cbs_get_value.c +++ b/menu/cbs/menu_cbs_get_value.c @@ -572,7 +572,7 @@ static void menu_action_setting_disp_set_label_perf_counters_common( return; snprintf(s, len, - STRING_REP_UINT64 " ticks, " STRING_REP_UINT64 " runs.", + PRIu64 " ticks, " PRIu64 " runs.", ((uint64_t)counters[offset]->total / (uint64_t)counters[offset]->call_cnt), (uint64_t)counters[offset]->call_cnt); From c1f81616b2ceaead653f4b31d5dee2fb5f0a66b5 Mon Sep 17 00:00:00 2001 From: Alcaro Date: Mon, 27 Nov 2017 17:09:59 +0100 Subject: [PATCH 067/394] #582 --- menu/menu_displaylist.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 2fddc1669c..0006e7ef05 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -834,21 +834,21 @@ static int menu_displaylist_parse_system_info(menu_displaylist_info_t *info) if (memory_used != 0 && memory_total != 0) { snprintf(tmp, sizeof(tmp), - "%s %s: " STRING_REP_UINT64 "/" STRING_REP_UINT64 " B", + "%s %s: " PRIu64 "/" PRIu64 " B", msg_hash_to_str(MSG_MEMORY), msg_hash_to_str(MSG_IN_BYTES), memory_used, memory_total ); snprintf(tmp2, sizeof(tmp2), - "%s %s: " STRING_REP_UINT64 "/" STRING_REP_UINT64 " MB", + "%s %s: " PRIu64 "/" PRIu64 " MB", msg_hash_to_str(MSG_MEMORY), msg_hash_to_str(MSG_IN_MEGABYTES), bytes_to_mb(memory_used), bytes_to_mb(memory_total) ); snprintf(tmp3, sizeof(tmp3), - "%s %s: " STRING_REP_UINT64 "/" STRING_REP_UINT64 " GB", + "%s %s: " PRIu64 "/" PRIu64 " GB", msg_hash_to_str(MSG_MEMORY), msg_hash_to_str(MSG_IN_GIGABYTES), bytes_to_gb(memory_used), From 0e91822ad1abff5a120b2ecaa46b978d7334de00 Mon Sep 17 00:00:00 2001 From: Alcaro Date: Mon, 27 Nov 2017 17:11:43 +0100 Subject: [PATCH 068/394] #5802 --- gfx/video_driver.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 1656d11bab..d06252fb90 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -2312,7 +2312,7 @@ void video_driver_frame(const void *data, unsigned width, snprintf(frames_text, sizeof(frames_text), - STRING_REP_UINT64, + "%" PRIu64, (uint64_t)video_driver_frame_count); strlcat(video_driver_window_title, @@ -2330,7 +2330,7 @@ void video_driver_frame(const void *data, unsigned width, snprintf( video_info.fps_text, sizeof(video_info.fps_text), - "FPS: %6.1f || %s: " STRING_REP_UINT64, + "FPS: %6.1f || %s: %" PRIu64, last_fps, msg_hash_to_str(MSG_FRAMES), (uint64_t)video_driver_frame_count); From 9b99a48cdb7cb00b5aa9c2bcd6a3d98b8464457b Mon Sep 17 00:00:00 2001 From: Alcaro Date: Mon, 27 Nov 2017 17:12:30 +0100 Subject: [PATCH 069/394] just remembered these PRIs don't start with % --- libretro-common/include/retro_common_api.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libretro-common/include/retro_common_api.h b/libretro-common/include/retro_common_api.h index 6967d31adb..7be1affe29 100644 --- a/libretro-common/include/retro_common_api.h +++ b/libretro-common/include/retro_common_api.h @@ -78,13 +78,13 @@ typedef int ssize_t; #ifndef _WIN32 #include #else -#define PRId64 "%I64d" -#define PRIu64 "%I64u" -#define PRIuPTR "%Iu" +#define PRId64 "I64d" +#define PRIu64 "I64u" +#define PRIuPTR "Iu" #endif -#define STRING_REP_INT64 PRId64 -#define STRING_REP_UINT64 PRIu64 -#define STRING_REP_USIZE PRIuPTR +#define STRING_REP_INT64 "%" PRId64 +#define STRING_REP_UINT64 "%" PRIu64 +#define STRING_REP_USIZE "%" PRIuPTR /* I would like to see retro_inline.h moved in here; possibly boolean too. From 485ad9f6f73b5d9c20d112cf484e570f985387a1 Mon Sep 17 00:00:00 2001 From: Alcaro Date: Mon, 27 Nov 2017 17:15:21 +0100 Subject: [PATCH 070/394] add missing %s --- network/httpserver/httpserver.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/network/httpserver/httpserver.c b/network/httpserver/httpserver.c index 17fe48f427..c85b67ffa4 100644 --- a/network/httpserver/httpserver.c +++ b/network/httpserver/httpserver.c @@ -247,10 +247,10 @@ static int httpserver_handle_basic_info(struct mg_connection* conn, void* cbdata "\"frontendSupportsAchievements\":false," "\"coreSupportsAchievements\":null," #endif - "\"saveRam\":{\"pointer\":\"%" PRIXPTR "\",\"size\":" PRIu64 "}," - "\"rtcRam\":{\"pointer\":\"%" PRIXPTR "\",\"size\":" PRIu64 "}," - "\"systemRam\":{\"pointer\":\"%" PRIXPTR "\",\"size\":" PRIu64 "}," - "\"videoRam\":{\"pointer\":\"%" PRIXPTR "\",\"size\":" PRIu64 "},", + "\"saveRam\":{\"pointer\":\"%" PRIXPTR "\",\"size\":%" PRIu64 "}," + "\"rtcRam\":{\"pointer\":\"%" PRIXPTR "\",\"size\":%" PRIu64 "}," + "\"systemRam\":{\"pointer\":\"%" PRIXPTR "\",\"size\":%" PRIu64 "}," + "\"videoRam\":{\"pointer\":\"%" PRIXPTR "\",\"size\":%" PRIu64 "},", core_path, api.version, system->info.library_name, @@ -428,13 +428,13 @@ static int httpserver_handle_get_mmaps(struct mg_connection* conn, void* cbdata) mg_printf(conn, "%s{" "\"id\":%u," - "\"flags\":" PRIu64 "," + "\"flags\":%" PRIu64 "," "\"ptr\":\"%" PRIXPTR "\"," - "\"offset\":" PRIu64 "," - "\"start\":" PRIu64 "," - "\"select\":" PRIu64 "," - "\"disconnect\":" PRIu64 "," - "\"len\":" PRIu64 "," + "\"offset\":%" PRIu64 "," + "\"start\":%" PRIu64 "," + "\"select\":%" PRIu64 "," + "\"disconnect\":%" PRIu64 "," + "\"len\":%" PRIu64 "," "\"addrspace\":\"%s\"" "}", comma, From e21de200a65c905bb621343edc9de8f2283934a4 Mon Sep 17 00:00:00 2001 From: Alcaro Date: Mon, 27 Nov 2017 17:15:58 +0100 Subject: [PATCH 071/394] fix missing %s --- libretro-db/query.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/libretro-db/query.c b/libretro-db/query.c index 821b603032..9509de2ad0 100644 --- a/libretro-db/query.c +++ b/libretro-db/query.c @@ -289,7 +289,7 @@ struct registered_func registered_functions[100] = { static void query_raise_expected_number(ssize_t where, const char **error) { snprintf(tmp_error_buff, MAX_ERROR_LEN, - PRIu64 "::Expected number", + "%" PRIu64 "::Expected number", (uint64_t)where); *error = tmp_error_buff; } @@ -297,7 +297,7 @@ static void query_raise_expected_number(ssize_t where, const char **error) static void query_raise_expected_string(ssize_t where, const char ** error) { snprintf(tmp_error_buff, MAX_ERROR_LEN, - PRIu64 "::Expected string", + "%" PRIu64 "::Expected string", (uint64_t)where); *error = tmp_error_buff; } @@ -305,7 +305,7 @@ static void query_raise_expected_string(ssize_t where, const char ** error) static void query_raise_unexpected_eof(ssize_t where, const char ** error) { snprintf(tmp_error_buff, MAX_ERROR_LEN, - PRIu64 "::Unexpected EOF", + "%" PRIu64 "::Unexpected EOF", (uint64_t)where ); *error = tmp_error_buff; @@ -321,7 +321,7 @@ static void query_raise_unknown_function(ssize_t where, const char *name, ssize_t len, const char **error) { int n = snprintf(tmp_error_buff, MAX_ERROR_LEN, - PRIu64 "::Unknown function '", + "%" PRIu64 "::Unknown function '", (uint64_t)where ); @@ -336,7 +336,7 @@ static void query_raise_expected_eof( ssize_t where, char found, const char **error) { snprintf(tmp_error_buff, MAX_ERROR_LEN, - PRIu64 "::Expected EOF found '%c'", + "%" PRIu64 "::Expected EOF found '%c'", (uint64_t)where, found ); @@ -348,7 +348,7 @@ static void query_raise_unexpected_char( const char **error) { snprintf(tmp_error_buff, MAX_ERROR_LEN, - PRIu64 "::Expected '%c' found '%c'", + "%" PRIu64 "::Expected '%c' found '%c'", (uint64_t)where, expected, found); *error = tmp_error_buff; } From 6394e30cb53f0c3d1afb9396d72fd6aa56335d9d Mon Sep 17 00:00:00 2001 From: Alcaro Date: Mon, 27 Nov 2017 17:16:11 +0100 Subject: [PATCH 072/394] fix missing %s --- libretro-db/rmsgpack_dom.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libretro-db/rmsgpack_dom.c b/libretro-db/rmsgpack_dom.c index 48bde6e1d6..942282a17c 100644 --- a/libretro-db/rmsgpack_dom.c +++ b/libretro-db/rmsgpack_dom.c @@ -315,10 +315,10 @@ void rmsgpack_dom_value_print(struct rmsgpack_dom_value *obj) printf("false"); break; case RDT_INT: - printf(PRId64, (int64_t)obj->val.int_); + printf("%" PRId64, (int64_t)obj->val.int_); break; case RDT_UINT: - printf(PRIu64, (uint64_t)obj->val.uint_); + printf("%" PRIu64, (uint64_t)obj->val.uint_); break; case RDT_STRING: printf("\"%s\"", obj->val.string.buff); From a96e3e1ead02ca3df27e21cda15cabcc2aaf85ca Mon Sep 17 00:00:00 2001 From: Alcaro Date: Mon, 27 Nov 2017 17:16:22 +0100 Subject: [PATCH 073/394] fix missing %s --- libretro-common/file/config_file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libretro-common/file/config_file.c b/libretro-common/file/config_file.c index 3d3189dd86..70f7b64aab 100644 --- a/libretro-common/file/config_file.c +++ b/libretro-common/file/config_file.c @@ -892,7 +892,7 @@ void config_set_uint64(config_file_t *conf, const char *key, uint64_t val) char buf[128]; buf[0] = '\0'; - snprintf(buf, sizeof(buf), PRIu64, val); + snprintf(buf, sizeof(buf), "%" PRIu64, val); config_set_string(conf, key, buf); } From 00fd39c9a042cb81236e197672d6a6334edf414d Mon Sep 17 00:00:00 2001 From: Alcaro Date: Mon, 27 Nov 2017 17:16:38 +0100 Subject: [PATCH 074/394] fix missing %s --- menu/cbs/menu_cbs_get_value.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/menu/cbs/menu_cbs_get_value.c b/menu/cbs/menu_cbs_get_value.c index 25c9e1e5e6..7c42baa346 100644 --- a/menu/cbs/menu_cbs_get_value.c +++ b/menu/cbs/menu_cbs_get_value.c @@ -572,7 +572,7 @@ static void menu_action_setting_disp_set_label_perf_counters_common( return; snprintf(s, len, - PRIu64 " ticks, " PRIu64 " runs.", + "%" PRIu64 " ticks, %" PRIu64 " runs.", ((uint64_t)counters[offset]->total / (uint64_t)counters[offset]->call_cnt), (uint64_t)counters[offset]->call_cnt); From 4cc7cad454e69611c6f098883333c81382ac8410 Mon Sep 17 00:00:00 2001 From: Alcaro Date: Mon, 27 Nov 2017 17:17:07 +0100 Subject: [PATCH 075/394] fix missing %s --- menu/menu_displaylist.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 0006e7ef05..2622132870 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -834,21 +834,21 @@ static int menu_displaylist_parse_system_info(menu_displaylist_info_t *info) if (memory_used != 0 && memory_total != 0) { snprintf(tmp, sizeof(tmp), - "%s %s: " PRIu64 "/" PRIu64 " B", + "%s %s: %" PRIu64 "/%" PRIu64 " B", msg_hash_to_str(MSG_MEMORY), msg_hash_to_str(MSG_IN_BYTES), memory_used, memory_total ); snprintf(tmp2, sizeof(tmp2), - "%s %s: " PRIu64 "/" PRIu64 " MB", + "%s %s: %" PRIu64 "/%" PRIu64 " MB", msg_hash_to_str(MSG_MEMORY), msg_hash_to_str(MSG_IN_MEGABYTES), bytes_to_mb(memory_used), bytes_to_mb(memory_total) ); snprintf(tmp3, sizeof(tmp3), - "%s %s: " PRIu64 "/" PRIu64 " GB", + "%s %s: %" PRIu64 "/%" PRIu64 " GB", msg_hash_to_str(MSG_MEMORY), msg_hash_to_str(MSG_IN_GIGABYTES), bytes_to_gb(memory_used), From 34491a6025723c088b83532d67ac8a8427c39e55 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Mon, 27 Nov 2017 11:10:27 -0500 Subject: [PATCH 076/394] libusb: prevent crash on driver deinit when there are no pad connections --- input/drivers_hid/libusb_hid.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/input/drivers_hid/libusb_hid.c b/input/drivers_hid/libusb_hid.c index 357504e46b..d112a46f97 100644 --- a/input/drivers_hid/libusb_hid.c +++ b/input/drivers_hid/libusb_hid.c @@ -502,7 +502,8 @@ static void libusb_hid_free(void *data) sthread_join(hid->poll_thread); } - pad_connection_destroy(hid->slots); + if (hid->slots) + pad_connection_destroy(hid->slots); libusb_hotplug_deregister_callback(hid->ctx, hid->hp); From 28c6237b47c092c3e6694269de33b7af86a08906 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Wed, 22 Nov 2017 23:44:54 -0500 Subject: [PATCH 077/394] FreeBSD: support libusb hid input driver --- Makefile.common | 6 +++++- input/drivers_hid/libusb_hid.c | 14 ++++++++++++++ qb/config.libs.sh | 2 +- 3 files changed, 20 insertions(+), 2 deletions(-) diff --git a/Makefile.common b/Makefile.common index ace2a5c4a6..cac0ea4aaf 100644 --- a/Makefile.common +++ b/Makefile.common @@ -916,7 +916,11 @@ ifeq ($(HAVE_THREADS), 1) ifeq ($(HAVE_HID), 1) DEFINES += -DHAVE_LIBUSB OBJ += input/drivers_hid/libusb_hid.o - LIBS += -lusb-1.0 + ifneq ($(findstring BSD,$(OS)),) + LIBS += -lusb + else + LIBS += -lusb-1.0 + endif endif endif endif diff --git a/input/drivers_hid/libusb_hid.c b/input/drivers_hid/libusb_hid.c index d112a46f97..bc6ddb4d0e 100644 --- a/input/drivers_hid/libusb_hid.c +++ b/input/drivers_hid/libusb_hid.c @@ -16,7 +16,11 @@ #include #include +#ifdef __FreeBSD__ +#include +#else #include +#endif #include #include @@ -38,7 +42,11 @@ typedef struct libusb_hid libusb_context *ctx; joypad_connection_t *slots; sthread_t *poll_thread; +#if defined(__FreeBSD__) && LIBUSB_API_VERSION <= 0x01000102 + libusb_hotplug_callback_handle hp; +#else int hp; /* libusb_hotplug_callback_handle is just int */ +#endif int quit; } libusb_hid_t; @@ -538,8 +546,14 @@ static void *libusb_hid_init(void) if (ret < 0) goto error; +#if 0 + /* NOTE: In what situation could this possibly happen? + * Don't use it for now since it requires a newer API + * version than FreeBSD has. + */ if (!libusb_has_capability(LIBUSB_CAP_HAS_HOTPLUG)) goto error; +#endif hid->slots = pad_connection_init(MAX_USERS); diff --git a/qb/config.libs.sh b/qb/config.libs.sh index d93a6f2732..9d382ad36a 100644 --- a/qb/config.libs.sh +++ b/qb/config.libs.sh @@ -264,7 +264,7 @@ if [ "$HAVE_SDL2" = 'yes' ]; then fi fi -check_pkgconf LIBUSB libusb-1.0 1.0.16 +check_pkgconf LIBUSB libusb-1.0 1.0.13 if [ "$OS" = 'Win32' ]; then check_lib '' DINPUT -ldinput8 From 1f58d9cd1fecde033e709978a0ee69cb4527e456 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Mon, 27 Nov 2017 11:18:32 -0500 Subject: [PATCH 078/394] comment --- input/drivers_hid/libusb_hid.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/input/drivers_hid/libusb_hid.c b/input/drivers_hid/libusb_hid.c index bc6ddb4d0e..5d681a9947 100644 --- a/input/drivers_hid/libusb_hid.c +++ b/input/drivers_hid/libusb_hid.c @@ -547,9 +547,9 @@ static void *libusb_hid_init(void) goto error; #if 0 - /* NOTE: In what situation could this possibly happen? - * Don't use it for now since it requires a newer API - * version than FreeBSD has. + /* Don't use this for now since it requires a newer API + * version than FreeBSD has, and always returns false on Windows anyway. + * https://github.com/libusb/libusb/issues/86 */ if (!libusb_has_capability(LIBUSB_CAP_HAS_HOTPLUG)) goto error; From 61bd9d7d700de2a36b0ab82ac5ac6582ac0b24c4 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Mon, 27 Nov 2017 11:30:16 -0500 Subject: [PATCH 079/394] libusb: early return if we fail to get a config descriptor, otherwise the memory returned is invalid (and should not be freed either) --- input/drivers_hid/libusb_hid.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/input/drivers_hid/libusb_hid.c b/input/drivers_hid/libusb_hid.c index 5d681a9947..d0eb1250d7 100644 --- a/input/drivers_hid/libusb_hid.c +++ b/input/drivers_hid/libusb_hid.c @@ -165,7 +165,13 @@ static void libusb_get_description(struct libusb_device *device, unsigned i, k; struct libusb_config_descriptor *config; - libusb_get_config_descriptor(device, 0, &config); + int desc_ret = libusb_get_config_descriptor(device, 0, &config); + + if (desc_ret != 0) + { + RARCH_ERR("Error %d getting libusb config descriptor\n", desc_ret); + return; + } for (i = 0; i < (int)config->bNumInterfaces; i++) { @@ -208,11 +214,12 @@ static void libusb_get_description(struct libusb_device *device, } } } + goto ret; } } - ret: +ret: libusb_free_config_descriptor(config); } From 26008ca58074e483e1281c620c3f58d8b6301149 Mon Sep 17 00:00:00 2001 From: Alcaro Date: Mon, 27 Nov 2017 17:55:05 +0100 Subject: [PATCH 080/394] #5802 --- libretro-common/include/retro_common_api.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libretro-common/include/retro_common_api.h b/libretro-common/include/retro_common_api.h index 7be1affe29..ef0860bbad 100644 --- a/libretro-common/include/retro_common_api.h +++ b/libretro-common/include/retro_common_api.h @@ -75,13 +75,15 @@ typedef int ssize_t; #include #endif -#ifndef _WIN32 -#include -#else +#ifdef _MSC_VER +#ifndef PRId64 #define PRId64 "I64d" #define PRIu64 "I64u" #define PRIuPTR "Iu" #endif +#else +#include +#endif #define STRING_REP_INT64 "%" PRId64 #define STRING_REP_UINT64 "%" PRIu64 #define STRING_REP_USIZE "%" PRIuPTR From fadea3730fa786e4f9b64bea18bfc60ee7213d73 Mon Sep 17 00:00:00 2001 From: orbea Date: Mon, 27 Nov 2017 10:03:13 -0800 Subject: [PATCH 081/394] qb: Silence some shellcheck warnings. --- qb/qb.libs.sh | 23 +++++++++++++++-------- 1 file changed, 15 insertions(+), 8 deletions(-) diff --git a/qb/qb.libs.sh b/qb/qb.libs.sh index 0391a3bbc5..86868a3cfb 100644 --- a/qb/qb.libs.sh +++ b/qb/qb.libs.sh @@ -111,16 +111,19 @@ check_header() #$1 = HAVE_$1 $2..$5 = header files [ "$5" != '' ] && CHECKHEADER="$5" && printf %s\\n "#include <$5>" >> "$TEMP_C" printf %s\\n "int main(void) { return 0; }" >> "$TEMP_C" answer='no' - "$CC" -o "$TEMP_EXE" "$TEMP_C" $INCLUDE_DIRS >>config.log 2>&1 && answer='yes' - eval "HAVE_$1=\"$answer\"" + val="$1" + header="$2" + eval "set -- $INCLUDE_DIRS" + "$CC" -o "$TEMP_EXE" "$TEMP_C" "$@" >>config.log 2>&1 && answer='yes' + eval "HAVE_$val=\"$answer\"" printf %s\\n "Checking presence of header file $CHECKHEADER ... $answer" rm -f -- "$TEMP_C" "$TEMP_EXE" [ "$tmpval" = 'yes' ] && [ "$answer" = 'no' ] && \ - die 1 "Build assumed that $2 exists, but cannot locate. Exiting ..." + die 1 "Build assumed that $header exists, but cannot locate. Exiting ..." } -check_macro() #$1 = HAVE_$1 $2 = macro name -{ tmpval="$(eval echo \$HAVE_$1)" +check_macro() #$1 = HAVE_$1 $2 = macro name +{ tmpval="$(eval "printf %s \"\$HAVE_$1\"")" [ "$tmpval" = 'no' ] && return 0 ECHOBUF="Checking presence of predefined macro $2" cat << EOF > "$TEMP_C" @@ -130,11 +133,15 @@ check_macro() #$1 = HAVE_$1 $2 = macro name int main(void) { return 0; } EOF answer='no' - "$CC" -o "$TEMP_EXE" "$TEMP_C" $CFLAGS $INCLUDE_DIRS >>config.log 2>&1 && answer='yes' - eval HAVE_$1="$answer"; echo "$ECHOBUF ... $answer" + val="$1" + macro="$2" + eval "set -- $CFLAGS $INCLUDE_DIRS" + "$CC" -o "$TEMP_EXE" "$TEMP_C" "$@" >>config.log 2>&1 && answer='yes' + eval "HAVE_$val=\"$answer\"" + printf %s\\n "$ECHOBUF ... $answer" rm -f -- "$TEMP_C" "$TEMP_EXE" [ "$tmpval" = 'yes' ] && [ "$answer" = 'no' ] && \ - die 1 "Build assumed that $2 is defined, but it's not. Exiting ..." + die 1 "Build assumed that $macro is defined, but it's not. Exiting ..." } check_switch() # $1 = language $2 = HAVE_$2 $3 = switch $4 = critical error message [checked only if non-empty] From 4463c0c8158618d1549b1b17a0b6dce80eefbd06 Mon Sep 17 00:00:00 2001 From: orbea Date: Mon, 27 Nov 2017 13:25:20 -0800 Subject: [PATCH 082/394] qb: Make systemd support configurable. --- qb/config.params.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/qb/config.params.sh b/qb/config.params.sh index 34bd92590b..53612d047f 100644 --- a/qb/config.params.sh +++ b/qb/config.params.sh @@ -19,6 +19,7 @@ C89_SDL2=no HAVE_LIBUSB=auto # Libusb HID support C89_LIBUSB=no HAVE_DBUS=auto # dbus support +HAVE_SYSTEMD=auto # Systemd support HAVE_UDEV=auto # Udev/Evdev gamepad support HAVE_THREADS=auto # Threading support HAVE_THREAD_STORAGE=auto # Thread Local Storage support From 4f46402afb993336fa12a1421aec1515e0f9d14b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Zolt=C3=A1n=20Mizsei?= Date: Mon, 27 Nov 2017 22:22:49 +0100 Subject: [PATCH 083/394] Haiku build fix --- deps/miniupnpc/minissdpc.c | 4 ++-- deps/miniupnpc/portlistingparse.c | 10 +++++----- qb/config.libs.sh | 1 + 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/deps/miniupnpc/minissdpc.c b/deps/miniupnpc/minissdpc.c index c015298b97..6cf1570787 100644 --- a/deps/miniupnpc/minissdpc.c +++ b/deps/miniupnpc/minissdpc.c @@ -67,13 +67,13 @@ struct sockaddr_un { #define PRINT_SOCKET_ERROR(x) perror(x) #endif -#if !defined(__DragonFly__) && !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__APPLE__) && !defined(_WIN32) && !defined(__CYGWIN__) && !defined(__sun) && !defined(__GNU__) && !defined(__FreeBSD_kernel__) +#if !defined(__DragonFly__) && !defined(__OpenBSD__) && !defined(__NetBSD__) && !defined(__APPLE__) && !defined(_WIN32) && !defined(__CYGWIN__) && !defined(__sun) && !defined(__GNU__) && !defined(__FreeBSD_kernel__) && !defined(__HAIKU__) #define HAS_IP_MREQN #endif #if !defined(HAS_IP_MREQN) && !defined(_WIN32) #include -#if defined(__sun) +#if defined(__sun) || defined(__HAIKU__) #include #endif #endif diff --git a/deps/miniupnpc/portlistingparse.c b/deps/miniupnpc/portlistingparse.c index e864c0eb70..de596698aa 100644 --- a/deps/miniupnpc/portlistingparse.c +++ b/deps/miniupnpc/portlistingparse.c @@ -31,7 +31,7 @@ static const struct { /* Helper function */ static UNSIGNED_INTEGER -atoui(const char * p, int l) +my_atoui(const char * p, int l) { UNSIGNED_INTEGER r = 0; while(l > 0 && *p) @@ -106,7 +106,7 @@ static void portlisting_data(void * d, const char * data, int l) pm->remoteHost[l] = '\0'; break; case NewExternalPort: - pm->externalPort = (unsigned short)atoui(data, l); + pm->externalPort = (unsigned short)my_atoui(data, l); break; case NewProtocol: if(l > 3) @@ -115,21 +115,21 @@ static void portlisting_data(void * d, const char * data, int l) pm->protocol[l] = '\0'; break; case NewInternalPort: - pm->internalPort = (unsigned short)atoui(data, l); + pm->internalPort = (unsigned short)my_atoui(data, l); break; case NewInternalClient: memcpy(pm->internalClient, data, l); pm->internalClient[l] = '\0'; break; case NewEnabled: - pm->enabled = (unsigned char)atoui(data, l); + pm->enabled = (unsigned char)my_atoui(data, l); break; case NewDescription: memcpy(pm->description, data, l); pm->description[l] = '\0'; break; case NewLeaseTime: - pm->leaseTime = atoui(data, l); + pm->leaseTime = my_atoui(data, l); break; default: break; diff --git a/qb/config.libs.sh b/qb/config.libs.sh index 9d382ad36a..615c36853c 100644 --- a/qb/config.libs.sh +++ b/qb/config.libs.sh @@ -29,6 +29,7 @@ elif [ "$OS" = 'Haiku' ]; then CLIB=-lroot PTHREADLIB=-lroot SOCKETLIB=-lnetwork + CFLAGS="$CFLAGS -D_BSD_SOURCE" elif [ "$OS" = 'Win32' ]; then SOCKETLIB=-lws2_32 SOCKETHEADER="#include " From ab5fa130276cd2fa6f4a9bff0a889868df77db52 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Mon, 27 Nov 2017 17:42:12 -0500 Subject: [PATCH 084/394] some systems have lowercase drive letters --- Makefile.griffin | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Makefile.griffin b/Makefile.griffin index fccba281b4..0eaa721ead 100644 --- a/Makefile.griffin +++ b/Makefile.griffin @@ -334,7 +334,7 @@ else ifeq ($(platform), windows_msvc6_x86) PLATCFLAGS += -D_WIN32 -D_WIN32_WINNT=0x0351 -D__STDC_CONSTANT_MACROS -D_MBCS LDFLAGS += shell32.lib user32.lib gdi32.lib comdlg32.lib winmm.lib ole32.lib - VCDIR ?= $(shell reg query "HKLM\SOFTWARE\Wow6432Node\Microsoft\DevStudio\6.0\Products\Microsoft Visual C++" -v "ProductDir" | grep -o '[A-Z]:\\.*') + VCDIR ?= $(shell reg query "HKLM\SOFTWARE\Wow6432Node\Microsoft\DevStudio\6.0\Products\Microsoft Visual C++" -v "ProductDir" | grep -io '[A-Z]:\\.*') PATH := $(shell IFS=$$'\n'; cygpath "$(VCDIR)/bin"):$(PATH) PATH := $(PATH):$(shell IFS=$$'\n'; cygpath "$(VCDIR)/../Common/MSDev98/Bin") @@ -493,8 +493,8 @@ else ifneq (,$(findstring windows_msvc2010,$(platform))) PATH := $(PATH):$(shell IFS=$$'\n'; cygpath "$(VS100COMNTOOLS)../IDE") INCLUDE := $(shell IFS=$$'\n'; cygpath -w "$(VS100COMNTOOLS)../../VC/include") - WindowsSdkDir ?= $(shell reg query "HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A" -v "InstallationFolder" | grep -o '[A-Z]:\\.*') - WindowsSdkDir ?= $(shell reg query "HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1A" -v "InstallationFolder" | grep -o '[A-Z]:\\.*') + WindowsSdkDir ?= $(shell reg query "HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.0A" -v "InstallationFolder" | grep -io '[A-Z]:\\.*') + WindowsSdkDir ?= $(shell reg query "HKLM\SOFTWARE\Microsoft\Microsoft SDKs\Windows\v7.1A" -v "InstallationFolder" | grep -io '[A-Z]:\\.*') WindowsSdkDir := $(WindowsSdkDir:\=) ifeq ($(HAVE_DIRECTX), 1) @@ -568,7 +568,7 @@ else ifneq (,$(findstring windows_msvc2012,$(platform))) PATH := $(PATH):$(shell IFS=$$'\n'; cygpath "$(VS110COMNTOOLS)../IDE") INCLUDE := $(shell IFS=$$'\n'; cygpath -w "$(VS110COMNTOOLS)../../VC/include") - WindowsSdkDir ?= $(shell reg query "HKLM\SOFTWARE\Microsoft\Windows Kits\Installed Roots" -v "KitsRoot81" | grep -o '[A-Z]:\\.*') + WindowsSdkDir ?= $(shell reg query "HKLM\SOFTWARE\Microsoft\Windows Kits\Installed Roots" -v "KitsRoot81" | grep -io '[A-Z]:\\.*') WindowsSdkDir := $(WindowsSdkDir:\=) ifeq ($(HAVE_DIRECTX), 1) @@ -642,7 +642,7 @@ else ifneq (,$(findstring windows_msvc2013,$(platform))) PATH := $(PATH):$(shell IFS=$$'\n'; cygpath "$(VS120COMNTOOLS)../IDE") INCLUDE := $(shell IFS=$$'\n'; cygpath -w "$(VS120COMNTOOLS)../../VC/include") - WindowsSdkDir ?= $(shell reg query "HKLM\SOFTWARE\Microsoft\Windows Kits\Installed Roots" -v "KitsRoot81" | grep -o '[A-Z]:\\.*') + WindowsSdkDir ?= $(shell reg query "HKLM\SOFTWARE\Microsoft\Windows Kits\Installed Roots" -v "KitsRoot81" | grep -io '[A-Z]:\\.*') WindowsSdkDir := $(WindowsSdkDir:\=) ifeq ($(HAVE_DIRECTX), 1) From 82884b319b8315f08b2de38a15189722f0d3399f Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Mon, 27 Nov 2017 17:42:45 -0500 Subject: [PATCH 085/394] add missing UTF-8 BOMs back for MSVC --- intl/msg_hash_chs.h | 2 +- intl/msg_hash_cht.h | 2 +- intl/msg_hash_ja.h | 2 +- intl/msg_hash_ko.h | 2 +- intl/msg_hash_pl.c | 2 +- intl/msg_hash_ru.c | 2 +- intl/msg_hash_ru.h | 2 +- intl/msg_hash_vn.h | 2 +- 8 files changed, 8 insertions(+), 8 deletions(-) diff --git a/intl/msg_hash_chs.h b/intl/msg_hash_chs.h index 14bb988f19..8879be108e 100644 --- a/intl/msg_hash_chs.h +++ b/intl/msg_hash_chs.h @@ -1,4 +1,4 @@ -MSG_HASH( +MSG_HASH( MSG_COMPILER, "编译器" ) diff --git a/intl/msg_hash_cht.h b/intl/msg_hash_cht.h index 5a70c2d652..33c9c5947d 100644 --- a/intl/msg_hash_cht.h +++ b/intl/msg_hash_cht.h @@ -1,4 +1,4 @@ -MSG_HASH( +MSG_HASH( MSG_COMPILER, "編譯器" ) diff --git a/intl/msg_hash_ja.h b/intl/msg_hash_ja.h index 7d502db12d..c1087e8ede 100644 --- a/intl/msg_hash_ja.h +++ b/intl/msg_hash_ja.h @@ -1,4 +1,4 @@ -#if defined(_MSC_VER) && !defined(_XBOX) +#if defined(_MSC_VER) && !defined(_XBOX) /* https://support.microsoft.com/en-us/kb/980263 */ #pragma execution_character_set("utf-8") #endif diff --git a/intl/msg_hash_ko.h b/intl/msg_hash_ko.h index 8b6daaccfd..46c001d5aa 100644 --- a/intl/msg_hash_ko.h +++ b/intl/msg_hash_ko.h @@ -1,4 +1,4 @@ -MSG_HASH( +MSG_HASH( MSG_COMPILER, "컴파일러" ) diff --git a/intl/msg_hash_pl.c b/intl/msg_hash_pl.c index a20415a68d..6aceda10d8 100644 --- a/intl/msg_hash_pl.c +++ b/intl/msg_hash_pl.c @@ -1,4 +1,4 @@ -/* RetroArch - A frontend for libretro. +/* RetroArch - A frontend for libretro. * Copyright (C) 2011-2017 - Daniel De Matteis * * RetroArch is free software: you can redistribute it and/or modify it under the terms diff --git a/intl/msg_hash_ru.c b/intl/msg_hash_ru.c index 6bfec695cc..9a48e61b7e 100644 --- a/intl/msg_hash_ru.c +++ b/intl/msg_hash_ru.c @@ -1,4 +1,4 @@ -/* RetroArch - A frontend for libretro. +/* RetroArch - A frontend for libretro. * Copyright (C) 2011-2017 - Daniel De Matteis * * RetroArch is free software: you can redistribute it and/or modify it under the terms diff --git a/intl/msg_hash_ru.h b/intl/msg_hash_ru.h index 25d792c7eb..4eac6397c2 100644 --- a/intl/msg_hash_ru.h +++ b/intl/msg_hash_ru.h @@ -1,4 +1,4 @@ -#if defined(_MSC_VER) && !defined(_XBOX) +#if defined(_MSC_VER) && !defined(_XBOX) /* https://support.microsoft.com/en-us/kb/980263 */ #pragma execution_character_set("utf-8") #endif diff --git a/intl/msg_hash_vn.h b/intl/msg_hash_vn.h index 8be07e4d75..9c68ac8d89 100644 --- a/intl/msg_hash_vn.h +++ b/intl/msg_hash_vn.h @@ -1,4 +1,4 @@ -MSG_HASH( +MSG_HASH( MSG_COMPILER, "Compiler" ) From ae6892a89ae117e0c6e60abe6b4414a538966ec8 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Mon, 27 Nov 2017 17:48:07 -0500 Subject: [PATCH 086/394] nbio: buildfix for Windows versions older than 2000 --- libretro-common/file/nbio/nbio_windowsmmap.c | 27 +++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/libretro-common/file/nbio/nbio_windowsmmap.c b/libretro-common/file/nbio/nbio_windowsmmap.c index 42a22a16d6..caf0d72514 100644 --- a/libretro-common/file/nbio/nbio_windowsmmap.c +++ b/libretro-common/file/nbio/nbio_windowsmmap.c @@ -56,7 +56,11 @@ static void *nbio_mmap_win32_open(const char * filename, unsigned mode) { static const DWORD dispositions[] = { OPEN_EXISTING, CREATE_ALWAYS, OPEN_ALWAYS, OPEN_EXISTING, CREATE_ALWAYS }; HANDLE mem; +#if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0500 LARGE_INTEGER len; +#else + SIZE_T len; +#endif struct nbio_mmap_win32_t* handle = NULL; void* ptr = NULL; bool is_write = (mode == NBIO_WRITE || mode == NBIO_UPDATE || mode == BIO_WRITE); @@ -74,17 +78,28 @@ static void *nbio_mmap_win32_open(const char * filename, unsigned mode) if (file == INVALID_HANDLE_VALUE) return NULL; +#if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0500 + /* GetFileSizeEx is new for Windows 2000 */ GetFileSizeEx(file, &len); - mem = CreateFileMapping(file, NULL, is_write ? PAGE_READWRITE : PAGE_READONLY, 0, 0, NULL); ptr = MapViewOfFile(mem, is_write ? (FILE_MAP_READ|FILE_MAP_WRITE) : FILE_MAP_READ, 0, 0, len.QuadPart); +#else + GetFileSize(file, &len); + mem = CreateFileMapping(file, NULL, is_write ? PAGE_READWRITE : PAGE_READONLY, 0, 0, NULL); + ptr = MapViewOfFile(mem, is_write ? (FILE_MAP_READ|FILE_MAP_WRITE) : FILE_MAP_READ, 0, 0, len); +#endif + CloseHandle(mem); handle = (struct nbio_mmap_win32_t*)malloc(sizeof(struct nbio_mmap_win32_t)); handle->file = file; handle->is_write = is_write; +#if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0500 handle->len = len.QuadPart; +#else + handle->len = len; +#endif handle->ptr = ptr; return handle; @@ -108,7 +123,11 @@ static bool nbio_mmap_win32_iterate(void *data) static void nbio_mmap_win32_resize(void *data, size_t len) { +#if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0500 LARGE_INTEGER len_li; +#else + SIZE_T len_li; +#endif HANDLE mem; struct nbio_mmap_win32_t* handle = (struct nbio_mmap_win32_t*)data; @@ -125,8 +144,14 @@ static void nbio_mmap_win32_resize(void *data, size_t len) abort(); } +#if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0500 + /* SetFilePointerEx is new for Windows 2000 */ len_li.QuadPart = len; SetFilePointerEx(handle->file, len_li, NULL, FILE_BEGIN); +#else + len_li = len; + SetFilePointer(handle->file, len_li, NULL, FILE_BEGIN); +#endif if (!SetEndOfFile(handle->file)) { From 02cb0fc583448a27a82b62f910bb93593e0254d7 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Mon, 27 Nov 2017 19:43:07 -0500 Subject: [PATCH 087/394] griffin: add -DEBUG to linker flags for MSVC is building with DEBUG=1 --- Makefile.griffin | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile.griffin b/Makefile.griffin index 0eaa721ead..5e2217dd6e 100644 --- a/Makefile.griffin +++ b/Makefile.griffin @@ -833,6 +833,7 @@ ifeq ($(DEBUG), 1) endif CFLAGS += -Od -Zi -D_DEBUG -MTd -TP + LDFLAGS += -DEBUG else CFLAGS += -O0 -g -DDEBUG endif From 130203c431ad683b404747ff597ab33896a3699b Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Mon, 27 Nov 2017 20:49:56 -0500 Subject: [PATCH 088/394] gdi: fix closing window via X button --- gfx/drivers/gdi_gfx.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/gfx/drivers/gdi_gfx.c b/gfx/drivers/gdi_gfx.c index 59e18af6b8..b1ded17fdb 100644 --- a/gfx/drivers/gdi_gfx.c +++ b/gfx/drivers/gdi_gfx.c @@ -356,7 +356,8 @@ static bool gdi_gfx_alive(void *data) unsigned temp_height = 0; bool quit = false; bool resize = false; - + bool ret = false; + /* Needed because some context drivers don't track their sizes */ video_driver_get_size(&temp_width, &temp_height); @@ -365,12 +366,13 @@ static bool gdi_gfx_alive(void *data) size_data.width = &temp_width; size_data.height = &temp_height; - video_context_driver_check_window(&size_data); + if (video_context_driver_check_window(&size_data)) + ret = !quit; if (temp_width != 0 && temp_height != 0) video_driver_set_size(&temp_width, &temp_height); - return true; + return ret; } static bool gdi_gfx_focus(void *data) From 013d2eba40659befbbcf42f53e71235f84e7eaa8 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 28 Nov 2017 02:52:26 +0100 Subject: [PATCH 089/394] Fix Griffin build --- deps/miniupnpc/upnpcommands.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/deps/miniupnpc/upnpcommands.c b/deps/miniupnpc/upnpcommands.c index 25483c0c45..017c5cdce6 100644 --- a/deps/miniupnpc/upnpcommands.c +++ b/deps/miniupnpc/upnpcommands.c @@ -14,7 +14,7 @@ #include "portlistingparse.h" static UNSIGNED_INTEGER -my_atoui(const char * s) +my_custom_atoui(const char * s) { return s ? ((UNSIGNED_INTEGER)STRTOUI(s, NULL, 0)) : 0; } @@ -38,7 +38,7 @@ UPNP_GetTotalBytesSent(const char * controlURL, /*DisplayNameValueList(buffer, bufsize);*/ free(buffer); buffer = NULL; p = GetValueFromNameValueList(&pdata, "NewTotalBytesSent"); - r = (unsigned)my_atoui(p); + r = (unsigned)my_custom_atoui(p); ClearNameValueList(&pdata); return r; } @@ -62,7 +62,7 @@ UPNP_GetTotalBytesReceived(const char * controlURL, /*DisplayNameValueList(buffer, bufsize);*/ free(buffer); buffer = NULL; p = GetValueFromNameValueList(&pdata, "NewTotalBytesReceived"); - r = (unsigned)my_atoui(p); + r = (unsigned)my_custom_atoui(p); ClearNameValueList(&pdata); return r; } @@ -86,7 +86,7 @@ UPNP_GetTotalPacketsSent(const char * controlURL, /*DisplayNameValueList(buffer, bufsize);*/ free(buffer); buffer = NULL; p = GetValueFromNameValueList(&pdata, "NewTotalPacketsSent"); - r = (unsigned)my_atoui(p); + r = (unsigned)my_custom_atoui(p); ClearNameValueList(&pdata); return r; } @@ -110,7 +110,7 @@ UPNP_GetTotalPacketsReceived(const char * controlURL, /*DisplayNameValueList(buffer, bufsize);*/ free(buffer); buffer = NULL; p = GetValueFromNameValueList(&pdata, "NewTotalPacketsReceived"); - r = (unsigned)my_atoui(p); + r = (unsigned)my_custom_atoui(p); ClearNameValueList(&pdata); return r; } @@ -903,11 +903,11 @@ UPNP_GetFirewallStatus(const char * controlURL, if(ipa && fe) ret = UPNPCOMMAND_SUCCESS; if(fe) - *firewallEnabled = (int)my_atoui(fe); + *firewallEnabled = (int)my_custom_atoui(fe); /*else *firewallEnabled = 0;*/ if(ipa) - *inboundPinholeAllowed = (int)my_atoui(ipa); + *inboundPinholeAllowed = (int)my_custom_atoui(ipa); /*else *inboundPinholeAllowed = 0;*/ p = GetValueFromNameValueList(&pdata, "errorCode"); @@ -971,7 +971,7 @@ UPNP_GetOutboundPinholeTimeout(const char * controlURL, const char * servicetype ret = UPNPCOMMAND_SUCCESS; p = GetValueFromNameValueList(&pdata, "OutboundPinholeTimeout"); if(p) - *opTimeout = (int)my_atoui(p); + *opTimeout = (int)my_custom_atoui(p); } ClearNameValueList(&pdata); return ret; @@ -1175,7 +1175,7 @@ UPNP_CheckPinholeWorking(const char * controlURL, const char * servicetype, p = GetValueFromNameValueList(&pdata, "IsWorking"); if(p) { - *isWorking = (int)my_atoui(p); + *isWorking = (int)my_custom_atoui(p); ret = UPNPCOMMAND_SUCCESS; } else @@ -1222,7 +1222,7 @@ UPNP_GetPinholePackets(const char * controlURL, const char * servicetype, p = GetValueFromNameValueList(&pdata, "PinholePackets"); if(p) { - *packets = (int)my_atoui(p); + *packets = (int)my_custom_atoui(p); ret = UPNPCOMMAND_SUCCESS; } From 6ed5a911d7f87b4ed1676384602c04f72ff486df Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 28 Nov 2017 08:59:33 +0100 Subject: [PATCH 090/394] Create path_mkdir_error --- libretro-common/file/file_path.c | 31 +++++++++++++++++++------------ 1 file changed, 19 insertions(+), 12 deletions(-) diff --git a/libretro-common/file/file_path.c b/libretro-common/file/file_path.c index 1643b0d6cb..62ee9f20e7 100644 --- a/libretro-common/file/file_path.c +++ b/libretro-common/file/file_path.c @@ -219,6 +219,17 @@ int32_t path_get_size(const char *path) return -1; } +static bool path_mkdir_error(int ret) +{ +#if defined(VITA) + return (ret == SCE_ERROR_ERRNO_EEXIST); +#elif defined(PSP) || defined(_3DS) || defined(WIIU) + return (ret == -1); +#else + return (ret < 0 && errno == EEXIST); +#endif +} + /** * path_mkdir: * @dir : directory @@ -230,10 +241,13 @@ int32_t path_get_size(const char *path) bool path_mkdir(const char *dir) { /* Use heap. Real chance of stack overflow if we recurse too hard. */ - char *basedir = strdup(dir); const char *target = NULL; bool sret = false; bool norecurse = false; + char *basedir = NULL; + + if (dir && *dir) + basedir = strdup(dir); if (!basedir) return false; @@ -249,8 +263,8 @@ bool path_mkdir(const char *dir) } else { - target = basedir; - sret = path_mkdir(basedir); + target = basedir; + sret = path_mkdir(basedir); if (sret) { @@ -274,16 +288,9 @@ bool path_mkdir(const char *dir) #endif /* Don't treat this as an error. */ -#if defined(VITA) - if ((ret == SCE_ERROR_ERRNO_EEXIST) && path_is_directory(dir)) + if (path_mkdir_error(ret) && path_is_directory(dir)) ret = 0; -#elif defined(PSP) || defined(_3DS) || defined(WIIU) - if ((ret == -1) && path_is_directory(dir)) - ret = 0; -#else - if (ret < 0 && errno == EEXIST && path_is_directory(dir)) - ret = 0; -#endif + if (ret < 0) printf("mkdir(%s) error: %s.\n", dir, strerror(errno)); sret = (ret == 0); From c5bdc02d6ff926c153ff29e5f9496e8dd8cde958 Mon Sep 17 00:00:00 2001 From: David Walters Date: Tue, 28 Nov 2017 10:04:34 +0000 Subject: [PATCH 091/394] replace uint64_t with retro_bits_t* for pad buttons state --- input/connect/connect_nesusb.c | 22 ++--- input/connect/connect_ps2adapter.c | 22 ++--- input/connect/connect_ps3.c | 24 +++-- input/connect/connect_ps4.c | 75 +++++++++++----- input/connect/connect_psxadapter.c | 44 ++++----- input/connect/connect_snesusb.c | 26 +++--- input/connect/connect_wii.c | 34 +++---- input/connect/connect_wiiugca.c | 15 ++-- input/connect/connect_wiiupro.c | 88 ++++++++++++------ input/connect/joypad_connection.c | 18 ++-- input/connect/joypad_connection.h | 7 +- input/drivers_hid/btstack_hid.c | 118 +++++++++++++------------ input/drivers_hid/iohidmanager_hid.c | 24 ++--- input/drivers_hid/libusb_hid.c | 71 ++++++--------- input/drivers_hid/null_hid.c | 6 +- input/drivers_hid/wiiusb_hid.c | 30 ++++--- input/drivers_joypad/ctr_joypad.c | 40 +++++---- input/drivers_joypad/gx_joypad.c | 12 ++- input/drivers_joypad/hid_joypad.c | 14 +-- input/drivers_joypad/linuxraw_joypad.c | 30 ++++--- input/drivers_joypad/mfi_joypad.m | 4 +- input/drivers_joypad/null_joypad.c | 4 +- input/drivers_joypad/parport_joypad.c | 30 ++++--- input/drivers_joypad/ps3_joypad.c | 12 ++- input/drivers_joypad/psp_joypad.c | 16 ++-- input/drivers_joypad/udev_joypad.c | 22 +++-- input/drivers_joypad/wiiu_joypad.c | 8 +- input/drivers_joypad/xdk_joypad.c | 20 +++-- input/input_defines.h | 27 +++++- input/input_driver.h | 58 ++++-------- 30 files changed, 520 insertions(+), 401 deletions(-) diff --git a/input/connect/connect_nesusb.c b/input/connect/connect_nesusb.c index 04b24d6746..24c5f0532e 100644 --- a/input/connect/connect_nesusb.c +++ b/input/connect/connect_nesusb.c @@ -27,7 +27,7 @@ struct hidpad_nesusb_data struct pad_connection* connection; uint8_t data[64]; uint32_t slot; - uint64_t buttons; + uint32_t buttons; }; static void* hidpad_nesusb_init(void *data, uint32_t slot, send_control_t ptr) @@ -59,12 +59,14 @@ static void hidpad_nesusb_deinit(void *data) free(device); } -static uint64_t hidpad_nesusb_get_buttons(void *data) +static void hidpad_nesusb_get_buttons(void *data, retro_bits_t* state) { - struct hidpad_nesusb_data *device = (struct hidpad_nesusb_data*)data; - if (!device) - return 0; - return device->buttons; + struct hidpad_nesusb_data *device = (struct hidpad_nesusb_data*)data; + if (device) { + RARCH_INPUT_STATE_COPY16_PTR(state, device->buttons); + } else { + RARCH_INPUT_STATE_CLEAR_PTR(state); + } } static int16_t hidpad_nesusb_get_axis(void *data, unsigned axis) @@ -102,7 +104,6 @@ static void hidpad_nesusb_packet_handler(void *data, uint8_t *packet, uint16_t s RETRO_DEVICE_ID_JOYPAD_A, RETRO_DEVICE_ID_JOYPAD_Y, RETRO_DEVICE_ID_JOYPAD_X, - 16, /* HOME BUTTON when pressing SELECT+START */ }; struct hidpad_nesusb_data *device = (struct hidpad_nesusb_data*)data; @@ -113,12 +114,11 @@ static void hidpad_nesusb_packet_handler(void *data, uint8_t *packet, uint16_t s device->buttons = 0; - pressed_keys = device->data[7] | (device->data[6] << 8) | - (((device->data[7] & 0x30) == 0x30) ? (1 << 16) : 0); /* SELECT+START=HOME */ + pressed_keys = device->data[7] | (device->data[6] << 8); - for (i = 0; i < 17; i ++) + for (i = 0; i < 16; i ++) if (button_mapping[i] != NO_BTN) - device->buttons |= (pressed_keys & (1 << i)) ? (UINT64_C(1) << button_mapping[i]) : 0; + device->buttons |= (pressed_keys & (1 << i)) ? (1 << button_mapping[i]) : 0; } static void hidpad_nesusb_set_rumble(void *data, diff --git a/input/connect/connect_ps2adapter.c b/input/connect/connect_ps2adapter.c index 10c922b66c..78c3cf9c92 100644 --- a/input/connect/connect_ps2adapter.c +++ b/input/connect/connect_ps2adapter.c @@ -27,7 +27,7 @@ struct hidpad_ps2adapter_data struct pad_connection* connection; uint8_t data[64]; uint32_t slot; - uint64_t buttons; + uint32_t buttons; }; static void* hidpad_ps2adapter_init(void *data, uint32_t slot, send_control_t ptr) @@ -59,12 +59,14 @@ static void hidpad_ps2adapter_deinit(void *data) free(device); } -static uint64_t hidpad_ps2adapter_get_buttons(void *data) +static void hidpad_ps2adapter_get_buttons(void *data, retro_bits_t *state) { - struct hidpad_ps2adapter_data *device = (struct hidpad_ps2adapter_data*)data; - if (!device) - return 0; - return device->buttons; + struct hidpad_ps2adapter_data *device = (struct hidpad_ps2adapter_data*)data; + if ( device ) { + RARCH_INPUT_STATE_COPY16_PTR(state, device->buttons); + } else { + RARCH_INPUT_STATE_CLEAR_PTR(state); + } } static int16_t hidpad_ps2adapter_get_axis(void *data, unsigned axis) @@ -74,7 +76,7 @@ static int16_t hidpad_ps2adapter_get_axis(void *data, unsigned axis) if (!device || axis >= 4) return 0; - + switch (axis) { case 0: @@ -90,7 +92,7 @@ static int16_t hidpad_ps2adapter_get_axis(void *data, unsigned axis) val = device->data[2]; break; } - + val = (val << 8) - 0x8000; return (abs(val) > 0x1000) ? val : 0; @@ -133,7 +135,7 @@ static void hidpad_ps2adapter_packet_handler(void *data, uint8_t *packet, uint16 /* Check if the data corresponds to the first controller, exit otherwise */ if (packet[1] != 1) return; - + memcpy(device->data, packet, size); device->buttons = 0; @@ -143,7 +145,7 @@ static void hidpad_ps2adapter_packet_handler(void *data, uint8_t *packet, uint16 for (i = 0; i < 16; i ++) if (button_mapping[i] != NO_BTN) device->buttons |= (pressed_keys & (1 << i)) ? (UINT64_C(1) << button_mapping[i]) : 0; - + /* Now process the hat values as if they were pad buttons */ hat_value = PS2_H_GET(device->data[6]); device->buttons |= PS2_H_LEFT(hat_value) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_LEFT) : 0; diff --git a/input/connect/connect_ps3.c b/input/connect/connect_ps3.c index 37ca54b8d2..422a1b02a2 100644 --- a/input/connect/connect_ps3.c +++ b/input/connect/connect_ps3.c @@ -20,6 +20,7 @@ #include #include "joypad_connection.h" +#include "../input_defines.h" struct hidpad_ps3_data { @@ -27,7 +28,7 @@ struct hidpad_ps3_data send_control_t send_control; uint8_t data[512]; uint32_t slot; - uint64_t buttons; + uint32_t buttons; bool have_led; uint16_t motors[2]; }; @@ -104,12 +105,23 @@ static void hidpad_ps3_deinit(void *data) free(device); } -static uint64_t hidpad_ps3_get_buttons(void *data) +static void hidpad_ps3_get_buttons(void *data, retro_bits_t *state) { - struct hidpad_ps3_data *device = (struct hidpad_ps3_data*)data; - if (!device) - return 0; - return device->buttons; + struct hidpad_ps3_data *device = (struct hidpad_ps3_data*)data; + if ( device ) + { + /*copy first 16 bits - standard RetroPad controls*/ + RARCH_INPUT_STATE_COPY16_PTR(state, device->buttons); + + /*PS button?*/ + if ( device->buttons & 0x10000 ) { + RARCH_INPUT_STATE_BIT_SET_PTR( state, RARCH_MENU_TOGGLE ); + } + } + else + { + RARCH_INPUT_STATE_CLEAR_PTR( state ); + } } static int16_t hidpad_ps3_get_axis(void *data, unsigned axis) diff --git a/input/connect/connect_ps4.c b/input/connect/connect_ps4.c index 198107842f..36965eed41 100644 --- a/input/connect/connect_ps4.c +++ b/input/connect/connect_ps4.c @@ -184,35 +184,66 @@ static bool hidpad_ps4_check_dpad(struct ps4 *rpt, unsigned id) return false; } -static uint64_t hidpad_ps4_get_buttons(void *data) +static void hidpad_ps4_get_buttons(void *data, retro_bits_t* state) { uint64_t buttonstate = 0; struct hidpad_ps4_data *device = (struct hidpad_ps4_data*)data; struct ps4 *rpt = device ? (struct ps4*)&device->data : NULL; if (!device || !rpt) - return 0; + return; - buttonstate |= (rpt->btn.r3 ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_R3) : 0); - buttonstate |= (rpt->btn.l3 ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_L3) : 0); - buttonstate |= (rpt->btn.options ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_START) : 0); - buttonstate |= (rpt->btn.share ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_SELECT) : 0); - buttonstate |= (rpt->btn.r2 ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_R2) : 0); - buttonstate |= (rpt->btn.l2 ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_L2) : 0); - buttonstate |= (rpt->btn.r1 ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_R) : 0); - buttonstate |= (rpt->btn.l1 ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_L) : 0); - - buttonstate |= (rpt->btn.triangle ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_X) : 0); - buttonstate |= (rpt->btn.circle ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_A) : 0); - buttonstate |= (rpt->btn.cross ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_B) : 0); - buttonstate |= (rpt->btn.square ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_Y) : 0); - buttonstate |= ((hidpad_ps4_check_dpad(rpt, RETRO_DEVICE_ID_JOYPAD_LEFT)) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_LEFT) : 0); - buttonstate |= ((hidpad_ps4_check_dpad(rpt, RETRO_DEVICE_ID_JOYPAD_DOWN)) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_DOWN) : 0); - buttonstate |= ((hidpad_ps4_check_dpad(rpt, RETRO_DEVICE_ID_JOYPAD_RIGHT)) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_RIGHT) : 0); - buttonstate |= ((hidpad_ps4_check_dpad(rpt, RETRO_DEVICE_ID_JOYPAD_UP)) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_UP) : 0); - buttonstate |= (rpt->btn.ps ? (UINT64_C(1) << RARCH_MENU_TOGGLE) : 0); - - return buttonstate; + if ( rpt->btn.r3 ) { + RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_R3 ); + } + if ( rpt->btn.l3 ) { + RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_L3 ); + } + if ( rpt->btn.options ) { + RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_START ); + } + if ( rpt->btn.share ) { + RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_SELECT ); + } + if ( rpt->btn.r2 ) { + RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_R2 ); + } + if ( rpt->btn.l2 ) { + RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_L2 ); + } + if ( rpt->btn.r1 ) { + RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_R ); + } + if ( rpt->btn.l1 ) { + RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_L ); + } + if ( rpt->btn.triangle ) { + RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_X ); + } + if ( rpt->btn.circle ) { + RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_A ); + } + if ( rpt->btn.cross ) { + RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_B ); + } + if ( rpt->btn.square ) { + RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_Y ); + } + if ( (hidpad_ps4_check_dpad(rpt, RETRO_DEVICE_ID_JOYPAD_LEFT)) ) { + RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_LEFT ); + } + if ( (hidpad_ps4_check_dpad(rpt, RETRO_DEVICE_ID_JOYPAD_DOWN)) ) { + RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_DOWN ); + } + if ( (hidpad_ps4_check_dpad(rpt, RETRO_DEVICE_ID_JOYPAD_RIGHT)) ) { + RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_RIGHT ); + } + if ( (hidpad_ps4_check_dpad(rpt, RETRO_DEVICE_ID_JOYPAD_UP)) ) { + RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_UP ); + } + if ( rpt->btn.ps ) { + RARCH_INPUT_STATE_BIT_SET_PTR( state, RARCH_MENU_TOGGLE ); + } } static int16_t hidpad_ps4_get_axis(void *data, unsigned axis) diff --git a/input/connect/connect_psxadapter.c b/input/connect/connect_psxadapter.c index d05bfc3793..6f77e77f72 100644 --- a/input/connect/connect_psxadapter.c +++ b/input/connect/connect_psxadapter.c @@ -27,7 +27,7 @@ struct hidpad_psxadapter_data struct pad_connection* connection; uint8_t data[64]; uint32_t slot; - uint64_t buttons; + uint32_t buttons; }; static void* hidpad_psxadapter_init(void *data, uint32_t slot, send_control_t ptr) @@ -59,12 +59,14 @@ static void hidpad_psxadapter_deinit(void *data) free(device); } -static uint64_t hidpad_psxadapter_get_buttons(void *data) +static void hidpad_psxadapter_get_buttons(void *data, retro_bits_t *state) { - struct hidpad_psxadapter_data *device = (struct hidpad_psxadapter_data*)data; - if (!device) - return 0; - return device->buttons; + struct hidpad_psxadapter_data *device = (struct hidpad_psxadapter_data*)data; + if ( device ) { + RARCH_INPUT_STATE_COPY16_PTR(state, device->buttons); + } else { + RARCH_INPUT_STATE_CLEAR_PTR(state); + } } static int16_t hidpad_psxadapter_get_axis(void *data, unsigned axis) @@ -75,7 +77,7 @@ static int16_t hidpad_psxadapter_get_axis(void *data, unsigned axis) if (!device || axis >= 4 || (device->data[2]==0x7F) ) /* digital mode detection */ return 0; - + switch (axis) { case 0: @@ -91,7 +93,7 @@ static int16_t hidpad_psxadapter_get_axis(void *data, unsigned axis) val = device->data[2]; break; } - + val = (val << 8) - 0x8000; return (abs(val) > 0x1000) ? val : 0; /* hard coded deadzone */ @@ -107,7 +109,7 @@ static void hidpad_psxadapter_packet_handler(void *data, uint8_t *packet, uint16 { uint32_t i, pressed_keys; int16_t hat_value; - static const uint32_t button_mapping[17] = + static const uint32_t button_mapping[16] = { RETRO_DEVICE_ID_JOYPAD_L2, RETRO_DEVICE_ID_JOYPAD_R2, @@ -125,7 +127,6 @@ static void hidpad_psxadapter_packet_handler(void *data, uint8_t *packet, uint16 RETRO_DEVICE_ID_JOYPAD_A, RETRO_DEVICE_ID_JOYPAD_B, RETRO_DEVICE_ID_JOYPAD_Y, - 16/* HOME BUTTON when pressing SELECT+START */ }; struct hidpad_psxadapter_data *device = (struct hidpad_psxadapter_data*)data; @@ -136,29 +137,28 @@ static void hidpad_psxadapter_packet_handler(void *data, uint8_t *packet, uint16 device->buttons = 0; - pressed_keys = device->data[7] | (device->data[6] << 8) | - (((device->data[7] & 0x30) == 0x30) ? (1 << 16) : 0); /* SELECT+START = MENU TOGGLE */ + pressed_keys = device->data[7] | (device->data[6] << 8); - for (i = 0; i < 17; i ++) + for (i = 0; i < 16; i ++) if (button_mapping[i] != NO_BTN) - device->buttons |= (pressed_keys & (1 << i)) ? (UINT64_C(1) << button_mapping[i]) : 0; + device->buttons |= (pressed_keys & (1 << i)) ? (1 << button_mapping[i]) : 0; if (device->data[2]==0x7F) /* digital mode detection */ { /* We're in digital mode, process the dpad values */ - device->buttons |= (device->data[4]==0x00) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_LEFT) : 0; - device->buttons |= (device->data[4]==0xFF) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_RIGHT) : 0; - device->buttons |= (device->data[5]==0x00) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_UP) : 0; - device->buttons |= (device->data[5]==0xFF) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_DOWN) : 0; + device->buttons |= (device->data[4]==0x00) ? (1 << RETRO_DEVICE_ID_JOYPAD_LEFT) : 0; + device->buttons |= (device->data[4]==0xFF) ? (1 << RETRO_DEVICE_ID_JOYPAD_RIGHT) : 0; + device->buttons |= (device->data[5]==0x00) ? (1 << RETRO_DEVICE_ID_JOYPAD_UP) : 0; + device->buttons |= (device->data[5]==0xFF) ? (1 << RETRO_DEVICE_ID_JOYPAD_DOWN) : 0; } else { /* We're in analog mode, process the hat values as if they were pad buttons */ hat_value = PSX_H_GET(device->data[6]); - device->buttons |= PSX_H_LEFT(hat_value) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_LEFT) : 0; - device->buttons |= PSX_H_RIGHT(hat_value) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_RIGHT) : 0; - device->buttons |= PSX_H_UP(hat_value) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_UP) : 0; - device->buttons |= PSX_H_DOWN(hat_value) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_DOWN) : 0; + device->buttons |= PSX_H_LEFT(hat_value) ? (1 << RETRO_DEVICE_ID_JOYPAD_LEFT) : 0; + device->buttons |= PSX_H_RIGHT(hat_value) ? (1 << RETRO_DEVICE_ID_JOYPAD_RIGHT) : 0; + device->buttons |= PSX_H_UP(hat_value) ? (1 << RETRO_DEVICE_ID_JOYPAD_UP) : 0; + device->buttons |= PSX_H_DOWN(hat_value) ? (1 << RETRO_DEVICE_ID_JOYPAD_DOWN) : 0; } } diff --git a/input/connect/connect_snesusb.c b/input/connect/connect_snesusb.c index d5cc9e2811..bbc9fb43a4 100644 --- a/input/connect/connect_snesusb.c +++ b/input/connect/connect_snesusb.c @@ -28,7 +28,7 @@ struct hidpad_snesusb_data struct pad_connection* connection; uint8_t data[64]; uint32_t slot; - uint64_t buttons; + uint32_t buttons; }; static void* hidpad_snesusb_init(void *data, uint32_t slot, send_control_t ptr) @@ -60,12 +60,14 @@ static void hidpad_snesusb_deinit(void *data) free(device); } -static uint64_t hidpad_snesusb_get_buttons(void *data) +static void hidpad_snesusb_get_buttons(void *data, retro_bits_t *state) { - struct hidpad_snesusb_data *device = (struct hidpad_snesusb_data*)data; - if (!device) - return 0; - return device->buttons; + struct hidpad_snesusb_data *device = (struct hidpad_snesusb_data*)data; + if ( device ) { + RARCH_INPUT_STATE_COPY16_PTR(state, device->buttons); + } else { + RARCH_INPUT_STATE_CLEAR_PTR(state); + } } static int16_t hidpad_snesusb_get_axis(void *data, unsigned axis) @@ -85,7 +87,7 @@ static int16_t hidpad_snesusb_get_axis(void *data, unsigned axis) static void hidpad_snesusb_packet_handler(void *data, uint8_t *packet, uint16_t size) { uint32_t i, pressed_keys; - static const uint32_t button_mapping[17] = + static const uint32_t button_mapping[16] = { RETRO_DEVICE_ID_JOYPAD_L, RETRO_DEVICE_ID_JOYPAD_R, @@ -102,8 +104,7 @@ static void hidpad_snesusb_packet_handler(void *data, uint8_t *packet, uint16_t RETRO_DEVICE_ID_JOYPAD_X, RETRO_DEVICE_ID_JOYPAD_A, RETRO_DEVICE_ID_JOYPAD_B, - RETRO_DEVICE_ID_JOYPAD_Y, - 16, /* HOME BUTTON when pressing SELECT+START */ + RETRO_DEVICE_ID_JOYPAD_Y }; struct hidpad_snesusb_data *device = (struct hidpad_snesusb_data*)data; @@ -114,12 +115,11 @@ static void hidpad_snesusb_packet_handler(void *data, uint8_t *packet, uint16_t device->buttons = 0; - pressed_keys = device->data[7] | (device->data[6] << 8) | - (((device->data[7] & 0x30) == 0x30) ? (1 << 16) : 0); /* SELECT+START = MENU TOGGLE */ + pressed_keys = device->data[7] | (device->data[6] << 8); - for (i = 0; i < 17; i ++) + for (i = 0; i < 16; i ++) if (button_mapping[i] != NO_BTN) - device->buttons |= (pressed_keys & (1 << i)) ? (UINT64_C(1) << button_mapping[i]) : 0; + device->buttons |= (pressed_keys & (1 << i)) ? (1 << button_mapping[i]) : 0; } static void hidpad_snesusb_set_rumble(void *data, diff --git a/input/connect/connect_wii.c b/input/connect/connect_wii.c index dcf342a5f1..ec4ceaaa72 100644 --- a/input/connect/connect_wii.c +++ b/input/connect/connect_wii.c @@ -25,6 +25,7 @@ #include #include "joypad_connection.h" +#include "../input_defines.h" /* wiimote state flags*/ #define WIIMOTE_STATE_DEV_FOUND 0x0001 @@ -198,7 +199,7 @@ static int wiimote_send(struct connect_wii_wiimote_t* wm, return 1; } -/* +/* * Request the wiimote controller status. * * Controller status includes: battery level, LED status, expansions. @@ -426,13 +427,13 @@ static int wiimote_handshake(struct connect_wii_wiimote_t* wm, switch (wm->handshake_state) { case 0: - /* no ha habido nunca handshake, debemos forzar un + /* no ha habido nunca handshake, debemos forzar un * mensaje de staus para ver que pasa. */ WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_HANDSHAKE); wiimote_set_leds(wm, WIIMOTE_LED_NONE); - /* Request the status of the Wiimote to + /* Request the status of the Wiimote to * see if there is an expansion */ wiimote_status(wm); @@ -440,16 +441,16 @@ static int wiimote_handshake(struct connect_wii_wiimote_t* wm, return 0; case 1: { - /* estamos haciendo handshake o bien se necesita iniciar un + /* estamos haciendo handshake o bien se necesita iniciar un * nuevo handshake ya que se inserta(quita una expansion. */ int attachment = 0; if(event != WM_RPT_CTRL_STATUS) return 0; - /* Is an attachment connected to + /* Is an attachment connected to * the expansion port? */ - if ((data[2] & WM_CTRL_STATUS_BYTE1_ATTACHMENT) == + if ((data[2] & WM_CTRL_STATUS_BYTE1_ATTACHMENT) == WM_CTRL_STATUS_BYTE1_ATTACHMENT) attachment = 1; @@ -473,19 +474,19 @@ static int wiimote_handshake(struct connect_wii_wiimote_t* wm, /* Rehandshake. */ WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_HANDSHAKE_COMPLETE); - /* forzamos un handshake por si venimos + /* forzamos un handshake por si venimos * de un hanshake completo. */ WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_HANDSHAKE); } - /*Old way. initialize the extension was by writing the + /*Old way. initialize the extension was by writing the * single encryption byte 0x00 to 0x(4)A40040. */ #if 0 buf = 0x00; wiimote_write_data(wm, WM_EXP_MEM_ENABLE, &buf, 1); #endif - /* NEW WAY 0x55 to 0x(4)A400F0, then writing + /* NEW WAY 0x55 to 0x(4)A400F0, then writing * 0x00 to 0x(4)A400FB. (support clones) */ buf = 0x55; wiimote_write_data(wm, 0x04A400F0, &buf, 1); @@ -515,7 +516,7 @@ static int wiimote_handshake(struct connect_wii_wiimote_t* wm, printf("rehandshake\n"); #endif WIIMOTE_DISABLE_STATE(wm, WIIMOTE_STATE_HANDSHAKE_COMPLETE); - /* forzamos un handshake por si venimos + /* forzamos un handshake por si venimos * de un hanshake completo. */ WIIMOTE_ENABLE_STATE(wm, WIIMOTE_STATE_HANDSHAKE); } @@ -671,12 +672,15 @@ static int16_t hidpad_wii_get_axis(void *data, unsigned axis) return 0; } -static uint64_t hidpad_wii_get_buttons(void *data) +static void hidpad_wii_get_buttons(void *data, retro_bits_t *state) { - struct connect_wii_wiimote_t* device = (struct connect_wii_wiimote_t*)data; - if (!device) - return 0; - return device->btns | (device->exp.cc.classic.btns << 16); + struct connect_wii_wiimote_t* device = (struct connect_wii_wiimote_t*)data; + if ( device ) + { + uint32_t b; + b = device->btns | (device->exp.cc.classic.btns << 16); /*broken? this doesn't match retropad!!*/ + RARCH_INPUT_STATE_COPY32_PTR(state, b); + } } static void hidpad_wii_packet_handler(void *data, diff --git a/input/connect/connect_wiiugca.c b/input/connect/connect_wiiugca.c index 8f1368fdd7..0f368e01fe 100644 --- a/input/connect/connect_wiiugca.c +++ b/input/connect/connect_wiiugca.c @@ -20,6 +20,7 @@ #include #include "joypad_connection.h" +#include "../input_defines.h" struct hidpad_wiiugca_data { @@ -27,7 +28,7 @@ struct hidpad_wiiugca_data send_control_t send_control; uint8_t data[64]; uint32_t slot; - uint64_t buttons; + uint32_t buttons; }; static void* hidpad_wiiugca_init(void *data, uint32_t slot, send_control_t ptr) @@ -62,12 +63,14 @@ static void hidpad_wiiugca_deinit(void *data) free(device); } -static uint64_t hidpad_wiiugca_get_buttons(void *data) +static void hidpad_wiiugca_get_buttons(void *data, retro_bits_t *state) { - struct hidpad_wiiugca_data *device = (struct hidpad_wiiugca_data*)data; - if (!device) - return 0; - return device->buttons; + struct hidpad_wiiugca_data *device = (struct hidpad_wiiugca_data*)data; + if ( device ) { + RARCH_INPUT_STATE_COPY16_PTR(state, device->buttons); + } else { + RARCH_INPUT_STATE_CLEAR_PTR(state); + } } static int16_t hidpad_wiiugca_get_axis(void *data, unsigned axis) diff --git a/input/connect/connect_wiiupro.c b/input/connect/connect_wiiupro.c index 05d36c240f..408944ad87 100644 --- a/input/connect/connect_wiiupro.c +++ b/input/connect/connect_wiiupro.c @@ -97,7 +97,7 @@ static void* hidpad_wiiupro_init(void *data, device->connection = connection; device->slot = slot; device->send_control = ptr; - + calib_data->calib_round = 0; /* Without this, the digital buttons won't be reported. */ hidpad_wiiupro_send_control(device); @@ -118,35 +118,65 @@ static void hidpad_wiiupro_deinit(void *data) free(device); } -static uint64_t hidpad_wiiupro_get_buttons(void *data) +static void hidpad_wiiupro_get_buttons(void *data, retro_bits_t *state) { - uint64_t buttonstate = 0; struct hidpad_wiiupro_data *device = (struct hidpad_wiiupro_data*)data; struct wiiupro *rpt = device ? (struct wiiupro*)&device->data : NULL; if (!device || !rpt) - return 0; + return; - buttonstate |= (rpt->btn.r3 ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_R3) : 0); - buttonstate |= (rpt->btn.l3 ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_L3) : 0); - buttonstate |= (rpt->btn.plus ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_START) : 0); - buttonstate |= (rpt->btn.minus ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_SELECT) : 0); - buttonstate |= (rpt->btn.zr ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_R2) : 0); - buttonstate |= (rpt->btn.zl ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_L2) : 0); - buttonstate |= (rpt->btn.r ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_R) : 0); - buttonstate |= (rpt->btn.l ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_L) : 0); - - buttonstate |= (rpt->btn.x ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_X) : 0); - buttonstate |= (rpt->btn.a ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_A) : 0); - buttonstate |= (rpt->btn.b ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_B) : 0); - buttonstate |= (rpt->btn.y ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_Y) : 0); - buttonstate |= (rpt->btn.left ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_LEFT) : 0); - buttonstate |= (rpt->btn.right ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_RIGHT) : 0); - buttonstate |= (rpt->btn.up ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_UP) : 0); - buttonstate |= (rpt->btn.down ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_DOWN) : 0); - buttonstate |= (rpt->btn.home ? (UINT64_C(1) << RARCH_MENU_TOGGLE) : 0); - - return buttonstate; + if ( rpt->btn.r3 ) { + RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_R3 ); + } + if ( rpt->btn.l3 ) { + RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_L3 ); + } + if ( rpt->btn.plus ) { + RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_START ); + } + if ( rpt->btn.minus ) { + RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_SELECT ); + } + if ( rpt->btn.zr ) { + RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_R2 ); + } + if ( rpt->btn.zl ) { + RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_L2 ); + } + if ( rpt->btn.r ) { + RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_R ); + } + if ( rpt->btn.l ) { + RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_L ); + } + if ( rpt->btn.x ) { + RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_X ); + } + if ( rpt->btn.a ) { + RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_A ); + } + if ( rpt->btn.b ) { + RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_B ); + } + if ( rpt->btn.y ) { + RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_Y ); + } + if ( rpt->btn.left ) { + RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_LEFT ); + } + if ( rpt->btn.down ) { + RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_DOWN ); + } + if ( rpt->btn.right ) { + RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_RIGHT ); + } + if ( rpt->btn.up ) { + RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_UP ); + } + if ( rpt->btn.home ) { + RARCH_INPUT_STATE_BIT_SET_PTR( state, RARCH_MENU_TOGGLE ); + } } static int16_t hidpad_wiiupro_get_axis(void *data, unsigned axis) @@ -214,18 +244,18 @@ static void hidpad_wiiupro_packet_handler(void *data, calib_data->hatvalue_calib[1] = (packet[8] | (packet[8 + 1] << 8)); calib_data->hatvalue_calib[2] = (packet[6] | (packet[6 + 1] << 8)); calib_data->hatvalue_calib[3] = (packet[10] | (packet[10 + 1] << 8)); - + calib_data->calib_round++; } else { - device->data.hatvalue[0] = (packet[4] | (packet[4 + 1] << 8)) + device->data.hatvalue[0] = (packet[4] | (packet[4 + 1] << 8)) - calib_data->hatvalue_calib[0]; - device->data.hatvalue[1] = (packet[8] | (packet[8 + 1] << 8)) + device->data.hatvalue[1] = (packet[8] | (packet[8 + 1] << 8)) - calib_data->hatvalue_calib[1]; - device->data.hatvalue[2] = (packet[6] | (packet[6 + 1] << 8)) + device->data.hatvalue[2] = (packet[6] | (packet[6 + 1] << 8)) - calib_data->hatvalue_calib[2]; - device->data.hatvalue[3] = (packet[10] | (packet[10 + 1] << 8)) + device->data.hatvalue[3] = (packet[10] | (packet[10 + 1] << 8)) - calib_data->hatvalue_calib[3]; } } diff --git a/input/connect/joypad_connection.c b/input/connect/joypad_connection.c index 0942505db2..18ae10612d 100644 --- a/input/connect/joypad_connection.c +++ b/input/connect/joypad_connection.c @@ -103,7 +103,7 @@ int32_t pad_connection_pad_init(joypad_connection_t *joyconn, const char *name_match = strstr(pad_map[i].name, name); /* Never change, Nintendo. */ - if(pad_map[i].vid == 1406 && pad_map[i].pid == 816) + if(pad_map[i].vid == 1406 && pad_map[i].pid == 816) { if(!string_is_equal(pad_map[i].name, name)) continue; @@ -133,7 +133,7 @@ int32_t pad_connection_pad_init(joypad_connection_t *joyconn, } } - /* We failed to find a matching pad, + /* We failed to find a matching pad, * set up one without an interface */ if (!s->connected) { @@ -173,11 +173,13 @@ void pad_connection_packet(joypad_connection_t *joyconn, uint32_t pad, joyconn->iface->packet_handler(joyconn->data, data, length); } -uint64_t pad_connection_get_buttons(joypad_connection_t *joyconn, unsigned pad) +void pad_connection_get_buttons(joypad_connection_t *joyconn, unsigned pad, retro_bits_t* state) { - if (!joyconn->iface) - return 0; - return joyconn->iface->get_buttons(joyconn->data); + if (joyconn->iface) { + joyconn->iface->get_buttons(joyconn->data, state); + } else { + RARCH_INPUT_STATE_CLEAR_PTR( state ); + } } int16_t pad_connection_get_axis(joypad_connection_t *joyconn, @@ -190,8 +192,8 @@ int16_t pad_connection_get_axis(joypad_connection_t *joyconn, bool pad_connection_has_interface(joypad_connection_t *joyconn, unsigned pad) { - if ( joyconn && pad < MAX_USERS - && joyconn[pad].connected + if ( joyconn && pad < MAX_USERS + && joyconn[pad].connected && joyconn[pad].iface) return true; return false; diff --git a/input/connect/joypad_connection.h b/input/connect/joypad_connection.h index c0d3669853..75b6dbb633 100644 --- a/input/connect/joypad_connection.h +++ b/input/connect/joypad_connection.h @@ -21,6 +21,7 @@ #include #include +#include typedef void (*send_control_t)(void *data, uint8_t *buf, size_t size); @@ -38,7 +39,7 @@ typedef struct pad_connection_interface void (*packet_handler)(void* device, uint8_t *packet, uint16_t size); void (*set_rumble)(void* device, enum retro_rumble_effect effect, uint16_t strength); - uint64_t (*get_buttons)(void *data); + void (*get_buttons)(void *data, retro_bits_t *state); int16_t (*get_axis)(void *data, unsigned axis); const char* (*get_name)(void *data); } pad_connection_interface_t; @@ -69,8 +70,8 @@ void pad_connection_pad_deinit(joypad_connection_t *joyconn, void pad_connection_packet(joypad_connection_t *joyconn, uint32_t idx, uint8_t* data, uint32_t length); -uint64_t pad_connection_get_buttons(joypad_connection_t *joyconn, - unsigned idx); +void pad_connection_get_buttons(joypad_connection_t *joyconn, + unsigned idx, retro_bits_t* state); int16_t pad_connection_get_axis(joypad_connection_t *joyconn, unsigned idx, unsigned i); diff --git a/input/drivers_hid/btstack_hid.c b/input/drivers_hid/btstack_hid.c index 02e4d0d5fb..f5f2a86296 100644 --- a/input/drivers_hid/btstack_hid.c +++ b/input/drivers_hid/btstack_hid.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2013-2014 - Jason Fetters * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -44,13 +44,13 @@ #define LINK_KEY_LEN 16 /* The device name type. */ #define DEVICE_NAME_LEN 248 - + /* Type definitions. */ typedef uint16_t hci_con_handle_t; typedef uint8_t bd_addr_t[BD_ADDR_LEN]; typedef uint8_t link_key_t[LINK_KEY_LEN]; typedef uint8_t device_name_t[DEVICE_NAME_LEN+1]; - + /* Packet handler. */ typedef void (*btstack_packet_handler_t) (uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size); @@ -62,7 +62,7 @@ typedef enum HCI_POWER_ON, HCI_POWER_SLEEP } HCI_POWER_MODE; - + /* State of BTstack */ typedef enum { @@ -73,14 +73,14 @@ typedef enum HCI_STATE_SLEEPING, HCI_STATE_FALLING_ASLEEP } HCI_STATE; - + typedef enum { RUN_LOOP_POSIX = 1, RUN_LOOP_COCOA, RUN_LOOP_EMBEDDED } RUN_LOOP_TYPE; - + /* compact HCI Command packet description */ typedef struct { @@ -93,7 +93,7 @@ typedef struct linked_item struct linked_item *next; /* <-- next element in list, or NULL */ void *user_data; /* <-- pointer to struct base */ } linked_item_t; - + typedef linked_item_t *linked_list_t; typedef struct data_source @@ -108,7 +108,7 @@ typedef struct data_source typedef struct timer { - linked_item_t item; + linked_item_t item; /* Next timeout. */ struct timeval timeout; #ifdef HAVE_TICK @@ -167,7 +167,7 @@ BTDIMPORT const hci_cmd_t* l2cap_decline_connection_ptr; /* extension for client/server communication */ #define DAEMON_EVENT_PACKET 0x05 - + /* L2CAP data */ #define L2CAP_DATA_PACKET 0x06 @@ -179,7 +179,7 @@ BTDIMPORT const hci_cmd_t* l2cap_decline_connection_ptr; /* Security Manager protocol data */ #define SM_DATA_PACKET 0x09 - + /* debug log messages */ #define LOG_MESSAGE_PACKET 0xFC @@ -228,7 +228,7 @@ BTDIMPORT const hci_cmd_t* l2cap_decline_connection_ptr; #define HCI_SUBEVENT_LE_CONNECTION_UPDATE_COMPLETE 0x03 #define HCI_SUBEVENT_LE_READ_REMOTE_USED_FEATURES_COMPLETE 0x04 #define HCI_SUBEVENT_LE_LONG_TERM_KEY_REQUEST 0x05 - + /* last used HCI_EVENT in 2.1 is 0x3d */ /* events 0x50-0x5f are used internally */ @@ -257,7 +257,7 @@ BTDIMPORT const hci_cmd_t* l2cap_decline_connection_ptr; #define BTSTACK_EVENT_DISCOVERABLE_ENABLED 0x66 /* L2CAP EVENTS */ - + /* data: event (8), len(8), status (8), address(48), handle (16), psm (16), local_cid(16), remote_cid (16), local_mtu(16), remote_mtu(16) */ #define L2CAP_EVENT_CHANNEL_OPENED 0x70 @@ -277,31 +277,31 @@ BTDIMPORT const hci_cmd_t* l2cap_decline_connection_ptr; #define L2CAP_EVENT_SERVICE_REGISTERED 0x75 /* RFCOMM EVENTS */ - + // data: event(8), len(8), status (8), address (48), handle (16), server channel(8), rfcomm_cid(16), max frame size(16) #define RFCOMM_EVENT_OPEN_CHANNEL_COMPLETE 0x80 - + // data: event(8), len(8), rfcomm_cid(16) #define RFCOMM_EVENT_CHANNEL_CLOSED 0x81 - + // data: event (8), len(8), address(48), channel (8), rfcomm_cid (16) #define RFCOMM_EVENT_INCOMING_CONNECTION 0x82 - + // data: event (8), len(8), rfcommid (16), ... #define RFCOMM_EVENT_REMOTE_LINE_STATUS 0x83 - + /* data: event(8), len(8), rfcomm_cid(16), credits(8) */ #define RFCOMM_EVENT_CREDITS 0x84 - + /* data: event(8), len(8), status (8), rfcomm server channel id (8) */ #define RFCOMM_EVENT_SERVICE_REGISTERED 0x85 - + /* data: event(8), len(8), status (8), rfcomm server channel id (8) */ #define RFCOMM_EVENT_PERSISTENT_CHANNEL 0x86 - + /* data: event(8), len(8), status(8), service_record_handle(32) */ #define SDP_SERVICE_REGISTERED 0x90 - + /* last error code in 2.1 is 0x38 - we start with 0x50 for BTstack errors */ #define BTSTACK_CONNECTION_TO_BTDAEMON_FAILED 0x50 @@ -329,14 +329,14 @@ BTDIMPORT const hci_cmd_t* l2cap_decline_connection_ptr; #define L2CAP_CONFIG_RESPONSE_RESULT_REJECTED 0x68 #define L2CAP_CONFIG_RESPONSE_RESULT_UNKNOWN_OPTIONS 0x69 #define L2CAP_SERVICE_ALREADY_REGISTERED 0x6a - + #define RFCOMM_MULTIPLEXER_STOPPED 0x70 #define RFCOMM_CHANNEL_ALREADY_REGISTERED 0x71 #define RFCOMM_NO_OUTGOING_CREDITS 0x72 #define SDP_HANDLE_ALREADY_REGISTERED 0x80 - -/* Default INQ Mode + +/* Default INQ Mode * 0x9E8B33: General/Unlimited Inquiry Access Code (GIAC) **/ #define HCI_INQUIRY_LAP 0x9E8B33L @@ -350,7 +350,7 @@ extern const hci_cmd_t btstack_get_system_bluetooth_enabled; extern const hci_cmd_t btstack_set_system_bluetooth_enabled; extern const hci_cmd_t btstack_set_discoverable; extern const hci_cmd_t btstack_set_bluetooth_enabled; /* only used by btstack config */ - + extern const hci_cmd_t hci_accept_connection_request; extern const hci_cmd_t hci_authentication_requested; extern const hci_cmd_t hci_change_connection_link_key; @@ -425,7 +425,7 @@ extern const hci_cmd_t hci_le_set_scan_response_data; extern const hci_cmd_t hci_le_start_encryption; extern const hci_cmd_t hci_le_test_end; extern const hci_cmd_t hci_le_transmitter_test; - + extern const hci_cmd_t l2cap_accept_connection; extern const hci_cmd_t l2cap_create_channel; extern const hci_cmd_t l2cap_create_channel_mtu; @@ -487,12 +487,12 @@ void run_loop_set_timer_handler(timer_source_t *ts, void (*process)(timer_source_t *_ts)); /* Add timer source. */ -void run_loop_add_timer(timer_source_t *timer); +void run_loop_add_timer(timer_source_t *timer); /* Remove timer source. */ int run_loop_remove_timer(timer_source_t *timer); -/* Init must be called before any other run_loop call. +/* Init must be called before any other run_loop call. * Use RUN_LOOP_EMBEDDED for embedded devices. */ void run_loop_init(RUN_LOOP_TYPE type); @@ -507,7 +507,7 @@ void run_loop_add_data_source(data_source_t *dataSource); /* Remove data source. */ int run_loop_remove_data_source(data_source_t *dataSource); -/* Execute configured run loop. +/* Execute configured run loop. * This function does not return. */ void run_loop_execute(void); @@ -525,7 +525,7 @@ uint32_t embedded_get_ticks(void); /* Connection handle type. */ - + /* helper for BT little endian format. */ #define READ_BT_16( buffer, pos) ( ((uint16_t) buffer[pos]) | (((uint16_t)buffer[pos+1]) << 8)) #define READ_BT_24( buffer, pos) ( ((uint32_t) buffer[pos]) | (((uint32_t)buffer[pos+1]) << 8) | (((uint32_t)buffer[pos+2]) << 16)) @@ -578,13 +578,13 @@ void print_bd_addr( bd_addr_t addr); char * bd_addr_to_str(bd_addr_t addr); int sscan_bd_addr(uint8_t * addr_string, bd_addr_t addr); - + uint8_t crc8_check(uint8_t *data, uint16_t len, uint8_t check_sum); uint8_t crc8_calc(uint8_t *data, uint16_t len); /* btstack.h */ - + /* Default TCP port for BTstack daemon. */ #define BTSTACK_PORT 13333 @@ -594,13 +594,13 @@ uint8_t crc8_calc(uint8_t *data, uint16_t len); /* Optional * - * If called before bt_open, TCP socket is used + * If called before bt_open, TCP socket is used * instead of local UNIX socket. * - * note: Address is not copied and must be + * note: Address is not copied and must be * valid during bt_open. */ -void bt_use_tcp(const char * address, uint16_t port); +void bt_use_tcp(const char * address, uint16_t port); /* Init BTstack library. */ int bt_open(void); @@ -611,7 +611,7 @@ int bt_close(void); /* Send HCI cmd packet. */ int bt_send_cmd(const hci_cmd_t *cmd, ...); -/* Register packet handler -- channel only valid +/* Register packet handler -- channel only valid for L2CAP and RFCOMM packets. */ btstack_packet_handler_t bt_register_packet_handler( @@ -783,7 +783,7 @@ static void btpad_queue_process_cmd(struct btpad_queue_command *cmd) { if (!cmd) return; - + if (cmd->command == btstack_set_power_mode_ptr) bt_send_cmd_ptr( cmd->command, @@ -808,7 +808,7 @@ static void btpad_queue_process_cmd(struct btpad_queue_command *cmd) cmd->hci_remote_name_request.page_scan_repetition_mode, cmd->hci_remote_name_request.reserved, cmd->hci_remote_name_request.clock_offset); - + else if (cmd->command == hci_pin_code_request_reply_ptr) bt_send_cmd_ptr( cmd->command, @@ -889,7 +889,7 @@ static void btpad_queue_hci_remote_name_request( cmd->command = hci_remote_name_request_ptr; memcpy(cmd->hci_remote_name_request.bd_addr, bd_addr, sizeof(bd_addr_t)); - cmd->hci_remote_name_request.page_scan_repetition_mode = + cmd->hci_remote_name_request.page_scan_repetition_mode = page_scan_repetition_mode; cmd->hci_remote_name_request.reserved = reserved; cmd->hci_remote_name_request.clock_offset = clock_offset; @@ -1024,7 +1024,7 @@ static void btpad_packet_handler(uint8_t packet_type, if (!connection || connection->state != BTPAD_CONNECTED) continue; - if ( connection->channels[0] == channel + if ( connection->channels[0] == channel || connection->channels[1] == channel) pad_connection_packet(&slots[connection->slot], connection->slot, packet, size); } @@ -1036,14 +1036,14 @@ static void btpad_packet_handler(uint8_t packet_type, RARCH_LOG("[BTstack]: HCI State %d.\n", packet[2]); switch (packet[2]) - { + { case HCI_STATE_WORKING: btpad_queue_reset(); btpad_queue_hci_read_bd_addr(cmd); /* TODO: Where did I get 672 for MTU? */ - bt_send_cmd_ptr(l2cap_register_service_ptr, PSM_HID_CONTROL, 672); + bt_send_cmd_ptr(l2cap_register_service_ptr, PSM_HID_CONTROL, 672); bt_send_cmd_ptr(l2cap_register_service_ptr, PSM_HID_INTERRUPT, 672); btpad_queue_hci_inquiry(cmd, HCI_INQUIRY_LAP, 3, 1); @@ -1052,7 +1052,7 @@ static void btpad_packet_handler(uint8_t packet_type, case HCI_STATE_HALTING: btpad_close_all_connections(); - break; + break; } break; @@ -1100,7 +1100,7 @@ static void btpad_packet_handler(uint8_t packet_type, break; case HCI_EVENT_INQUIRY_COMPLETE: - /* This must be turned off during gameplay + /* This must be turned off during gameplay * as it causes a ton of lag. */ inquiry_running = !inquiry_off; @@ -1363,26 +1363,30 @@ static const char *btstack_hid_joypad_name(void *data, unsigned pad) return NULL; } -static uint64_t btstack_hid_joypad_get_buttons(void *data, unsigned port) +static void btstack_hid_joypad_get_buttons(void *data, unsigned port, retro_bits_t *state) { - btstack_hid_t *hid = (btstack_hid_t*)data; - if (hid) - return pad_connection_get_buttons(&hid->slots[port], port); - return 0; + btstack_hid_t *hid = (btstack_hid_t*)data; + if ( hid ) { + pad_connection_get_buttons(&hid->slots[port], port, state); + } else { + RARCH_INPUT_STATE_CLEAR_PTR( state ); + } } static bool btstack_hid_joypad_button(void *data, unsigned port, uint16_t joykey) { - uint64_t buttons = btstack_hid_joypad_get_buttons(data, port); + retro_bits_t buttons; + btstack_hid_joypad_get_buttons(data, port, &buttons); - /* Check hat. */ - if (GET_HAT_DIR(joykey)) - return false; + /* Check hat. */ + if (GET_HAT_DIR(joykey)) + return false; - /* Check the button. */ - if ((port < MAX_USERS) && (joykey < 32)) - return ((buttons & (1 << joykey)) != 0); - return false; + /* Check the button. */ + if ((port < MAX_USERS) && (joykey < 32)) + return ( RARCH_INPUT_STATE_BIT_GET( buttons, joykey ) != 0 ); + + return false; } static bool btstack_hid_joypad_rumble(void *data, unsigned pad, diff --git a/input/drivers_hid/iohidmanager_hid.c b/input/drivers_hid/iohidmanager_hid.c index e63f3cf7ad..d6f5512591 100644 --- a/input/drivers_hid/iohidmanager_hid.c +++ b/input/drivers_hid/iohidmanager_hid.c @@ -108,21 +108,24 @@ static const char *iohidmanager_hid_joypad_name(void *data, unsigned pad) return NULL; } -static uint64_t iohidmanager_hid_joypad_get_buttons(void *data, unsigned port) +static void iohidmanager_hid_joypad_get_buttons(void *data, unsigned port, retro_bits_t *state) { - iohidmanager_hid_t *hid = (iohidmanager_hid_t*)data; - if (hid) - return pad_connection_get_buttons(&hid->slots[port], port); - return 0; + iohidmanager_hid_t *hid = (iohidmanager_hid_t*)data; + if (hid) { + return pad_connection_get_buttons(&hid->slots[port], port, state); + } else { + RARCH_INPUT_STATE_CLEAR_PTR( state ); + } } static bool iohidmanager_hid_joypad_button(void *data, unsigned port, uint16_t joykey) { - uint64_t buttons = - iohidmanager_hid_joypad_get_buttons(data, port); - iohidmanager_hid_t *hid = (iohidmanager_hid_t*)data; - unsigned hat_dir = GET_HAT_DIR(joykey); + retro_bits_t buttons; + iohidmanager_hid_t *hid = (iohidmanager_hid_t*)data; + unsigned hat_dir = GET_HAT_DIR(joykey); + + iohidmanager_hid_joypad_get_buttons(data, port, &buttons); /* Check hat. */ if (hat_dir) @@ -148,8 +151,9 @@ static bool iohidmanager_hid_joypad_button(void *data, /* Check the button. */ if ((port < MAX_USERS) && (joykey < 32)) - return ((buttons & (1 << joykey)) != 0) + return (RARCH_INPUT_STATE_BIT_GET( buttons, joykey )) != 0) || ((hid->buttons[port] & (1 << joykey)) != 0); + return false; } diff --git a/input/drivers_hid/libusb_hid.c b/input/drivers_hid/libusb_hid.c index d0eb1250d7..1608cef89a 100644 --- a/input/drivers_hid/libusb_hid.c +++ b/input/drivers_hid/libusb_hid.c @@ -16,11 +16,7 @@ #include #include -#ifdef __FreeBSD__ -#include -#else #include -#endif #include #include @@ -42,11 +38,7 @@ typedef struct libusb_hid libusb_context *ctx; joypad_connection_t *slots; sthread_t *poll_thread; -#if defined(__FreeBSD__) && LIBUSB_API_VERSION <= 0x01000102 - libusb_hotplug_callback_handle hp; -#else int hp; /* libusb_hotplug_callback_handle is just int */ -#endif int quit; } libusb_hid_t; @@ -93,13 +85,13 @@ static void adapter_thread(void *data) int size = 0; slock_lock(adapter->send_control_lock); - if (fifo_read_avail(adapter->send_control_buffer) + if (fifo_read_avail(adapter->send_control_buffer) >= sizeof(send_command_size)) { fifo_read(adapter->send_control_buffer, &send_command_size, sizeof(send_command_size)); - if (fifo_read_avail(adapter->send_control_buffer) + if (fifo_read_avail(adapter->send_control_buffer) >= sizeof(send_command_size)) { fifo_read(adapter->send_control_buffer, @@ -165,13 +157,7 @@ static void libusb_get_description(struct libusb_device *device, unsigned i, k; struct libusb_config_descriptor *config; - int desc_ret = libusb_get_config_descriptor(device, 0, &config); - - if (desc_ret != 0) - { - RARCH_ERR("Error %d getting libusb config descriptor\n", desc_ret); - return; - } + libusb_get_config_descriptor(device, 0, &config); for (i = 0; i < (int)config->bNumInterfaces; i++) { @@ -179,7 +165,7 @@ static void libusb_get_description(struct libusb_device *device, for(j = 0; j < inter->num_altsetting; j++) { - const struct libusb_interface_descriptor *interdesc = + const struct libusb_interface_descriptor *interdesc = &inter->altsetting[j]; #if 0 @@ -190,13 +176,13 @@ static void libusb_get_description(struct libusb_device *device, for(k = 0; k < (int)interdesc->bNumEndpoints; k++) { - const struct libusb_endpoint_descriptor *epdesc = + const struct libusb_endpoint_descriptor *epdesc = &interdesc->endpoint[k]; - bool is_int = (epdesc->bmAttributes & LIBUSB_TRANSFER_TYPE_MASK) + bool is_int = (epdesc->bmAttributes & LIBUSB_TRANSFER_TYPE_MASK) == LIBUSB_TRANSFER_TYPE_INTERRUPT; - bool is_out = (epdesc->bEndpointAddress & LIBUSB_ENDPOINT_DIR_MASK) + bool is_out = (epdesc->bEndpointAddress & LIBUSB_ENDPOINT_DIR_MASK) == LIBUSB_ENDPOINT_OUT; - bool is_in = (epdesc->bEndpointAddress & LIBUSB_ENDPOINT_DIR_MASK) + bool is_in = (epdesc->bEndpointAddress & LIBUSB_ENDPOINT_DIR_MASK) == LIBUSB_ENDPOINT_IN; if (is_int) @@ -214,12 +200,11 @@ static void libusb_get_description(struct libusb_device *device, } } } - goto ret; } } -ret: + ret: libusb_free_config_descriptor(config); } @@ -441,27 +426,30 @@ static const char *libusb_hid_joypad_name(void *data, unsigned pad) return NULL; } -static uint64_t libusb_hid_joypad_get_buttons(void *data, unsigned port) +static void libusb_hid_joypad_get_buttons(void *data, unsigned port, retro_bits_t *state) { - libusb_hid_t *hid = (libusb_hid_t*)data; - if (hid) - return pad_connection_get_buttons(&hid->slots[port], port); - return 0; + libusb_hid_t *hid = (libusb_hid_t*)data; + if (hid) { + return pad_connection_get_buttons(&hid->slots[port], port, state); + } else { + RARCH_INPUT_STATE_CLEAR_PTR( state ); + } } static bool libusb_hid_joypad_button(void *data, unsigned port, uint16_t joykey) { - uint64_t buttons = libusb_hid_joypad_get_buttons(data, port); + retro_bits_t buttons; + libusb_hid_joypad_get_buttons(data, port, &buttons); - /* Check hat. */ - if (GET_HAT_DIR(joykey)) - return false; + /* Check hat. */ + if (GET_HAT_DIR(joykey)) + return false; - /* Check the button. */ - if ((port < MAX_USERS) && (joykey < 32)) - return ((buttons & (1 << joykey)) != 0); - return false; + /* Check the button. */ + if ((port < MAX_USERS) && (joykey < 32)) + return (RARCH_INPUT_STATE_BIT_GET(buttons, joykey) != 0); + return false; } static bool libusb_hid_joypad_rumble(void *data, unsigned pad, @@ -517,8 +505,7 @@ static void libusb_hid_free(void *data) sthread_join(hid->poll_thread); } - if (hid->slots) - pad_connection_destroy(hid->slots); + pad_connection_destroy(hid->slots); libusb_hotplug_deregister_callback(hid->ctx, hid->hp); @@ -553,14 +540,8 @@ static void *libusb_hid_init(void) if (ret < 0) goto error; -#if 0 - /* Don't use this for now since it requires a newer API - * version than FreeBSD has, and always returns false on Windows anyway. - * https://github.com/libusb/libusb/issues/86 - */ if (!libusb_has_capability(LIBUSB_CAP_HAS_HOTPLUG)) goto error; -#endif hid->slots = pad_connection_init(MAX_USERS); diff --git a/input/drivers_hid/null_hid.c b/input/drivers_hid/null_hid.c index 10be0ba7c8..34f8bdb7d6 100644 --- a/input/drivers_hid/null_hid.c +++ b/input/drivers_hid/null_hid.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2013-2014 - Jason Fetters * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -38,12 +38,12 @@ static const char *null_hid_joypad_name(void *data, unsigned pad) return NULL; } -static uint64_t null_hid_joypad_get_buttons(void *data, unsigned port) +static void null_hid_joypad_get_buttons(void *data, unsigned port, retro_bits_t *state) { (void)data; (void)port; - return 0; + RARCH_INPUT_STATE_CLEAR_PTR(state); } static bool null_hid_joypad_button(void *data, unsigned port, uint16_t joykey) diff --git a/input/drivers_hid/wiiusb_hid.c b/input/drivers_hid/wiiusb_hid.c index 8c022a12b8..8f98c65c5a 100644 --- a/input/drivers_hid/wiiusb_hid.c +++ b/input/drivers_hid/wiiusb_hid.c @@ -478,27 +478,31 @@ static bool wiiusb_hid_joypad_query(void *data, unsigned pad) return pad < MAX_USERS; } -static uint64_t wiiusb_hid_joypad_get_buttons(void *data, unsigned port) +static void wiiusb_hid_joypad_get_buttons(void *data, unsigned port, retro_bits_t *state) { - wiiusb_hid_t *hid = (wiiusb_hid_t*)data; - if (hid) - return pad_connection_get_buttons(&hid->connections[port], port); - return 0; + wiiusb_hid_t *hid = (wiiusb_hid_t*)data; + if (hid) { + return pad_connection_get_buttons(&hid->connections[port], port, state); + } else { + RARCH_INPUT_STATE_CLEAR_PTR( state ); + } } static bool wiiusb_hid_joypad_button(void *data, unsigned port, uint16_t joykey) { - uint64_t buttons = wiiusb_hid_joypad_get_buttons(data, port); + retro_bits_t buttons; - /* Check hat. */ - if (GET_HAT_DIR(joykey)) - return false; + wiiusb_hid_joypad_get_buttons(data, port, &buttons); - /* Check the button. */ - if ((port < MAX_USERS) && (joykey < 32)) - return ((buttons & (1 << joykey)) != 0); + /* Check hat. */ + if (GET_HAT_DIR(joykey)) + return false; - return false; + /* Check the button. */ + if ((port < MAX_USERS) && (joykey < 32)) + return (RARCH_INPUT_STATE_BIT_GET(buttons, joykey)) != 0); + + return false; } static bool wiiusb_hid_joypad_rumble(void *data, unsigned pad, diff --git a/input/drivers_joypad/ctr_joypad.c b/input/drivers_joypad/ctr_joypad.c index aa1b3efcbe..a31a7511fe 100644 --- a/input/drivers_joypad/ctr_joypad.c +++ b/input/drivers_joypad/ctr_joypad.c @@ -31,7 +31,7 @@ #define MAX_PADS 1 #endif -static uint64_t pad_state; +static uint32_t pad_state; static int16_t analog_state[1][2][2]; extern uint64_t lifecycle_state; @@ -67,12 +67,16 @@ static bool ctr_joypad_button(unsigned port_num, uint16_t key) if (port_num >= MAX_PADS) return false; - return (pad_state & (UINT64_C(1) << key)); + return (pad_state & (1 << key)); } -static uint64_t ctr_joypad_get_buttons(unsigned port_num) +static void ctr_joypad_get_buttons(unsigned port_num, retro_bits_t *state) { - return pad_state; + if ( port_num < MAX_PADS ) { + RARCH_INPUT_STATE_COPY16_PTR( state, pad_state ); + } else { + RARCH_INPUT_STATE_CLEAR_PTR(state); + } } static int16_t ctr_joypad_axis(unsigned port_num, uint32_t joyaxis) @@ -140,20 +144,20 @@ static void ctr_joypad_poll(void) hidTouchRead(&state_tmp_touch); pad_state = 0; - pad_state |= (state_tmp & KEY_DLEFT) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_LEFT) : 0; - pad_state |= (state_tmp & KEY_DDOWN) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_DOWN) : 0; - pad_state |= (state_tmp & KEY_DRIGHT) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_RIGHT) : 0; - pad_state |= (state_tmp & KEY_DUP) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_UP) : 0; - pad_state |= (state_tmp & KEY_START) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_START) : 0; - pad_state |= (state_tmp & KEY_SELECT) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_SELECT) : 0; - pad_state |= (state_tmp & KEY_X) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_X) : 0; - pad_state |= (state_tmp & KEY_Y) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_Y) : 0; - pad_state |= (state_tmp & KEY_B) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_B) : 0; - pad_state |= (state_tmp & KEY_A) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_A) : 0; - pad_state |= (state_tmp & KEY_R) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_R) : 0; - pad_state |= (state_tmp & KEY_L) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_L) : 0; - pad_state |= (state_tmp & KEY_ZR) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_R2) : 0; - pad_state |= (state_tmp & KEY_ZL) ? (UINT64_C(1) << RETRO_DEVICE_ID_JOYPAD_L2) : 0; + pad_state |= (state_tmp & KEY_DLEFT) ? (1 << RETRO_DEVICE_ID_JOYPAD_LEFT) : 0; + pad_state |= (state_tmp & KEY_DDOWN) ? (1 << RETRO_DEVICE_ID_JOYPAD_DOWN) : 0; + pad_state |= (state_tmp & KEY_DRIGHT) ? (1 << RETRO_DEVICE_ID_JOYPAD_RIGHT) : 0; + pad_state |= (state_tmp & KEY_DUP) ? (1 << RETRO_DEVICE_ID_JOYPAD_UP) : 0; + pad_state |= (state_tmp & KEY_START) ? (1 << RETRO_DEVICE_ID_JOYPAD_START) : 0; + pad_state |= (state_tmp & KEY_SELECT) ? (1 << RETRO_DEVICE_ID_JOYPAD_SELECT) : 0; + pad_state |= (state_tmp & KEY_X) ? (1 << RETRO_DEVICE_ID_JOYPAD_X) : 0; + pad_state |= (state_tmp & KEY_Y) ? (1 << RETRO_DEVICE_ID_JOYPAD_Y) : 0; + pad_state |= (state_tmp & KEY_B) ? (1 << RETRO_DEVICE_ID_JOYPAD_B) : 0; + pad_state |= (state_tmp & KEY_A) ? (1 << RETRO_DEVICE_ID_JOYPAD_A) : 0; + pad_state |= (state_tmp & KEY_R) ? (1 << RETRO_DEVICE_ID_JOYPAD_R) : 0; + pad_state |= (state_tmp & KEY_L) ? (1 << RETRO_DEVICE_ID_JOYPAD_L) : 0; + pad_state |= (state_tmp & KEY_ZR) ? (1 << RETRO_DEVICE_ID_JOYPAD_R2) : 0; + pad_state |= (state_tmp & KEY_ZL) ? (1 << RETRO_DEVICE_ID_JOYPAD_L2) : 0; analog_state[0][RETRO_DEVICE_INDEX_ANALOG_LEFT] [RETRO_DEVICE_ID_ANALOG_X] = ctr_joypad_fix_range(state_tmp_left_analog.dx); analog_state[0][RETRO_DEVICE_INDEX_ANALOG_LEFT] [RETRO_DEVICE_ID_ANALOG_Y] = -ctr_joypad_fix_range(state_tmp_left_analog.dy); diff --git a/input/drivers_joypad/gx_joypad.c b/input/drivers_joypad/gx_joypad.c index 348884e833..318eb637ed 100644 --- a/input/drivers_joypad/gx_joypad.c +++ b/input/drivers_joypad/gx_joypad.c @@ -162,9 +162,13 @@ static bool gx_joypad_button(unsigned port, uint16_t key) return (pad_state[port] & (UINT64_C(1) << key)); } -static uint64_t gx_joypad_get_buttons(unsigned port) +static void gx_joypad_get_buttons(unsigned port, retro_bits_t *state) { - return pad_state[port]; + if ( port < MAX_PADS ) { + RARCH_INPUT_STATE_COPY16_PTR( state, pad_state[port] ); + } else { + RARCH_INPUT_STATE_CLEAR_PTR(state); + } } static int16_t gx_joypad_axis(unsigned port, uint32_t joyaxis) @@ -501,8 +505,8 @@ static void gx_joypad_destroy(void) int i; for (i = 0; i < MAX_PADS; i++) { - /* Commenting this out fixes the Wii - * remote not reconnecting after + /* Commenting this out fixes the Wii + * remote not reconnecting after * core load, exit, etc. */ WPAD_Flush(i); WPADDisconnect(i); diff --git a/input/drivers_joypad/hid_joypad.c b/input/drivers_joypad/hid_joypad.c index 94eaaef7b6..eaed7efbed 100644 --- a/input/drivers_joypad/hid_joypad.c +++ b/input/drivers_joypad/hid_joypad.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2013-2014 - Jason Fetters * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -44,7 +44,7 @@ static void hid_joypad_free(void) if (generic_hid->free) generic_hid->free((void*)hid_driver_get_data()); - + generic_hid = NULL; } @@ -55,11 +55,13 @@ static bool hid_joypad_button(unsigned port, uint16_t joykey) return false; } -static uint64_t hid_joypad_get_buttons(unsigned port) +static void hid_joypad_get_buttons(unsigned port, retro_bits_t *state) { - if (generic_hid && generic_hid->get_buttons) - return generic_hid->get_buttons((void*)hid_driver_get_data(), port); - return 0; + if (generic_hid && generic_hid->get_buttons) { + generic_hid->get_buttons((void*)hid_driver_get_data(), port, state); + } else { + RARCH_INPUT_STATE_CLEAR_PTR( state ); + } } static int16_t hid_joypad_axis(unsigned port, uint32_t joyaxis) diff --git a/input/drivers_joypad/linuxraw_joypad.c b/input/drivers_joypad/linuxraw_joypad.c index 4178ffe188..212aeb8adc 100644 --- a/input/drivers_joypad/linuxraw_joypad.c +++ b/input/drivers_joypad/linuxraw_joypad.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -41,7 +41,7 @@ struct linuxraw_joypad { int fd; - uint64_t buttons; + uint32_t buttons; int16_t axes[NUM_AXES]; char *ident; @@ -55,7 +55,7 @@ static bool linuxraw_hotplug = false; static void linuxraw_poll_pad(struct linuxraw_joypad *pad) { struct js_event event; - + while (read(pad->fd, &event, sizeof(event)) == (ssize_t)sizeof(event)) { unsigned type = event.type & ~JS_EVENT_INIT; @@ -66,9 +66,9 @@ static void linuxraw_poll_pad(struct linuxraw_joypad *pad) if (event.number < NUM_BUTTONS) { if (event.value) - BIT64_SET(pad->buttons, event.number); + BIT32_SET(pad->buttons, event.number); else - BIT64_CLEAR(pad->buttons, event.number); + BIT32_CLEAR(pad->buttons, event.number); } break; @@ -200,7 +200,7 @@ retry: input_config_set_device_name(idx, NULL); } } - /* Sometimes, device will be created before + /* Sometimes, device will be created before * access to it is established. */ else if (event->mask & (IN_CREATE | IN_ATTRIB)) { @@ -210,7 +210,7 @@ retry: snprintf(path, sizeof(path), "/dev/input/%s", event->name); - if ( !string_is_empty(linuxraw_pads[idx].ident) + if ( !string_is_empty(linuxraw_pads[idx].ident) && linuxraw_joypad_init_pad(path, &linuxraw_pads[idx])) { if (!input_autoconfigure_connect( @@ -251,7 +251,7 @@ static bool linuxraw_joypad_init(void *data) pad->fd = -1; pad->ident = input_device_names[i]; - + snprintf(path, sizeof(path), "/dev/input/js%u", i); if (!input_autoconfigure_connect( @@ -323,15 +323,17 @@ static bool linuxraw_joypad_button(unsigned port, uint16_t joykey) const struct linuxraw_joypad *pad = (const struct linuxraw_joypad*) &linuxraw_pads[port]; - return joykey < NUM_BUTTONS && BIT64_GET(pad->buttons, joykey); + return joykey < NUM_BUTTONS && BIT32_GET(pad->buttons, joykey); } -static uint64_t linuxraw_joypad_get_buttons(unsigned port) +static void linuxraw_joypad_get_buttons(unsigned port, retro_bits_t *state) { - const struct linuxraw_joypad *pad = (const struct linuxraw_joypad*) - &linuxraw_pads[port]; - - return pad->buttons; + const struct linuxraw_joypad *pad = (const struct linuxraw_joypad*)&linuxraw_pads[port]; + if ( pad ) { + RARCH_INPUT_STATE_COPY16_PTR(state, pad->buttons); + } else { + RARCH_INPUT_STATE_CLEAR_PTR(state); + } } static int16_t linuxraw_joypad_axis(unsigned port, uint32_t joyaxis) diff --git a/input/drivers_joypad/mfi_joypad.m b/input/drivers_joypad/mfi_joypad.m index ef6f025746..10964893f0 100644 --- a/input/drivers_joypad/mfi_joypad.m +++ b/input/drivers_joypad/mfi_joypad.m @@ -221,9 +221,9 @@ static bool apple_gamecontroller_joypad_button(unsigned port, uint16_t joykey) return false; } -static uint64_t apple_gamecontroller_joypad_get_buttons(unsigned port) +static void apple_gamecontroller_joypad_get_buttons(unsigned port, retro_bits_t *state) { - return mfi_buttons[port]; + RARCH_INPUT_STATE_COPY16_PTR(state, mfi_buttons[port]); } static int16_t apple_gamecontroller_joypad_axis(unsigned port, uint32_t joyaxis) diff --git a/input/drivers_joypad/null_joypad.c b/input/drivers_joypad/null_joypad.c index c3377a45d6..d364433e06 100644 --- a/input/drivers_joypad/null_joypad.c +++ b/input/drivers_joypad/null_joypad.c @@ -37,9 +37,9 @@ static bool null_joypad_button(unsigned port_num, uint16_t joykey) return false; } -static uint64_t null_joypad_get_buttons(unsigned port_num) +static void null_joypad_get_buttons(unsigned port_num, retro_bits_t *state) { - return 0; + RARCH_INPUT_STATE_CLEAR_PTR( state ); } static int16_t null_joypad_axis(unsigned port_num, uint32_t joyaxis) diff --git a/input/drivers_joypad/parport_joypad.c b/input/drivers_joypad/parport_joypad.c index c3bc156db3..062e6dd958 100644 --- a/input/drivers_joypad/parport_joypad.c +++ b/input/drivers_joypad/parport_joypad.c @@ -40,7 +40,7 @@ struct parport_joypad { int fd; - uint64_t buttons; + uint32_t buttons; bool button_enable[PARPORT_NUM_BUTTONS]; char saved_data; char saved_control; @@ -97,22 +97,22 @@ static void parport_poll_pad(struct parport_joypad *pad) for (i = 0; i < 8; i++) { if (!(data & UINT8_C(1 << i)) && pad->button_enable[i]) - BIT64_SET(pad->buttons, i); + BIT32_SET(pad->buttons, i); else - BIT64_CLEAR(pad->buttons, i); + BIT32_CLEAR(pad->buttons, i); } for (i = 3; i < 8; i++) { if (!(status & UINT8_C(1 << i)) && pad->button_enable[i + 5]) - BIT64_SET(pad->buttons, i + 5); + BIT32_SET(pad->buttons, i + 5); else - BIT64_CLEAR(pad->buttons, i + 5); + BIT32_CLEAR(pad->buttons, i + 5); } - if (BIT64_GET(pad->buttons, 12) && pad->button_enable[12]) - BIT64_CLEAR(pad->buttons, 12); + if (BIT32_GET(pad->buttons, 12) && pad->button_enable[12]) + BIT32_CLEAR(pad->buttons, 12); else - BIT64_SET(pad->buttons, 12); + BIT32_SET(pad->buttons, 12); } static bool parport_joypad_init_pad(const char *path, struct parport_joypad *pad) @@ -268,7 +268,7 @@ static bool parport_joypad_init(void *data) for (j = 0; j < PARPORT_NUM_BUTTONS; j++) { - if (!(BIT64_GET(pad->buttons, j))) + if (!(BIT32_GET(pad->buttons, j))) { pad->button_enable[j] = true; found_enabled_button = true; @@ -337,13 +337,17 @@ static void parport_joypad_destroy(void) static bool parport_joypad_button(unsigned port, uint16_t joykey) { const struct parport_joypad *pad = (const struct parport_joypad*)&parport_pads[port]; - return joykey < PARPORT_NUM_BUTTONS && BIT64_GET(pad->buttons, joykey); + return joykey < PARPORT_NUM_BUTTONS && BIT32_GET(pad->buttons, joykey); } -static uint64_t parport_joypad_get_buttons(unsigned port) +static void parport_joypad_get_buttons(unsigned port, retro_bits_t *state) { - const struct parport_joypad *pad = (const struct parport_joypad*)&parport_pads[port]; - return pad->buttons; + const struct parport_joypad *pad = (const struct parport_joypad*)&parport_pads[port]; + if ( pad ) { + RARCH_INPUT_STATE_COPY16_PTR(state, pad->buttons); + } else { + RARCH_INPUT_STATE_CLEAR_PTR(state); + } } static int16_t parport_joypad_axis(unsigned port, uint32_t joyaxis) diff --git a/input/drivers_joypad/ps3_joypad.c b/input/drivers_joypad/ps3_joypad.c index 35fc7dadc9..c14277924c 100644 --- a/input/drivers_joypad/ps3_joypad.c +++ b/input/drivers_joypad/ps3_joypad.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -68,9 +68,13 @@ static bool ps3_joypad_button(unsigned port_num, uint16_t joykey) return pad_state[port_num] & (UINT64_C(1) << joykey); } -static uint64_t ps3_joypad_get_buttons(unsigned port_num) +static void ps3_joypad_get_buttons(unsigned port_num, retro_bits_t *state) { - return pad_state[port_num]; + if ( port_num < MAX_PADS ) { + RARCH_INPUT_STATE_COPY16_PTR( state, pad_state[port_num] ); + } else { + RARCH_INPUT_STATE_CLEAR_PTR(state); + } } static int16_t ps3_joypad_axis(unsigned port_num, uint32_t joyaxis) @@ -142,7 +146,7 @@ static void ps3_joypad_poll(void) ps3_joypad_autodetect_add(port); } } - + if (pads_connected[port] == 0) continue; diff --git a/input/drivers_joypad/psp_joypad.c b/input/drivers_joypad/psp_joypad.c index 9e569eeca2..967e9092e8 100644 --- a/input/drivers_joypad/psp_joypad.c +++ b/input/drivers_joypad/psp_joypad.c @@ -124,9 +124,13 @@ static bool psp_joypad_button(unsigned port_num, uint16_t key) return (pad_state[port_num] & (UINT64_C(1) << key)); } -static uint64_t psp_joypad_get_buttons(unsigned port_num) +static void psp_joypad_get_buttons(unsigned port_num, retro_bits_t *state) { - return pad_state[port_num]; + if ( port_num < PSP_MAX_PADS ) { + RARCH_INPUT_STATE_COPY16_PTR( state, pad_state[port_num] ); + } else { + RARCH_INPUT_STATE_CLEAR_PTR(state); + } } static int16_t psp_joypad_axis(unsigned port_num, uint32_t joyaxis) @@ -236,10 +240,10 @@ static void psp_joypad_poll(void) if (curr_ctrl_info.port[p] == SCE_CTRL_TYPE_UNPAIRED) continue; #elif defined(SN_TARGET_PSP2) - /* Dumb hack, but here's the explanation - + /* Dumb hack, but here's the explanation - * sceCtrlPeekBufferPositive's port parameter * can be 0 or 1 to read the first controller on - * a PSTV, but HAS to be 0 for a real VITA and 2 + * a PSTV, but HAS to be 0 for a real VITA and 2 * for the 2nd controller on a PSTV */ unsigned p = (player > 0) ? player+1 : player; #else @@ -256,12 +260,12 @@ static void psp_joypad_poll(void) continue; #endif #if defined(VITA) - if (psp2_model == SCE_KERNEL_MODEL_VITA + if (psp2_model == SCE_KERNEL_MODEL_VITA && settings->bools.input_backtouch_enable) { unsigned i; SceTouchData touch_surface = {0}; - sceTouchPeek(settings->bools.input_backtouch_toggle + sceTouchPeek(settings->bools.input_backtouch_toggle ? SCE_TOUCH_PORT_FRONT : SCE_TOUCH_PORT_BACK, &touch_surface, 1); for (i = 0; i < touch_surface.reportNum; i++) diff --git a/input/drivers_joypad/udev_joypad.c b/input/drivers_joypad/udev_joypad.c index ce3ad8617d..3aa6ba092a 100644 --- a/input/drivers_joypad/udev_joypad.c +++ b/input/drivers_joypad/udev_joypad.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2015 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -204,7 +204,7 @@ static int udev_add_pad(struct udev_device *dev, unsigned p, int fd, const char i = ABS_HAT3Y; continue; } - + if (test_bit(i, absbit)) { struct input_absinfo *abs = &pad->absinfo[axes]; @@ -420,11 +420,11 @@ static bool udev_set_rumble(unsigned i, static bool udev_joypad_poll_hotplug_available(struct udev_monitor *dev) { - struct pollfd fds; + struct pollfd fds; - fds.fd = udev_monitor_get_fd(dev); - fds.events = POLLIN; - fds.revents = 0; + fds.fd = udev_monitor_get_fd(dev); + fds.events = POLLIN; + fds.revents = 0; return (poll(&fds, 1, 0) == 1) && (fds.revents & POLLIN); } @@ -604,10 +604,14 @@ static bool udev_joypad_button(unsigned port, uint16_t joykey) return joykey < UDEV_NUM_BUTTONS && BIT64_GET(pad->buttons, joykey); } -static uint64_t udev_joypad_get_buttons(unsigned port) +static void udev_joypad_get_buttons(unsigned port, retro_bits_t *state) { - const struct udev_joypad *pad = (const struct udev_joypad*)&udev_pads[port]; - return pad->buttons; + const struct udev_joypad *pad = (const struct udev_joypad*)&udev_pads[port]; + if ( pad ) { + RARCH_INPUT_STATE_COPY16_PTR( state, pad->buttons ); + } else { + RARCH_INPUT_STATE_CLEAR_PTR(state); + } } static int16_t udev_joypad_axis(unsigned port, uint32_t joyaxis) diff --git a/input/drivers_joypad/wiiu_joypad.c b/input/drivers_joypad/wiiu_joypad.c index 8fac55d0ae..957e736241 100644 --- a/input/drivers_joypad/wiiu_joypad.c +++ b/input/drivers_joypad/wiiu_joypad.c @@ -122,9 +122,13 @@ static bool wiiu_joypad_button(unsigned port_num, uint16_t key) return (pad_state[port_num] & (UINT64_C(1) << key)); } -static uint64_t wiiu_joypad_get_buttons(unsigned port_num) +static void wiiu_joypad_get_buttons(unsigned port_num, retro_bits_t *state) { - return pad_state[port_num]; + if ( port_num < MAX_PADS ) { + RARCH_INPUT_STATE_COPY16_PTR( state, pad_state[port_num] ); + } else { + RARCH_INPUT_STATE_CLEAR_PTR(state); + } } static int16_t wiiu_joypad_axis(unsigned port_num, uint32_t joyaxis) diff --git a/input/drivers_joypad/xdk_joypad.c b/input/drivers_joypad/xdk_joypad.c index 6bdb3d25b3..b9e25268b4 100644 --- a/input/drivers_joypad/xdk_joypad.c +++ b/input/drivers_joypad/xdk_joypad.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -19,7 +19,7 @@ #include "../input_driver.h" #include "../../tasks/tasks_internal.h" -static uint64_t pad_state[MAX_PADS]; +static uint32_t pad_state[MAX_PADS]; static int16_t analog_state[MAX_PADS][2][2]; #ifdef _XBOX1 static HANDLE gamepads[MAX_PADS]; @@ -73,12 +73,16 @@ static bool xdk_joypad_button(unsigned port_num, uint16_t joykey) if (port_num >= MAX_PADS) return false; - return pad_state[port_num] & (UINT64_C(1) << joykey); + return pad_state[port_num] & (1 << joykey); } -static uint64_t xdk_joypad_get_buttons(unsigned port_num) +static void xdk_joypad_get_buttons(unsigned port_num, retro_bits_t *state) { - return pad_state[port_num]; + if ( port_num < MAX_PADS ) { + RARCH_INPUT_STATE_COPY16_PTR( state, pad_state[port_num] ); + } else { + RARCH_INPUT_STATE_CLEAR_PTR(state); + } } static int16_t xdk_joypad_axis(unsigned port_num, uint32_t joyaxis) @@ -154,7 +158,7 @@ static void xdk_joypad_poll(void) if(bRemoved[port]) { - /* if the controller was removed after + /* if the controller was removed after * XGetDeviceChanges but before * XInputOpen, the device handle will be NULL. */ if(gamepads[port]) @@ -178,14 +182,14 @@ static void xdk_joypad_poll(void) m_pollingParameters.bOutputInterval = 8; gamepads[port] = XInputOpen(XDEVICE_TYPE_GAMEPAD, port, XDEVICE_NO_SLOT, NULL); - + xdk_joypad_autodetect_add(port); } if (!gamepads[port]) continue; - /* if the controller is removed after + /* if the controller is removed after * XGetDeviceChanges but before XInputOpen, * the device handle will be NULL. */ #endif diff --git a/input/input_defines.h b/input/input_defines.h index d9ef13cc37..fa697c54a4 100644 --- a/input/input_defines.h +++ b/input/input_defines.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -18,6 +18,7 @@ #define __INPUT_DEFINES__H #include +#include #include @@ -157,6 +158,30 @@ enum analog_dpad_mode #define GET_HAT_DIR(x) (x & HAT_MASK) #define GET_HAT(x) (x & (~HAT_MASK)) +#define RARCH_INPUT_STATE_BIT_SET(a,bit) ((a).data [((bit) >> 5)] |= (1 << ((bit) & 31))) +#define RARCH_INPUT_STATE_BIT_SET_PTR(a,bit) ((a)->data[((bit) >> 5)] |= (1 << ((bit) & 31))) +#define RARCH_INPUT_STATE_BIT_GET(a,bit) ((a).data [((bit) >> 5)] & (1 << ((bit) & 31))) +#define RARCH_INPUT_STATE_BIT_GET_PTR(a,bit) ((a)->data[((bit) >> 5)] & (1 << ((bit) & 31))) +#define RARCH_INPUT_STATE_CLEAR(a) memset(&a, 0, sizeof(a)); +#define RARCH_INPUT_STATE_CLEAR_PTR(a) memset(a, 0, sizeof(retro_bits_t)); +#define RARCH_INPUT_STATE_ANY_SET(a) ( ((a).data[0])||((a).data[1])||((a).data[2])||((a).data[3])|| \ + ((a).data[4])||((a).data[5])||((a).data[6])||((a).data[7]) ) +#define RARCH_INPUT_STATE_ANY_SET_PTR(a) ( ((a)->data[0])||((a)->data[1])||((a)->data[2])||((a)->data[3])|| \ + ((a)->data[4])||((a)->data[5])||((a)->data[6])||((a)->data[7]) ) +#define RARCH_INPUT_STATE_CLEAR_BITS(a,b) \ + ((a).data[0])&=(~((b).data[0])); \ + ((a).data[1])&=(~((b).data[1])); \ + ((a).data[2])&=(~((b).data[2])); \ + ((a).data[3])&=(~((b).data[3])); \ + ((a).data[4])&=(~((b).data[4])); \ + ((a).data[5])&=(~((b).data[5])); \ + ((a).data[6])&=(~((b).data[6])); \ + ((a).data[7])&=(~((b).data[7])); + +#define RARCH_INPUT_STATE_COPY16_PTR(a,bits) {memset(a, 0, sizeof(retro_bits_t));((a)->data[0] = (bits)&0xffff);} +#define RARCH_INPUT_STATE_COPY32_PTR(a,bits) {memset(a, 0, sizeof(retro_bits_t));((a)->data[0] = (bits));} + + RETRO_END_DECLS #endif diff --git a/input/input_driver.h b/input/input_driver.h index c3084979a9..3222237a41 100644 --- a/input/input_driver.h +++ b/input/input_driver.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -79,7 +79,7 @@ enum rarch_input_keyboard_ctl_state RARCH_INPUT_KEYBOARD_CTL_LINE_FREE, /* - * Waits for keys to be pressed (used for binding + * Waits for keys to be pressed (used for binding * keys in the menu). * Callback returns false when all polling is done. **/ @@ -98,19 +98,19 @@ struct retro_keybind uint16_t mbutton; - /* Joypad key. Joypad POV (hats) + /* Joypad key. Joypad POV (hats) * are embedded into this key as well. */ uint64_t joykey; - /* Default key binding value - + /* Default key binding value - * for resetting bind to default */ uint64_t def_joykey; - /* Joypad axis. Negative and positive axes + /* Joypad axis. Negative and positive axes * are embedded into this variable. */ uint32_t joyaxis; - /* Default joy axis binding value - + /* Default joy axis binding value - * for resetting bind to default */ uint32_t def_joyaxis; @@ -130,7 +130,7 @@ typedef struct rarch_joypad_info typedef struct input_driver { - /* Inits input driver. + /* Inits input driver. */ void *(*init)(const char *joypad_driver); @@ -174,7 +174,7 @@ struct rarch_joypad_driver bool (*query_pad)(unsigned); void (*destroy)(void); bool (*button)(unsigned, uint16_t); - uint64_t (*get_buttons)(unsigned); + void (*get_buttons)(unsigned, retro_bits_t *); int16_t (*axis)(unsigned, uint32_t); void (*poll)(void); bool (*set_rumble)(unsigned, enum retro_rumble_effect, uint16_t); @@ -189,7 +189,7 @@ struct hid_driver bool (*query_pad)(void *, unsigned); void (*free)(void *); bool (*button)(void *, unsigned, uint16_t); - uint64_t (*get_buttons)(void *, unsigned); + void (*get_buttons)(void *, unsigned, retro_bits_t *); int16_t (*axis)(void *, unsigned, uint32_t); void (*poll)(void *); bool (*set_rumble)(void *, unsigned, enum retro_rumble_effect, uint16_t); @@ -336,26 +336,6 @@ void input_poll(void); int16_t input_state(unsigned port, unsigned device, unsigned idx, unsigned id); -#define RARCH_INPUT_STATE_BIT_SET(a,bit) ((a).data [((bit) >> 5)] |= (1 << ((bit) & 31))) -#define RARCH_INPUT_STATE_BIT_SET_PTR(a,bit) ((a)->data[((bit) >> 5)] |= (1 << ((bit) & 31))) -#define RARCH_INPUT_STATE_BIT_GET(a,bit) ((a).data [((bit) >> 5)] & (1 << ((bit) & 31))) -#define RARCH_INPUT_STATE_BIT_GET_PTR(a,bit) ((a)->data[((bit) >> 5)] & (1 << ((bit) & 31))) -#define RARCH_INPUT_STATE_CLEAR(a) memset(&a, 0, sizeof(a)); -#define RARCH_INPUT_STATE_CLEAR_PTR(a) memset(a, 0, sizeof(retro_bits_t)); -#define RARCH_INPUT_STATE_ANY_SET(a) ( ((a).data[0])||((a).data[1])||((a).data[2])||((a).data[3])|| \ - ((a).data[4])||((a).data[5])||((a).data[6])||((a).data[7]) ) -#define RARCH_INPUT_STATE_ANY_SET_PTR(a) ( ((a)->data[0])||((a)->data[1])||((a)->data[2])||((a)->data[3])|| \ - ((a)->data[4])||((a)->data[5])||((a)->data[6])||((a)->data[7]) ) -#define RARCH_INPUT_STATE_CLEAR_BITS(a,b) \ - ((a).data[0])&=(~((b).data[0])); \ - ((a).data[1])&=(~((b).data[1])); \ - ((a).data[2])&=(~((b).data[2])); \ - ((a).data[3])&=(~((b).data[3])); \ - ((a).data[4])&=(~((b).data[4])); \ - ((a).data[5])&=(~((b).data[5])); \ - ((a).data[6])&=(~((b).data[6])); \ - ((a).data[7])&=(~((b).data[7])); - void input_keys_pressed(void *data, retro_bits_t* new_state); #ifdef HAVE_MENU @@ -467,7 +447,7 @@ const char* config_get_joypad_driver_options(void); * * Initialize a joypad driver of name @ident. * - * If ident points to NULL or a zero-length string, + * If ident points to NULL or a zero-length string, * equivalent to calling input_joypad_init_first(). * * Returns: joypad driver if found, otherwise NULL. @@ -486,7 +466,7 @@ const input_device_driver_t *input_joypad_init_first(void *data); /** * input_conv_analog_id_to_bind_id: * @idx : Analog key index. - * E.g.: + * E.g.: * - RETRO_DEVICE_INDEX_ANALOG_LEFT * - RETRO_DEVICE_INDEX_ANALOG_RIGHT * @ident : Analog key identifier. @@ -525,7 +505,7 @@ static INLINE bool input_joypad_pressed( /* Auto-binds are per joypad, not per user. */ uint64_t joykey = (binds[key].joykey != NO_BTN) ? binds[key].joykey : joypad_info.auto_binds[key].joykey; - uint32_t joyaxis = (binds[key].joyaxis != AXIS_NONE) + uint32_t joyaxis = (binds[key].joyaxis != AXIS_NONE) ? binds[key].joyaxis : joypad_info.auto_binds[key].joyaxis; if ((uint16_t)joykey != NO_BTN && drv->button(joypad_info.joy_idx, (uint16_t)joykey)) @@ -540,7 +520,7 @@ static INLINE bool input_joypad_pressed( * @drv : Input device driver handle. * @port : User number. * @idx : Analog key index. - * E.g.: + * E.g.: * - RETRO_DEVICE_INDEX_ANALOG_LEFT * - RETRO_DEVICE_INDEX_ANALOG_RIGHT * - RETRO_DEVICE_INDEX_ANALOG_BUTTON @@ -575,12 +555,12 @@ bool input_joypad_set_rumble(const input_device_driver_t *driver, unsigned port, enum retro_rumble_effect effect, uint16_t strength); /** - * input_joypad_axis_raw: + * input_joypad_axis_raw: * @drv : Input device driver handle. * @port : Joystick number. * @axis : Identifier of axis. * - * Checks if axis (@axis) was being pressed by user + * Checks if axis (@axis) was being pressed by user * with joystick number @port. * * Returns: true (1) if axis was pressed, otherwise @@ -674,7 +654,7 @@ const hid_driver_t *input_hid_init_first(void); const void *hid_driver_get_data(void); #endif -/** Line complete callback. +/** Line complete callback. * Calls back after return is pressed with the completed line. * Line can be NULL. **/ @@ -711,8 +691,8 @@ bool input_keyboard_line_append(const char *word); * * Sets function pointer for keyboard line handle. * - * The underlying buffer can be reallocated at any time - * (or be NULL), but the pointer to it remains constant + * The underlying buffer can be reallocated at any time + * (or be NULL), but the pointer to it remains constant * throughout the objects lifetime. * * Returns: underlying buffer of the keyboard line. @@ -759,7 +739,7 @@ const char *input_config_get_prefix(unsigned user, bool meta); * * Translate string representation to bind ID. * - * Returns: Bind ID value on success, otherwise + * Returns: Bind ID value on success, otherwise * RARCH_BIND_LIST_END on not found. **/ unsigned input_config_translate_str_to_bind_id(const char *str); From f09477d46a7fa49966ab62d89ebc62a48a08712f Mon Sep 17 00:00:00 2001 From: David Walters Date: Tue, 28 Nov 2017 10:36:16 +0000 Subject: [PATCH 092/394] additional compile fixes --- input/connect/connect_ps4.c | 3 +- input/connect/connect_wiiupro.c | 2 + input/drivers/cocoa_input.c | 68 +++++++++++++++------------- input/drivers_hid/iohidmanager_hid.c | 2 +- 4 files changed, 42 insertions(+), 33 deletions(-) diff --git a/input/connect/connect_ps4.c b/input/connect/connect_ps4.c index 36965eed41..47a9cdabe6 100644 --- a/input/connect/connect_ps4.c +++ b/input/connect/connect_ps4.c @@ -186,13 +186,14 @@ static bool hidpad_ps4_check_dpad(struct ps4 *rpt, unsigned id) static void hidpad_ps4_get_buttons(void *data, retro_bits_t* state) { - uint64_t buttonstate = 0; struct hidpad_ps4_data *device = (struct hidpad_ps4_data*)data; struct ps4 *rpt = device ? (struct ps4*)&device->data : NULL; if (!device || !rpt) return; + RARCH_INPUT_STATE_CLEAR_PTR( state ); + if ( rpt->btn.r3 ) { RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_R3 ); } diff --git a/input/connect/connect_wiiupro.c b/input/connect/connect_wiiupro.c index 408944ad87..d380e119a0 100644 --- a/input/connect/connect_wiiupro.c +++ b/input/connect/connect_wiiupro.c @@ -126,6 +126,8 @@ static void hidpad_wiiupro_get_buttons(void *data, retro_bits_t *state) if (!device || !rpt) return; + RARCH_INPUT_STATE_CLEAR_PTR( state ); + if ( rpt->btn.r3 ) { RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_R3 ); } diff --git a/input/drivers/cocoa_input.c b/input/drivers/cocoa_input.c index 9b84770b8b..ceeaf417b1 100644 --- a/input/drivers/cocoa_input.c +++ b/input/drivers/cocoa_input.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2011-2017 - Daniel De Matteis * Copyright (C) 2013-2014 - Jason Fetters - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -36,13 +36,13 @@ float get_backing_scale_factor(void); int32_t cocoa_input_find_any_key(void) { cocoa_input_data_t *apple = (cocoa_input_data_t*)input_driver_get_data(); - + if (!apple) return 0; - + if (apple->joypad) apple->joypad->poll(); - + if (apple->sec_joypad) apple->sec_joypad->poll(); @@ -50,13 +50,13 @@ int32_t cocoa_input_find_any_key(void) } static int cocoa_input_find_any_button_ret(cocoa_input_data_t *apple, - unsigned buttons, unsigned port) + retro_bits_t * state, unsigned port) { unsigned i; - if (buttons) - for (i = 0; i < 32; i++) - if (buttons & (1 << i)) + if (state) + for (i = 0; i < 256; i++) + if (RARCH_INPUT_STATE_BIT_GET_PTR(state,i)) return i; return -1; } @@ -68,26 +68,32 @@ int32_t cocoa_input_find_any_button(uint32_t port) if (!apple) return -1; - + if (apple->joypad) { apple->joypad->poll(); if (apple->joypad->get_buttons) - ret = cocoa_input_find_any_button_ret(apple, (unsigned)apple->joypad->get_buttons(port), port); + { + retro_bits_t state; + apple->joypad->get_buttons(port,&state); + ret = cocoa_input_find_any_button_ret(apple, &state, port); + } } if (ret != -1) return ret; - + if (apple->sec_joypad) { apple->sec_joypad->poll(); if (apple->sec_joypad->get_buttons) { + retro_bits_t state; apple->sec_joypad->poll(); - ret = cocoa_input_find_any_button_ret(apple, (unsigned)apple->sec_joypad->get_buttons(port), port); + apple->sec_joypad->get_buttons(port,&state); + ret = cocoa_input_find_any_button_ret(apple, &state, port); } } @@ -101,17 +107,17 @@ int32_t cocoa_input_find_any_axis(uint32_t port) { int i; cocoa_input_data_t *apple = (cocoa_input_data_t*)input_driver_get_data(); - + if (apple && apple->joypad) apple->joypad->poll(); - + if (apple && apple->sec_joypad) apple->sec_joypad->poll(); for (i = 0; i < 6; i++) { int16_t value = apple->joypad ? apple->joypad->axis(port, i) : 0; - + if (abs(value) > 0x4000) return (value < 0) ? -(i + 1) : i + 1; @@ -130,15 +136,15 @@ static void *cocoa_input_init(const char *joypad_driver) cocoa_input_data_t *apple = (cocoa_input_data_t*)calloc(1, sizeof(*apple)); if (!apple) return NULL; - + input_keymaps_init_keyboard_lut(rarch_key_map_apple_hid); apple->joypad = input_joypad_init_driver(joypad_driver, apple); - + #ifdef HAVE_MFI apple->sec_joypad = input_joypad_init_driver("mfi", apple); #endif - + return apple; } @@ -149,14 +155,14 @@ static void cocoa_input_poll(void *data) #ifndef IOS float backing_scale_factor = get_backing_scale_factor(); #endif - + if (!apple) return; for (i = 0; i < apple->touch_count; i++) { struct video_viewport vp; - + vp.x = 0; vp.y = 0; vp.width = 0; @@ -249,13 +255,13 @@ static int16_t cocoa_pointer_state(cocoa_input_data_t *apple, int16_t x, y; const cocoa_touch_data_t *touch = (const cocoa_touch_data_t *) &apple->touches[idx]; - + if (!touch) return 0; - + x = touch->fixed_x; y = touch->fixed_y; - + if (want_full) { x = touch->full_x; @@ -328,16 +334,16 @@ static void cocoa_input_free(void *data) { unsigned i; cocoa_input_data_t *apple = (cocoa_input_data_t*)data; - + if (!apple || !data) return; - + if (apple->joypad) apple->joypad->destroy(); - + if (apple->sec_joypad) apple->sec_joypad->destroy(); - + for (i = 0; i < MAX_KEYS; i++) apple_key_state[i] = 0; @@ -348,7 +354,7 @@ static bool cocoa_input_set_rumble(void *data, unsigned port, enum retro_rumble_effect effect, uint16_t strength) { cocoa_input_data_t *apple = (cocoa_input_data_t*)data; - + if (apple && apple->joypad) return input_joypad_set_rumble(apple->joypad, port, effect, strength); @@ -364,7 +370,7 @@ static uint64_t cocoa_input_get_capabilities(void *data) { (void)data; - return + return (1 << RETRO_DEVICE_JOYPAD) | (1 << RETRO_DEVICE_MOUSE) | (1 << RETRO_DEVICE_KEYBOARD) | @@ -382,7 +388,7 @@ static void cocoa_input_grab_mouse(void *data, bool state) static const input_device_driver_t *cocoa_input_get_sec_joypad_driver(void *data) { cocoa_input_data_t *apple = (cocoa_input_data_t*)data; - + if (apple && apple->sec_joypad) return apple->sec_joypad; return NULL; @@ -391,7 +397,7 @@ static const input_device_driver_t *cocoa_input_get_sec_joypad_driver(void *data static const input_device_driver_t *cocoa_input_get_joypad_driver(void *data) { cocoa_input_data_t *apple = (cocoa_input_data_t*)data; - + if (apple && apple->joypad) return apple->joypad; return NULL; diff --git a/input/drivers_hid/iohidmanager_hid.c b/input/drivers_hid/iohidmanager_hid.c index d6f5512591..c832417bd4 100644 --- a/input/drivers_hid/iohidmanager_hid.c +++ b/input/drivers_hid/iohidmanager_hid.c @@ -151,7 +151,7 @@ static bool iohidmanager_hid_joypad_button(void *data, /* Check the button. */ if ((port < MAX_USERS) && (joykey < 32)) - return (RARCH_INPUT_STATE_BIT_GET( buttons, joykey )) != 0) + return (RARCH_INPUT_STATE_BIT_GET( buttons, joykey ) != 0) || ((hid->buttons[port] & (1 << joykey)) != 0); return false; From 96b7fa46dc3fafe42c5b40f7aa7f0319790589f8 Mon Sep 17 00:00:00 2001 From: altiereslima Date: Tue, 28 Nov 2017 13:58:03 -0200 Subject: [PATCH 093/394] Updated Portuguese Translation --- intl/msg_hash_pt_br.h | 54 +++++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/intl/msg_hash_pt_br.h b/intl/msg_hash_pt_br.h index 376860a968..c2b0ae58f5 100644 --- a/intl/msg_hash_pt_br.h +++ b/intl/msg_hash_pt_br.h @@ -662,27 +662,27 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_ANALOG_RIGHT_Y_PLUS, "Analógico Direito Y+ (baixo)" ) MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_TRIGGER, - "Gun Trigger") + "Gatinho da Pistola") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_RELOAD, - "Gun Reload") + "Recarregar Pistola") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_A, - "Gun Aux A") + "Aux A da Pistola") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_B, - "Gun Aux B") + "Aux B da Pistola") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_AUX_C, - "Gun Aux C") + "Aux C da Pistola") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_START, - "Gun Start") + "Start da Pistola") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_SELECT, - "Gun Select") + "Select da Pistola") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_UP, - "Gun D-pad Up") + "D-pad Cima da Pistola") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_DOWN, - "Gun D-pad Down") + "D-pad Baixo da Pistola") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_LEFT, - "Gun D-pad Left") + "D-pad Esquerdo da Pistola") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_LIGHTGUN_DPAD_RIGHT, - "Gun D-pad Right") + "D-pad Direito da Pistola") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_AUTODETECT_ENABLE, "Habilitar Autoconfiguração" ) @@ -790,13 +790,13 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON4, MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_BUTTON5, "Mouse 5") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_UP, - "Wheel Up") + "Roda do Mouse para Cima") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_WHEEL_DOWN, - "Wheel Down") + "Roda do Mouse para Baixo") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_UP, - "Wheel Left") + "Roda do Mouse para Esquerda") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_MOUSE_HORIZ_WHEEL_DOWN, - "Wheel Right") + "Roda do Mouse para Diretira") MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_KEYBOARD_GAMEPAD_MAPPING_TYPE, "Tipo de Mapeamento para Gamepad no Teclado" ) @@ -897,10 +897,10 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_META_SLOWMOTION, "Câmera Lenta" ) MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_META_STATE_SLOT_MINUS, - "Posição do Estado de Jogo -" + "Compartimento do Estado de Jogo -" ) MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_META_STATE_SLOT_PLUS, - "Posição do Estado de Jogo +" + "Compartimento do Estado de Jogo +" ) MSG_HASH(MENU_ENUM_LABEL_VALUE_INPUT_META_VOLUME_DOWN, "Volume -" @@ -1704,7 +1704,7 @@ MSG_HASH(MENU_ENUM_LABEL_VALUE_START_VIDEO_PROCESSOR, "Iniciar Processador de Vídeo" ) MSG_HASH(MENU_ENUM_LABEL_VALUE_STATE_SLOT, - "Posição do Estado de Jogo" + "Compartimento do Estado de Jogo" ) MSG_HASH(MENU_ENUM_LABEL_VALUE_STATUS, "Condição" @@ -2775,7 +2775,7 @@ MSG_HASH(MSG_FOUND_FIRST_DATA_TRACK_ON_FILE, "Encontrada primeira faixa de dados no arquivo" ) MSG_HASH(MSG_FOUND_LAST_STATE_SLOT, - "Encontrada última posição de Estado de Jogo" + "Encontrada último compartimento de Estado de Jogo" ) MSG_HASH(MSG_FOUND_SHADER, "Shader encontrado" @@ -2844,10 +2844,10 @@ MSG_HASH(MSG_LIBRETRO_FRONTEND, "Frontend para Libretro" ) MSG_HASH(MSG_LOADED_STATE_FROM_SLOT, - "Estado de Jogo carregado da posição #%d." + "Estado de Jogo carregado do compartimento #%d." ) MSG_HASH(MSG_LOADED_STATE_FROM_SLOT_AUTO, - "Estado de Jogo carregado da posição #-1 (automático)." + "Estado de Jogo carregado do compartimento #-1 (automático)." ) MSG_HASH(MSG_LOADING, "Carregando" @@ -2973,10 +2973,10 @@ MSG_HASH(MSG_SAVED_NEW_CONFIG_TO, "Nova configuração salva em" ) MSG_HASH(MSG_SAVED_STATE_TO_SLOT, - "Estado de Jogo salvo na posição #%d." + "Estado de Jogo salvo no compartimento #%d." ) MSG_HASH(MSG_SAVED_STATE_TO_SLOT_AUTO, - "Estado de Jogo salvo na posição #-1 (automático)." + "Estado de Jogo salvo no compartimento #-1 (automático)." ) MSG_HASH(MSG_SAVED_SUCCESSFULLY_TO, "Salvo com sucesso em" @@ -3030,7 +3030,7 @@ MSG_HASH(MSG_STATE_SIZE, "Tamanho do Estado de Jogo" ) MSG_HASH(MSG_STATE_SLOT, - "Posição do Estado de Jogo" + "Compartimento do Estado de Jogo" ) MSG_HASH(MSG_TAKING_SCREENSHOT, "Fazendo captura de tela" @@ -3636,10 +3636,10 @@ MSG_HASH(MENU_ENUM_SUBLABEL_CLOSE_CONTENT, "Fecha o conteúdo atual. Alterações não salvas serão perdidas." ) MSG_HASH(MENU_ENUM_SUBLABEL_LOAD_STATE, - "Carregar um Estado de Jogo da posição selecionado atualmente." + "Carregar um Estado de Jogo do compartimento selecionado atualmente." ) MSG_HASH(MENU_ENUM_SUBLABEL_SAVE_STATE, - "Salvar um Estado de Jogo na posição selecionado atualmente." + "Salvar um Estado de Jogo no compartimento selecionado atualmente." ) MSG_HASH(MENU_ENUM_SUBLABEL_RESUME, "Retomar a execução do conteúdo atual e sair do Menu Rápido." @@ -3648,7 +3648,7 @@ MSG_HASH(MENU_ENUM_SUBLABEL_RESUME_CONTENT, "Retomar a execução do conteúdo atual e sair do Menu Rápido." ) MSG_HASH(MENU_ENUM_SUBLABEL_STATE_SLOT, - "Altera a posição do Estado de Jogo selecionado atualmente." + "Altera o compartimento do Estado de Jogo selecionado atualmente." ) MSG_HASH(MENU_ENUM_SUBLABEL_UNDO_LOAD_STATE, "Se um Estado de Jogo for carregado, o conteúdo voltará ao estado anterior ao carregamento." From 224b581881ccbbbd8c6a219722f9de2d16ab8ae6 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Tue, 28 Nov 2017 11:43:32 -0500 Subject: [PATCH 094/394] C89 buildfix --- menu/widgets/menu_input_dialog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/menu/widgets/menu_input_dialog.c b/menu/widgets/menu_input_dialog.c index 4b138f55ef..1017c4c4d5 100644 --- a/menu/widgets/menu_input_dialog.c +++ b/menu/widgets/menu_input_dialog.c @@ -129,7 +129,7 @@ bool menu_input_dialog_start(menu_input_ctx_line_t *line) menu_input_dialog_display_kb(); - // Only copy over the menu label and setting if they exist. + /* Only copy over the menu label and setting if they exist. */ if (line->label) strlcpy(menu_input_dialog_keyboard_label, line->label, sizeof(menu_input_dialog_keyboard_label)); From 2dd64d9c118fcc76953b6dc2f80a3bfb4fcb7574 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Tue, 28 Nov 2017 18:25:12 -0500 Subject: [PATCH 095/394] Initial blissbox support, requires firmware 2.0. Currently limited to platforms with libusb support. --- input/include/blissbox.h | 98 +++++++++++++++++++++++++++ tasks/task_autodetect.c | 141 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 239 insertions(+) create mode 100644 input/include/blissbox.h diff --git a/input/include/blissbox.h b/input/include/blissbox.h new file mode 100644 index 0000000000..bddb5b6bb6 --- /dev/null +++ b/input/include/blissbox.h @@ -0,0 +1,98 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2014 - Hans-Kristian Arntzen + * Copyright (C) 2011-2016 - Daniel De Matteis + * Copyright (C) 2016-2017 - Brad Parker + * + * RetroArch 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 Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch 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 RetroArch. + * If not, see . + */ + +#ifndef __BLISSBOX_H +#define __BLISSBOX_H + +#include + +#define BLISSBOX_VID 0x16d0 /* requires firmware 2.0 */ +#define BLISSBOX_PID 0x0d04 /* first of 4 controllers, each one increments PID by 1 */ +#define BLISSBOX_MAX_PADS 4 +#define BLISSBOX_MAX_PAD_INDEX (BLISSBOX_MAX_PADS - 1) + +#define BLISSBOX_USB_FEATURE_REPORT_ID 17 + +RETRO_BEGIN_DECLS + +typedef struct { + const char *name; + int index; +} blissbox_pad_type_t; + +const blissbox_pad_type_t blissbox_pad_types[] = +{ + {"A5200", 6}, + {"A5200_TB", 50}, + {"A7800", 4}, + {"ATARI_KEYPAD", 43}, + {"ATMARK", 10}, + {"BALLY", 42}, + {"CD32", 24}, + {"CDI", 33}, + {"COL", 1}, + {"DC_ASCI", 15}, + {"DC_PAD", 16}, + {"FC_ARKANOID", 53}, + {"FC_NES", 52}, + {"GC", 9}, + {"GC_WHEEL", 18}, + {"GEN_3", 20}, + {"GEN_6", 21}, + {"GRAVIS_EX", 38}, + {"gx4000", 2}, + {"HAMMERHEAD", 40}, + {"HPD", 7}, + {"INTELI", 14}, + {"JAG", 11}, + {"MSSW", 39}, + {"N64", 19}, + {"NEO", 49}, + {"NES", 17}, + {"PADDLES", 41}, + {"PC_FX", 26}, + {"PC_GAMEPAD", 46}, + {"PSX_DIGITAL", 65}, + {"PSX_DS", 115}, + {"PSX_DS2", 121}, + {"PSX_FS", 83}, + {"PSX_NEGCON", 51}, + {"PSX_WHEEL", 12}, + {"SAC", 34}, + {"SATURN_ANALOG", 8}, + {"SATURN_DIGITAL", 3}, + {"SMS", 22}, + {"SPEEK", 45}, + {"TG16", 23}, + {"THREE_DO", 25}, + {"THREE_DO_ANALOG", 37}, + {"VEC", 5}, + {"WII_NUNCHUK", 13}, + {"ZXSINC", 44}, + {"NES_ARKANOID", 30}, + {"NES_GUN", 28}, + {"NES_POWERPAD", 36}, + {"SNES", 27}, + {"V_BOY", 29}, + {"WII_CLASSIC", 31}, + {"WII_MPLUS", 32}, + {NULL, 0}, /* used to mark unconnected ports, do not remove */ +}; + +RETRO_END_DECLS + +#endif diff --git a/tasks/task_autodetect.c b/tasks/task_autodetect.c index 7a25d9bc61..c2ea1f176e 100644 --- a/tasks/task_autodetect.c +++ b/tasks/task_autodetect.c @@ -1,6 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis + * Copyright (C) 2016-2017 - Brad Parker * * RetroArch 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 Found- @@ -24,7 +25,14 @@ #include #include +#ifdef __FreeBSD__ +#include +#else +#include +#endif + #include "../input/input_driver.h" +#include "../input/include/blissbox.h" #include "../configuration.h" #include "../file_path_special.h" @@ -33,6 +41,17 @@ #include "tasks_internal.h" +/* HID Class-Specific Requests values. See section 7.2 of the HID specifications */ +#define USB_HID_GET_REPORT 0x01 +#define USB_CTRL_IN LIBUSB_ENDPOINT_IN|LIBUSB_REQUEST_TYPE_CLASS|LIBUSB_RECIPIENT_INTERFACE +#define USB_PACKET_CTRL_LEN 64 +#define USB_TIMEOUT 5000 /* timeout in ms */ + +/* only one blissbox per machine is currently supported */ +static const blissbox_pad_type_t *blissbox_pads[BLISSBOX_MAX_PADS] = {NULL}; + +static struct libusb_device_handle *autoconfig_libusb_handle = NULL; + typedef struct autoconfig_disconnect autoconfig_disconnect_t; typedef struct autoconfig_params autoconfig_params_t; @@ -333,6 +352,126 @@ static void input_autoconfigure_params_free(autoconfig_params_t *params) params->autoconfig_directory = NULL; } +static const blissbox_pad_type_t* input_autoconfigure_get_blissbox_pad_type(int vid, int pid) +{ +#ifdef HAVE_LIBUSB + unsigned char answer[USB_PACKET_CTRL_LEN] = {0}; + unsigned i; + int ret = libusb_init(NULL); + + if (ret < 0) + { + RARCH_ERR("[Autoconfig]: Could not initialize libusb.\n"); + return NULL; + } + + autoconfig_libusb_handle = libusb_open_device_with_vid_pid(NULL, vid, pid); + + if (!autoconfig_libusb_handle) + { + RARCH_ERR("[Autoconfig]: Could not find or open libusb device %d:%d.\n", vid, pid); + goto error; + } + +#ifdef __linux__ + libusb_detach_kernel_driver(autoconfig_libusb_handle, 0); +#endif + + ret = libusb_set_configuration(autoconfig_libusb_handle, 1); + + if (ret < 0) + { + RARCH_ERR("[Autoconfig]: Error during libusb_set_configuration.\n"); + goto error; + } + + ret = libusb_claim_interface(autoconfig_libusb_handle, 0); + + if (ret < 0) + { + RARCH_ERR("[Autoconfig]: Error during libusb_claim_interface.\n"); + goto error; + } + + ret = libusb_control_transfer(autoconfig_libusb_handle, USB_CTRL_IN, USB_HID_GET_REPORT, BLISSBOX_USB_FEATURE_REPORT_ID, 0, answer, USB_PACKET_CTRL_LEN, USB_TIMEOUT); + + if (ret < 0) + RARCH_ERR("[Autoconfig]: Error during libusb_control_transfer.\n"); + + libusb_release_interface(autoconfig_libusb_handle, 0); + +#ifdef __linux__ + libusb_attach_kernel_driver(autoconfig_libusb_handle, 0); +#endif + + libusb_close(autoconfig_libusb_handle); + libusb_exit(NULL); + + for (i = 0; i < sizeof(blissbox_pad_types) / sizeof(blissbox_pad_types[0]); i++) + { + const blissbox_pad_type_t *pad = &blissbox_pad_types[i]; + + if (!pad || string_is_empty(pad->name)) + continue; + + if (pad->index == answer[0]) + return pad; + } + + RARCH_LOG("[Autoconfig]: Could not find pad type for Bliss-Box in port#%d.\n", pid - BLISSBOX_PID); + + return NULL; +#else + return NULL; +#endif +error: + libusb_close(autoconfig_libusb_handle); + libusb_exit(NULL); + return NULL; +} + +static void input_autoconfigure_override_handler(autoconfig_params_t *params) +{ + if (params->vid == BLISSBOX_VID) + { + if (params->pid >= BLISSBOX_PID && params->pid <= BLISSBOX_PID + BLISSBOX_MAX_PAD_INDEX) + { + const blissbox_pad_type_t *pad; + char name[255] = {0}; + int index = params->pid - BLISSBOX_PID; + + RARCH_LOG("[Autoconf]: Bliss-Box detected. Fetching pad type...\n"); + + if (blissbox_pads[index]) + pad = blissbox_pads[index]; + else + pad = input_autoconfigure_get_blissbox_pad_type(params->vid, params->pid); + + if (pad && !string_is_empty(pad->name)) + { + RARCH_LOG("[Autoconf]: Found Bliss-Box pad type: %s (%d) in port#%d\n", pad->name, pad->index, index); + + if (params->name) + free(params->name); + + /* override name given to autoconfig so it knows what kind of pad this is */ + strlcat(name, "Bliss-Box ", sizeof(name)); + strlcat(name, pad->name, sizeof(name)); + + params->name = strdup(name); + + blissbox_pads[index] = pad; + } + else + { + int count = sizeof(blissbox_pad_types) / sizeof(blissbox_pad_types[0]); + /* use NULL entry to mark as an unconnected port */ + blissbox_pads[index] = &blissbox_pad_types[count - 1]; + } + } + } +} + static void input_autoconfigure_connect_handler(retro_task_t *task) { autoconfig_params_t *params = (autoconfig_params_t*)task->state; @@ -499,6 +638,8 @@ bool input_autoconfigure_connect( state->max_users = *( input_driver_get_uint(INPUT_ACTION_MAX_USERS)); + input_autoconfigure_override_handler(state); + if (!string_is_empty(state->name)) input_config_set_device_name(state->idx, state->name); input_config_set_pid(state->idx, state->pid); From def24ef8eb189687540f2900251dee37403833de Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Tue, 28 Nov 2017 21:25:54 -0500 Subject: [PATCH 096/394] blissbox: print message if detecting update mode or old firmware versions, override vid/pid check for autoconfig profiles, misc comments --- input/include/blissbox.h | 2 ++ tasks/task_autodetect.c | 27 +++++++++++++++++---------- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/input/include/blissbox.h b/input/include/blissbox.h index bddb5b6bb6..fd515ee218 100644 --- a/input/include/blissbox.h +++ b/input/include/blissbox.h @@ -22,6 +22,8 @@ #define BLISSBOX_VID 0x16d0 /* requires firmware 2.0 */ #define BLISSBOX_PID 0x0d04 /* first of 4 controllers, each one increments PID by 1 */ +#define BLISSBOX_UPDATE_MODE_PID 0x0a5f +#define BLISSBOX_OLD_PID 0x0a60 #define BLISSBOX_MAX_PADS 4 #define BLISSBOX_MAX_PAD_INDEX (BLISSBOX_MAX_PADS - 1) diff --git a/tasks/task_autodetect.c b/tasks/task_autodetect.c index c2ea1f176e..d5f162f747 100644 --- a/tasks/task_autodetect.c +++ b/tasks/task_autodetect.c @@ -139,13 +139,16 @@ static int input_autoconfigure_joypad_try_from_conf(config_file_t *conf, if (config_get_int (conf, "input_product_id", &tmp_int)) input_pid = tmp_int; + if (params->vid == BLISSBOX_VID) + input_pid = BLISSBOX_PID; + /* Check for VID/PID */ if ( (params->vid == input_vid) && (params->pid == input_pid) && (params->vid != 0) && (params->pid != 0) - && (input_vid != 0) - && (input_pid != 0)) + && (params->vid != BLISSBOX_VID) + && (params->pid != BLISSBOX_PID)) score += 3; /* Check for name match */ @@ -361,7 +364,7 @@ static const blissbox_pad_type_t* input_autoconfigure_get_blissbox_pad_type(int if (ret < 0) { - RARCH_ERR("[Autoconfig]: Could not initialize libusb.\n"); + RARCH_ERR("[Autoconf]: Could not initialize libusb.\n"); return NULL; } @@ -369,7 +372,7 @@ static const blissbox_pad_type_t* input_autoconfigure_get_blissbox_pad_type(int if (!autoconfig_libusb_handle) { - RARCH_ERR("[Autoconfig]: Could not find or open libusb device %d:%d.\n", vid, pid); + RARCH_ERR("[Autoconf]: Could not find or open libusb device %d:%d.\n", vid, pid); goto error; } @@ -381,7 +384,7 @@ static const blissbox_pad_type_t* input_autoconfigure_get_blissbox_pad_type(int if (ret < 0) { - RARCH_ERR("[Autoconfig]: Error during libusb_set_configuration.\n"); + RARCH_ERR("[Autoconf]: Error during libusb_set_configuration.\n"); goto error; } @@ -389,14 +392,14 @@ static const blissbox_pad_type_t* input_autoconfigure_get_blissbox_pad_type(int if (ret < 0) { - RARCH_ERR("[Autoconfig]: Error during libusb_claim_interface.\n"); + RARCH_ERR("[Autoconf]: Error during libusb_claim_interface.\n"); goto error; } ret = libusb_control_transfer(autoconfig_libusb_handle, USB_CTRL_IN, USB_HID_GET_REPORT, BLISSBOX_USB_FEATURE_REPORT_ID, 0, answer, USB_PACKET_CTRL_LEN, USB_TIMEOUT); if (ret < 0) - RARCH_ERR("[Autoconfig]: Error during libusb_control_transfer.\n"); + RARCH_ERR("[Autoconf]: Error during libusb_control_transfer.\n"); libusb_release_interface(autoconfig_libusb_handle, 0); @@ -418,7 +421,7 @@ static const blissbox_pad_type_t* input_autoconfigure_get_blissbox_pad_type(int return pad; } - RARCH_LOG("[Autoconfig]: Could not find pad type for Bliss-Box in port#%d.\n", pid - BLISSBOX_PID); + RARCH_LOG("[Autoconf]: Could not find connected pad in Bliss-Box port#%d.\n", pid - BLISSBOX_PID); return NULL; #else @@ -434,13 +437,17 @@ static void input_autoconfigure_override_handler(autoconfig_params_t *params) { if (params->vid == BLISSBOX_VID) { - if (params->pid >= BLISSBOX_PID && params->pid <= BLISSBOX_PID + BLISSBOX_MAX_PAD_INDEX) + if (params->pid == BLISSBOX_UPDATE_MODE_PID) + RARCH_LOG("[Autoconf]: Bliss-Box in update mode detected. Ignoring.\n"); + else if (params->pid == BLISSBOX_OLD_PID) + RARCH_LOG("[Autoconf]: Bliss-Box 1.0 firmware detected. Please update to 2.0 or later.\n"); + else if (params->pid >= BLISSBOX_PID && params->pid <= BLISSBOX_PID + BLISSBOX_MAX_PAD_INDEX) { const blissbox_pad_type_t *pad; char name[255] = {0}; int index = params->pid - BLISSBOX_PID; - RARCH_LOG("[Autoconf]: Bliss-Box detected. Fetching pad type...\n"); + RARCH_LOG("[Autoconf]: Bliss-Box detected. Getting pad type...\n"); if (blissbox_pads[index]) pad = blissbox_pads[index]; From 5a2dff0ff13e25cf9bc8c822550b5030c9ac9306 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Tue, 28 Nov 2017 22:32:41 -0500 Subject: [PATCH 097/394] only use libusb code if we have support for it --- tasks/task_autodetect.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tasks/task_autodetect.c b/tasks/task_autodetect.c index d5f162f747..364cffea8a 100644 --- a/tasks/task_autodetect.c +++ b/tasks/task_autodetect.c @@ -25,11 +25,13 @@ #include #include +#ifdef HAVE_LIBUSB #ifdef __FreeBSD__ #include #else #include #endif +#endif #include "../input/input_driver.h" #include "../input/include/blissbox.h" @@ -50,7 +52,9 @@ /* only one blissbox per machine is currently supported */ static const blissbox_pad_type_t *blissbox_pads[BLISSBOX_MAX_PADS] = {NULL}; +#ifdef HAVE_LIBUSB static struct libusb_device_handle *autoconfig_libusb_handle = NULL; +#endif typedef struct autoconfig_disconnect autoconfig_disconnect_t; typedef struct autoconfig_params autoconfig_params_t; @@ -424,13 +428,14 @@ static const blissbox_pad_type_t* input_autoconfigure_get_blissbox_pad_type(int RARCH_LOG("[Autoconf]: Could not find connected pad in Bliss-Box port#%d.\n", pid - BLISSBOX_PID); return NULL; -#else - return NULL; -#endif + error: libusb_close(autoconfig_libusb_handle); libusb_exit(NULL); return NULL; +#else + return NULL; +#endif } static void input_autoconfigure_override_handler(autoconfig_params_t *params) From e2837d7dfbe46ebb7961026157e592e35ed56540 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Tue, 28 Nov 2017 22:34:34 -0500 Subject: [PATCH 098/394] add libusb to travis file --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 73b48fb889..b742d8d89d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,6 +29,7 @@ matrix: - llvm-toolchain-precise-3.8 packages: - clang-3.8 + - libusb-1.0-0-dev env: COMPILER_NAME=clang-3.8 CXX=clang++-3.8 CC=clang-3.8 - os: osx osx_image: xcode7.3 From 5279b02dce0eaab3d6f0bc5c0caeb7434757e718 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Tue, 28 Nov 2017 23:16:38 -0500 Subject: [PATCH 099/394] travis: libusb package was in wrong place --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index b742d8d89d..a67a17b635 100644 --- a/.travis.yml +++ b/.travis.yml @@ -29,7 +29,6 @@ matrix: - llvm-toolchain-precise-3.8 packages: - clang-3.8 - - libusb-1.0-0-dev env: COMPILER_NAME=clang-3.8 CXX=clang++-3.8 CC=clang-3.8 - os: osx osx_image: xcode7.3 @@ -56,6 +55,7 @@ addons: - libsdl-image1.2-dev - libsdl-mixer1.2-dev - libsdl-ttf2.0-dev + - libusb-1.0-0-dev coverity_scan: project: name: "RetroArch" From aa1f95b3d51035555d5c6665ca5901f1fe0c5e2a Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Wed, 29 Nov 2017 10:22:30 -0500 Subject: [PATCH 100/394] undo changes in c5bdc02 that reverted my previous commits: 34491a6 28c6237 1f58d9c 61bd9d7 --- input/drivers_hid/libusb_hid.c | 71 +++++++++++++++++++++------------- 1 file changed, 45 insertions(+), 26 deletions(-) diff --git a/input/drivers_hid/libusb_hid.c b/input/drivers_hid/libusb_hid.c index 1608cef89a..d0eb1250d7 100644 --- a/input/drivers_hid/libusb_hid.c +++ b/input/drivers_hid/libusb_hid.c @@ -16,7 +16,11 @@ #include #include +#ifdef __FreeBSD__ +#include +#else #include +#endif #include #include @@ -38,7 +42,11 @@ typedef struct libusb_hid libusb_context *ctx; joypad_connection_t *slots; sthread_t *poll_thread; +#if defined(__FreeBSD__) && LIBUSB_API_VERSION <= 0x01000102 + libusb_hotplug_callback_handle hp; +#else int hp; /* libusb_hotplug_callback_handle is just int */ +#endif int quit; } libusb_hid_t; @@ -85,13 +93,13 @@ static void adapter_thread(void *data) int size = 0; slock_lock(adapter->send_control_lock); - if (fifo_read_avail(adapter->send_control_buffer) + if (fifo_read_avail(adapter->send_control_buffer) >= sizeof(send_command_size)) { fifo_read(adapter->send_control_buffer, &send_command_size, sizeof(send_command_size)); - if (fifo_read_avail(adapter->send_control_buffer) + if (fifo_read_avail(adapter->send_control_buffer) >= sizeof(send_command_size)) { fifo_read(adapter->send_control_buffer, @@ -157,7 +165,13 @@ static void libusb_get_description(struct libusb_device *device, unsigned i, k; struct libusb_config_descriptor *config; - libusb_get_config_descriptor(device, 0, &config); + int desc_ret = libusb_get_config_descriptor(device, 0, &config); + + if (desc_ret != 0) + { + RARCH_ERR("Error %d getting libusb config descriptor\n", desc_ret); + return; + } for (i = 0; i < (int)config->bNumInterfaces; i++) { @@ -165,7 +179,7 @@ static void libusb_get_description(struct libusb_device *device, for(j = 0; j < inter->num_altsetting; j++) { - const struct libusb_interface_descriptor *interdesc = + const struct libusb_interface_descriptor *interdesc = &inter->altsetting[j]; #if 0 @@ -176,13 +190,13 @@ static void libusb_get_description(struct libusb_device *device, for(k = 0; k < (int)interdesc->bNumEndpoints; k++) { - const struct libusb_endpoint_descriptor *epdesc = + const struct libusb_endpoint_descriptor *epdesc = &interdesc->endpoint[k]; - bool is_int = (epdesc->bmAttributes & LIBUSB_TRANSFER_TYPE_MASK) + bool is_int = (epdesc->bmAttributes & LIBUSB_TRANSFER_TYPE_MASK) == LIBUSB_TRANSFER_TYPE_INTERRUPT; - bool is_out = (epdesc->bEndpointAddress & LIBUSB_ENDPOINT_DIR_MASK) + bool is_out = (epdesc->bEndpointAddress & LIBUSB_ENDPOINT_DIR_MASK) == LIBUSB_ENDPOINT_OUT; - bool is_in = (epdesc->bEndpointAddress & LIBUSB_ENDPOINT_DIR_MASK) + bool is_in = (epdesc->bEndpointAddress & LIBUSB_ENDPOINT_DIR_MASK) == LIBUSB_ENDPOINT_IN; if (is_int) @@ -200,11 +214,12 @@ static void libusb_get_description(struct libusb_device *device, } } } + goto ret; } } - ret: +ret: libusb_free_config_descriptor(config); } @@ -426,30 +441,27 @@ static const char *libusb_hid_joypad_name(void *data, unsigned pad) return NULL; } -static void libusb_hid_joypad_get_buttons(void *data, unsigned port, retro_bits_t *state) +static uint64_t libusb_hid_joypad_get_buttons(void *data, unsigned port) { - libusb_hid_t *hid = (libusb_hid_t*)data; - if (hid) { - return pad_connection_get_buttons(&hid->slots[port], port, state); - } else { - RARCH_INPUT_STATE_CLEAR_PTR( state ); - } + libusb_hid_t *hid = (libusb_hid_t*)data; + if (hid) + return pad_connection_get_buttons(&hid->slots[port], port); + return 0; } static bool libusb_hid_joypad_button(void *data, unsigned port, uint16_t joykey) { - retro_bits_t buttons; - libusb_hid_joypad_get_buttons(data, port, &buttons); + uint64_t buttons = libusb_hid_joypad_get_buttons(data, port); - /* Check hat. */ - if (GET_HAT_DIR(joykey)) - return false; + /* Check hat. */ + if (GET_HAT_DIR(joykey)) + return false; - /* Check the button. */ - if ((port < MAX_USERS) && (joykey < 32)) - return (RARCH_INPUT_STATE_BIT_GET(buttons, joykey) != 0); - return false; + /* Check the button. */ + if ((port < MAX_USERS) && (joykey < 32)) + return ((buttons & (1 << joykey)) != 0); + return false; } static bool libusb_hid_joypad_rumble(void *data, unsigned pad, @@ -505,7 +517,8 @@ static void libusb_hid_free(void *data) sthread_join(hid->poll_thread); } - pad_connection_destroy(hid->slots); + if (hid->slots) + pad_connection_destroy(hid->slots); libusb_hotplug_deregister_callback(hid->ctx, hid->hp); @@ -540,8 +553,14 @@ static void *libusb_hid_init(void) if (ret < 0) goto error; +#if 0 + /* Don't use this for now since it requires a newer API + * version than FreeBSD has, and always returns false on Windows anyway. + * https://github.com/libusb/libusb/issues/86 + */ if (!libusb_has_capability(LIBUSB_CAP_HAS_HOTPLUG)) goto error; +#endif hid->slots = pad_connection_init(MAX_USERS); From 42e81dcef4fd3f35166404fe2b22b51dcd9d038d Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Wed, 29 Nov 2017 10:35:52 -0500 Subject: [PATCH 101/394] add back missing code from c5bdc02 --- input/drivers_hid/libusb_hid.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/input/drivers_hid/libusb_hid.c b/input/drivers_hid/libusb_hid.c index d0eb1250d7..6638b014e0 100644 --- a/input/drivers_hid/libusb_hid.c +++ b/input/drivers_hid/libusb_hid.c @@ -441,18 +441,20 @@ static const char *libusb_hid_joypad_name(void *data, unsigned pad) return NULL; } -static uint64_t libusb_hid_joypad_get_buttons(void *data, unsigned port) +static void libusb_hid_joypad_get_buttons(void *data, unsigned port, retro_bits_t *state) { libusb_hid_t *hid = (libusb_hid_t*)data; if (hid) - return pad_connection_get_buttons(&hid->slots[port], port); - return 0; + return pad_connection_get_buttons(&hid->slots[port], port, state); + else + RARCH_INPUT_STATE_CLEAR_PTR(state); } static bool libusb_hid_joypad_button(void *data, unsigned port, uint16_t joykey) { - uint64_t buttons = libusb_hid_joypad_get_buttons(data, port); + retro_bits_t buttons; + libusb_hid_joypad_get_buttons(data, port, &buttons); /* Check hat. */ if (GET_HAT_DIR(joykey)) @@ -460,7 +462,7 @@ static bool libusb_hid_joypad_button(void *data, /* Check the button. */ if ((port < MAX_USERS) && (joykey < 32)) - return ((buttons & (1 << joykey)) != 0); + return (RARCH_INPUT_STATE_BIT_GET(buttons, joykey) != 0); return false; } From 44b70efb68d06e157ba4ac12775970e9d48b21a5 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Wed, 29 Nov 2017 10:42:39 -0500 Subject: [PATCH 102/394] style nits --- input/drivers_hid/btstack_hid.c | 32 +++++++++--------- input/drivers_hid/iohidmanager_hid.c | 21 ++++++------ input/drivers_hid/wiiusb_hid.c | 49 ++++++++++++++-------------- 3 files changed, 50 insertions(+), 52 deletions(-) diff --git a/input/drivers_hid/btstack_hid.c b/input/drivers_hid/btstack_hid.c index f5f2a86296..10df710342 100644 --- a/input/drivers_hid/btstack_hid.c +++ b/input/drivers_hid/btstack_hid.c @@ -573,7 +573,7 @@ void hexdump(void *data, int size); void printUUID(uint8_t *uuid); /* Deprecated - please use more convenient bd_addr_to_str. */ -void print_bd_addr( bd_addr_t addr); +void print_bd_addr(bd_addr_t addr); char * bd_addr_to_str(bd_addr_t addr); @@ -1365,28 +1365,28 @@ static const char *btstack_hid_joypad_name(void *data, unsigned pad) static void btstack_hid_joypad_get_buttons(void *data, unsigned port, retro_bits_t *state) { - btstack_hid_t *hid = (btstack_hid_t*)data; - if ( hid ) { - pad_connection_get_buttons(&hid->slots[port], port, state); - } else { - RARCH_INPUT_STATE_CLEAR_PTR( state ); - } + btstack_hid_t *hid = (btstack_hid_t*)data; + if (hid) + pad_connection_get_buttons(&hid->slots[port], port, state); + else + RARCH_INPUT_STATE_CLEAR_PTR(state); + } } static bool btstack_hid_joypad_button(void *data, unsigned port, uint16_t joykey) { - retro_bits_t buttons; - btstack_hid_joypad_get_buttons(data, port, &buttons); + retro_bits_t buttons; + btstack_hid_joypad_get_buttons(data, port, &buttons); - /* Check hat. */ - if (GET_HAT_DIR(joykey)) - return false; + /* Check hat. */ + if (GET_HAT_DIR(joykey)) + return false; - /* Check the button. */ - if ((port < MAX_USERS) && (joykey < 32)) - return ( RARCH_INPUT_STATE_BIT_GET( buttons, joykey ) != 0 ); + /* Check the button. */ + if ((port < MAX_USERS) && (joykey < 32)) + return (RARCH_INPUT_STATE_BIT_GET(buttons, joykey) != 0); - return false; + return false; } static bool btstack_hid_joypad_rumble(void *data, unsigned pad, diff --git a/input/drivers_hid/iohidmanager_hid.c b/input/drivers_hid/iohidmanager_hid.c index c832417bd4..aac33afd56 100644 --- a/input/drivers_hid/iohidmanager_hid.c +++ b/input/drivers_hid/iohidmanager_hid.c @@ -110,22 +110,21 @@ static const char *iohidmanager_hid_joypad_name(void *data, unsigned pad) static void iohidmanager_hid_joypad_get_buttons(void *data, unsigned port, retro_bits_t *state) { - iohidmanager_hid_t *hid = (iohidmanager_hid_t*)data; - if (hid) { - return pad_connection_get_buttons(&hid->slots[port], port, state); - } else { - RARCH_INPUT_STATE_CLEAR_PTR( state ); - } + iohidmanager_hid_t *hid = (iohidmanager_hid_t*)data; + if (hid) + return pad_connection_get_buttons(&hid->slots[port], port, state); + else + RARCH_INPUT_STATE_CLEAR_PTR(state); } static bool iohidmanager_hid_joypad_button(void *data, unsigned port, uint16_t joykey) { - retro_bits_t buttons; - iohidmanager_hid_t *hid = (iohidmanager_hid_t*)data; - unsigned hat_dir = GET_HAT_DIR(joykey); + retro_bits_t buttons; + iohidmanager_hid_t *hid = (iohidmanager_hid_t*)data; + unsigned hat_dir = GET_HAT_DIR(joykey); - iohidmanager_hid_joypad_get_buttons(data, port, &buttons); + iohidmanager_hid_joypad_get_buttons(data, port, &buttons); /* Check hat. */ if (hat_dir) @@ -151,7 +150,7 @@ static bool iohidmanager_hid_joypad_button(void *data, /* Check the button. */ if ((port < MAX_USERS) && (joykey < 32)) - return (RARCH_INPUT_STATE_BIT_GET( buttons, joykey ) != 0) + return (RARCH_INPUT_STATE_BIT_GET(buttons, joykey) != 0) || ((hid->buttons[port] & (1 << joykey)) != 0); return false; diff --git a/input/drivers_hid/wiiusb_hid.c b/input/drivers_hid/wiiusb_hid.c index 8f98c65c5a..250a8b563b 100644 --- a/input/drivers_hid/wiiusb_hid.c +++ b/input/drivers_hid/wiiusb_hid.c @@ -64,7 +64,7 @@ struct wiiusb_adapter int32_t slot; uint8_t *data; - uint8_t send_control_type; + uint8_t send_control_type; uint8_t *send_control_buffer; uint32_t send_control_size; }; @@ -113,10 +113,10 @@ static int32_t wiiusb_hid_read_cb(int32_t size, void *data) pad_connection_packet(&hid->connections[adapter->slot], adapter->slot, adapter->data-1, size+1); - if (adapter) + if (adapter) adapter->busy = false; - return size; + return size; } static void wiiusb_hid_device_send_control(void *data, @@ -398,7 +398,7 @@ static void wiiusb_hid_scan_for_devices(wiiusb_hid_t *hid) for (i = 0; i < count; i++) { - /* first check the device is not already in our list */ + /* first check the device is not already in our list */ if (!wiiusb_hid_new_device(hid, dev_entries[i].device_id)) continue; @@ -461,11 +461,11 @@ static int wiiusb_hid_change_cb(int result, void *usrdata) return -1; /* As it's not coming from the removal callback - then we detected a new device being inserted */ - if (!hid->removal_cb) - hid->device_detected = true; - else - hid->removal_cb = false; + then we detected a new device being inserted */ + if (!hid->removal_cb) + hid->device_detected = true; + else + hid->removal_cb = false; /* Re-submit the change alert */ USB_DeviceChangeNotifyAsync(USB_CLASS_HID, wiiusb_hid_change_cb, usrdata); @@ -480,35 +480,34 @@ static bool wiiusb_hid_joypad_query(void *data, unsigned pad) static void wiiusb_hid_joypad_get_buttons(void *data, unsigned port, retro_bits_t *state) { - wiiusb_hid_t *hid = (wiiusb_hid_t*)data; - if (hid) { - return pad_connection_get_buttons(&hid->connections[port], port, state); - } else { - RARCH_INPUT_STATE_CLEAR_PTR( state ); - } + wiiusb_hid_t *hid = (wiiusb_hid_t*)data; + if (hid) + return pad_connection_get_buttons(&hid->connections[port], port, state); + else + RARCH_INPUT_STATE_CLEAR_PTR(state); } static bool wiiusb_hid_joypad_button(void *data, unsigned port, uint16_t joykey) { - retro_bits_t buttons; + retro_bits_t buttons; - wiiusb_hid_joypad_get_buttons(data, port, &buttons); + wiiusb_hid_joypad_get_buttons(data, port, &buttons); - /* Check hat. */ - if (GET_HAT_DIR(joykey)) - return false; + /* Check hat. */ + if (GET_HAT_DIR(joykey)) + return false; - /* Check the button. */ - if ((port < MAX_USERS) && (joykey < 32)) - return (RARCH_INPUT_STATE_BIT_GET(buttons, joykey)) != 0); + /* Check the button. */ + if ((port < MAX_USERS) && (joykey < 32)) + return (RARCH_INPUT_STATE_BIT_GET(buttons, joykey)) != 0); - return false; + return false; } static bool wiiusb_hid_joypad_rumble(void *data, unsigned pad, enum retro_rumble_effect effect, uint16_t strength) { - wiiusb_hid_t *hid = (wiiusb_hid_t*)data; + wiiusb_hid_t *hid = (wiiusb_hid_t*)data; if (!hid) return false; From f41187df2293e71f2fc76f09c8a7d620644da2f0 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Wed, 29 Nov 2017 11:17:13 -0500 Subject: [PATCH 103/394] remove extra brace --- input/drivers_hid/btstack_hid.c | 1 - 1 file changed, 1 deletion(-) diff --git a/input/drivers_hid/btstack_hid.c b/input/drivers_hid/btstack_hid.c index 10df710342..83eec68c61 100644 --- a/input/drivers_hid/btstack_hid.c +++ b/input/drivers_hid/btstack_hid.c @@ -1370,7 +1370,6 @@ static void btstack_hid_joypad_get_buttons(void *data, unsigned port, retro_bits pad_connection_get_buttons(&hid->slots[port], port, state); else RARCH_INPUT_STATE_CLEAR_PTR(state); - } } static bool btstack_hid_joypad_button(void *data, unsigned port, uint16_t joykey) From 54538530014b5efe3d28746703f74ebef1c353fe Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Wed, 29 Nov 2017 11:32:32 -0500 Subject: [PATCH 104/394] remove extra paren --- input/drivers_hid/wiiusb_hid.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/input/drivers_hid/wiiusb_hid.c b/input/drivers_hid/wiiusb_hid.c index 250a8b563b..3f0fdb282c 100644 --- a/input/drivers_hid/wiiusb_hid.c +++ b/input/drivers_hid/wiiusb_hid.c @@ -499,7 +499,7 @@ static bool wiiusb_hid_joypad_button(void *data, unsigned port, uint16_t joykey) /* Check the button. */ if ((port < MAX_USERS) && (joykey < 32)) - return (RARCH_INPUT_STATE_BIT_GET(buttons, joykey)) != 0); + return (RARCH_INPUT_STATE_BIT_GET(buttons, joykey) != 0); return false; } From ed99c36851920a9021d494ea0077e8baa6220986 Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Wed, 29 Nov 2017 11:46:11 -0500 Subject: [PATCH 105/394] Use retroarch-assets makefile to install assets --- Makefile | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/Makefile b/Makefile index 8e70dd430d..f9f1876a9a 100644 --- a/Makefile +++ b/Makefile @@ -201,17 +201,7 @@ install: $(TARGET) install -m644 media/retroarch.svg $(DESTDIR)$(PREFIX)/share/pixmaps @if test -d media/assets; then \ echo "Installing media assets..."; \ - mkdir -p $(DESTDIR)$(ASSETS_DIR)/retroarch/assets/xmb; \ - mkdir -p $(DESTDIR)$(ASSETS_DIR)/retroarch/assets/glui; \ - cp -r media/assets/xmb/ $(DESTDIR)$(ASSETS_DIR)/retroarch/assets; \ - cp -r media/assets/glui/ $(DESTDIR)$(ASSETS_DIR)/retroarch/assets; \ - echo "Removing unneeded source image files.."; \ - rm -rf $(DESTDIR)$(ASSETS_DIR)/retroarch/assets/xmb/flatui/src; \ - rm -rf $(DESTDIR)$(ASSETS_DIR)/retroarch/assets/xmb/monochrome/src; \ - rm -rf $(DESTDIR)$(ASSETS_DIR)/retroarch/assets/xmb/retroactive/src; \ - rm -rf $(DESTDIR)$(ASSETS_DIR)/retroarch/assets/xmb/neoactive/src; \ - rm -rf $(DESTDIR)$(ASSETS_DIR)/retroarch/assets/xmb/retrosystem/src; \ - rm -rf $(DESTDIR)$(ASSETS_DIR)/retroarch/assets/xmb/dot-art/src; \ + $(MAKE) install -C media/assets INSTALLDIR=$(ASSETS_DIR)/retroarch/assets; \ echo "Asset copying done."; \ fi From 825887810b51eee9de0c012afb6dcd7200d1a4b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s?= Date: Wed, 29 Nov 2017 12:03:21 -0500 Subject: [PATCH 106/394] Create PULL_REQUEST_TEMPLATE --- .github/PULL_REQUEST_TEMPLATE | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/PULL_REQUEST_TEMPLATE diff --git a/.github/PULL_REQUEST_TEMPLATE b/.github/PULL_REQUEST_TEMPLATE new file mode 100644 index 0000000000..00a283e2ad --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE @@ -0,0 +1,22 @@ +## Guidelines + +1. Rebase before opening a pull request +2. If you are sending several unrelated fixes or features, use a branch and a separate pull request for each +3. If possible try squashing everything in a single commit. This is particularly beneficial in the case of feature merges since it allows easy bisecting when a problem arises + + +## Description + +[Description of the pull request, detail any issues you are fixing or any features you are implementing] + +## Related Issues + +[Any issues this pull request may be addressing] + +## Related Pull Requests + +[Any other PRs from related repositories that might be needed for this pull request to work] + +## Reviewers + +[If possible @mention all the people that should review your pull request] From cc2080c04f150927f2c6857eb807f5583596c8d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s?= Date: Wed, 29 Nov 2017 12:03:42 -0500 Subject: [PATCH 107/394] Rename PULL_REQUEST_TEMPLATE to PULL_REQUEST_TEMPLATE.md --- .github/{PULL_REQUEST_TEMPLATE => PULL_REQUEST_TEMPLATE.md} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename .github/{PULL_REQUEST_TEMPLATE => PULL_REQUEST_TEMPLATE.md} (100%) diff --git a/.github/PULL_REQUEST_TEMPLATE b/.github/PULL_REQUEST_TEMPLATE.md similarity index 100% rename from .github/PULL_REQUEST_TEMPLATE rename to .github/PULL_REQUEST_TEMPLATE.md From 7dfcc169de9016eb3db440c20351963c43c83071 Mon Sep 17 00:00:00 2001 From: David Walters Date: Wed, 29 Nov 2017 18:32:58 +0000 Subject: [PATCH 108/394] Add new lighgun/mouse-bind features to X11 driver --- input/drivers/x11_input.c | 197 ++++++++++++++++++++++++++++++-------- 1 file changed, 157 insertions(+), 40 deletions(-) diff --git a/input/drivers/x11_input.c b/input/drivers/x11_input.c index 40842f0719..e21e9a100e 100644 --- a/input/drivers/x11_input.c +++ b/input/drivers/x11_input.c @@ -30,6 +30,7 @@ #include "../../gfx/video_driver.h" #include "../common/input_x11_common.h" +#include "../../configuration.h" #include "../../verbosity.h" typedef struct x11_input @@ -72,6 +73,78 @@ static void *x_input_init(const char *joypad_driver) return x11; } +static bool x_keyboard_pressed(x11_input_t *x11, unsigned key) +{ + int keycode = XKeysymToKeycode(x11->display, rarch_keysym_lut[(enum retro_key)key]); + return x11->state[keycode >> 3] & (1 << (keycode & 7)); +} + +static bool x_mbutton_pressed(x11_input_t *x11, unsigned port, unsigned key) +{ + bool result; + settings_t *settings = config_get_ptr(); + + if (port >= MAX_USERS) + return false; + + /* the driver only supports one mouse */ + if ( settings->uints.input_mouse_index[ port ] != 0 ) + return false; + + switch ( key ) + { + + case RETRO_DEVICE_ID_MOUSE_LEFT: + return x11->mouse_l; + case RETRO_DEVICE_ID_MOUSE_RIGHT: + return x11->mouse_r; + case RETRO_DEVICE_ID_MOUSE_MIDDLE: + return x11->mouse_m; +/* case RETRO_DEVICE_ID_MOUSE_BUTTON_4: + return x11->mouse_b4;*/ +/* case RETRO_DEVICE_ID_MOUSE_BUTTON_5: + return x11->mouse_b5;*/ + + case RETRO_DEVICE_ID_MOUSE_WHEELUP: + case RETRO_DEVICE_ID_MOUSE_WHEELDOWN: + return x_mouse_state_wheel( key ); + +/* case RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELUP: + result = x11->mouse_hwu; + x11->mouse_hwu = false; + return result; + + case RETRO_DEVICE_ID_MOUSE_HORIZ_WHEELDOWN: + result = x11->mouse_hwd; + x11->mouse_hwd = false; + return result; +*/ + } + + return false; +} + +static bool x_is_pressed(x11_input_t *x11, + rarch_joypad_info_t joypad_info, + const struct retro_keybind *binds, + unsigned port, unsigned id) +{ + const struct retro_keybind *bind = &binds[id]; + + if ( (bind->key < RETROK_LAST) && x_keyboard_pressed(x11, bind->key) ) + return true; + + if (binds && binds[id].valid) + { + if (x_mbutton_pressed(x11, port, bind->mbutton)) + return true; + if (input_joypad_pressed(x11->joypad, joypad_info, port, binds, id)) + return true; + } + + return false; +} + static int16_t x_pressed_analog(x11_input_t *x11, const struct retro_keybind *binds, unsigned idx, unsigned id) { @@ -111,6 +184,44 @@ static bool x_input_meta_key_pressed(void *data, int key) return false; } +static int16_t x_lightgun_aiming_state( x11_input_t *x11, unsigned idx, unsigned id ) +{ + const int edge_detect = 32700; + struct video_viewport vp; + bool inside = false; + int16_t res_x = 0; + int16_t res_y = 0; + int16_t res_screen_x = 0; + int16_t res_screen_y = 0; + + vp.x = 0; + vp.y = 0; + vp.width = 0; + vp.height = 0; + vp.full_width = 0; + vp.full_height = 0; + + if (!(video_driver_translate_coord_viewport_wrap(&vp, x11->mouse_x, x11->mouse_y, + &res_x, &res_y, &res_screen_x, &res_screen_y))) + return 0; + + inside = (res_x >= -edge_detect) && (res_y >= -edge_detect) && (res_x <= edge_detect) && (res_y <= edge_detect); + + switch ( id ) + { + case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X: + return inside ? res_x : 0; + case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y: + return inside ? res_y : 0; + case RETRO_DEVICE_ID_LIGHTGUN_IS_OFFSCREEN: + return !inside; + default: + break; + } + + return 0; +} + static int16_t x_mouse_state(x11_input_t *x11, unsigned id) { switch (id) @@ -193,29 +304,6 @@ static int16_t x_pointer_state(x11_input_t *x11, return 0; } -static int16_t x_lightgun_state(x11_input_t *x11, unsigned id) -{ - switch (id) - { - case RETRO_DEVICE_ID_LIGHTGUN_X: - return x11->mouse_x - x11->mouse_last_x; - case RETRO_DEVICE_ID_LIGHTGUN_Y: - return x11->mouse_y - x11->mouse_last_y; - case RETRO_DEVICE_ID_LIGHTGUN_TRIGGER: - return x11->mouse_l; - case RETRO_DEVICE_ID_LIGHTGUN_CURSOR: - return x11->mouse_m; - case RETRO_DEVICE_ID_LIGHTGUN_TURBO: - return x11->mouse_r; - case RETRO_DEVICE_ID_LIGHTGUN_START: - return x11->mouse_m && x11->mouse_r; - case RETRO_DEVICE_ID_LIGHTGUN_PAUSE: - return x11->mouse_m && x11->mouse_l; - } - - return 0; -} - static int16_t x_input_state(void *data, rarch_joypad_info_t joypad_info, const struct retro_keybind **binds, unsigned port, @@ -227,23 +315,11 @@ static int16_t x_input_state(void *data, switch (device) { case RETRO_DEVICE_JOYPAD: - { - int keycode = XKeysymToKeycode(x11->display, - rarch_keysym_lut[(enum retro_key)binds[port][id].key]); - ret = (binds[port][id].key < RETROK_LAST) && (x11->state[keycode >> 3] & (1 << (keycode & 7))); - if (!ret) - ret = input_joypad_pressed(x11->joypad, - joypad_info, port, binds[port], id); - } - return ret; + if (id < RARCH_BIND_LIST_END) + return x_is_pressed(x11, joypad_info, binds[port], port, id); + break; case RETRO_DEVICE_KEYBOARD: - if (id < RETROK_LAST) - { - int keycode = XKeysymToKeycode(x11->display, - rarch_keysym_lut[(enum retro_key)id]); - ret = x11->state[keycode >> 3] & (1 << (keycode & 7)); - } - return ret; + return (id < RETROK_LAST) && x_keyboard_pressed(x11, id); case RETRO_DEVICE_ANALOG: ret = x_pressed_analog(x11, binds[port], idx, id); if (!ret && binds[port]) @@ -263,7 +339,48 @@ static int16_t x_input_state(void *data, device == RARCH_DEVICE_POINTER_SCREEN); break; case RETRO_DEVICE_LIGHTGUN: - return x_lightgun_state(x11, id); + switch ( id ) + { + /*aiming*/ + case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X: + case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y: + case RETRO_DEVICE_ID_LIGHTGUN_IS_OFFSCREEN: + return x_lightgun_aiming_state( x11, idx, id ); + + /*buttons*/ + case RETRO_DEVICE_ID_LIGHTGUN_TRIGGER: + return x_is_pressed(x11, joypad_info, binds[port], port, RARCH_LIGHTGUN_TRIGGER); + case RETRO_DEVICE_ID_LIGHTGUN_RELOAD: + return x_is_pressed(x11, joypad_info, binds[port], port, RARCH_LIGHTGUN_RELOAD); + case RETRO_DEVICE_ID_LIGHTGUN_AUX_A: + return x_is_pressed(x11, joypad_info, binds[port], port, RARCH_LIGHTGUN_AUX_A); + case RETRO_DEVICE_ID_LIGHTGUN_AUX_B: + return x_is_pressed(x11, joypad_info, binds[port], port, RARCH_LIGHTGUN_AUX_B); + case RETRO_DEVICE_ID_LIGHTGUN_AUX_C: + return x_is_pressed(x11, joypad_info, binds[port], port, RARCH_LIGHTGUN_AUX_C); + case RETRO_DEVICE_ID_LIGHTGUN_START: + return x_is_pressed(x11, joypad_info, binds[port], port, RARCH_LIGHTGUN_START); + case RETRO_DEVICE_ID_LIGHTGUN_SELECT: + return x_is_pressed(x11, joypad_info, binds[port], port, RARCH_LIGHTGUN_SELECT); + case RETRO_DEVICE_ID_LIGHTGUN_DPAD_UP: + return x_is_pressed(x11, joypad_info, binds[port], port, RARCH_LIGHTGUN_DPAD_UP); + case RETRO_DEVICE_ID_LIGHTGUN_DPAD_DOWN: + return x_is_pressed(x11, joypad_info, binds[port], port, RARCH_LIGHTGUN_DPAD_DOWN); + case RETRO_DEVICE_ID_LIGHTGUN_DPAD_LEFT: + return x_is_pressed(x11, joypad_info, binds[port], port, RARCH_LIGHTGUN_DPAD_LEFT); + case RETRO_DEVICE_ID_LIGHTGUN_DPAD_RIGHT: + return x_is_pressed(x11, joypad_info, binds[port], port, RARCH_LIGHTGUN_DPAD_RIGHT); + + /*deprecated*/ + case RETRO_DEVICE_ID_LIGHTGUN_X: + return x11->mouse_x - x11->mouse_last_x; + case RETRO_DEVICE_ID_LIGHTGUN_Y: + return x11->mouse_y - x11->mouse_last_y; + case RETRO_DEVICE_ID_LIGHTGUN_PAUSE: + return x_is_pressed(x11, joypad_info, binds[port], port, RARCH_LIGHTGUN_START); + + } + break; } return 0; From 5f095677a707286f522418e953a643ab5bfed0fa Mon Sep 17 00:00:00 2001 From: David Walters Date: Wed, 29 Nov 2017 20:55:31 +0000 Subject: [PATCH 109/394] fix for wiiu build (#5826) --- input/drivers/wiiu_input.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/input/drivers/wiiu_input.c b/input/drivers/wiiu_input.c index 9673947317..7cb9444b3c 100644 --- a/input/drivers/wiiu_input.c +++ b/input/drivers/wiiu_input.c @@ -105,7 +105,11 @@ static int16_t wiiu_pointer_device_state(wiiu_input_t* wiiu, unsigned id) switch (id) { case RETRO_DEVICE_ID_POINTER_PRESSED: - return (wiiu->joypad->get_buttons(0) & VPAD_BUTTON_TOUCH) ? 1 : 0; + { + retro_bits_t state; + wiiu->joypad->get_buttons(0,&state); + return RARCH_INPUT_STATE_BIT_GET(state, VPAD_BUTTON_TOUCH) ? 1 : 0; + } case RETRO_DEVICE_ID_POINTER_X: return wiiu->joypad->axis(0, 0xFFFF0004UL); case RETRO_DEVICE_ID_POINTER_Y: From 05578f0634d3495768474a2cf908aaccaec8cad8 Mon Sep 17 00:00:00 2001 From: David Walters Date: Wed, 29 Nov 2017 20:56:18 +0000 Subject: [PATCH 110/394] Show VID/PID values for unsupported devices. (#5825) --- input/drivers_hid/libusb_hid.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/input/drivers_hid/libusb_hid.c b/input/drivers_hid/libusb_hid.c index 6638b014e0..4165762b16 100644 --- a/input/drivers_hid/libusb_hid.c +++ b/input/drivers_hid/libusb_hid.c @@ -314,7 +314,8 @@ static int add_adapter(void *data, struct libusb_device *dev) if (!pad_connection_has_interface(hid->slots, adapter->slot)) { - RARCH_ERR(" Interface not found (%s).\n", adapter->name); + RARCH_ERR("Interface not found (%s) (VID/PID: %04x:%04x).\n", + adapter->name, desc.idVendor, desc.idProduct); goto error; } From 4e66962ba83941b85b206778828596c6ad20be33 Mon Sep 17 00:00:00 2001 From: Alcaro Date: Wed, 29 Nov 2017 21:39:35 +0000 Subject: [PATCH 111/394] #5664 --- libretro-common/streams/file_stream.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libretro-common/streams/file_stream.c b/libretro-common/streams/file_stream.c index 9f6ad73437..c4dcddf0a7 100644 --- a/libretro-common/streams/file_stream.c +++ b/libretro-common/streams/file_stream.c @@ -169,8 +169,9 @@ void filestream_set_size(RFILE *stream) * If bufsize is > 0 for unbuffered modes (like RFILE_MODE_WRITE), file will instead be fully buffered. * Returns a pointer to an RFILE if opened successfully, otherwise NULL. **/ -RFILE *filestream_open(const char *path, unsigned mode, ssize_t bufsize) +RFILE *filestream_open(const char *path, unsigned mode, ssize_t unused) { + ssize_t bufsize = 0x4000; int flags = 0; int mode_int = 0; #if defined(HAVE_BUFFERED_IO) From 562f7071f069a277c98622874fbf958a8ffc2762 Mon Sep 17 00:00:00 2001 From: radius Date: Wed, 29 Nov 2017 17:16:04 -0500 Subject: [PATCH 112/394] allow building and debugging RetroArch from Visual Studio code automatically on a MINGW64 (MSYS2) installation this works if MSYS2 is installed in the default path allow building RetroArch from the command pallete Allow building, and starting RetroArch via vscode Tasks use 3 whitespaces for tabs --- .vscode/launch.json | 28 +++++++++++++ .vscode/settings.json | 12 ++++++ .vscode/tasks.json | 91 +++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 131 insertions(+) create mode 100644 .vscode/launch.json create mode 100644 .vscode/settings.json create mode 100644 .vscode/tasks.json diff --git a/.vscode/launch.json b/.vscode/launch.json new file mode 100644 index 0000000000..53837e538f --- /dev/null +++ b/.vscode/launch.json @@ -0,0 +1,28 @@ +{ + // Use IntelliSense to learn about possible attributes. + // Hover to view descriptions of existing attributes. + // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 + "version": "0.2.0", + "configurations": [ + { + "name": "MINGW64 (MSYS2) debug", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/retroarch.exe", + "args": [], + "stopAtEntry": false, + "cwd": "${workspaceFolder}", + "environment": [], + "externalConsole": true, + "MIMode": "gdb", + "miDebuggerPath": "c:\\msys64\\mingw64\\bin\\gdb.exe", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + } + ] + } + ] +} \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000000..1fdc2bf309 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,12 @@ +{ + "terminal.integrated.shell.windows": "C:\\msys64\\usr\\bin\\bash.exe", + "terminal.integrated.env.windows": { + "PATH": "/mingw64/lib/ccache/bin:/mingw64/lib/ccache/bin:/mingw64/lib/ccache/bin:/mingw64/bin:/usr/local/bin:/usr/bin:/bin:$PATH", + "MSYSTEM": "MINGW64", + }, + "terminal.integrated.cursorBlinking": true, + + "editor.tabSize": 3, + "editor.renderWhitespace": "all", + "editor.insertSpaces": true, +} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json new file mode 100644 index 0000000000..496810ecfa --- /dev/null +++ b/.vscode/tasks.json @@ -0,0 +1,91 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=733558 + // for the documentation about the tasks.json format + "version": "2.0.0", + "tasks": [ + { + "taskName": "Build", + "type": "shell", + + "group": { + "kind": "build", + "isDefault": true }, + + "command": "./configure; make -j2", + "options": { + "shell": { + "executable": "C:\\msys64\\usr\\bin\\bash.exe", + "args": [ + "-c" + ] + } + } + } + { + "taskName": "Build with debugging symbols", + "type": "shell", + + "group": "build", + + "command": "./configure; DEBUG=1 make -j2", + "options": { + "shell": { + "executable": "C:\\msys64\\usr\\bin\\bash.exe", + "args": [ + "-c" + ] + } + } + } + { + "taskName": "Build without reconfiguring", + "type": "shell", + + "group": "build", + + "command": "make -j2", + "options": { + "shell": { + "executable": "C:\\msys64\\usr\\bin\\bash.exe", + "args": [ + "-c" + ] + } + } + } + { + "taskName": "Clean", + "type": "shell", + + "group": "build", + + "command": "make clean", + "options": { + "shell": { + "executable": "C:\\msys64\\usr\\bin\\bash.exe", + "args": [ + "-c" + ] + } + } + } + { + "taskName": "Start", + "type": "shell", + + "group": { + "kind": "test", + "isDefault": true }, + + "command": "./retroarch -v", + "options": { + "shell": { + "executable": "C:\\msys64\\usr\\bin\\bash.exe", + "args": [ + "-c" + ] + } + } + } + ] +} \ No newline at end of file From 9aeddb781a775696a8ba435db78ab9ddc5922ab0 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Wed, 29 Nov 2017 19:33:39 -0500 Subject: [PATCH 113/394] GlobalMemoryStatusEx only exists for 2000 and up --- frontend/drivers/platform_win32.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/drivers/platform_win32.c b/frontend/drivers/platform_win32.c index 02ae1dd7d3..2988b75c4e 100644 --- a/frontend/drivers/platform_win32.c +++ b/frontend/drivers/platform_win32.c @@ -340,7 +340,7 @@ static uint64_t frontend_win32_get_mem_total(void) { /* OSes below 2000 don't have the Ex version, * and non-Ex cannot work with >4GB RAM */ -#if _WIN32_WINNT > 0x0400 +#if _WIN32_WINNT >= 0x0500 MEMORYSTATUSEX mem_info; mem_info.dwLength = sizeof(MEMORYSTATUSEX); GlobalMemoryStatusEx(&mem_info); @@ -357,7 +357,7 @@ static uint64_t frontend_win32_get_mem_used(void) { /* OSes below 2000 don't have the Ex version, * and non-Ex cannot work with >4GB RAM */ -#if _WIN32_WINNT > 0x0400 +#if _WIN32_WINNT >= 0x0500 MEMORYSTATUSEX mem_info; mem_info.dwLength = sizeof(MEMORYSTATUSEX); GlobalMemoryStatusEx(&mem_info); From 2203deb499bef0bdef886d2f0415711ae6c3d62c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 30 Nov 2017 03:43:35 +0100 Subject: [PATCH 114/394] Need to include config.h here --- libretro-common/file/nbio/nbio_unixmmap.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libretro-common/file/nbio/nbio_unixmmap.c b/libretro-common/file/nbio/nbio_unixmmap.c index 25ec106cd8..40703ae138 100644 --- a/libretro-common/file/nbio/nbio_unixmmap.c +++ b/libretro-common/file/nbio/nbio_unixmmap.c @@ -20,13 +20,17 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +#include +#include + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #if defined(HAVE_MMAP) && defined(BSD) -#include -#include - #ifdef _WIN32 #include #else From 62280439b774eb4d1aac55ef7e0b769fb69eecc5 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 30 Nov 2017 07:00:09 +0100 Subject: [PATCH 115/394] Rename epfd to fd --- input/drivers/udev_input.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/input/drivers/udev_input.c b/input/drivers/udev_input.c index 01600ecdea..9f7686dc36 100644 --- a/input/drivers/udev_input.c +++ b/input/drivers/udev_input.c @@ -117,7 +117,7 @@ struct udev_input const input_device_driver_t *joypad; - int epfd; + int fd; udev_input_device_t **devices; unsigned num_devices; @@ -522,7 +522,7 @@ static bool udev_input_add_device(udev_input_t *udev, event.data.ptr = device; /* Shouldn't happen, but just check it. */ - if (epoll_ctl(udev->epfd, EPOLL_CTL_ADD, fd, &event) < 0) + if (epoll_ctl(udev->fd, EPOLL_CTL_ADD, fd, &event) < 0) { RARCH_ERR("Failed to add FD (%d) to epoll list (%s).\n", fd, strerror(errno)); @@ -666,7 +666,7 @@ static void udev_input_poll(void *data) while (udev->monitor && udev_input_poll_hotplug_available(udev->monitor)) udev_input_handle_hotplug(udev); - ret = epoll_wait(udev->epfd, events, ARRAY_SIZE(events), 0); + ret = epoll_wait(udev->fd, events, ARRAY_SIZE(events), 0); for (i = 0; i < ret; i++) { @@ -874,10 +874,10 @@ static void udev_input_free(void *data) if (udev->joypad) udev->joypad->destroy(); - if (udev->epfd >= 0) - close(udev->epfd); + if (udev->fd >= 0) + close(udev->fd); - udev->epfd = -1; + udev->fd = -1; for (i = 0; i < udev->num_devices; i++) { @@ -985,7 +985,7 @@ static void *udev_input_init(const char *joypad_driver) goto error; } - udev->epfd = fd; + udev->fd = fd; if (!open_devices(udev, UDEV_INPUT_KEYBOARD, udev_handle_keyboard)) { From 6c69002ab4b63b0f841ee0b5786f72f30b48f54a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 30 Nov 2017 07:28:59 +0100 Subject: [PATCH 116/394] Start adding not-complete kqueue codepaths - bparker - see if you can finish this up --- input/drivers/udev_input.c | 60 +++++++++++++++++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) diff --git a/input/drivers/udev_input.c b/input/drivers/udev_input.c index 9f7686dc36..a22ba8636d 100644 --- a/input/drivers/udev_input.c +++ b/input/drivers/udev_input.c @@ -14,6 +14,19 @@ * If not, see . */ +/* TODO/FIXME - set this once the kqueue codepath is implemented and working properly */ +#if 1 +#define HAVE_EPOLL +#else +#ifdef __linux__ +#define HAVE_EPOLL 1 +#endif + +#if defined(__APPLE__) || defined(__FreeBSD__) || defined(__OpenBSD__) || defined (__NetBSD__) +#define HAVE_KQUEUE 1 +#endif +#endif + #include #include @@ -25,7 +38,11 @@ #include #include +#if defined(HAVE_EPOLL) #include +#elif defined(HAVE_KQUEUE) +#include +#endif #include #include @@ -450,7 +467,11 @@ static bool udev_input_add_device(udev_input_t *udev, { int fd; struct stat st; +#if defined(HAVE_EPOLL) struct epoll_event event; +#elif defined(HAVE_KQUEUE) + struct kevent event; +#endif struct input_absinfo absinfo; udev_input_device_t **tmp; udev_input_device_t *device = NULL; @@ -518,6 +539,7 @@ static bool udev_input_add_device(udev_input_t *udev, tmp[udev->num_devices++] = device; udev->devices = tmp; +#if defined(HAVE_EPOLL) event.events = EPOLLIN; event.data.ptr = device; @@ -527,6 +549,14 @@ static bool udev_input_add_device(udev_input_t *udev, RARCH_ERR("Failed to add FD (%d) to epoll list (%s).\n", fd, strerror(errno)); } +#elif defined(HAVE_KQUEUE) + EV_SET(&event, fd, EVFILT_READ, EV_ADD, 0, 0, LISTENSOCKET); + if (kevent(udev->fd, &event, 1, NULL, 0, NULL) == -1) + { + RARCH_ERR("Failed to add FD (%d) to kqueue list (%s).\n", + fd, strerror(errno)); + } +#endif return true; @@ -639,7 +669,11 @@ static bool udev_input_poll_hotplug_available(struct udev_monitor *dev) static void udev_input_poll(void *data) { int i, ret; +#if defined(HAVE_EPOLL) struct epoll_event events[32]; +#elif defined(HAVE_KQUEUE) + struct kevent events[32]; +#endif udev_input_mouse_t *mouse = NULL; udev_input_t *udev = (udev_input_t*)data; @@ -666,15 +700,30 @@ static void udev_input_poll(void *data) while (udev->monitor && udev_input_poll_hotplug_available(udev->monitor)) udev_input_handle_hotplug(udev); +#if defined(HAVE_EPOLL) ret = epoll_wait(udev->fd, events, ARRAY_SIZE(events), 0); +#elif defined(HAVE_KQUEUE) + { + struct timespec timeoutspec; + timeoutspec.tv_sec = timeout; + timeoutspec.tv_nsec = 0; + ret = kevent(udev->fd, NULL, 0, events, + ARRAY_SIZE(events), &timeoutspec); + } +#endif for (i = 0; i < ret; i++) { + /* TODO/FIXME - add HAVE_EPOLL/HAVE_KQUEUE codepaths here */ if (events[i].events & EPOLLIN) { int j, len; struct input_event input_events[32]; +#if defined(HAVE_EPOLL) udev_input_device_t *device = (udev_input_device_t*)events[i].data.ptr; +#elif defined(HAVE_KQUEUE) + udev_input_device_t *device = (udev_input_device_t*)events[i].udata; +#endif while ((len = read(device->fd, input_events, sizeof(input_events))) > 0) @@ -978,12 +1027,21 @@ static void *udev_input_init(const char *joypad_driver) udev->xkb_handling = string_is_equal(ctx_ident.ident, "kms"); #endif +#if defined(HAVE_EPOLL) fd = epoll_create(32); if (fd < 0) { - RARCH_ERR("Failed to create epoll FD.\n"); + RARCH_ERR("Failed to create poll file descriptor.\n"); goto error; } +#elif defined(HAVE_KQUEUE) + fd = kqueue(); + if (fd == -1) + { + RARCH_ERR("Failed to create poll file descriptor.\n"); + goto error; + } +#endif udev->fd = fd; From a9451822b5415951be9021b7f0ac1cc03778fa82 Mon Sep 17 00:00:00 2001 From: David Walters Date: Thu, 30 Nov 2017 15:30:46 +0000 Subject: [PATCH 117/394] Improved handling of libusb hotplug capability (#5830) * Improved handling of libusb hotplug capability * Only deregister hotplug callback if registration happened. --- input/drivers_hid/libusb_hid.c | 61 ++++++++++++++++++++++------------ 1 file changed, 39 insertions(+), 22 deletions(-) diff --git a/input/drivers_hid/libusb_hid.c b/input/drivers_hid/libusb_hid.c index 4165762b16..257b4819cc 100644 --- a/input/drivers_hid/libusb_hid.c +++ b/input/drivers_hid/libusb_hid.c @@ -42,6 +42,7 @@ typedef struct libusb_hid libusb_context *ctx; joypad_connection_t *slots; sthread_t *poll_thread; + int can_hotplug; #if defined(__FreeBSD__) && LIBUSB_API_VERSION <= 0x01000102 libusb_hotplug_callback_handle hp; #else @@ -523,7 +524,8 @@ static void libusb_hid_free(void *data) if (hid->slots) pad_connection_destroy(hid->slots); - libusb_hotplug_deregister_callback(hid->ctx, hid->hp); + if (hid->can_hotplug) + libusb_hotplug_deregister_callback(hid->ctx, hid->hp); libusb_exit(hid->ctx); free(hid); @@ -556,13 +558,21 @@ static void *libusb_hid_init(void) if (ret < 0) goto error; -#if 0 - /* Don't use this for now since it requires a newer API - * version than FreeBSD has, and always returns false on Windows anyway. - * https://github.com/libusb/libusb/issues/86 +#if LIBUSB_API_VERSION <= 0x01000102 + /* API is too old, so libusb_has_capability function does not exist. + * Since we can't be sure, we assume for now there might be hot-plugging + * capability and continue on until we're told otherwise. */ - if (!libusb_has_capability(LIBUSB_CAP_HAS_HOTPLUG)) - goto error; + hid->can_hotplug = 1; +#else + /* Ask libusb if it supports hotplug and store the result. + * Note: On Windows this will probably be false, see: + * https://github.com/libusb/libusb/issues/86 + */ + if (libusb_has_capability(LIBUSB_CAP_HAS_HOTPLUG)) + hid->can_hotplug = 1; + else + hid->can_hotplug = 0; #endif hid->slots = pad_connection_init(MAX_USERS); @@ -584,22 +594,29 @@ static void *libusb_hid_init(void) if (count > 0) libusb_free_device_list(devices, 1); - ret = libusb_hotplug_register_callback( - hid->ctx, - (libusb_hotplug_event)(LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED | - LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT), - (libusb_hotplug_flag)LIBUSB_HOTPLUG_ENUMERATE, - LIBUSB_HOTPLUG_MATCH_ANY, - LIBUSB_HOTPLUG_MATCH_ANY, - LIBUSB_HOTPLUG_MATCH_ANY, - libusb_hid_hotplug_callback, - hid, - &hid->hp); - - if (ret != LIBUSB_SUCCESS) + if (hid->can_hotplug) { - RARCH_ERR("Error creating a hotplug callback.\n"); - goto error; + ret = libusb_hotplug_register_callback( + hid->ctx, + (libusb_hotplug_event)(LIBUSB_HOTPLUG_EVENT_DEVICE_ARRIVED | + LIBUSB_HOTPLUG_EVENT_DEVICE_LEFT), + (libusb_hotplug_flag)LIBUSB_HOTPLUG_ENUMERATE, + LIBUSB_HOTPLUG_MATCH_ANY, + LIBUSB_HOTPLUG_MATCH_ANY, + LIBUSB_HOTPLUG_MATCH_ANY, + libusb_hid_hotplug_callback, + hid, + &hid->hp); + + if (ret != LIBUSB_SUCCESS) + { + /* Creating the hotplug callback has failed. We assume libusb + * is still okay to continue and just update our knowledge of + * the situation accordingly. + */ + RARCH_WARN("[libusb] Failed to create a hotplug callback.\n"); + hid->can_hotplug = 0; + } } hid->poll_thread = sthread_create(poll_thread, hid); From fa3aab97687bee086005f8c6e40a54f99cdfa836 Mon Sep 17 00:00:00 2001 From: q3cpma Date: Thu, 30 Nov 2017 16:53:55 +0100 Subject: [PATCH 118/394] Fixes compilation on FreeBSD (and hopefully on other POSIX platforms) --- gfx/common/x11_common.c | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/gfx/common/x11_common.c b/gfx/common/x11_common.c index 20eebf8da3..5189cb3792 100644 --- a/gfx/common/x11_common.c +++ b/gfx/common/x11_common.c @@ -21,6 +21,7 @@ #include #include +#include #include #include @@ -159,19 +160,27 @@ static void x11_set_window_class(Display *dpy, Window win) static void x11_set_window_pid(Display *dpy, Window win) { + long scret; + char *hostname; pid_t pid = getpid(); - char hostname[HOST_NAME_MAX + 1]; - XChangeProperty(dpy, win, XInternAtom(dpy, "_NET_WM_PID", False), - XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&pid, 1); + XChangeProperty(dpy, win, XInternAtom(dpy, "_NET_WM_PID", False), + XA_CARDINAL, 32, PropModeReplace, (unsigned char *)&pid, 1); - if(gethostname(hostname, HOST_NAME_MAX + 1) == -1) - RARCH_WARN("Failed to get hostname.\n"); - else - { - XChangeProperty(dpy, win, XA_WM_CLIENT_MACHINE, XA_STRING, 8, - PropModeReplace, (unsigned char *)hostname, strlen(hostname)); - } + errno = 0; + if((scret = sysconf(_SC_HOST_NAME_MAX)) == -1 && errno) + return; + if((hostname = malloc(scret + 1)) == NULL) + return; + + if(gethostname(hostname, HOST_NAME_MAX + 1) == -1) + RARCH_WARN("Failed to get hostname.\n"); + else + { + XChangeProperty(dpy, win, XA_WM_CLIENT_MACHINE, XA_STRING, 8, + PropModeReplace, (unsigned char *)hostname, strlen(hostname)); + } + free(hostname); } void x11_set_window_attr(Display *dpy, Window win) From 9ee5ef0f7432b3ae092a14a4d82ec9c296706571 Mon Sep 17 00:00:00 2001 From: theheroGAC Date: Thu, 30 Nov 2017 21:54:59 +0100 Subject: [PATCH 119/394] Update msg_hash_it.h --- intl/msg_hash_it.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/intl/msg_hash_it.h b/intl/msg_hash_it.h index dfa0290a1e..d6b420f08b 100644 --- a/intl/msg_hash_it.h +++ b/intl/msg_hash_it.h @@ -3292,8 +3292,8 @@ MSG_HASH(MSG_INPUT_KIOSK_MODE_PASSWORD_OK, MSG_HASH(MSG_INPUT_KIOSK_MODE_PASSWORD_NOK, "Password non corretta.") MSG_HASH(MENU_ENUM_LABEL_VALUE_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, - "Automatically add content to playlist") + "Aggiungi automaticamente il contenuto alla playlist") MSG_HASH(MENU_ENUM_SUBLABEL_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, - "Automatically scans loaded content so they appear inside playlists.") + "Esegue automaticamente la scansione dei contenuti caricati in modo che vengano visualizzati all'interno delle playlist.") MSG_HASH(MSG_SCANNING_OF_FILE_FINISHED, - "Scanning of file finished") + "Scansione del file completata") From 6e8fb49d05e9ca063956f26db075ae08fd8f6efd Mon Sep 17 00:00:00 2001 From: q3cpma Date: Fri, 1 Dec 2017 00:17:50 +0100 Subject: [PATCH 120/394] Whoops --- gfx/common/x11_common.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfx/common/x11_common.c b/gfx/common/x11_common.c index 5189cb3792..1375fd1186 100644 --- a/gfx/common/x11_common.c +++ b/gfx/common/x11_common.c @@ -173,7 +173,7 @@ static void x11_set_window_pid(Display *dpy, Window win) if((hostname = malloc(scret + 1)) == NULL) return; - if(gethostname(hostname, HOST_NAME_MAX + 1) == -1) + if(gethostname(hostname, scret + 1) == -1) RARCH_WARN("Failed to get hostname.\n"); else { From a79d3aa8aa5b60029e55169854b94e4e985e6024 Mon Sep 17 00:00:00 2001 From: Ash Date: Wed, 22 Nov 2017 10:39:04 +1100 Subject: [PATCH 121/394] [WiiU] Exception handler: fix coreinit handles, add opcode to DSIs Coreinit seems to get special handles, so adding a special case should make its relative addresses actually become helpful again. Let's just hope __PPCExit stays at 0x180! Also added the violating opcode to the DSI message; may have to move it in case it pushes stuff off the end of the screen. Untested at time of commit. Hopefully this should make debugging #5357 a bit easier... --- wiiu/system/exception_handler.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/wiiu/system/exception_handler.c b/wiiu/system/exception_handler.c index 7ec7dc3f90..1169c078a2 100644 --- a/wiiu/system/exception_handler.c +++ b/wiiu/system/exception_handler.c @@ -90,9 +90,8 @@ void __attribute__((__noreturn__)) exception_cb(OSContext* ctx, OSExceptionType /* First up, the pretty header that tells you wtf just happened */ if (type == OS_EXCEPTION_TYPE_DSI) { - /* Exception type and offending instruction location - Also initializes exception_msgbuf, use buf_add from now on */ - buf_add("DSI: Instr at %08" PRIX32, ctx->srr0); + /* Exception type and offending instruction location + opcode */ + buf_add("DSI: Instr at %08" PRIX32 " (%08 " PRIX32 ")", ctx->srr0, *(unsigned int*)(ctx->srr0)); /* Was this a read or a write? */ if (ctx->dsisr & DSISR_WRITE_ATTEMPTED) { buf_add(" bad write to"); @@ -216,6 +215,12 @@ void exception_print_symbol(uint32_t addr) { /* Try for a base address */ void* libAddr; OSDynLoad_Acquire(symbolName, &libAddr); + /* Special case for coreinit; which has broken handles */ + if (strcmp(symbolName, "coreinit.rpl")) { + void* PPCExit_addr; + OSDynLoad_FindExport(libAddr, 0, "__PPCExit", &PPCExit_addr); + libAddr = PPCExit_addr - 0x180; + } *seperator = '|'; /* We got one! */ if (libAddr) { From 469662345ff275f892986283e66fdfad59c05311 Mon Sep 17 00:00:00 2001 From: Ash Date: Fri, 1 Dec 2017 10:56:54 +1100 Subject: [PATCH 122/394] [WiiU] Exception handler: remove opcodes; fix strcmp misuse Thanks for @gblues for finding the strcmp bug. I've removed the opcode display since it's a bit unsafe - if the exception handler causes a DSI; Cafe OS will take over and freeze up the console. This is obviously not a good thing. There are possible situations where memory is executable and not readable; so this is just about covering all bases until a better solution can be implemented. Maybe we can experiment a bit more once this handler isn't being used so often ;) --- wiiu/system/exception_handler.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/wiiu/system/exception_handler.c b/wiiu/system/exception_handler.c index 1169c078a2..7e01e648f6 100644 --- a/wiiu/system/exception_handler.c +++ b/wiiu/system/exception_handler.c @@ -91,7 +91,7 @@ void __attribute__((__noreturn__)) exception_cb(OSContext* ctx, OSExceptionType /* First up, the pretty header that tells you wtf just happened */ if (type == OS_EXCEPTION_TYPE_DSI) { /* Exception type and offending instruction location + opcode */ - buf_add("DSI: Instr at %08" PRIX32 " (%08 " PRIX32 ")", ctx->srr0, *(unsigned int*)(ctx->srr0)); + buf_add("DSI: Instr at %08" PRIX32, ctx->srr0); /* Was this a read or a write? */ if (ctx->dsisr & DSISR_WRITE_ATTEMPTED) { buf_add(" bad write to"); @@ -216,7 +216,7 @@ void exception_print_symbol(uint32_t addr) { void* libAddr; OSDynLoad_Acquire(symbolName, &libAddr); /* Special case for coreinit; which has broken handles */ - if (strcmp(symbolName, "coreinit.rpl")) { + if (!strcmp(symbolName, "coreinit.rpl")) { void* PPCExit_addr; OSDynLoad_FindExport(libAddr, 0, "__PPCExit", &PPCExit_addr); libAddr = PPCExit_addr - 0x180; From 52fb8276d7609fe30f640687c3ce218bf75cc9fa Mon Sep 17 00:00:00 2001 From: Ash Date: Fri, 1 Dec 2017 11:03:09 +1100 Subject: [PATCH 123/394] [WiiU] Exception handler: minor comment tweak --- wiiu/system/exception_handler.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wiiu/system/exception_handler.c b/wiiu/system/exception_handler.c index 7e01e648f6..b867a77a2e 100644 --- a/wiiu/system/exception_handler.c +++ b/wiiu/system/exception_handler.c @@ -90,7 +90,7 @@ void __attribute__((__noreturn__)) exception_cb(OSContext* ctx, OSExceptionType /* First up, the pretty header that tells you wtf just happened */ if (type == OS_EXCEPTION_TYPE_DSI) { - /* Exception type and offending instruction location + opcode */ + /* Exception type and offending instruction location */ buf_add("DSI: Instr at %08" PRIX32, ctx->srr0); /* Was this a read or a write? */ if (ctx->dsisr & DSISR_WRITE_ATTEMPTED) { From 26a006cfac4e044fab5062b7baeed12ef982f68c Mon Sep 17 00:00:00 2001 From: Ash Date: Fri, 1 Dec 2017 18:18:02 +1100 Subject: [PATCH 124/394] [WiiU] Toolchain: Fix C++ constructor/destructor handling The old setup relied on there being at least one constructor *or* the value of *__CTOR_LIST__ being NULL. Neither of these are guaranteed; and having no C++ constructors actually resulted in a random value being read (which passed the NULL check!). This new setup uses the __CTOR_END__ symbol; which is a pointer to just after the end of the list. When there are no constructors, it has the same value as __CTOR_LIST__; so the while loop is never entered. This fix also allows us to re-enable destructors; in case they're ever needed. --- frontend/drivers/platform_wiiu.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/frontend/drivers/platform_wiiu.c b/frontend/drivers/platform_wiiu.c index c97ec97139..c975df3b16 100644 --- a/frontend/drivers/platform_wiiu.c +++ b/frontend/drivers/platform_wiiu.c @@ -523,22 +523,26 @@ void __eabi() __attribute__((weak)) void __init(void) { - extern void(*__CTOR_LIST__[])(void); - void(**ctor)(void) = __CTOR_LIST__; + extern void (**const __CTOR_LIST__)(void); + extern void (**const __CTOR_END__)(void); - while (*ctor) + void (**ctor)(void) = __CTOR_LIST__; + while (ctor < __CTOR_END__) { (*ctor++)(); + } } __attribute__((weak)) void __fini(void) { - extern void(*__DTOR_LIST__[])(void); - void(**ctor)(void) = __DTOR_LIST__; + extern void (**const __DTOR_LIST__)(void); + extern void (**const __DTOR_END__)(void); - while (*ctor) - (*ctor++)(); + void (**dtor)(void) = __DTOR_LIST__; + while (dtor < __DTOR_END__) { + (*dtor++)(); + } } /* libiosuhax related */ @@ -633,7 +637,7 @@ int __entry_menu(int argc, char **argv) int ret = main(argc, argv); fsdev_exit(); -// __fini(); + __fini(); memoryRelease(); return ret; } From bf3e256a43ace7b4b3fa8ee32e6818a71f6a640f Mon Sep 17 00:00:00 2001 From: Ash Date: Fri, 1 Dec 2017 18:29:21 +1100 Subject: [PATCH 125/394] [WiiU] Input: Make controller_patcher a compile-time option As discussed in libretro#5357; controller_patcher is now optional. It's off by default; though this could be changed with a simple makefile tweak (ENABLE_CONTROLLER_PATCHER ?= 1, perhaps?) To re-enable controller_patcher; append ENABLE_CONTROLLER_PATCHER=1 to your usual make command. controller_patcher was the only user of c++ constructors in the Wii U port, so you'll need 26a006c in your tree otherwise you will have a blackscreen on startup. --- Makefile.wiiu | 36 ++++++----- frontend/drivers/platform_wiiu.c | 8 ++- input/drivers_joypad/wiiu_joypad.c | 97 ++++++++++++++++++------------ input/input_autodetect_builtin.c | 6 +- 4 files changed, 88 insertions(+), 59 deletions(-) diff --git a/Makefile.wiiu b/Makefile.wiiu index b83d1caae7..00881ed117 100644 --- a/Makefile.wiiu +++ b/Makefile.wiiu @@ -18,24 +18,27 @@ OBJ += wiiu/system/exception_handler.o OBJ += wiiu/system/missing_libc_functions.o OBJ += wiiu/fs/sd_fat_devoptab.o OBJ += wiiu/fs/fs_utils.o -OBJ += wiiu/controller_patcher/ControllerPatcher.o -OBJ += wiiu/controller_patcher/ControllerPatcherWrapper.o -OBJ += wiiu/controller_patcher/ConfigReader.o -OBJ += wiiu/controller_patcher/config/ConfigParser.o -OBJ += wiiu/controller_patcher/config/ConfigValues.o -OBJ += wiiu/controller_patcher/network/ControllerPatcherNet.o -OBJ += wiiu/controller_patcher/network/TCPServer.o -OBJ += wiiu/controller_patcher/network/UDPClient.o -OBJ += wiiu/controller_patcher/network/UDPServer.o -OBJ += wiiu/controller_patcher/patcher/ControllerPatcherUtils.o -OBJ += wiiu/controller_patcher/patcher/ControllerPatcherHID.o -OBJ += wiiu/controller_patcher/utils/CPRetainVars.o -OBJ += wiiu/controller_patcher/utils/CPStringTools.o -OBJ += wiiu/controller_patcher/utils/PadConst.o -OBJ += wiiu/controller_patcher/utils/FSHelper.o OBJ += wiiu/tex_shader.o OBJ += wiiu/hbl.o +ifeq ($(ENABLE_CONTROLLER_PATCHER), 1) + OBJ += wiiu/controller_patcher/ControllerPatcher.o + OBJ += wiiu/controller_patcher/ControllerPatcherWrapper.o + OBJ += wiiu/controller_patcher/ConfigReader.o + OBJ += wiiu/controller_patcher/config/ConfigParser.o + OBJ += wiiu/controller_patcher/config/ConfigValues.o + OBJ += wiiu/controller_patcher/network/ControllerPatcherNet.o + OBJ += wiiu/controller_patcher/network/TCPServer.o + OBJ += wiiu/controller_patcher/network/UDPClient.o + OBJ += wiiu/controller_patcher/network/UDPServer.o + OBJ += wiiu/controller_patcher/patcher/ControllerPatcherUtils.o + OBJ += wiiu/controller_patcher/patcher/ControllerPatcherHID.o + OBJ += wiiu/controller_patcher/utils/CPRetainVars.o + OBJ += wiiu/controller_patcher/utils/CPStringTools.o + OBJ += wiiu/controller_patcher/utils/PadConst.o + OBJ += wiiu/controller_patcher/utils/FSHelper.o +endif + DEFINES := ifeq ($(GRIFFIN_BUILD), 1) @@ -158,6 +161,9 @@ CFLAGS += -DWIIU -DMSB_FIRST CFLAGS += -DHAVE_MAIN CFLAGS += -DHAVE_UPDATE_ASSETS CFLAGS += -DRARCH_INTERNAL -DRARCH_CONSOLE +ifeq ($(ENABLE_CONTROLLER_PATCHER), 1) + CFLAGS += -DENABLE_CONTROLLER_PATCHER +endif CFLAGS += -DHAVE_FILTERS_BUILTIN $(DEFINES) ifneq ($(PC_DEVELOPMENT_IP_ADDRESS),) diff --git a/frontend/drivers/platform_wiiu.c b/frontend/drivers/platform_wiiu.c index c975df3b16..ab8a62f115 100644 --- a/frontend/drivers/platform_wiiu.c +++ b/frontend/drivers/platform_wiiu.c @@ -58,7 +58,9 @@ #include #include -#include "wiiu/controller_patcher/ControllerPatcherWrapper.h" +#if defined(ENABLE_CONTROLLER_PATCHER) + #include "wiiu/controller_patcher/ControllerPatcherWrapper.h" +#endif #include #include @@ -430,7 +432,7 @@ int main(int argc, char **argv) KPADInit(); #endif verbosity_enable(); -#ifndef IS_SALAMANDER +#if !defined(IS_SALAMANDER) && defined(ENABLE_CONTROLLER_PATCHER) ControllerPatcherInit(); #endif fflush(stdout); @@ -492,7 +494,7 @@ int main(int argc, char **argv) } while (1); -#ifndef IS_SALAMANDER +#if !defined(IS_SALAMANDER) && defined(ENABLE_CONTROLLER_PATCHER) ControllerPatcherDeInit(); #endif main_exit(NULL); diff --git a/input/drivers_joypad/wiiu_joypad.c b/input/drivers_joypad/wiiu_joypad.c index 957e736241..ed62f14e09 100644 --- a/input/drivers_joypad/wiiu_joypad.c +++ b/input/drivers_joypad/wiiu_joypad.c @@ -21,7 +21,9 @@ #include #include -#include "wiiu/controller_patcher/ControllerPatcherWrapper.h" +#if defined(ENABLE_CONTROLLER_PATCHER) + #include "wiiu/controller_patcher/ControllerPatcherWrapper.h" +#endif #include "../input_driver.h" @@ -33,8 +35,12 @@ #include "wiiu_dbg.h" -#ifndef MAX_PADS -#define MAX_PADS 16 +#if !defined(MAX_PADS) + #if defined(ENABLE_CONTROLLER_PATCHER) + #define MAX_PADS 16 + #else + #define MAX_PADS 5 + #endif #endif #define WIIUINPUT_TYPE_WIIMOTE 0x00 @@ -45,22 +51,27 @@ #define GAMEPAD_COUNT 1 #define KPAD_COUNT 4 -#define HID_COUNT (MAX_PADS - GAMEPAD_COUNT - KPAD_COUNT) #define GAMEPAD_OFFSET 0 #define KPAD_OFFSET (GAMEPAD_OFFSET + GAMEPAD_COUNT) -#define HID_OFFSET (KPAD_OFFSET + KPAD_COUNT) + +#if defined(ENABLE_CONTROLLER_PATCHER) + #define HID_COUNT (MAX_PADS - GAMEPAD_COUNT - KPAD_COUNT) + #define HID_OFFSET (KPAD_OFFSET + KPAD_COUNT) +#endif static uint64_t pad_state[MAX_PADS]; static uint8_t pad_type[KPAD_COUNT] = {WIIUINPUT_TYPE_NONE, WIIUINPUT_TYPE_NONE, WIIUINPUT_TYPE_NONE, WIIUINPUT_TYPE_NONE}; +#if defined(ENABLE_CONTROLLER_PATCHER) static uint8_t hid_status[HID_COUNT]; static InputData hid_data[HID_COUNT]; +static char hidName[HID_COUNT][255]; +#endif + /* 3 axis - one for touch/future IR support? */ static int16_t analog_state[MAX_PADS][3][2]; static bool wiiu_pad_inited = false; -static char hidName[HID_COUNT][255]; - static const char* wiiu_joypad_name(unsigned pad) { if (pad > MAX_PADS) return "N/A"; @@ -91,12 +102,14 @@ static const char* wiiu_joypad_name(unsigned pad) } } - if (pad >= HID_OFFSET && pad < HID_OFFSET + HID_COUNT) - { - s32 hid_index = pad - HID_OFFSET; - sprintf(hidName[hid_index], "HID %04X/%04X(%02X)", hid_data[hid_index].device_info.vidpid.vid, hid_data[hid_index].device_info.vidpid.pid, hid_data[hid_index].pad); - return hidName[hid_index]; - } + #if defined(ENABLE_CONTROLLER_PATCHER) + if (pad >= HID_OFFSET && pad < HID_OFFSET + HID_COUNT) + { + s32 hid_index = pad - HID_OFFSET; + sprintf(hidName[hid_index], "HID %04X/%04X(%02X)", hid_data[hid_index].device_info.vidpid.vid, hid_data[hid_index].device_info.vidpid.pid, hid_data[hid_index].pad); + return hidName[hid_index]; + } + #endif //defined(ENABLE_CONTROLLER_PATCHER) return "unknown"; } @@ -194,9 +207,12 @@ static int16_t scaleTP(int16_t oldMin, int16_t oldMax, int16_t newMin, int16_t n static void wiiu_joypad_poll(void) { - int i, c, result; + int i, c; VPADStatus vpad; VPADReadError vpadError; + #if defined(ENABLE_CONTROLLER_PATCHER) + int result; + #endif VPADRead(0, &vpad, 1, &vpadError); @@ -311,41 +327,46 @@ static void wiiu_joypad_poll(void) } } - memset(hid_data,0,sizeof(hid_data)); - result = gettingInputAllDevices(hid_data,HID_COUNT); + #if defined(ENABLE_CONTROLLER_PATCHER) + memset(hid_data,0,sizeof(hid_data)); + result = gettingInputAllDevices(hid_data,HID_COUNT); - if (result + HID_OFFSET > MAX_PADS) - result = MAX_PADS - HID_OFFSET; + if (result + HID_OFFSET > MAX_PADS) + result = MAX_PADS - HID_OFFSET; - for(i = HID_OFFSET;i < result + HID_OFFSET; i++) - { - int hid_index = i-HID_OFFSET; - uint8_t old_status = hid_status[hid_index]; - uint8_t new_status = hid_data[hid_index].status;/* TODO: defines for the status. */ - - if (old_status == 1 || new_status == 1) + for(i = HID_OFFSET;i < result + HID_OFFSET; i++) { - hid_status[hid_index] = new_status; - if (old_status == 0 && new_status == 1) /* Pad was attached */ - wiiu_joypad_autodetect_add(i); - else if (old_status == 1 && new_status == 0) /* Pad was detached */ - input_autoconfigure_disconnect(i, wiiu_joypad.ident); - else if (old_status == 1 && new_status == 1) /* Pad still connected */ + int hid_index = i-HID_OFFSET; + uint8_t old_status = hid_status[hid_index]; + uint8_t new_status = hid_data[hid_index].status;/* TODO: defines for the status. */ + + if (old_status == 1 || new_status == 1) { - pad_state[i] = hid_data[hid_index].button_data.hold & ~0x7F800000; /* clear out emulated analog sticks */ - analog_state[i][RETRO_DEVICE_INDEX_ANALOG_LEFT] [RETRO_DEVICE_ID_ANALOG_X] = hid_data[hid_index].stick_data.leftStickX * 0x7FF0; - analog_state[i][RETRO_DEVICE_INDEX_ANALOG_LEFT] [RETRO_DEVICE_ID_ANALOG_Y] = hid_data[hid_index].stick_data.leftStickY * 0x7FF0; - analog_state[i][RETRO_DEVICE_INDEX_ANALOG_RIGHT] [RETRO_DEVICE_ID_ANALOG_X] = hid_data[hid_index].stick_data.rightStickX * 0x7FF0; - analog_state[i][RETRO_DEVICE_INDEX_ANALOG_RIGHT] [RETRO_DEVICE_ID_ANALOG_Y] = hid_data[hid_index].stick_data.rightStickY * 0x7FF0; + hid_status[hid_index] = new_status; + if (old_status == 0 && new_status == 1) /* Pad was attached */ + wiiu_joypad_autodetect_add(i); + else if (old_status == 1 && new_status == 0) /* Pad was detached */ + input_autoconfigure_disconnect(i, wiiu_joypad.ident); + else if (old_status == 1 && new_status == 1) /* Pad still connected */ + { + pad_state[i] = hid_data[hid_index].button_data.hold & ~0x7F800000; /* clear out emulated analog sticks */ + analog_state[i][RETRO_DEVICE_INDEX_ANALOG_LEFT] [RETRO_DEVICE_ID_ANALOG_X] = hid_data[hid_index].stick_data.leftStickX * 0x7FF0; + analog_state[i][RETRO_DEVICE_INDEX_ANALOG_LEFT] [RETRO_DEVICE_ID_ANALOG_Y] = hid_data[hid_index].stick_data.leftStickY * 0x7FF0; + analog_state[i][RETRO_DEVICE_INDEX_ANALOG_RIGHT] [RETRO_DEVICE_ID_ANALOG_X] = hid_data[hid_index].stick_data.rightStickX * 0x7FF0; + analog_state[i][RETRO_DEVICE_INDEX_ANALOG_RIGHT] [RETRO_DEVICE_ID_ANALOG_Y] = hid_data[hid_index].stick_data.rightStickY * 0x7FF0; + } } } - } + #endif //defined(ENABLE_CONTROLLER_PATCHER) } static bool wiiu_joypad_init(void* data) { wiiu_joypad_autodetect_add(0); - memset(hid_status,0,sizeof(hid_status)); + + #if defined(ENABLE_CONTROLLER_PATCHER) + memset(hid_status,0,sizeof(hid_status)); + #endif wiiu_joypad_poll(); wiiu_pad_inited = true; diff --git a/input/input_autodetect_builtin.c b/input/input_autodetect_builtin.c index ba55e1ecbd..bd6fdaf768 100644 --- a/input/input_autodetect_builtin.c +++ b/input/input_autodetect_builtin.c @@ -544,16 +544,16 @@ const char* const input_builtin_autoconfs[] = #endif #ifdef WIIU DECL_AUTOCONF_DEVICE("WIIU Gamepad", "wiiu", WIIUINPUT_GAMEPAD_DEFAULT_BINDS), - DECL_AUTOCONF_DEVICE("HID Controller", "wiiu", WIIUINPUT_GAMEPAD_DEFAULT_BINDS), DECL_AUTOCONF_DEVICE("WIIU Pro Controller", "wiiu", WIIUINPUT_PRO_CONTROLLER_DEFAULT_BINDS), DECL_AUTOCONF_DEVICE("Wiimote Controller", "wiiu", WIIUINPUT_WIIMOTE_DEFAULT_BINDS), DECL_AUTOCONF_DEVICE("Nunchuk Controller", "wiiu", WIIUINPUT_NUNCHUK_DEFAULT_BINDS), DECL_AUTOCONF_DEVICE("Classic Controller", "wiiu", WIIUINPUT_CLASSIC_CONTROLLER_DEFAULT_BINDS), + #if defined(ENABLE_CONTROLLER_PATCHER) + DECL_AUTOCONF_DEVICE("HID Controller", "wiiu", WIIUINPUT_GAMEPAD_DEFAULT_BINDS), + #endif #endif #ifdef __CELLOS_LV2__ DECL_AUTOCONF_DEVICE("SixAxis Controller", "ps3", PS3INPUT_DEFAULT_BINDS), #endif NULL }; - - From 5d5aa7ca608c97fa6c1367aeb4e041c5123738ff Mon Sep 17 00:00:00 2001 From: orbea Date: Fri, 1 Dec 2017 06:26:02 -0800 Subject: [PATCH 126/394] Revert "Use RetroArch Assets' Makefile to install Assets" --- Makefile | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index f9f1876a9a..8e70dd430d 100644 --- a/Makefile +++ b/Makefile @@ -201,7 +201,17 @@ install: $(TARGET) install -m644 media/retroarch.svg $(DESTDIR)$(PREFIX)/share/pixmaps @if test -d media/assets; then \ echo "Installing media assets..."; \ - $(MAKE) install -C media/assets INSTALLDIR=$(ASSETS_DIR)/retroarch/assets; \ + mkdir -p $(DESTDIR)$(ASSETS_DIR)/retroarch/assets/xmb; \ + mkdir -p $(DESTDIR)$(ASSETS_DIR)/retroarch/assets/glui; \ + cp -r media/assets/xmb/ $(DESTDIR)$(ASSETS_DIR)/retroarch/assets; \ + cp -r media/assets/glui/ $(DESTDIR)$(ASSETS_DIR)/retroarch/assets; \ + echo "Removing unneeded source image files.."; \ + rm -rf $(DESTDIR)$(ASSETS_DIR)/retroarch/assets/xmb/flatui/src; \ + rm -rf $(DESTDIR)$(ASSETS_DIR)/retroarch/assets/xmb/monochrome/src; \ + rm -rf $(DESTDIR)$(ASSETS_DIR)/retroarch/assets/xmb/retroactive/src; \ + rm -rf $(DESTDIR)$(ASSETS_DIR)/retroarch/assets/xmb/neoactive/src; \ + rm -rf $(DESTDIR)$(ASSETS_DIR)/retroarch/assets/xmb/retrosystem/src; \ + rm -rf $(DESTDIR)$(ASSETS_DIR)/retroarch/assets/xmb/dot-art/src; \ echo "Asset copying done."; \ fi From b9394846dc506ebe1785e2ee4b70fc5bb96faf5c Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Fri, 1 Dec 2017 14:07:40 -0500 Subject: [PATCH 127/394] blissbox: use win32 HID API to get pad type on windows, libusb seems broken there --- Makefile.common | 2 +- tasks/task_autodetect.c | 277 +++++++++++++++++++++++++++++++++++++++- 2 files changed, 277 insertions(+), 2 deletions(-) diff --git a/Makefile.common b/Makefile.common index cac0ea4aaf..58158f33aa 100644 --- a/Makefile.common +++ b/Makefile.common @@ -1531,7 +1531,7 @@ ifneq ($(findstring Win32,$(OS)),) gfx/drivers_font/gdi_font.o \ menu/drivers_display/menu_display_gdi.o - LIBS += -lmsimg32 + LIBS += -lmsimg32 -lhid -lsetupapi endif ifeq ($(HAVE_AVFOUNDATION), 1) diff --git a/tasks/task_autodetect.c b/tasks/task_autodetect.c index 364cffea8a..fffc0fb7d0 100644 --- a/tasks/task_autodetect.c +++ b/tasks/task_autodetect.c @@ -33,6 +33,16 @@ #endif #endif +#if defined(_WIN32) && !defined(_XBOX) && !defined(_MSC_VER) && _WIN32_WINNT >= 0x0500 +/* MinGW Win32 HID API */ +#include +#include +#include +#include +/* Why doesn't including cguid.h work to get a GUID_NULL instead? */ +const GUID GUID_NULL = {0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0}}; +#endif + #include "../input/input_driver.h" #include "../input/include/blissbox.h" @@ -359,7 +369,256 @@ static void input_autoconfigure_params_free(autoconfig_params_t *params) params->autoconfig_directory = NULL; } -static const blissbox_pad_type_t* input_autoconfigure_get_blissbox_pad_type(int vid, int pid) +#ifdef _WIN32 +static const blissbox_pad_type_t* input_autoconfigure_get_blissbox_pad_type_win32(int vid, int pid) +{ + /* TODO: Remove the check for !defined(_MSC_VER) after making sure this builds on MSVC */ + + /* HID API is available since Windows 2000 */ +#if defined(_WIN32) && !defined(_XBOX) && !defined(_MSC_VER) && _WIN32_WINNT >= 0x0500 + HANDLE hDeviceHandle = INVALID_HANDLE_VALUE; + GUID guidDeviceInterface = {0}; + BOOL bResult = TRUE; + BOOL success = FALSE; + HDEVINFO hDeviceInfo; + SP_DEVINFO_DATA DeviceInfoData; + SP_DEVICE_INTERFACE_DATA deviceInterfaceData; + PSP_DEVICE_INTERFACE_DETAIL_DATA pInterfaceDetailData = NULL; + ULONG requiredLength = 0; + LPTSTR lpDevicePath = NULL; + char *devicePath = NULL; + DWORD index = 0; + DWORD intIndex = 0; + size_t nLength = 0; + unsigned len = 0; + unsigned i = 0; + char vidPidString[32] = {0}; + char vidString[5] = {0}; + char pidString[5] = {0}; + char report[USB_PACKET_CTRL_LEN + 1] = {0}; + + snprintf(vidString, sizeof(vidString), "%04x", vid); + snprintf(pidString, sizeof(pidString), "%04x", pid); + + strlcat(vidPidString, "vid_", sizeof(vidPidString)); + strlcat(vidPidString, vidString, sizeof(vidPidString)); + strlcat(vidPidString, "&pid_", sizeof(vidPidString)); + strlcat(vidPidString, pidString, sizeof(vidPidString)); + + HidD_GetHidGuid(&guidDeviceInterface); + + if (!memcmp(&guidDeviceInterface, &GUID_NULL, sizeof(GUID_NULL))) + { + RARCH_ERR("[Autoconf]: null guid\n"); + return NULL; + } + + /* Get information about all the installed devices for the specified + * device interface class. + */ + hDeviceInfo = SetupDiGetClassDevs( + &guidDeviceInterface, + NULL, + NULL, + DIGCF_PRESENT | DIGCF_DEVICEINTERFACE); + + if (hDeviceInfo == INVALID_HANDLE_VALUE) + { + RARCH_ERR("[Autoconf]: Error in SetupDiGetClassDevs: %d.\n", GetLastError()); + goto done; + } + + /* Enumerate all the device interfaces in the device information set. */ + DeviceInfoData.cbSize = sizeof(SP_DEVINFO_DATA); + + while (!success) + { + success = SetupDiEnumDeviceInfo(hDeviceInfo, index, &DeviceInfoData); + + /* Reset for this iteration */ + if (lpDevicePath) + { + LocalFree(lpDevicePath); + lpDevicePath = NULL; + } + + if (pInterfaceDetailData) + { + LocalFree(pInterfaceDetailData); + pInterfaceDetailData = NULL; + } + + /* Check if this is the last item */ + if (GetLastError() == ERROR_NO_MORE_ITEMS) + break; + + deviceInterfaceData.cbSize = sizeof(SP_INTERFACE_DEVICE_DATA); + + /* Get information about the device interface. */ + for (intIndex = 0; (bResult = SetupDiEnumDeviceInterfaces( + hDeviceInfo, + &DeviceInfoData, + &guidDeviceInterface, + intIndex, + &deviceInterfaceData)); intIndex++) + { + /* Check if this is the last item */ + if (GetLastError() == ERROR_NO_MORE_ITEMS) + break; + + /* Check for some other error */ + if (!bResult) + { + RARCH_ERR("[Autoconf]: Error in SetupDiEnumDeviceInterfaces: %d.\n", GetLastError()); + goto done; + } + + /* Interface data is returned in SP_DEVICE_INTERFACE_DETAIL_DATA + * which we need to allocate, so we have to call this function twice. + * First to get the size so that we know how much to allocate, and + * second to do the actual call with the allocated buffer. + */ + + bResult = SetupDiGetDeviceInterfaceDetail( + hDeviceInfo, + &deviceInterfaceData, + NULL, 0, + &requiredLength, + NULL); + + /* Check for some other error */ + if (!bResult) + { + if ((ERROR_INSUFFICIENT_BUFFER == GetLastError()) && (requiredLength > 0)) + { + /* we got the size, now allocate buffer */ + pInterfaceDetailData = (PSP_DEVICE_INTERFACE_DETAIL_DATA)LocalAlloc(LPTR, requiredLength); + + if (!pInterfaceDetailData) + { + RARCH_ERR("[Autoconf]: Error allocating memory for the device detail buffer.\n"); + goto done; + } + } + else + { + RARCH_ERR("[Autoconf]: Other error: %d.\n", GetLastError()); + goto done; + } + } + + /* get the interface detailed data */ + pInterfaceDetailData->cbSize = sizeof(SP_DEVICE_INTERFACE_DETAIL_DATA); + + /* Now call it with the correct size and allocated buffer */ + bResult = SetupDiGetDeviceInterfaceDetail( + hDeviceInfo, + &deviceInterfaceData, + pInterfaceDetailData, + requiredLength, + NULL, + &DeviceInfoData); + + /* Check for some other error */ + if (!bResult) + { + RARCH_LOG("[Autoconf]: Error in SetupDiGetDeviceInterfaceDetail: %d.\n", GetLastError()); + goto done; + } + + /* copy device path */ + nLength = _tcslen(pInterfaceDetailData->DevicePath) + 1; + lpDevicePath = (TCHAR*)LocalAlloc(LPTR, nLength * sizeof(TCHAR)); + + StringCchCopy(lpDevicePath, nLength, pInterfaceDetailData->DevicePath); + + devicePath = (char*)malloc(nLength); + + for (len = 0; len < nLength; len++) + { + devicePath[len] = lpDevicePath[len]; + } + + lpDevicePath[nLength - 1] = 0; + + if (strstr(devicePath, vidPidString)) + goto found; + } + + success = FALSE; + index++; + } + + if (!lpDevicePath) + { + RARCH_ERR("[Autoconf]: No devicepath. Error %d.", GetLastError()); + goto done; + } + +found: + /* Open the device */ + hDeviceHandle = CreateFileA( + devicePath, + GENERIC_READ, /* | GENERIC_WRITE,*/ + FILE_SHARE_READ, /* | FILE_SHARE_WRITE,*/ + NULL, + OPEN_EXISTING, + 0, /*FILE_FLAG_OVERLAPPED,*/ + NULL); + + if (hDeviceHandle == INVALID_HANDLE_VALUE) + { + RARCH_ERR("[Autoconf]: Can't open device: %d.", GetLastError()); + goto done; + } + +done: + free(devicePath); + LocalFree(lpDevicePath); + LocalFree(pInterfaceDetailData); + bResult = SetupDiDestroyDeviceInfoList(hDeviceInfo); + + devicePath = NULL; + lpDevicePath = NULL; + pInterfaceDetailData = NULL; + + if (!bResult) + RARCH_ERR("[Autoconf]: Could not destroy device info list.\n"); + + if (!hDeviceHandle || hDeviceHandle == INVALID_HANDLE_VALUE) + { + /* device is not connected */ + return NULL; + } + + report[0] = BLISSBOX_USB_FEATURE_REPORT_ID; + + HidD_GetFeature(hDeviceHandle, report, sizeof(report)); + + CloseHandle(hDeviceHandle); + + for (i = 0; i < sizeof(blissbox_pad_types) / sizeof(blissbox_pad_types[0]); i++) + { + const blissbox_pad_type_t *pad = &blissbox_pad_types[i]; + + if (!pad || string_is_empty(pad->name)) + continue; + + if (pad->index == report[0]) + return pad; + } + + RARCH_LOG("[Autoconf]: Could not find connected pad in Bliss-Box port#%d.\n", pid - BLISSBOX_PID); + + return NULL; +#else + return NULL; +#endif +} +#endif + +#ifndef _WIN32 +static const blissbox_pad_type_t* input_autoconfigure_get_blissbox_pad_type_libusb(int vid, int pid) { #ifdef HAVE_LIBUSB unsigned char answer[USB_PACKET_CTRL_LEN] = {0}; @@ -437,6 +696,22 @@ error: return NULL; #endif } +#endif + +static const blissbox_pad_type_t* input_autoconfigure_get_blissbox_pad_type(int vid, int pid) +{ +#if defined(_WIN32) +#if defined(_MSC_VER) || defined(_XBOX) + /* no MSVC/XBOX support */ + return NULL; +#else + /* MinGW */ + return input_autoconfigure_get_blissbox_pad_type_win32(vid, pid); +#endif +#else + return input_autoconfigure_get_blissbox_pad_type_libusb(vid, pid); +#endif +} static void input_autoconfigure_override_handler(autoconfig_params_t *params) { From 0eb8c471665a1423faac948a02079933f4fb68c6 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Fri, 1 Dec 2017 14:38:13 -0500 Subject: [PATCH 128/394] try to fix lack of GUID type on buildbot that I cannot reproduce --- tasks/task_autodetect.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tasks/task_autodetect.c b/tasks/task_autodetect.c index fffc0fb7d0..fc402668d5 100644 --- a/tasks/task_autodetect.c +++ b/tasks/task_autodetect.c @@ -37,6 +37,8 @@ /* MinGW Win32 HID API */ #include #include +#include +#include #include #include /* Why doesn't including cguid.h work to get a GUID_NULL instead? */ From 067f5bcd16d5d8830ae33e23096d4ef36a4c4472 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Fri, 1 Dec 2017 22:40:17 -0500 Subject: [PATCH 129/394] blissbox: add 4-Play to overridden hid name --- tasks/task_autodetect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/task_autodetect.c b/tasks/task_autodetect.c index fc402668d5..81dae25c86 100644 --- a/tasks/task_autodetect.c +++ b/tasks/task_autodetect.c @@ -744,7 +744,7 @@ static void input_autoconfigure_override_handler(autoconfig_params_t *params) free(params->name); /* override name given to autoconfig so it knows what kind of pad this is */ - strlcat(name, "Bliss-Box ", sizeof(name)); + strlcat(name, "Bliss-Box 4-Play ", sizeof(name)); strlcat(name, pad->name, sizeof(name)); params->name = strdup(name); From a132e33231051d30e19eca9d7aa0f12f5e64af1b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 2 Dec 2017 05:17:14 +0100 Subject: [PATCH 130/394] Add copyright headers to ps3py --- tools/ps3/ps3py/LICENSE | 19 +++++++++++++++++++ tools/ps3/ps3py/crypt.c | 25 +++++++++++++++++++++++-- 2 files changed, 42 insertions(+), 2 deletions(-) create mode 100644 tools/ps3/ps3py/LICENSE diff --git a/tools/ps3/ps3py/LICENSE b/tools/ps3/ps3py/LICENSE new file mode 100644 index 0000000000..1580af9d38 --- /dev/null +++ b/tools/ps3/ps3py/LICENSE @@ -0,0 +1,19 @@ + Copyright (c) 2011 PSL1GHT Development Team + + Permission is hereby granted, free of charge, to any person obtaining a copy + of this software and associated documentation files (the "Software"), to deal + in the Software without restriction, including without limitation the rights + to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + copies of the Software, and to permit persons to whom the Software is + furnished to do so, subject to the following conditions: + + The above copyright notice and this permission notice shall be included in + all copies or substantial portions of the Software. + + THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + THE SOFTWARE. diff --git a/tools/ps3/ps3py/crypt.c b/tools/ps3/ps3py/crypt.c index f128b47e02..01bb770e8b 100644 --- a/tools/ps3/ps3py/crypt.c +++ b/tools/ps3/ps3py/crypt.c @@ -1,3 +1,24 @@ +/* Copyright (c) 2011 PSL1GHT Development Team + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in + * all copies or substantial portions of the Software. + + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN + * THE SOFTWARE. + */ + #include static PyObject *sha1_callback = NULL; @@ -81,10 +102,10 @@ static PyObject *register_sha1_callback(PyObject *self, PyObject *args) PyErr_SetString(PyExc_TypeError, "parameter must be callable"); return NULL; } - Py_XINCREF(temp); /* Add a reference to new callback */ + Py_XINCREF(temp); /* Add a reference to new callback */ Py_XDECREF(sha1_callback); /* Dispose of previous callback */ sha1_callback = temp; /* Remember new callback */ - /* Boilerplate to return "None" */ + /* Boilerplate to return "None" */ Py_INCREF(Py_None); result = Py_None; } From 2608fd1550fea040729c3b932b260d2f7e935c24 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 2 Dec 2017 11:36:22 +0100 Subject: [PATCH 131/394] (task_autodetect.c) Cleanups --- tasks/task_autodetect.c | 58 +++++++++++++++++++---------------------- 1 file changed, 27 insertions(+), 31 deletions(-) diff --git a/tasks/task_autodetect.c b/tasks/task_autodetect.c index 81dae25c86..4c2b454e3c 100644 --- a/tasks/task_autodetect.c +++ b/tasks/task_autodetect.c @@ -378,25 +378,26 @@ static const blissbox_pad_type_t* input_autoconfigure_get_blissbox_pad_type_win3 /* HID API is available since Windows 2000 */ #if defined(_WIN32) && !defined(_XBOX) && !defined(_MSC_VER) && _WIN32_WINNT >= 0x0500 - HANDLE hDeviceHandle = INVALID_HANDLE_VALUE; - GUID guidDeviceInterface = {0}; - BOOL bResult = TRUE; - BOOL success = FALSE; HDEVINFO hDeviceInfo; SP_DEVINFO_DATA DeviceInfoData; SP_DEVICE_INTERFACE_DATA deviceInterfaceData; - PSP_DEVICE_INTERFACE_DETAIL_DATA pInterfaceDetailData = NULL; - ULONG requiredLength = 0; - LPTSTR lpDevicePath = NULL; - char *devicePath = NULL; - DWORD index = 0; - DWORD intIndex = 0; - size_t nLength = 0; - unsigned len = 0; - unsigned i = 0; - char vidPidString[32] = {0}; - char vidString[5] = {0}; - char pidString[5] = {0}; + HANDLE hDeviceHandle = INVALID_HANDLE_VALUE; + BOOL bResult = TRUE; + BOOL success = FALSE; + GUID guidDeviceInterface = {0}; + PSP_DEVICE_INTERFACE_DETAIL_DATA + pInterfaceDetailData = NULL; + ULONG requiredLength = 0; + LPTSTR lpDevicePath = NULL; + char *devicePath = NULL; + DWORD index = 0; + DWORD intIndex = 0; + size_t nLength = 0; + unsigned len = 0; + unsigned i = 0; + char vidPidString[32] = {0}; + char vidString[5] = {0}; + char pidString[5] = {0}; char report[USB_PACKET_CTRL_LEN + 1] = {0}; snprintf(vidString, sizeof(vidString), "%04x", vid); @@ -529,17 +530,15 @@ static const blissbox_pad_type_t* input_autoconfigure_get_blissbox_pad_type_win3 } /* copy device path */ - nLength = _tcslen(pInterfaceDetailData->DevicePath) + 1; + nLength = _tcslen(pInterfaceDetailData->DevicePath) + 1; lpDevicePath = (TCHAR*)LocalAlloc(LPTR, nLength * sizeof(TCHAR)); StringCchCopy(lpDevicePath, nLength, pInterfaceDetailData->DevicePath); - devicePath = (char*)malloc(nLength); + devicePath = (char*)malloc(nLength); for (len = 0; len < nLength; len++) - { devicePath[len] = lpDevicePath[len]; - } lpDevicePath[nLength - 1] = 0; @@ -578,10 +577,10 @@ done: free(devicePath); LocalFree(lpDevicePath); LocalFree(pInterfaceDetailData); - bResult = SetupDiDestroyDeviceInfoList(hDeviceInfo); + bResult = SetupDiDestroyDeviceInfoList(hDeviceInfo); - devicePath = NULL; - lpDevicePath = NULL; + devicePath = NULL; + lpDevicePath = NULL; pInterfaceDetailData = NULL; if (!bResult) @@ -611,11 +610,9 @@ done: } RARCH_LOG("[Autoconf]: Could not find connected pad in Bliss-Box port#%d.\n", pid - BLISSBOX_PID); +#endif return NULL; -#else - return NULL; -#endif } #endif @@ -623,9 +620,9 @@ done: static const blissbox_pad_type_t* input_autoconfigure_get_blissbox_pad_type_libusb(int vid, int pid) { #ifdef HAVE_LIBUSB - unsigned char answer[USB_PACKET_CTRL_LEN] = {0}; unsigned i; - int ret = libusb_init(NULL); + unsigned char answer[USB_PACKET_CTRL_LEN] = {0}; + int ret = libusb_init(NULL); if (ret < 0) { @@ -693,10 +690,9 @@ static const blissbox_pad_type_t* input_autoconfigure_get_blissbox_pad_type_libu error: libusb_close(autoconfig_libusb_handle); libusb_exit(NULL); - return NULL; -#else - return NULL; #endif + + return NULL; } #endif From 78bf72e29e10c85ef642ba4921fb6a45a5033ffc Mon Sep 17 00:00:00 2001 From: bparker06 Date: Sat, 2 Dec 2017 13:33:09 -0500 Subject: [PATCH 132/394] blissbox: add atari pad type --- input/include/blissbox.h | 1 + 1 file changed, 1 insertion(+) diff --git a/input/include/blissbox.h b/input/include/blissbox.h index fd515ee218..4ec18e500d 100644 --- a/input/include/blissbox.h +++ b/input/include/blissbox.h @@ -42,6 +42,7 @@ const blissbox_pad_type_t blissbox_pad_types[] = {"A5200_TB", 50}, {"A7800", 4}, {"ATARI_KEYPAD", 43}, + {"ATARI", 0}, {"ATMARK", 10}, {"BALLY", 42}, {"CD32", 24}, From b1911495adb7e0509f96ff75012a722851f95193 Mon Sep 17 00:00:00 2001 From: radius Date: Sat, 2 Dec 2017 13:59:44 -0500 Subject: [PATCH 133/394] reenable network gamepad --- menu/menu_displaylist.c | 2 +- menu/menu_setting.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 2622132870..b42384394d 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -4273,7 +4273,7 @@ bool menu_displaylist_process(menu_displaylist_info_t *info) MENU_SETTING_ACTION, 0, 0); #endif -#if defined(HAVE_NETWORKING) && defined(HAVE_NETWORKGAMEPAD) && defined(HAVE_NETWORKGAMEPAD_CORE) +#if defined(HAVE_NETWORKING) && defined(HAVE_NETWORKGAMEPAD) menu_entries_append_enum(info->list, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_START_NET_RETROPAD), msg_hash_to_str(MENU_ENUM_LABEL_START_NET_RETROPAD), diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 22e36c4b68..86cca1a42a 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -2263,7 +2263,7 @@ static bool setting_append_list( parent_group); #endif -#if defined(HAVE_NETWORKING) && defined(HAVE_NETWORKGAMEPAD) && defined(HAVE_NETWORKGAMEPAD_CORE) +#if defined(HAVE_NETWORKING) && defined(HAVE_NETWORKGAMEPAD) CONFIG_ACTION( list, list_info, MENU_ENUM_LABEL_START_NET_RETROPAD, From 4efc8453c232996f3bfb2a83470fa5e14b54d44a Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Sat, 2 Dec 2017 15:59:33 -0500 Subject: [PATCH 134/394] buildfix for certain mingw environments --- tasks/task_autodetect.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tasks/task_autodetect.c b/tasks/task_autodetect.c index 4c2b454e3c..66080478f8 100644 --- a/tasks/task_autodetect.c +++ b/tasks/task_autodetect.c @@ -35,7 +35,15 @@ #if defined(_WIN32) && !defined(_XBOX) && !defined(_MSC_VER) && _WIN32_WINNT >= 0x0500 /* MinGW Win32 HID API */ +#include +#include #include +#ifdef __NO_INLINE__ +/* Workaround MinGW issue where compiling without -O2 (which sets __NO_INLINE__) causes the strsafe functions + * to never be defined (only declared). + */ +#define __CRT_STRSAFE_IMPL +#endif #include #include #include From e9a3088a795366929c5ff9c2757d64ae3d49ef6b Mon Sep 17 00:00:00 2001 From: Ash Date: Sun, 3 Dec 2017 11:31:30 +1100 Subject: [PATCH 135/394] [WiiU] Toolchain: Actually fix C++ constructors/destructors (oops!) Looks like I temporarily forgot how external symbols work. Fixes https://gbatemp.net/posts/7720955; hopefully we finally have C++ under control. --- frontend/drivers/platform_wiiu.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/frontend/drivers/platform_wiiu.c b/frontend/drivers/platform_wiiu.c index ab8a62f115..925f820652 100644 --- a/frontend/drivers/platform_wiiu.c +++ b/frontend/drivers/platform_wiiu.c @@ -525,24 +525,23 @@ void __eabi() __attribute__((weak)) void __init(void) { - extern void (**const __CTOR_LIST__)(void); - extern void (**const __CTOR_END__)(void); + extern void (*const __CTOR_LIST__)(void); + extern void (*const __CTOR_END__)(void); - void (**ctor)(void) = __CTOR_LIST__; - while (ctor < __CTOR_END__) { + void (*const *ctor)(void) = &__CTOR_LIST__; + while (ctor < &__CTOR_END__) { (*ctor++)(); } } - __attribute__((weak)) void __fini(void) { - extern void (**const __DTOR_LIST__)(void); - extern void (**const __DTOR_END__)(void); + extern void (*const __DTOR_LIST__)(void); + extern void (*const __DTOR_END__)(void); - void (**dtor)(void) = __DTOR_LIST__; - while (dtor < __DTOR_END__) { + void (*const *dtor)(void) = &__DTOR_LIST__; + while (dtor < &__DTOR_END__) { (*dtor++)(); } } @@ -654,7 +653,10 @@ void _start(int argc, char **argv) main(argc, argv); fsdev_exit(); -// __fini(); + +/* TODO: fix elf2rpl so it doesn't error with "Could not find matching symbol + for relocation" then uncomment this */ +// __fini(); memoryRelease(); SYSRelaunchTitle(0, 0); exit(0); From 69c2040e55755a8a093815a34a6c7f495fd12f8d Mon Sep 17 00:00:00 2001 From: radius Date: Sat, 2 Dec 2017 21:29:13 -0500 Subject: [PATCH 136/394] fix slow motion --- configuration.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/configuration.c b/configuration.c index 14b8d82c0a..30f985f4f3 100644 --- a/configuration.c +++ b/configuration.c @@ -2718,7 +2718,9 @@ static bool config_load_file(const char *path, bool set_defaults, *settings->paths.directory_system = '\0'; if (settings->floats.slowmotion_ratio < 1.0f) - configuration_set_float(settings, settings->floats.slowmotion_ratio, 1.0f); + { + configuration_set_float(settings, settings->floats.slowmotion_ratio, 15.0f); + } /* Sanitize fastforward_ratio value - previously range was -1 * and up (with 0 being skipped) */ @@ -2727,6 +2729,7 @@ static bool config_load_file(const char *path, bool set_defaults, configuration_set_float(settings, settings->floats.fastforward_ratio, 0.0f); } + #ifdef HAVE_LAKKA settings->bools.ssh_enable = path_file_exists(LAKKA_SSH_PATH); settings->bools.samba_enable = path_file_exists(LAKKA_SAMBA_PATH); From 0a3fb3ec40912211bbbafce8eb73fa61eef17c4b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 3 Dec 2017 03:37:06 +0100 Subject: [PATCH 137/394] Change value to 1.0f --- configuration.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configuration.c b/configuration.c index 30f985f4f3..0af3f1e94a 100644 --- a/configuration.c +++ b/configuration.c @@ -2719,7 +2719,7 @@ static bool config_load_file(const char *path, bool set_defaults, if (settings->floats.slowmotion_ratio < 1.0f) { - configuration_set_float(settings, settings->floats.slowmotion_ratio, 15.0f); + configuration_set_float(settings, settings->floats.slowmotion_ratio, 1.0f); } /* Sanitize fastforward_ratio value - previously range was -1 From 04b26fe111d991eedfd4ee879bd962472dc0d1c4 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 3 Dec 2017 03:43:05 +0100 Subject: [PATCH 138/394] Put braces around macros --- configuration.c | 4 ---- configuration.h | 17 ++++++++++++----- 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/configuration.c b/configuration.c index 0af3f1e94a..8edb392412 100644 --- a/configuration.c +++ b/configuration.c @@ -2718,16 +2718,12 @@ static bool config_load_file(const char *path, bool set_defaults, *settings->paths.directory_system = '\0'; if (settings->floats.slowmotion_ratio < 1.0f) - { configuration_set_float(settings, settings->floats.slowmotion_ratio, 1.0f); - } /* Sanitize fastforward_ratio value - previously range was -1 * and up (with 0 being skipped) */ if (settings->floats.fastforward_ratio < 0.0f) - { configuration_set_float(settings, settings->floats.fastforward_ratio, 0.0f); - } #ifdef HAVE_LAKKA diff --git a/configuration.h b/configuration.h index 31dbeebff3..c81a53f962 100644 --- a/configuration.h +++ b/configuration.h @@ -29,21 +29,28 @@ #include "input/input_defines.h" #define configuration_set_float(settings, var, newvar) \ +{ \ settings->modified = true; \ - var = newvar + var = newvar; \ +} #define configuration_set_bool(settings, var, newvar) \ +{ \ settings->modified = true; \ - var = newvar + var = newvar; \ +} #define configuration_set_uint(settings, var, newvar) \ +{ \ settings->modified = true; \ - var = newvar + var = newvar; \ +} #define configuration_set_int(settings, var, newvar) \ +{ \ settings->modified = true; \ - var = newvar - + var = newvar; \ +} enum override_type { From bada13a2152b2092e7c66e656b06f14bcd8ea07c Mon Sep 17 00:00:00 2001 From: radius Date: Sat, 2 Dec 2017 22:47:16 -0500 Subject: [PATCH 139/394] let it snow --- .../gl_shaders/pipeline_snowflake.glsl.frag.h | 65 +++++++++++++++++++ gfx/drivers_shader/shader_glsl.c | 16 +++++ gfx/video_driver.h | 1 + intl/msg_hash_us.h | 2 + menu/cbs/menu_cbs_get_value.c | 4 ++ menu/drivers/xmb.c | 3 + menu/drivers_display/menu_display_gl.c | 2 + menu/menu_driver.h | 1 + msg_hash.h | 1 + 9 files changed, 95 insertions(+) create mode 100644 gfx/drivers/gl_shaders/pipeline_snowflake.glsl.frag.h diff --git a/gfx/drivers/gl_shaders/pipeline_snowflake.glsl.frag.h b/gfx/drivers/gl_shaders/pipeline_snowflake.glsl.frag.h new file mode 100644 index 0000000000..f2bd97f6df --- /dev/null +++ b/gfx/drivers/gl_shaders/pipeline_snowflake.glsl.frag.h @@ -0,0 +1,65 @@ +/* credits to: TheTimJames + https://www.shadertoy.com/view/Md2GRw +*/ + +#include "shaders_common.h" + +static const char* stock_fragment_xmb_snowflake = GLSL( + uniform float time; + uniform float atime; + uniform vec2 OutputSize; + vec2 uv; + + float rand(vec2 co) + { + return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453); + } + + float snow(vec3 pos, vec2 uv, float o) + { + vec2 d = (pos.xy - uv); + float a = atan(d.y,d.x)+sin(atime*1.+o)*10.; + + float dist = d.x*d.x + d.y*d.y; + + if(dist < pos.z/400.){ + float col = 0.0; + if(sin(a*8.) < 0.0){col=1.0;} + if(distprg[VIDEO_SHADER_MENU_5].id, &glsl->uniforms[VIDEO_SHADER_MENU_5]); + +#if defined(HAVE_OPENGLES) + shader_prog_info.vertex = stock_vertex_xmb_snow_modern; +#else + shader_prog_info.vertex = glsl_core ? stock_vertex_xmb_snow_modern : stock_vertex_xmb_snow_legacy; +#endif + shader_prog_info.fragment = stock_fragment_xmb_snowflake; + + gl_glsl_compile_program( + glsl, + VIDEO_SHADER_MENU_6, + &glsl->prg[VIDEO_SHADER_MENU_6], + &shader_prog_info); + gl_glsl_find_uniforms(glsl, 0, glsl->prg[VIDEO_SHADER_MENU_6].id, + &glsl->uniforms[VIDEO_SHADER_MENU_6]); #endif gl_glsl_reset_attrib(glsl); diff --git a/gfx/video_driver.h b/gfx/video_driver.h index 0267c11e6d..6836ede817 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -56,6 +56,7 @@ #define VIDEO_SHADER_MENU_3 (GFX_MAX_SHADERS - 4) #define VIDEO_SHADER_MENU_4 (GFX_MAX_SHADERS - 5) #define VIDEO_SHADER_MENU_5 (GFX_MAX_SHADERS - 6) +#define VIDEO_SHADER_MENU_6 (GFX_MAX_SHADERS - 7) #endif diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index 5fb03ee34b..25a36dda4f 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -2542,6 +2542,8 @@ MSG_HASH( ) MSG_HASH(MENU_ENUM_LABEL_VALUE_SHADER_PIPELINE_BOKEH, "Bokeh") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SHADER_PIPELINE_SNOWFLAKE, + "Snowflake") MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_REFRESH_ROOMS, "Refresh Room List") MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_ROOM_NICKNAME, diff --git a/menu/cbs/menu_cbs_get_value.c b/menu/cbs/menu_cbs_get_value.c index 7c42baa346..5b98e95554 100644 --- a/menu/cbs/menu_cbs_get_value.c +++ b/menu/cbs/menu_cbs_get_value.c @@ -246,6 +246,10 @@ static void menu_action_setting_disp_set_label_pipeline( strlcpy(s, msg_hash_to_str( MENU_ENUM_LABEL_VALUE_SHADER_PIPELINE_BOKEH), len); + case XMB_SHADER_PIPELINE_SNOWFLAKE: + strlcpy(s, + msg_hash_to_str( + MENU_ENUM_LABEL_VALUE_SHADER_PIPELINE_SNOWFLAKE), len); break; } diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 0392da6f34..0185ec76ee 100755 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -2759,6 +2759,9 @@ static void xmb_draw_bg( case XMB_SHADER_PIPELINE_BOKEH: draw.pipeline.id = VIDEO_SHADER_MENU_5; break; + case XMB_SHADER_PIPELINE_SNOWFLAKE: + draw.pipeline.id = VIDEO_SHADER_MENU_6; + break; default: break; } diff --git a/menu/drivers_display/menu_display_gl.c b/menu/drivers_display/menu_display_gl.c index 65cf522115..d1d57b7075 100644 --- a/menu/drivers_display/menu_display_gl.c +++ b/menu/drivers_display/menu_display_gl.c @@ -185,6 +185,7 @@ static void menu_display_gl_draw_pipeline(void *data) case VIDEO_SHADER_MENU_3: case VIDEO_SHADER_MENU_4: case VIDEO_SHADER_MENU_5: + case VIDEO_SHADER_MENU_6: shader_info.data = NULL; shader_info.idx = draw->pipeline.id; shader_info.set_active = true; @@ -215,6 +216,7 @@ static void menu_display_gl_draw_pipeline(void *data) case VIDEO_SHADER_MENU_3: case VIDEO_SHADER_MENU_4: case VIDEO_SHADER_MENU_5: + case VIDEO_SHADER_MENU_6: #ifndef HAVE_PSGL uniform_param.type = UNIFORM_2F; uniform_param.lookup.ident = "OutputSize"; diff --git a/menu/menu_driver.h b/menu/menu_driver.h index d660ccbb4b..f2d3db313f 100644 --- a/menu/menu_driver.h +++ b/menu/menu_driver.h @@ -260,6 +260,7 @@ enum xmb_shader_pipeline XMB_SHADER_PIPELINE_SIMPLE_SNOW, XMB_SHADER_PIPELINE_SNOW, XMB_SHADER_PIPELINE_BOKEH, + XMB_SHADER_PIPELINE_SNOWFLAKE, XMB_SHADER_PIPELINE_LAST }; diff --git a/msg_hash.h b/msg_hash.h index fdd00470e1..f9e92af1d3 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -447,6 +447,7 @@ enum msg_hash_enums MENU_LABEL(SHADER_PIPELINE_SIMPLE_SNOW), MENU_LABEL(SHADER_PIPELINE_SNOW), MENU_LABEL(SHADER_PIPELINE_BOKEH), + MENU_LABEL(SHADER_PIPELINE_SNOWFLAKE), MENU_LABEL(MATERIALUI_MENU_HEADER_OPACITY), MENU_LABEL(MATERIALUI_MENU_FOOTER_OPACITY), From 3cd7026819286e2ced5adcfa267207290a73a9fd Mon Sep 17 00:00:00 2001 From: radius Date: Sun, 3 Dec 2017 12:19:00 -0500 Subject: [PATCH 140/394] fix the shader and the label --- gfx/drivers/gl_shaders/pipeline_snowflake.glsl.frag.h | 8 ++++---- menu/cbs/menu_cbs_get_value.c | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/gfx/drivers/gl_shaders/pipeline_snowflake.glsl.frag.h b/gfx/drivers/gl_shaders/pipeline_snowflake.glsl.frag.h index f2bd97f6df..a5426710ba 100644 --- a/gfx/drivers/gl_shaders/pipeline_snowflake.glsl.frag.h +++ b/gfx/drivers/gl_shaders/pipeline_snowflake.glsl.frag.h @@ -15,6 +15,8 @@ static const char* stock_fragment_xmb_snowflake = GLSL( return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453); } + float rand(float x){ return rand(vec2(x,1.0));} + float snow(vec3 pos, vec2 uv, float o) { vec2 d = (pos.xy - uv); @@ -35,17 +37,15 @@ static const char* stock_fragment_xmb_snowflake = GLSL( float col(vec2 c) { float color = 0.0; - for (int i = 1; i < 15; i++) + for (int i = 1; i < 50; i++) { - float o = rand(float(i) / 3.) * 15 * 2.0; + float o = rand(float(i) / 3.0) * 15 * 2.0; float z = rand(float(i) + 13.0); float x = 1.8 - (3.6) * (rand(floor((time*((z+1.0)/2.0)+o)/2.0)) + sin(time*o/1000.0)/10.0); float y = 1.0-mod((time*((z+1.0)/2.0))+o, 2.0); color += snow(vec3(x,y,z),c,o); } - - return color; } diff --git a/menu/cbs/menu_cbs_get_value.c b/menu/cbs/menu_cbs_get_value.c index 5b98e95554..d58701f8e3 100644 --- a/menu/cbs/menu_cbs_get_value.c +++ b/menu/cbs/menu_cbs_get_value.c @@ -246,6 +246,7 @@ static void menu_action_setting_disp_set_label_pipeline( strlcpy(s, msg_hash_to_str( MENU_ENUM_LABEL_VALUE_SHADER_PIPELINE_BOKEH), len); + break; case XMB_SHADER_PIPELINE_SNOWFLAKE: strlcpy(s, msg_hash_to_str( From 2747067f6188d0e4f845c6ceb5d39a33ab193b87 Mon Sep 17 00:00:00 2001 From: radius Date: Sun, 3 Dec 2017 15:10:24 -0500 Subject: [PATCH 141/394] this probably fixes the shader on noveau and others --- .../gl_shaders/pipeline_snowflake.glsl.frag.h | 39 ++++++++++++------- 1 file changed, 25 insertions(+), 14 deletions(-) diff --git a/gfx/drivers/gl_shaders/pipeline_snowflake.glsl.frag.h b/gfx/drivers/gl_shaders/pipeline_snowflake.glsl.frag.h index a5426710ba..1b048d2223 100644 --- a/gfx/drivers/gl_shaders/pipeline_snowflake.glsl.frag.h +++ b/gfx/drivers/gl_shaders/pipeline_snowflake.glsl.frag.h @@ -6,29 +6,40 @@ static const char* stock_fragment_xmb_snowflake = GLSL( uniform float time; - uniform float atime; uniform vec2 OutputSize; vec2 uv; + float atime; + float rand(vec2 co) { return fract(sin(dot(co.xy, vec2(12.9898, 78.233))) * 43758.5453); } - float rand(float x){ return rand(vec2(x,1.0));} + float rand_float(float x) + { + return rand(vec2(x, 1.0)); + } float snow(vec3 pos, vec2 uv, float o) { vec2 d = (pos.xy - uv); - float a = atan(d.y,d.x)+sin(atime*1.+o)*10.; + float a = atan(d.y,d.x) + sin(atime*1.0 + o) * 10.0; float dist = d.x*d.x + d.y*d.y; - if(dist < pos.z/400.){ + if(dist < pos.z/400.0) + { float col = 0.0; - if(sin(a*8.) < 0.0){col=1.0;} - if(dist Date: Mon, 4 Dec 2017 02:48:08 +0100 Subject: [PATCH 142/394] OSX PowerPC might not define O_CLOEXEC --- libretro-common/file/nbio/nbio_unixmmap.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/libretro-common/file/nbio/nbio_unixmmap.c b/libretro-common/file/nbio/nbio_unixmmap.c index 40703ae138..80325da393 100644 --- a/libretro-common/file/nbio/nbio_unixmmap.c +++ b/libretro-common/file/nbio/nbio_unixmmap.c @@ -39,6 +39,20 @@ #include #include +#ifdef __APPLE__ + +#ifndef O_CLOEXEC +#define O_CLOEXEC 0x1000000 +#endif + +#else + +#ifndef O_CLOEXEC +#define O_CLOEXEC 0 +#endif + +#endif + struct nbio_mmap_unix_t { int fd; From 43f6a03110a03ec1216e645645fa087fd91ba96c Mon Sep 17 00:00:00 2001 From: neville Date: Mon, 4 Dec 2017 02:59:06 +0100 Subject: [PATCH 143/394] (OSX PPC) Buildfixes --- gfx/common/gl_common.h | 5 +---- input/input_driver.c | 3 +++ 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/gfx/common/gl_common.h b/gfx/common/gl_common.h index 5d5c1fa284..04f2d6e3f4 100644 --- a/gfx/common/gl_common.h +++ b/gfx/common/gl_common.h @@ -33,15 +33,12 @@ #include "../video_coord_array.h" #include "../video_driver.h" #include "../drivers/gl_symlinks.h" +#include RETRO_BEGIN_DECLS #define MAX_FENCES 4 -#ifndef ARB_sync -typedef struct __GLsync *GLsync; -#endif - typedef struct gl { GLenum internal_fmt; diff --git a/input/input_driver.c b/input/input_driver.c index abfba95a91..b2e216c191 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -806,6 +806,9 @@ void input_menu_keys_pressed(void *data, retro_bits_t* p_new_state) uint8_t port_max = settings->bools.input_all_users_control_menu ? max_users : 1; + + joypad_info.joy_idx = 0; + joypad_info.auto_binds = NULL; RARCH_INPUT_STATE_CLEAR_PTR( p_new_state ); From f53093de4d4e8e5893dd7bd20b30989ea6a2d9dd Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 4 Dec 2017 03:12:27 +0100 Subject: [PATCH 144/394] Default to nbio stdio for PowerPC Mac --- libretro-common/file/nbio/nbio_intf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libretro-common/file/nbio/nbio_intf.c b/libretro-common/file/nbio/nbio_intf.c index 57d3eb6484..925cd6884e 100644 --- a/libretro-common/file/nbio/nbio_intf.c +++ b/libretro-common/file/nbio/nbio_intf.c @@ -36,7 +36,7 @@ extern nbio_intf_t nbio_stdio; #if defined(_linux__) static nbio_intf_t *internal_nbio = &nbio_linux; -#elif defined(HAVE_MMAP) && defined(BSD) +#elif defined(HAVE_MMAP) && defined(BSD) && !defined(__powerpc__) && !defined(__ppc__) static nbio_intf_t *internal_nbio = &nbio_mmap_unix; #elif defined(_WIN32) && !defined(_XBOX) static nbio_intf_t *internal_nbio = &nbio_mmap_win32; From 0bf461c40ff2a78dc6695f0a56bec8348ba11a93 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 4 Dec 2017 03:27:03 +0100 Subject: [PATCH 145/394] Try to get past OSX PowerPC crash on exit --- gfx/drivers_renderchain/gl2_renderchain.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/gfx/drivers_renderchain/gl2_renderchain.c b/gfx/drivers_renderchain/gl2_renderchain.c index 0c9733e35f..5f68e6005e 100644 --- a/gfx/drivers_renderchain/gl2_renderchain.c +++ b/gfx/drivers_renderchain/gl2_renderchain.c @@ -420,19 +420,25 @@ static void gl2_renderchain_deinit_fbo(void *data) { gl_t *gl = (gl_t*)data; + if (!gl) + return; + glDeleteTextures(gl->fbo_pass, gl->fbo_texture); - glDeleteFramebuffers(gl->fbo_pass, gl->fbo); + + if (gl->fbo) + glDeleteFramebuffers(gl->fbo_pass, gl->fbo); + memset(gl->fbo_texture, 0, sizeof(gl->fbo_texture)); - memset(gl->fbo, 0, sizeof(gl->fbo)); - gl->fbo_inited = false; - gl->fbo_pass = 0; + memset(gl->fbo, 0, sizeof(gl->fbo)); if (gl->fbo_feedback) glDeleteFramebuffers(1, &gl->fbo_feedback); if (gl->fbo_feedback_texture) glDeleteTextures(1, &gl->fbo_feedback_texture); + gl->fbo_inited = false; gl->fbo_feedback_enable = false; + gl->fbo_pass = 0; gl->fbo_feedback_pass = 0; gl->fbo_feedback_texture = 0; gl->fbo_feedback = 0; From 62215129115cf9e6f5bea6859a52f90cfd7eaad5 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 4 Dec 2017 04:04:07 +0100 Subject: [PATCH 146/394] use EXT version of Framebuffer/Renderbuffer functions for MacOS X PowerPC --- gfx/drivers/gl_symlinks.h | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/gfx/drivers/gl_symlinks.h b/gfx/drivers/gl_symlinks.h index 8628698f3e..fb84a8b182 100644 --- a/gfx/drivers/gl_symlinks.h +++ b/gfx/drivers/gl_symlinks.h @@ -38,6 +38,17 @@ #define glFramebufferRenderbuffer glFramebufferRenderbufferOES #define glRenderbufferStorage glRenderbufferStorageOES #define glDeleteRenderbuffers glDeleteRenderbuffersOES +#elif (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__))) +#define glGenFramebuffers glGenFramebuffersEXT +#define glBindFramebuffer glBindFramebufferEXT +#define glFramebufferTexture2D glFramebufferTexture2DEXT +#define glCheckFramebufferStatus glCheckFramebufferStatusEXT +#define glDeleteFramebuffers glDeleteFramebuffersEXT +#define glGenRenderbuffers glGenRenderbuffersEXT +#define glBindRenderbuffer glBindRenderbufferEXT +#define glFramebufferRenderbuffer glFramebufferRenderbufferEXT +#define glRenderbufferStorage glRenderbufferStorageEXT +#define glDeleteRenderbuffers glDeleteRenderbuffersEXT #endif #if defined(HAVE_PSGL) From 52e7a533f096dd71ada1cb3daf691414660fe0a5 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 4 Dec 2017 04:12:46 +0100 Subject: [PATCH 147/394] Improve FBO check --- libretro-common/gfx/gl_capabilities.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/libretro-common/gfx/gl_capabilities.c b/libretro-common/gfx/gl_capabilities.c index 221aa2a0b7..695650eee0 100644 --- a/libretro-common/gfx/gl_capabilities.c +++ b/libretro-common/gfx/gl_capabilities.c @@ -179,16 +179,13 @@ bool gl_check_capability(enum gl_capability_enum enum_idx) && !gl_query_extension("EXT_framebuffer_object")) return false; - if (glGenFramebuffers - && glBindFramebuffer - && glFramebufferTexture2D - && glCheckFramebufferStatus - && glDeleteFramebuffers - && glGenRenderbuffers - && glBindRenderbuffer - && glFramebufferRenderbuffer - && glRenderbufferStorage - && glDeleteRenderbuffers) + if (gl_query_extension("ARB_framebuffer_object")) + return true; + + if (gl_query_extension("EXT_framebuffer_object")) + return true; + + if (major >= 3) return true; break; #endif From b2fbb9aeda9bfb270920131ee76fe21464790f89 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 4 Dec 2017 04:18:28 +0100 Subject: [PATCH 148/394] Prepare to map DeleteFramebuffersEXT like this --- gfx/drivers/gl_symlinks.h | 11 ----------- gfx/drivers_renderchain/gl2_renderchain.c | 4 +--- libretro-common/glsym/glsym_gl.c | 4 ++++ 3 files changed, 5 insertions(+), 14 deletions(-) diff --git a/gfx/drivers/gl_symlinks.h b/gfx/drivers/gl_symlinks.h index fb84a8b182..8628698f3e 100644 --- a/gfx/drivers/gl_symlinks.h +++ b/gfx/drivers/gl_symlinks.h @@ -38,17 +38,6 @@ #define glFramebufferRenderbuffer glFramebufferRenderbufferOES #define glRenderbufferStorage glRenderbufferStorageOES #define glDeleteRenderbuffers glDeleteRenderbuffersOES -#elif (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__))) -#define glGenFramebuffers glGenFramebuffersEXT -#define glBindFramebuffer glBindFramebufferEXT -#define glFramebufferTexture2D glFramebufferTexture2DEXT -#define glCheckFramebufferStatus glCheckFramebufferStatusEXT -#define glDeleteFramebuffers glDeleteFramebuffersEXT -#define glGenRenderbuffers glGenRenderbuffersEXT -#define glBindRenderbuffer glBindRenderbufferEXT -#define glFramebufferRenderbuffer glFramebufferRenderbufferEXT -#define glRenderbufferStorage glRenderbufferStorageEXT -#define glDeleteRenderbuffers glDeleteRenderbuffersEXT #endif #if defined(HAVE_PSGL) diff --git a/gfx/drivers_renderchain/gl2_renderchain.c b/gfx/drivers_renderchain/gl2_renderchain.c index 5f68e6005e..69b70b71fa 100644 --- a/gfx/drivers_renderchain/gl2_renderchain.c +++ b/gfx/drivers_renderchain/gl2_renderchain.c @@ -424,9 +424,7 @@ static void gl2_renderchain_deinit_fbo(void *data) return; glDeleteTextures(gl->fbo_pass, gl->fbo_texture); - - if (gl->fbo) - glDeleteFramebuffers(gl->fbo_pass, gl->fbo); + glDeleteFramebuffers(gl->fbo_pass, gl->fbo); memset(gl->fbo_texture, 0, sizeof(gl->fbo_texture)); memset(gl->fbo, 0, sizeof(gl->fbo)); diff --git a/libretro-common/glsym/glsym_gl.c b/libretro-common/glsym/glsym_gl.c index 5aa92fdca2..41680ffcd1 100644 --- a/libretro-common/glsym/glsym_gl.c +++ b/libretro-common/glsym/glsym_gl.c @@ -308,7 +308,11 @@ const struct rglgen_sym_map rglgen_symbol_map[] = { SYM(GetRenderbufferParameteriv), SYM(IsFramebuffer), SYM(BindFramebuffer), +#if (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__))) + SYM(DeleteFramebuffersEXT), +#else SYM(DeleteFramebuffers), +#endif SYM(GenFramebuffers), SYM(CheckFramebufferStatus), SYM(FramebufferTexture1D), From e9af9f1b092a24699fc6023817d8ae21fc582a55 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 4 Dec 2017 04:20:54 +0100 Subject: [PATCH 149/394] Add EXT version --- libretro-common/glsym/glsym_gl.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libretro-common/glsym/glsym_gl.c b/libretro-common/glsym/glsym_gl.c index 41680ffcd1..585e7c320c 100644 --- a/libretro-common/glsym/glsym_gl.c +++ b/libretro-common/glsym/glsym_gl.c @@ -1341,6 +1341,7 @@ RGLSYMGLGETRENDERBUFFERPARAMETERIVPROC __rglgen_glGetRenderbufferParameteriv; RGLSYMGLISFRAMEBUFFERPROC __rglgen_glIsFramebuffer; RGLSYMGLBINDFRAMEBUFFERPROC __rglgen_glBindFramebuffer; RGLSYMGLDELETEFRAMEBUFFERSPROC __rglgen_glDeleteFramebuffers; +RGLSYMGLDELETEFRAMEBUFFERSPROC __rglgen_glDeleteFramebuffersEXT; RGLSYMGLGENFRAMEBUFFERSPROC __rglgen_glGenFramebuffers; RGLSYMGLCHECKFRAMEBUFFERSTATUSPROC __rglgen_glCheckFramebufferStatus; RGLSYMGLFRAMEBUFFERTEXTURE1DPROC __rglgen_glFramebufferTexture1D; From 19d7afd0c26778fc1e50dab9f31fd72048c75c57 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 4 Dec 2017 04:30:28 +0100 Subject: [PATCH 150/394] remove --- libretro-common/glsym/glsym_gl.c | 5 ----- 1 file changed, 5 deletions(-) diff --git a/libretro-common/glsym/glsym_gl.c b/libretro-common/glsym/glsym_gl.c index 585e7c320c..5aa92fdca2 100644 --- a/libretro-common/glsym/glsym_gl.c +++ b/libretro-common/glsym/glsym_gl.c @@ -308,11 +308,7 @@ const struct rglgen_sym_map rglgen_symbol_map[] = { SYM(GetRenderbufferParameteriv), SYM(IsFramebuffer), SYM(BindFramebuffer), -#if (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__))) - SYM(DeleteFramebuffersEXT), -#else SYM(DeleteFramebuffers), -#endif SYM(GenFramebuffers), SYM(CheckFramebufferStatus), SYM(FramebufferTexture1D), @@ -1341,7 +1337,6 @@ RGLSYMGLGETRENDERBUFFERPARAMETERIVPROC __rglgen_glGetRenderbufferParameteriv; RGLSYMGLISFRAMEBUFFERPROC __rglgen_glIsFramebuffer; RGLSYMGLBINDFRAMEBUFFERPROC __rglgen_glBindFramebuffer; RGLSYMGLDELETEFRAMEBUFFERSPROC __rglgen_glDeleteFramebuffers; -RGLSYMGLDELETEFRAMEBUFFERSPROC __rglgen_glDeleteFramebuffersEXT; RGLSYMGLGENFRAMEBUFFERSPROC __rglgen_glGenFramebuffers; RGLSYMGLCHECKFRAMEBUFFERSTATUSPROC __rglgen_glCheckFramebufferStatus; RGLSYMGLFRAMEBUFFERTEXTURE1DPROC __rglgen_glFramebufferTexture1D; From 44f3341ffe20323e2ed4b357e5b0dc33cfc3131f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 4 Dec 2017 04:42:40 +0100 Subject: [PATCH 151/394] Add EXT versions for OSX PPC --- gfx/drivers_renderchain/gl2_renderchain.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/gfx/drivers_renderchain/gl2_renderchain.c b/gfx/drivers_renderchain/gl2_renderchain.c index 69b70b71fa..22eb9bc558 100644 --- a/gfx/drivers_renderchain/gl2_renderchain.c +++ b/gfx/drivers_renderchain/gl2_renderchain.c @@ -67,7 +67,14 @@ typedef struct gl2_renderchain coords[5] = yamt; \ coords[7] = yamt -#define gl2_bind_fb(id) glBindFramebuffer(RARCH_GL_FRAMEBUFFER, id) +#if (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__))) +#define gl2_delete_fb(n, fb) glDeleteFramebuffersEXT(n, fb) +#define gl2_bind_fb(id) glBindFramebufferEXT(RARCH_GL_FRAMEBUFFER, id) +#else +#define gl2_delete_fb(n, fb) glDeleteFramebuffers(n, fb) +#define gl2_bind_fb(id) glBindFramebuffer(RARCH_GL_FRAMEBUFFER, id) +#endif + #ifndef GL_SYNC_GPU_COMMANDS_COMPLETE #define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117 @@ -424,13 +431,13 @@ static void gl2_renderchain_deinit_fbo(void *data) return; glDeleteTextures(gl->fbo_pass, gl->fbo_texture); - glDeleteFramebuffers(gl->fbo_pass, gl->fbo); + gl2_delete_fb(gl->fbo_pass, gl->fbo); memset(gl->fbo_texture, 0, sizeof(gl->fbo_texture)); memset(gl->fbo, 0, sizeof(gl->fbo)); if (gl->fbo_feedback) - glDeleteFramebuffers(1, &gl->fbo_feedback); + gl2_delete_fb(1, &gl->fbo_feedback); if (gl->fbo_feedback_texture) glDeleteTextures(1, &gl->fbo_feedback_texture); @@ -451,7 +458,7 @@ static void gl2_renderchain_deinit_hw_render(void *data) context_bind_hw_render(true); if (gl->hw_render_fbo_init) - glDeleteFramebuffers(gl->textures, gl->hw_render_fbo); + gl2_delete_fb(gl->textures, gl->hw_render_fbo); if (gl->hw_render_depth_init) glDeleteRenderbuffers(gl->textures, gl->hw_render_depth); gl->hw_render_fbo_init = false; @@ -510,9 +517,9 @@ static bool gl_create_fbo_targets(gl_t *gl) return true; error: - glDeleteFramebuffers(gl->fbo_pass, gl->fbo); + gl2_delete_fb(gl->fbo_pass, gl->fbo); if (gl->fbo_feedback) - glDeleteFramebuffers(1, &gl->fbo_feedback); + gl2_delete_fb(1, &gl->fbo_feedback); RARCH_ERR("[GL]: Failed to set up frame buffer objects. Multi-pass shading will not work.\n"); return false; } From 5a341acb5fe0dee96920ef2e7e32e1dbd8762985 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 4 Dec 2017 04:57:58 +0100 Subject: [PATCH 152/394] Wrap more GL framebuffer functions --- gfx/drivers_renderchain/gl2_renderchain.c | 28 ++++++++++++++--------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/gfx/drivers_renderchain/gl2_renderchain.c b/gfx/drivers_renderchain/gl2_renderchain.c index 22eb9bc558..82038df196 100644 --- a/gfx/drivers_renderchain/gl2_renderchain.c +++ b/gfx/drivers_renderchain/gl2_renderchain.c @@ -68,9 +68,15 @@ typedef struct gl2_renderchain coords[7] = yamt #if (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__))) +#define gl2_fb_texture_2d(a, b, c, d, e) glFramebufferTexture2DEXT(a, b, c, d, e) +#define gl2_check_fb_status(target) glCheckFramebufferStatusEXT(target) +#define gl2_gen_fb(n, ids) glGenFramebuffersEXT(n, ids) #define gl2_delete_fb(n, fb) glDeleteFramebuffersEXT(n, fb) #define gl2_bind_fb(id) glBindFramebufferEXT(RARCH_GL_FRAMEBUFFER, id) #else +#define gl2_fb_texture_2d(a, b, c, d, e) glFramebufferTexture2D(a, b, c, d, e) +#define gl2_check_fb_status(target) glCheckFramebufferStatus(target) +#define gl2_gen_fb(n, ids) glGenFramebuffers(n, ids) #define gl2_delete_fb(n, fb) glDeleteFramebuffers(n, fb) #define gl2_bind_fb(id) glBindFramebuffer(RARCH_GL_FRAMEBUFFER, id) #endif @@ -176,11 +182,11 @@ static bool gl_recreate_fbo( 0, RARCH_GL_TEXTURE_TYPE32, RARCH_GL_FORMAT32, NULL); - glFramebufferTexture2D(RARCH_GL_FRAMEBUFFER, + gl2_fb_texture_2d(RARCH_GL_FRAMEBUFFER, RARCH_GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, *texture, 0); - if (glCheckFramebufferStatus(RARCH_GL_FRAMEBUFFER) + if (gl2_check_fb_status(RARCH_GL_FRAMEBUFFER) == RARCH_GL_FRAMEBUFFER_COMPLETE) return true; @@ -479,17 +485,17 @@ static bool gl_create_fbo_targets(gl_t *gl) int i; glBindTexture(GL_TEXTURE_2D, 0); - glGenFramebuffers(gl->fbo_pass, gl->fbo); + gl2_gen_fb(gl->fbo_pass, gl->fbo); for (i = 0; i < gl->fbo_pass; i++) { GLenum status; gl2_bind_fb(gl->fbo[i]); - glFramebufferTexture2D(RARCH_GL_FRAMEBUFFER, + gl2_fb_texture_2d(RARCH_GL_FRAMEBUFFER, RARCH_GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, gl->fbo_texture[i], 0); - status = glCheckFramebufferStatus(RARCH_GL_FRAMEBUFFER); + status = gl2_check_fb_status(RARCH_GL_FRAMEBUFFER); if (status != RARCH_GL_FRAMEBUFFER_COMPLETE) goto error; } @@ -498,13 +504,13 @@ static bool gl_create_fbo_targets(gl_t *gl) { GLenum status; - glGenFramebuffers(1, &gl->fbo_feedback); + gl2_gen_fb(1, &gl->fbo_feedback); gl2_bind_fb(gl->fbo_feedback); - glFramebufferTexture2D(RARCH_GL_FRAMEBUFFER, + gl2_fb_texture_2d(RARCH_GL_FRAMEBUFFER, RARCH_GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, gl->fbo_feedback_texture, 0); - status = glCheckFramebufferStatus(RARCH_GL_FRAMEBUFFER); + status = gl2_check_fb_status(RARCH_GL_FRAMEBUFFER); if (status != RARCH_GL_FRAMEBUFFER_COMPLETE) goto error; @@ -883,7 +889,7 @@ static bool gl2_renderchain_init_hw_render( RARCH_LOG("[GL]: Supports FBO (render-to-texture).\n"); glBindTexture(GL_TEXTURE_2D, 0); - glGenFramebuffers(gl->textures, gl->hw_render_fbo); + gl2_gen_fb(gl->textures, gl->hw_render_fbo); depth = hwr->depth; stencil = hwr->stencil; @@ -897,7 +903,7 @@ static bool gl2_renderchain_init_hw_render( for (i = 0; i < gl->textures; i++) { gl2_bind_fb(gl->hw_render_fbo[i]); - glFramebufferTexture2D(RARCH_GL_FRAMEBUFFER, + gl2_fb_texture_2d(RARCH_GL_FRAMEBUFFER, RARCH_GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, gl->texture[i], 0); if (depth) @@ -934,7 +940,7 @@ static bool gl2_renderchain_init_hw_render( } } - status = glCheckFramebufferStatus(RARCH_GL_FRAMEBUFFER); + status = gl2_check_fb_status(RARCH_GL_FRAMEBUFFER); if (status != RARCH_GL_FRAMEBUFFER_COMPLETE) { RARCH_ERR("[GL]: Failed to create HW render FBO #%u, error: 0x%u.\n", From c869cc51025d7ac04ded8825c64720fd5aa74ce4 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 4 Dec 2017 05:55:18 +0100 Subject: [PATCH 153/394] Refactor GL code --- gfx/common/gl_common.c | 2 + gfx/drivers/gl.c | 1 + gfx/drivers/gl_symlinks.h | 15 -------- gfx/drivers_renderchain/gl2_renderchain.c | 46 ++++++++++++++++++----- 4 files changed, 39 insertions(+), 25 deletions(-) diff --git a/gfx/common/gl_common.c b/gfx/common/gl_common.c index f349938427..bf8aab5059 100644 --- a/gfx/common/gl_common.c +++ b/gfx/common/gl_common.c @@ -21,6 +21,8 @@ #include "../../config.h" #endif +#include + #include "../drivers/gl_symlinks.h" #include "../video_coord_array.h" diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 8c2d230194..ba037d574d 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -40,6 +40,7 @@ #include #include +#include #include "../../configuration.h" #include "../../dynamic.h" diff --git a/gfx/drivers/gl_symlinks.h b/gfx/drivers/gl_symlinks.h index 8628698f3e..91d618776d 100644 --- a/gfx/drivers/gl_symlinks.h +++ b/gfx/drivers/gl_symlinks.h @@ -21,25 +21,10 @@ #include #include -#include - #ifdef HAVE_CONFIG_H #include "config.h" #endif -#if defined(HAVE_PSGL) -#define glGenFramebuffers glGenFramebuffersOES -#define glBindFramebuffer glBindFramebufferOES -#define glFramebufferTexture2D glFramebufferTexture2DOES -#define glCheckFramebufferStatus glCheckFramebufferStatusOES -#define glDeleteFramebuffers glDeleteFramebuffersOES -#define glGenRenderbuffers glGenRenderbuffersOES -#define glBindRenderbuffer glBindRenderbufferOES -#define glFramebufferRenderbuffer glFramebufferRenderbufferOES -#define glRenderbufferStorage glRenderbufferStorageOES -#define glDeleteRenderbuffers glDeleteRenderbuffersOES -#endif - #if defined(HAVE_PSGL) #define RARCH_GL_FRAMEBUFFER GL_FRAMEBUFFER_OES #define RARCH_GL_FRAMEBUFFER_COMPLETE GL_FRAMEBUFFER_COMPLETE_OES diff --git a/gfx/drivers_renderchain/gl2_renderchain.c b/gfx/drivers_renderchain/gl2_renderchain.c index 82038df196..a9320732b3 100644 --- a/gfx/drivers_renderchain/gl2_renderchain.c +++ b/gfx/drivers_renderchain/gl2_renderchain.c @@ -41,6 +41,7 @@ #include #include +#include #include "../video_driver.h" #include "../video_shader_parse.h" @@ -67,18 +68,43 @@ typedef struct gl2_renderchain coords[5] = yamt; \ coords[7] = yamt -#if (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__))) +#if defined(HAVE_PSGL) +#define gl2_fb_texture_2d(a, b, c, d, e) glFramebufferTexture2DOES(a, b, c, d, e) +#define gl2_check_fb_status(target) glCheckFramebufferStatusOES(target) +#define gl2_gen_fb(n, ids) glGenFramebuffersOES(n, ids) +#define gl2_delete_fb(n, fb) glDeleteFramebuffersOES(n, fb) +#define gl2_bind_fb(id) glBindFramebufferOES(RARCH_GL_FRAMEBUFFER, id) +#define gl2_gen_rb glGenRenderbuffersOES +#define gl2_bind_rb glBindRenderbufferOES +#define gl2_fb_rb glFramebufferRenderbufferOES +#define gl2_rb_storage glRenderbufferStorageOES +#define gl2_delete_rb glDeleteRenderbuffersOES + +#elif (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__))) #define gl2_fb_texture_2d(a, b, c, d, e) glFramebufferTexture2DEXT(a, b, c, d, e) #define gl2_check_fb_status(target) glCheckFramebufferStatusEXT(target) #define gl2_gen_fb(n, ids) glGenFramebuffersEXT(n, ids) #define gl2_delete_fb(n, fb) glDeleteFramebuffersEXT(n, fb) #define gl2_bind_fb(id) glBindFramebufferEXT(RARCH_GL_FRAMEBUFFER, id) +#define gl2_gen_rb glGenRenderbuffersEXT +#define gl2_bind_rb glBindRenderbufferEXT +#define gl2_fb_rb glFramebufferRenderbufferEXT +#define gl2_rb_storage glRenderbufferStorageEXT +#define gl2_delete_rb glDeleteRenderbuffersEXT + #else + #define gl2_fb_texture_2d(a, b, c, d, e) glFramebufferTexture2D(a, b, c, d, e) #define gl2_check_fb_status(target) glCheckFramebufferStatus(target) #define gl2_gen_fb(n, ids) glGenFramebuffers(n, ids) #define gl2_delete_fb(n, fb) glDeleteFramebuffers(n, fb) #define gl2_bind_fb(id) glBindFramebuffer(RARCH_GL_FRAMEBUFFER, id) +#define gl2_gen_rb glGenRenderbuffers +#define gl2_bind_rb glBindRenderbuffer +#define gl2_fb_rb glFramebufferRenderbuffer +#define gl2_rb_storage glRenderbufferStorage +#define gl2_delete_rb glDeleteRenderbuffers + #endif @@ -466,7 +492,7 @@ static void gl2_renderchain_deinit_hw_render(void *data) if (gl->hw_render_fbo_init) gl2_delete_fb(gl->textures, gl->hw_render_fbo); if (gl->hw_render_depth_init) - glDeleteRenderbuffers(gl->textures, gl->hw_render_depth); + gl2_delete_rb(gl->textures, gl->hw_render_depth); gl->hw_render_fbo_init = false; context_bind_hw_render(false); @@ -896,7 +922,7 @@ static bool gl2_renderchain_init_hw_render( if (depth) { - glGenRenderbuffers(gl->textures, gl->hw_render_depth); + gl2_gen_rb(gl->textures, gl->hw_render_depth); gl->hw_render_depth_init = true; } @@ -908,33 +934,33 @@ static bool gl2_renderchain_init_hw_render( if (depth) { - glBindRenderbuffer(RARCH_GL_RENDERBUFFER, gl->hw_render_depth[i]); - glRenderbufferStorage(RARCH_GL_RENDERBUFFER, + gl2_bind_rb(RARCH_GL_RENDERBUFFER, gl->hw_render_depth[i]); + gl2_rb_storage(RARCH_GL_RENDERBUFFER, stencil ? RARCH_GL_DEPTH24_STENCIL8 : GL_DEPTH_COMPONENT16, width, height); - glBindRenderbuffer(RARCH_GL_RENDERBUFFER, 0); + gl2_bind_rb(RARCH_GL_RENDERBUFFER, 0); if (stencil) { #if defined(HAVE_OPENGLES2) || defined(HAVE_OPENGLES1) || ((defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__)))) /* GLES2 is a bit weird, as always. * There's no GL_DEPTH_STENCIL_ATTACHMENT like in desktop GL. */ - glFramebufferRenderbuffer(RARCH_GL_FRAMEBUFFER, + gl2_fb_rb(RARCH_GL_FRAMEBUFFER, RARCH_GL_DEPTH_ATTACHMENT, RARCH_GL_RENDERBUFFER, gl->hw_render_depth[i]); - glFramebufferRenderbuffer(RARCH_GL_FRAMEBUFFER, + gl2_fb_rb(RARCH_GL_FRAMEBUFFER, RARCH_GL_STENCIL_ATTACHMENT, RARCH_GL_RENDERBUFFER, gl->hw_render_depth[i]); #else /* We use ARB FBO extensions, no need to check. */ - glFramebufferRenderbuffer(RARCH_GL_FRAMEBUFFER, + gl2_fb_rb(RARCH_GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, RARCH_GL_RENDERBUFFER, gl->hw_render_depth[i]); #endif } else { - glFramebufferRenderbuffer(RARCH_GL_FRAMEBUFFER, + gl2_fb_rb(RARCH_GL_FRAMEBUFFER, RARCH_GL_DEPTH_ATTACHMENT, RARCH_GL_RENDERBUFFER, gl->hw_render_depth[i]); } From 9558e569f10f924321c6c9541144cd505b2573c9 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 4 Dec 2017 05:56:03 +0100 Subject: [PATCH 154/394] We can still make use of this for PowerPC Mac --- libretro-common/file/nbio/nbio_intf.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libretro-common/file/nbio/nbio_intf.c b/libretro-common/file/nbio/nbio_intf.c index 925cd6884e..57d3eb6484 100644 --- a/libretro-common/file/nbio/nbio_intf.c +++ b/libretro-common/file/nbio/nbio_intf.c @@ -36,7 +36,7 @@ extern nbio_intf_t nbio_stdio; #if defined(_linux__) static nbio_intf_t *internal_nbio = &nbio_linux; -#elif defined(HAVE_MMAP) && defined(BSD) && !defined(__powerpc__) && !defined(__ppc__) +#elif defined(HAVE_MMAP) && defined(BSD) static nbio_intf_t *internal_nbio = &nbio_mmap_unix; #elif defined(_WIN32) && !defined(_XBOX) static nbio_intf_t *internal_nbio = &nbio_mmap_win32; From 512a1b4cb65ac1294b84b0b3453ab4f5fc68262d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 4 Dec 2017 06:03:11 +0100 Subject: [PATCH 155/394] Cleanups --- gfx/common/gl_common.c | 7 +- gfx/common/gl_common.h | 119 ++++++++++++++++++++++++++++++- gfx/drivers/gl_symlinks.h | 144 -------------------------------------- 3 files changed, 119 insertions(+), 151 deletions(-) delete mode 100644 gfx/drivers/gl_symlinks.h diff --git a/gfx/common/gl_common.c b/gfx/common/gl_common.c index bf8aab5059..10c139bef0 100644 --- a/gfx/common/gl_common.c +++ b/gfx/common/gl_common.c @@ -14,18 +14,13 @@ * If not, see . */ -#include #include #ifdef HAVE_CONFIG_H #include "../../config.h" #endif -#include - -#include "../drivers/gl_symlinks.h" -#include "../video_coord_array.h" - +#include "gl_common.h" static void gl_size_format(GLint* internalFormat) { diff --git a/gfx/common/gl_common.h b/gfx/common/gl_common.h index 04f2d6e3f4..7eb88af66e 100644 --- a/gfx/common/gl_common.h +++ b/gfx/common/gl_common.h @@ -17,7 +17,9 @@ #ifndef __GL_COMMON_H #define __GL_COMMON_H +#include #include +#include #ifdef HAVE_CONFIG_H #include "../../config.h" @@ -32,13 +34,128 @@ #include "../font_driver.h" #include "../video_coord_array.h" #include "../video_driver.h" -#include "../drivers/gl_symlinks.h" #include RETRO_BEGIN_DECLS #define MAX_FENCES 4 +#if defined(HAVE_PSGL) +#define RARCH_GL_FRAMEBUFFER GL_FRAMEBUFFER_OES +#define RARCH_GL_FRAMEBUFFER_COMPLETE GL_FRAMEBUFFER_COMPLETE_OES +#define RARCH_GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0_EXT +#elif (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__))) +#define RARCH_GL_FRAMEBUFFER GL_FRAMEBUFFER_EXT +#define RARCH_GL_FRAMEBUFFER_COMPLETE GL_FRAMEBUFFER_COMPLETE_EXT +#define RARCH_GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0_EXT +#else +#define RARCH_GL_FRAMEBUFFER GL_FRAMEBUFFER +#define RARCH_GL_FRAMEBUFFER_COMPLETE GL_FRAMEBUFFER_COMPLETE +#define RARCH_GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0 +#endif + +#if defined(HAVE_OPENGLES2) || defined(HAVE_OPENGLES3) || defined(HAVE_OPENGLES_3_1) || defined(HAVE_OPENGLES_3_2) +#define RARCH_GL_RENDERBUFFER GL_RENDERBUFFER +#if defined(HAVE_OPENGLES2) +#define RARCH_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_OES +#else +#define RARCH_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8 +#endif +#define RARCH_GL_DEPTH_ATTACHMENT GL_DEPTH_ATTACHMENT +#define RARCH_GL_STENCIL_ATTACHMENT GL_STENCIL_ATTACHMENT +#elif (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__))) +#define RARCH_GL_RENDERBUFFER GL_RENDERBUFFER_EXT +#define RARCH_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_EXT +#define RARCH_GL_DEPTH_ATTACHMENT GL_DEPTH_ATTACHMENT_EXT +#define RARCH_GL_STENCIL_ATTACHMENT GL_STENCIL_ATTACHMENT_EXT +#elif defined(HAVE_PSGL) +#define RARCH_GL_RENDERBUFFER GL_RENDERBUFFER_OES +#define RARCH_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_SCE +#define RARCH_GL_DEPTH_ATTACHMENT GL_DEPTH_ATTACHMENT_OES +#define RARCH_GL_STENCIL_ATTACHMENT GL_STENCIL_ATTACHMENT_OES +#else +#define RARCH_GL_RENDERBUFFER GL_RENDERBUFFER +#define RARCH_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8 +#define RARCH_GL_DEPTH_ATTACHMENT GL_DEPTH_ATTACHMENT +#define RARCH_GL_STENCIL_ATTACHMENT GL_STENCIL_ATTACHMENT +#endif + +#if (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__))) +#define RARCH_GL_MAX_RENDERBUFFER_SIZE GL_MAX_RENDERBUFFER_SIZE_EXT +#elif defined(HAVE_PSGL) +#define RARCH_GL_MAX_RENDERBUFFER_SIZE GL_MAX_RENDERBUFFER_SIZE_OES +#else +#define RARCH_GL_MAX_RENDERBUFFER_SIZE GL_MAX_RENDERBUFFER_SIZE +#endif + +#if defined(HAVE_PSGL) +#define glGenerateMipmap glGenerateMipmapOES +#endif + +#if defined(__APPLE__) || defined(HAVE_PSGL) +#define GL_RGBA32F GL_RGBA32F_ARB +#endif + +#if defined(HAVE_PSGL) +#define RARCH_GL_INTERNAL_FORMAT32 GL_ARGB_SCE +#define RARCH_GL_INTERNAL_FORMAT16 GL_RGB5 /* TODO: Verify if this is really 565 or just 555. */ +#define RARCH_GL_TEXTURE_TYPE32 GL_BGRA +#define RARCH_GL_TEXTURE_TYPE16 GL_BGRA +#define RARCH_GL_FORMAT32 GL_UNSIGNED_INT_8_8_8_8_REV +#define RARCH_GL_FORMAT16 GL_RGB5 +#elif defined(HAVE_OPENGLES) +/* Imgtec/SGX headers have this missing. */ +#ifndef GL_BGRA_EXT +#define GL_BGRA_EXT 0x80E1 +#endif +#ifndef GL_BGRA8_EXT +#define GL_BGRA8_EXT 0x93A1 +#endif +#ifdef IOS +/* Stupid Apple */ +#define RARCH_GL_INTERNAL_FORMAT32 GL_RGBA +#else +#define RARCH_GL_INTERNAL_FORMAT32 GL_BGRA_EXT +#endif +#define RARCH_GL_INTERNAL_FORMAT16 GL_RGB +#define RARCH_GL_TEXTURE_TYPE32 GL_BGRA_EXT +#define RARCH_GL_TEXTURE_TYPE16 GL_RGB +#define RARCH_GL_FORMAT32 GL_UNSIGNED_BYTE +#define RARCH_GL_FORMAT16 GL_UNSIGNED_SHORT_5_6_5 +#else +/* On desktop, we always use 32-bit. */ +#define RARCH_GL_INTERNAL_FORMAT32 GL_RGBA8 +#define RARCH_GL_INTERNAL_FORMAT16 GL_RGBA8 +#define RARCH_GL_TEXTURE_TYPE32 GL_BGRA +#define RARCH_GL_TEXTURE_TYPE16 GL_BGRA +#define RARCH_GL_FORMAT32 GL_UNSIGNED_INT_8_8_8_8_REV +#define RARCH_GL_FORMAT16 GL_UNSIGNED_INT_8_8_8_8_REV + +/* GL_RGB565 internal format isn't in desktop GL + * until 4.1 core (ARB_ES2_compatibility). + * Check for this. */ +#ifndef GL_RGB565 +#define GL_RGB565 0x8D62 +#endif +#define RARCH_GL_INTERNAL_FORMAT16_565 GL_RGB565 +#define RARCH_GL_TEXTURE_TYPE16_565 GL_RGB +#define RARCH_GL_FORMAT16_565 GL_UNSIGNED_SHORT_5_6_5 +#endif + +#if defined(HAVE_OPENGLES2) /* TODO: Figure out exactly what. */ +#define NO_GL_CLAMP_TO_BORDER +#endif + +#if defined(HAVE_OPENGLES) +#ifndef GL_UNPACK_ROW_LENGTH +#define GL_UNPACK_ROW_LENGTH 0x0CF2 +#endif + +#ifndef GL_SRGB_ALPHA_EXT +#define GL_SRGB_ALPHA_EXT 0x8C42 +#endif +#endif + typedef struct gl { GLenum internal_fmt; diff --git a/gfx/drivers/gl_symlinks.h b/gfx/drivers/gl_symlinks.h deleted file mode 100644 index 91d618776d..0000000000 --- a/gfx/drivers/gl_symlinks.h +++ /dev/null @@ -1,144 +0,0 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2010-2014 - Hans-Kristian Arntzen - * Copyright (C) 2011-2017 - Daniel De Matteis - * Copyright (C) 2012-2015 - Michael Lelli - * - * RetroArch 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 Found- - * ation, either version 3 of the License, or (at your option) any later version. - * - * RetroArch 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 RetroArch. - * If not, see . - */ - -#ifndef _GL_SYMLINKS_H -#define _GL_SYMLINKS_H - -#include -#include - -#ifdef HAVE_CONFIG_H -#include "config.h" -#endif - -#if defined(HAVE_PSGL) -#define RARCH_GL_FRAMEBUFFER GL_FRAMEBUFFER_OES -#define RARCH_GL_FRAMEBUFFER_COMPLETE GL_FRAMEBUFFER_COMPLETE_OES -#define RARCH_GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0_EXT -#elif (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__))) -#define RARCH_GL_FRAMEBUFFER GL_FRAMEBUFFER_EXT -#define RARCH_GL_FRAMEBUFFER_COMPLETE GL_FRAMEBUFFER_COMPLETE_EXT -#define RARCH_GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0_EXT -#else -#define RARCH_GL_FRAMEBUFFER GL_FRAMEBUFFER -#define RARCH_GL_FRAMEBUFFER_COMPLETE GL_FRAMEBUFFER_COMPLETE -#define RARCH_GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0 -#endif - -#if defined(HAVE_OPENGLES2) || defined(HAVE_OPENGLES3) || defined(HAVE_OPENGLES_3_1) || defined(HAVE_OPENGLES_3_2) -#define RARCH_GL_RENDERBUFFER GL_RENDERBUFFER -#if defined(HAVE_OPENGLES2) -#define RARCH_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_OES -#else -#define RARCH_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8 -#endif -#define RARCH_GL_DEPTH_ATTACHMENT GL_DEPTH_ATTACHMENT -#define RARCH_GL_STENCIL_ATTACHMENT GL_STENCIL_ATTACHMENT -#elif (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__))) -#define RARCH_GL_RENDERBUFFER GL_RENDERBUFFER_EXT -#define RARCH_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_EXT -#define RARCH_GL_DEPTH_ATTACHMENT GL_DEPTH_ATTACHMENT_EXT -#define RARCH_GL_STENCIL_ATTACHMENT GL_STENCIL_ATTACHMENT_EXT -#elif defined(HAVE_PSGL) -#define RARCH_GL_RENDERBUFFER GL_RENDERBUFFER_OES -#define RARCH_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8_SCE -#define RARCH_GL_DEPTH_ATTACHMENT GL_DEPTH_ATTACHMENT_OES -#define RARCH_GL_STENCIL_ATTACHMENT GL_STENCIL_ATTACHMENT_OES -#else -#define RARCH_GL_RENDERBUFFER GL_RENDERBUFFER -#define RARCH_GL_DEPTH24_STENCIL8 GL_DEPTH24_STENCIL8 -#define RARCH_GL_DEPTH_ATTACHMENT GL_DEPTH_ATTACHMENT -#define RARCH_GL_STENCIL_ATTACHMENT GL_STENCIL_ATTACHMENT -#endif - -#if (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__))) -#define RARCH_GL_MAX_RENDERBUFFER_SIZE GL_MAX_RENDERBUFFER_SIZE_EXT -#elif defined(HAVE_PSGL) -#define RARCH_GL_MAX_RENDERBUFFER_SIZE GL_MAX_RENDERBUFFER_SIZE_OES -#else -#define RARCH_GL_MAX_RENDERBUFFER_SIZE GL_MAX_RENDERBUFFER_SIZE -#endif - -#if defined(HAVE_PSGL) -#define glGenerateMipmap glGenerateMipmapOES -#endif - -#if defined(__APPLE__) || defined(HAVE_PSGL) -#define GL_RGBA32F GL_RGBA32F_ARB -#endif - -#if defined(HAVE_PSGL) -#define RARCH_GL_INTERNAL_FORMAT32 GL_ARGB_SCE -#define RARCH_GL_INTERNAL_FORMAT16 GL_RGB5 /* TODO: Verify if this is really 565 or just 555. */ -#define RARCH_GL_TEXTURE_TYPE32 GL_BGRA -#define RARCH_GL_TEXTURE_TYPE16 GL_BGRA -#define RARCH_GL_FORMAT32 GL_UNSIGNED_INT_8_8_8_8_REV -#define RARCH_GL_FORMAT16 GL_RGB5 -#elif defined(HAVE_OPENGLES) -/* Imgtec/SGX headers have this missing. */ -#ifndef GL_BGRA_EXT -#define GL_BGRA_EXT 0x80E1 -#endif -#ifndef GL_BGRA8_EXT -#define GL_BGRA8_EXT 0x93A1 -#endif -#ifdef IOS -/* Stupid Apple */ -#define RARCH_GL_INTERNAL_FORMAT32 GL_RGBA -#else -#define RARCH_GL_INTERNAL_FORMAT32 GL_BGRA_EXT -#endif -#define RARCH_GL_INTERNAL_FORMAT16 GL_RGB -#define RARCH_GL_TEXTURE_TYPE32 GL_BGRA_EXT -#define RARCH_GL_TEXTURE_TYPE16 GL_RGB -#define RARCH_GL_FORMAT32 GL_UNSIGNED_BYTE -#define RARCH_GL_FORMAT16 GL_UNSIGNED_SHORT_5_6_5 -#else -/* On desktop, we always use 32-bit. */ -#define RARCH_GL_INTERNAL_FORMAT32 GL_RGBA8 -#define RARCH_GL_INTERNAL_FORMAT16 GL_RGBA8 -#define RARCH_GL_TEXTURE_TYPE32 GL_BGRA -#define RARCH_GL_TEXTURE_TYPE16 GL_BGRA -#define RARCH_GL_FORMAT32 GL_UNSIGNED_INT_8_8_8_8_REV -#define RARCH_GL_FORMAT16 GL_UNSIGNED_INT_8_8_8_8_REV - -/* GL_RGB565 internal format isn't in desktop GL - * until 4.1 core (ARB_ES2_compatibility). - * Check for this. */ -#ifndef GL_RGB565 -#define GL_RGB565 0x8D62 -#endif -#define RARCH_GL_INTERNAL_FORMAT16_565 GL_RGB565 -#define RARCH_GL_TEXTURE_TYPE16_565 GL_RGB -#define RARCH_GL_FORMAT16_565 GL_UNSIGNED_SHORT_5_6_5 -#endif - -#if defined(HAVE_OPENGLES2) /* TODO: Figure out exactly what. */ -#define NO_GL_CLAMP_TO_BORDER -#endif - -#if defined(HAVE_OPENGLES) -#ifndef GL_UNPACK_ROW_LENGTH -#define GL_UNPACK_ROW_LENGTH 0x0CF2 -#endif - -#ifndef GL_SRGB_ALPHA_EXT -#define GL_SRGB_ALPHA_EXT 0x8C42 -#endif -#endif - -#endif From 4e342956c10e774363666157bfe58a6e97f83374 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 4 Dec 2017 06:13:01 +0100 Subject: [PATCH 156/394] Update comment --- gfx/drivers_renderchain/gl1_renderchain.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/gfx/drivers_renderchain/gl1_renderchain.c b/gfx/drivers_renderchain/gl1_renderchain.c index 04e8fa6199..9cc36d8a36 100644 --- a/gfx/drivers_renderchain/gl1_renderchain.c +++ b/gfx/drivers_renderchain/gl1_renderchain.c @@ -108,14 +108,12 @@ static bool gl1_renderchain_read_viewport( /* Use slow synchronous readbacks. Use this with plain screenshots as we don't really care about performance in this case. */ - /* GLES2 only guarantees GL_RGBA/GL_UNSIGNED_BYTE + /* GL1 only guarantees GL_RGBA/GL_UNSIGNED_BYTE * readbacks so do just that. - * GLES2 also doesn't support reading back data + * GL1 also doesn't support reading back data * from front buffer, so render a cached frame * and have gl_frame() do the readback while it's * in the back buffer. - * - * Keep codepath similar for GLES and desktop GL. */ gl->readback_buffer_screenshot = malloc(num_pixels * sizeof(uint32_t)); From 241df59771d5b9d1048162b15c7c53fdd38a48f8 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 4 Dec 2017 11:20:18 +0100 Subject: [PATCH 157/394] Get rid of include --- gfx/video_driver.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/gfx/video_driver.c b/gfx/video_driver.c index d06252fb90..c4174e6726 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -46,10 +46,6 @@ #include "../menu/menu_setting.h" #endif -#ifdef HAVE_OPENGL -#include "common/gl_common.h" -#endif - #include "video_thread_wrapper.h" #include "video_driver.h" From 05ab278aca22bdbf47773a53618a1598d93ae30a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 4 Dec 2017 11:54:30 +0100 Subject: [PATCH 158/394] Pass chain userdata to renderchain driver --- gfx/drivers/gl.c | 80 +++++++++++++---------- gfx/drivers_renderchain/gl1_renderchain.c | 4 +- gfx/drivers_renderchain/gl2_renderchain.c | 77 +++++++++++++++------- gfx/video_driver.h | 56 +++++++++------- 4 files changed, 134 insertions(+), 83 deletions(-) diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index ba037d574d..3cc6adf629 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -595,7 +595,7 @@ static void gl_init_textures(gl_t *gl, const video_info_t *video) if (gl->renderchain_driver->init_texture_reference) gl->renderchain_driver->init_texture_reference( - gl, i, internal_fmt, + gl, gl->renderchain_data, i, internal_fmt, texture_fmt, texture_type); } @@ -894,11 +894,11 @@ static void gl_pbo_async_readback(gl_t *gl) gl->pbo_readback_valid[gl->pbo_readback_index] = true; if (gl->renderchain_driver->readback) - gl->renderchain_driver->readback(gl, + gl->renderchain_driver->readback(gl, gl->renderchain_data, video_pixel_get_alignment(gl->vp.width * sizeof(uint32_t)), fmt, type, NULL); if (gl->renderchain_driver->unbind_pbo) - gl->renderchain_driver->unbind_pbo(); + gl->renderchain_driver->unbind_pbo(gl, gl->renderchain_data); } static INLINE void gl_draw_texture(gl_t *gl, video_frame_info_t *video_info) @@ -983,7 +983,7 @@ static bool gl_frame(void *data, const void *frame, context_bind_hw_render(false); if (gl->core_context_in_use && gl->renderchain_driver->bind_vao) - gl->renderchain_driver->bind_vao(gl); + gl->renderchain_driver->bind_vao(gl, gl->renderchain_data); video_info->cb_shader_use(gl, video_info->shader_data, 1, true); @@ -997,11 +997,12 @@ static bool gl_frame(void *data, const void *frame, { if (gl->renderchain_driver->recompute_pass_sizes) gl->renderchain_driver->recompute_pass_sizes( - gl, frame_width, frame_height, + gl, gl->renderchain_data, frame_width, frame_height, gl->vp_out_width, gl->vp_out_height); if (gl->renderchain_driver->start_render) - gl->renderchain_driver->start_render(gl, video_info); + gl->renderchain_driver->start_render(gl, gl->renderchain_data, + video_info); } if (gl->should_resize) @@ -1019,12 +1020,14 @@ static bool gl_frame(void *data, const void *frame, if (gl->fbo_inited) { if (gl->renderchain_driver->check_fbo_dimensions) - gl->renderchain_driver->check_fbo_dimensions(gl); + gl->renderchain_driver->check_fbo_dimensions(gl, + gl->renderchain_data); /* Go back to what we're supposed to do, * render to FBO #0. */ if (gl->renderchain_driver->start_render) - gl->renderchain_driver->start_render(gl, video_info); + gl->renderchain_driver->start_render(gl, gl->renderchain_data, + video_info); } else gl_set_viewport(gl, video_info, width, height, false, true); @@ -1043,7 +1046,7 @@ static bool gl_frame(void *data, const void *frame, gl_update_input_size(gl, frame_width, frame_height, pitch, true); if (gl->renderchain_driver->copy_frame) - gl->renderchain_driver->copy_frame(gl, + gl->renderchain_driver->copy_frame(gl, gl->renderchain_data, video_info, frame, frame_width, frame_height, pitch); } @@ -1061,12 +1064,12 @@ static bool gl_frame(void *data, const void *frame, if (!gl->fbo_inited) { if (gl->renderchain_driver->bind_backbuffer) - gl->renderchain_driver->bind_backbuffer(); + gl->renderchain_driver->bind_backbuffer(gl, gl->renderchain_data); gl_set_viewport(gl, video_info, width, height, false, true); } if (gl->renderchain_driver->restore_default_state) - gl->renderchain_driver->restore_default_state(gl); + gl->renderchain_driver->restore_default_state(gl, gl->renderchain_data); glDisable(GL_STENCIL_TEST); glDisable(GL_BLEND); @@ -1128,12 +1131,14 @@ static bool gl_frame(void *data, const void *frame, glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); if (gl->fbo_inited && gl->renderchain_driver->renderchain_render) - gl->renderchain_driver->renderchain_render(gl, video_info, + gl->renderchain_driver->renderchain_render(gl, gl->renderchain_data, + video_info, frame_count, &gl->tex_info, &feedback_info); /* Set prev textures. */ if (gl->renderchain_driver->bind_prev_texture) - gl->renderchain_driver->bind_prev_texture(gl, &gl->tex_info); + gl->renderchain_driver->bind_prev_texture(gl, gl->renderchain_data, + &gl->tex_info); #if defined(HAVE_MENU) if (gl->menu_texture_enable) @@ -1168,7 +1173,8 @@ static bool gl_frame(void *data, const void *frame, glBindTexture(GL_TEXTURE_2D, 0); if (gl->renderchain_driver->disable_client_arrays) - gl->renderchain_driver->disable_client_arrays(); + gl->renderchain_driver->disable_client_arrays(gl, + gl->renderchain_data); } /* Screenshots. */ @@ -1176,6 +1182,7 @@ static bool gl_frame(void *data, const void *frame, { if (gl->renderchain_driver->readback) gl->renderchain_driver->readback(gl, + gl->renderchain_data, 4, GL_RGBA, GL_UNSIGNED_BYTE, gl->readback_buffer_screenshot); } @@ -1208,12 +1215,14 @@ static bool gl_frame(void *data, const void *frame, if (gl->renderchain_driver->fence_iterate) gl->renderchain_driver->fence_iterate(gl, + gl->renderchain_data, video_info->hard_sync_frames); } if (gl->core_context_in_use && gl->renderchain_driver->unbind_vao) - gl->renderchain_driver->unbind_vao(gl); + gl->renderchain_driver->unbind_vao(gl, + gl->renderchain_data); context_bind_hw_render(true); @@ -1243,7 +1252,7 @@ static void gl_deinit_chain(gl_t *gl) return; if (gl->renderchain_driver->chain_free) - gl->renderchain_driver->chain_free(gl->renderchain_data); + gl->renderchain_driver->chain_free(gl, gl->renderchain_data); gl->renderchain_driver = NULL; gl->renderchain_data = NULL; @@ -1260,14 +1269,14 @@ static void gl_free(void *data) if (gl->have_sync) { if (gl->renderchain_driver->fence_free) - gl->renderchain_driver->fence_free(gl); + gl->renderchain_driver->fence_free(gl, gl->renderchain_data); } font_driver_free_osd(); video_shader_driver_deinit(); if (gl->renderchain_driver->disable_client_arrays) - gl->renderchain_driver->disable_client_arrays(); + gl->renderchain_driver->disable_client_arrays(gl, gl->renderchain_data); glDeleteTextures(gl->textures, gl->texture); @@ -1296,13 +1305,13 @@ static void gl_free(void *data) if (gl->core_context_in_use) { if (gl->renderchain_driver->unbind_vao) - gl->renderchain_driver->unbind_vao(gl); + gl->renderchain_driver->unbind_vao(gl, gl->renderchain_data); if (gl->renderchain_driver->free_vao) - gl->renderchain_driver->free_vao(gl); + gl->renderchain_driver->free_vao(gl, gl->renderchain_data); } if (gl->renderchain_driver->free) - gl->renderchain_driver->free(gl); + gl->renderchain_driver->free(gl, gl->renderchain_data); gl_deinit_chain(gl); video_context_driver_free(); @@ -1464,7 +1473,7 @@ static bool gl_init_pbo_readback(gl_t *gl) gl->vp.height * sizeof(uint32_t), NULL); } if (gl->renderchain_driver->unbind_pbo) - gl->renderchain_driver->unbind_pbo(); + gl->renderchain_driver->unbind_pbo(gl, gl->renderchain_data); #ifndef HAVE_OPENGLES3 { @@ -1776,11 +1785,11 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo } if (gl->renderchain_driver->restore_default_state) - gl->renderchain_driver->restore_default_state(gl); + gl->renderchain_driver->restore_default_state(gl, gl->renderchain_data); if (hwr->context_type == RETRO_HW_CONTEXT_OPENGL_CORE) if (gl->renderchain_driver->new_vao) - gl->renderchain_driver->new_vao(gl); + gl->renderchain_driver->new_vao(gl, gl->renderchain_data); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendEquation(GL_FUNC_ADD); @@ -1928,13 +1937,13 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo gl_init_textures_data(gl); if (gl->renderchain_driver->init) - gl->renderchain_driver->init(gl, gl->tex_w, gl->tex_h); + gl->renderchain_driver->init(gl, gl->renderchain_data, gl->tex_w, gl->tex_h); if (gl->has_fbo) { if (gl->hw_render_use && gl->renderchain_driver->init_hw_render && - !gl->renderchain_driver->init_hw_render(gl, gl->tex_w, gl->tex_h)) + !gl->renderchain_driver->init_hw_render(gl, gl->renderchain_data, gl->tex_w, gl->tex_h)) { RARCH_ERR("[GL]: Hardware rendering context initialization failed.\n"); goto error; @@ -2112,7 +2121,7 @@ static bool gl_set_shader(void *data, if (gl->fbo_inited) { if (gl->renderchain_driver->deinit_fbo) - gl->renderchain_driver->deinit_fbo(gl); + gl->renderchain_driver->deinit_fbo(gl, gl->renderchain_data); glBindTexture(GL_TEXTURE_2D, gl->texture[gl->tex_index]); } @@ -2144,7 +2153,7 @@ static bool gl_set_shader(void *data, { if (gl->hw_render_use && gl->fbo_inited && gl->renderchain_driver->deinit_hw_render) - gl->renderchain_driver->deinit_hw_render(gl); + gl->renderchain_driver->deinit_hw_render(gl, gl->renderchain_data); glDeleteTextures(gl->textures, gl->texture); #if defined(HAVE_PSGL) @@ -2158,11 +2167,13 @@ static bool gl_set_shader(void *data, gl_init_textures_data(gl); if (gl->hw_render_use && gl->renderchain_driver->init_hw_render) - gl->renderchain_driver->init_hw_render(gl, gl->tex_w, gl->tex_h); + gl->renderchain_driver->init_hw_render(gl, gl->renderchain_data, + gl->tex_w, gl->tex_h); } if (gl->renderchain_driver->init) - gl->renderchain_driver->init(gl, gl->tex_w, gl->tex_h); + gl->renderchain_driver->init(gl, gl->renderchain_data, + gl->tex_w, gl->tex_h); /* Apparently need to set viewport for passes when we aren't using FBOs. */ gl_set_shader_viewports(gl); @@ -2186,7 +2197,7 @@ static void gl_viewport_info(void *data, struct video_viewport *vp) gl_t *gl = (gl_t*)data; if (!gl->renderchain_driver || !gl->renderchain_driver->viewport_info) return; - gl->renderchain_driver->viewport_info(data, vp); + gl->renderchain_driver->viewport_info(gl, gl->renderchain_data, vp); } static bool gl_read_viewport(void *data, uint8_t *buffer, bool is_idle) @@ -2194,7 +2205,8 @@ static bool gl_read_viewport(void *data, uint8_t *buffer, bool is_idle) gl_t *gl = (gl_t*)data; if (!gl->renderchain_driver || !gl->renderchain_driver->read_viewport) return false; - return gl->renderchain_driver->read_viewport(data, buffer, is_idle); + return gl->renderchain_driver->read_viewport(gl, gl->renderchain_data, + buffer, is_idle); } #if 0 @@ -2525,7 +2537,7 @@ static void gl_set_coords(void *handle_data, void *shader_data, { gl_t *gl = (gl_t*)handle_data; if (gl && gl->renderchain_driver->set_coords) - gl->renderchain_driver->set_coords(handle_data, + gl->renderchain_driver->set_coords(gl, gl->renderchain_data, shader_data, coords); } @@ -2534,7 +2546,7 @@ static void gl_set_mvp(void *data, void *shader_data, { gl_t *gl = (gl_t*)data; if (gl && gl->renderchain_driver->set_mvp) - gl->renderchain_driver->set_mvp(data, + gl->renderchain_driver->set_mvp(gl, gl->renderchain_data, shader_data, mat_data); } diff --git a/gfx/drivers_renderchain/gl1_renderchain.c b/gfx/drivers_renderchain/gl1_renderchain.c index 9cc36d8a36..04a756db9f 100644 --- a/gfx/drivers_renderchain/gl1_renderchain.c +++ b/gfx/drivers_renderchain/gl1_renderchain.c @@ -57,9 +57,9 @@ typedef struct gl1_renderchain GLenum min_filter_to_mag(GLenum type); -void gl1_renderchain_free(void *data) +void gl1_renderchain_free(void *data, void *chain_data) { - gl_t *gl = (gl_t*)data; + (void)chain_data; (void)gl; } diff --git a/gfx/drivers_renderchain/gl2_renderchain.c b/gfx/drivers_renderchain/gl2_renderchain.c index a9320732b3..f52f77f5e7 100644 --- a/gfx/drivers_renderchain/gl2_renderchain.c +++ b/gfx/drivers_renderchain/gl2_renderchain.c @@ -117,7 +117,8 @@ typedef struct gl2_renderchain #endif /* Prototypes */ -static void gl2_renderchain_bind_backbuffer(void) +static void gl2_renderchain_bind_backbuffer(void *data, + void *chain_data) { #ifdef IOS /* There is no default frame buffer on iOS. */ @@ -257,7 +258,8 @@ static void gl_check_fbo_dimension(gl_t *gl, unsigned i, /* On resize, we might have to recreate our FBOs * due to "Viewport" scale, and set a new viewport. */ -static void gl2_renderchain_check_fbo_dimensions(void *data) +static void gl2_renderchain_check_fbo_dimensions(void *data, + void *chain_data) { int i; gl_t *gl = (gl_t*)data; @@ -280,6 +282,7 @@ static void gl2_renderchain_check_fbo_dimensions(void *data) static void gl2_renderchain_render( void *data, + void *chain_data, video_frame_info_t *video_info, uint64_t frame_count, const struct video_tex_info *tex_info, @@ -391,7 +394,7 @@ static void gl2_renderchain_render( set_texture_coords(fbo_tex_coords, xamt, yamt); /* Push final FBO to list. */ - fbo_info = &fbo_tex_info[gl->fbo_pass - 1]; + fbo_info = &fbo_tex_info[gl->fbo_pass - 1]; fbo_info->tex = gl->fbo_texture[gl->fbo_pass - 1]; fbo_info->input_size[0] = prev_rect->img_width; @@ -402,7 +405,7 @@ static void gl2_renderchain_render( fbo_tex_info_cnt++; /* Render our FBO texture to back buffer. */ - gl2_renderchain_bind_backbuffer(); + gl2_renderchain_bind_backbuffer(gl, chain_data); shader_info.data = gl; shader_info.idx = gl->fbo_pass + 1; @@ -455,7 +458,8 @@ static void gl2_renderchain_render( gl->coords.tex_coord = gl->tex_info.coord; } -static void gl2_renderchain_deinit_fbo(void *data) +static void gl2_renderchain_deinit_fbo(void *data, + void *chain_data) { gl_t *gl = (gl_t*)data; @@ -481,7 +485,9 @@ static void gl2_renderchain_deinit_fbo(void *data) gl->fbo_feedback = 0; } -static void gl2_renderchain_deinit_hw_render(void *data) +static void gl2_renderchain_deinit_hw_render( + void *data, + void *chain_data) { gl_t *gl = (gl_t*)data; if (!gl) @@ -498,12 +504,12 @@ static void gl2_renderchain_deinit_hw_render(void *data) context_bind_hw_render(false); } -void gl2_renderchain_free(void *data) +static void gl2_renderchain_free(void *data, void *chain_data) { gl_t *gl = (gl_t*)data; - gl2_renderchain_deinit_fbo(gl); - gl2_renderchain_deinit_hw_render(gl); + gl2_renderchain_deinit_fbo(gl, chain_data); + gl2_renderchain_deinit_hw_render(gl, chain_data); } static bool gl_create_fbo_targets(gl_t *gl) @@ -683,6 +689,7 @@ static void gl_create_fbo_textures(gl_t *gl) static void gl2_renderchain_recompute_pass_sizes( void *data, + void *chain_data, unsigned width, unsigned height, unsigned vp_width, unsigned vp_height) { @@ -745,6 +752,7 @@ static void gl2_renderchain_recompute_pass_sizes( } static void gl2_renderchain_start_render(void *data, + void *chain_data, video_frame_info_t *video_info) { /* Used when rendering to an FBO. @@ -779,7 +787,8 @@ static void gl2_renderchain_start_render(void *data, /* Set up render to texture. */ void gl2_renderchain_init( - void *data, unsigned fbo_width, unsigned fbo_height) + void *data, void *chain_data, + unsigned fbo_width, unsigned fbo_height) { int i; unsigned width, height; @@ -847,6 +856,7 @@ void gl2_renderchain_init( } gl2_renderchain_recompute_pass_sizes(gl, + chain_data, fbo_width, fbo_height, width, height); for (i = 0; i < gl->fbo_pass; i++) @@ -887,6 +897,7 @@ void gl2_renderchain_init( static bool gl2_renderchain_init_hw_render( void *data, + void *chain_data, unsigned width, unsigned height) { GLenum status; @@ -975,7 +986,7 @@ static bool gl2_renderchain_init_hw_render( } } - gl2_renderchain_bind_backbuffer(); + gl2_renderchain_bind_backbuffer(gl, chain_data); gl->hw_render_fbo_init = true; context_bind_hw_render(false); @@ -984,6 +995,7 @@ static bool gl2_renderchain_init_hw_render( static void gl2_renderchain_bind_prev_texture( void *data, + void *chain_data, const struct video_tex_info *tex_info) { gl_t *gl = (gl_t*)data; @@ -1007,7 +1019,8 @@ static void gl2_renderchain_bind_prev_texture( } static void gl2_renderchain_viewport_info( - void *data, struct video_viewport *vp) + void *data, void *chain_data, + struct video_viewport *vp) { unsigned width, height; unsigned top_y, top_dist; @@ -1026,7 +1039,9 @@ static void gl2_renderchain_viewport_info( } static bool gl2_renderchain_read_viewport( - void *data, uint8_t *buffer, bool is_idle) + void *data, + void *chain_data, + uint8_t *buffer, bool is_idle) { unsigned num_pixels = 0; gl_t *gl = (gl_t*)data; @@ -1127,9 +1142,9 @@ error: return false; } -void gl2_renderchain_free_internal(void *data) +void gl2_renderchain_free_internal(void *data, void *chain_data) { - gl2_renderchain_t *cg_data = (gl2_renderchain_t*)data; + gl2_renderchain_t *cg_data = (gl2_renderchain_t*)chain_data; if (!cg_data) return; @@ -1147,7 +1162,8 @@ static void *gl2_renderchain_new(void) } #ifndef HAVE_OPENGLES -static void gl2_renderchain_bind_vao(void *data) +static void gl2_renderchain_bind_vao(void *data, + void *chain_data) { gl_t *gl = (gl_t*)data; if (!gl) @@ -1155,7 +1171,8 @@ static void gl2_renderchain_bind_vao(void *data) glBindVertexArray(gl->vao); } -static void gl2_renderchain_unbind_vao(void *data) +static void gl2_renderchain_unbind_vao(void *data, + void *chain_data) { gl_t *gl = (gl_t*)data; if (!gl) @@ -1163,7 +1180,8 @@ static void gl2_renderchain_unbind_vao(void *data) glBindVertexArray(0); } -static void gl2_renderchain_new_vao(void *data) +static void gl2_renderchain_new_vao(void *data, + void *chain_data) { gl_t *gl = (gl_t*)data; if (!gl) @@ -1171,7 +1189,8 @@ static void gl2_renderchain_new_vao(void *data) glGenVertexArrays(1, &gl->vao); } -static void gl2_renderchain_free_vao(void *data) +static void gl2_renderchain_free_vao(void *data, + void *chain_data) { gl_t *gl = (gl_t*)data; if (!gl) @@ -1180,7 +1199,9 @@ static void gl2_renderchain_free_vao(void *data) } #endif -static void gl2_renderchain_restore_default_state(void *data) +static void gl2_renderchain_restore_default_state( + void *data, + void *chain_data) { gl_t *gl = (gl_t*)data; if (!gl) @@ -1196,6 +1217,7 @@ static void gl2_renderchain_restore_default_state(void *data) static void gl2_renderchain_copy_frame( void *data, + void *chain_data, video_frame_info_t *video_info, const void *frame, unsigned width, unsigned height, unsigned pitch) @@ -1338,7 +1360,8 @@ static void gl2_renderchain_bind_pbo(unsigned idx) glBindBuffer(GL_PIXEL_PACK_BUFFER, (GLuint)idx); } -static void gl2_renderchain_unbind_pbo(void) +static void gl2_renderchain_unbind_pbo(void *data, + void *chain_data) { glBindBuffer(GL_PIXEL_PACK_BUFFER, 0); } @@ -1352,6 +1375,7 @@ static void gl2_renderchain_init_pbo(unsigned size, #endif static void gl2_renderchain_readback(void *data, + void *chain_data, unsigned alignment, unsigned fmt, unsigned type, void *src) @@ -1370,8 +1394,10 @@ static void gl2_renderchain_readback(void *data, } #ifndef HAVE_OPENGLES -static void gl2_renderchain_fence_iterate(void *data, unsigned - hard_sync_frames) +static void gl2_renderchain_fence_iterate( + void *data, + void *chain_data, + unsigned hard_sync_frames) { gl_t *gl = (gl_t*)data; @@ -1390,7 +1416,8 @@ static void gl2_renderchain_fence_iterate(void *data, unsigned } } -static void gl2_renderchain_fence_free(void *data) +static void gl2_renderchain_fence_free(void *data, + void *chain_data) { unsigned i; gl_t *gl = (gl_t*)data; @@ -1406,7 +1433,7 @@ static void gl2_renderchain_fence_free(void *data) #endif static void gl2_renderchain_init_textures_reference( - void *data, unsigned i, + void *data, void *chain_data, unsigned i, unsigned internal_fmt, unsigned texture_fmt, unsigned texture_type) { diff --git a/gfx/video_driver.h b/gfx/video_driver.h index 6836ede817..33765da5dd 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -838,56 +838,68 @@ typedef struct d3d_renderchain_driver typedef struct gl_renderchain_driver { void (*set_coords)(void *handle_data, + void *chain_data, void *shader_data, const struct video_coords *coords); - void (*set_mvp)(void *data, void *shader_data, + void (*set_mvp)(void *data, + void *chain_data, + void *shader_data, const void *mat_data); void (*init_texture_reference)( - void *data, unsigned i, + void *data, void *chain_data, unsigned i, unsigned internal_fmt, unsigned texture_fmt, unsigned texture_type); - void (*fence_iterate)(void *data, unsigned hard_sync_frames); - void (*fence_free)(void *data); + void (*fence_iterate)(void *data, void *chain_data, + unsigned hard_sync_frames); + void (*fence_free)(void *data, void *chain_data); void (*readback)(void *data, + void *chain_data, unsigned alignment, unsigned fmt, unsigned type, void *src); void (*init_pbo)(unsigned size, const void *data); void (*bind_pbo)(unsigned idx); - void (*unbind_pbo)(void); + void (*unbind_pbo)(void *data, void *chain_data); void (*copy_frame)( void *data, + void *chain_data, video_frame_info_t *video_info, const void *frame, unsigned width, unsigned height, unsigned pitch); - void (*restore_default_state)(void *data); - void (*new_vao)(void *data); - void (*free_vao)(void *data); - void (*bind_vao)(void *data); - void (*unbind_vao)(void *data); - void (*disable_client_arrays)(void); + void (*restore_default_state)(void *data, void *chain_data); + void (*new_vao)(void *data, void *chain_data); + void (*free_vao)(void *data, void *chain_data); + void (*bind_vao)(void *data, void *chain_data); + void (*unbind_vao)(void *data, void *chain_data); + void (*disable_client_arrays)(void *data, void *chain_data); void (*ff_vertex)(const void *data); void (*ff_matrix)(const void *data); - void (*bind_backbuffer)(void); - void (*deinit_fbo)(void *data); + void (*bind_backbuffer)(void *data, void *chain_data); + void (*deinit_fbo)(void *data, void *chain_data); void (*viewport_info)( - void *data, struct video_viewport *vp); + void *data, void *chain_data, struct video_viewport *vp); bool (*read_viewport)( - void *data, uint8_t *buffer, bool is_idle); + void *data, void *chain_data, uint8_t *buffer, bool is_idle); void (*bind_prev_texture)( void *data, + void *chain_data, const struct video_tex_info *tex_info); - void (*chain_free)(void *data); + void (*chain_free)(void *data, void *chain_data); void *(*chain_new)(void); - void (*init)(void *data, unsigned fbo_width, unsigned fbo_height); - bool (*init_hw_render)(void *data, unsigned width, unsigned height); - void (*free)(void *data); - void (*deinit_hw_render)(void *data); - void (*start_render)(void *data, video_frame_info_t *video_info); - void (*check_fbo_dimensions)(void *data); + void (*init)(void *data, void *chain_data, + unsigned fbo_width, unsigned fbo_height); + bool (*init_hw_render)(void *data, void *chain_data, + unsigned width, unsigned height); + void (*free)(void *data, void *chain_data); + void (*deinit_hw_render)(void *data, void *chain_data); + void (*start_render)(void *data, void *chain_data, + video_frame_info_t *video_info); + void (*check_fbo_dimensions)(void *data, void *chain_data); void (*recompute_pass_sizes)(void *data, + void *chain_data, unsigned width, unsigned height, unsigned vp_width, unsigned vp_height); void (*renderchain_render)(void *data, + void *chain_data, video_frame_info_t *video_info, uint64_t frame_count, const struct video_tex_info *tex_info, From 072570bbf3f90273474c14380b50e77fd2429482 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 4 Dec 2017 11:58:16 +0100 Subject: [PATCH 159/394] (GL) Update GL1 renderchain too --- gfx/drivers_renderchain/gl1_renderchain.c | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) diff --git a/gfx/drivers_renderchain/gl1_renderchain.c b/gfx/drivers_renderchain/gl1_renderchain.c index 04a756db9f..a9762cf0ba 100644 --- a/gfx/drivers_renderchain/gl1_renderchain.c +++ b/gfx/drivers_renderchain/gl1_renderchain.c @@ -60,11 +60,12 @@ GLenum min_filter_to_mag(GLenum type); void gl1_renderchain_free(void *data, void *chain_data) { (void)chain_data; - (void)gl; + (void)data; } static void gl1_renderchain_bind_prev_texture( void *data, + void *chain_data, const struct video_tex_info *tex_info) { gl_t *gl = (gl_t*)data; @@ -76,7 +77,8 @@ static void gl1_renderchain_bind_prev_texture( } static void gl1_renderchain_viewport_info( - void *data, struct video_viewport *vp) + void *data, void *chain_data, + struct video_viewport *vp) { unsigned width, height; unsigned top_y, top_dist; @@ -95,7 +97,8 @@ static void gl1_renderchain_viewport_info( } static bool gl1_renderchain_read_viewport( - void *data, uint8_t *buffer, bool is_idle) + void *data, void *chain_data, + uint8_t *buffer, bool is_idle) { unsigned num_pixels = 0; gl_t *gl = (gl_t*)data; @@ -134,9 +137,9 @@ static bool gl1_renderchain_read_viewport( return true; } -void gl1_renderchain_free_internal(void *data) +void gl1_renderchain_free_internal(void *data, void *chain_data) { - gl1_renderchain_t *cg_data = (gl1_renderchain_t*)data; + gl1_renderchain_t *cg_data = (gl1_renderchain_t*)chain_data; if (!cg_data) return; @@ -183,7 +186,8 @@ static void gl1_renderchain_ff_matrix(const void *data) glLoadMatrixf(ident.data); } -static void gl1_renderchain_disable_client_arrays(void) +static void gl1_renderchain_disable_client_arrays(void *data, + void *chain_data) { if (gl_query_core_context_in_use()) return; @@ -196,7 +200,8 @@ static void gl1_renderchain_disable_client_arrays(void) glDisableClientState(GL_TEXTURE_COORD_ARRAY); } -static void gl1_renderchain_restore_default_state(void *data) +static void gl1_renderchain_restore_default_state(void *data, + void *chain_data) { gl_t *gl = (gl_t*)data; if (!gl) @@ -209,6 +214,7 @@ static void gl1_renderchain_restore_default_state(void *data) static void gl1_renderchain_copy_frame( void *data, + void *chain_data, video_frame_info_t *video_info, const void *frame, unsigned width, unsigned height, unsigned pitch) @@ -244,6 +250,7 @@ static void gl1_renderchain_copy_frame( } static void gl1_renderchain_readback(void *data, + void *chain_data, unsigned alignment, unsigned fmt, unsigned type, void *src) @@ -260,6 +267,7 @@ static void gl1_renderchain_readback(void *data, } static void gl1_renderchain_set_mvp(void *data, + void *chain_data, void *shader_data, const void *mat_data) { math_matrix_4x4 ident; @@ -274,6 +282,7 @@ static void gl1_renderchain_set_mvp(void *data, } static void gl1_renderchain_set_coords(void *handle_data, + void *chain_data, void *shader_data, const struct video_coords *coords) { /* Fall back to fixed function-style if needed and possible. */ From 267e6fe85fb45dd53adb9d7dc4b1b672401224c4 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 4 Dec 2017 12:02:53 +0100 Subject: [PATCH 160/394] Move fence variables to renderchain data struct --- gfx/common/gl_common.h | 3 -- gfx/drivers_renderchain/gl2_renderchain.c | 37 ++++++++++++----------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/gfx/common/gl_common.h b/gfx/common/gl_common.h index 7eb88af66e..535dd15ada 100644 --- a/gfx/common/gl_common.h +++ b/gfx/common/gl_common.h @@ -38,8 +38,6 @@ RETRO_BEGIN_DECLS -#define MAX_FENCES 4 - #if defined(HAVE_PSGL) #define RARCH_GL_FRAMEBUFFER GL_FRAMEBUFFER_OES #define RARCH_GL_FRAMEBUFFER_COMPLETE GL_FRAMEBUFFER_COMPLETE_OES @@ -250,7 +248,6 @@ typedef struct gl struct video_fbo_rect fbo_rect[GFX_MAX_SHADERS]; struct gfx_fbo_scale fbo_scale[GFX_MAX_SHADERS]; - GLsync fences[MAX_FENCES]; const gl_renderchain_driver_t *renderchain_driver; void *renderchain_data; } gl_t; diff --git a/gfx/drivers_renderchain/gl2_renderchain.c b/gfx/drivers_renderchain/gl2_renderchain.c index f52f77f5e7..07934a6d52 100644 --- a/gfx/drivers_renderchain/gl2_renderchain.c +++ b/gfx/drivers_renderchain/gl2_renderchain.c @@ -51,9 +51,12 @@ #include "../../configuration.h" #include "../../verbosity.h" +#define MAX_FENCES 4 + typedef struct gl2_renderchain { - void *empty; + unsigned fence_count; + GLsync fences[MAX_FENCES]; } gl2_renderchain_t; #if (!defined(HAVE_OPENGLES) || defined(HAVE_OPENGLES3)) @@ -1144,12 +1147,12 @@ error: void gl2_renderchain_free_internal(void *data, void *chain_data) { - gl2_renderchain_t *cg_data = (gl2_renderchain_t*)chain_data; + gl2_renderchain_t *chain = (gl2_renderchain_t*)chain_data; - if (!cg_data) + if (!chain) return; - free(cg_data); + free(chain); } static void *gl2_renderchain_new(void) @@ -1399,20 +1402,20 @@ static void gl2_renderchain_fence_iterate( void *chain_data, unsigned hard_sync_frames) { - gl_t *gl = (gl_t*)data; + gl2_renderchain_t *chain = (gl2_renderchain_t*)chain_data; - gl->fences[gl->fence_count++] = + chain->fences[chain->fence_count++] = glFenceSync(GL_SYNC_GPU_COMMANDS_COMPLETE, 0); - while (gl->fence_count > hard_sync_frames) + while (chain->fence_count > hard_sync_frames) { - glClientWaitSync(gl->fences[0], + glClientWaitSync(chain->fences[0], GL_SYNC_FLUSH_COMMANDS_BIT, 1000000000); - glDeleteSync(gl->fences[0]); + glDeleteSync(chain->fences[0]); - gl->fence_count--; - memmove(gl->fences, gl->fences + 1, - gl->fence_count * sizeof(GLsync)); + chain->fence_count--; + memmove(chain->fences, chain->fences + 1, + chain->fence_count * sizeof(GLsync)); } } @@ -1420,15 +1423,15 @@ static void gl2_renderchain_fence_free(void *data, void *chain_data) { unsigned i; - gl_t *gl = (gl_t*)data; + gl2_renderchain_t *chain = (gl2_renderchain_t*)chain_data; - for (i = 0; i < gl->fence_count; i++) + for (i = 0; i < chain->fence_count; i++) { - glClientWaitSync(gl->fences[i], + glClientWaitSync(chain->fences[i], GL_SYNC_FLUSH_COMMANDS_BIT, 1000000000); - glDeleteSync(gl->fences[i]); + glDeleteSync(chain->fences[i]); } - gl->fence_count = 0; + chain->fence_count = 0; } #endif From 69d3fd5047e4c0898e4082632ee56f3c4f87a9bc Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 4 Dec 2017 12:03:29 +0100 Subject: [PATCH 161/394] Get rid of fence_count in gl struct --- gfx/common/gl_common.h | 1 - 1 file changed, 1 deletion(-) diff --git a/gfx/common/gl_common.h b/gfx/common/gl_common.h index 535dd15ada..bf0a8b3ac4 100644 --- a/gfx/common/gl_common.h +++ b/gfx/common/gl_common.h @@ -222,7 +222,6 @@ typedef struct gl unsigned base_size; /* 2 or 4 */ unsigned overlays; unsigned pbo_readback_index; - unsigned fence_count; unsigned last_width[GFX_MAX_TEXTURES]; unsigned last_height[GFX_MAX_TEXTURES]; From 19ad9aa1cb58691c8a0188260b5799e823363094 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 4 Dec 2017 12:43:22 +0100 Subject: [PATCH 162/394] Add resolve extensions callback --- gfx/drivers/gl.c | 3 +++ gfx/drivers_renderchain/gl1_renderchain.c | 7 ++++--- gfx/drivers_renderchain/gl2_renderchain.c | 6 ++++++ gfx/video_driver.h | 4 ++++ 4 files changed, 17 insertions(+), 3 deletions(-) diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 3cc6adf629..b7302756e8 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -1371,6 +1371,9 @@ static bool resolve_extensions(gl_t *gl, const char *context_ident) video_driver_unset_rgba(); + if (gl->renderchain_driver->resolve_extensions) + gl->renderchain_driver->resolve_extensions(gl, gl->renderchain_data, context_ident); + #if defined(HAVE_OPENGLES) && !defined(HAVE_PSGL) if (!gl_check_capability(GL_CAPS_BGRA8888)) { diff --git a/gfx/drivers_renderchain/gl1_renderchain.c b/gfx/drivers_renderchain/gl1_renderchain.c index a9762cf0ba..56a5d27650 100644 --- a/gfx/drivers_renderchain/gl1_renderchain.c +++ b/gfx/drivers_renderchain/gl1_renderchain.c @@ -327,10 +327,11 @@ gl_renderchain_driver_t gl2_renderchain = { NULL, /* renderchain_init */ NULL, /* init_hw_render */ gl1_renderchain_free, - NULL, /* deinit_hw_render */ - NULL, /* start_render */ + NULL, /* deinit_hw_render */ + NULL, /* start_render */ NULL, /* check_fbo_dimensions */ NULL, /* recompute_pass_sizes */ - NULL, /* renderchain_render */ + NULL, /* renderchain_render */ + NULL, /* resolve_extensions */ "gl1", }; diff --git a/gfx/drivers_renderchain/gl2_renderchain.c b/gfx/drivers_renderchain/gl2_renderchain.c index 07934a6d52..5e6d5bcad5 100644 --- a/gfx/drivers_renderchain/gl2_renderchain.c +++ b/gfx/drivers_renderchain/gl2_renderchain.c @@ -1461,6 +1461,11 @@ static void gl2_renderchain_init_textures_reference( #endif } +static void gl2_renderchain_resolve_extensions(void *data, + void *chain_data, const char *context_ident) +{ +} + gl_renderchain_driver_t gl2_renderchain = { NULL, /* set_coords */ NULL, /* set_mvp */ @@ -1513,5 +1518,6 @@ gl_renderchain_driver_t gl2_renderchain = { gl2_renderchain_check_fbo_dimensions, gl2_renderchain_recompute_pass_sizes, gl2_renderchain_render, + gl2_renderchain_resolve_extensions, "gl2", }; diff --git a/gfx/video_driver.h b/gfx/video_driver.h index 33765da5dd..1519bdc7a3 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -904,6 +904,10 @@ typedef struct gl_renderchain_driver uint64_t frame_count, const struct video_tex_info *tex_info, const struct video_tex_info *feedback_info); + void (*resolve_extensions)( + void *data, + void *chain_data, + const char *context_ident); const char *ident; } gl_renderchain_driver_t; From f47888aeda777a317f98e5125cf1e0ee7ab523df Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 4 Dec 2017 12:50:22 +0100 Subject: [PATCH 163/394] Move more variables to renderchain data --- gfx/common/gl_common.h | 3 -- gfx/drivers/gl.c | 7 ---- gfx/drivers_renderchain/gl2_renderchain.c | 42 +++++++++++++++++------ 3 files changed, 32 insertions(+), 20 deletions(-) diff --git a/gfx/common/gl_common.h b/gfx/common/gl_common.h index bf0a8b3ac4..8fe344e433 100644 --- a/gfx/common/gl_common.h +++ b/gfx/common/gl_common.h @@ -168,9 +168,6 @@ typedef struct gl bool hw_render_fbo_init; bool hw_render_depth_init; bool has_fbo; - bool has_srgb_fbo_gles3; - bool has_fp_fbo; - bool has_srgb_fbo; bool hw_render_use; bool core_context_in_use; diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index b7302756e8..262292ca93 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -1352,19 +1352,12 @@ static bool resolve_extensions(gl_t *gl, const char *context_ident) * * have_sync - Use ARB_sync to reduce latency. */ - gl->has_srgb_fbo = false; gl->has_fbo = gl_check_capability(GL_CAPS_FBO); gl->have_full_npot_support = gl_check_capability(GL_CAPS_FULL_NPOT_SUPPORT); gl->have_mipmap = gl_check_capability(GL_CAPS_MIPMAP); gl->have_es2_compat = gl_check_capability(GL_CAPS_ES2_COMPAT); - gl->has_fp_fbo = gl_check_capability(GL_CAPS_FP_FBO); gl->support_unpack_row_length = gl_check_capability(GL_CAPS_UNPACK_ROW_LENGTH); gl->have_sync = gl_check_capability(GL_CAPS_SYNC); - /* GLES3 has unpack_subimage and sRGB in core. */ - gl->has_srgb_fbo_gles3 = gl_check_capability(GL_CAPS_SRGB_FBO_ES3); - - if (!settings->bools.video_force_srgb_disable) - gl->has_srgb_fbo = gl_check_capability(GL_CAPS_SRGB_FBO); if (gl->have_sync && settings->bools.video_hard_sync) RARCH_LOG("[GL]: Using ARB_sync to reduce latency.\n"); diff --git a/gfx/drivers_renderchain/gl2_renderchain.c b/gfx/drivers_renderchain/gl2_renderchain.c index 5e6d5bcad5..97e1a36c45 100644 --- a/gfx/drivers_renderchain/gl2_renderchain.c +++ b/gfx/drivers_renderchain/gl2_renderchain.c @@ -55,6 +55,9 @@ typedef struct gl2_renderchain { + bool has_fp_fbo; + bool has_srgb_fbo_gles3; + bool has_srgb_fbo; unsigned fence_count; GLsync fences[MAX_FENCES]; } gl2_renderchain_t; @@ -296,6 +299,7 @@ static void gl2_renderchain_render( video_shader_ctx_params_t params; video_shader_ctx_info_t shader_info; gl_t *gl = (gl_t*)data; + gl2_renderchain_t *chain = (gl2_renderchain_t*)chain_data; static GLfloat fbo_tex_coords[8] = {0.0f}; struct video_tex_info fbo_tex_info[GFX_MAX_SHADERS]; struct video_tex_info *fbo_info = NULL; @@ -385,7 +389,7 @@ static void gl2_renderchain_render( } #if defined(GL_FRAMEBUFFER_SRGB) && !defined(HAVE_OPENGLES) - if (gl->has_srgb_fbo) + if (chain->has_srgb_fbo) glDisable(GL_FRAMEBUFFER_SRGB); #endif @@ -565,13 +569,15 @@ error: return false; } -static void gl_create_fbo_texture(gl_t *gl, unsigned i, GLuint texture) +static void gl_create_fbo_texture(gl_t *gl, + void *chain_data, unsigned i, GLuint texture) { GLenum mag_filter, wrap_enum; video_shader_ctx_filter_t filter_type; video_shader_ctx_wrap_t wrap = {0}; bool fp_fbo = false; bool smooth = false; + gl2_renderchain_t *chain = (gl2_renderchain_t*)chain_data; settings_t *settings = config_get_ptr(); GLuint base_filt = settings->bools.video_smooth ? GL_LINEAR : GL_NEAREST; GLuint base_mip_filt = settings->bools.video_smooth ? @@ -603,12 +609,12 @@ static void gl_create_fbo_texture(gl_t *gl, unsigned i, GLuint texture) if (fp_fbo) { - if (!gl->has_fp_fbo) + if (!chain->has_fp_fbo) RARCH_ERR("[GL]: Floating-point FBO was requested, but is not supported. Falling back to UNORM. Result may band/clip/etc.!\n"); } #if !defined(HAVE_OPENGLES2) - if (fp_fbo && gl->has_fp_fbo) + if (fp_fbo && chain->has_fp_fbo) { RARCH_LOG("[GL]: FBO pass #%d is floating-point.\n", i); gl_load_texture_image(GL_TEXTURE_2D, 0, GL_RGBA32F, @@ -623,14 +629,14 @@ static void gl_create_fbo_texture(gl_t *gl, unsigned i, GLuint texture) if (!fp_fbo && srgb_fbo) { - if (!gl->has_srgb_fbo) + if (!chain->has_srgb_fbo) RARCH_ERR("[GL]: sRGB FBO was requested, but it is not supported. Falling back to UNORM. Result may have banding!\n"); } if (settings->bools.video_force_srgb_disable) srgb_fbo = false; - if (srgb_fbo && gl->has_srgb_fbo) + if (srgb_fbo && chain->has_srgb_fbo) { RARCH_LOG("[GL]: FBO pass #%d is sRGB.\n", i); #ifdef HAVE_OPENGLES2 @@ -639,7 +645,7 @@ static void gl_create_fbo_texture(gl_t *gl, unsigned i, GLuint texture) glTexImage2D(GL_TEXTURE_2D, 0, GL_SRGB_ALPHA_EXT, gl->fbo_rect[i].width, gl->fbo_rect[i].height, 0, - gl->has_srgb_fbo_gles3 ? GL_RGBA : GL_SRGB_ALPHA_EXT, + chain->has_srgb_fbo_gles3 ? GL_RGBA : GL_SRGB_ALPHA_EXT, GL_UNSIGNED_BYTE, NULL); #else gl_load_texture_image(GL_TEXTURE_2D, @@ -674,12 +680,14 @@ static void gl_create_fbo_textures(gl_t *gl) glGenTextures(gl->fbo_pass, gl->fbo_texture); for (i = 0; i < gl->fbo_pass; i++) - gl_create_fbo_texture(gl, i, gl->fbo_texture[i]); + gl_create_fbo_texture(gl, gl->renderchain_data, + i, gl->fbo_texture[i]); if (gl->fbo_feedback_enable) { glGenTextures(1, &gl->fbo_feedback_texture); gl_create_fbo_texture(gl, + gl->renderchain_data, gl->fbo_feedback_pass, gl->fbo_feedback_texture); } @@ -767,7 +775,8 @@ static void gl2_renderchain_start_render(void *data, 0, 1, 1, 1 }; - gl_t *gl = (gl_t*)data; + gl_t *gl = (gl_t*)data; + gl2_renderchain_t *chain = (gl2_renderchain_t*)chain_data; glBindTexture(GL_TEXTURE_2D, gl->texture[gl->tex_index]); gl2_bind_fb(gl->fbo[0]); @@ -783,7 +792,7 @@ static void gl2_renderchain_start_render(void *data, gl->coords.vertex = fbo_vertexes; #if defined(GL_FRAMEBUFFER_SRGB) && !defined(HAVE_OPENGLES) - if (gl->has_srgb_fbo) + if (chain->has_srgb_fbo) glEnable(GL_FRAMEBUFFER_SRGB); #endif } @@ -1464,6 +1473,19 @@ static void gl2_renderchain_init_textures_reference( static void gl2_renderchain_resolve_extensions(void *data, void *chain_data, const char *context_ident) { + gl2_renderchain_t *chain = (gl2_renderchain_t*)chain_data; + settings_t *settings = config_get_ptr(); + + if (!chain) + return; + + chain->has_srgb_fbo = false; + chain->has_fp_fbo = gl_check_capability(GL_CAPS_FP_FBO); + /* GLES3 has unpack_subimage and sRGB in core. */ + chain->has_srgb_fbo_gles3 = gl_check_capability(GL_CAPS_SRGB_FBO_ES3); + + if (!settings->bools.video_force_srgb_disable) + chain->has_srgb_fbo = gl_check_capability(GL_CAPS_SRGB_FBO); } gl_renderchain_driver_t gl2_renderchain = { From 48c3a509320031a91a7de1bec2a358f972b9e33d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 4 Dec 2017 13:03:14 +0100 Subject: [PATCH 164/394] Move more variables --- gfx/common/gl_common.h | 1 - gfx/drivers/gl.c | 18 ++++++------------ gfx/drivers_renderchain/gl2_renderchain.c | 16 ++++++++++++---- gfx/video_driver.h | 3 ++- 4 files changed, 20 insertions(+), 18 deletions(-) diff --git a/gfx/common/gl_common.h b/gfx/common/gl_common.h index 8fe344e433..db94c1a268 100644 --- a/gfx/common/gl_common.h +++ b/gfx/common/gl_common.h @@ -180,7 +180,6 @@ typedef struct gl bool have_full_npot_support; bool have_mipmap; - bool egl_images; bool overlay_enable; bool overlay_full_screen; bool menu_texture_enable; diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 262292ca93..c717513f74 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -544,11 +544,9 @@ static void gl_init_textures_data(gl_t *gl) static void gl_init_textures(gl_t *gl, const video_info_t *video) { unsigned i; - GLenum internal_fmt, texture_type = 0, texture_fmt = 0; - - /* Use regular textures if we use HW render. */ - gl->egl_images = !gl->hw_render_use && gl_check_capability(GL_CAPS_EGLIMAGE) && - video_context_driver_init_image_buffer(video); + GLenum internal_fmt = gl->internal_fmt; + GLenum texture_type = gl->texture_type; + GLenum texture_fmt = gl->texture_fmt; #ifdef HAVE_PSGL if (!gl->pbo) @@ -560,10 +558,6 @@ static void gl_init_textures(gl_t *gl, const video_info_t *video) NULL, GL_STREAM_DRAW); #endif - internal_fmt = gl->internal_fmt; - texture_type = gl->texture_type; - texture_fmt = gl->texture_fmt; - #if defined(HAVE_OPENGLES) && !defined(HAVE_PSGL) /* GLES is picky about which format we use here. * Without extensions, we can *only* render to 16-bit FBOs. */ @@ -1339,7 +1333,7 @@ static void gl_set_nonblock_state(void *data, bool state) context_bind_hw_render(true); } -static bool resolve_extensions(gl_t *gl, const char *context_ident) +static bool resolve_extensions(gl_t *gl, const char *context_ident, const video_info_t *video) { settings_t *settings = config_get_ptr(); @@ -1365,7 +1359,7 @@ static bool resolve_extensions(gl_t *gl, const char *context_ident) video_driver_unset_rgba(); if (gl->renderchain_driver->resolve_extensions) - gl->renderchain_driver->resolve_extensions(gl, gl->renderchain_data, context_ident); + gl->renderchain_driver->resolve_extensions(gl, gl->renderchain_data, context_ident, video); #if defined(HAVE_OPENGLES) && !defined(HAVE_PSGL) if (!gl_check_capability(GL_CAPS_BGRA8888)) @@ -1790,7 +1784,7 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); glBlendEquation(GL_FUNC_ADD); - if (!resolve_extensions(gl, ctx_driver->ident)) + if (!resolve_extensions(gl, ctx_driver->ident, video)) goto error; #ifdef GL_DEBUG diff --git a/gfx/drivers_renderchain/gl2_renderchain.c b/gfx/drivers_renderchain/gl2_renderchain.c index 97e1a36c45..3ed9b0eb1e 100644 --- a/gfx/drivers_renderchain/gl2_renderchain.c +++ b/gfx/drivers_renderchain/gl2_renderchain.c @@ -55,6 +55,7 @@ typedef struct gl2_renderchain { + bool egl_images; bool has_fp_fbo; bool has_srgb_fbo_gles3; bool has_srgb_fbo; @@ -1253,7 +1254,7 @@ static void gl2_renderchain_copy_frame( } #elif defined(HAVE_OPENGLES) #if defined(HAVE_EGL) - if (gl->egl_images) + if (chain->egl_images) { gfx_ctx_image_t img_info; bool new_egl = false; @@ -1449,7 +1450,8 @@ static void gl2_renderchain_init_textures_reference( unsigned internal_fmt, unsigned texture_fmt, unsigned texture_type) { - gl_t *gl = (gl_t*)data; + gl_t *gl = (gl_t*)data; + gl2_renderchain_t *chain = (gl2_renderchain_t*)chain_data; #ifdef HAVE_PSGL glTextureReferenceSCE(GL_TEXTURE_2D, 1, gl->tex_w, gl->tex_h, 0, @@ -1457,7 +1459,7 @@ static void gl2_renderchain_init_textures_reference( gl->tex_w * gl->base_size, gl->tex_w * gl->tex_h * i * gl->base_size); #else - if (gl->egl_images) + if (chain->egl_images) return; gl_load_texture_image(GL_TEXTURE_2D, @@ -1471,8 +1473,10 @@ static void gl2_renderchain_init_textures_reference( } static void gl2_renderchain_resolve_extensions(void *data, - void *chain_data, const char *context_ident) + void *chain_data, const char *context_ident, + const video_info_t *video) { + gl_t *gl = (gl_t*)data; gl2_renderchain_t *chain = (gl2_renderchain_t*)chain_data; settings_t *settings = config_get_ptr(); @@ -1486,6 +1490,10 @@ static void gl2_renderchain_resolve_extensions(void *data, if (!settings->bools.video_force_srgb_disable) chain->has_srgb_fbo = gl_check_capability(GL_CAPS_SRGB_FBO); + + /* Use regular textures if we use HW render. */ + chain->egl_images = !gl->hw_render_use && gl_check_capability(GL_CAPS_EGLIMAGE) && + video_context_driver_init_image_buffer(video); } gl_renderchain_driver_t gl2_renderchain = { diff --git a/gfx/video_driver.h b/gfx/video_driver.h index 1519bdc7a3..43bbef97ca 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -907,7 +907,8 @@ typedef struct gl_renderchain_driver void (*resolve_extensions)( void *data, void *chain_data, - const char *context_ident); + const char *context_ident, + const video_info_t *video); const char *ident; } gl_renderchain_driver_t; From 9a8f73fb6cd472a7e5204464347344ba815d4df0 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 4 Dec 2017 13:18:34 +0100 Subject: [PATCH 165/394] Move variables --- gfx/common/gl_common.h | 5 - gfx/drivers_renderchain/gl2_renderchain.c | 152 +++++++++++++--------- 2 files changed, 88 insertions(+), 69 deletions(-) diff --git a/gfx/common/gl_common.h b/gfx/common/gl_common.h index db94c1a268..c413d653c0 100644 --- a/gfx/common/gl_common.h +++ b/gfx/common/gl_common.h @@ -166,7 +166,6 @@ typedef struct gl bool fbo_inited; bool fbo_feedback_enable; bool hw_render_fbo_init; - bool hw_render_depth_init; bool has_fbo; bool hw_render_use; bool core_context_in_use; @@ -190,7 +189,6 @@ typedef struct gl int version_major; int version_minor; - int fbo_pass; GLuint tex_mag_filter; GLuint tex_min_filter; @@ -199,13 +197,10 @@ typedef struct gl GLuint pbo; GLuint *overlay_tex; GLuint menu_texture; - GLuint vao; GLuint pbo_readback[4]; GLuint texture[GFX_MAX_TEXTURES]; GLuint fbo[GFX_MAX_SHADERS]; - GLuint fbo_texture[GFX_MAX_SHADERS]; GLuint hw_render_fbo[GFX_MAX_TEXTURES]; - GLuint hw_render_depth[GFX_MAX_TEXTURES]; unsigned tex_index; /* For use with PREV. */ unsigned textures; diff --git a/gfx/drivers_renderchain/gl2_renderchain.c b/gfx/drivers_renderchain/gl2_renderchain.c index 3ed9b0eb1e..0b0eff8ff3 100644 --- a/gfx/drivers_renderchain/gl2_renderchain.c +++ b/gfx/drivers_renderchain/gl2_renderchain.c @@ -59,7 +59,16 @@ typedef struct gl2_renderchain bool has_fp_fbo; bool has_srgb_fbo_gles3; bool has_srgb_fbo; + bool hw_render_depth_init; + + int fbo_pass; + + GLuint vao; + GLuint fbo_texture[GFX_MAX_SHADERS]; + GLuint hw_render_depth[GFX_MAX_TEXTURES]; + unsigned fence_count; + GLsync fences[MAX_FENCES]; } gl2_renderchain_t; @@ -228,12 +237,15 @@ static bool gl_recreate_fbo( return false; } -static void gl_check_fbo_dimension(gl_t *gl, unsigned i, +static void gl_check_fbo_dimension(gl_t *gl, + void *chain_data, + unsigned i, bool update_feedback) { struct video_fbo_rect *fbo_rect = &gl->fbo_rect[i]; /* Check proactively since we might suddently * get sizes of tex_w width or tex_h height. */ + gl2_renderchain_t *chain = (gl2_renderchain_t*)chain_data; unsigned img_width = fbo_rect->max_img_width; unsigned img_height = fbo_rect->max_img_height; unsigned max = img_width > img_height ? img_width : img_height; @@ -242,7 +254,7 @@ static void gl_check_fbo_dimension(gl_t *gl, unsigned i, fbo_rect->width = pow2_size; fbo_rect->height = pow2_size; - gl_recreate_fbo(fbo_rect, gl->fbo[i], &gl->fbo_texture[i]); + gl_recreate_fbo(fbo_rect, gl->fbo[i], &chain->fbo_texture[i]); /* Update feedback texture in-place so we avoid having to * juggle two different fbo_rect structs since they get updated here. */ @@ -269,10 +281,11 @@ static void gl2_renderchain_check_fbo_dimensions(void *data, void *chain_data) { int i; - gl_t *gl = (gl_t*)data; + gl_t *gl = (gl_t*)data; + gl2_renderchain_t *chain = (gl2_renderchain_t*)chain_data; /* Check if we have to recreate our FBO textures. */ - for (i = 0; i < gl->fbo_pass; i++) + for (i = 0; i < chain->fbo_pass; i++) { struct video_fbo_rect *fbo_rect = &gl->fbo_rect[i]; if (fbo_rect) @@ -282,7 +295,7 @@ static void gl2_renderchain_check_fbo_dimensions(void *data, if ((fbo_rect->max_img_width > fbo_rect->width) || (fbo_rect->max_img_height > fbo_rect->height)) - gl_check_fbo_dimension(gl, i, update_feedback); + gl_check_fbo_dimension(gl, chain_data, i, update_feedback); } } } @@ -317,7 +330,7 @@ static void gl2_renderchain_render( /* Calculate viewports, texture coordinates etc, * and render all passes from FBOs, to another FBO. */ - for (i = 1; i < gl->fbo_pass; i++) + for (i = 1; i < chain->fbo_pass; i++) { video_shader_ctx_coords_t coords; video_shader_ctx_params_t params; @@ -331,7 +344,7 @@ static void gl2_renderchain_render( set_texture_coords(fbo_tex_coords, xamt, yamt); - fbo_info->tex = gl->fbo_texture[i - 1]; + fbo_info->tex = chain->fbo_texture[i - 1]; fbo_info->input_size[0] = prev_rect->img_width; fbo_info->input_size[1] = prev_rect->img_height; fbo_info->tex_size[0] = prev_rect->width; @@ -346,7 +359,7 @@ static void gl2_renderchain_render( shader_info.set_active = true; video_shader_driver_use(shader_info); - glBindTexture(GL_TEXTURE_2D, gl->fbo_texture[i - 1]); + glBindTexture(GL_TEXTURE_2D, chain->fbo_texture[i - 1]); mip_level = i + 1; @@ -395,16 +408,16 @@ static void gl2_renderchain_render( #endif /* Render our last FBO texture directly to screen. */ - prev_rect = &gl->fbo_rect[gl->fbo_pass - 1]; + prev_rect = &gl->fbo_rect[chain->fbo_pass - 1]; xamt = (GLfloat)prev_rect->img_width / prev_rect->width; yamt = (GLfloat)prev_rect->img_height / prev_rect->height; set_texture_coords(fbo_tex_coords, xamt, yamt); /* Push final FBO to list. */ - fbo_info = &fbo_tex_info[gl->fbo_pass - 1]; + fbo_info = &fbo_tex_info[chain->fbo_pass - 1]; - fbo_info->tex = gl->fbo_texture[gl->fbo_pass - 1]; + fbo_info->tex = chain->fbo_texture[chain->fbo_pass - 1]; fbo_info->input_size[0] = prev_rect->img_width; fbo_info->input_size[1] = prev_rect->img_height; fbo_info->tex_size[0] = prev_rect->width; @@ -416,14 +429,14 @@ static void gl2_renderchain_render( gl2_renderchain_bind_backbuffer(gl, chain_data); shader_info.data = gl; - shader_info.idx = gl->fbo_pass + 1; + shader_info.idx = chain->fbo_pass + 1; shader_info.set_active = true; video_shader_driver_use(shader_info); - glBindTexture(GL_TEXTURE_2D, gl->fbo_texture[gl->fbo_pass - 1]); + glBindTexture(GL_TEXTURE_2D, chain->fbo_texture[chain->fbo_pass - 1]); - mip_level = gl->fbo_pass + 1; + mip_level = chain->fbo_pass + 1; if (video_shader_driver_mipmap_input(&mip_level) && gl->have_mipmap) @@ -469,15 +482,16 @@ static void gl2_renderchain_render( static void gl2_renderchain_deinit_fbo(void *data, void *chain_data) { - gl_t *gl = (gl_t*)data; + gl_t *gl = (gl_t*)data; + gl2_renderchain_t *chain = (gl2_renderchain_t*)chain_data; if (!gl) return; - glDeleteTextures(gl->fbo_pass, gl->fbo_texture); - gl2_delete_fb(gl->fbo_pass, gl->fbo); + glDeleteTextures(chain->fbo_pass, chain->fbo_texture); + gl2_delete_fb(chain->fbo_pass, gl->fbo); - memset(gl->fbo_texture, 0, sizeof(gl->fbo_texture)); + memset(chain->fbo_texture, 0, sizeof(chain->fbo_texture)); memset(gl->fbo, 0, sizeof(gl->fbo)); if (gl->fbo_feedback) @@ -485,9 +499,10 @@ static void gl2_renderchain_deinit_fbo(void *data, if (gl->fbo_feedback_texture) glDeleteTextures(1, &gl->fbo_feedback_texture); + chain->fbo_pass = 0; + gl->fbo_inited = false; gl->fbo_feedback_enable = false; - gl->fbo_pass = 0; gl->fbo_feedback_pass = 0; gl->fbo_feedback_texture = 0; gl->fbo_feedback = 0; @@ -497,7 +512,8 @@ static void gl2_renderchain_deinit_hw_render( void *data, void *chain_data) { - gl_t *gl = (gl_t*)data; + gl_t *gl = (gl_t*)data; + gl2_renderchain_t *chain = (gl2_renderchain_t*)chain_data; if (!gl) return; @@ -505,8 +521,8 @@ static void gl2_renderchain_deinit_hw_render( if (gl->hw_render_fbo_init) gl2_delete_fb(gl->textures, gl->hw_render_fbo); - if (gl->hw_render_depth_init) - gl2_delete_rb(gl->textures, gl->hw_render_depth); + if (chain->hw_render_depth_init) + gl2_delete_rb(gl->textures, chain->hw_render_depth); gl->hw_render_fbo_init = false; context_bind_hw_render(false); @@ -520,20 +536,21 @@ static void gl2_renderchain_free(void *data, void *chain_data) gl2_renderchain_deinit_hw_render(gl, chain_data); } -static bool gl_create_fbo_targets(gl_t *gl) +static bool gl_create_fbo_targets(gl_t *gl, void *chain_data) { int i; + gl2_renderchain_t *chain = (gl2_renderchain_t*)chain_data; glBindTexture(GL_TEXTURE_2D, 0); - gl2_gen_fb(gl->fbo_pass, gl->fbo); + gl2_gen_fb(chain->fbo_pass, gl->fbo); - for (i = 0; i < gl->fbo_pass; i++) + for (i = 0; i < chain->fbo_pass; i++) { GLenum status; gl2_bind_fb(gl->fbo[i]); gl2_fb_texture_2d(RARCH_GL_FRAMEBUFFER, - RARCH_GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, gl->fbo_texture[i], 0); + RARCH_GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, chain->fbo_texture[i], 0); status = gl2_check_fb_status(RARCH_GL_FRAMEBUFFER); if (status != RARCH_GL_FRAMEBUFFER_COMPLETE) @@ -563,7 +580,7 @@ static bool gl_create_fbo_targets(gl_t *gl) return true; error: - gl2_delete_fb(gl->fbo_pass, gl->fbo); + gl2_delete_fb(chain->fbo_pass, gl->fbo); if (gl->fbo_feedback) gl2_delete_fb(1, &gl->fbo_feedback); RARCH_ERR("[GL]: Failed to set up frame buffer objects. Multi-pass shading will not work.\n"); @@ -675,14 +692,16 @@ static void gl_create_fbo_texture(gl_t *gl, } } -static void gl_create_fbo_textures(gl_t *gl) +static void gl_create_fbo_textures(gl_t *gl, void *chain_data) { int i; - glGenTextures(gl->fbo_pass, gl->fbo_texture); + gl2_renderchain_t *chain = (gl2_renderchain_t*)chain_data; - for (i = 0; i < gl->fbo_pass; i++) + glGenTextures(chain->fbo_pass, chain->fbo_texture); + + for (i = 0; i < chain->fbo_pass; i++) gl_create_fbo_texture(gl, gl->renderchain_data, - i, gl->fbo_texture[i]); + i, chain->fbo_texture[i]); if (gl->fbo_feedback_enable) { @@ -707,6 +726,7 @@ static void gl2_renderchain_recompute_pass_sizes( { int i; gl_t *gl = (gl_t*)data; + gl2_renderchain_t *chain = (gl2_renderchain_t*)chain_data; bool size_modified = false; GLint max_size = 0; unsigned last_width = width; @@ -717,7 +737,7 @@ static void gl2_renderchain_recompute_pass_sizes( glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max_size); /* Calculate viewports for FBOs. */ - for (i = 0; i < gl->fbo_pass; i++) + for (i = 0; i < chain->fbo_pass; i++) { struct video_fbo_rect *fbo_rect = &gl->fbo_rect[i]; struct gfx_fbo_scale *fbo_scale = &gl->fbo_scale[i]; @@ -808,7 +828,8 @@ void gl2_renderchain_init( video_shader_ctx_scale_t scaler; video_shader_ctx_info_t shader_info; struct gfx_fbo_scale scale, scale_last; - gl_t *gl = (gl_t*)data; + gl_t *gl = (gl_t*)data; + gl2_renderchain_t *chain = (gl2_renderchain_t*)chain_data; if (!video_shader_driver_info(&shader_info)) return; @@ -838,9 +859,9 @@ void gl2_renderchain_init( return; } - gl->fbo_pass = shader_info.num - 1; + chain->fbo_pass = shader_info.num - 1; if (scale_last.valid) - gl->fbo_pass++; + chain->fbo_pass++; if (!scale.valid) { @@ -852,7 +873,7 @@ void gl2_renderchain_init( gl->fbo_scale[0] = scale; - for (i = 1; i < gl->fbo_pass; i++) + for (i = 1; i < chain->fbo_pass; i++) { scaler.idx = i + 1; scaler.scale = &gl->fbo_scale[i]; @@ -872,7 +893,7 @@ void gl2_renderchain_init( chain_data, fbo_width, fbo_height, width, height); - for (i = 0; i < gl->fbo_pass; i++) + for (i = 0; i < chain->fbo_pass; i++) { gl->fbo_rect[i].width = next_pow2(gl->fbo_rect[i].img_width); gl->fbo_rect[i].height = next_pow2(gl->fbo_rect[i].img_height); @@ -884,7 +905,7 @@ void gl2_renderchain_init( &gl->fbo_feedback_pass); if (gl->fbo_feedback_enable && gl->fbo_feedback_pass - < (unsigned)gl->fbo_pass) + < (unsigned)chain->fbo_pass) { RARCH_LOG("[GL]: Creating feedback FBO %d @ %ux%u\n", i, gl->fbo_rect[gl->fbo_feedback_pass].width, @@ -893,14 +914,14 @@ void gl2_renderchain_init( else if (gl->fbo_feedback_enable) { RARCH_WARN("[GL]: Tried to create feedback FBO of pass #%u, but there are only %d FBO passes. Will use input texture as feedback texture.\n", - gl->fbo_feedback_pass, gl->fbo_pass); + gl->fbo_feedback_pass, chain->fbo_pass); gl->fbo_feedback_enable = false; } - gl_create_fbo_textures(gl); - if (!gl || !gl_create_fbo_targets(gl)) + gl_create_fbo_textures(gl, chain); + if (!gl || !gl_create_fbo_targets(gl, chain)) { - glDeleteTextures(gl->fbo_pass, gl->fbo_texture); + glDeleteTextures(chain->fbo_pass, chain->fbo_texture); RARCH_ERR("[GL]: Failed to create FBO targets. Will continue without FBO.\n"); return; } @@ -922,6 +943,7 @@ static bool gl2_renderchain_init_hw_render( struct retro_hw_render_callback *hwr = video_driver_get_hw_context(); gl_t *gl = (gl_t*)data; + gl2_renderchain_t *chain = (gl2_renderchain_t*)chain_data; /* We can only share texture objects through contexts. * FBOs are "abstract" objects and are not shared. */ @@ -946,8 +968,8 @@ static bool gl2_renderchain_init_hw_render( if (depth) { - gl2_gen_rb(gl->textures, gl->hw_render_depth); - gl->hw_render_depth_init = true; + gl2_gen_rb(gl->textures, chain->hw_render_depth); + chain->hw_render_depth_init = true; } for (i = 0; i < gl->textures; i++) @@ -958,7 +980,7 @@ static bool gl2_renderchain_init_hw_render( if (depth) { - gl2_bind_rb(RARCH_GL_RENDERBUFFER, gl->hw_render_depth[i]); + gl2_bind_rb(RARCH_GL_RENDERBUFFER, chain->hw_render_depth[i]); gl2_rb_storage(RARCH_GL_RENDERBUFFER, stencil ? RARCH_GL_DEPTH24_STENCIL8 : GL_DEPTH_COMPONENT16, width, height); @@ -971,22 +993,26 @@ static bool gl2_renderchain_init_hw_render( * There's no GL_DEPTH_STENCIL_ATTACHMENT like in desktop GL. */ gl2_fb_rb(RARCH_GL_FRAMEBUFFER, RARCH_GL_DEPTH_ATTACHMENT, - RARCH_GL_RENDERBUFFER, gl->hw_render_depth[i]); + RARCH_GL_RENDERBUFFER, + chain->hw_render_depth[i]); gl2_fb_rb(RARCH_GL_FRAMEBUFFER, RARCH_GL_STENCIL_ATTACHMENT, - RARCH_GL_RENDERBUFFER, gl->hw_render_depth[i]); + RARCH_GL_RENDERBUFFER, + chain->hw_render_depth[i]); #else /* We use ARB FBO extensions, no need to check. */ gl2_fb_rb(RARCH_GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, - RARCH_GL_RENDERBUFFER, gl->hw_render_depth[i]); + RARCH_GL_RENDERBUFFER, + chain->hw_render_depth[i]); #endif } else { gl2_fb_rb(RARCH_GL_FRAMEBUFFER, RARCH_GL_DEPTH_ATTACHMENT, - RARCH_GL_RENDERBUFFER, gl->hw_render_depth[i]); + RARCH_GL_RENDERBUFFER, + chain->hw_render_depth[i]); } } @@ -1011,7 +1037,8 @@ static void gl2_renderchain_bind_prev_texture( void *chain_data, const struct video_tex_info *tex_info) { - gl_t *gl = (gl_t*)data; + gl_t *gl = (gl_t*)data; + gl2_renderchain_t *chain = (gl2_renderchain_t*)chain_data; memmove(gl->prev_info + 1, gl->prev_info, sizeof(*tex_info) * (gl->textures - 1)); @@ -1025,9 +1052,9 @@ static void gl2_renderchain_bind_prev_texture( GLuint tmp_fbo = gl->fbo_feedback; GLuint tmp_tex = gl->fbo_feedback_texture; gl->fbo_feedback = gl->fbo[gl->fbo_feedback_pass]; - gl->fbo_feedback_texture = gl->fbo_texture[gl->fbo_feedback_pass]; + gl->fbo_feedback_texture = chain->fbo_texture[gl->fbo_feedback_pass]; gl->fbo[gl->fbo_feedback_pass] = tmp_fbo; - gl->fbo_texture[gl->fbo_feedback_pass] = tmp_tex; + chain->fbo_texture[gl->fbo_feedback_pass] = tmp_tex; } } @@ -1178,37 +1205,34 @@ static void *gl2_renderchain_new(void) static void gl2_renderchain_bind_vao(void *data, void *chain_data) { - gl_t *gl = (gl_t*)data; - if (!gl) + gl2_renderchain_t *chain = (gl2_renderchain_t*)chain_data; + if (!chain) return; - glBindVertexArray(gl->vao); + glBindVertexArray(chain->vao); } static void gl2_renderchain_unbind_vao(void *data, void *chain_data) { - gl_t *gl = (gl_t*)data; - if (!gl) - return; glBindVertexArray(0); } static void gl2_renderchain_new_vao(void *data, void *chain_data) { - gl_t *gl = (gl_t*)data; - if (!gl) + gl2_renderchain_t *chain = (gl2_renderchain_t*)chain_data; + if (!chain) return; - glGenVertexArrays(1, &gl->vao); + glGenVertexArrays(1, &chain->vao); } static void gl2_renderchain_free_vao(void *data, void *chain_data) { - gl_t *gl = (gl_t*)data; - if (!gl) + gl2_renderchain_t *chain = (gl2_renderchain_t*)chain_data; + if (!chain) return; - glDeleteVertexArrays(1, &gl->vao); + glDeleteVertexArrays(1, &chain->vao); } #endif From 2fd720bcb349043ae973ff4788deb8f0badb458b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 4 Dec 2017 13:21:23 +0100 Subject: [PATCH 166/394] move more variables over --- gfx/common/gl_common.h | 1 - gfx/drivers_renderchain/gl2_renderchain.c | 20 +++++++++++--------- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/gfx/common/gl_common.h b/gfx/common/gl_common.h index c413d653c0..48458363c3 100644 --- a/gfx/common/gl_common.h +++ b/gfx/common/gl_common.h @@ -236,7 +236,6 @@ typedef struct gl video_info_t video_info; struct video_tex_info prev_info[GFX_MAX_TEXTURES]; struct video_fbo_rect fbo_rect[GFX_MAX_SHADERS]; - struct gfx_fbo_scale fbo_scale[GFX_MAX_SHADERS]; const gl_renderchain_driver_t *renderchain_driver; void *renderchain_data; diff --git a/gfx/drivers_renderchain/gl2_renderchain.c b/gfx/drivers_renderchain/gl2_renderchain.c index 0b0eff8ff3..972d93844c 100644 --- a/gfx/drivers_renderchain/gl2_renderchain.c +++ b/gfx/drivers_renderchain/gl2_renderchain.c @@ -70,6 +70,8 @@ typedef struct gl2_renderchain unsigned fence_count; GLsync fences[MAX_FENCES]; + + struct gfx_fbo_scale fbo_scale[GFX_MAX_SHADERS]; } gl2_renderchain_t; #if (!defined(HAVE_OPENGLES) || defined(HAVE_OPENGLES3)) @@ -623,7 +625,7 @@ static void gl_create_fbo_texture(gl_t *gl, gl_bind_texture(texture, wrap_enum, mag_filter, min_filter); - fp_fbo = gl->fbo_scale[i].fp_fbo; + fp_fbo = chain->fbo_scale[i].fp_fbo; if (fp_fbo) { @@ -643,7 +645,7 @@ static void gl_create_fbo_texture(gl_t *gl, #endif { #ifndef HAVE_OPENGLES - bool srgb_fbo = gl->fbo_scale[i].srgb_fbo; + bool srgb_fbo = chain->fbo_scale[i].srgb_fbo; if (!fp_fbo && srgb_fbo) { @@ -740,7 +742,7 @@ static void gl2_renderchain_recompute_pass_sizes( for (i = 0; i < chain->fbo_pass; i++) { struct video_fbo_rect *fbo_rect = &gl->fbo_rect[i]; - struct gfx_fbo_scale *fbo_scale = &gl->fbo_scale[i]; + struct gfx_fbo_scale *fbo_scale = &chain->fbo_scale[i]; gl2_renderchain_convert_geometry( gl, fbo_rect, fbo_scale, @@ -871,21 +873,21 @@ void gl2_renderchain_init( scale.valid = true; } - gl->fbo_scale[0] = scale; + chain->fbo_scale[0] = scale; for (i = 1; i < chain->fbo_pass; i++) { scaler.idx = i + 1; - scaler.scale = &gl->fbo_scale[i]; + scaler.scale = &chain->fbo_scale[i]; video_shader_driver_scale(&scaler); - if (!gl->fbo_scale[i].valid) + if (!chain->fbo_scale[i].valid) { - gl->fbo_scale[i].scale_x = gl->fbo_scale[i].scale_y = 1.0f; - gl->fbo_scale[i].type_x = gl->fbo_scale[i].type_y = + chain->fbo_scale[i].scale_x = chain->fbo_scale[i].scale_y = 1.0f; + chain->fbo_scale[i].type_x = chain->fbo_scale[i].type_y = RARCH_SCALE_INPUT; - gl->fbo_scale[i].valid = true; + chain->fbo_scale[i].valid = true; } } From f08b04952004397f51478184b5c3b63de314340e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 4 Dec 2017 13:24:27 +0100 Subject: [PATCH 167/394] Move more variables --- gfx/common/gl_common.h | 1 - gfx/drivers_renderchain/gl2_renderchain.c | 21 +++++++++++---------- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/gfx/common/gl_common.h b/gfx/common/gl_common.h index 48458363c3..7fb5527dcf 100644 --- a/gfx/common/gl_common.h +++ b/gfx/common/gl_common.h @@ -199,7 +199,6 @@ typedef struct gl GLuint menu_texture; GLuint pbo_readback[4]; GLuint texture[GFX_MAX_TEXTURES]; - GLuint fbo[GFX_MAX_SHADERS]; GLuint hw_render_fbo[GFX_MAX_TEXTURES]; unsigned tex_index; /* For use with PREV. */ diff --git a/gfx/drivers_renderchain/gl2_renderchain.c b/gfx/drivers_renderchain/gl2_renderchain.c index 972d93844c..a74e0d6637 100644 --- a/gfx/drivers_renderchain/gl2_renderchain.c +++ b/gfx/drivers_renderchain/gl2_renderchain.c @@ -64,6 +64,7 @@ typedef struct gl2_renderchain int fbo_pass; GLuint vao; + GLuint fbo[GFX_MAX_SHADERS]; GLuint fbo_texture[GFX_MAX_SHADERS]; GLuint hw_render_depth[GFX_MAX_TEXTURES]; @@ -256,7 +257,7 @@ static void gl_check_fbo_dimension(gl_t *gl, fbo_rect->width = pow2_size; fbo_rect->height = pow2_size; - gl_recreate_fbo(fbo_rect, gl->fbo[i], &chain->fbo_texture[i]); + gl_recreate_fbo(fbo_rect, chain->fbo[i], &chain->fbo_texture[i]); /* Update feedback texture in-place so we avoid having to * juggle two different fbo_rect structs since they get updated here. */ @@ -354,7 +355,7 @@ static void gl2_renderchain_render( memcpy(fbo_info->coord, fbo_tex_coords, sizeof(fbo_tex_coords)); fbo_tex_info_cnt++; - gl2_bind_fb(gl->fbo[i]); + gl2_bind_fb(chain->fbo[i]); shader_info.data = gl; shader_info.idx = i + 1; @@ -491,10 +492,10 @@ static void gl2_renderchain_deinit_fbo(void *data, return; glDeleteTextures(chain->fbo_pass, chain->fbo_texture); - gl2_delete_fb(chain->fbo_pass, gl->fbo); + gl2_delete_fb(chain->fbo_pass, chain->fbo); memset(chain->fbo_texture, 0, sizeof(chain->fbo_texture)); - memset(gl->fbo, 0, sizeof(gl->fbo)); + memset(chain->fbo, 0, sizeof(chain->fbo)); if (gl->fbo_feedback) gl2_delete_fb(1, &gl->fbo_feedback); @@ -544,13 +545,13 @@ static bool gl_create_fbo_targets(gl_t *gl, void *chain_data) gl2_renderchain_t *chain = (gl2_renderchain_t*)chain_data; glBindTexture(GL_TEXTURE_2D, 0); - gl2_gen_fb(chain->fbo_pass, gl->fbo); + gl2_gen_fb(chain->fbo_pass, chain->fbo); for (i = 0; i < chain->fbo_pass; i++) { GLenum status; - gl2_bind_fb(gl->fbo[i]); + gl2_bind_fb(chain->fbo[i]); gl2_fb_texture_2d(RARCH_GL_FRAMEBUFFER, RARCH_GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, chain->fbo_texture[i], 0); @@ -582,7 +583,7 @@ static bool gl_create_fbo_targets(gl_t *gl, void *chain_data) return true; error: - gl2_delete_fb(chain->fbo_pass, gl->fbo); + gl2_delete_fb(chain->fbo_pass, chain->fbo); if (gl->fbo_feedback) gl2_delete_fb(1, &gl->fbo_feedback); RARCH_ERR("[GL]: Failed to set up frame buffer objects. Multi-pass shading will not work.\n"); @@ -802,7 +803,7 @@ static void gl2_renderchain_start_render(void *data, gl2_renderchain_t *chain = (gl2_renderchain_t*)chain_data; glBindTexture(GL_TEXTURE_2D, gl->texture[gl->tex_index]); - gl2_bind_fb(gl->fbo[0]); + gl2_bind_fb(chain->fbo[0]); gl_set_viewport(gl, video_info, gl->fbo_rect[0].img_width, @@ -1053,9 +1054,9 @@ static void gl2_renderchain_bind_prev_texture( { GLuint tmp_fbo = gl->fbo_feedback; GLuint tmp_tex = gl->fbo_feedback_texture; - gl->fbo_feedback = gl->fbo[gl->fbo_feedback_pass]; + gl->fbo_feedback = chain->fbo[gl->fbo_feedback_pass]; gl->fbo_feedback_texture = chain->fbo_texture[gl->fbo_feedback_pass]; - gl->fbo[gl->fbo_feedback_pass] = tmp_fbo; + chain->fbo[gl->fbo_feedback_pass] = tmp_fbo; chain->fbo_texture[gl->fbo_feedback_pass] = tmp_tex; } } From 50148c03e27083af64f194ab32595566b9442718 Mon Sep 17 00:00:00 2001 From: Alcaro Date: Mon, 4 Dec 2017 13:27:05 +0100 Subject: [PATCH 168/394] not used anymore https://github.com/libretro/RetroArch/commit/4e66962ba83941b85b206778828596c6ad20be33 --- libretro-common/include/streams/file_stream.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libretro-common/include/streams/file_stream.h b/libretro-common/include/streams/file_stream.h index e6d6bbca1c..c57731d76a 100644 --- a/libretro-common/include/streams/file_stream.h +++ b/libretro-common/include/streams/file_stream.h @@ -63,10 +63,9 @@ const char *filestream_get_ext(RFILE *stream); * @bufsize : optional buffer size (-1 or 0 to use default) * * Opens a file for reading or writing, depending on the requested mode. - * If bufsize is > 0 for unbuffered modes (like RFILE_MODE_WRITE), file will instead be fully buffered. * Returns a pointer to an RFILE if opened successfully, otherwise NULL. **/ -RFILE *filestream_open(const char *path, unsigned mode, ssize_t bufsize); +RFILE *filestream_open(const char *path, unsigned mode, ssize_t unused); ssize_t filestream_seek(RFILE *stream, ssize_t offset, int whence); From 89f7afdc8f28a3e28f6a14c707671ea62f44bfb3 Mon Sep 17 00:00:00 2001 From: Alcaro Date: Mon, 4 Dec 2017 13:28:38 +0100 Subject: [PATCH 169/394] silence warning --- libretro-common/streams/file_stream.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libretro-common/streams/file_stream.c b/libretro-common/streams/file_stream.c index c4dcddf0a7..ff742674b7 100644 --- a/libretro-common/streams/file_stream.c +++ b/libretro-common/streams/file_stream.c @@ -166,7 +166,6 @@ void filestream_set_size(RFILE *stream) * @bufsize : optional buffer size (-1 or 0 to use default) * * Opens a file for reading or writing, depending on the requested mode. - * If bufsize is > 0 for unbuffered modes (like RFILE_MODE_WRITE), file will instead be fully buffered. * Returns a pointer to an RFILE if opened successfully, otherwise NULL. **/ RFILE *filestream_open(const char *path, unsigned mode, ssize_t unused) @@ -192,6 +191,7 @@ RFILE *filestream_open(const char *path, unsigned mode, ssize_t unused) (void)mode_int; (void)flags; + (void)bufsize; stream->hints = mode; From df55e6b4d1b094794bc08356eea01468f2fa6e06 Mon Sep 17 00:00:00 2001 From: Alcaro Date: Mon, 4 Dec 2017 13:30:38 +0100 Subject: [PATCH 170/394] actually, let's just completely remove it --- libretro-common/streams/file_stream.c | 27 +++++++++++---------------- 1 file changed, 11 insertions(+), 16 deletions(-) diff --git a/libretro-common/streams/file_stream.c b/libretro-common/streams/file_stream.c index ff742674b7..f8db1c9442 100644 --- a/libretro-common/streams/file_stream.c +++ b/libretro-common/streams/file_stream.c @@ -170,7 +170,6 @@ void filestream_set_size(RFILE *stream) **/ RFILE *filestream_open(const char *path, unsigned mode, ssize_t unused) { - ssize_t bufsize = 0x4000; int flags = 0; int mode_int = 0; #if defined(HAVE_BUFFERED_IO) @@ -191,7 +190,6 @@ RFILE *filestream_open(const char *path, unsigned mode, ssize_t unused) (void)mode_int; (void)flags; - (void)bufsize; stream->hints = mode; @@ -298,20 +296,17 @@ RFILE *filestream_open(const char *path, unsigned mode, ssize_t unused) if (!stream->fp) goto error; - if (bufsize > 0) - { - /* Regarding setvbuf: - * - * https://www.freebsd.org/cgi/man.cgi?query=setvbuf&apropos=0&sektion=0&manpath=FreeBSD+11.1-RELEASE&arch=default&format=html - * - * If the size argument is not zero but buf is NULL, a buffer of the given size will be allocated immediately, and - * released on close. This is an extension to ANSI C. - * - * Since C89 does not support specifying a null buffer with a non-zero size, we create and track our own buffer for it. - */ - stream->buf = (char*)calloc(1, bufsize); - setvbuf(stream->fp, stream->buf, _IOFBF, bufsize); - } + /* Regarding setvbuf: + * + * https://www.freebsd.org/cgi/man.cgi?query=setvbuf&apropos=0&sektion=0&manpath=FreeBSD+11.1-RELEASE&arch=default&format=html + * + * If the size argument is not zero but buf is NULL, a buffer of the given size will be allocated immediately, and + * released on close. This is an extension to ANSI C. + * + * Since C89 does not support specifying a null buffer with a non-zero size, we create and track our own buffer for it. + */ + stream->buf = (char*)calloc(1, 0x4000); + setvbuf(stream->fp, stream->buf, _IOFBF, 0x4000); } else #endif From 0d4ac123100f8c473a30064eb0fa7ea9982f5a9c Mon Sep 17 00:00:00 2001 From: Alcaro Date: Mon, 4 Dec 2017 13:34:15 +0100 Subject: [PATCH 171/394] Update file_stream.c --- libretro-common/streams/file_stream.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libretro-common/streams/file_stream.c b/libretro-common/streams/file_stream.c index f8db1c9442..5703a69b1d 100644 --- a/libretro-common/streams/file_stream.c +++ b/libretro-common/streams/file_stream.c @@ -305,6 +305,7 @@ RFILE *filestream_open(const char *path, unsigned mode, ssize_t unused) * * Since C89 does not support specifying a null buffer with a non-zero size, we create and track our own buffer for it. */ + /* TODO: this is only useful for a few platforms, find which and add ifdef */ stream->buf = (char*)calloc(1, 0x4000); setvbuf(stream->fp, stream->buf, _IOFBF, 0x4000); } From 2b3cc8898a0ae2312feba3c40d1ba7639b7fd9dc Mon Sep 17 00:00:00 2001 From: Alcaro Date: Mon, 4 Dec 2017 13:41:04 +0100 Subject: [PATCH 172/394] Fix this one for non-stdio backends Why does filestream_get_fp exist --- playlist.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/playlist.c b/playlist.c index 2c22d9243d..5ccc40cd2e 100644 --- a/playlist.c +++ b/playlist.c @@ -381,7 +381,6 @@ void playlist_write_file(playlist_t *playlist) { size_t i; RFILE *file = NULL; - FILE *fp = NULL; if (!playlist || !playlist->modified) return; @@ -394,10 +393,8 @@ void playlist_write_file(playlist_t *playlist) return; } - fp = filestream_get_fp(file); - for (i = 0; i < playlist->size; i++) - fprintf(fp, "%s\n%s\n%s\n%s\n%s\n%s\n", + filestream_printf(file, "%s\n%s\n%s\n%s\n%s\n%s\n", playlist->entries[i].path ? playlist->entries[i].path : "", playlist->entries[i].label ? playlist->entries[i].label : "", playlist->entries[i].core_path, From 130e4522e2c580dec7989736dfe898dcd9dc188c Mon Sep 17 00:00:00 2001 From: Alcaro Date: Mon, 4 Dec 2017 13:51:25 +0100 Subject: [PATCH 173/394] Update file_stream.h --- libretro-common/include/streams/file_stream.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/libretro-common/include/streams/file_stream.h b/libretro-common/include/streams/file_stream.h index c57731d76a..ee8cc8e0ba 100644 --- a/libretro-common/include/streams/file_stream.h +++ b/libretro-common/include/streams/file_stream.h @@ -99,8 +99,11 @@ int filestream_printf(RFILE *stream, const char* format, ...); int filestream_error(RFILE *stream); -int filestream_get_fd(RFILE *stream); +/* DO NOT put this function back, unless you want to deal with + the UNAVOIDABLE REGRESSIONS on platforms using unexpected rfile backends +int filestream_get_fd(RFILE *stream); */ +/* TODO: remove, for the same reason as the above */ FILE* filestream_get_fp(RFILE *stream); int filestream_flush(RFILE *stream); From e4bb8e7aeb286b2c3e4e0bc890b72ee2a435c3f0 Mon Sep 17 00:00:00 2001 From: Alcaro Date: Mon, 4 Dec 2017 13:52:11 +0100 Subject: [PATCH 174/394] Update file_stream.c --- libretro-common/streams/file_stream.c | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/libretro-common/streams/file_stream.c b/libretro-common/streams/file_stream.c index 5703a69b1d..fce0934a92 100644 --- a/libretro-common/streams/file_stream.c +++ b/libretro-common/streams/file_stream.c @@ -121,17 +121,6 @@ FILE* filestream_get_fp(RFILE *stream) return stream->fp; } -int filestream_get_fd(RFILE *stream) -{ - if (!stream) - return -1; -#if defined(HAVE_BUFFERED_IO) - if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0) - return fileno(stream->fp); -#endif - return stream->fd; -} - const char *filestream_get_ext(RFILE *stream) { if (!stream) From 1aa6ae1b389c2a18ca2ec48161b9a5b4cd53e812 Mon Sep 17 00:00:00 2001 From: Alcaro Date: Mon, 4 Dec 2017 14:25:16 +0100 Subject: [PATCH 175/394] Use FILE* all the way Fixes platforms where RFILE isn't using the FILE* backend, needed for #5664 --- verbosity.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/verbosity.c b/verbosity.c index 83dca5d02f..368067fa96 100644 --- a/verbosity.c +++ b/verbosity.c @@ -49,8 +49,8 @@ /* If this is non-NULL. RARCH_LOG and friends * will write to this file. */ -static RFILE *log_file = NULL; static FILE *log_file_fp = NULL; +static void* log_file_buf = NULL; static bool main_verbosity = false; static bool log_file_initialized = false; @@ -96,17 +96,21 @@ void retro_main_log_file_init(const char *path) if (path == NULL) return; - log_file = filestream_open(path, RFILE_MODE_WRITE, -1); - log_file_fp = filestream_get_fp(log_file); + log_file_fp = fopen(path, "wb"); log_file_initialized = true; + + /* TODO: this is only useful for a few platforms, find which and add ifdef */ + log_file_buf = (char*)calloc(1, 0x4000); + setvbuf(log_file_fp, log_file_buf, _IOFBF, 0x4000); } void retro_main_log_file_deinit(void) { - if (log_file && log_file_fp != stderr) - filestream_close(log_file); - log_file = NULL; + if (log_file_fp && log_file_fp != stderr) + fclose(log_file_fp); + if (log_file_buf) free(log_file_buf); log_file_fp = NULL; + log_file_buf = NULL; } #if !defined(HAVE_LOGGER) From b9900b1fb8e7c570d338325dd827badc044e98ab Mon Sep 17 00:00:00 2001 From: Alcaro Date: Mon, 4 Dec 2017 14:27:36 +0100 Subject: [PATCH 176/394] This cast isn't needed, and probably breaks CXX_BUILD --- verbosity.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/verbosity.c b/verbosity.c index 368067fa96..2fb735e6bf 100644 --- a/verbosity.c +++ b/verbosity.c @@ -100,7 +100,7 @@ void retro_main_log_file_init(const char *path) log_file_initialized = true; /* TODO: this is only useful for a few platforms, find which and add ifdef */ - log_file_buf = (char*)calloc(1, 0x4000); + log_file_buf = calloc(1, 0x4000); setvbuf(log_file_fp, log_file_buf, _IOFBF, 0x4000); } From 300052626fc4db994a1e94a46c4ed93d3dd179b4 Mon Sep 17 00:00:00 2001 From: Alcaro Date: Mon, 4 Dec 2017 14:30:32 +0100 Subject: [PATCH 177/394] Use FILE* all the way Fixes platforms where RFILE isn't using the FILE* backend, needed for #5664 --- libretro-common/file/config_file.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/libretro-common/file/config_file.c b/libretro-common/file/config_file.c index 70f7b64aab..67c0703ff6 100644 --- a/libretro-common/file/config_file.c +++ b/libretro-common/file/config_file.c @@ -912,20 +912,28 @@ void config_set_bool(config_file_t *conf, const char *key, bool val) bool config_file_write(config_file_t *conf, const char *path) { - RFILE *file = NULL; + FILE* file = NULL; + void* buf = NULL; if (!string_is_empty(path)) { - file = filestream_open(path, RFILE_MODE_WRITE, 0x4000); + file = fopen(path, "wb"); if (!file) return false; - config_file_dump(conf, filestream_get_fp(file)); + + /* TODO: this is only useful for a few platforms, find which and add ifdef */ + buf = calloc(1, 0x4000); + setvbuf(file, buf, _IOFBF, 0x4000); + + config_file_dump(conf, file); } else config_file_dump(conf, stdout); - if (file) - filestream_close(file); + if (file && file != stdout) + fclose(file); + if (buf) + free(buf); return true; } From dca30d533fc415d04a03a79965e223f2f3a4d39e Mon Sep 17 00:00:00 2001 From: Alcaro Date: Mon, 4 Dec 2017 14:31:11 +0100 Subject: [PATCH 178/394] Update file_stream.h --- libretro-common/include/streams/file_stream.h | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/libretro-common/include/streams/file_stream.h b/libretro-common/include/streams/file_stream.h index ee8cc8e0ba..06cdf33ded 100644 --- a/libretro-common/include/streams/file_stream.h +++ b/libretro-common/include/streams/file_stream.h @@ -99,12 +99,10 @@ int filestream_printf(RFILE *stream, const char* format, ...); int filestream_error(RFILE *stream); -/* DO NOT put this function back, unless you want to deal with +/* DO NOT put these functions back, unless you want to deal with the UNAVOIDABLE REGRESSIONS on platforms using unexpected rfile backends -int filestream_get_fd(RFILE *stream); */ - -/* TODO: remove, for the same reason as the above */ -FILE* filestream_get_fp(RFILE *stream); +int filestream_get_fd(RFILE *stream); +FILE* filestream_get_fp(RFILE *stream); */ int filestream_flush(RFILE *stream); From c10859b745cfd902246b646c05e666c7461345a4 Mon Sep 17 00:00:00 2001 From: Alcaro Date: Mon, 4 Dec 2017 14:31:31 +0100 Subject: [PATCH 179/394] Update file_stream.c --- libretro-common/streams/file_stream.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/libretro-common/streams/file_stream.c b/libretro-common/streams/file_stream.c index fce0934a92..9fdf995d8f 100644 --- a/libretro-common/streams/file_stream.c +++ b/libretro-common/streams/file_stream.c @@ -114,13 +114,6 @@ struct RFILE char *buf; }; -FILE* filestream_get_fp(RFILE *stream) -{ - if (!stream) - return NULL; - return stream->fp; -} - const char *filestream_get_ext(RFILE *stream) { if (!stream) From fbd3a435d2f93ed6d217257b055e411d700a66c5 Mon Sep 17 00:00:00 2001 From: Alcaro Date: Mon, 4 Dec 2017 15:01:57 +0100 Subject: [PATCH 180/394] Turns out this is char*, let's cast because CXX_BUILD wants that --- verbosity.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/verbosity.c b/verbosity.c index 2fb735e6bf..734dcaba39 100644 --- a/verbosity.c +++ b/verbosity.c @@ -101,7 +101,7 @@ void retro_main_log_file_init(const char *path) /* TODO: this is only useful for a few platforms, find which and add ifdef */ log_file_buf = calloc(1, 0x4000); - setvbuf(log_file_fp, log_file_buf, _IOFBF, 0x4000); + setvbuf(log_file_fp, (char*)log_file_buf, _IOFBF, 0x4000); } void retro_main_log_file_deinit(void) From ff4dca86f95ab0cf34004ddca9cacc353127bda4 Mon Sep 17 00:00:00 2001 From: Alcaro Date: Mon, 4 Dec 2017 15:01:58 +0100 Subject: [PATCH 181/394] Turns out this is char*, let's cast because CXX_BUILD wants that --- libretro-common/file/config_file.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libretro-common/file/config_file.c b/libretro-common/file/config_file.c index 67c0703ff6..66e03f3f7b 100644 --- a/libretro-common/file/config_file.c +++ b/libretro-common/file/config_file.c @@ -923,7 +923,7 @@ bool config_file_write(config_file_t *conf, const char *path) /* TODO: this is only useful for a few platforms, find which and add ifdef */ buf = calloc(1, 0x4000); - setvbuf(file, buf, _IOFBF, 0x4000); + setvbuf(file, (char*)buf, _IOFBF, 0x4000); config_file_dump(conf, file); } From 059354de2f60e14c3894382d53641a1cb1d09845 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 4 Dec 2017 16:26:28 +0100 Subject: [PATCH 182/394] Cleanup for config_file_write --- libretro-common/file/config_file.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/libretro-common/file/config_file.c b/libretro-common/file/config_file.c index 66e03f3f7b..9e23012168 100644 --- a/libretro-common/file/config_file.c +++ b/libretro-common/file/config_file.c @@ -912,12 +912,10 @@ void config_set_bool(config_file_t *conf, const char *key, bool val) bool config_file_write(config_file_t *conf, const char *path) { - FILE* file = NULL; - void* buf = NULL; - if (!string_is_empty(path)) { - file = fopen(path, "wb"); + void* buf = NULL; + FILE *file = fopen(path, "wb"); if (!file) return false; @@ -926,15 +924,14 @@ bool config_file_write(config_file_t *conf, const char *path) setvbuf(file, (char*)buf, _IOFBF, 0x4000); config_file_dump(conf, file); + + if (file != stdout) + fclose(file); + free(buf); } else config_file_dump(conf, stdout); - if (file && file != stdout) - fclose(file); - if (buf) - free(buf); - return true; } From d74ad6cd5e9fe19bcba0e299369aaa9960533c0b Mon Sep 17 00:00:00 2001 From: Alcaro Date: Mon, 4 Dec 2017 16:32:40 +0100 Subject: [PATCH 183/394] Create fopen_utf8.h --- libretro-common/include/compat/fopen_utf8.h | 5 +++++ 1 file changed, 5 insertions(+) create mode 100644 libretro-common/include/compat/fopen_utf8.h diff --git a/libretro-common/include/compat/fopen_utf8.h b/libretro-common/include/compat/fopen_utf8.h new file mode 100644 index 0000000000..0c6d44d778 --- /dev/null +++ b/libretro-common/include/compat/fopen_utf8.h @@ -0,0 +1,5 @@ +#include +#ifdef _WIN32 +#define fopen fopen_utf8 +FILE* fopen_utf8(const char * filename, const char * mode); +#endif From 8df699984ea1820fa6ce64b0921db6689acbbf24 Mon Sep 17 00:00:00 2001 From: Alcaro Date: Mon, 4 Dec 2017 16:34:56 +0100 Subject: [PATCH 184/394] Update fopen_utf8.h --- libretro-common/include/compat/fopen_utf8.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libretro-common/include/compat/fopen_utf8.h b/libretro-common/include/compat/fopen_utf8.h index 0c6d44d778..583b558a26 100644 --- a/libretro-common/include/compat/fopen_utf8.h +++ b/libretro-common/include/compat/fopen_utf8.h @@ -1,5 +1,9 @@ #include #ifdef _WIN32 -#define fopen fopen_utf8 +/* defined to error rather than fopen_utf8, to make clear to everyone reading the code that not worrying about utf16 is fine */ +/* TODO: enable */ +/* #define fopen (use fopen_utf8 instead) */ FILE* fopen_utf8(const char * filename, const char * mode); +#else +#define fopen_utf8 fopen #endif From 8a93a9eb8eac185850f79eb54653cdb4bec2de7c Mon Sep 17 00:00:00 2001 From: Alcaro Date: Mon, 4 Dec 2017 16:44:34 +0100 Subject: [PATCH 185/394] Create fopen_utf8.c --- libretro-common/compat/fopen_utf8.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 libretro-common/compat/fopen_utf8.c diff --git a/libretro-common/compat/fopen_utf8.c b/libretro-common/compat/fopen_utf8.c new file mode 100644 index 0000000000..a17ad81542 --- /dev/null +++ b/libretro-common/compat/fopen_utf8.c @@ -0,0 +1,25 @@ +#include +#include + +#ifdef _WIN32 +#undef fopen + +FILE* fopen_utf8(const char * filename, const char * mode) +{ +#if defined(_XBOX) + return fopen(filename, mode); +#elif defined(LEGACY_WIN32) + char * filename_local = utf8_to_local_string_alloc(path); + FILE* ret = fopen(filename_local, mode); + free(filename_local); + return ret; +#else + wchar_t * filename_w = utf8_to_utf16_string_alloc(filename); + wchar_t * mode_w = utf8_to_utf16_string_alloc(mode); + FILE* ret = _wfopen(filename_w, mode_w); + free(filename_w); + free(mode_w); + return ret; +#endif +} +#endif From cc2dd827b568a05f68bf6beeea2d90dff8bc5e75 Mon Sep 17 00:00:00 2001 From: Alcaro Date: Mon, 4 Dec 2017 16:46:59 +0100 Subject: [PATCH 186/394] Update Makefile.common --- Makefile.common | 1 + 1 file changed, 1 insertion(+) diff --git a/Makefile.common b/Makefile.common index 58158f33aa..14caf2e201 100644 --- a/Makefile.common +++ b/Makefile.common @@ -170,6 +170,7 @@ OBJ += frontend/frontend.o \ tasks/task_audio_mixer.o \ $(LIBRETRO_COMM_DIR)/encodings/encoding_utf.o \ $(LIBRETRO_COMM_DIR)/encodings/encoding_crc32.o \ + $(LIBRETRO_COMM_DIR)/compat/fopen_utf8.o \ $(LIBRETRO_COMM_DIR)/lists/file_list.o \ $(LIBRETRO_COMM_DIR)/lists/dir_list.o \ $(LIBRETRO_COMM_DIR)/file/retro_dirent.o \ From a6ef704369348a6cc57c35b847379d42d7e373ba Mon Sep 17 00:00:00 2001 From: Alcaro Date: Mon, 4 Dec 2017 16:47:27 +0100 Subject: [PATCH 187/394] Update config_file.c --- libretro-common/file/config_file.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libretro-common/file/config_file.c b/libretro-common/file/config_file.c index 9e23012168..cf105bbc3a 100644 --- a/libretro-common/file/config_file.c +++ b/libretro-common/file/config_file.c @@ -38,6 +38,7 @@ #include #include #include +#include #include #include #include @@ -915,7 +916,7 @@ bool config_file_write(config_file_t *conf, const char *path) if (!string_is_empty(path)) { void* buf = NULL; - FILE *file = fopen(path, "wb"); + FILE *file = fopen_utf8(path, "wb"); if (!file) return false; From 486d5e77e3015e44c0df9334ca3b60b281ac7f25 Mon Sep 17 00:00:00 2001 From: Alcaro Date: Mon, 4 Dec 2017 16:48:17 +0100 Subject: [PATCH 188/394] Update verbosity.c --- verbosity.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/verbosity.c b/verbosity.c index 734dcaba39..a260f79949 100644 --- a/verbosity.c +++ b/verbosity.c @@ -35,6 +35,7 @@ #include #include +#include #ifdef HAVE_CONFIG_H #include "config.h" @@ -96,7 +97,7 @@ void retro_main_log_file_init(const char *path) if (path == NULL) return; - log_file_fp = fopen(path, "wb"); + log_file_fp = fopen_utf8(path, "wb"); log_file_initialized = true; /* TODO: this is only useful for a few platforms, find which and add ifdef */ From 6359aee509704c6488ef174d899b3d6233fafc9e Mon Sep 17 00:00:00 2001 From: Alcaro Date: Mon, 4 Dec 2017 17:03:53 +0100 Subject: [PATCH 189/394] Update fopen_utf8.c --- libretro-common/compat/fopen_utf8.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libretro-common/compat/fopen_utf8.c b/libretro-common/compat/fopen_utf8.c index a17ad81542..843c449cc1 100644 --- a/libretro-common/compat/fopen_utf8.c +++ b/libretro-common/compat/fopen_utf8.c @@ -1,6 +1,12 @@ #include #include +#if defined(_MSC_VER) && _MSC_VER < 1400 || defined(_XBOX) +#ifndef LEGACY_WIN32 +#define LEGACY_WIN32 +#endif +#endif + #ifdef _WIN32 #undef fopen From 90dd2892b0449231f7d66eb33c85ec1ef8445b16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francisco=20Jos=C3=A9=20Garc=C3=ADa=20Garc=C3=ADa?= Date: Mon, 4 Dec 2017 18:09:37 +0100 Subject: [PATCH 190/394] FIX sceIoOpen return error --- libretro-common/streams/file_stream.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libretro-common/streams/file_stream.c b/libretro-common/streams/file_stream.c index 9fdf995d8f..fd792bc40c 100644 --- a/libretro-common/streams/file_stream.c +++ b/libretro-common/streams/file_stream.c @@ -251,7 +251,7 @@ RFILE *filestream_open(const char *path, unsigned mode, ssize_t unused) #if defined(PSP) stream->fd = sceIoOpen(path, flags, mode_int); - if (stream->fd == -1) + if (stream->fd < 0) goto error; #else #if defined(HAVE_BUFFERED_IO) From 84691c7b9bb2c294b6cad03ca5096aa308238aa2 Mon Sep 17 00:00:00 2001 From: Alcaro Date: Mon, 4 Dec 2017 19:15:35 +0100 Subject: [PATCH 191/394] Update retro_miscellaneous.h --- libretro-common/include/retro_miscellaneous.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libretro-common/include/retro_miscellaneous.h b/libretro-common/include/retro_miscellaneous.h index bfa3fcb741..c2e11b021f 100644 --- a/libretro-common/include/retro_miscellaneous.h +++ b/libretro-common/include/retro_miscellaneous.h @@ -80,7 +80,7 @@ #define BIT128_SET(a, bit) ((a).data[(bit) >> 5] |= (1 << ((bit) & 31))) #define BIT128_CLEAR(a, bit) ((a).data[(bit) >> 5] &= ~(1 << ((bit) & 31))) #define BIT128_GET(a, bit) ((a).data[(bit) >> 5] & (1 << ((bit) & 31))) -#define BIT128_CLEAR_ALL(a) memset(&(a), 0, sizeof(a)); +#define BIT128_CLEAR_ALL(a) memset(&(a), 0, sizeof(a)) /* Helper macros and struct to keep track of many booleans. * To check for multiple bits, use &&, not &. From 908784b0ae3bc075382d9da41ac1d182bb3a79a1 Mon Sep 17 00:00:00 2001 From: Alcaro Date: Mon, 4 Dec 2017 20:19:35 +0100 Subject: [PATCH 192/394] Update griffin.c --- griffin/griffin.c | 1 + 1 file changed, 1 insertion(+) diff --git a/griffin/griffin.c b/griffin/griffin.c index 2bbb31a47b..8ac7762892 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -58,6 +58,7 @@ COMPATIBILITY #endif #include "../libretro-common/compat/compat_fnmatch.c" +#include "../libretro-common/compat/fopen_utf8.c" #include "../libretro-common/memmap/memalign.c" /*============================================================ From 2f1bcb64093e153561878fe33058e8db1033226f Mon Sep 17 00:00:00 2001 From: Alcaro Date: Mon, 4 Dec 2017 20:20:10 +0100 Subject: [PATCH 193/394] Update fopen_utf8.c --- libretro-common/compat/fopen_utf8.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libretro-common/compat/fopen_utf8.c b/libretro-common/compat/fopen_utf8.c index 843c449cc1..1fd64187fb 100644 --- a/libretro-common/compat/fopen_utf8.c +++ b/libretro-common/compat/fopen_utf8.c @@ -1,5 +1,6 @@ #include #include +#include #if defined(_MSC_VER) && _MSC_VER < 1400 || defined(_XBOX) #ifndef LEGACY_WIN32 From 75c59aedcf6d45642bbd399aa7f348b96112123b Mon Sep 17 00:00:00 2001 From: Alcaro Date: Mon, 4 Dec 2017 20:23:45 +0100 Subject: [PATCH 194/394] Update fopen_utf8.h --- libretro-common/include/compat/fopen_utf8.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/libretro-common/include/compat/fopen_utf8.h b/libretro-common/include/compat/fopen_utf8.h index 583b558a26..67cc289aa6 100644 --- a/libretro-common/include/compat/fopen_utf8.h +++ b/libretro-common/include/compat/fopen_utf8.h @@ -1,9 +1,14 @@ +#ifndef __FOPEN_UTF8_H +#define __FOPEN_UTF8_H + #include + #ifdef _WIN32 -/* defined to error rather than fopen_utf8, to make clear to everyone reading the code that not worrying about utf16 is fine */ +/* defined to error rather than fopen_utf8, to make it clear to everyone reading the code that not worrying about utf16 is fine */ /* TODO: enable */ /* #define fopen (use fopen_utf8 instead) */ FILE* fopen_utf8(const char * filename, const char * mode); #else #define fopen_utf8 fopen #endif +#endif From e8a9471afdbc17064ed47807f72cf972b89a17bb Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Mon, 4 Dec 2017 18:53:34 -0500 Subject: [PATCH 195/394] Fix to ARM to ensure chain has been declared --- gfx/drivers_renderchain/gl2_renderchain.c | 1 + 1 file changed, 1 insertion(+) diff --git a/gfx/drivers_renderchain/gl2_renderchain.c b/gfx/drivers_renderchain/gl2_renderchain.c index a74e0d6637..ebdb9709b0 100644 --- a/gfx/drivers_renderchain/gl2_renderchain.c +++ b/gfx/drivers_renderchain/gl2_renderchain.c @@ -1281,6 +1281,7 @@ static void gl2_renderchain_copy_frame( } #elif defined(HAVE_OPENGLES) #if defined(HAVE_EGL) + gl2_renderchain_t *chain = (gl2_renderchain_t*)chain_data; if (chain->egl_images) { gfx_ctx_image_t img_info; From 49d02998086d0e154f22385d627710835ebb536c Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Mon, 4 Dec 2017 22:49:08 -0500 Subject: [PATCH 196/394] LEGACY_WIN32: check for target of less than Win2K instead of < vc2005, since Win98 does not support Unicode --- gfx/common/win32_common.c | 4 ++-- libretro-common/compat/fopen_utf8.c | 4 ++-- libretro-common/file/file_path.c | 8 ++++---- libretro-common/file/nbio/nbio_stdio.c | 4 ++-- libretro-common/file/nbio/nbio_windowsmmap.c | 4 ++-- libretro-common/file/retro_dirent.c | 2 +- libretro-common/streams/file_stream.c | 4 ++-- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/gfx/common/win32_common.c b/gfx/common/win32_common.c index 40a807a2c0..a8a696cbb2 100644 --- a/gfx/common/win32_common.c +++ b/gfx/common/win32_common.c @@ -53,8 +53,8 @@ #include -/* Assume W-functions do not work below VC2005 and Xbox platforms */ -#if defined(_MSC_VER) && _MSC_VER < 1400 || defined(_XBOX) +/* Assume W-functions do not work below Win2K and Xbox platforms */ +#if defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0500 || defined(_XBOX) #ifndef LEGACY_WIN32 #define LEGACY_WIN32 diff --git a/libretro-common/compat/fopen_utf8.c b/libretro-common/compat/fopen_utf8.c index 1fd64187fb..b61c53ebd1 100644 --- a/libretro-common/compat/fopen_utf8.c +++ b/libretro-common/compat/fopen_utf8.c @@ -2,7 +2,7 @@ #include #include -#if defined(_MSC_VER) && _MSC_VER < 1400 || defined(_XBOX) +#if defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0500 || defined(_XBOX) #ifndef LEGACY_WIN32 #define LEGACY_WIN32 #endif @@ -16,7 +16,7 @@ FILE* fopen_utf8(const char * filename, const char * mode) #if defined(_XBOX) return fopen(filename, mode); #elif defined(LEGACY_WIN32) - char * filename_local = utf8_to_local_string_alloc(path); + char * filename_local = utf8_to_local_string_alloc(filename); FILE* ret = fopen(filename_local, mode); free(filename_local); return ret; diff --git a/libretro-common/file/file_path.c b/libretro-common/file/file_path.c index 62ee9f20e7..8d9f8414b2 100644 --- a/libretro-common/file/file_path.c +++ b/libretro-common/file/file_path.c @@ -84,8 +84,8 @@ #include /* stat() is defined here */ #endif -/* Assume W-functions do not work below VC2005 and Xbox platforms */ -#if defined(_MSC_VER) && _MSC_VER < 1400 || defined(_XBOX) +/* Assume W-functions do not work below Win2K and Xbox platforms */ +#if defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0500 || defined(_XBOX) #ifndef LEGACY_WIN32 #define LEGACY_WIN32 @@ -936,7 +936,7 @@ bool path_file_remove(const char *path) (void)path_wide; #if defined(_WIN32) && !defined(_XBOX) -#if defined(_MSC_VER) && _MSC_VER < 1400 +#if defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0500 path_local = utf8_to_local_string_alloc(path); if (path_local) @@ -982,7 +982,7 @@ bool path_file_rename(const char *old_path, const char *new_path) (void)new_path_wide; #if defined(_WIN32) && !defined(_XBOX) -#if defined(_MSC_VER) && _MSC_VER < 1400 +#if defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0500 old_path_local = utf8_to_local_string_alloc(old_path); new_path_local = utf8_to_local_string_alloc(new_path); diff --git a/libretro-common/file/nbio/nbio_stdio.c b/libretro-common/file/nbio/nbio_stdio.c index 3e6f4094f1..d3425f7de0 100644 --- a/libretro-common/file/nbio/nbio_stdio.c +++ b/libretro-common/file/nbio/nbio_stdio.c @@ -26,8 +26,8 @@ #include #include -/* Assume W-functions do not work below VC2005 and Xbox platforms */ -#if defined(_MSC_VER) && _MSC_VER < 1400 || defined(_XBOX) +/* Assume W-functions do not work below Win2K and Xbox platforms */ +#if defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0500 || defined(_XBOX) #ifndef LEGACY_WIN32 #define LEGACY_WIN32 diff --git a/libretro-common/file/nbio/nbio_windowsmmap.c b/libretro-common/file/nbio/nbio_windowsmmap.c index caf0d72514..25208571b2 100644 --- a/libretro-common/file/nbio/nbio_windowsmmap.c +++ b/libretro-common/file/nbio/nbio_windowsmmap.c @@ -31,8 +31,8 @@ #include -/* Assume W-functions do not work below VC2005 and Xbox platforms */ -#if defined(_MSC_VER) && _MSC_VER < 1400 || defined(_XBOX) +/* Assume W-functions do not work below Win2K and Xbox platforms */ +#if defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0500 || defined(_XBOX) #ifndef LEGACY_WIN32 #define LEGACY_WIN32 diff --git a/libretro-common/file/retro_dirent.c b/libretro-common/file/retro_dirent.c index 98328e30c1..aa221c888c 100644 --- a/libretro-common/file/retro_dirent.c +++ b/libretro-common/file/retro_dirent.c @@ -67,7 +67,7 @@ #include /* stat() is defined here */ #endif -#if defined(_MSC_VER) && _MSC_VER < 1400 || defined(_XBOX) +#if defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0500 || defined(_XBOX) #ifndef LEGACY_WIN32 #define LEGACY_WIN32 #endif diff --git a/libretro-common/streams/file_stream.c b/libretro-common/streams/file_stream.c index fd792bc40c..da29d4864d 100644 --- a/libretro-common/streams/file_stream.c +++ b/libretro-common/streams/file_stream.c @@ -65,8 +65,8 @@ #include #endif -/* Assume W-functions do not work below VC2005 and Xbox platforms */ -#if defined(_MSC_VER) && _MSC_VER < 1400 || defined(_XBOX) +/* Assume W-functions do not work below Win2K and Xbox platforms */ +#if defined(_WIN32_WINNT) && _WIN32_WINNT < 0x0500 || defined(_XBOX) #ifndef LEGACY_WIN32 #define LEGACY_WIN32 From 0215648a83e931de88a613b6c1e34c1ed2bd0e84 Mon Sep 17 00:00:00 2001 From: Alcaro Date: Tue, 5 Dec 2017 08:34:29 +0100 Subject: [PATCH 197/394] Make booleans boolean again #5856 why do both BIT_ and BIT128_ exist --- libretro-common/include/retro_miscellaneous.h | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/libretro-common/include/retro_miscellaneous.h b/libretro-common/include/retro_miscellaneous.h index c2e11b021f..c26899eb9f 100644 --- a/libretro-common/include/retro_miscellaneous.h +++ b/libretro-common/include/retro_miscellaneous.h @@ -60,31 +60,29 @@ #define BIT_SET(a, bit) ((a)[(bit) >> 3] |= (1 << ((bit) & 7))) #define BIT_CLEAR(a, bit) ((a)[(bit) >> 3] &= ~(1 << ((bit) & 7))) -#define BIT_GET(a, bit) ((a)[(bit) >> 3] & (1 << ((bit) & 7))) +#define BIT_GET(a, bit) (((a).data[(bit) >> 3] >> ((bit) & 7)) & 1) #define BIT16_SET(a, bit) ((a) |= (1 << ((bit) & 15))) #define BIT16_CLEAR(a, bit) ((a) &= ~(1 << ((bit) & 15))) -#define BIT16_GET(a, bit) (!!((a) & (1 << ((bit) & 15)))) +#define BIT16_GET(a, bit) (((a) >> ((bit) & 15)) & 1) #define BIT16_CLEAR_ALL(a) ((a) = 0) #define BIT32_SET(a, bit) ((a) |= (1 << ((bit) & 31))) #define BIT32_CLEAR(a, bit) ((a) &= ~(1 << ((bit) & 31))) -#define BIT32_GET(a, bit) (!!((a) & (1 << ((bit) & 31)))) +#define BIT32_GET(a, bit) (((a) >> ((bit) & 31)) & 1) #define BIT32_CLEAR_ALL(a) ((a) = 0) #define BIT64_SET(a, bit) ((a) |= (UINT64_C(1) << ((bit) & 63))) #define BIT64_CLEAR(a, bit) ((a) &= ~(UINT64_C(1) << ((bit) & 63))) -#define BIT64_GET(a, bit) (!!((a) & (UINT64_C(1) << ((bit) & 63)))) +#define BIT64_GET(a, bit) (((a) >> ((bit) & 63)) & 1) #define BIT64_CLEAR_ALL(a) ((a) = 0) #define BIT128_SET(a, bit) ((a).data[(bit) >> 5] |= (1 << ((bit) & 31))) #define BIT128_CLEAR(a, bit) ((a).data[(bit) >> 5] &= ~(1 << ((bit) & 31))) -#define BIT128_GET(a, bit) ((a).data[(bit) >> 5] & (1 << ((bit) & 31))) +#define BIT128_GET(a, bit) (((a).data[(bit) >> 5] >> ((bit) & 31)) & 1) #define BIT128_CLEAR_ALL(a) memset(&(a), 0, sizeof(a)) -/* Helper macros and struct to keep track of many booleans. - * To check for multiple bits, use &&, not &. - * For OR, | can be used. */ +/* Helper macros and struct to keep track of many booleans. */ typedef struct { uint32_t data[8]; From 3ccce249ea3e4fd7f67881d3893818009b0c02e5 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 5 Dec 2017 08:50:24 +0100 Subject: [PATCH 198/394] Fixes hotkey issues with MSVC --- input/input_defines.h | 25 +++++++++++++------ libretro-common/include/retro_miscellaneous.h | 3 +++ 2 files changed, 20 insertions(+), 8 deletions(-) diff --git a/input/input_defines.h b/input/input_defines.h index fa697c54a4..54eac4a25b 100644 --- a/input/input_defines.h +++ b/input/input_defines.h @@ -158,12 +158,12 @@ enum analog_dpad_mode #define GET_HAT_DIR(x) (x & HAT_MASK) #define GET_HAT(x) (x & (~HAT_MASK)) -#define RARCH_INPUT_STATE_BIT_SET(a,bit) ((a).data [((bit) >> 5)] |= (1 << ((bit) & 31))) -#define RARCH_INPUT_STATE_BIT_SET_PTR(a,bit) ((a)->data[((bit) >> 5)] |= (1 << ((bit) & 31))) -#define RARCH_INPUT_STATE_BIT_GET(a,bit) ((a).data [((bit) >> 5)] & (1 << ((bit) & 31))) -#define RARCH_INPUT_STATE_BIT_GET_PTR(a,bit) ((a)->data[((bit) >> 5)] & (1 << ((bit) & 31))) -#define RARCH_INPUT_STATE_CLEAR(a) memset(&a, 0, sizeof(a)); -#define RARCH_INPUT_STATE_CLEAR_PTR(a) memset(a, 0, sizeof(retro_bits_t)); +#define RARCH_INPUT_STATE_BIT_SET(a,bit) BIT128_SET(a, bit) +#define RARCH_INPUT_STATE_BIT_SET_PTR(a,bit) BIT128_SET_PTR(a, bit) +#define RARCH_INPUT_STATE_BIT_GET(a,bit) BIT128_GET(a, bit) +#define RARCH_INPUT_STATE_BIT_GET_PTR(a,bit) BIT128_GET_PTR(a, bit) +#define RARCH_INPUT_STATE_CLEAR(a) BIT128_CLEAR_ALL(a) +#define RARCH_INPUT_STATE_CLEAR_PTR(a) BIT128_CLEAR_ALL_PTR(a) #define RARCH_INPUT_STATE_ANY_SET(a) ( ((a).data[0])||((a).data[1])||((a).data[2])||((a).data[3])|| \ ((a).data[4])||((a).data[5])||((a).data[6])||((a).data[7]) ) #define RARCH_INPUT_STATE_ANY_SET_PTR(a) ( ((a)->data[0])||((a)->data[1])||((a)->data[2])||((a)->data[3])|| \ @@ -178,8 +178,17 @@ enum analog_dpad_mode ((a).data[6])&=(~((b).data[6])); \ ((a).data[7])&=(~((b).data[7])); -#define RARCH_INPUT_STATE_COPY16_PTR(a,bits) {memset(a, 0, sizeof(retro_bits_t));((a)->data[0] = (bits)&0xffff);} -#define RARCH_INPUT_STATE_COPY32_PTR(a,bits) {memset(a, 0, sizeof(retro_bits_t));((a)->data[0] = (bits));} +#define RARCH_INPUT_STATE_COPY16_PTR(a,bits) \ +{ \ + BIT128_CLEAR_ALL_PTR(a); \ + ((a)->data[0] = (bits) & 0xffff); \ +} + +#define RARCH_INPUT_STATE_COPY32_PTR(a,bits) \ +{ \ + BIT128_CLEAR_ALL_PTR(a); \ + ((a)->data[0] = (bits)); \ +} RETRO_END_DECLS diff --git a/libretro-common/include/retro_miscellaneous.h b/libretro-common/include/retro_miscellaneous.h index c26899eb9f..9baf2e0214 100644 --- a/libretro-common/include/retro_miscellaneous.h +++ b/libretro-common/include/retro_miscellaneous.h @@ -78,9 +78,12 @@ #define BIT64_CLEAR_ALL(a) ((a) = 0) #define BIT128_SET(a, bit) ((a).data[(bit) >> 5] |= (1 << ((bit) & 31))) +#define BIT128_SET_PTR(a, bit) ((a)->data[(bit) >> 5] |= (1 << ((bit) & 31))) #define BIT128_CLEAR(a, bit) ((a).data[(bit) >> 5] &= ~(1 << ((bit) & 31))) #define BIT128_GET(a, bit) (((a).data[(bit) >> 5] >> ((bit) & 31)) & 1) +#define BIT128_GET_PTR(a, bit) (((a)->data[(bit) >> 5] >> ((bit) & 31)) & 1) #define BIT128_CLEAR_ALL(a) memset(&(a), 0, sizeof(a)) +#define BIT128_CLEAR_ALL_PTR(a) memset((a), 0, sizeof(retro_bits_t)) /* Helper macros and struct to keep track of many booleans. */ typedef struct From 0691c9e0d316e847e11ded8167d9e0e6113a79d2 Mon Sep 17 00:00:00 2001 From: Alcaro Date: Tue, 5 Dec 2017 08:55:42 +0100 Subject: [PATCH 199/394] Let's not duplicate those macros more than needed --- libretro-common/include/retro_miscellaneous.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libretro-common/include/retro_miscellaneous.h b/libretro-common/include/retro_miscellaneous.h index 9baf2e0214..b29c5cdc54 100644 --- a/libretro-common/include/retro_miscellaneous.h +++ b/libretro-common/include/retro_miscellaneous.h @@ -78,14 +78,17 @@ #define BIT64_CLEAR_ALL(a) ((a) = 0) #define BIT128_SET(a, bit) ((a).data[(bit) >> 5] |= (1 << ((bit) & 31))) -#define BIT128_SET_PTR(a, bit) ((a)->data[(bit) >> 5] |= (1 << ((bit) & 31))) #define BIT128_CLEAR(a, bit) ((a).data[(bit) >> 5] &= ~(1 << ((bit) & 31))) #define BIT128_GET(a, bit) (((a).data[(bit) >> 5] >> ((bit) & 31)) & 1) -#define BIT128_GET_PTR(a, bit) (((a)->data[(bit) >> 5] >> ((bit) & 31)) & 1) #define BIT128_CLEAR_ALL(a) memset(&(a), 0, sizeof(a)) -#define BIT128_CLEAR_ALL_PTR(a) memset((a), 0, sizeof(retro_bits_t)) + +#define BIT128_SET_PTR(a, bit) BIT128_SET(*a, bit) +#define BIT128_CLEAR_PTR(a, bit) BIT128_CLEAR(*a, bit) +#define BIT128_GET_PTR(a, bit) BIT128_GET(*a, bit) +#define BIT128_CLEAR_ALL_PTR(a) BIT128_CLEAR_ALL(*a) /* Helper macros and struct to keep track of many booleans. */ +/* This struct has 256 bits, but the macros are named 128 due to some historical accident. */ typedef struct { uint32_t data[8]; From e94300a581ca46975a1a07b9b7424e22b6be7e5f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 5 Dec 2017 09:22:33 +0100 Subject: [PATCH 200/394] Get rid of a lot of RARCH_INPUT_STATE_BIT_ macros - replace them with BIT128_ equivalents instead --- input/connect/connect_nesusb.c | 7 +- input/connect/connect_ps2adapter.c | 7 +- input/connect/connect_ps3.c | 9 +-- input/connect/connect_ps4.c | 91 +++++++++------------ input/connect/connect_psxadapter.c | 7 +- input/connect/connect_snesusb.c | 7 +- input/connect/connect_wiiugca.c | 7 +- input/connect/connect_wiiupro.c | 90 +++++++++------------ input/connect/joypad_connection.c | 7 +- input/drivers/cocoa_input.c | 7 +- input/drivers/wiiu_input.c | 4 +- input/drivers_hid/btstack_hid.c | 5 +- input/drivers_hid/iohidmanager_hid.c | 4 +- input/drivers_hid/libusb_hid.c | 4 +- input/drivers_hid/null_hid.c | 2 +- input/drivers_hid/wiiusb_hid.c | 4 +- input/drivers_joypad/ctr_joypad.c | 7 +- input/drivers_joypad/gx_joypad.c | 7 +- input/drivers_joypad/hid_joypad.c | 7 +- input/drivers_joypad/linuxraw_joypad.c | 7 +- input/drivers_joypad/null_joypad.c | 2 +- input/drivers_joypad/parport_joypad.c | 7 +- input/drivers_joypad/ps3_joypad.c | 7 +- input/drivers_joypad/psp_joypad.c | 7 +- input/drivers_joypad/udev_joypad.c | 7 +- input/drivers_joypad/wiiu_joypad.c | 7 +- input/drivers_joypad/xdk_joypad.c | 7 +- input/input_defines.h | 6 -- input/input_driver.c | 29 +++---- menu/menu_event.c | 48 +++++------ retroarch.c | 107 ++++++++++++------------- retroarch.h | 2 - 32 files changed, 250 insertions(+), 276 deletions(-) diff --git a/input/connect/connect_nesusb.c b/input/connect/connect_nesusb.c index 24c5f0532e..b39936be06 100644 --- a/input/connect/connect_nesusb.c +++ b/input/connect/connect_nesusb.c @@ -62,11 +62,12 @@ static void hidpad_nesusb_deinit(void *data) static void hidpad_nesusb_get_buttons(void *data, retro_bits_t* state) { struct hidpad_nesusb_data *device = (struct hidpad_nesusb_data*)data; - if (device) { + if (device) + { RARCH_INPUT_STATE_COPY16_PTR(state, device->buttons); - } else { - RARCH_INPUT_STATE_CLEAR_PTR(state); } + else + BIT128_CLEAR_ALL_PTR(state); } static int16_t hidpad_nesusb_get_axis(void *data, unsigned axis) diff --git a/input/connect/connect_ps2adapter.c b/input/connect/connect_ps2adapter.c index 78c3cf9c92..29b2c932fe 100644 --- a/input/connect/connect_ps2adapter.c +++ b/input/connect/connect_ps2adapter.c @@ -62,11 +62,12 @@ static void hidpad_ps2adapter_deinit(void *data) static void hidpad_ps2adapter_get_buttons(void *data, retro_bits_t *state) { struct hidpad_ps2adapter_data *device = (struct hidpad_ps2adapter_data*)data; - if ( device ) { + if (device) + { RARCH_INPUT_STATE_COPY16_PTR(state, device->buttons); - } else { - RARCH_INPUT_STATE_CLEAR_PTR(state); } + else + BIT128_CLEAR_ALL_PTR(state); } static int16_t hidpad_ps2adapter_get_axis(void *data, unsigned axis) diff --git a/input/connect/connect_ps3.c b/input/connect/connect_ps3.c index 422a1b02a2..de4e8fa3ec 100644 --- a/input/connect/connect_ps3.c +++ b/input/connect/connect_ps3.c @@ -114,14 +114,11 @@ static void hidpad_ps3_get_buttons(void *data, retro_bits_t *state) RARCH_INPUT_STATE_COPY16_PTR(state, device->buttons); /*PS button?*/ - if ( device->buttons & 0x10000 ) { - RARCH_INPUT_STATE_BIT_SET_PTR( state, RARCH_MENU_TOGGLE ); - } + if (device->buttons & 0x10000) + BIT128_SET_PTR(state, RARCH_MENU_TOGGLE); } else - { - RARCH_INPUT_STATE_CLEAR_PTR( state ); - } + BIT128_CLEAR_ALL_PTR(state); } static int16_t hidpad_ps3_get_axis(void *data, unsigned axis) diff --git a/input/connect/connect_ps4.c b/input/connect/connect_ps4.c index 47a9cdabe6..901e693d80 100644 --- a/input/connect/connect_ps4.c +++ b/input/connect/connect_ps4.c @@ -20,6 +20,7 @@ #include #include +#include #include "joypad_connection.h" #include "../input_defines.h" @@ -187,64 +188,48 @@ static bool hidpad_ps4_check_dpad(struct ps4 *rpt, unsigned id) static void hidpad_ps4_get_buttons(void *data, retro_bits_t* state) { struct hidpad_ps4_data *device = (struct hidpad_ps4_data*)data; - struct ps4 *rpt = device ? (struct ps4*)&device->data : NULL; + struct ps4 *rpt = device ? + (struct ps4*)&device->data : NULL; if (!device || !rpt) return; - RARCH_INPUT_STATE_CLEAR_PTR( state ); + BIT128_CLEAR_ALL_PTR( state ); - if ( rpt->btn.r3 ) { - RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_R3 ); - } - if ( rpt->btn.l3 ) { - RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_L3 ); - } - if ( rpt->btn.options ) { - RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_START ); - } - if ( rpt->btn.share ) { - RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_SELECT ); - } - if ( rpt->btn.r2 ) { - RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_R2 ); - } - if ( rpt->btn.l2 ) { - RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_L2 ); - } - if ( rpt->btn.r1 ) { - RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_R ); - } - if ( rpt->btn.l1 ) { - RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_L ); - } - if ( rpt->btn.triangle ) { - RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_X ); - } - if ( rpt->btn.circle ) { - RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_A ); - } - if ( rpt->btn.cross ) { - RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_B ); - } - if ( rpt->btn.square ) { - RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_Y ); - } - if ( (hidpad_ps4_check_dpad(rpt, RETRO_DEVICE_ID_JOYPAD_LEFT)) ) { - RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_LEFT ); - } - if ( (hidpad_ps4_check_dpad(rpt, RETRO_DEVICE_ID_JOYPAD_DOWN)) ) { - RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_DOWN ); - } - if ( (hidpad_ps4_check_dpad(rpt, RETRO_DEVICE_ID_JOYPAD_RIGHT)) ) { - RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_RIGHT ); - } - if ( (hidpad_ps4_check_dpad(rpt, RETRO_DEVICE_ID_JOYPAD_UP)) ) { - RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_UP ); - } - if ( rpt->btn.ps ) { - RARCH_INPUT_STATE_BIT_SET_PTR( state, RARCH_MENU_TOGGLE ); - } + if (rpt->btn.r3) + BIT128_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_R3 ); + if (rpt->btn.l3) + BIT128_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_L3 ); + if (rpt->btn.options) + BIT128_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_START ); + if ( rpt->btn.share) + BIT128_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_SELECT ); + if ( rpt->btn.r2) + BIT128_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_R2 ); + if (rpt->btn.l2) + BIT128_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_L2 ); + if (rpt->btn.r1) + BIT128_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_R ); + if (rpt->btn.l1) + BIT128_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_L ); + if (rpt->btn.triangle) + BIT128_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_X ); + if (rpt->btn.circle) + BIT128_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_A ); + if (rpt->btn.cross) + BIT128_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_B ); + if (rpt->btn.square) + BIT128_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_Y ); + if ((hidpad_ps4_check_dpad(rpt, RETRO_DEVICE_ID_JOYPAD_LEFT))) + BIT128_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_LEFT ); + if ((hidpad_ps4_check_dpad(rpt, RETRO_DEVICE_ID_JOYPAD_DOWN))) + BIT128_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_DOWN ); + if ((hidpad_ps4_check_dpad(rpt, RETRO_DEVICE_ID_JOYPAD_RIGHT))) + BIT128_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_RIGHT ); + if ((hidpad_ps4_check_dpad(rpt, RETRO_DEVICE_ID_JOYPAD_UP))) + BIT128_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_UP ); + if (rpt->btn.ps) + BIT128_SET_PTR( state, RARCH_MENU_TOGGLE ); } static int16_t hidpad_ps4_get_axis(void *data, unsigned axis) diff --git a/input/connect/connect_psxadapter.c b/input/connect/connect_psxadapter.c index 6f77e77f72..a4fcf78587 100644 --- a/input/connect/connect_psxadapter.c +++ b/input/connect/connect_psxadapter.c @@ -62,11 +62,12 @@ static void hidpad_psxadapter_deinit(void *data) static void hidpad_psxadapter_get_buttons(void *data, retro_bits_t *state) { struct hidpad_psxadapter_data *device = (struct hidpad_psxadapter_data*)data; - if ( device ) { + if (device) + { RARCH_INPUT_STATE_COPY16_PTR(state, device->buttons); - } else { - RARCH_INPUT_STATE_CLEAR_PTR(state); } + else + BIT128_CLEAR_ALL_PTR(state); } static int16_t hidpad_psxadapter_get_axis(void *data, unsigned axis) diff --git a/input/connect/connect_snesusb.c b/input/connect/connect_snesusb.c index bbc9fb43a4..b7cb594905 100644 --- a/input/connect/connect_snesusb.c +++ b/input/connect/connect_snesusb.c @@ -63,11 +63,12 @@ static void hidpad_snesusb_deinit(void *data) static void hidpad_snesusb_get_buttons(void *data, retro_bits_t *state) { struct hidpad_snesusb_data *device = (struct hidpad_snesusb_data*)data; - if ( device ) { + if (device) + { RARCH_INPUT_STATE_COPY16_PTR(state, device->buttons); - } else { - RARCH_INPUT_STATE_CLEAR_PTR(state); } + else + BIT128_CLEAR_ALL_PTR(state); } static int16_t hidpad_snesusb_get_axis(void *data, unsigned axis) diff --git a/input/connect/connect_wiiugca.c b/input/connect/connect_wiiugca.c index 0f368e01fe..69ceaa0739 100644 --- a/input/connect/connect_wiiugca.c +++ b/input/connect/connect_wiiugca.c @@ -66,11 +66,12 @@ static void hidpad_wiiugca_deinit(void *data) static void hidpad_wiiugca_get_buttons(void *data, retro_bits_t *state) { struct hidpad_wiiugca_data *device = (struct hidpad_wiiugca_data*)data; - if ( device ) { + if (device) + { RARCH_INPUT_STATE_COPY16_PTR(state, device->buttons); - } else { - RARCH_INPUT_STATE_CLEAR_PTR(state); } + else + BIT128_CLEAR_ALL_PTR(state); } static int16_t hidpad_wiiugca_get_axis(void *data, unsigned axis) diff --git a/input/connect/connect_wiiupro.c b/input/connect/connect_wiiupro.c index d380e119a0..b7e148a010 100644 --- a/input/connect/connect_wiiupro.c +++ b/input/connect/connect_wiiupro.c @@ -121,64 +121,48 @@ static void hidpad_wiiupro_deinit(void *data) static void hidpad_wiiupro_get_buttons(void *data, retro_bits_t *state) { struct hidpad_wiiupro_data *device = (struct hidpad_wiiupro_data*)data; - struct wiiupro *rpt = device ? (struct wiiupro*)&device->data : NULL; + struct wiiupro *rpt = device ? + (struct wiiupro*)&device->data : NULL; if (!device || !rpt) return; - RARCH_INPUT_STATE_CLEAR_PTR( state ); + BIT128_CLEAR_ALL_PTR(state); - if ( rpt->btn.r3 ) { - RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_R3 ); - } - if ( rpt->btn.l3 ) { - RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_L3 ); - } - if ( rpt->btn.plus ) { - RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_START ); - } - if ( rpt->btn.minus ) { - RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_SELECT ); - } - if ( rpt->btn.zr ) { - RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_R2 ); - } - if ( rpt->btn.zl ) { - RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_L2 ); - } - if ( rpt->btn.r ) { - RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_R ); - } - if ( rpt->btn.l ) { - RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_L ); - } - if ( rpt->btn.x ) { - RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_X ); - } - if ( rpt->btn.a ) { - RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_A ); - } - if ( rpt->btn.b ) { - RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_B ); - } - if ( rpt->btn.y ) { - RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_Y ); - } - if ( rpt->btn.left ) { - RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_LEFT ); - } - if ( rpt->btn.down ) { - RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_DOWN ); - } - if ( rpt->btn.right ) { - RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_RIGHT ); - } - if ( rpt->btn.up ) { - RARCH_INPUT_STATE_BIT_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_UP ); - } - if ( rpt->btn.home ) { - RARCH_INPUT_STATE_BIT_SET_PTR( state, RARCH_MENU_TOGGLE ); - } + if (rpt->btn.r3) + BIT128_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_R3); + if (rpt->btn.l3) + BIT128_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_L3); + if (rpt->btn.plus) + BIT128_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_START); + if ( rpt->btn.minus) + BIT128_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_SELECT); + if ( rpt->btn.zr) + BIT128_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_R2); + if ( rpt->btn.zl) + BIT128_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_L2); + if ( rpt->btn.r) + BIT128_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_R); + if ( rpt->btn.l) + BIT128_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_L); + if ( rpt->btn.x) + BIT128_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_X); + if ( rpt->btn.a) + BIT128_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_A); + if ( rpt->btn.b) + BIT128_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_B); + if ( rpt->btn.y) + BIT128_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_Y); + if ( rpt->btn.left) + BIT128_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_LEFT); + if ( rpt->btn.down) + BIT128_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_DOWN); + if ( rpt->btn.right) + BIT128_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_RIGHT); + if ( rpt->btn.up) + BIT128_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_UP); + if ( rpt->btn.home) + BIT128_SET_PTR(state, RARCH_MENU_TOGGLE); } static int16_t hidpad_wiiupro_get_axis(void *data, unsigned axis) diff --git a/input/connect/joypad_connection.c b/input/connect/joypad_connection.c index 18ae10612d..178d32fcd2 100644 --- a/input/connect/joypad_connection.c +++ b/input/connect/joypad_connection.c @@ -175,11 +175,12 @@ void pad_connection_packet(joypad_connection_t *joyconn, uint32_t pad, void pad_connection_get_buttons(joypad_connection_t *joyconn, unsigned pad, retro_bits_t* state) { - if (joyconn->iface) { + if (joyconn->iface) + { joyconn->iface->get_buttons(joyconn->data, state); - } else { - RARCH_INPUT_STATE_CLEAR_PTR( state ); } + else + BIT128_CLEAR_ALL_PTR( state ); } int16_t pad_connection_get_axis(joypad_connection_t *joyconn, diff --git a/input/drivers/cocoa_input.c b/input/drivers/cocoa_input.c index ceeaf417b1..2ce55ddb38 100644 --- a/input/drivers/cocoa_input.c +++ b/input/drivers/cocoa_input.c @@ -17,14 +17,17 @@ #include #include +#include + #ifdef HAVE_CONFIG_H #include "../../config.h" #endif #include "../input_driver.h" - #include "../input_keymaps.h" + #include "cocoa_input.h" + #include "../../gfx/video_driver.h" #include "../../driver.h" @@ -56,7 +59,7 @@ static int cocoa_input_find_any_button_ret(cocoa_input_data_t *apple, if (state) for (i = 0; i < 256; i++) - if (RARCH_INPUT_STATE_BIT_GET_PTR(state,i)) + if (BIT128_GET_PTR(state,i)) return i; return -1; } diff --git a/input/drivers/wiiu_input.c b/input/drivers/wiiu_input.c index 7cb9444b3c..99d8087e65 100644 --- a/input/drivers/wiiu_input.c +++ b/input/drivers/wiiu_input.c @@ -107,8 +107,8 @@ static int16_t wiiu_pointer_device_state(wiiu_input_t* wiiu, unsigned id) case RETRO_DEVICE_ID_POINTER_PRESSED: { retro_bits_t state; - wiiu->joypad->get_buttons(0,&state); - return RARCH_INPUT_STATE_BIT_GET(state, VPAD_BUTTON_TOUCH) ? 1 : 0; + wiiu->joypad->get_buttons(0, &state); + return BIT128_GET(state, VPAD_BUTTON_TOUCH) ? 1 : 0; } case RETRO_DEVICE_ID_POINTER_X: return wiiu->joypad->axis(0, 0xFFFF0004UL); diff --git a/input/drivers_hid/btstack_hid.c b/input/drivers_hid/btstack_hid.c index 83eec68c61..2166a2d2a3 100644 --- a/input/drivers_hid/btstack_hid.c +++ b/input/drivers_hid/btstack_hid.c @@ -27,6 +27,7 @@ #endif #include +#include #include #ifdef HAVE_DYNAMIC #include @@ -1369,7 +1370,7 @@ static void btstack_hid_joypad_get_buttons(void *data, unsigned port, retro_bits if (hid) pad_connection_get_buttons(&hid->slots[port], port, state); else - RARCH_INPUT_STATE_CLEAR_PTR(state); + BIT128_CLEAR_ALL_PTR(state); } static bool btstack_hid_joypad_button(void *data, unsigned port, uint16_t joykey) @@ -1383,7 +1384,7 @@ static bool btstack_hid_joypad_button(void *data, unsigned port, uint16_t joykey /* Check the button. */ if ((port < MAX_USERS) && (joykey < 32)) - return (RARCH_INPUT_STATE_BIT_GET(buttons, joykey) != 0); + return (BIT128_GET(buttons, joykey) != 0); return false; } diff --git a/input/drivers_hid/iohidmanager_hid.c b/input/drivers_hid/iohidmanager_hid.c index aac33afd56..3d479fce40 100644 --- a/input/drivers_hid/iohidmanager_hid.c +++ b/input/drivers_hid/iohidmanager_hid.c @@ -114,7 +114,7 @@ static void iohidmanager_hid_joypad_get_buttons(void *data, unsigned port, retro if (hid) return pad_connection_get_buttons(&hid->slots[port], port, state); else - RARCH_INPUT_STATE_CLEAR_PTR(state); + BIT128_CLEAR_ALL_PTR(state); } static bool iohidmanager_hid_joypad_button(void *data, @@ -150,7 +150,7 @@ static bool iohidmanager_hid_joypad_button(void *data, /* Check the button. */ if ((port < MAX_USERS) && (joykey < 32)) - return (RARCH_INPUT_STATE_BIT_GET(buttons, joykey) != 0) + return (BIT128_GET(buttons, joykey) != 0) || ((hid->buttons[port] & (1 << joykey)) != 0); return false; diff --git a/input/drivers_hid/libusb_hid.c b/input/drivers_hid/libusb_hid.c index 257b4819cc..a653b6b9bc 100644 --- a/input/drivers_hid/libusb_hid.c +++ b/input/drivers_hid/libusb_hid.c @@ -449,7 +449,7 @@ static void libusb_hid_joypad_get_buttons(void *data, unsigned port, retro_bits_ if (hid) return pad_connection_get_buttons(&hid->slots[port], port, state); else - RARCH_INPUT_STATE_CLEAR_PTR(state); + BIT128_CLEAR_ALL_PTR(state); } static bool libusb_hid_joypad_button(void *data, @@ -464,7 +464,7 @@ static bool libusb_hid_joypad_button(void *data, /* Check the button. */ if ((port < MAX_USERS) && (joykey < 32)) - return (RARCH_INPUT_STATE_BIT_GET(buttons, joykey) != 0); + return (BIT128_GET(buttons, joykey) != 0); return false; } diff --git a/input/drivers_hid/null_hid.c b/input/drivers_hid/null_hid.c index 34f8bdb7d6..74b61d051e 100644 --- a/input/drivers_hid/null_hid.c +++ b/input/drivers_hid/null_hid.c @@ -43,7 +43,7 @@ static void null_hid_joypad_get_buttons(void *data, unsigned port, retro_bits_t (void)data; (void)port; - RARCH_INPUT_STATE_CLEAR_PTR(state); + BIT128_CLEAR_ALL_PTR(state); } static bool null_hid_joypad_button(void *data, unsigned port, uint16_t joykey) diff --git a/input/drivers_hid/wiiusb_hid.c b/input/drivers_hid/wiiusb_hid.c index 3f0fdb282c..b550915689 100644 --- a/input/drivers_hid/wiiusb_hid.c +++ b/input/drivers_hid/wiiusb_hid.c @@ -484,7 +484,7 @@ static void wiiusb_hid_joypad_get_buttons(void *data, unsigned port, retro_bits_ if (hid) return pad_connection_get_buttons(&hid->connections[port], port, state); else - RARCH_INPUT_STATE_CLEAR_PTR(state); + BIT128_CLEAR_ALL_PTR(state); } static bool wiiusb_hid_joypad_button(void *data, unsigned port, uint16_t joykey) @@ -499,7 +499,7 @@ static bool wiiusb_hid_joypad_button(void *data, unsigned port, uint16_t joykey) /* Check the button. */ if ((port < MAX_USERS) && (joykey < 32)) - return (RARCH_INPUT_STATE_BIT_GET(buttons, joykey) != 0); + return (BIT128_GET(buttons, joykey) != 0); return false; } diff --git a/input/drivers_joypad/ctr_joypad.c b/input/drivers_joypad/ctr_joypad.c index a31a7511fe..7350c71d78 100644 --- a/input/drivers_joypad/ctr_joypad.c +++ b/input/drivers_joypad/ctr_joypad.c @@ -72,11 +72,12 @@ static bool ctr_joypad_button(unsigned port_num, uint16_t key) static void ctr_joypad_get_buttons(unsigned port_num, retro_bits_t *state) { - if ( port_num < MAX_PADS ) { + if ( port_num < MAX_PADS ) + { RARCH_INPUT_STATE_COPY16_PTR( state, pad_state ); - } else { - RARCH_INPUT_STATE_CLEAR_PTR(state); } + else + BIT128_CLEAR_ALL_PTR(state); } static int16_t ctr_joypad_axis(unsigned port_num, uint32_t joyaxis) diff --git a/input/drivers_joypad/gx_joypad.c b/input/drivers_joypad/gx_joypad.c index 318eb637ed..2dc568df78 100644 --- a/input/drivers_joypad/gx_joypad.c +++ b/input/drivers_joypad/gx_joypad.c @@ -164,11 +164,12 @@ static bool gx_joypad_button(unsigned port, uint16_t key) static void gx_joypad_get_buttons(unsigned port, retro_bits_t *state) { - if ( port < MAX_PADS ) { + if (port < MAX_PADS) + { RARCH_INPUT_STATE_COPY16_PTR( state, pad_state[port] ); - } else { - RARCH_INPUT_STATE_CLEAR_PTR(state); } + else + BIT128_CLEAR_ALL_PTR(state); } static int16_t gx_joypad_axis(unsigned port, uint32_t joyaxis) diff --git a/input/drivers_joypad/hid_joypad.c b/input/drivers_joypad/hid_joypad.c index eaed7efbed..fe0badd38a 100644 --- a/input/drivers_joypad/hid_joypad.c +++ b/input/drivers_joypad/hid_joypad.c @@ -57,11 +57,10 @@ static bool hid_joypad_button(unsigned port, uint16_t joykey) static void hid_joypad_get_buttons(unsigned port, retro_bits_t *state) { - if (generic_hid && generic_hid->get_buttons) { + if (generic_hid && generic_hid->get_buttons) generic_hid->get_buttons((void*)hid_driver_get_data(), port, state); - } else { - RARCH_INPUT_STATE_CLEAR_PTR( state ); - } + else + BIT128_CLEAR_ALL_PTR(state); } static int16_t hid_joypad_axis(unsigned port, uint32_t joyaxis) diff --git a/input/drivers_joypad/linuxraw_joypad.c b/input/drivers_joypad/linuxraw_joypad.c index 212aeb8adc..f8cf299464 100644 --- a/input/drivers_joypad/linuxraw_joypad.c +++ b/input/drivers_joypad/linuxraw_joypad.c @@ -329,11 +329,12 @@ static bool linuxraw_joypad_button(unsigned port, uint16_t joykey) static void linuxraw_joypad_get_buttons(unsigned port, retro_bits_t *state) { const struct linuxraw_joypad *pad = (const struct linuxraw_joypad*)&linuxraw_pads[port]; - if ( pad ) { + if (pad) + { RARCH_INPUT_STATE_COPY16_PTR(state, pad->buttons); - } else { - RARCH_INPUT_STATE_CLEAR_PTR(state); } + else + BIT128_CLEAR_ALL_PTR(state); } static int16_t linuxraw_joypad_axis(unsigned port, uint32_t joyaxis) diff --git a/input/drivers_joypad/null_joypad.c b/input/drivers_joypad/null_joypad.c index d364433e06..f938e802e4 100644 --- a/input/drivers_joypad/null_joypad.c +++ b/input/drivers_joypad/null_joypad.c @@ -39,7 +39,7 @@ static bool null_joypad_button(unsigned port_num, uint16_t joykey) static void null_joypad_get_buttons(unsigned port_num, retro_bits_t *state) { - RARCH_INPUT_STATE_CLEAR_PTR( state ); + BIT128_CLEAR_ALL_PTR(state); } static int16_t null_joypad_axis(unsigned port_num, uint32_t joyaxis) diff --git a/input/drivers_joypad/parport_joypad.c b/input/drivers_joypad/parport_joypad.c index 062e6dd958..61879842c8 100644 --- a/input/drivers_joypad/parport_joypad.c +++ b/input/drivers_joypad/parport_joypad.c @@ -343,11 +343,12 @@ static bool parport_joypad_button(unsigned port, uint16_t joykey) static void parport_joypad_get_buttons(unsigned port, retro_bits_t *state) { const struct parport_joypad *pad = (const struct parport_joypad*)&parport_pads[port]; - if ( pad ) { + if (pad) + { RARCH_INPUT_STATE_COPY16_PTR(state, pad->buttons); - } else { - RARCH_INPUT_STATE_CLEAR_PTR(state); } + else + BIT128_CLEAR_ALL_PTR(state); } static int16_t parport_joypad_axis(unsigned port, uint32_t joyaxis) diff --git a/input/drivers_joypad/ps3_joypad.c b/input/drivers_joypad/ps3_joypad.c index c14277924c..cd11cda4b7 100644 --- a/input/drivers_joypad/ps3_joypad.c +++ b/input/drivers_joypad/ps3_joypad.c @@ -70,11 +70,12 @@ static bool ps3_joypad_button(unsigned port_num, uint16_t joykey) static void ps3_joypad_get_buttons(unsigned port_num, retro_bits_t *state) { - if ( port_num < MAX_PADS ) { + if (port_num < MAX_PADS) + { RARCH_INPUT_STATE_COPY16_PTR( state, pad_state[port_num] ); - } else { - RARCH_INPUT_STATE_CLEAR_PTR(state); } + else + BIT128_CLEAR_ALL_PTR(state); } static int16_t ps3_joypad_axis(unsigned port_num, uint32_t joyaxis) diff --git a/input/drivers_joypad/psp_joypad.c b/input/drivers_joypad/psp_joypad.c index 967e9092e8..c86ee65a0b 100644 --- a/input/drivers_joypad/psp_joypad.c +++ b/input/drivers_joypad/psp_joypad.c @@ -126,11 +126,12 @@ static bool psp_joypad_button(unsigned port_num, uint16_t key) static void psp_joypad_get_buttons(unsigned port_num, retro_bits_t *state) { - if ( port_num < PSP_MAX_PADS ) { + if (port_num < PSP_MAX_PADS) + { RARCH_INPUT_STATE_COPY16_PTR( state, pad_state[port_num] ); - } else { - RARCH_INPUT_STATE_CLEAR_PTR(state); } + else + BIT128_CLEAR_ALL_PTR(state); } static int16_t psp_joypad_axis(unsigned port_num, uint32_t joyaxis) diff --git a/input/drivers_joypad/udev_joypad.c b/input/drivers_joypad/udev_joypad.c index 3aa6ba092a..50cfec8f20 100644 --- a/input/drivers_joypad/udev_joypad.c +++ b/input/drivers_joypad/udev_joypad.c @@ -607,11 +607,12 @@ static bool udev_joypad_button(unsigned port, uint16_t joykey) static void udev_joypad_get_buttons(unsigned port, retro_bits_t *state) { const struct udev_joypad *pad = (const struct udev_joypad*)&udev_pads[port]; - if ( pad ) { + if (pad) + { RARCH_INPUT_STATE_COPY16_PTR( state, pad->buttons ); - } else { - RARCH_INPUT_STATE_CLEAR_PTR(state); } + else + BIT128_CLEAR_ALL_PTR(state); } static int16_t udev_joypad_axis(unsigned port, uint32_t joyaxis) diff --git a/input/drivers_joypad/wiiu_joypad.c b/input/drivers_joypad/wiiu_joypad.c index ed62f14e09..67f8708b25 100644 --- a/input/drivers_joypad/wiiu_joypad.c +++ b/input/drivers_joypad/wiiu_joypad.c @@ -137,11 +137,12 @@ static bool wiiu_joypad_button(unsigned port_num, uint16_t key) static void wiiu_joypad_get_buttons(unsigned port_num, retro_bits_t *state) { - if ( port_num < MAX_PADS ) { + if (port_num < MAX_PADS) + { RARCH_INPUT_STATE_COPY16_PTR( state, pad_state[port_num] ); - } else { - RARCH_INPUT_STATE_CLEAR_PTR(state); } + else + BIT128_CLAR_ALL_PTR(state); } static int16_t wiiu_joypad_axis(unsigned port_num, uint32_t joyaxis) diff --git a/input/drivers_joypad/xdk_joypad.c b/input/drivers_joypad/xdk_joypad.c index b9e25268b4..92fa8b02eb 100644 --- a/input/drivers_joypad/xdk_joypad.c +++ b/input/drivers_joypad/xdk_joypad.c @@ -78,11 +78,12 @@ static bool xdk_joypad_button(unsigned port_num, uint16_t joykey) static void xdk_joypad_get_buttons(unsigned port_num, retro_bits_t *state) { - if ( port_num < MAX_PADS ) { + if (port_num < MAX_PADS) + { RARCH_INPUT_STATE_COPY16_PTR( state, pad_state[port_num] ); - } else { - RARCH_INPUT_STATE_CLEAR_PTR(state); } + else + BIT128_CLEAR_ALL_PTR(state); } static int16_t xdk_joypad_axis(unsigned port_num, uint32_t joyaxis) diff --git a/input/input_defines.h b/input/input_defines.h index 54eac4a25b..489122d3b1 100644 --- a/input/input_defines.h +++ b/input/input_defines.h @@ -158,12 +158,6 @@ enum analog_dpad_mode #define GET_HAT_DIR(x) (x & HAT_MASK) #define GET_HAT(x) (x & (~HAT_MASK)) -#define RARCH_INPUT_STATE_BIT_SET(a,bit) BIT128_SET(a, bit) -#define RARCH_INPUT_STATE_BIT_SET_PTR(a,bit) BIT128_SET_PTR(a, bit) -#define RARCH_INPUT_STATE_BIT_GET(a,bit) BIT128_GET(a, bit) -#define RARCH_INPUT_STATE_BIT_GET_PTR(a,bit) BIT128_GET_PTR(a, bit) -#define RARCH_INPUT_STATE_CLEAR(a) BIT128_CLEAR_ALL(a) -#define RARCH_INPUT_STATE_CLEAR_PTR(a) BIT128_CLEAR_ALL_PTR(a) #define RARCH_INPUT_STATE_ANY_SET(a) ( ((a).data[0])||((a).data[1])||((a).data[2])||((a).data[3])|| \ ((a).data[4])||((a).data[5])||((a).data[6])||((a).data[7]) ) #define RARCH_INPUT_STATE_ANY_SET_PTR(a) ( ((a)->data[0])||((a)->data[1])||((a)->data[2])||((a)->data[3])|| \ diff --git a/input/input_driver.c b/input/input_driver.c index b2e216c191..ca491bea9f 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -810,7 +810,7 @@ void input_menu_keys_pressed(void *data, retro_bits_t* p_new_state) joypad_info.joy_idx = 0; joypad_info.auto_binds = NULL; - RARCH_INPUT_STATE_CLEAR_PTR( p_new_state ); + BIT128_CLEAR_ALL_PTR(p_new_state); input_driver_block_libretro_input = false; input_driver_block_hotkey = false; @@ -912,7 +912,7 @@ void input_menu_keys_pressed(void *data, retro_bits_t* p_new_state) if (pressed) { - RARCH_INPUT_STATE_BIT_SET_PTR(p_new_state, i); + BIT128_SET_PTR(p_new_state, i); continue; } } @@ -922,7 +922,7 @@ void input_menu_keys_pressed(void *data, retro_bits_t* p_new_state) { if (current_input->meta_key_pressed(current_input_data, i)) { - RARCH_INPUT_STATE_BIT_SET_PTR(p_new_state, i); + BIT128_SET_PTR(p_new_state, i); continue; } } @@ -930,7 +930,7 @@ void input_menu_keys_pressed(void *data, retro_bits_t* p_new_state) #ifdef HAVE_OVERLAY if (overlay_ptr && input_overlay_key_pressed(overlay_ptr, i)) { - RARCH_INPUT_STATE_BIT_SET_PTR(p_new_state, i); + BIT128_SET_PTR(p_new_state, i); continue; } #endif @@ -945,7 +945,7 @@ void input_menu_keys_pressed(void *data, retro_bits_t* p_new_state) if (command_get(&handle)) { - RARCH_INPUT_STATE_BIT_SET_PTR(p_new_state, i); + BIT128_SET_PTR(p_new_state, i); continue; } } @@ -954,7 +954,7 @@ void input_menu_keys_pressed(void *data, retro_bits_t* p_new_state) #ifdef HAVE_NETWORKGAMEPAD if (input_driver_remote && input_remote_key_pressed(i, 0)) { - RARCH_INPUT_STATE_BIT_SET_PTR(p_new_state, i); + BIT128_SET_PTR(p_new_state, i); continue; } #endif @@ -1007,9 +1007,10 @@ void input_menu_keys_pressed(void *data, retro_bits_t* p_new_state) for (i = 0; i < 13; i++) { - if (current_input->input_state(current_input_data, joypad_info, binds, 0, + if (current_input->input_state(current_input_data, + joypad_info, binds, 0, RETRO_DEVICE_KEYBOARD, 0, ids[i][0])) - RARCH_INPUT_STATE_BIT_SET_PTR(p_new_state, ids[i][1]); + BIT128_SET_PTR(p_new_state, ids[i][1]); } } } @@ -1036,7 +1037,7 @@ void input_keys_pressed(void *data, retro_bits_t* p_new_state) const struct retro_keybind *enable_hotkey = &input_config_binds[0][RARCH_ENABLE_HOTKEY]; bool game_focus_toggle_valid = false; - RARCH_INPUT_STATE_CLEAR_PTR( p_new_state ); + BIT128_CLEAR_ALL_PTR(p_new_state); joypad_info.joy_idx = settings->uints.input_joypad_map[0]; joypad_info.auto_binds = input_autoconf_binds[joypad_info.joy_idx]; @@ -1082,7 +1083,7 @@ void input_keys_pressed(void *data, retro_bits_t* p_new_state) 0, RETRO_DEVICE_JOYPAD, 0, i) ) { - RARCH_INPUT_STATE_BIT_SET_PTR(p_new_state, i); + BIT128_SET_PTR(p_new_state, i); continue; } @@ -1090,7 +1091,7 @@ void input_keys_pressed(void *data, retro_bits_t* p_new_state) current_input->meta_key_pressed(current_input_data, i) ) { - RARCH_INPUT_STATE_BIT_SET_PTR(p_new_state, i); + BIT128_SET_PTR(p_new_state, i); continue; } @@ -1098,7 +1099,7 @@ void input_keys_pressed(void *data, retro_bits_t* p_new_state) if (overlay_ptr && input_overlay_key_pressed(overlay_ptr, i)) { - RARCH_INPUT_STATE_BIT_SET_PTR(p_new_state, i); + BIT128_SET_PTR(p_new_state, i); continue; } #endif @@ -1113,7 +1114,7 @@ void input_keys_pressed(void *data, retro_bits_t* p_new_state) if (command_get(&handle)) { - RARCH_INPUT_STATE_BIT_SET_PTR(p_new_state, i); + BIT128_SET_PTR(p_new_state, i); continue; } } @@ -1123,7 +1124,7 @@ void input_keys_pressed(void *data, retro_bits_t* p_new_state) if (input_driver_remote && input_remote_key_pressed(i, 0)) { - RARCH_INPUT_STATE_BIT_SET_PTR(p_new_state, i); + BIT128_SET_PTR(p_new_state, i); continue; } #endif diff --git a/menu/menu_event.c b/menu/menu_event.c index c8fe862dbb..6af08b3e5a 100644 --- a/menu/menu_event.c +++ b/menu/menu_event.c @@ -160,7 +160,7 @@ unsigned menu_event(retro_bits_t* p_input, retro_bits_t* p_trigger_input) unsigned menu_cancel_btn = (!input_swap_override && settings->bools.input_menu_swap_ok_cancel_buttons) ? RETRO_DEVICE_ID_JOYPAD_A : RETRO_DEVICE_ID_JOYPAD_B; - unsigned ok_current = RARCH_INPUT_STATE_BIT_GET_PTR(p_input, menu_ok_btn ); + unsigned ok_current = BIT128_GET_PTR(p_input, menu_ok_btn ); unsigned ok_trigger = ok_current & ~ok_old; ok_old = ok_current; @@ -221,31 +221,31 @@ unsigned menu_event(retro_bits_t* p_input, retro_bits_t* p_trigger_input) { menu_event_osk_iterate(); - if (RARCH_INPUT_STATE_BIT_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_DOWN)) + if (BIT128_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_DOWN)) { if (menu_event_get_osk_ptr() < 33) menu_event_set_osk_ptr(menu_event_get_osk_ptr() + OSK_CHARS_PER_LINE); } - if (RARCH_INPUT_STATE_BIT_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_UP)) + if (BIT128_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_UP)) { if (menu_event_get_osk_ptr() >= OSK_CHARS_PER_LINE) menu_event_set_osk_ptr(menu_event_get_osk_ptr() - OSK_CHARS_PER_LINE); } - if (RARCH_INPUT_STATE_BIT_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_RIGHT)) + if (BIT128_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_RIGHT)) { if (menu_event_get_osk_ptr() < 43) menu_event_set_osk_ptr(menu_event_get_osk_ptr() + 1); } - if (RARCH_INPUT_STATE_BIT_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_LEFT)) + if (BIT128_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_LEFT)) { if (menu_event_get_osk_ptr() >= 1) menu_event_set_osk_ptr(menu_event_get_osk_ptr() - 1); } - if (RARCH_INPUT_STATE_BIT_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_L)) + if (BIT128_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_L)) { if (menu_event_get_osk_idx() > OSK_TYPE_UNKNOWN + 1) menu_event_set_osk_idx((enum osk_type)(menu_event_get_osk_idx() - 1)); @@ -253,7 +253,7 @@ unsigned menu_event(retro_bits_t* p_input, retro_bits_t* p_trigger_input) menu_event_set_osk_idx((enum osk_type)(OSK_TYPE_LAST - 1)); } - if (RARCH_INPUT_STATE_BIT_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_R)) + if (BIT128_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_R)) { if (menu_event_get_osk_idx() < OSK_TYPE_LAST - 1) menu_event_set_osk_idx((enum osk_type)(menu_event_get_osk_idx() + 1)); @@ -261,50 +261,50 @@ unsigned menu_event(retro_bits_t* p_input, retro_bits_t* p_trigger_input) menu_event_set_osk_idx((enum osk_type)(OSK_TYPE_UNKNOWN + 1)); } - if (RARCH_INPUT_STATE_BIT_GET_PTR(p_trigger_input, menu_ok_btn)) + if (BIT128_GET_PTR(p_trigger_input, menu_ok_btn)) { if (menu_event_get_osk_ptr() >= 0) menu_event_osk_append(menu_event_get_osk_ptr()); } - if (RARCH_INPUT_STATE_BIT_GET_PTR(p_trigger_input, menu_cancel_btn)) + if (BIT128_GET_PTR(p_trigger_input, menu_cancel_btn)) { input_keyboard_event(true, '\x7f', '\x7f', 0, RETRO_DEVICE_KEYBOARD); } /* send return key to close keyboard input window */ - if (RARCH_INPUT_STATE_BIT_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_START)) + if (BIT128_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_START)) input_keyboard_event(true, '\n', '\n', 0, RETRO_DEVICE_KEYBOARD); - RARCH_INPUT_STATE_CLEAR_PTR(p_trigger_input); + BIT128_CLEAR_ALL_PTR(p_trigger_input); } else { - if (RARCH_INPUT_STATE_BIT_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_UP)) + if (BIT128_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_UP)) ret = MENU_ACTION_UP; - else if (RARCH_INPUT_STATE_BIT_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_DOWN)) + else if (BIT128_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_DOWN)) ret = MENU_ACTION_DOWN; - else if (RARCH_INPUT_STATE_BIT_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_LEFT)) + else if (BIT128_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_LEFT)) ret = MENU_ACTION_LEFT; - else if (RARCH_INPUT_STATE_BIT_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_RIGHT)) + else if (BIT128_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_RIGHT)) ret = MENU_ACTION_RIGHT; - else if (RARCH_INPUT_STATE_BIT_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_L)) + else if (BIT128_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_L)) ret = MENU_ACTION_SCROLL_UP; - else if (RARCH_INPUT_STATE_BIT_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_R)) + else if (BIT128_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_R)) ret = MENU_ACTION_SCROLL_DOWN; else if (ok_trigger) ret = MENU_ACTION_OK; - else if (RARCH_INPUT_STATE_BIT_GET_PTR(p_trigger_input, menu_cancel_btn)) + else if (BIT128_GET_PTR(p_trigger_input, menu_cancel_btn)) ret = MENU_ACTION_CANCEL; - else if (RARCH_INPUT_STATE_BIT_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_X)) + else if (BIT128_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_X)) ret = MENU_ACTION_SEARCH; - else if (RARCH_INPUT_STATE_BIT_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_Y)) + else if (BIT128_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_Y)) ret = MENU_ACTION_SCAN; - else if (RARCH_INPUT_STATE_BIT_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_START)) + else if (BIT128_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_START)) ret = MENU_ACTION_START; - else if (RARCH_INPUT_STATE_BIT_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_SELECT)) + else if (BIT128_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_SELECT)) ret = MENU_ACTION_INFO; - else if (RARCH_INPUT_STATE_BIT_GET_PTR(p_trigger_input, RARCH_MENU_TOGGLE)) + else if (BIT128_GET_PTR(p_trigger_input, RARCH_MENU_TOGGLE)) ret = MENU_ACTION_TOGGLE; } @@ -314,7 +314,7 @@ unsigned menu_event(retro_bits_t* p_input, retro_bits_t* p_trigger_input) menu_event_kb_set_internal(RETROK_F11, 0); } - if (RARCH_INPUT_STATE_BIT_GET_PTR(p_trigger_input, RARCH_QUIT_KEY)) + if (BIT128_GET_PTR(p_trigger_input, RARCH_QUIT_KEY)) return MENU_ACTION_QUIT; mouse_enabled = settings->bools.menu_mouse_enable; diff --git a/retroarch.c b/retroarch.c index 88173a0266..f9d7b6aae9 100644 --- a/retroarch.c +++ b/retroarch.c @@ -2315,35 +2315,35 @@ static bool input_driver_toggle_button_combo( switch (mode) { case INPUT_TOGGLE_DOWN_Y_L_R: - if (!RARCH_INPUT_STATE_BIT_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_DOWN)) + if (!BIT128_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_DOWN)) return false; - if (!RARCH_INPUT_STATE_BIT_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_Y)) + if (!BIT128_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_Y)) return false; - if (!RARCH_INPUT_STATE_BIT_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_L)) + if (!BIT128_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_L)) return false; - if (!RARCH_INPUT_STATE_BIT_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_R)) + if (!BIT128_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_R)) return false; break; case INPUT_TOGGLE_L3_R3: - if (!RARCH_INPUT_STATE_BIT_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_L3)) + if (!BIT128_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_L3)) return false; - if (!RARCH_INPUT_STATE_BIT_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_R3)) + if (!BIT128_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_R3)) return false; break; case INPUT_TOGGLE_L1_R1_START_SELECT: - if (!RARCH_INPUT_STATE_BIT_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_START)) + if (!BIT128_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_START)) return false; - if (!RARCH_INPUT_STATE_BIT_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_SELECT)) + if (!BIT128_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_SELECT)) return false; - if (!RARCH_INPUT_STATE_BIT_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_L)) + if (!BIT128_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_L)) return false; - if (!RARCH_INPUT_STATE_BIT_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_R)) + if (!BIT128_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_R)) return false; break; case INPUT_TOGGLE_START_SELECT: - if (!RARCH_INPUT_STATE_BIT_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_START)) + if (!BIT128_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_START)) return false; - if (!RARCH_INPUT_STATE_BIT_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_SELECT)) + if (!BIT128_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_SELECT)) return false; break; default: @@ -2375,7 +2375,7 @@ static enum runloop_state runloop_check_state( retro_bits_t current_input; - if ( menu_is_alive && !(settings->bools.menu_unified_controls && !menu_input_dialog_get_display_kb()) ) + if (menu_is_alive && !(settings->bools.menu_unified_controls && !menu_input_dialog_get_display_kb())) input_menu_keys_pressed(settings, ¤t_input); else input_keys_pressed(settings, ¤t_input); @@ -2391,9 +2391,7 @@ static enum runloop_state runloop_check_state( ((settings->uints.input_menu_toggle_gamepad_combo != INPUT_TOGGLE_NONE) && input_driver_toggle_button_combo( settings->uints.input_menu_toggle_gamepad_combo, &last_input))) - { - RARCH_INPUT_STATE_BIT_SET(current_input, RARCH_MENU_TOGGLE); - } + BIT128_SET(current_input, RARCH_MENU_TOGGLE); #endif if (input_driver_flushing_input) @@ -2401,9 +2399,9 @@ static enum runloop_state runloop_check_state( input_driver_flushing_input = false; if (RARCH_INPUT_STATE_ANY_SET(current_input)) { - RARCH_INPUT_STATE_CLEAR( current_input ); + BIT128_CLEAR_ALL(current_input); if (runloop_paused) - RARCH_INPUT_STATE_BIT_SET(current_input, RARCH_PAUSE_TOGGLE); + BIT128_SET(current_input, RARCH_PAUSE_TOGGLE); input_driver_flushing_input = true; } } @@ -2412,14 +2410,14 @@ static enum runloop_state runloop_check_state( #ifdef HAVE_MENU if (menu_driver_binding_state) - RARCH_INPUT_STATE_CLEAR( current_input ); + BIT128_CLEAR_ALL(current_input); #endif #ifdef HAVE_OVERLAY /* Check next overlay */ { static bool old_should_check_next_overlay = false; - bool should_check_next_overlay = runloop_cmd_press( + bool should_check_next_overlay = BIT128_GET( current_input, RARCH_OVERLAY_NEXT); if (should_check_next_overlay && !old_should_check_next_overlay) @@ -2431,7 +2429,7 @@ static enum runloop_state runloop_check_state( /* Check fullscreen toggle */ { - bool fs_toggle_pressed = runloop_cmd_press( + bool fs_toggle_pressed = BIT128_GET( current_input, RARCH_FULLSCREEN_TOGGLE_KEY); fs_toggle_triggered = fs_toggle_pressed && !old_fs_toggle_pressed; @@ -2454,7 +2452,7 @@ static enum runloop_state runloop_check_state( /* Check mouse grab toggle */ { static bool old_pressed = false; - bool pressed = runloop_cmd_press( + bool pressed = BIT128_GET( current_input, RARCH_GRAB_MOUSE_TOGGLE); if (pressed && !old_pressed) @@ -2489,7 +2487,7 @@ static enum runloop_state runloop_check_state( /* Check quit key */ { static bool old_quit_key = false; - bool quit_key = runloop_cmd_press( + bool quit_key = BIT128_GET( current_input, RARCH_QUIT_KEY); bool trig_quit_key = quit_key && !old_quit_key; @@ -2544,7 +2542,7 @@ static enum runloop_state runloop_check_state( bool focused; trigger_input = current_input; - RARCH_INPUT_STATE_CLEAR_BITS( trigger_input, old_input ); + RARCH_INPUT_STATE_CLEAR_BITS(trigger_input, old_input); action = (enum menu_action)menu_event(¤t_input, &trigger_input); focused = pause_nonactive ? is_focused : true; @@ -2583,7 +2581,7 @@ static enum runloop_state runloop_check_state( /* Check game focus toggle */ { static bool old_pressed = false; - bool pressed = runloop_cmd_press( + bool pressed = BIT128_GET( current_input, RARCH_GAME_FOCUS_TOGGLE); if (pressed && !old_pressed) @@ -2596,7 +2594,7 @@ static enum runloop_state runloop_check_state( /* Check menu toggle */ { static bool old_pressed = false; - bool pressed = runloop_cmd_press( + bool pressed = BIT128_GET( current_input, RARCH_MENU_TOGGLE); if (menu_event_kb_is_set(RETROK_F1) == 1) @@ -2646,7 +2644,7 @@ static enum runloop_state runloop_check_state( /* Check screenshot toggle */ { static bool old_pressed = false; - bool pressed = runloop_cmd_press( + bool pressed = BIT128_GET( current_input, RARCH_SCREENSHOT); if (pressed && old_pressed) @@ -2658,7 +2656,7 @@ static enum runloop_state runloop_check_state( /* Check audio mute toggle */ { static bool old_pressed = false; - bool pressed = runloop_cmd_press( + bool pressed = BIT128_GET( current_input, RARCH_MUTE); if (pressed && !old_pressed) @@ -2670,8 +2668,7 @@ static enum runloop_state runloop_check_state( /* Check OSK toggle */ { static bool old_pressed = false; - bool pressed = runloop_cmd_press( - current_input, RARCH_OSK); + bool pressed = BIT128_GET(current_input, RARCH_OSK); if (pressed && !old_pressed) { @@ -2687,9 +2684,9 @@ static enum runloop_state runloop_check_state( old_pressed = pressed; } - if (runloop_cmd_press(current_input, RARCH_VOLUME_UP)) + if (BIT128_GET(current_input, RARCH_VOLUME_UP)) command_event(CMD_EVENT_VOLUME_UP, NULL); - else if (runloop_cmd_press(current_input, RARCH_VOLUME_DOWN)) + else if (BIT128_GET(current_input, RARCH_VOLUME_DOWN)) command_event(CMD_EVENT_VOLUME_DOWN, NULL); #ifdef HAVE_NETWORKING @@ -2697,9 +2694,9 @@ static enum runloop_state runloop_check_state( { static bool old_netplay_flip = false; static bool old_netplay_watch = false; - bool netplay_flip = runloop_cmd_press( + bool netplay_flip = BIT128_GET( current_input, RARCH_NETPLAY_FLIP); - bool netplay_watch = runloop_cmd_press( + bool netplay_watch = BIT128_GET( current_input, RARCH_NETPLAY_GAME_WATCH); if (netplay_flip && !old_netplay_flip) @@ -2718,9 +2715,9 @@ static enum runloop_state runloop_check_state( static bool old_frameadvance = false; static bool old_pause_pressed = false; bool check_is_oneshot = true; - bool frameadvance_pressed = runloop_cmd_press( + bool frameadvance_pressed = BIT128_GET( current_input, RARCH_FRAMEADVANCE); - bool pause_pressed = runloop_cmd_press( + bool pause_pressed = BIT128_GET( current_input, RARCH_PAUSE_TOGGLE); bool trig_frameadvance = frameadvance_pressed && !old_frameadvance; @@ -2744,7 +2741,7 @@ static enum runloop_state runloop_check_state( if (runloop_paused) { check_is_oneshot = trig_frameadvance || - runloop_cmd_press(current_input, RARCH_REWIND); + BIT128_GET(current_input, RARCH_REWIND); if (fs_toggle_triggered) { @@ -2769,9 +2766,9 @@ static enum runloop_state runloop_check_state( { static bool old_button_state = false; static bool old_hold_button_state = false; - bool new_button_state = runloop_cmd_press( + bool new_button_state = BIT128_GET( current_input, RARCH_FAST_FORWARD_KEY); - bool new_hold_button_state = runloop_cmd_press( + bool new_hold_button_state = BIT128_GET( current_input, RARCH_FAST_FORWARD_HOLD_KEY); if (new_button_state && !old_button_state) @@ -2812,9 +2809,9 @@ static enum runloop_state runloop_check_state( { static bool old_should_slot_increase = false; static bool old_should_slot_decrease = false; - bool should_slot_increase = runloop_cmd_press( + bool should_slot_increase = BIT128_GET( current_input, RARCH_STATE_SLOT_PLUS); - bool should_slot_decrease = runloop_cmd_press( + bool should_slot_decrease = BIT128_GET( current_input, RARCH_STATE_SLOT_MINUS); /* Checks if the state increase/decrease keys have been pressed @@ -2865,9 +2862,9 @@ static enum runloop_state runloop_check_state( { static bool old_should_savestate = false; static bool old_should_loadstate = false; - bool should_savestate = runloop_cmd_press( + bool should_savestate = BIT128_GET( current_input, RARCH_SAVE_STATE_KEY); - bool should_loadstate = runloop_cmd_press( + bool should_loadstate = BIT128_GET( current_input, RARCH_LOAD_STATE_KEY); if (should_savestate && !old_should_savestate) @@ -2888,14 +2885,14 @@ static enum runloop_state runloop_check_state( s[0] = '\0'; - if (state_manager_check_rewind(runloop_cmd_press(current_input, RARCH_REWIND), + if (state_manager_check_rewind(BIT128_GET(current_input, RARCH_REWIND), settings->uints.rewind_granularity, runloop_paused, s, sizeof(s), &t)) runloop_msg_queue_push(s, 0, t, true); } /* Checks if slowmotion toggle/hold was being pressed and/or held. */ { - runloop_slowmotion = runloop_cmd_press(current_input, RARCH_SLOWMOTION); + runloop_slowmotion = BIT128_GET(current_input, RARCH_SLOWMOTION); if (runloop_slowmotion) { @@ -2917,7 +2914,7 @@ static enum runloop_state runloop_check_state( /* Check movie record toggle */ { static bool old_pressed = false; - bool pressed = runloop_cmd_press( + bool pressed = BIT128_GET( current_input, RARCH_MOVIE_RECORD_TOGGLE); if (pressed && !old_pressed) @@ -2930,9 +2927,9 @@ static enum runloop_state runloop_check_state( { static bool old_shader_next = false; static bool old_shader_prev = false; - bool shader_next = runloop_cmd_press( + bool shader_next = BIT128_GET( current_input, RARCH_SHADER_NEXT); - bool shader_prev = runloop_cmd_press( + bool shader_prev = BIT128_GET( current_input, RARCH_SHADER_PREV); bool trig_shader_next = shader_next && !old_shader_next; bool trig_shader_prev = shader_prev && !old_shader_prev; @@ -2949,11 +2946,11 @@ static enum runloop_state runloop_check_state( static bool old_disk_eject = false; static bool old_disk_next = false; static bool old_disk_prev = false; - bool disk_eject = runloop_cmd_press( + bool disk_eject = BIT128_GET( current_input, RARCH_DISK_EJECT_TOGGLE); - bool disk_next = runloop_cmd_press( + bool disk_next = BIT128_GET( current_input, RARCH_DISK_NEXT); - bool disk_prev = runloop_cmd_press( + bool disk_prev = BIT128_GET( current_input, RARCH_DISK_PREV); if (disk_eject && !old_disk_eject) @@ -2971,7 +2968,7 @@ static enum runloop_state runloop_check_state( /* Check reset */ { static bool old_state = false; - bool new_state = runloop_cmd_press( + bool new_state = BIT128_GET( current_input, RARCH_RESET); if (new_state && !old_state) @@ -2985,11 +2982,11 @@ static enum runloop_state runloop_check_state( static bool old_cheat_index_plus = false; static bool old_cheat_index_minus = false; static bool old_cheat_index_toggle = false; - bool cheat_index_plus = runloop_cmd_press( + bool cheat_index_plus = BIT128_GET( current_input, RARCH_CHEAT_INDEX_PLUS); - bool cheat_index_minus = runloop_cmd_press( + bool cheat_index_minus = BIT128_GET( current_input, RARCH_CHEAT_INDEX_MINUS); - bool cheat_index_toggle = runloop_cmd_press( + bool cheat_index_toggle = BIT128_GET( current_input, RARCH_CHEAT_TOGGLE); if (cheat_index_plus && !old_cheat_index_plus) diff --git a/retroarch.h b/retroarch.h index 3cd1b742d3..6c45f744c1 100644 --- a/retroarch.h +++ b/retroarch.h @@ -27,8 +27,6 @@ #include "core_type.h" #include "core.h" -#define runloop_cmd_press(current_input, id) (RARCH_INPUT_STATE_BIT_GET(current_input, id)) - RETRO_BEGIN_DECLS enum rarch_ctl_state From 31cc6a8dd769707dfc009d5980335abafde9bdbd Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 5 Dec 2017 09:51:58 +0100 Subject: [PATCH 201/394] Create 256 bit macros --- libretro-common/include/retro_miscellaneous.h | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/libretro-common/include/retro_miscellaneous.h b/libretro-common/include/retro_miscellaneous.h index b29c5cdc54..e42f6b345b 100644 --- a/libretro-common/include/retro_miscellaneous.h +++ b/libretro-common/include/retro_miscellaneous.h @@ -87,8 +87,18 @@ #define BIT128_GET_PTR(a, bit) BIT128_GET(*a, bit) #define BIT128_CLEAR_ALL_PTR(a) BIT128_CLEAR_ALL(*a) +#define BIT256_SET(a, bit) BIT128_SET(a, bit) +#define BIT256_CLEAR(a, bit) BIT128_CLEAR(a, bit) +#define BIT256_GET(a, bit) BIT128_GET(a, bit) +#define BIT256_CLEAR_ALL(a) BIT128_CLEAR_ALL(a) + +#define BIT256_SET_PTR(a, bit) BIT256_SET(*a, bit) +#define BIT256_CLEAR_PTR(a, bit) BIT256_CLEAR(*a, bit) +#define BIT256_GET_PTR(a, bit) BIT256_GET(*a, bit) +#define BIT256_CLEAR_ALL_PTR(a) BIT256_CLEAR_ALL(*a) + /* Helper macros and struct to keep track of many booleans. */ -/* This struct has 256 bits, but the macros are named 128 due to some historical accident. */ +/* This struct has 256 bits. */ typedef struct { uint32_t data[8]; From 6c09661a643f02b0bb92b7802e41022b759b166c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 5 Dec 2017 10:42:37 +0100 Subject: [PATCH 202/394] Move defines to retro_miscellaneous.h --- input/connect/connect_nesusb.c | 2 +- input/connect/connect_ps2adapter.c | 2 +- input/connect/connect_ps3.c | 2 +- input/connect/connect_psxadapter.c | 2 +- input/connect/connect_snesusb.c | 2 +- input/connect/connect_wii.c | 6 ++--- input/connect/connect_wiiugca.c | 2 +- input/drivers_joypad/ctr_joypad.c | 2 +- input/drivers_joypad/gx_joypad.c | 2 +- input/drivers_joypad/linuxraw_joypad.c | 2 +- input/drivers_joypad/mfi_joypad.m | 2 +- input/drivers_joypad/parport_joypad.c | 2 +- input/drivers_joypad/ps3_joypad.c | 2 +- input/drivers_joypad/psp_joypad.c | 2 +- input/drivers_joypad/udev_joypad.c | 2 +- input/drivers_joypad/wiiu_joypad.c | 2 +- input/drivers_joypad/xdk_joypad.c | 2 +- input/input_defines.h | 27 ------------------- libretro-common/include/retro_miscellaneous.h | 27 +++++++++++++++++++ menu/menu_event.c | 2 +- retroarch.c | 10 +++---- 21 files changed, 51 insertions(+), 53 deletions(-) diff --git a/input/connect/connect_nesusb.c b/input/connect/connect_nesusb.c index b39936be06..797f83e7ae 100644 --- a/input/connect/connect_nesusb.c +++ b/input/connect/connect_nesusb.c @@ -64,7 +64,7 @@ static void hidpad_nesusb_get_buttons(void *data, retro_bits_t* state) struct hidpad_nesusb_data *device = (struct hidpad_nesusb_data*)data; if (device) { - RARCH_INPUT_STATE_COPY16_PTR(state, device->buttons); + BITS_COPY16_PTR(state, device->buttons); } else BIT128_CLEAR_ALL_PTR(state); diff --git a/input/connect/connect_ps2adapter.c b/input/connect/connect_ps2adapter.c index 29b2c932fe..c79aac8df3 100644 --- a/input/connect/connect_ps2adapter.c +++ b/input/connect/connect_ps2adapter.c @@ -64,7 +64,7 @@ static void hidpad_ps2adapter_get_buttons(void *data, retro_bits_t *state) struct hidpad_ps2adapter_data *device = (struct hidpad_ps2adapter_data*)data; if (device) { - RARCH_INPUT_STATE_COPY16_PTR(state, device->buttons); + BITS_COPY16_PTR(state, device->buttons); } else BIT128_CLEAR_ALL_PTR(state); diff --git a/input/connect/connect_ps3.c b/input/connect/connect_ps3.c index de4e8fa3ec..6ef05f8e4e 100644 --- a/input/connect/connect_ps3.c +++ b/input/connect/connect_ps3.c @@ -111,7 +111,7 @@ static void hidpad_ps3_get_buttons(void *data, retro_bits_t *state) if ( device ) { /*copy first 16 bits - standard RetroPad controls*/ - RARCH_INPUT_STATE_COPY16_PTR(state, device->buttons); + BITS_COPY16_PTR(state, device->buttons); /*PS button?*/ if (device->buttons & 0x10000) diff --git a/input/connect/connect_psxadapter.c b/input/connect/connect_psxadapter.c index a4fcf78587..03193fd606 100644 --- a/input/connect/connect_psxadapter.c +++ b/input/connect/connect_psxadapter.c @@ -64,7 +64,7 @@ static void hidpad_psxadapter_get_buttons(void *data, retro_bits_t *state) struct hidpad_psxadapter_data *device = (struct hidpad_psxadapter_data*)data; if (device) { - RARCH_INPUT_STATE_COPY16_PTR(state, device->buttons); + BITS_COPY16_PTR(state, device->buttons); } else BIT128_CLEAR_ALL_PTR(state); diff --git a/input/connect/connect_snesusb.c b/input/connect/connect_snesusb.c index b7cb594905..51570d82fa 100644 --- a/input/connect/connect_snesusb.c +++ b/input/connect/connect_snesusb.c @@ -65,7 +65,7 @@ static void hidpad_snesusb_get_buttons(void *data, retro_bits_t *state) struct hidpad_snesusb_data *device = (struct hidpad_snesusb_data*)data; if (device) { - RARCH_INPUT_STATE_COPY16_PTR(state, device->buttons); + BITS_COPY16_PTR(state, device->buttons); } else BIT128_CLEAR_ALL_PTR(state); diff --git a/input/connect/connect_wii.c b/input/connect/connect_wii.c index ec4ceaaa72..83ac50d736 100644 --- a/input/connect/connect_wii.c +++ b/input/connect/connect_wii.c @@ -677,9 +677,9 @@ static void hidpad_wii_get_buttons(void *data, retro_bits_t *state) struct connect_wii_wiimote_t* device = (struct connect_wii_wiimote_t*)data; if ( device ) { - uint32_t b; - b = device->btns | (device->exp.cc.classic.btns << 16); /*broken? this doesn't match retropad!!*/ - RARCH_INPUT_STATE_COPY32_PTR(state, b); + /* TODO/FIXME - Broken? this doesn't match retropad! */ + uint32_t b = device->btns | (device->exp.cc.classic.btns << 16); + BITS_COPY32_PTR(state, b); } } diff --git a/input/connect/connect_wiiugca.c b/input/connect/connect_wiiugca.c index 69ceaa0739..cd0ea8b33e 100644 --- a/input/connect/connect_wiiugca.c +++ b/input/connect/connect_wiiugca.c @@ -68,7 +68,7 @@ static void hidpad_wiiugca_get_buttons(void *data, retro_bits_t *state) struct hidpad_wiiugca_data *device = (struct hidpad_wiiugca_data*)data; if (device) { - RARCH_INPUT_STATE_COPY16_PTR(state, device->buttons); + BITS_COPY16_PTR(state, device->buttons); } else BIT128_CLEAR_ALL_PTR(state); diff --git a/input/drivers_joypad/ctr_joypad.c b/input/drivers_joypad/ctr_joypad.c index 7350c71d78..a98fce76fc 100644 --- a/input/drivers_joypad/ctr_joypad.c +++ b/input/drivers_joypad/ctr_joypad.c @@ -74,7 +74,7 @@ static void ctr_joypad_get_buttons(unsigned port_num, retro_bits_t *state) { if ( port_num < MAX_PADS ) { - RARCH_INPUT_STATE_COPY16_PTR( state, pad_state ); + BITS_COPY16_PTR( state, pad_state ); } else BIT128_CLEAR_ALL_PTR(state); diff --git a/input/drivers_joypad/gx_joypad.c b/input/drivers_joypad/gx_joypad.c index 2dc568df78..bccc6f467b 100644 --- a/input/drivers_joypad/gx_joypad.c +++ b/input/drivers_joypad/gx_joypad.c @@ -166,7 +166,7 @@ static void gx_joypad_get_buttons(unsigned port, retro_bits_t *state) { if (port < MAX_PADS) { - RARCH_INPUT_STATE_COPY16_PTR( state, pad_state[port] ); + BITS_COPY16_PTR( state, pad_state[port] ); } else BIT128_CLEAR_ALL_PTR(state); diff --git a/input/drivers_joypad/linuxraw_joypad.c b/input/drivers_joypad/linuxraw_joypad.c index f8cf299464..c43ea0b93a 100644 --- a/input/drivers_joypad/linuxraw_joypad.c +++ b/input/drivers_joypad/linuxraw_joypad.c @@ -331,7 +331,7 @@ static void linuxraw_joypad_get_buttons(unsigned port, retro_bits_t *state) const struct linuxraw_joypad *pad = (const struct linuxraw_joypad*)&linuxraw_pads[port]; if (pad) { - RARCH_INPUT_STATE_COPY16_PTR(state, pad->buttons); + BITS_COPY16_PTR(state, pad->buttons); } else BIT128_CLEAR_ALL_PTR(state); diff --git a/input/drivers_joypad/mfi_joypad.m b/input/drivers_joypad/mfi_joypad.m index 10964893f0..94f56b2147 100644 --- a/input/drivers_joypad/mfi_joypad.m +++ b/input/drivers_joypad/mfi_joypad.m @@ -223,7 +223,7 @@ static bool apple_gamecontroller_joypad_button(unsigned port, uint16_t joykey) static void apple_gamecontroller_joypad_get_buttons(unsigned port, retro_bits_t *state) { - RARCH_INPUT_STATE_COPY16_PTR(state, mfi_buttons[port]); + BITS_COPY16_PTR(state, mfi_buttons[port]); } static int16_t apple_gamecontroller_joypad_axis(unsigned port, uint32_t joyaxis) diff --git a/input/drivers_joypad/parport_joypad.c b/input/drivers_joypad/parport_joypad.c index 61879842c8..f24c2706a5 100644 --- a/input/drivers_joypad/parport_joypad.c +++ b/input/drivers_joypad/parport_joypad.c @@ -345,7 +345,7 @@ static void parport_joypad_get_buttons(unsigned port, retro_bits_t *state) const struct parport_joypad *pad = (const struct parport_joypad*)&parport_pads[port]; if (pad) { - RARCH_INPUT_STATE_COPY16_PTR(state, pad->buttons); + BITS_COPY16_PTR(state, pad->buttons); } else BIT128_CLEAR_ALL_PTR(state); diff --git a/input/drivers_joypad/ps3_joypad.c b/input/drivers_joypad/ps3_joypad.c index cd11cda4b7..f37822642d 100644 --- a/input/drivers_joypad/ps3_joypad.c +++ b/input/drivers_joypad/ps3_joypad.c @@ -72,7 +72,7 @@ static void ps3_joypad_get_buttons(unsigned port_num, retro_bits_t *state) { if (port_num < MAX_PADS) { - RARCH_INPUT_STATE_COPY16_PTR( state, pad_state[port_num] ); + BITS_COPY16_PTR( state, pad_state[port_num] ); } else BIT128_CLEAR_ALL_PTR(state); diff --git a/input/drivers_joypad/psp_joypad.c b/input/drivers_joypad/psp_joypad.c index c86ee65a0b..60ca2daff3 100644 --- a/input/drivers_joypad/psp_joypad.c +++ b/input/drivers_joypad/psp_joypad.c @@ -128,7 +128,7 @@ static void psp_joypad_get_buttons(unsigned port_num, retro_bits_t *state) { if (port_num < PSP_MAX_PADS) { - RARCH_INPUT_STATE_COPY16_PTR( state, pad_state[port_num] ); + BITS_COPY16_PTR( state, pad_state[port_num] ); } else BIT128_CLEAR_ALL_PTR(state); diff --git a/input/drivers_joypad/udev_joypad.c b/input/drivers_joypad/udev_joypad.c index 50cfec8f20..283e1bd38b 100644 --- a/input/drivers_joypad/udev_joypad.c +++ b/input/drivers_joypad/udev_joypad.c @@ -609,7 +609,7 @@ static void udev_joypad_get_buttons(unsigned port, retro_bits_t *state) const struct udev_joypad *pad = (const struct udev_joypad*)&udev_pads[port]; if (pad) { - RARCH_INPUT_STATE_COPY16_PTR( state, pad->buttons ); + BITS_COPY16_PTR( state, pad->buttons ); } else BIT128_CLEAR_ALL_PTR(state); diff --git a/input/drivers_joypad/wiiu_joypad.c b/input/drivers_joypad/wiiu_joypad.c index 67f8708b25..8a3d8189db 100644 --- a/input/drivers_joypad/wiiu_joypad.c +++ b/input/drivers_joypad/wiiu_joypad.c @@ -139,7 +139,7 @@ static void wiiu_joypad_get_buttons(unsigned port_num, retro_bits_t *state) { if (port_num < MAX_PADS) { - RARCH_INPUT_STATE_COPY16_PTR( state, pad_state[port_num] ); + BITS_COPY16_PTR( state, pad_state[port_num] ); } else BIT128_CLAR_ALL_PTR(state); diff --git a/input/drivers_joypad/xdk_joypad.c b/input/drivers_joypad/xdk_joypad.c index 92fa8b02eb..6553346160 100644 --- a/input/drivers_joypad/xdk_joypad.c +++ b/input/drivers_joypad/xdk_joypad.c @@ -80,7 +80,7 @@ static void xdk_joypad_get_buttons(unsigned port_num, retro_bits_t *state) { if (port_num < MAX_PADS) { - RARCH_INPUT_STATE_COPY16_PTR( state, pad_state[port_num] ); + BITS_COPY16_PTR( state, pad_state[port_num] ); } else BIT128_CLEAR_ALL_PTR(state); diff --git a/input/input_defines.h b/input/input_defines.h index 489122d3b1..b005e90f58 100644 --- a/input/input_defines.h +++ b/input/input_defines.h @@ -158,33 +158,6 @@ enum analog_dpad_mode #define GET_HAT_DIR(x) (x & HAT_MASK) #define GET_HAT(x) (x & (~HAT_MASK)) -#define RARCH_INPUT_STATE_ANY_SET(a) ( ((a).data[0])||((a).data[1])||((a).data[2])||((a).data[3])|| \ - ((a).data[4])||((a).data[5])||((a).data[6])||((a).data[7]) ) -#define RARCH_INPUT_STATE_ANY_SET_PTR(a) ( ((a)->data[0])||((a)->data[1])||((a)->data[2])||((a)->data[3])|| \ - ((a)->data[4])||((a)->data[5])||((a)->data[6])||((a)->data[7]) ) -#define RARCH_INPUT_STATE_CLEAR_BITS(a,b) \ - ((a).data[0])&=(~((b).data[0])); \ - ((a).data[1])&=(~((b).data[1])); \ - ((a).data[2])&=(~((b).data[2])); \ - ((a).data[3])&=(~((b).data[3])); \ - ((a).data[4])&=(~((b).data[4])); \ - ((a).data[5])&=(~((b).data[5])); \ - ((a).data[6])&=(~((b).data[6])); \ - ((a).data[7])&=(~((b).data[7])); - -#define RARCH_INPUT_STATE_COPY16_PTR(a,bits) \ -{ \ - BIT128_CLEAR_ALL_PTR(a); \ - ((a)->data[0] = (bits) & 0xffff); \ -} - -#define RARCH_INPUT_STATE_COPY32_PTR(a,bits) \ -{ \ - BIT128_CLEAR_ALL_PTR(a); \ - ((a)->data[0] = (bits)); \ -} - - RETRO_END_DECLS #endif diff --git a/libretro-common/include/retro_miscellaneous.h b/libretro-common/include/retro_miscellaneous.h index e42f6b345b..c69afed90b 100644 --- a/libretro-common/include/retro_miscellaneous.h +++ b/libretro-common/include/retro_miscellaneous.h @@ -58,6 +58,33 @@ #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) +#define BITS_ANY_SET(a) ( ((a).data[0])||((a).data[1])||((a).data[2])||((a).data[3])|| \ + ((a).data[4])||((a).data[5])||((a).data[6])||((a).data[7]) ) +#define BITS_ANY_SET_PTR(a) ( ((a)->data[0])||((a)->data[1])||((a)->data[2])||((a)->data[3])|| \ + ((a)->data[4])||((a)->data[5])||((a)->data[6])||((a)->data[7]) ) +#define BITS_CLEAR_BITS(a,b) \ + ((a).data[0])&=(~((b).data[0])); \ + ((a).data[1])&=(~((b).data[1])); \ + ((a).data[2])&=(~((b).data[2])); \ + ((a).data[3])&=(~((b).data[3])); \ + ((a).data[4])&=(~((b).data[4])); \ + ((a).data[5])&=(~((b).data[5])); \ + ((a).data[6])&=(~((b).data[6])); \ + ((a).data[7])&=(~((b).data[7])); + +#define BITS_COPY16_PTR(a,bits) \ +{ \ + BIT128_CLEAR_ALL_PTR(a); \ + ((a)->data[0] = (bits) & 0xffff); \ +} + +#define BITS_COPY32_PTR(a,bits) \ +{ \ + BIT128_CLEAR_ALL_PTR(a); \ + ((a)->data[0] = (bits)); \ +} + + #define BIT_SET(a, bit) ((a)[(bit) >> 3] |= (1 << ((bit) & 7))) #define BIT_CLEAR(a, bit) ((a)[(bit) >> 3] &= ~(1 << ((bit) & 7))) #define BIT_GET(a, bit) (((a).data[(bit) >> 3] >> ((bit) & 7)) & 1) diff --git a/menu/menu_event.c b/menu/menu_event.c index 6af08b3e5a..a492aca726 100644 --- a/menu/menu_event.c +++ b/menu/menu_event.c @@ -165,7 +165,7 @@ unsigned menu_event(retro_bits_t* p_input, retro_bits_t* p_trigger_input) ok_old = ok_current; - if (RARCH_INPUT_STATE_ANY_SET_PTR(p_input)) + if (BITS_ANY_SET_PTR(p_input)) { if (!first_held) { diff --git a/retroarch.c b/retroarch.c index f9d7b6aae9..d7a2d3170a 100644 --- a/retroarch.c +++ b/retroarch.c @@ -2397,7 +2397,7 @@ static enum runloop_state runloop_check_state( if (input_driver_flushing_input) { input_driver_flushing_input = false; - if (RARCH_INPUT_STATE_ANY_SET(current_input)) + if (BITS_ANY_SET(current_input)) { BIT128_CLEAR_ALL(current_input); if (runloop_paused) @@ -2537,12 +2537,10 @@ static enum runloop_state runloop_check_state( retro_ctx.poll_cb(); { - retro_bits_t trigger_input; enum menu_action action; - bool focused; - - trigger_input = current_input; - RARCH_INPUT_STATE_CLEAR_BITS(trigger_input, old_input); + bool focused = false; + retro_bits_t trigger_input = current_input; + BITS_CLEAR_BITS(trigger_input, old_input); action = (enum menu_action)menu_event(¤t_input, &trigger_input); focused = pause_nonactive ? is_focused : true; From f0c143766e38fb49d8871125bbfa147b7dcc3f5b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 5 Dec 2017 12:07:35 +0100 Subject: [PATCH 203/394] Change to 256bit macros --- audio/drivers/xaudio.h | 11 +-- input/connect/connect_nesusb.c | 2 +- input/connect/connect_ps2adapter.c | 2 +- input/connect/connect_ps3.c | 4 +- input/connect/connect_ps4.c | 36 ++++----- input/connect/connect_psxadapter.c | 2 +- input/connect/connect_snesusb.c | 2 +- input/connect/connect_wiiugca.c | 2 +- input/connect/connect_wiiupro.c | 36 ++++----- input/connect/joypad_connection.c | 4 +- input/drivers/cocoa_input.c | 2 +- input/drivers/wiiu_input.c | 2 +- input/drivers/winraw_input.c | 3 +- input/drivers_hid/btstack_hid.c | 4 +- input/drivers_hid/iohidmanager_hid.c | 4 +- input/drivers_hid/libusb_hid.c | 11 ++- input/drivers_hid/null_hid.c | 2 +- input/drivers_hid/wiiusb_hid.c | 10 ++- input/drivers_joypad/ctr_joypad.c | 2 +- input/drivers_joypad/gx_joypad.c | 2 +- input/drivers_joypad/hid_joypad.c | 2 +- input/drivers_joypad/linuxraw_joypad.c | 2 +- input/drivers_joypad/null_joypad.c | 2 +- input/drivers_joypad/parport_joypad.c | 2 +- input/drivers_joypad/ps3_joypad.c | 2 +- input/drivers_joypad/psp_joypad.c | 2 +- input/drivers_joypad/udev_joypad.c | 2 +- input/drivers_joypad/wiiu_joypad.c | 2 +- input/drivers_joypad/xdk_joypad.c | 2 +- input/input_driver.c | 26 +++--- menu/menu_event.c | 48 +++++------ retroarch.c | 106 ++++++++++++------------- 32 files changed, 168 insertions(+), 173 deletions(-) diff --git a/audio/drivers/xaudio.h b/audio/drivers/xaudio.h index 41e21be09d..266f89a59c 100644 --- a/audio/drivers/xaudio.h +++ b/audio/drivers/xaudio.h @@ -324,16 +324,11 @@ STDAPI XAudio2Create(__deref_out IXAudio2** ppXAudio2, UINT32 Flags X2DEFAULT(0) #else static INLINE HRESULT XAudio2Create(IXAudio2 **ppXAudio2, UINT32 flags, XAUDIO2_PROCESSOR proc) { - HRESULT hr; IXAudio2 *pXAudio2 = NULL; - - (void)flags; - (void)proc; - #ifdef __cplusplus - hr = CoCreateInstance(CLSID_XAudio2, NULL, CLSCTX_INPROC_SERVER, IID_IXAudio2, (void**)&pXAudio2); + HRESULT hr = CoCreateInstance(CLSID_XAudio2, NULL, CLSCTX_INPROC_SERVER, IID_IXAudio2, (void**)&pXAudio2); #else - hr = CoCreateInstance(&CLSID_XAudio2, NULL, CLSCTX_INPROC_SERVER, &IID_IXAudio2, (void**)&pXAudio2); + HRESULT hr = CoCreateInstance(&CLSID_XAudio2, NULL, CLSCTX_INPROC_SERVER, &IID_IXAudio2, (void**)&pXAudio2); #endif if (SUCCEEDED(hr)) @@ -342,9 +337,7 @@ static INLINE HRESULT XAudio2Create(IXAudio2 **ppXAudio2, UINT32 flags, XAUDIO2_ if (SUCCEEDED(hr)) *ppXAudio2 = pXAudio2; else - { IXAudio2_Release(pXAudio2); - } } return hr; } diff --git a/input/connect/connect_nesusb.c b/input/connect/connect_nesusb.c index 797f83e7ae..bf21fbb901 100644 --- a/input/connect/connect_nesusb.c +++ b/input/connect/connect_nesusb.c @@ -67,7 +67,7 @@ static void hidpad_nesusb_get_buttons(void *data, retro_bits_t* state) BITS_COPY16_PTR(state, device->buttons); } else - BIT128_CLEAR_ALL_PTR(state); + BIT256_CLEAR_ALL_PTR(state); } static int16_t hidpad_nesusb_get_axis(void *data, unsigned axis) diff --git a/input/connect/connect_ps2adapter.c b/input/connect/connect_ps2adapter.c index c79aac8df3..87b174bd4e 100644 --- a/input/connect/connect_ps2adapter.c +++ b/input/connect/connect_ps2adapter.c @@ -67,7 +67,7 @@ static void hidpad_ps2adapter_get_buttons(void *data, retro_bits_t *state) BITS_COPY16_PTR(state, device->buttons); } else - BIT128_CLEAR_ALL_PTR(state); + BIT256_CLEAR_ALL_PTR(state); } static int16_t hidpad_ps2adapter_get_axis(void *data, unsigned axis) diff --git a/input/connect/connect_ps3.c b/input/connect/connect_ps3.c index 6ef05f8e4e..7e96e5a7f4 100644 --- a/input/connect/connect_ps3.c +++ b/input/connect/connect_ps3.c @@ -115,10 +115,10 @@ static void hidpad_ps3_get_buttons(void *data, retro_bits_t *state) /*PS button?*/ if (device->buttons & 0x10000) - BIT128_SET_PTR(state, RARCH_MENU_TOGGLE); + BIT256_SET_PTR(state, RARCH_MENU_TOGGLE); } else - BIT128_CLEAR_ALL_PTR(state); + BIT256_CLEAR_ALL_PTR(state); } static int16_t hidpad_ps3_get_axis(void *data, unsigned axis) diff --git a/input/connect/connect_ps4.c b/input/connect/connect_ps4.c index 901e693d80..dcdd88a41e 100644 --- a/input/connect/connect_ps4.c +++ b/input/connect/connect_ps4.c @@ -194,42 +194,42 @@ static void hidpad_ps4_get_buttons(void *data, retro_bits_t* state) if (!device || !rpt) return; - BIT128_CLEAR_ALL_PTR( state ); + BIT256_CLEAR_ALL_PTR( state ); if (rpt->btn.r3) - BIT128_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_R3 ); + BIT256_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_R3 ); if (rpt->btn.l3) - BIT128_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_L3 ); + BIT256_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_L3 ); if (rpt->btn.options) - BIT128_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_START ); + BIT256_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_START ); if ( rpt->btn.share) - BIT128_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_SELECT ); + BIT256_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_SELECT ); if ( rpt->btn.r2) - BIT128_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_R2 ); + BIT256_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_R2 ); if (rpt->btn.l2) - BIT128_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_L2 ); + BIT256_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_L2 ); if (rpt->btn.r1) - BIT128_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_R ); + BIT256_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_R ); if (rpt->btn.l1) - BIT128_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_L ); + BIT256_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_L ); if (rpt->btn.triangle) - BIT128_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_X ); + BIT256_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_X ); if (rpt->btn.circle) - BIT128_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_A ); + BIT256_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_A ); if (rpt->btn.cross) - BIT128_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_B ); + BIT256_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_B ); if (rpt->btn.square) - BIT128_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_Y ); + BIT256_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_Y ); if ((hidpad_ps4_check_dpad(rpt, RETRO_DEVICE_ID_JOYPAD_LEFT))) - BIT128_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_LEFT ); + BIT256_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_LEFT ); if ((hidpad_ps4_check_dpad(rpt, RETRO_DEVICE_ID_JOYPAD_DOWN))) - BIT128_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_DOWN ); + BIT256_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_DOWN ); if ((hidpad_ps4_check_dpad(rpt, RETRO_DEVICE_ID_JOYPAD_RIGHT))) - BIT128_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_RIGHT ); + BIT256_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_RIGHT ); if ((hidpad_ps4_check_dpad(rpt, RETRO_DEVICE_ID_JOYPAD_UP))) - BIT128_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_UP ); + BIT256_SET_PTR( state, RETRO_DEVICE_ID_JOYPAD_UP ); if (rpt->btn.ps) - BIT128_SET_PTR( state, RARCH_MENU_TOGGLE ); + BIT256_SET_PTR( state, RARCH_MENU_TOGGLE ); } static int16_t hidpad_ps4_get_axis(void *data, unsigned axis) diff --git a/input/connect/connect_psxadapter.c b/input/connect/connect_psxadapter.c index 03193fd606..b9d2e7f9ba 100644 --- a/input/connect/connect_psxadapter.c +++ b/input/connect/connect_psxadapter.c @@ -67,7 +67,7 @@ static void hidpad_psxadapter_get_buttons(void *data, retro_bits_t *state) BITS_COPY16_PTR(state, device->buttons); } else - BIT128_CLEAR_ALL_PTR(state); + BIT256_CLEAR_ALL_PTR(state); } static int16_t hidpad_psxadapter_get_axis(void *data, unsigned axis) diff --git a/input/connect/connect_snesusb.c b/input/connect/connect_snesusb.c index 51570d82fa..62759b51fb 100644 --- a/input/connect/connect_snesusb.c +++ b/input/connect/connect_snesusb.c @@ -68,7 +68,7 @@ static void hidpad_snesusb_get_buttons(void *data, retro_bits_t *state) BITS_COPY16_PTR(state, device->buttons); } else - BIT128_CLEAR_ALL_PTR(state); + BIT256_CLEAR_ALL_PTR(state); } static int16_t hidpad_snesusb_get_axis(void *data, unsigned axis) diff --git a/input/connect/connect_wiiugca.c b/input/connect/connect_wiiugca.c index cd0ea8b33e..5705a7acdf 100644 --- a/input/connect/connect_wiiugca.c +++ b/input/connect/connect_wiiugca.c @@ -71,7 +71,7 @@ static void hidpad_wiiugca_get_buttons(void *data, retro_bits_t *state) BITS_COPY16_PTR(state, device->buttons); } else - BIT128_CLEAR_ALL_PTR(state); + BIT256_CLEAR_ALL_PTR(state); } static int16_t hidpad_wiiugca_get_axis(void *data, unsigned axis) diff --git a/input/connect/connect_wiiupro.c b/input/connect/connect_wiiupro.c index b7e148a010..6356fc94fa 100644 --- a/input/connect/connect_wiiupro.c +++ b/input/connect/connect_wiiupro.c @@ -127,42 +127,42 @@ static void hidpad_wiiupro_get_buttons(void *data, retro_bits_t *state) if (!device || !rpt) return; - BIT128_CLEAR_ALL_PTR(state); + BIT256_CLEAR_ALL_PTR(state); if (rpt->btn.r3) - BIT128_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_R3); + BIT256_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_R3); if (rpt->btn.l3) - BIT128_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_L3); + BIT256_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_L3); if (rpt->btn.plus) - BIT128_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_START); + BIT256_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_START); if ( rpt->btn.minus) - BIT128_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_SELECT); + BIT256_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_SELECT); if ( rpt->btn.zr) - BIT128_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_R2); + BIT256_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_R2); if ( rpt->btn.zl) - BIT128_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_L2); + BIT256_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_L2); if ( rpt->btn.r) - BIT128_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_R); + BIT256_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_R); if ( rpt->btn.l) - BIT128_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_L); + BIT256_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_L); if ( rpt->btn.x) - BIT128_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_X); + BIT256_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_X); if ( rpt->btn.a) - BIT128_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_A); + BIT256_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_A); if ( rpt->btn.b) - BIT128_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_B); + BIT256_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_B); if ( rpt->btn.y) - BIT128_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_Y); + BIT256_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_Y); if ( rpt->btn.left) - BIT128_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_LEFT); + BIT256_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_LEFT); if ( rpt->btn.down) - BIT128_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_DOWN); + BIT256_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_DOWN); if ( rpt->btn.right) - BIT128_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_RIGHT); + BIT256_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_RIGHT); if ( rpt->btn.up) - BIT128_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_UP); + BIT256_SET_PTR(state, RETRO_DEVICE_ID_JOYPAD_UP); if ( rpt->btn.home) - BIT128_SET_PTR(state, RARCH_MENU_TOGGLE); + BIT256_SET_PTR(state, RARCH_MENU_TOGGLE); } static int16_t hidpad_wiiupro_get_axis(void *data, unsigned axis) diff --git a/input/connect/joypad_connection.c b/input/connect/joypad_connection.c index 178d32fcd2..90cb9cf06b 100644 --- a/input/connect/joypad_connection.c +++ b/input/connect/joypad_connection.c @@ -176,11 +176,9 @@ void pad_connection_packet(joypad_connection_t *joyconn, uint32_t pad, void pad_connection_get_buttons(joypad_connection_t *joyconn, unsigned pad, retro_bits_t* state) { if (joyconn->iface) - { joyconn->iface->get_buttons(joyconn->data, state); - } else - BIT128_CLEAR_ALL_PTR( state ); + BIT256_CLEAR_ALL_PTR( state ); } int16_t pad_connection_get_axis(joypad_connection_t *joyconn, diff --git a/input/drivers/cocoa_input.c b/input/drivers/cocoa_input.c index 2ce55ddb38..f14932ab23 100644 --- a/input/drivers/cocoa_input.c +++ b/input/drivers/cocoa_input.c @@ -59,7 +59,7 @@ static int cocoa_input_find_any_button_ret(cocoa_input_data_t *apple, if (state) for (i = 0; i < 256; i++) - if (BIT128_GET_PTR(state,i)) + if (BIT256_GET_PTR(state,i)) return i; return -1; } diff --git a/input/drivers/wiiu_input.c b/input/drivers/wiiu_input.c index 99d8087e65..7bf5a752e0 100644 --- a/input/drivers/wiiu_input.c +++ b/input/drivers/wiiu_input.c @@ -108,7 +108,7 @@ static int16_t wiiu_pointer_device_state(wiiu_input_t* wiiu, unsigned id) { retro_bits_t state; wiiu->joypad->get_buttons(0, &state); - return BIT128_GET(state, VPAD_BUTTON_TOUCH) ? 1 : 0; + return BIT256_GET(state, VPAD_BUTTON_TOUCH) ? 1 : 0; } case RETRO_DEVICE_ID_POINTER_X: return wiiu->joypad->axis(0, 0xFFFF0004UL); diff --git a/input/drivers/winraw_input.c b/input/drivers/winraw_input.c index 31f86cadb5..fa6011291d 100644 --- a/input/drivers/winraw_input.c +++ b/input/drivers/winraw_input.c @@ -356,9 +356,8 @@ static bool winraw_keyboard_pressed(winraw_input_t *wr, unsigned key) static bool winraw_mbutton_pressed(winraw_input_t *wr, unsigned port, unsigned key) { unsigned i; - bool result; winraw_mouse_t *mouse = NULL; - settings_t *settings = config_get_ptr(); + settings_t *settings = config_get_ptr(); if (port >= MAX_USERS) return false; diff --git a/input/drivers_hid/btstack_hid.c b/input/drivers_hid/btstack_hid.c index 2166a2d2a3..9946e1f6dc 100644 --- a/input/drivers_hid/btstack_hid.c +++ b/input/drivers_hid/btstack_hid.c @@ -1370,7 +1370,7 @@ static void btstack_hid_joypad_get_buttons(void *data, unsigned port, retro_bits if (hid) pad_connection_get_buttons(&hid->slots[port], port, state); else - BIT128_CLEAR_ALL_PTR(state); + BIT256_CLEAR_ALL_PTR(state); } static bool btstack_hid_joypad_button(void *data, unsigned port, uint16_t joykey) @@ -1384,7 +1384,7 @@ static bool btstack_hid_joypad_button(void *data, unsigned port, uint16_t joykey /* Check the button. */ if ((port < MAX_USERS) && (joykey < 32)) - return (BIT128_GET(buttons, joykey) != 0); + return (BIT256_GET(buttons, joykey) != 0); return false; } diff --git a/input/drivers_hid/iohidmanager_hid.c b/input/drivers_hid/iohidmanager_hid.c index 3d479fce40..8f4e0cb71b 100644 --- a/input/drivers_hid/iohidmanager_hid.c +++ b/input/drivers_hid/iohidmanager_hid.c @@ -114,7 +114,7 @@ static void iohidmanager_hid_joypad_get_buttons(void *data, unsigned port, retro if (hid) return pad_connection_get_buttons(&hid->slots[port], port, state); else - BIT128_CLEAR_ALL_PTR(state); + BIT256_CLEAR_ALL_PTR(state); } static bool iohidmanager_hid_joypad_button(void *data, @@ -150,7 +150,7 @@ static bool iohidmanager_hid_joypad_button(void *data, /* Check the button. */ if ((port < MAX_USERS) && (joykey < 32)) - return (BIT128_GET(buttons, joykey) != 0) + return (BIT256_GET(buttons, joykey) != 0) || ((hid->buttons[port] & (1 << joykey)) != 0); return false; diff --git a/input/drivers_hid/libusb_hid.c b/input/drivers_hid/libusb_hid.c index a653b6b9bc..f2fd6d0bca 100644 --- a/input/drivers_hid/libusb_hid.c +++ b/input/drivers_hid/libusb_hid.c @@ -447,9 +447,12 @@ static void libusb_hid_joypad_get_buttons(void *data, unsigned port, retro_bits_ { libusb_hid_t *hid = (libusb_hid_t*)data; if (hid) - return pad_connection_get_buttons(&hid->slots[port], port, state); - else - BIT128_CLEAR_ALL_PTR(state); + { + pad_connection_get_buttons(&hid->slots[port], port, state); + return; + } + + BIT256_CLEAR_ALL_PTR(state); } static bool libusb_hid_joypad_button(void *data, @@ -464,7 +467,7 @@ static bool libusb_hid_joypad_button(void *data, /* Check the button. */ if ((port < MAX_USERS) && (joykey < 32)) - return (BIT128_GET(buttons, joykey) != 0); + return (BIT256_GET(buttons, joykey) != 0); return false; } diff --git a/input/drivers_hid/null_hid.c b/input/drivers_hid/null_hid.c index 74b61d051e..ce657d8b90 100644 --- a/input/drivers_hid/null_hid.c +++ b/input/drivers_hid/null_hid.c @@ -43,7 +43,7 @@ static void null_hid_joypad_get_buttons(void *data, unsigned port, retro_bits_t (void)data; (void)port; - BIT128_CLEAR_ALL_PTR(state); + BIT256_CLEAR_ALL_PTR(state); } static bool null_hid_joypad_button(void *data, unsigned port, uint16_t joykey) diff --git a/input/drivers_hid/wiiusb_hid.c b/input/drivers_hid/wiiusb_hid.c index b550915689..e50657c64d 100644 --- a/input/drivers_hid/wiiusb_hid.c +++ b/input/drivers_hid/wiiusb_hid.c @@ -482,9 +482,11 @@ static void wiiusb_hid_joypad_get_buttons(void *data, unsigned port, retro_bits_ { wiiusb_hid_t *hid = (wiiusb_hid_t*)data; if (hid) - return pad_connection_get_buttons(&hid->connections[port], port, state); - else - BIT128_CLEAR_ALL_PTR(state); + { + pad_connection_get_buttons(&hid->connections[port], port, state); + return; + } + BIT256_CLEAR_ALL_PTR(state); } static bool wiiusb_hid_joypad_button(void *data, unsigned port, uint16_t joykey) @@ -499,7 +501,7 @@ static bool wiiusb_hid_joypad_button(void *data, unsigned port, uint16_t joykey) /* Check the button. */ if ((port < MAX_USERS) && (joykey < 32)) - return (BIT128_GET(buttons, joykey) != 0); + return (BIT256_GET(buttons, joykey) != 0); return false; } diff --git a/input/drivers_joypad/ctr_joypad.c b/input/drivers_joypad/ctr_joypad.c index a98fce76fc..711b88493d 100644 --- a/input/drivers_joypad/ctr_joypad.c +++ b/input/drivers_joypad/ctr_joypad.c @@ -77,7 +77,7 @@ static void ctr_joypad_get_buttons(unsigned port_num, retro_bits_t *state) BITS_COPY16_PTR( state, pad_state ); } else - BIT128_CLEAR_ALL_PTR(state); + BIT256_CLEAR_ALL_PTR(state); } static int16_t ctr_joypad_axis(unsigned port_num, uint32_t joyaxis) diff --git a/input/drivers_joypad/gx_joypad.c b/input/drivers_joypad/gx_joypad.c index bccc6f467b..392cb602a9 100644 --- a/input/drivers_joypad/gx_joypad.c +++ b/input/drivers_joypad/gx_joypad.c @@ -169,7 +169,7 @@ static void gx_joypad_get_buttons(unsigned port, retro_bits_t *state) BITS_COPY16_PTR( state, pad_state[port] ); } else - BIT128_CLEAR_ALL_PTR(state); + BIT256_CLEAR_ALL_PTR(state); } static int16_t gx_joypad_axis(unsigned port, uint32_t joyaxis) diff --git a/input/drivers_joypad/hid_joypad.c b/input/drivers_joypad/hid_joypad.c index fe0badd38a..203a272922 100644 --- a/input/drivers_joypad/hid_joypad.c +++ b/input/drivers_joypad/hid_joypad.c @@ -60,7 +60,7 @@ static void hid_joypad_get_buttons(unsigned port, retro_bits_t *state) if (generic_hid && generic_hid->get_buttons) generic_hid->get_buttons((void*)hid_driver_get_data(), port, state); else - BIT128_CLEAR_ALL_PTR(state); + BIT256_CLEAR_ALL_PTR(state); } static int16_t hid_joypad_axis(unsigned port, uint32_t joyaxis) diff --git a/input/drivers_joypad/linuxraw_joypad.c b/input/drivers_joypad/linuxraw_joypad.c index c43ea0b93a..4d852f406b 100644 --- a/input/drivers_joypad/linuxraw_joypad.c +++ b/input/drivers_joypad/linuxraw_joypad.c @@ -334,7 +334,7 @@ static void linuxraw_joypad_get_buttons(unsigned port, retro_bits_t *state) BITS_COPY16_PTR(state, pad->buttons); } else - BIT128_CLEAR_ALL_PTR(state); + BIT256_CLEAR_ALL_PTR(state); } static int16_t linuxraw_joypad_axis(unsigned port, uint32_t joyaxis) diff --git a/input/drivers_joypad/null_joypad.c b/input/drivers_joypad/null_joypad.c index f938e802e4..058d01d5b3 100644 --- a/input/drivers_joypad/null_joypad.c +++ b/input/drivers_joypad/null_joypad.c @@ -39,7 +39,7 @@ static bool null_joypad_button(unsigned port_num, uint16_t joykey) static void null_joypad_get_buttons(unsigned port_num, retro_bits_t *state) { - BIT128_CLEAR_ALL_PTR(state); + BIT256_CLEAR_ALL_PTR(state); } static int16_t null_joypad_axis(unsigned port_num, uint32_t joyaxis) diff --git a/input/drivers_joypad/parport_joypad.c b/input/drivers_joypad/parport_joypad.c index f24c2706a5..e236a36fc5 100644 --- a/input/drivers_joypad/parport_joypad.c +++ b/input/drivers_joypad/parport_joypad.c @@ -348,7 +348,7 @@ static void parport_joypad_get_buttons(unsigned port, retro_bits_t *state) BITS_COPY16_PTR(state, pad->buttons); } else - BIT128_CLEAR_ALL_PTR(state); + BIT256_CLEAR_ALL_PTR(state); } static int16_t parport_joypad_axis(unsigned port, uint32_t joyaxis) diff --git a/input/drivers_joypad/ps3_joypad.c b/input/drivers_joypad/ps3_joypad.c index f37822642d..a85a23fcf9 100644 --- a/input/drivers_joypad/ps3_joypad.c +++ b/input/drivers_joypad/ps3_joypad.c @@ -75,7 +75,7 @@ static void ps3_joypad_get_buttons(unsigned port_num, retro_bits_t *state) BITS_COPY16_PTR( state, pad_state[port_num] ); } else - BIT128_CLEAR_ALL_PTR(state); + BIT256_CLEAR_ALL_PTR(state); } static int16_t ps3_joypad_axis(unsigned port_num, uint32_t joyaxis) diff --git a/input/drivers_joypad/psp_joypad.c b/input/drivers_joypad/psp_joypad.c index 60ca2daff3..d9cb4dd65a 100644 --- a/input/drivers_joypad/psp_joypad.c +++ b/input/drivers_joypad/psp_joypad.c @@ -131,7 +131,7 @@ static void psp_joypad_get_buttons(unsigned port_num, retro_bits_t *state) BITS_COPY16_PTR( state, pad_state[port_num] ); } else - BIT128_CLEAR_ALL_PTR(state); + BIT256_CLEAR_ALL_PTR(state); } static int16_t psp_joypad_axis(unsigned port_num, uint32_t joyaxis) diff --git a/input/drivers_joypad/udev_joypad.c b/input/drivers_joypad/udev_joypad.c index 283e1bd38b..20ee084ec8 100644 --- a/input/drivers_joypad/udev_joypad.c +++ b/input/drivers_joypad/udev_joypad.c @@ -612,7 +612,7 @@ static void udev_joypad_get_buttons(unsigned port, retro_bits_t *state) BITS_COPY16_PTR( state, pad->buttons ); } else - BIT128_CLEAR_ALL_PTR(state); + BIT256_CLEAR_ALL_PTR(state); } static int16_t udev_joypad_axis(unsigned port, uint32_t joyaxis) diff --git a/input/drivers_joypad/wiiu_joypad.c b/input/drivers_joypad/wiiu_joypad.c index 8a3d8189db..b7c46b995f 100644 --- a/input/drivers_joypad/wiiu_joypad.c +++ b/input/drivers_joypad/wiiu_joypad.c @@ -142,7 +142,7 @@ static void wiiu_joypad_get_buttons(unsigned port_num, retro_bits_t *state) BITS_COPY16_PTR( state, pad_state[port_num] ); } else - BIT128_CLAR_ALL_PTR(state); + BIT256_CLEAR_ALL_PTR(state); } static int16_t wiiu_joypad_axis(unsigned port_num, uint32_t joyaxis) diff --git a/input/drivers_joypad/xdk_joypad.c b/input/drivers_joypad/xdk_joypad.c index 6553346160..517ddaa972 100644 --- a/input/drivers_joypad/xdk_joypad.c +++ b/input/drivers_joypad/xdk_joypad.c @@ -83,7 +83,7 @@ static void xdk_joypad_get_buttons(unsigned port_num, retro_bits_t *state) BITS_COPY16_PTR( state, pad_state[port_num] ); } else - BIT128_CLEAR_ALL_PTR(state); + BIT256_CLEAR_ALL_PTR(state); } static int16_t xdk_joypad_axis(unsigned port_num, uint32_t joyaxis) diff --git a/input/input_driver.c b/input/input_driver.c index ca491bea9f..d17fb5fc61 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -810,7 +810,7 @@ void input_menu_keys_pressed(void *data, retro_bits_t* p_new_state) joypad_info.joy_idx = 0; joypad_info.auto_binds = NULL; - BIT128_CLEAR_ALL_PTR(p_new_state); + BIT256_CLEAR_ALL_PTR(p_new_state); input_driver_block_libretro_input = false; input_driver_block_hotkey = false; @@ -912,7 +912,7 @@ void input_menu_keys_pressed(void *data, retro_bits_t* p_new_state) if (pressed) { - BIT128_SET_PTR(p_new_state, i); + BIT256_SET_PTR(p_new_state, i); continue; } } @@ -922,7 +922,7 @@ void input_menu_keys_pressed(void *data, retro_bits_t* p_new_state) { if (current_input->meta_key_pressed(current_input_data, i)) { - BIT128_SET_PTR(p_new_state, i); + BIT256_SET_PTR(p_new_state, i); continue; } } @@ -930,7 +930,7 @@ void input_menu_keys_pressed(void *data, retro_bits_t* p_new_state) #ifdef HAVE_OVERLAY if (overlay_ptr && input_overlay_key_pressed(overlay_ptr, i)) { - BIT128_SET_PTR(p_new_state, i); + BIT256_SET_PTR(p_new_state, i); continue; } #endif @@ -945,7 +945,7 @@ void input_menu_keys_pressed(void *data, retro_bits_t* p_new_state) if (command_get(&handle)) { - BIT128_SET_PTR(p_new_state, i); + BIT256_SET_PTR(p_new_state, i); continue; } } @@ -954,7 +954,7 @@ void input_menu_keys_pressed(void *data, retro_bits_t* p_new_state) #ifdef HAVE_NETWORKGAMEPAD if (input_driver_remote && input_remote_key_pressed(i, 0)) { - BIT128_SET_PTR(p_new_state, i); + BIT256_SET_PTR(p_new_state, i); continue; } #endif @@ -1010,7 +1010,7 @@ void input_menu_keys_pressed(void *data, retro_bits_t* p_new_state) if (current_input->input_state(current_input_data, joypad_info, binds, 0, RETRO_DEVICE_KEYBOARD, 0, ids[i][0])) - BIT128_SET_PTR(p_new_state, ids[i][1]); + BIT256_SET_PTR(p_new_state, ids[i][1]); } } } @@ -1037,7 +1037,7 @@ void input_keys_pressed(void *data, retro_bits_t* p_new_state) const struct retro_keybind *enable_hotkey = &input_config_binds[0][RARCH_ENABLE_HOTKEY]; bool game_focus_toggle_valid = false; - BIT128_CLEAR_ALL_PTR(p_new_state); + BIT256_CLEAR_ALL_PTR(p_new_state); joypad_info.joy_idx = settings->uints.input_joypad_map[0]; joypad_info.auto_binds = input_autoconf_binds[joypad_info.joy_idx]; @@ -1083,7 +1083,7 @@ void input_keys_pressed(void *data, retro_bits_t* p_new_state) 0, RETRO_DEVICE_JOYPAD, 0, i) ) { - BIT128_SET_PTR(p_new_state, i); + BIT256_SET_PTR(p_new_state, i); continue; } @@ -1091,7 +1091,7 @@ void input_keys_pressed(void *data, retro_bits_t* p_new_state) current_input->meta_key_pressed(current_input_data, i) ) { - BIT128_SET_PTR(p_new_state, i); + BIT256_SET_PTR(p_new_state, i); continue; } @@ -1099,7 +1099,7 @@ void input_keys_pressed(void *data, retro_bits_t* p_new_state) if (overlay_ptr && input_overlay_key_pressed(overlay_ptr, i)) { - BIT128_SET_PTR(p_new_state, i); + BIT256_SET_PTR(p_new_state, i); continue; } #endif @@ -1114,7 +1114,7 @@ void input_keys_pressed(void *data, retro_bits_t* p_new_state) if (command_get(&handle)) { - BIT128_SET_PTR(p_new_state, i); + BIT256_SET_PTR(p_new_state, i); continue; } } @@ -1124,7 +1124,7 @@ void input_keys_pressed(void *data, retro_bits_t* p_new_state) if (input_driver_remote && input_remote_key_pressed(i, 0)) { - BIT128_SET_PTR(p_new_state, i); + BIT256_SET_PTR(p_new_state, i); continue; } #endif diff --git a/menu/menu_event.c b/menu/menu_event.c index a492aca726..87449d3ff6 100644 --- a/menu/menu_event.c +++ b/menu/menu_event.c @@ -160,7 +160,7 @@ unsigned menu_event(retro_bits_t* p_input, retro_bits_t* p_trigger_input) unsigned menu_cancel_btn = (!input_swap_override && settings->bools.input_menu_swap_ok_cancel_buttons) ? RETRO_DEVICE_ID_JOYPAD_A : RETRO_DEVICE_ID_JOYPAD_B; - unsigned ok_current = BIT128_GET_PTR(p_input, menu_ok_btn ); + unsigned ok_current = BIT256_GET_PTR(p_input, menu_ok_btn ); unsigned ok_trigger = ok_current & ~ok_old; ok_old = ok_current; @@ -221,31 +221,31 @@ unsigned menu_event(retro_bits_t* p_input, retro_bits_t* p_trigger_input) { menu_event_osk_iterate(); - if (BIT128_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_DOWN)) + if (BIT256_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_DOWN)) { if (menu_event_get_osk_ptr() < 33) menu_event_set_osk_ptr(menu_event_get_osk_ptr() + OSK_CHARS_PER_LINE); } - if (BIT128_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_UP)) + if (BIT256_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_UP)) { if (menu_event_get_osk_ptr() >= OSK_CHARS_PER_LINE) menu_event_set_osk_ptr(menu_event_get_osk_ptr() - OSK_CHARS_PER_LINE); } - if (BIT128_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_RIGHT)) + if (BIT256_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_RIGHT)) { if (menu_event_get_osk_ptr() < 43) menu_event_set_osk_ptr(menu_event_get_osk_ptr() + 1); } - if (BIT128_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_LEFT)) + if (BIT256_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_LEFT)) { if (menu_event_get_osk_ptr() >= 1) menu_event_set_osk_ptr(menu_event_get_osk_ptr() - 1); } - if (BIT128_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_L)) + if (BIT256_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_L)) { if (menu_event_get_osk_idx() > OSK_TYPE_UNKNOWN + 1) menu_event_set_osk_idx((enum osk_type)(menu_event_get_osk_idx() - 1)); @@ -253,7 +253,7 @@ unsigned menu_event(retro_bits_t* p_input, retro_bits_t* p_trigger_input) menu_event_set_osk_idx((enum osk_type)(OSK_TYPE_LAST - 1)); } - if (BIT128_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_R)) + if (BIT256_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_R)) { if (menu_event_get_osk_idx() < OSK_TYPE_LAST - 1) menu_event_set_osk_idx((enum osk_type)(menu_event_get_osk_idx() + 1)); @@ -261,50 +261,50 @@ unsigned menu_event(retro_bits_t* p_input, retro_bits_t* p_trigger_input) menu_event_set_osk_idx((enum osk_type)(OSK_TYPE_UNKNOWN + 1)); } - if (BIT128_GET_PTR(p_trigger_input, menu_ok_btn)) + if (BIT256_GET_PTR(p_trigger_input, menu_ok_btn)) { if (menu_event_get_osk_ptr() >= 0) menu_event_osk_append(menu_event_get_osk_ptr()); } - if (BIT128_GET_PTR(p_trigger_input, menu_cancel_btn)) + if (BIT256_GET_PTR(p_trigger_input, menu_cancel_btn)) { input_keyboard_event(true, '\x7f', '\x7f', 0, RETRO_DEVICE_KEYBOARD); } /* send return key to close keyboard input window */ - if (BIT128_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_START)) + if (BIT256_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_START)) input_keyboard_event(true, '\n', '\n', 0, RETRO_DEVICE_KEYBOARD); - BIT128_CLEAR_ALL_PTR(p_trigger_input); + BIT256_CLEAR_ALL_PTR(p_trigger_input); } else { - if (BIT128_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_UP)) + if (BIT256_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_UP)) ret = MENU_ACTION_UP; - else if (BIT128_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_DOWN)) + else if (BIT256_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_DOWN)) ret = MENU_ACTION_DOWN; - else if (BIT128_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_LEFT)) + else if (BIT256_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_LEFT)) ret = MENU_ACTION_LEFT; - else if (BIT128_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_RIGHT)) + else if (BIT256_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_RIGHT)) ret = MENU_ACTION_RIGHT; - else if (BIT128_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_L)) + else if (BIT256_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_L)) ret = MENU_ACTION_SCROLL_UP; - else if (BIT128_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_R)) + else if (BIT256_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_R)) ret = MENU_ACTION_SCROLL_DOWN; else if (ok_trigger) ret = MENU_ACTION_OK; - else if (BIT128_GET_PTR(p_trigger_input, menu_cancel_btn)) + else if (BIT256_GET_PTR(p_trigger_input, menu_cancel_btn)) ret = MENU_ACTION_CANCEL; - else if (BIT128_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_X)) + else if (BIT256_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_X)) ret = MENU_ACTION_SEARCH; - else if (BIT128_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_Y)) + else if (BIT256_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_Y)) ret = MENU_ACTION_SCAN; - else if (BIT128_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_START)) + else if (BIT256_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_START)) ret = MENU_ACTION_START; - else if (BIT128_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_SELECT)) + else if (BIT256_GET_PTR(p_trigger_input, RETRO_DEVICE_ID_JOYPAD_SELECT)) ret = MENU_ACTION_INFO; - else if (BIT128_GET_PTR(p_trigger_input, RARCH_MENU_TOGGLE)) + else if (BIT256_GET_PTR(p_trigger_input, RARCH_MENU_TOGGLE)) ret = MENU_ACTION_TOGGLE; } @@ -314,7 +314,7 @@ unsigned menu_event(retro_bits_t* p_input, retro_bits_t* p_trigger_input) menu_event_kb_set_internal(RETROK_F11, 0); } - if (BIT128_GET_PTR(p_trigger_input, RARCH_QUIT_KEY)) + if (BIT256_GET_PTR(p_trigger_input, RARCH_QUIT_KEY)) return MENU_ACTION_QUIT; mouse_enabled = settings->bools.menu_mouse_enable; diff --git a/retroarch.c b/retroarch.c index d7a2d3170a..0de71056dc 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1931,7 +1931,7 @@ bool retroarch_override_setting_is_set(enum rarch_override_setting enum_idx, voi if (val) { unsigned bit = *val; - return BIT128_GET(has_set_libretro_device, bit); + return BIT256_GET(has_set_libretro_device, bit); } } break; @@ -1980,7 +1980,7 @@ void retroarch_override_setting_set(enum rarch_override_setting enum_idx, void * if (val) { unsigned bit = *val; - BIT128_SET(has_set_libretro_device, bit); + BIT256_SET(has_set_libretro_device, bit); } } break; @@ -2039,7 +2039,7 @@ void retroarch_override_setting_unset(enum rarch_override_setting enum_idx, void if (val) { unsigned bit = *val; - BIT128_CLEAR(has_set_libretro_device, bit); + BIT256_CLEAR(has_set_libretro_device, bit); } } break; @@ -2315,35 +2315,35 @@ static bool input_driver_toggle_button_combo( switch (mode) { case INPUT_TOGGLE_DOWN_Y_L_R: - if (!BIT128_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_DOWN)) + if (!BIT256_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_DOWN)) return false; - if (!BIT128_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_Y)) + if (!BIT256_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_Y)) return false; - if (!BIT128_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_L)) + if (!BIT256_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_L)) return false; - if (!BIT128_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_R)) + if (!BIT256_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_R)) return false; break; case INPUT_TOGGLE_L3_R3: - if (!BIT128_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_L3)) + if (!BIT256_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_L3)) return false; - if (!BIT128_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_R3)) + if (!BIT256_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_R3)) return false; break; case INPUT_TOGGLE_L1_R1_START_SELECT: - if (!BIT128_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_START)) + if (!BIT256_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_START)) return false; - if (!BIT128_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_SELECT)) + if (!BIT256_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_SELECT)) return false; - if (!BIT128_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_L)) + if (!BIT256_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_L)) return false; - if (!BIT128_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_R)) + if (!BIT256_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_R)) return false; break; case INPUT_TOGGLE_START_SELECT: - if (!BIT128_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_START)) + if (!BIT256_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_START)) return false; - if (!BIT128_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_SELECT)) + if (!BIT256_GET_PTR(p_input, RETRO_DEVICE_ID_JOYPAD_SELECT)) return false; break; default: @@ -2391,7 +2391,7 @@ static enum runloop_state runloop_check_state( ((settings->uints.input_menu_toggle_gamepad_combo != INPUT_TOGGLE_NONE) && input_driver_toggle_button_combo( settings->uints.input_menu_toggle_gamepad_combo, &last_input))) - BIT128_SET(current_input, RARCH_MENU_TOGGLE); + BIT256_SET(current_input, RARCH_MENU_TOGGLE); #endif if (input_driver_flushing_input) @@ -2399,9 +2399,9 @@ static enum runloop_state runloop_check_state( input_driver_flushing_input = false; if (BITS_ANY_SET(current_input)) { - BIT128_CLEAR_ALL(current_input); + BIT256_CLEAR_ALL(current_input); if (runloop_paused) - BIT128_SET(current_input, RARCH_PAUSE_TOGGLE); + BIT256_SET(current_input, RARCH_PAUSE_TOGGLE); input_driver_flushing_input = true; } } @@ -2410,14 +2410,14 @@ static enum runloop_state runloop_check_state( #ifdef HAVE_MENU if (menu_driver_binding_state) - BIT128_CLEAR_ALL(current_input); + BIT256_CLEAR_ALL(current_input); #endif #ifdef HAVE_OVERLAY /* Check next overlay */ { static bool old_should_check_next_overlay = false; - bool should_check_next_overlay = BIT128_GET( + bool should_check_next_overlay = BIT256_GET( current_input, RARCH_OVERLAY_NEXT); if (should_check_next_overlay && !old_should_check_next_overlay) @@ -2429,7 +2429,7 @@ static enum runloop_state runloop_check_state( /* Check fullscreen toggle */ { - bool fs_toggle_pressed = BIT128_GET( + bool fs_toggle_pressed = BIT256_GET( current_input, RARCH_FULLSCREEN_TOGGLE_KEY); fs_toggle_triggered = fs_toggle_pressed && !old_fs_toggle_pressed; @@ -2452,7 +2452,7 @@ static enum runloop_state runloop_check_state( /* Check mouse grab toggle */ { static bool old_pressed = false; - bool pressed = BIT128_GET( + bool pressed = BIT256_GET( current_input, RARCH_GRAB_MOUSE_TOGGLE); if (pressed && !old_pressed) @@ -2487,7 +2487,7 @@ static enum runloop_state runloop_check_state( /* Check quit key */ { static bool old_quit_key = false; - bool quit_key = BIT128_GET( + bool quit_key = BIT256_GET( current_input, RARCH_QUIT_KEY); bool trig_quit_key = quit_key && !old_quit_key; @@ -2579,7 +2579,7 @@ static enum runloop_state runloop_check_state( /* Check game focus toggle */ { static bool old_pressed = false; - bool pressed = BIT128_GET( + bool pressed = BIT256_GET( current_input, RARCH_GAME_FOCUS_TOGGLE); if (pressed && !old_pressed) @@ -2592,7 +2592,7 @@ static enum runloop_state runloop_check_state( /* Check menu toggle */ { static bool old_pressed = false; - bool pressed = BIT128_GET( + bool pressed = BIT256_GET( current_input, RARCH_MENU_TOGGLE); if (menu_event_kb_is_set(RETROK_F1) == 1) @@ -2642,7 +2642,7 @@ static enum runloop_state runloop_check_state( /* Check screenshot toggle */ { static bool old_pressed = false; - bool pressed = BIT128_GET( + bool pressed = BIT256_GET( current_input, RARCH_SCREENSHOT); if (pressed && old_pressed) @@ -2654,7 +2654,7 @@ static enum runloop_state runloop_check_state( /* Check audio mute toggle */ { static bool old_pressed = false; - bool pressed = BIT128_GET( + bool pressed = BIT256_GET( current_input, RARCH_MUTE); if (pressed && !old_pressed) @@ -2666,7 +2666,7 @@ static enum runloop_state runloop_check_state( /* Check OSK toggle */ { static bool old_pressed = false; - bool pressed = BIT128_GET(current_input, RARCH_OSK); + bool pressed = BIT256_GET(current_input, RARCH_OSK); if (pressed && !old_pressed) { @@ -2682,9 +2682,9 @@ static enum runloop_state runloop_check_state( old_pressed = pressed; } - if (BIT128_GET(current_input, RARCH_VOLUME_UP)) + if (BIT256_GET(current_input, RARCH_VOLUME_UP)) command_event(CMD_EVENT_VOLUME_UP, NULL); - else if (BIT128_GET(current_input, RARCH_VOLUME_DOWN)) + else if (BIT256_GET(current_input, RARCH_VOLUME_DOWN)) command_event(CMD_EVENT_VOLUME_DOWN, NULL); #ifdef HAVE_NETWORKING @@ -2692,9 +2692,9 @@ static enum runloop_state runloop_check_state( { static bool old_netplay_flip = false; static bool old_netplay_watch = false; - bool netplay_flip = BIT128_GET( + bool netplay_flip = BIT256_GET( current_input, RARCH_NETPLAY_FLIP); - bool netplay_watch = BIT128_GET( + bool netplay_watch = BIT256_GET( current_input, RARCH_NETPLAY_GAME_WATCH); if (netplay_flip && !old_netplay_flip) @@ -2713,9 +2713,9 @@ static enum runloop_state runloop_check_state( static bool old_frameadvance = false; static bool old_pause_pressed = false; bool check_is_oneshot = true; - bool frameadvance_pressed = BIT128_GET( + bool frameadvance_pressed = BIT256_GET( current_input, RARCH_FRAMEADVANCE); - bool pause_pressed = BIT128_GET( + bool pause_pressed = BIT256_GET( current_input, RARCH_PAUSE_TOGGLE); bool trig_frameadvance = frameadvance_pressed && !old_frameadvance; @@ -2739,7 +2739,7 @@ static enum runloop_state runloop_check_state( if (runloop_paused) { check_is_oneshot = trig_frameadvance || - BIT128_GET(current_input, RARCH_REWIND); + BIT256_GET(current_input, RARCH_REWIND); if (fs_toggle_triggered) { @@ -2764,9 +2764,9 @@ static enum runloop_state runloop_check_state( { static bool old_button_state = false; static bool old_hold_button_state = false; - bool new_button_state = BIT128_GET( + bool new_button_state = BIT256_GET( current_input, RARCH_FAST_FORWARD_KEY); - bool new_hold_button_state = BIT128_GET( + bool new_hold_button_state = BIT256_GET( current_input, RARCH_FAST_FORWARD_HOLD_KEY); if (new_button_state && !old_button_state) @@ -2807,9 +2807,9 @@ static enum runloop_state runloop_check_state( { static bool old_should_slot_increase = false; static bool old_should_slot_decrease = false; - bool should_slot_increase = BIT128_GET( + bool should_slot_increase = BIT256_GET( current_input, RARCH_STATE_SLOT_PLUS); - bool should_slot_decrease = BIT128_GET( + bool should_slot_decrease = BIT256_GET( current_input, RARCH_STATE_SLOT_MINUS); /* Checks if the state increase/decrease keys have been pressed @@ -2860,9 +2860,9 @@ static enum runloop_state runloop_check_state( { static bool old_should_savestate = false; static bool old_should_loadstate = false; - bool should_savestate = BIT128_GET( + bool should_savestate = BIT256_GET( current_input, RARCH_SAVE_STATE_KEY); - bool should_loadstate = BIT128_GET( + bool should_loadstate = BIT256_GET( current_input, RARCH_LOAD_STATE_KEY); if (should_savestate && !old_should_savestate) @@ -2883,14 +2883,14 @@ static enum runloop_state runloop_check_state( s[0] = '\0'; - if (state_manager_check_rewind(BIT128_GET(current_input, RARCH_REWIND), + if (state_manager_check_rewind(BIT256_GET(current_input, RARCH_REWIND), settings->uints.rewind_granularity, runloop_paused, s, sizeof(s), &t)) runloop_msg_queue_push(s, 0, t, true); } /* Checks if slowmotion toggle/hold was being pressed and/or held. */ { - runloop_slowmotion = BIT128_GET(current_input, RARCH_SLOWMOTION); + runloop_slowmotion = BIT256_GET(current_input, RARCH_SLOWMOTION); if (runloop_slowmotion) { @@ -2912,7 +2912,7 @@ static enum runloop_state runloop_check_state( /* Check movie record toggle */ { static bool old_pressed = false; - bool pressed = BIT128_GET( + bool pressed = BIT256_GET( current_input, RARCH_MOVIE_RECORD_TOGGLE); if (pressed && !old_pressed) @@ -2925,9 +2925,9 @@ static enum runloop_state runloop_check_state( { static bool old_shader_next = false; static bool old_shader_prev = false; - bool shader_next = BIT128_GET( + bool shader_next = BIT256_GET( current_input, RARCH_SHADER_NEXT); - bool shader_prev = BIT128_GET( + bool shader_prev = BIT256_GET( current_input, RARCH_SHADER_PREV); bool trig_shader_next = shader_next && !old_shader_next; bool trig_shader_prev = shader_prev && !old_shader_prev; @@ -2944,11 +2944,11 @@ static enum runloop_state runloop_check_state( static bool old_disk_eject = false; static bool old_disk_next = false; static bool old_disk_prev = false; - bool disk_eject = BIT128_GET( + bool disk_eject = BIT256_GET( current_input, RARCH_DISK_EJECT_TOGGLE); - bool disk_next = BIT128_GET( + bool disk_next = BIT256_GET( current_input, RARCH_DISK_NEXT); - bool disk_prev = BIT128_GET( + bool disk_prev = BIT256_GET( current_input, RARCH_DISK_PREV); if (disk_eject && !old_disk_eject) @@ -2966,7 +2966,7 @@ static enum runloop_state runloop_check_state( /* Check reset */ { static bool old_state = false; - bool new_state = BIT128_GET( + bool new_state = BIT256_GET( current_input, RARCH_RESET); if (new_state && !old_state) @@ -2980,11 +2980,11 @@ static enum runloop_state runloop_check_state( static bool old_cheat_index_plus = false; static bool old_cheat_index_minus = false; static bool old_cheat_index_toggle = false; - bool cheat_index_plus = BIT128_GET( + bool cheat_index_plus = BIT256_GET( current_input, RARCH_CHEAT_INDEX_PLUS); - bool cheat_index_minus = BIT128_GET( + bool cheat_index_minus = BIT256_GET( current_input, RARCH_CHEAT_INDEX_MINUS); - bool cheat_index_toggle = BIT128_GET( + bool cheat_index_toggle = BIT256_GET( current_input, RARCH_CHEAT_TOGGLE); if (cheat_index_plus && !old_cheat_index_plus) From 53ce29ca315b4e3ec8ef074795ec239edcdc39dc Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 5 Dec 2017 12:49:59 +0100 Subject: [PATCH 204/394] Cleanups --- libretro-common/include/retro_miscellaneous.h | 35 +++++++++++-------- 1 file changed, 20 insertions(+), 15 deletions(-) diff --git a/libretro-common/include/retro_miscellaneous.h b/libretro-common/include/retro_miscellaneous.h index c69afed90b..30bb2de69d 100644 --- a/libretro-common/include/retro_miscellaneous.h +++ b/libretro-common/include/retro_miscellaneous.h @@ -58,33 +58,38 @@ #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) -#define BITS_ANY_SET(a) ( ((a).data[0])||((a).data[1])||((a).data[2])||((a).data[3])|| \ - ((a).data[4])||((a).data[5])||((a).data[6])||((a).data[7]) ) -#define BITS_ANY_SET_PTR(a) ( ((a)->data[0])||((a)->data[1])||((a)->data[2])||((a)->data[3])|| \ - ((a)->data[4])||((a)->data[5])||((a)->data[6])||((a)->data[7]) ) +#define BITS_GET_ELEM(a, i) ((a).data[i]) +#define BITS_GET_ELEM_PTR(a, i) ((a)->data[i]) + +#define BITS_ANY_SET(a) ( BITS_GET_ELEM(a, 0)|| BITS_GET_ELEM(a, 1) || BITS_GET_ELEM(a, 2) || BITS_GET_ELEM(a, 3) || \ + BITS_GET_ELEM(a, 4) || BITS_GET_ELEM(a, 5) || BITS_GET_ELEM(a, 6) || BITS_GET_ELEM(a, 7) ) +#define BITS_ANY_SET_PTR(a) ( BITS_GET_ELEM_PTR(a, 0)|| BITS_GET_ELEM_PTR(a, 1) || BITS_GET_ELEM_PTR(a, 2) || BITS_GET_ELEM_PTR(a, 3) || \ + BITS_GET_ELEM_PTR(a, 4) || BITS_GET_ELEM_PTR(a, 5) || BITS_GET_ELEM_PTR(a, 6) || BITS_GET_ELEM_PTR(a, 7) ) + #define BITS_CLEAR_BITS(a,b) \ - ((a).data[0])&=(~((b).data[0])); \ - ((a).data[1])&=(~((b).data[1])); \ - ((a).data[2])&=(~((b).data[2])); \ - ((a).data[3])&=(~((b).data[3])); \ - ((a).data[4])&=(~((b).data[4])); \ - ((a).data[5])&=(~((b).data[5])); \ - ((a).data[6])&=(~((b).data[6])); \ - ((a).data[7])&=(~((b).data[7])); +{ \ + BITS_GET_ELEM(a, 0) &= (~BITS_GET_ELEM(b, 0)); \ + BITS_GET_ELEM(a, 1) &= (~BITS_GET_ELEM(b, 1)); \ + BITS_GET_ELEM(a, 2) &= (~BITS_GET_ELEM(b, 2)); \ + BITS_GET_ELEM(a, 3) &= (~BITS_GET_ELEM(b, 3)); \ + BITS_GET_ELEM(a, 4) &= (~BITS_GET_ELEM(b, 4)); \ + BITS_GET_ELEM(a, 5) &= (~BITS_GET_ELEM(b, 5)); \ + BITS_GET_ELEM(a, 6) &= (~BITS_GET_ELEM(b, 6)); \ + BITS_GET_ELEM(a, 7) &= (~BITS_GET_ELEM(b, 7)); \ +} #define BITS_COPY16_PTR(a,bits) \ { \ BIT128_CLEAR_ALL_PTR(a); \ - ((a)->data[0] = (bits) & 0xffff); \ + BITS_GET_ELEM_PTR(a, 0) = (bits) & 0xffff; \ } #define BITS_COPY32_PTR(a,bits) \ { \ BIT128_CLEAR_ALL_PTR(a); \ - ((a)->data[0] = (bits)); \ + BITS_GET_ELEM_PTR(a, 0) = (bits); \ } - #define BIT_SET(a, bit) ((a)[(bit) >> 3] |= (1 << ((bit) & 7))) #define BIT_CLEAR(a, bit) ((a)[(bit) >> 3] &= ~(1 << ((bit) & 7))) #define BIT_GET(a, bit) (((a).data[(bit) >> 3] >> ((bit) & 7)) & 1) From 332aee5b0f777a22e404654a3d4ecdbfcc53fdb7 Mon Sep 17 00:00:00 2001 From: Alcaro Date: Tue, 5 Dec 2017 13:03:34 +0100 Subject: [PATCH 205/394] Dehardcode some sizes (#5856) --- libretro-common/include/retro_miscellaneous.h | 38 +++++++++++-------- 1 file changed, 23 insertions(+), 15 deletions(-) diff --git a/libretro-common/include/retro_miscellaneous.h b/libretro-common/include/retro_miscellaneous.h index 30bb2de69d..60da013743 100644 --- a/libretro-common/include/retro_miscellaneous.h +++ b/libretro-common/include/retro_miscellaneous.h @@ -24,6 +24,7 @@ #define __RARCH_MISCELLANEOUS_H #include +#include #if defined(_WIN32) && !defined(_XBOX) #ifndef WIN32_LEAN_AND_MEAN @@ -61,23 +62,30 @@ #define BITS_GET_ELEM(a, i) ((a).data[i]) #define BITS_GET_ELEM_PTR(a, i) ((a)->data[i]) -#define BITS_ANY_SET(a) ( BITS_GET_ELEM(a, 0)|| BITS_GET_ELEM(a, 1) || BITS_GET_ELEM(a, 2) || BITS_GET_ELEM(a, 3) || \ - BITS_GET_ELEM(a, 4) || BITS_GET_ELEM(a, 5) || BITS_GET_ELEM(a, 6) || BITS_GET_ELEM(a, 7) ) -#define BITS_ANY_SET_PTR(a) ( BITS_GET_ELEM_PTR(a, 0)|| BITS_GET_ELEM_PTR(a, 1) || BITS_GET_ELEM_PTR(a, 2) || BITS_GET_ELEM_PTR(a, 3) || \ - BITS_GET_ELEM_PTR(a, 4) || BITS_GET_ELEM_PTR(a, 5) || BITS_GET_ELEM_PTR(a, 6) || BITS_GET_ELEM_PTR(a, 7) ) - -#define BITS_CLEAR_BITS(a,b) \ -{ \ - BITS_GET_ELEM(a, 0) &= (~BITS_GET_ELEM(b, 0)); \ - BITS_GET_ELEM(a, 1) &= (~BITS_GET_ELEM(b, 1)); \ - BITS_GET_ELEM(a, 2) &= (~BITS_GET_ELEM(b, 2)); \ - BITS_GET_ELEM(a, 3) &= (~BITS_GET_ELEM(b, 3)); \ - BITS_GET_ELEM(a, 4) &= (~BITS_GET_ELEM(b, 4)); \ - BITS_GET_ELEM(a, 5) &= (~BITS_GET_ELEM(b, 5)); \ - BITS_GET_ELEM(a, 6) &= (~BITS_GET_ELEM(b, 6)); \ - BITS_GET_ELEM(a, 7) &= (~BITS_GET_ELEM(b, 7)); \ +static inline bool bits_any_set(uint32_t* ptr, uint32_t count) +{ + uint32_t i; + for (i=0;i Date: Tue, 5 Dec 2017 13:15:15 +0100 Subject: [PATCH 206/394] Cleanups --- libretro-common/include/retro_miscellaneous.h | 69 +++++++++---------- menu/menu_event.c | 2 +- retroarch.c | 6 +- 3 files changed, 37 insertions(+), 40 deletions(-) diff --git a/libretro-common/include/retro_miscellaneous.h b/libretro-common/include/retro_miscellaneous.h index 60da013743..b51cc15e60 100644 --- a/libretro-common/include/retro_miscellaneous.h +++ b/libretro-common/include/retro_miscellaneous.h @@ -25,6 +25,7 @@ #include #include +#include #if defined(_WIN32) && !defined(_XBOX) #ifndef WIN32_LEAN_AND_MEAN @@ -41,6 +42,24 @@ #include #endif +static INLINE void bits_clear_bits(uint32_t *a, uint32_t *b, uint32_t count) +{ + uint32_t i; + for (i = 0; i < count;i++) + a[i] &= b[i]; +} + +static INLINE bool bits_any_set(uint32_t* ptr, uint32_t count) +{ + uint32_t i; + for (i = 0; i < count; i++) + { + if (ptr[i] != 0) + return true; + } + return false; +} + #ifndef PATH_MAX_LENGTH #if defined(_XBOX1) || defined(_3DS) || defined(PSP) || defined(GEKKO)|| defined(WIIU) #define PATH_MAX_LENGTH 512 @@ -57,47 +76,11 @@ #define MIN(a, b) ((a) < (b) ? (a) : (b)) #endif -#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) +#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) #define BITS_GET_ELEM(a, i) ((a).data[i]) #define BITS_GET_ELEM_PTR(a, i) ((a)->data[i]) -static inline bool bits_any_set(uint32_t* ptr, uint32_t count) -{ - uint32_t i; - for (i=0;i> 3] |= (1 << ((bit) & 7))) #define BIT_CLEAR(a, bit) ((a)[(bit) >> 3] &= ~(1 << ((bit) & 7))) #define BIT_GET(a, bit) (((a).data[(bit) >> 3] >> ((bit) & 7)) & 1) @@ -137,6 +120,18 @@ static inline void bits_clear_bits(uint32_t* a, uint32_t* b, uint32_t count) #define BIT256_GET_PTR(a, bit) BIT256_GET(*a, bit) #define BIT256_CLEAR_ALL_PTR(a) BIT256_CLEAR_ALL(*a) +#define BITS_COPY16_PTR(a,bits) \ +{ \ + BIT128_CLEAR_ALL_PTR(a); \ + BITS_GET_ELEM_PTR(a, 0) = (bits) & 0xffff; \ +} + +#define BITS_COPY32_PTR(a,bits) \ +{ \ + BIT128_CLEAR_ALL_PTR(a); \ + BITS_GET_ELEM_PTR(a, 0) = (bits); \ +} + /* Helper macros and struct to keep track of many booleans. */ /* This struct has 256 bits. */ typedef struct diff --git a/menu/menu_event.c b/menu/menu_event.c index 87449d3ff6..9c2c8eaecc 100644 --- a/menu/menu_event.c +++ b/menu/menu_event.c @@ -165,7 +165,7 @@ unsigned menu_event(retro_bits_t* p_input, retro_bits_t* p_trigger_input) ok_old = ok_current; - if (BITS_ANY_SET_PTR(p_input)) + if (bits_any_set(p_input->data, ARRAY_SIZE(p_input->data))) { if (!first_held) { diff --git a/retroarch.c b/retroarch.c index 0de71056dc..2545b79424 100644 --- a/retroarch.c +++ b/retroarch.c @@ -2397,7 +2397,7 @@ static enum runloop_state runloop_check_state( if (input_driver_flushing_input) { input_driver_flushing_input = false; - if (BITS_ANY_SET(current_input)) + if (bits_any_set(current_input.data, ARRAY_SIZE(current_input.data))) { BIT256_CLEAR_ALL(current_input); if (runloop_paused) @@ -2540,7 +2540,9 @@ static enum runloop_state runloop_check_state( enum menu_action action; bool focused = false; retro_bits_t trigger_input = current_input; - BITS_CLEAR_BITS(trigger_input, old_input); + + bits_clear_bits(trigger_input.data, old_input.data, + ARRAY_SIZE(trigger_input.data)); action = (enum menu_action)menu_event(¤t_input, &trigger_input); focused = pause_nonactive ? is_focused : true; From b432fb4668bd8cbf68d12a6b90d86232ad6249d4 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 5 Dec 2017 13:21:29 +0100 Subject: [PATCH 207/394] Bugfix --- libretro-common/include/retro_miscellaneous.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libretro-common/include/retro_miscellaneous.h b/libretro-common/include/retro_miscellaneous.h index b51cc15e60..010b04f19c 100644 --- a/libretro-common/include/retro_miscellaneous.h +++ b/libretro-common/include/retro_miscellaneous.h @@ -46,7 +46,7 @@ static INLINE void bits_clear_bits(uint32_t *a, uint32_t *b, uint32_t count) { uint32_t i; for (i = 0; i < count;i++) - a[i] &= b[i]; + a[i] &= ~b[i]; } static INLINE bool bits_any_set(uint32_t* ptr, uint32_t count) From fafc96d3777ac7102d1bafd39777c8884d47f677 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 5 Dec 2017 13:31:51 +0100 Subject: [PATCH 208/394] Cleanups --- gfx/drivers_renderchain/gl2_renderchain.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/gfx/drivers_renderchain/gl2_renderchain.c b/gfx/drivers_renderchain/gl2_renderchain.c index ebdb9709b0..1b246ce143 100644 --- a/gfx/drivers_renderchain/gl2_renderchain.c +++ b/gfx/drivers_renderchain/gl2_renderchain.c @@ -1262,7 +1262,9 @@ static void gl2_renderchain_copy_frame( const void *frame, unsigned width, unsigned height, unsigned pitch) { - gl_t *gl = (gl_t*)data; + gl_t *gl = (gl_t*)data; + gl2_renderchain_t *chain = (gl2_renderchain_t*)chain_data; + #if defined(HAVE_PSGL) { unsigned h; @@ -1281,7 +1283,6 @@ static void gl2_renderchain_copy_frame( } #elif defined(HAVE_OPENGLES) #if defined(HAVE_EGL) - gl2_renderchain_t *chain = (gl2_renderchain_t*)chain_data; if (chain->egl_images) { gfx_ctx_image_t img_info; From df8a2274dfe8dce3a304cd99b6809f52fc57d639 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 5 Dec 2017 13:47:23 +0100 Subject: [PATCH 209/394] Update CHANGES.md --- CHANGES.md | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index 17bb6ec41b..cabe1a0b9c 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -1,5 +1,21 @@ # 1.7.0 (future) -- CHEEVOS: Add badges +- CHEEVOS: Add badges for achievements, shows thumbnail images of achievements. +- COMMON: Add 'Automatically Load Content To Playlist' feature, enabled by default. +- COMMON: Fix slowmotion ratio always being reset back to 1. +- COMMON: Optimized NBIO implementations now for Apple, Windows, and Linux. Uses mmap for Linux/Windows/BSD if/when available. File I/O should now be much faster for loading images inside the menu. +- COMMON: Native Blissbox support now for latest firmware as of writing (2.0). Implementation through libusb and/or native Windows HID. +- COMMON: New lightgun API. +- FREEBSD: Support libusb HID input driver. +- HAIKU: Buildfix. +- LOCALIZATION: Update Italian translation. +- LOCALIZATION: Update Portuguese-Brazilian translation. +- LOCALIZATION: Update Russian translation. +- OSX/PPC: Fix the GL2 renderchain, had to use EXT versions of framebuffer/renderbuffer functions. +- SCANNER: Fix crash from Windows-incompatible format string. +- WIIU: Disabled the controller patcher for now since it was the source of many stability issues. +- WINDOWS: Raw input driver now supports new lightgun code. +- X11: Add RetroArch logo to window title bar. +- X11: Input driver now supports new lightgun code. # 1.6.9 - COMMON: Small memory leak. From c486fa08cabc977a46cb328a9b2b72bcd3dddffe Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 5 Dec 2017 14:11:50 +0100 Subject: [PATCH 210/394] Cut down on code duplication --- menu/cbs/menu_cbs_deferred_push.c | 414 ++++++------------------------ 1 file changed, 80 insertions(+), 334 deletions(-) diff --git a/menu/cbs/menu_cbs_deferred_push.c b/menu/cbs/menu_cbs_deferred_push.c index 538198987c..77ad57d4c4 100644 --- a/menu/cbs/menu_cbs_deferred_push.c +++ b/menu/cbs/menu_cbs_deferred_push.c @@ -58,90 +58,85 @@ static int deferred_push_dlist(menu_displaylist_info_t *info, enum menu_displayl return 0; } -static int deferred_push_core_information(menu_displaylist_info_t *info) +static int deferred_push_database_manager_list_deferred( + menu_displaylist_info_t *info) { - return deferred_push_dlist(info, DISPLAYLIST_CORE_INFO); + if (!string_is_empty(info->path_b)) + free(info->path_b); + if (!string_is_empty(info->path_c)) + free(info->path_c); + + info->path_b = strdup(info->path); + info->path_c = NULL; + + return deferred_push_dlist(info, DISPLAYLIST_DATABASE_QUERY); } -static int deferred_push_system_information(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_SYSTEM_INFO); +#define generic_deferred_push(name, type) \ +static int (name)(menu_displaylist_info_t *info) \ +{ \ + return deferred_push_dlist(info, type); \ } -static int deferred_push_network_information(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_NETWORK_INFO); -} - -static int deferred_push_achievement_list(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_ACHIEVEMENT_LIST); -} - -static int deferred_push_rdb_collection(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_PLAYLIST_COLLECTION); -} - -static int deferred_main_menu_list(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_MAIN_MENU); -} - -static int deferred_music_list(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_MUSIC_LIST); -} - -static int deferred_user_binds_list(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_USER_BINDS_LIST); -} - -static int deferred_push_accounts_list(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_ACCOUNTS_LIST); -} - -static int deferred_push_driver_settings_list(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_DRIVER_SETTINGS_LIST); -} - -static int deferred_push_core_settings_list(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_CORE_SETTINGS_LIST); -} - -static int deferred_push_video_settings_list(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_VIDEO_SETTINGS_LIST); -} - -static int deferred_push_configuration_settings_list(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_CONFIGURATION_SETTINGS_LIST); -} - -static int deferred_push_saving_settings_list(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_SAVING_SETTINGS_LIST); -} - -static int deferred_push_logging_settings_list(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_LOGGING_SETTINGS_LIST); -} - -static int deferred_push_frame_throttle_settings_list(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_FRAME_THROTTLE_SETTINGS_LIST); -} - -static int deferred_push_rewind_settings_list(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_REWIND_SETTINGS_LIST); -} +generic_deferred_push(deferred_push_video_shader_preset_parameters, DISPLAYLIST_SHADER_PARAMETERS_PRESET) +generic_deferred_push(deferred_push_video_shader_parameters, DISPLAYLIST_SHADER_PARAMETERS) +generic_deferred_push(deferred_push_settings, DISPLAYLIST_SETTINGS_ALL) +generic_deferred_push(deferred_push_shader_options, DISPLAYLIST_OPTIONS_SHADERS) +generic_deferred_push(deferred_push_options, DISPLAYLIST_OPTIONS) +generic_deferred_push(deferred_push_netplay, DISPLAYLIST_NETPLAY_ROOM_LIST) +generic_deferred_push(deferred_push_netplay_sublist, DISPLAYLIST_NETPLAY) +generic_deferred_push(deferred_push_content_settings, DISPLAYLIST_CONTENT_SETTINGS) +generic_deferred_push(deferred_push_add_content_list, DISPLAYLIST_ADD_CONTENT_LIST) +generic_deferred_push(deferred_push_history_list, DISPLAYLIST_HISTORY) +generic_deferred_push(deferred_push_database_manager_list, DISPLAYLIST_DATABASES) +generic_deferred_push(deferred_push_cursor_manager_list, DISPLAYLIST_DATABASE_CURSORS) +generic_deferred_push(deferred_push_content_collection_list, DISPLAYLIST_DATABASE_PLAYLISTS) +generic_deferred_push(deferred_push_configurations_list, DISPLAYLIST_CONFIGURATIONS_LIST) +generic_deferred_push(deferred_push_load_content_special, DISPLAYLIST_LOAD_CONTENT_LIST) +generic_deferred_push(deferred_push_load_content_list, DISPLAYLIST_LOAD_CONTENT_LIST) +generic_deferred_push(deferred_push_information_list, DISPLAYLIST_INFORMATION_LIST) +generic_deferred_push(deferred_archive_action_detect_core, DISPLAYLIST_ARCHIVE_ACTION_DETECT_CORE) +generic_deferred_push(deferred_archive_action, DISPLAYLIST_ARCHIVE_ACTION) +generic_deferred_push(deferred_push_management_options, DISPLAYLIST_OPTIONS_MANAGEMENT) +generic_deferred_push(deferred_push_core_counters, DISPLAYLIST_PERFCOUNTERS_CORE) +generic_deferred_push(deferred_push_frontend_counters, DISPLAYLIST_PERFCOUNTERS_FRONTEND) +generic_deferred_push(deferred_push_core_cheat_options, DISPLAYLIST_OPTIONS_CHEATS) +generic_deferred_push(deferred_push_core_input_remapping_options, DISPLAYLIST_OPTIONS_REMAPPINGS) +generic_deferred_push(deferred_push_core_options, DISPLAYLIST_CORE_OPTIONS) +generic_deferred_push(deferred_push_disk_options, DISPLAYLIST_OPTIONS_DISK) +generic_deferred_push(deferred_push_browse_url_list, DISPLAYLIST_BROWSE_URL_LIST) +generic_deferred_push(deferred_push_browse_url_start, DISPLAYLIST_BROWSE_URL_START) +generic_deferred_push(deferred_push_core_list, DISPLAYLIST_CORES) +generic_deferred_push(deferred_push_configurations, DISPLAYLIST_CONFIG_FILES) +generic_deferred_push(deferred_push_video_shader_preset, DISPLAYLIST_SHADER_PRESET) +generic_deferred_push(deferred_push_video_shader_pass, DISPLAYLIST_SHADER_PASS) +generic_deferred_push(deferred_push_video_filter, DISPLAYLIST_VIDEO_FILTERS) +generic_deferred_push(deferred_push_images, DISPLAYLIST_IMAGES) +generic_deferred_push(deferred_push_audio_dsp_plugin, DISPLAYLIST_AUDIO_FILTERS) +generic_deferred_push(deferred_push_cheat_file_load, DISPLAYLIST_CHEAT_FILES) +generic_deferred_push(deferred_push_remap_file_load, DISPLAYLIST_REMAP_FILES) +generic_deferred_push(deferred_push_record_configfile, DISPLAYLIST_RECORD_CONFIG_FILES) +generic_deferred_push(deferred_push_input_overlay, DISPLAYLIST_OVERLAYS) +generic_deferred_push(deferred_push_video_font_path, DISPLAYLIST_FONTS) +generic_deferred_push(deferred_push_xmb_font_path, DISPLAYLIST_FONTS) +generic_deferred_push(deferred_push_content_history_path, DISPLAYLIST_CONTENT_HISTORY) +generic_deferred_push(deferred_push_core_information, DISPLAYLIST_CORE_INFO) +generic_deferred_push(deferred_push_system_information, DISPLAYLIST_SYSTEM_INFO) +generic_deferred_push(deferred_push_network_information, DISPLAYLIST_NETWORK_INFO) +generic_deferred_push(deferred_push_achievement_list, DISPLAYLIST_ACHIEVEMENT_LIST) +generic_deferred_push(deferred_push_rdb_collection, DISPLAYLIST_PLAYLIST_COLLECTION) +generic_deferred_push(deferred_main_menu_list, DISPLAYLIST_MAIN_MENU) +generic_deferred_push(deferred_music_list, DISPLAYLIST_MUSIC_LIST) +generic_deferred_push(deferred_user_binds_list, DISPLAYLIST_USER_BINDS_LIST) +generic_deferred_push(deferred_push_accounts_list, DISPLAYLIST_ACCOUNTS_LIST) +generic_deferred_push(deferred_push_driver_settings_list, DISPLAYLIST_DRIVER_SETTINGS_LIST) +generic_deferred_push(deferred_push_core_settings_list, DISPLAYLIST_CORE_SETTINGS_LIST) +generic_deferred_push(deferred_push_video_settings_list, DISPLAYLIST_VIDEO_SETTINGS_LIST) +generic_deferred_push(deferred_push_configuration_settings_list, DISPLAYLIST_CONFIGURATION_SETTINGS_LIST) +generic_deferred_push(deferred_push_saving_settings_list, DISPLAYLIST_SAVING_SETTINGS_LIST) +generic_deferred_push(deferred_push_logging_settings_list, DISPLAYLIST_LOGGING_SETTINGS_LIST) +generic_deferred_push(deferred_push_frame_throttle_settings_list, DISPLAYLIST_FRAME_THROTTLE_SETTINGS_LIST) +generic_deferred_push(deferred_push_rewind_settings_list, DISPLAYLIST_REWIND_SETTINGS_LIST) static int deferred_push_onscreen_display_settings_list(menu_displaylist_info_t *info) { @@ -279,165 +274,16 @@ static int deferred_push_core_collection_list_deferred( return deferred_push_dlist(info, DISPLAYLIST_CORES_COLLECTION_SUPPORTED); } -static int deferred_push_database_manager_list_deferred( - menu_displaylist_info_t *info) -{ - if (!string_is_empty(info->path_b)) - free(info->path_b); - if (!string_is_empty(info->path_c)) - free(info->path_c); - - info->path_b = strdup(info->path); - info->path_c = NULL; - - return deferred_push_dlist(info, DISPLAYLIST_DATABASE_QUERY); -} - -static int deferred_push_video_shader_preset_parameters( - menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_SHADER_PARAMETERS_PRESET); -} - -static int deferred_push_video_shader_parameters( - menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_SHADER_PARAMETERS); -} - -static int deferred_push_settings(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_SETTINGS_ALL); -} - -static int deferred_push_shader_options(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_OPTIONS_SHADERS); -} - -static int deferred_push_options(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_OPTIONS); -} - -static int deferred_push_netplay(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_NETPLAY_ROOM_LIST); -} - -static int deferred_push_netplay_sublist(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_NETPLAY); -} - -static int deferred_push_content_settings(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_CONTENT_SETTINGS); -} - -static int deferred_push_add_content_list(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_ADD_CONTENT_LIST); -} - -static int deferred_push_configurations_list(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_CONFIGURATIONS_LIST); -} - -static int deferred_push_load_content_special(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_LOAD_CONTENT_LIST); -} - -static int deferred_push_load_content_list(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_LOAD_CONTENT_LIST); -} - -static int deferred_push_information_list(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_INFORMATION_LIST); -} - -static int deferred_push_management_options(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_OPTIONS_MANAGEMENT); -} - -static int deferred_push_core_counters(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_PERFCOUNTERS_CORE); -} - -static int deferred_push_frontend_counters(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_PERFCOUNTERS_FRONTEND); -} - -static int deferred_push_core_cheat_options(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_OPTIONS_CHEATS); -} - -static int deferred_push_core_input_remapping_options(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_OPTIONS_REMAPPINGS); -} - -static int deferred_push_core_options(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_CORE_OPTIONS); -} - -static int deferred_push_disk_options(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_OPTIONS_DISK); -} #ifdef HAVE_NETWORKING -static int deferred_push_thumbnails_updater_list(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_THUMBNAILS_UPDATER); -} - -static int deferred_push_core_updater_list(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_CORES_UPDATER); -} - -static int deferred_push_core_content_list(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_CORE_CONTENT); -} - -static int deferred_push_core_content_dirs_list(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_CORE_CONTENT_DIRS); -} - -static int deferred_push_core_content_dirs_subdir_list(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_CORE_CONTENT_DIRS_SUBDIR); -} - -static int deferred_push_lakka_list(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_LAKKA); -} - +generic_deferred_push(deferred_push_thumbnails_updater_list, DISPLAYLIST_THUMBNAILS_UPDATER) +generic_deferred_push(deferred_push_core_updater_list, DISPLAYLIST_CORES_UPDATER) +generic_deferred_push(deferred_push_core_content_list, DISPLAYLIST_CORE_CONTENT) +generic_deferred_push(deferred_push_core_content_dirs_list, DISPLAYLIST_CORE_CONTENT_DIRS) +generic_deferred_push(deferred_push_core_content_dirs_subdir_list, DISPLAYLIST_CORE_CONTENT_DIRS_SUBDIR) +generic_deferred_push(deferred_push_lakka_list, DISPLAYLIST_LAKKA) #endif -static int deferred_archive_action_detect_core(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_ARCHIVE_ACTION_DETECT_CORE); -} - -static int deferred_archive_action(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_ARCHIVE_ACTION); -} - static int deferred_push_cursor_manager_list_deferred( menu_displaylist_info_t *info) { @@ -941,111 +787,11 @@ static int deferred_push_default(menu_displaylist_info_t *info) return general_push(info, PUSH_DEFAULT, DISPLAYLIST_DEFAULT); } -static int deferred_push_history_list(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_HISTORY); -} - -static int deferred_push_database_manager_list(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_DATABASES); -} - -static int deferred_push_cursor_manager_list(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_DATABASE_CURSORS); -} - -static int deferred_push_content_collection_list(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_DATABASE_PLAYLISTS); -} - static int deferred_push_favorites_list(menu_displaylist_info_t *info) { return general_push(info, PUSH_DEFAULT, DISPLAYLIST_FAVORITES); } -static int deferred_push_browse_url_list(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_BROWSE_URL_LIST); -} - -static int deferred_push_browse_url_start(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_BROWSE_URL_START); -} - -static int deferred_push_core_list(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_CORES); -} - -static int deferred_push_configurations(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_CONFIG_FILES); -} - -static int deferred_push_video_shader_preset(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_SHADER_PRESET); -} - -static int deferred_push_video_shader_pass(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_SHADER_PASS); -} - -static int deferred_push_video_filter(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_VIDEO_FILTERS); -} - -static int deferred_push_images(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_IMAGES); -} - -static int deferred_push_audio_dsp_plugin(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_AUDIO_FILTERS); -} - -static int deferred_push_cheat_file_load(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_CHEAT_FILES); -} - -static int deferred_push_remap_file_load(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_REMAP_FILES); -} - -static int deferred_push_record_configfile(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_RECORD_CONFIG_FILES); -} - -static int deferred_push_input_overlay(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_OVERLAYS); -} - -static int deferred_push_video_font_path(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_FONTS); -} - -static int deferred_push_xmb_font_path(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_FONTS); -} - -static int deferred_push_content_history_path(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_CONTENT_HISTORY); -} - static int menu_cbs_init_bind_deferred_push_compare_label( menu_file_list_cbs_t *cbs, const char *label, uint32_t label_hash) From 264d9903e886e8f5e60a814ebea64c641716a678 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 5 Dec 2017 14:24:06 +0100 Subject: [PATCH 211/394] Update NL --- intl/msg_hash_nl.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/intl/msg_hash_nl.h b/intl/msg_hash_nl.h index f912f35260..f2a3b58f4b 100644 --- a/intl/msg_hash_nl.h +++ b/intl/msg_hash_nl.h @@ -2313,6 +2313,8 @@ MSG_HASH( ) MSG_HASH(MENU_ENUM_LABEL_VALUE_SHADER_PIPELINE_BOKEH, "Bokeh") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SHADER_PIPELINE_SNOWFLAKE, + "Sneeuwvlok") MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_REFRESH_ROOMS, "Refresh Room List") MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_ROOM_NICKNAME, From 5d8df93c99bc46d7dbf2b8e3ac77544e06d91817 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 5 Dec 2017 14:30:54 +0100 Subject: [PATCH 212/394] Cleanups --- menu/cbs/menu_cbs_deferred_push.c | 164 +++++------------------------- 1 file changed, 27 insertions(+), 137 deletions(-) diff --git a/menu/cbs/menu_cbs_deferred_push.c b/menu/cbs/menu_cbs_deferred_push.c index 77ad57d4c4..3d158cc4b9 100644 --- a/menu/cbs/menu_cbs_deferred_push.c +++ b/menu/cbs/menu_cbs_deferred_push.c @@ -137,143 +137,33 @@ generic_deferred_push(deferred_push_saving_settings_list, DISPLAYLIST_ generic_deferred_push(deferred_push_logging_settings_list, DISPLAYLIST_LOGGING_SETTINGS_LIST) generic_deferred_push(deferred_push_frame_throttle_settings_list, DISPLAYLIST_FRAME_THROTTLE_SETTINGS_LIST) generic_deferred_push(deferred_push_rewind_settings_list, DISPLAYLIST_REWIND_SETTINGS_LIST) - -static int deferred_push_onscreen_display_settings_list(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_ONSCREEN_DISPLAY_SETTINGS_LIST); -} - -static int deferred_push_onscreen_notifications_settings_list(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_ONSCREEN_NOTIFICATIONS_SETTINGS_LIST); -} - -static int deferred_push_onscreen_overlay_settings_list(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_ONSCREEN_OVERLAY_SETTINGS_LIST); -} - -static int deferred_push_menu_file_browser_settings_list(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_MENU_FILE_BROWSER_SETTINGS_LIST); -} - -static int deferred_push_menu_views_settings_list(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_MENU_VIEWS_SETTINGS_LIST); -} - -static int deferred_push_quick_menu_views_settings_list(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_QUICK_MENU_VIEWS_SETTINGS_LIST); -} - -static int deferred_push_menu_settings_list(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_MENU_SETTINGS_LIST); -} - -static int deferred_push_user_interface_settings_list(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_USER_INTERFACE_SETTINGS_LIST); -} - -static int deferred_push_retro_achievements_settings_list(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_RETRO_ACHIEVEMENTS_SETTINGS_LIST); -} - -static int deferred_push_updater_settings_list(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_UPDATER_SETTINGS_LIST); -} - -static int deferred_push_wifi_settings_list(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_WIFI_SETTINGS_LIST); -} - -static int deferred_push_network_settings_list(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_NETWORK_SETTINGS_LIST); -} - -static int deferred_push_lakka_services_list(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_LAKKA_SERVICES_LIST); -} - -static int deferred_push_user_settings_list(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_USER_SETTINGS_LIST); -} - -static int deferred_push_directory_settings_list(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_DIRECTORY_SETTINGS_LIST); -} - -static int deferred_push_privacy_settings_list(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_PRIVACY_SETTINGS_LIST); -} - -static int deferred_push_audio_settings_list(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_AUDIO_SETTINGS_LIST); -} - -static int deferred_push_input_settings_list(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_INPUT_SETTINGS_LIST); -} - -static int deferred_push_recording_settings_list(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_RECORDING_SETTINGS_LIST); -} - -static int deferred_push_playlist_settings_list(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_PLAYLIST_SETTINGS_LIST); -} - -static int deferred_push_input_hotkey_binds_list(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_INPUT_HOTKEY_BINDS_LIST); -} - -static int deferred_push_accounts_cheevos_list(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_ACCOUNTS_CHEEVOS_LIST); -} - -static int deferred_push_help(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_HELP_SCREEN_LIST); -} - -static int deferred_push_rdb_entry_detail(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_DATABASE_ENTRY); -} - -static int deferred_push_rpl_entry_actions(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_HORIZONTAL_CONTENT_ACTIONS); -} - -static int deferred_push_core_list_deferred(menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_CORES_SUPPORTED); -} - -static int deferred_push_core_collection_list_deferred( - menu_displaylist_info_t *info) -{ - return deferred_push_dlist(info, DISPLAYLIST_CORES_COLLECTION_SUPPORTED); -} - +generic_deferred_push(deferred_push_onscreen_display_settings_list, DISPLAYLIST_ONSCREEN_DISPLAY_SETTINGS_LIST) +generic_deferred_push(deferred_push_onscreen_notifications_settings_list, DISPLAYLIST_ONSCREEN_NOTIFICATIONS_SETTINGS_LIST) +generic_deferred_push(deferred_push_onscreen_overlay_settings_list, DISPLAYLIST_ONSCREEN_OVERLAY_SETTINGS_LIST) +generic_deferred_push(deferred_push_menu_file_browser_settings_list,DISPLAYLIST_MENU_FILE_BROWSER_SETTINGS_LIST) +generic_deferred_push(deferred_push_menu_views_settings_list, DISPLAYLIST_MENU_VIEWS_SETTINGS_LIST) +generic_deferred_push(deferred_push_quick_menu_views_settings_list, DISPLAYLIST_QUICK_MENU_VIEWS_SETTINGS_LIST) +generic_deferred_push(deferred_push_menu_settings_list, DISPLAYLIST_MENU_SETTINGS_LIST) +generic_deferred_push(deferred_push_user_interface_settings_list, DISPLAYLIST_USER_INTERFACE_SETTINGS_LIST) +generic_deferred_push(deferred_push_retro_achievements_settings_list,DISPLAYLIST_RETRO_ACHIEVEMENTS_SETTINGS_LIST) +generic_deferred_push(deferred_push_updater_settings_list, DISPLAYLIST_UPDATER_SETTINGS_LIST) +generic_deferred_push(deferred_push_wifi_settings_list, DISPLAYLIST_WIFI_SETTINGS_LIST) +generic_deferred_push(deferred_push_network_settings_list, DISPLAYLIST_NETWORK_SETTINGS_LIST) +generic_deferred_push(deferred_push_lakka_services_list, DISPLAYLIST_LAKKA_SERVICES_LIST) +generic_deferred_push(deferred_push_user_settings_list, DISPLAYLIST_USER_SETTINGS_LIST) +generic_deferred_push(deferred_push_directory_settings_list, DISPLAYLIST_DIRECTORY_SETTINGS_LIST) +generic_deferred_push(deferred_push_privacy_settings_list, DISPLAYLIST_PRIVACY_SETTINGS_LIST) +generic_deferred_push(deferred_push_audio_settings_list, DISPLAYLIST_AUDIO_SETTINGS_LIST) +generic_deferred_push(deferred_push_input_settings_list, DISPLAYLIST_INPUT_SETTINGS_LIST) +generic_deferred_push(deferred_push_recording_settings_list, DISPLAYLIST_RECORDING_SETTINGS_LIST) +generic_deferred_push(deferred_push_playlist_settings_list, DISPLAYLIST_PLAYLIST_SETTINGS_LIST) +generic_deferred_push(deferred_push_input_hotkey_binds_list, DISPLAYLIST_INPUT_HOTKEY_BINDS_LIST) +generic_deferred_push(deferred_push_accounts_cheevos_list, DISPLAYLIST_ACCOUNTS_CHEEVOS_LIST) +generic_deferred_push(deferred_push_help, DISPLAYLIST_HELP_SCREEN_LIST) +generic_deferred_push(deferred_push_rdb_entry_detail, DISPLAYLIST_DATABASE_ENTRY) +generic_deferred_push(deferred_push_rpl_entry_actions, DISPLAYLIST_HORIZONTAL_CONTENT_ACTIONS) +generic_deferred_push(deferred_push_core_list_deferred, DISPLAYLIST_CORES_SUPPORTED) +generic_deferred_push(deferred_push_core_collection_list_deferred, DISPLAYLIST_CORES_COLLECTION_SUPPORTED) #ifdef HAVE_NETWORKING generic_deferred_push(deferred_push_thumbnails_updater_list, DISPLAYLIST_THUMBNAILS_UPDATER) From 7ba46356e698e6979814fe364565f0f7487d2aca Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 5 Dec 2017 15:44:41 +0100 Subject: [PATCH 213/394] Cut down on code duplication --- menu/cbs/menu_cbs_deferred_push.c | 112 ++++++------------------------ 1 file changed, 20 insertions(+), 92 deletions(-) diff --git a/menu/cbs/menu_cbs_deferred_push.c b/menu/cbs/menu_cbs_deferred_push.c index 3d158cc4b9..9a93e60dda 100644 --- a/menu/cbs/menu_cbs_deferred_push.c +++ b/menu/cbs/menu_cbs_deferred_push.c @@ -259,101 +259,29 @@ end: return ret; } -static int deferred_push_cursor_manager_list_deferred_query_rdb_entry_max_users( - menu_displaylist_info_t *info) -{ - return deferred_push_cursor_manager_list_generic(info, DATABASE_QUERY_ENTRY_MAX_USERS); +#define generic_deferred_cursor_manager(name, type) \ +static int (name)(menu_displaylist_info_t *info) \ +{ \ + return deferred_push_cursor_manager_list_generic(info, type); \ } -static int deferred_push_cursor_manager_list_deferred_query_rdb_entry_famitsu_magazine_rating( - menu_displaylist_info_t *info) -{ - return deferred_push_cursor_manager_list_generic(info, DATABASE_QUERY_ENTRY_FAMITSU_MAGAZINE_RATING); -} +generic_deferred_cursor_manager(deferred_push_cursor_manager_list_deferred_query_rdb_entry_max_users, DATABASE_QUERY_ENTRY_MAX_USERS) +generic_deferred_cursor_manager(deferred_push_cursor_manager_list_deferred_query_rdb_entry_famitsu_magazine_rating, DATABASE_QUERY_ENTRY_FAMITSU_MAGAZINE_RATING) +generic_deferred_cursor_manager(deferred_push_cursor_manager_list_deferred_query_rdb_entry_edge_magazine_rating, DATABASE_QUERY_ENTRY_EDGE_MAGAZINE_RATING) +generic_deferred_cursor_manager(deferred_push_cursor_manager_list_deferred_query_rdb_entry_edge_magazine_issue, DATABASE_QUERY_ENTRY_EDGE_MAGAZINE_ISSUE) +generic_deferred_cursor_manager(deferred_push_cursor_manager_list_deferred_query_rdb_entry_elspa_rating, DATABASE_QUERY_ENTRY_ELSPA_RATING) +generic_deferred_cursor_manager(deferred_push_cursor_manager_list_deferred_query_rdb_entry_cero_rating, DATABASE_QUERY_ENTRY_CERO_RATING) +generic_deferred_cursor_manager(deferred_push_cursor_manager_list_deferred_query_rdb_entry_pegi_rating, DATABASE_QUERY_ENTRY_PEGI_RATING) +generic_deferred_cursor_manager(deferred_push_cursor_manager_list_deferred_query_rdb_entry_bbfc_rating, DATABASE_QUERY_ENTRY_BBFC_RATING) +generic_deferred_cursor_manager(deferred_push_cursor_manager_list_deferred_query_rdb_entry_esrb_rating, DATABASE_QUERY_ENTRY_ESRB_RATING) +generic_deferred_cursor_manager(deferred_push_cursor_manager_list_deferred_query_rdb_entry_enhancement_hw, DATABASE_QUERY_ENTRY_ENHANCEMENT_HW) +generic_deferred_cursor_manager(deferred_push_cursor_manager_list_deferred_query_rdb_entry_franchise, DATABASE_QUERY_ENTRY_FRANCHISE) +generic_deferred_cursor_manager(deferred_push_cursor_manager_list_deferred_query_rdb_entry_publisher, DATABASE_QUERY_ENTRY_PUBLISHER) +generic_deferred_cursor_manager(deferred_push_cursor_manager_list_deferred_query_rdb_entry_developer, DATABASE_QUERY_ENTRY_DEVELOPER) +generic_deferred_cursor_manager(deferred_push_cursor_manager_list_deferred_query_rdb_entry_origin, DATABASE_QUERY_ENTRY_ORIGIN) +generic_deferred_cursor_manager(deferred_push_cursor_manager_list_deferred_query_rdb_entry_releasemonth, DATABASE_QUERY_ENTRY_RELEASEDATE_MONTH) +generic_deferred_cursor_manager(deferred_push_cursor_manager_list_deferred_query_rdb_entry_releaseyear, DATABASE_QUERY_ENTRY_RELEASEDATE_YEAR) -static int deferred_push_cursor_manager_list_deferred_query_rdb_entry_edge_magazine_rating( - menu_displaylist_info_t *info) -{ - return deferred_push_cursor_manager_list_generic(info, DATABASE_QUERY_ENTRY_EDGE_MAGAZINE_RATING); -} - -static int deferred_push_cursor_manager_list_deferred_query_rdb_entry_edge_magazine_issue( - menu_displaylist_info_t *info) -{ - return deferred_push_cursor_manager_list_generic(info, DATABASE_QUERY_ENTRY_EDGE_MAGAZINE_ISSUE); -} - -static int deferred_push_cursor_manager_list_deferred_query_rdb_entry_elspa_rating( - menu_displaylist_info_t *info) -{ - return deferred_push_cursor_manager_list_generic(info, DATABASE_QUERY_ENTRY_ELSPA_RATING); -} - -static int deferred_push_cursor_manager_list_deferred_query_rdb_entry_cero_rating( - menu_displaylist_info_t *info) -{ - return deferred_push_cursor_manager_list_generic(info, DATABASE_QUERY_ENTRY_CERO_RATING); -} - -static int deferred_push_cursor_manager_list_deferred_query_rdb_entry_pegi_rating( - menu_displaylist_info_t *info) -{ - return deferred_push_cursor_manager_list_generic(info, DATABASE_QUERY_ENTRY_PEGI_RATING); -} - -static int deferred_push_cursor_manager_list_deferred_query_rdb_entry_bbfc_rating( - menu_displaylist_info_t *info) -{ - return deferred_push_cursor_manager_list_generic(info, DATABASE_QUERY_ENTRY_BBFC_RATING); -} - -static int deferred_push_cursor_manager_list_deferred_query_rdb_entry_esrb_rating( - menu_displaylist_info_t *info) -{ - return deferred_push_cursor_manager_list_generic(info, DATABASE_QUERY_ENTRY_ESRB_RATING); -} - -static int deferred_push_cursor_manager_list_deferred_query_rdb_entry_enhancement_hw( - menu_displaylist_info_t *info) -{ - return deferred_push_cursor_manager_list_generic(info, DATABASE_QUERY_ENTRY_ENHANCEMENT_HW); -} - -static int deferred_push_cursor_manager_list_deferred_query_rdb_entry_franchise( - menu_displaylist_info_t *info) -{ - return deferred_push_cursor_manager_list_generic(info, DATABASE_QUERY_ENTRY_FRANCHISE); -} - -static int deferred_push_cursor_manager_list_deferred_query_rdb_entry_publisher( - menu_displaylist_info_t *info) -{ - return deferred_push_cursor_manager_list_generic(info, DATABASE_QUERY_ENTRY_PUBLISHER); -} - -static int deferred_push_cursor_manager_list_deferred_query_rdb_entry_developer( - menu_displaylist_info_t *info) -{ - return deferred_push_cursor_manager_list_generic(info, DATABASE_QUERY_ENTRY_DEVELOPER); -} - -static int deferred_push_cursor_manager_list_deferred_query_rdb_entry_origin( - menu_displaylist_info_t *info) -{ - return deferred_push_cursor_manager_list_generic(info, DATABASE_QUERY_ENTRY_ORIGIN); -} - -static int deferred_push_cursor_manager_list_deferred_query_rdb_entry_releasemonth( - menu_displaylist_info_t *info) -{ - return deferred_push_cursor_manager_list_generic(info, DATABASE_QUERY_ENTRY_RELEASEDATE_MONTH); -} - -static int deferred_push_cursor_manager_list_deferred_query_rdb_entry_releaseyear( - menu_displaylist_info_t *info) -{ - return deferred_push_cursor_manager_list_generic(info, DATABASE_QUERY_ENTRY_RELEASEDATE_YEAR); -} #endif #if 0 From 4b4ae0c1a005c589362a578f73b3ea6404f7ab43 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 5 Dec 2017 16:09:19 +0100 Subject: [PATCH 214/394] Update CHANGES.md --- CHANGES.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index cabe1a0b9c..bef6f254b5 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -7,6 +7,8 @@ - COMMON: New lightgun API. - FREEBSD: Support libusb HID input driver. - HAIKU: Buildfix. +- LINUX/X11: Add RetroArch logo to window title bar. +- LINUX/X11: Input driver now supports new lightgun code. - LOCALIZATION: Update Italian translation. - LOCALIZATION: Update Portuguese-Brazilian translation. - LOCALIZATION: Update Russian translation. @@ -14,8 +16,6 @@ - SCANNER: Fix crash from Windows-incompatible format string. - WIIU: Disabled the controller patcher for now since it was the source of many stability issues. - WINDOWS: Raw input driver now supports new lightgun code. -- X11: Add RetroArch logo to window title bar. -- X11: Input driver now supports new lightgun code. # 1.6.9 - COMMON: Small memory leak. From 4cb739d45aacb17c3137eb48e5548aced18b4b17 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 5 Dec 2017 16:09:44 +0100 Subject: [PATCH 215/394] Update CHANGES.md --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index bef6f254b5..9a962e0dcf 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -5,6 +5,7 @@ - COMMON: Optimized NBIO implementations now for Apple, Windows, and Linux. Uses mmap for Linux/Windows/BSD if/when available. File I/O should now be much faster for loading images inside the menu. - COMMON: Native Blissbox support now for latest firmware as of writing (2.0). Implementation through libusb and/or native Windows HID. - COMMON: New lightgun API. +- COMMON: Fixed some playlist bugs. - FREEBSD: Support libusb HID input driver. - HAIKU: Buildfix. - LINUX/X11: Add RetroArch logo to window title bar. From 69295c21790c85820576541544589ddcfc4caffd Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 5 Dec 2017 16:20:52 +0100 Subject: [PATCH 216/394] Fix BIT_GET --- libretro-common/include/retro_miscellaneous.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libretro-common/include/retro_miscellaneous.h b/libretro-common/include/retro_miscellaneous.h index 010b04f19c..bfebd1f8e8 100644 --- a/libretro-common/include/retro_miscellaneous.h +++ b/libretro-common/include/retro_miscellaneous.h @@ -83,7 +83,7 @@ static INLINE bool bits_any_set(uint32_t* ptr, uint32_t count) #define BIT_SET(a, bit) ((a)[(bit) >> 3] |= (1 << ((bit) & 7))) #define BIT_CLEAR(a, bit) ((a)[(bit) >> 3] &= ~(1 << ((bit) & 7))) -#define BIT_GET(a, bit) (((a).data[(bit) >> 3] >> ((bit) & 7)) & 1) +#define BIT_GET(a, bit) (((a)[(bit) >> 3] >> ((bit) & 7)) & 1) #define BIT16_SET(a, bit) ((a) |= (1 << ((bit) & 15))) #define BIT16_CLEAR(a, bit) ((a) &= ~(1 << ((bit) & 15))) From 88b85c2d15e18c0fc5b5bcdb1ad0822b313a63a0 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 5 Dec 2017 16:27:39 +0100 Subject: [PATCH 217/394] Fix it for C89 --- intl/msg_hash_de.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/intl/msg_hash_de.c b/intl/msg_hash_de.c index 333f191a49..24b7eb69ce 100644 --- a/intl/msg_hash_de.c +++ b/intl/msg_hash_de.c @@ -904,13 +904,19 @@ int menu_hash_get_help_de_enum(enum msg_hash_enums msg, char *s, size_t len) break; case MENU_ENUM_LABEL_VIDEO_SHADER_SCALE_PASS: snprintf(s, len, + " \n" + ); + { + /* Work around C89 limitations */ + const char * t = "Für diesen durchgang skalieren. \n" " \n" "Der Skalierungsfaktor wird multipliziert, \n" "d.h. 2x im ersten durchgang und 2x im \n" "zweiten durchgang bedeute eine 4x Gesamt- \n" "Skalierung." - " \n" + " \n"; + const char * u = "Wenn es im letzten durchgang einen \n" "Skalierungsfaktor gibt, wird das Ergebnis \n" "mit dem als 'Standardfilter' eingestellten \n" @@ -919,8 +925,10 @@ int menu_hash_get_help_de_enum(enum msg_hash_enums msg, char *s, size_t len) "Wenn 'Ignorieren' eingestellt ist, wird \n" "entweder einfache Skalierung oder Vollbild- \n" "Streckung verwendet - abhängig davon, ob \n" - "es der letzte durchgang ist oder nicht." - ); + "es der letzte durchgang ist oder nicht."; + strlcpy(s, t, len); + strlcat(s, u, len); + } break; case MENU_ENUM_LABEL_VIDEO_SHADER_NUM_PASSES: snprintf(s, len, From de900325c6247fd20be59c5c7460927abb4099e4 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 5 Dec 2017 16:31:58 +0100 Subject: [PATCH 218/394] More C89_BUILD fixes --- intl/msg_hash_de.c | 51 +++++++++++++++++++++++++++++++--------------- 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/intl/msg_hash_de.c b/intl/msg_hash_de.c index 24b7eb69ce..6f56a0dd5a 100644 --- a/intl/msg_hash_de.c +++ b/intl/msg_hash_de.c @@ -1141,7 +1141,9 @@ int menu_hash_get_help_de_enum(enum msg_hash_enums msg, char *s, size_t len) "Verwendet für Inhalt, der auf mehreren Datenträgern ausgeliefert wird. "); break; case MENU_ENUM_LABEL_ENABLE_HOTKEY: - snprintf(s, len, + { + /* Work around C89 limitations */ + const char * t = "Andere Tastenkürzel aktivieren. \n" " \n" "Wenn dieses Tastenkürzel entweder einer\n" @@ -1149,14 +1151,18 @@ int menu_hash_get_help_de_enum(enum msg_hash_enums msg, char *s, size_t len) "Controller-Achse zugeordnet ist, werden alle \n" "anderen Tastenkürzel nur aktiviert, wenn dieses \n" "Tastenkürzel zur gleichen Zeit gehalten wird. \n" - " \n" + " \n"; + const char * u = "Dies ist hilfreich für Implementierungen, die auf \n" "RETRO_KEYBOARD ausgelegt sind und eine große \n" "Fläche auf der Tastatur benötigen, wo es nicht \n" "gewünscht ist, dass es zu Kollisionen mit Tastenkürzeln kommt \n." " \n" "Alternativ können auch alle Tastatur-Kürzel durch \n" - "den Benutzer deaktiviert werden."); + "den Benutzer deaktiviert werden."; + strlcpy(s, t, len); + strlcat(s, u, len); + } break; case MENU_ENUM_LABEL_REWIND_ENABLE: snprintf(s, len, @@ -1173,7 +1179,9 @@ int menu_hash_get_help_de_enum(enum msg_hash_enums msg, char *s, size_t len) "Libretro-Core-Implementierungen gesucht wird."); break; case MENU_ENUM_LABEL_VIDEO_REFRESH_RATE_AUTO: - snprintf(s, len, + { + /* Work around C89 limitations */ + const char * t = "Bildwiederholrate.\n" " \n" "Die genaue Bildwiederholrate deines Bildschirms (Hz).\n" @@ -1182,14 +1190,19 @@ int menu_hash_get_help_de_enum(enum msg_hash_enums msg, char *s, size_t len) " \n" "audio_input_rate = Spiel-Eingaberate * Bildschirm- \n" "Wiederholrate / Spiel-Wiederholrate\n" - " \n" + " \n"; + const char * u = "Wenn die Implementierung keinen Wert liefert, \n" "werden aus Kompatiblitätsgründen die Werte für NTSC \n" "angenommen.\n" " \n" "Dieser Wert sollte nahe 60Hz liegen, um Tonsprünge zu vermeiden. \n" "Wenn dein Bildschirm nicht auf 60Hz oder einem ähnlichen Wert läuft, \n" - "deaktiviere VSync und lasse diese Einstellung unverändert. \n"); + "deaktiviere VSync und lasse diese Einstellung unverändert. \n"; + ; + strlcpy(s, t, len); + strlcat(s, u, len); + } break; case MENU_ENUM_LABEL_VIDEO_ROTATION: snprintf(s, len, @@ -1602,20 +1615,26 @@ int menu_hash_get_help_de_enum(enum msg_hash_enums msg, char *s, size_t len) "tritt keine Netplay-Verzögerung auf.\n"); break; case MENU_ENUM_LABEL_NETPLAY_CHECK_FRAMES: - snprintf(s, len, + { + /* Work around C89 limitations */ + const char * t = "Die Frequenz in Einzelbildern, mit der Netplay \n" "sicherstellen wird, dass Host und Clients \n" "synchronisiert sind. \n" " \n" - "Bei den meisten Cores wird diese Einstellungen \n" - "keine sichtbaren Auswirkungen haben und kann ignoriert werden. \n" - "Bei nichtdeterministischen Cores legt dieser Wert fest, \n" - "wie oft die Netplay-Mitglieder miteinander synchronisiert \n" - "werden. Bei fehlerhaften Cores wird ein \n" - "anderer Wert als 0 für diese Einstellung erhebliche \n" - "Leistungsprobleme verursachen. Auf 0 setzen, um keine \n" - "Überprüfungen durchzuführen. Diese Einstellung wird nur \n" - "auf dem Netplay-Host verwendet. \n"); + "Bei den meisten Cores wird diese Einstellungen \n" + "keine sichtbaren Auswirkungen haben und kann ignoriert werden. \n"; + const char *u = + "Bei nichtdeterministischen Cores legt dieser Wert fest, \n" + "wie oft die Netplay-Mitglieder miteinander synchronisiert \n" + "werden. Bei fehlerhaften Cores wird ein \n" + "anderer Wert als 0 für diese Einstellung erhebliche \n" + "Leistungsprobleme verursachen. Auf 0 setzen, um keine \n" + "Überprüfungen durchzuführen. Diese Einstellung wird nur \n" + "auf dem Netplay-Host verwendet. \n"; + strlcpy(s, t, len); + strlcat(s, u, len); + } break; case MENU_ENUM_LABEL_NETPLAY_INPUT_LATENCY_FRAMES_MIN: snprintf(s, len, From 3ede6a9aebd704361530a7f6b3b41bae2b278d0d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 5 Dec 2017 16:35:03 +0100 Subject: [PATCH 219/394] Some C89_BUILD fixes --- cheevos/cheevos.c | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/cheevos/cheevos.c b/cheevos/cheevos.c index b2cf87154b..b9df229ac7 100644 --- a/cheevos/cheevos.c +++ b/cheevos/cheevos.c @@ -1796,6 +1796,7 @@ static void cheevos_test_cheevo_set(const cheevoset_t *set) } else if (valid) { + char msg[256]; char url[256]; url[0] = '\0'; @@ -1807,7 +1808,6 @@ static void cheevos_test_cheevo_set(const cheevoset_t *set) RARCH_LOG("[CHEEVOS]: awarding cheevo %u: %s (%s).\n", cheevo->id, cheevo->title, cheevo->description); - char msg[256]; snprintf(msg, sizeof(msg), "Achievement Unlocked: %s", cheevo->title); msg[sizeof(msg) - 1] = 0; runloop_msg_queue_push(msg, 0, 2 * 60, false); @@ -1856,10 +1856,11 @@ static int cheevos_expr_value(cheevos_expr_t* expr) { cheevos_term_t* term = expr->terms; unsigned i; - /* Separate possible values with '$' operator, submit the largest */ unsigned current_value = 0; + /* TODO/FIXME - variable length forbidden in C89 - rewrite this! */ int values[expr->compare_count]; + memset(values, 0, sizeof values); for (i = expr->count; i != 0; i--, term++) @@ -1974,12 +1975,13 @@ static void cheevos_test_leaderboards(void) else { char url[256]; + char msg[256]; + char formatted_value[16]; + cheevos_make_lboard_url(lboard, url, sizeof(url)); task_push_http_transfer(url, true, NULL, cheevos_lboard_submit, lboard); RARCH_LOG("[CHEEVOS]: submit lboard %s\n", lboard->title); - char msg[256]; - char formatted_value[16]; cheevos_format_value(value, lboard->format, formatted_value, sizeof(formatted_value)); snprintf(msg, sizeof(msg), "Submitted %s for %s", formatted_value, lboard->title); msg[sizeof(msg) - 1] = 0; @@ -1998,11 +2000,12 @@ static void cheevos_test_leaderboards(void) { if (cheevos_test_lboard_condition(&lboard->start)) { + char msg[256]; + RARCH_LOG("[CHEEVOS]: start lboard %s\n", lboard->title); lboard->active = 1; lboard->last_value = -1; - char msg[256]; snprintf(msg, sizeof(msg), "Leaderboard Active: %s", lboard->title); msg[sizeof(msg) - 1] = 0; runloop_msg_queue_push(msg, 0, 2 * 60, false); @@ -2835,10 +2838,10 @@ static int cheevos_iterate(coro_t* coro) { if(cheevos_locals.core.count > 0) { + int mode; const cheevo_t* cheevo = cheevos_locals.core.cheevos; const cheevo_t* end = cheevo + cheevos_locals.core.count; int number_of_unlocked = cheevos_locals.core.count; - int mode; char msg[256]; if(CHEEVOS_VAR_SETTINGS->bools.cheevos_hardcore_mode_enable) From 3e81996bd363db34a4b5f951348ce3587e6ddcbd Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 5 Dec 2017 16:40:13 +0100 Subject: [PATCH 220/394] Update D3D headers --- gfx/include/d3d9/d3dx9shader.h | 2 +- gfx/include/d3d9caps.h | 204 ++++++++++++++++----------------- gfx/include/d3d9types.h | 41 +++---- 3 files changed, 120 insertions(+), 127 deletions(-) diff --git a/gfx/include/d3d9/d3dx9shader.h b/gfx/include/d3d9/d3dx9shader.h index 46ddf4c85a..74e40cfc80 100644 --- a/gfx/include/d3d9/d3dx9shader.h +++ b/gfx/include/d3d9/d3dx9shader.h @@ -643,4 +643,4 @@ typedef struct _D3DXSHADER_STRUCTMEMBERINFO -#endif //__D3DX9SHADER_H__ +#endif /* __D3DX9SHADER_H__ */ diff --git a/gfx/include/d3d9caps.h b/gfx/include/d3d9caps.h index 96a9bef9d4..adc3fb1f8d 100644 --- a/gfx/include/d3d9caps.h +++ b/gfx/include/d3d9caps.h @@ -12,9 +12,9 @@ #ifndef DIRECT3D_VERSION #define DIRECT3D_VERSION 0x0900 -#endif //DIRECT3D_VERSION +#endif /* DIRECT3D_VERSION */ -// include this file content only if compiling for DX9 interfaces +/* include this file content only if compiling for DX9 interfaces */ #if(DIRECT3D_VERSION >= 0x0900) @@ -117,7 +117,7 @@ DEFINE_GUID(D3DKEYEXCHANGE_RSAES_OAEP, DEFINE_GUID(D3DKEYEXCHANGE_DXVA, 0x43d3775c, 0x38e5, 0x4924, 0x8d, 0x86, 0xd3, 0xfc, 0xcf, 0x15, 0x3e, 0x9b); -#endif // !D3D_DISABLE_9EX +#endif /* !D3D_DISABLE_9EX */ /* -- D3D9Ex only */ typedef struct _D3DCAPS9 @@ -146,13 +146,13 @@ typedef struct _D3DCAPS9 DWORD AlphaCmpCaps; DWORD ShadeCaps; DWORD TextureCaps; - DWORD TextureFilterCaps; // D3DPTFILTERCAPS for IDirect3DTexture9's - DWORD CubeTextureFilterCaps; // D3DPTFILTERCAPS for IDirect3DCubeTexture9's - DWORD VolumeTextureFilterCaps; // D3DPTFILTERCAPS for IDirect3DVolumeTexture9's - DWORD TextureAddressCaps; // D3DPTADDRESSCAPS for IDirect3DTexture9's - DWORD VolumeTextureAddressCaps; // D3DPTADDRESSCAPS for IDirect3DVolumeTexture9's + DWORD TextureFilterCaps; /* D3DPTFILTERCAPS for IDirect3DTexture9's */ + DWORD CubeTextureFilterCaps; /* D3DPTFILTERCAPS for IDirect3DCubeTexture9's */ + DWORD VolumeTextureFilterCaps; /* D3DPTFILTERCAPS for IDirect3DVolumeTexture9's */ + DWORD TextureAddressCaps; /* D3DPTADDRESSCAPS for IDirect3DTexture9's */ + DWORD VolumeTextureAddressCaps; /* D3DPTADDRESSCAPS for IDirect3DVolumeTexture9's */ - DWORD LineCaps; // D3DLINECAPS + DWORD LineCaps; /* D3DLINECAPS */ DWORD MaxTextureWidth, MaxTextureHeight; DWORD MaxVolumeExtent; @@ -183,51 +183,49 @@ typedef struct _D3DCAPS9 float MaxPointSize; - DWORD MaxPrimitiveCount; // max number of primitives per DrawPrimitive call + DWORD MaxPrimitiveCount; /* max number of primitives per DrawPrimitive call */ DWORD MaxVertexIndex; DWORD MaxStreams; - DWORD MaxStreamStride; // max stride for SetStreamSource + DWORD MaxStreamStride; /* max stride for SetStreamSource */ DWORD VertexShaderVersion; - DWORD MaxVertexShaderConst; // number of vertex shader constant registers + DWORD MaxVertexShaderConst; /* number of vertex shader constant registers */ DWORD PixelShaderVersion; - float PixelShader1xMaxValue; // max value storable in registers of ps.1.x shaders + float PixelShader1xMaxValue; /* max value storable in registers of ps.1.x shaders */ - // Here are the DX9 specific ones + /* Here are the DX9 specific ones */ DWORD DevCaps2; float MaxNpatchTessellationLevel; DWORD Reserved5; - UINT MasterAdapterOrdinal; // ordinal of master adaptor for adapter group - UINT AdapterOrdinalInGroup; // ordinal inside the adapter group - UINT NumberOfAdaptersInGroup; // number of adapters in this adapter group (only if master) - DWORD DeclTypes; // Data types, supported in vertex declarations - DWORD NumSimultaneousRTs; // Will be at least 1 - DWORD StretchRectFilterCaps; // Filter caps supported by StretchRect + UINT MasterAdapterOrdinal; /* ordinal of master adaptor for adapter group */ + UINT AdapterOrdinalInGroup; /* ordinal inside the adapter group */ + UINT NumberOfAdaptersInGroup; /* number of adapters in this adapter group (only if master) */ + DWORD DeclTypes; /* Data types, supported in vertex declarations */ + DWORD NumSimultaneousRTs; /* Will be at least 1 */ + DWORD StretchRectFilterCaps; /* Filter caps supported by StretchRect */ D3DVSHADERCAPS2_0 VS20Caps; D3DPSHADERCAPS2_0 PS20Caps; - DWORD VertexTextureFilterCaps; // D3DPTFILTERCAPS for IDirect3DTexture9's for texture, used in vertex shaders - DWORD MaxVShaderInstructionsExecuted; // maximum number of vertex shader instructions that can be executed - DWORD MaxPShaderInstructionsExecuted; // maximum number of pixel shader instructions that can be executed + DWORD VertexTextureFilterCaps; /* D3DPTFILTERCAPS for IDirect3DTexture9's for texture, used in vertex shaders */ + DWORD MaxVShaderInstructionsExecuted; /* maximum number of vertex shader instructions that can be executed */ + DWORD MaxPShaderInstructionsExecuted; /* maximum number of pixel shader instructions that can be executed */ DWORD MaxVertexShader30InstructionSlots; DWORD MaxPixelShader30InstructionSlots; } D3DCAPS9; -// -// BIT DEFINES FOR D3DCAPS9 DWORD MEMBERS -// +/* + * BIT DEFINES FOR D3DCAPS9 DWORD MEMBERS + */ -// -// Caps -// +/* + * Caps + */ #define D3DCAPS_OVERLAY 0x00000800L #define D3DCAPS_READ_SCANLINE 0x00020000L -// -// Caps2 -// +/* Caps2 */ #define D3DCAPS2_FULLSCREENGAMMA 0x00020000L #define D3DCAPS2_CANCALIBRATEGAMMA 0x00100000L #define D3DCAPS2_RESERVED 0x02000000L @@ -240,21 +238,21 @@ typedef struct _D3DCAPS9 #define D3DCAPS2_CANSHARERESOURCE 0x80000000L -#endif // !D3D_DISABLE_9EX +#endif /* !D3D_DISABLE_9EX */ /* -- D3D9Ex only */ -// -// Caps3 -// +/* Caps3 */ #define D3DCAPS3_RESERVED 0x8000001fL -// Indicates that the device can respect the ALPHABLENDENABLE render state -// when fullscreen while using the FLIP or DISCARD swap effect. -// COPY and COPYVSYNC swap effects work whether or not this flag is set. +/* Indicates that the device can respect the ALPHABLENDENABLE render state + * when fullscreen while using the FLIP or DISCARD swap effect. + * COPY and COPYVSYNC swap effects work whether or not this flag is set. + */ #define D3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD 0x00000020L -// Indicates that the device can perform a gamma correction from -// a windowed back buffer containing linear content to the sRGB desktop. +/* Indicates that the device can perform a gamma correction from + * a windowed back buffer containing linear content to the sRGB desktop. + */ #define D3DCAPS3_LINEAR_TO_SRGB_PRESENTATION 0x00000080L #define D3DCAPS3_COPY_TO_VIDMEM 0x00000100L /* Device can acclerate copies from sysmem to local vidmem */ @@ -262,10 +260,7 @@ typedef struct _D3DCAPS9 #define D3DCAPS3_DXVAHD 0x00000400L #define D3DCAPS3_DXVAHD_LIMITED 0x00000800L - -// -// PresentationIntervals -// +/* PresentationIntervals */ #define D3DPRESENT_INTERVAL_DEFAULT 0x00000000L #define D3DPRESENT_INTERVAL_ONE 0x00000001L #define D3DPRESENT_INTERVAL_TWO 0x00000002L @@ -273,17 +268,13 @@ typedef struct _D3DCAPS9 #define D3DPRESENT_INTERVAL_FOUR 0x00000008L #define D3DPRESENT_INTERVAL_IMMEDIATE 0x80000000L -// -// CursorCaps -// -// Driver supports HW color cursor in at least hi-res modes(height >=400) +/* CursorCaps */ +/* Driver supports HW color cursor in at least hi-res modes(height >=400) */ #define D3DCURSORCAPS_COLOR 0x00000001L -// Driver supports HW cursor also in low-res modes(height < 400) +/* Driver supports HW cursor also in low-res modes(height < 400) */ #define D3DCURSORCAPS_LOWRES 0x00000002L -// -// DevCaps -// +/* DevCaps */ #define D3DDEVCAPS_EXECUTESYSTEMMEMORY 0x00000010L /* Device can use execute buffers from system memory */ #define D3DDEVCAPS_EXECUTEVIDEOMEMORY 0x00000020L /* Device can use execute buffers from video memory */ #define D3DDEVCAPS_TLVERTEXSYSTEMMEMORY 0x00000040L /* Device can use TL buffers from system memory */ @@ -305,9 +296,9 @@ typedef struct _D3DCAPS9 #define D3DDEVCAPS_RTPATCHHANDLEZERO 0x00800000L /* Indicates that RT Patches may be drawn efficiently using handle 0 */ #define D3DDEVCAPS_NPATCHES 0x01000000L /* Device supports N-Patches */ -// -// PrimitiveMiscCaps -// +/* + * PrimitiveMiscCaps + */ #define D3DPMISCCAPS_MASKZ 0x00000002L #define D3DPMISCCAPS_CULLNONE 0x00000010L #define D3DPMISCCAPS_CULLCW 0x00000020L @@ -332,13 +323,13 @@ typedef struct _D3DCAPS9 #define D3DPMISCCAPS_POSTBLENDSRGBCONVERT 0x00200000L /* Indicates device can perform conversion to sRGB after blending. */ -#endif // !D3D_DISABLE_9EX +#endif /* !D3D_DISABLE_9EX */ /* -- D3D9Ex only */ -// -// LineCaps -// +/* + * LineCaps + */ #define D3DLINECAPS_TEXTURE 0x00000001L #define D3DLINECAPS_ZTEST 0x00000002L #define D3DLINECAPS_BLEND 0x00000004L @@ -346,9 +337,9 @@ typedef struct _D3DCAPS9 #define D3DLINECAPS_FOG 0x00000010L #define D3DLINECAPS_ANTIALIAS 0x00000020L -// -// RasterCaps -// +/* + * RasterCaps + */ #define D3DPRASTERCAPS_DITHER 0x00000001L #define D3DPRASTERCAPS_ZTEST 0x00000010L #define D3DPRASTERCAPS_FOGVERTEX 0x00000080L @@ -366,9 +357,9 @@ typedef struct _D3DCAPS9 #define D3DPRASTERCAPS_DEPTHBIAS 0x04000000L #define D3DPRASTERCAPS_MULTISAMPLE_TOGGLE 0x08000000L -// -// ZCmpCaps, AlphaCmpCaps -// +/* + * ZCmpCaps, AlphaCmpCaps + */ #define D3DPCMPCAPS_NEVER 0x00000001L #define D3DPCMPCAPS_LESS 0x00000002L #define D3DPCMPCAPS_EQUAL 0x00000004L @@ -378,9 +369,9 @@ typedef struct _D3DCAPS9 #define D3DPCMPCAPS_GREATEREQUAL 0x00000040L #define D3DPCMPCAPS_ALWAYS 0x00000080L -// -// SourceBlendCaps, DestBlendCaps -// +/* + * SourceBlendCaps, DestBlendCaps + */ #define D3DPBLENDCAPS_ZERO 0x00000001L #define D3DPBLENDCAPS_ONE 0x00000002L #define D3DPBLENDCAPS_SRCCOLOR 0x00000004L @@ -402,31 +393,32 @@ typedef struct _D3DCAPS9 #define D3DPBLENDCAPS_SRCCOLOR2 0x00004000L #define D3DPBLENDCAPS_INVSRCCOLOR2 0x00008000L -#endif // !D3D_DISABLE_9EX +#endif /* !D3D_DISABLE_9EX */ /* -- D3D9Ex only */ - -// -// ShadeCaps -// +/* + * ShadeCaps + */ #define D3DPSHADECAPS_COLORGOURAUDRGB 0x00000008L #define D3DPSHADECAPS_SPECULARGOURAUDRGB 0x00000200L #define D3DPSHADECAPS_ALPHAGOURAUDBLEND 0x00004000L #define D3DPSHADECAPS_FOGGOURAUD 0x00080000L -// -// TextureCaps -// +/* + * TextureCaps + */ #define D3DPTEXTURECAPS_PERSPECTIVE 0x00000001L /* Perspective-correct texturing is supported */ #define D3DPTEXTURECAPS_POW2 0x00000002L /* Power-of-2 texture dimensions are required - applies to non-Cube/Volume textures only. */ #define D3DPTEXTURECAPS_ALPHA 0x00000004L /* Alpha in texture pixels is supported */ #define D3DPTEXTURECAPS_SQUAREONLY 0x00000020L /* Only square textures are supported */ #define D3DPTEXTURECAPS_TEXREPEATNOTSCALEDBYSIZE 0x00000040L /* Texture indices are not scaled by the texture size prior to interpolation */ #define D3DPTEXTURECAPS_ALPHAPALETTE 0x00000080L /* Device can draw alpha from texture palettes */ -// Device can use non-POW2 textures if: -// 1) D3DTEXTURE_ADDRESS is set to CLAMP for this texture's stage -// 2) D3DRS_WRAP(N) is zero for this texture's coordinates -// 3) mip mapping is not enabled (use magnification filter only) + +/* Device can use non-POW2 textures if: + * 1) D3DTEXTURE_ADDRESS is set to CLAMP for this texture's stage + * 2) D3DRS_WRAP(N) is zero for this texture's coordinates + * 3) mip mapping is not enabled (use magnification filter only) + */ #define D3DPTEXTURECAPS_NONPOW2CONDITIONAL 0x00000100L #define D3DPTEXTURECAPS_PROJECTED 0x00000400L /* Device can do D3DTTFF_PROJECTED */ #define D3DPTEXTURECAPS_CUBEMAP 0x00000800L /* Device can do cubemap textures */ @@ -439,9 +431,9 @@ typedef struct _D3DCAPS9 #define D3DPTEXTURECAPS_NOPROJECTEDBUMPENV 0x00200000L /* Device does not support projected bump env lookup operation in programmable and fixed function pixel shaders */ -// -// TextureFilterCaps, StretchRectFilterCaps -// +/* + * TextureFilterCaps, StretchRectFilterCaps + */ #define D3DPTFILTERCAPS_MINFPOINT 0x00000100L /* Min Filter */ #define D3DPTFILTERCAPS_MINFLINEAR 0x00000200L #define D3DPTFILTERCAPS_MINFANISOTROPIC 0x00000400L @@ -455,7 +447,7 @@ typedef struct _D3DCAPS9 #define D3DPTFILTERCAPS_CONVOLUTIONMONO 0x00040000L /* Min and Mag for the convolution mono filter */ -#endif // !D3D_DISABLE_9EX +#endif /* !D3D_DISABLE_9EX */ /* -- D3D9Ex only */ #define D3DPTFILTERCAPS_MAGFPOINT 0x01000000L /* Mag Filter */ @@ -464,9 +456,9 @@ typedef struct _D3DCAPS9 #define D3DPTFILTERCAPS_MAGFPYRAMIDALQUAD 0x08000000L #define D3DPTFILTERCAPS_MAGFGAUSSIANQUAD 0x10000000L -// -// TextureAddressCaps -// +/* + * TextureAddressCaps + */ #define D3DPTADDRESSCAPS_WRAP 0x00000001L #define D3DPTADDRESSCAPS_MIRROR 0x00000002L #define D3DPTADDRESSCAPS_CLAMP 0x00000004L @@ -474,9 +466,9 @@ typedef struct _D3DCAPS9 #define D3DPTADDRESSCAPS_INDEPENDENTUV 0x00000010L #define D3DPTADDRESSCAPS_MIRRORONCE 0x00000020L -// -// StencilCaps -// +/* + * StencilCaps + */ #define D3DSTENCILCAPS_KEEP 0x00000001L #define D3DSTENCILCAPS_ZERO 0x00000002L #define D3DSTENCILCAPS_REPLACE 0x00000004L @@ -487,9 +479,9 @@ typedef struct _D3DCAPS9 #define D3DSTENCILCAPS_DECR 0x00000080L #define D3DSTENCILCAPS_TWOSIDED 0x00000100L -// -// TextureOpCaps -// +/* + * TextureOpCaps + */ #define D3DTEXOPCAPS_DISABLE 0x00000001L #define D3DTEXOPCAPS_SELECTARG1 0x00000002L #define D3DTEXOPCAPS_SELECTARG2 0x00000004L @@ -517,16 +509,16 @@ typedef struct _D3DCAPS9 #define D3DTEXOPCAPS_MULTIPLYADD 0x01000000L #define D3DTEXOPCAPS_LERP 0x02000000L -// -// FVFCaps -// +/* + * FVFCaps + */ #define D3DFVFCAPS_TEXCOORDCOUNTMASK 0x0000ffffL /* mask for texture coordinate count field */ #define D3DFVFCAPS_DONOTSTRIPELEMENTS 0x00080000L /* Device prefers that vertex elements not be stripped */ #define D3DFVFCAPS_PSIZE 0x00100000L /* Device can receive point size */ -// -// VertexProcessingCaps -// +/* + * VertexProcessingCaps + */ #define D3DVTXPCAPS_TEXGEN 0x00000001L /* device can do texgen */ #define D3DVTXPCAPS_MATERIALSOURCE7 0x00000002L /* device can do DX7-level colormaterialsource ops */ #define D3DVTXPCAPS_DIRECTIONALLIGHTS 0x00000008L /* device can do directional lights */ @@ -537,9 +529,9 @@ typedef struct _D3DCAPS9 #define D3DVTXPCAPS_NO_TEXGEN_NONLOCALVIEWER 0x00000200L /* device does not support TexGen in non-local viewer mode */ -// -// DevCaps2 -// +/* + * DevCaps2 + */ #define D3DDEVCAPS2_STREAMOFFSET 0x00000001L /* Device supports offsets in streams. Must be set by DX9 drivers */ #define D3DDEVCAPS2_DMAPNPATCH 0x00000002L /* Device supports displacement maps for N-Patches*/ #define D3DDEVCAPS2_ADAPTIVETESSRTPATCH 0x00000004L /* Device supports adaptive tesselation of RT-patches*/ @@ -548,9 +540,9 @@ typedef struct _D3DCAPS9 #define D3DDEVCAPS2_PRESAMPLEDDMAPNPATCH 0x00000020L /* Device supports presampled displacement maps for N-Patches */ #define D3DDEVCAPS2_VERTEXELEMENTSCANSHARESTREAMOFFSET 0x00000040L /* Vertex elements in a vertex declaration can share the same stream offset */ -// -// DeclTypes -// +/* + * DeclTypes + */ #define D3DDTCAPS_UBYTE4 0x00000001L #define D3DDTCAPS_UBYTE4N 0x00000002L #define D3DDTCAPS_SHORT2N 0x00000004L diff --git a/gfx/include/d3d9types.h b/gfx/include/d3d9types.h index 80fabba9e8..b4b9a94ddf 100644 --- a/gfx/include/d3d9types.h +++ b/gfx/include/d3d9types.h @@ -565,25 +565,25 @@ typedef enum _D3DTEXTUREOP D3DTOP_MODULATE4X = 6, /* multiply and 2 bits */ /* Add */ - D3DTOP_ADD = 7, // add arguments together - D3DTOP_ADDSIGNED = 8, // add with -0.5 bias - D3DTOP_ADDSIGNED2X = 9, // as above but left 1 bit - D3DTOP_SUBTRACT = 10, // Arg1 - Arg2, with no saturation - D3DTOP_ADDSMOOTH = 11, // add 2 args, subtract product - // Arg1 + Arg2 - Arg1*Arg2 - // = Arg1 + (1-Arg1)*Arg2 + D3DTOP_ADD = 7, /* add arguments together */ + D3DTOP_ADDSIGNED = 8, /* add with -0.5 bias */ + D3DTOP_ADDSIGNED2X = 9, /* as above but left 1 bit */ + D3DTOP_SUBTRACT = 10, /* Arg1 - Arg2, with no saturation */ + D3DTOP_ADDSMOOTH = 11, /* add 2 args, subtract product */ + /* Arg1 + Arg2 - Arg1*Arg2 */ + /* = Arg1 + (1-Arg1)*Arg2 */ - // Linear alpha blend: Arg1*(Alpha) + Arg2*(1-Alpha) - D3DTOP_BLENDDIFFUSEALPHA = 12, // iterated alpha - D3DTOP_BLENDTEXTUREALPHA = 13, // texture alpha - D3DTOP_BLENDFACTORALPHA = 14, // alpha from D3DRS_TEXTUREFACTOR + /* Linear alpha blend: Arg1*(Alpha) + Arg2*(1-Alpha) */ + D3DTOP_BLENDDIFFUSEALPHA = 12, /* iterated alpha */ + D3DTOP_BLENDTEXTUREALPHA = 13, /* texture alpha */ + D3DTOP_BLENDFACTORALPHA = 14, /* alpha from D3DRS_TEXTUREFACTOR */ - // Linear alpha blend with pre-multiplied arg1 input: Arg1 + Arg2*(1-Alpha) - D3DTOP_BLENDTEXTUREALPHAPM = 15, // texture alpha - D3DTOP_BLENDCURRENTALPHA = 16, // by alpha of current color + /* Linear alpha blend with pre-multiplied arg1 input: Arg1 + Arg2*(1-Alpha) */ + D3DTOP_BLENDTEXTUREALPHAPM = 15, /* texture alpha */ + D3DTOP_BLENDCURRENTALPHA = 16, /* by alpha of current color */ - // Specular mapping - D3DTOP_PREMODULATE = 17, // modulate with next texture before use + /* Specular mapping */ + D3DTOP_PREMODULATE = 17, /* modulate with next texture before use */ D3DTOP_MODULATEALPHA_ADDCOLOR = 18, // Arg1.RGB + Arg1.A*Arg2.RGB // COLOROP only D3DTOP_MODULATECOLOR_ADDALPHA = 19, // Arg1.RGB*Arg2.RGB + Arg1.A @@ -1601,10 +1601,11 @@ typedef enum _D3DRESOURCETYPE { #endif /* !D3D_DISABLE_9EX */ /* -- D3D9Ex only */ -// When passed to CheckDeviceFormat, D3DUSAGE_AUTOGENMIPMAP may return -// D3DOK_NOAUTOGEN if the device doesn't support autogeneration for that format. -// D3DOK_NOAUTOGEN is a success code, not a failure code... the SUCCEEDED and FAILED macros -// will return true and false respectively for this code. +/* When passed to CheckDeviceFormat, D3DUSAGE_AUTOGENMIPMAP may return + * D3DOK_NOAUTOGEN if the device doesn't support autogeneration for that format. + * D3DOK_NOAUTOGEN is a success code, not a failure code... the SUCCEEDED and FAILED macros + * will return true and false respectively for this code. + */ #define D3DUSAGE_AUTOGENMIPMAP (0x00000400L) #define D3DUSAGE_DMAP (0x00004000L) From 863858ab0095c8f792b212fe86487e19657fc8d5 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 5 Dec 2017 16:42:37 +0100 Subject: [PATCH 221/394] Can't have anonymous variadic macros in C89 --- cheevos/var.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/cheevos/var.c b/cheevos/var.c index 36828b46b3..45ae9ac866 100644 --- a/cheevos/var.c +++ b/cheevos/var.c @@ -24,10 +24,15 @@ #include "../core.h" #include "../verbosity.h" +static void STUB_LOG(const char *fmt, ...) +{ + (void)fmt; +} + #ifdef CHEEVOS_VERBOSE #define CHEEVOS_LOG RARCH_LOG #else -#define CHEEVOS_LOG(...) +#define CHEEVOS_LOG STUB_LOG #endif /***************************************************************************** From f9fa2ab2b78bd806401fa4331eed57aac9034c54 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 5 Dec 2017 16:44:05 +0100 Subject: [PATCH 222/394] More C89_BUILD fixes --- cheevos/cheevos.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/cheevos/cheevos.c b/cheevos/cheevos.c index b9df229ac7..87517d6164 100644 --- a/cheevos/cheevos.c +++ b/cheevos/cheevos.c @@ -1872,8 +1872,10 @@ static int cheevos_expr_value(cheevos_expr_t* expr) if (expr->compare_count > 1) { + unsigned j; int maximum = values[0]; - for (unsigned j = 1; j < expr->compare_count; j++) + + for (j = 1; j < expr->compare_count; j++) maximum = values[j] > maximum ? values[j] : maximum; return maximum; @@ -3171,10 +3173,12 @@ static int cheevos_iterate(coro_t* coro) badges_ctx = new_badges_ctx; - settings_t *settings = config_get_ptr(); - if (!string_is_equal(settings->arrays.menu_driver, "xmb") || - !settings->bools.cheevos_badges_enable) - CORO_RET(); + { + settings_t *settings = config_get_ptr(); + if (!string_is_equal(settings->arrays.menu_driver, "xmb") || + !settings->bools.cheevos_badges_enable) + CORO_RET(); + } CHEEVOS_VAR_CHEEVO_CURR = cheevos_locals.core.cheevos; CHEEVOS_VAR_CHEEVO_END = cheevos_locals.core.cheevos + cheevos_locals.core.count; From 32c1c3134ef79178cdfbd4742c94df980e85eca1 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 5 Dec 2017 16:45:57 +0100 Subject: [PATCH 223/394] Fix another C89 issue --- cheevos/badges.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cheevos/badges.c b/cheevos/badges.c index 961fbc600e..5ac1112222 100644 --- a/cheevos/badges.c +++ b/cheevos/badges.c @@ -21,15 +21,16 @@ bool badge_exists(const char* filepath) void set_badge_menu_texture(badges_ctx_t * badges, int i) { + char fullpath[PATH_MAX_LENGTH]; const char * locked_suffix = (badges->badge_locked[i] == true) ? "_lock.png" : ".png"; unsigned int bufferSize = 16; + /* TODO/FIXME - variable length forbidden in C89 - rewrite this! */ char badge_file[bufferSize]; snprintf(badge_file, bufferSize, "%s", badges->badge_id_list[i]); strcat(badge_file, locked_suffix); - char fullpath[PATH_MAX_LENGTH]; fill_pathname_application_special(fullpath, PATH_MAX_LENGTH * sizeof(char), APPLICATION_SPECIAL_DIRECTORY_THUMBNAILS_CHEEVOS_BADGES); From b69622ea885114491d6198a356e94f0cf6e9d28b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 5 Dec 2017 16:56:33 +0100 Subject: [PATCH 224/394] Avoid usage of GLsync type --- gfx/drivers_renderchain/gl2_renderchain.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gfx/drivers_renderchain/gl2_renderchain.c b/gfx/drivers_renderchain/gl2_renderchain.c index 1b246ce143..62ebde2275 100644 --- a/gfx/drivers_renderchain/gl2_renderchain.c +++ b/gfx/drivers_renderchain/gl2_renderchain.c @@ -70,7 +70,7 @@ typedef struct gl2_renderchain unsigned fence_count; - GLsync fences[MAX_FENCES]; + void *fences[MAX_FENCES]; struct gfx_fbo_scale fbo_scale[GFX_MAX_SHADERS]; } gl2_renderchain_t; @@ -1454,7 +1454,7 @@ static void gl2_renderchain_fence_iterate( chain->fence_count--; memmove(chain->fences, chain->fences + 1, - chain->fence_count * sizeof(GLsync)); + chain->fence_count * sizeof(void*)); } } From 763e6f766c921de5cf1254a5ea333f3f29a23000 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Tue, 5 Dec 2017 16:58:20 +0100 Subject: [PATCH 225/394] Silence warning --- gfx/drivers_renderchain/gl2_renderchain.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gfx/drivers_renderchain/gl2_renderchain.c b/gfx/drivers_renderchain/gl2_renderchain.c index 62ebde2275..99913d414e 100644 --- a/gfx/drivers_renderchain/gl2_renderchain.c +++ b/gfx/drivers_renderchain/gl2_renderchain.c @@ -1264,6 +1264,8 @@ static void gl2_renderchain_copy_frame( { gl_t *gl = (gl_t*)data; gl2_renderchain_t *chain = (gl2_renderchain_t*)chain_data; + + (void)chain; #if defined(HAVE_PSGL) { From db4387bd30d6d016f88fedf02e3fad075065f6f2 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 5 Dec 2017 17:10:31 +0100 Subject: [PATCH 226/394] See if it's always defined this way --- gfx/drivers_renderchain/gl2_renderchain.c | 2 +- gfx/include/GL/glext.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gfx/drivers_renderchain/gl2_renderchain.c b/gfx/drivers_renderchain/gl2_renderchain.c index 99913d414e..d2a4d2c3a1 100644 --- a/gfx/drivers_renderchain/gl2_renderchain.c +++ b/gfx/drivers_renderchain/gl2_renderchain.c @@ -70,7 +70,7 @@ typedef struct gl2_renderchain unsigned fence_count; - void *fences[MAX_FENCES]; + GLsync fences[MAX_FENCES]; struct gfx_fbo_scale fbo_scale[GFX_MAX_SHADERS]; } gl2_renderchain_t; diff --git a/gfx/include/GL/glext.h b/gfx/include/GL/glext.h index 44ab7c62e1..a1381696b4 100644 --- a/gfx/include/GL/glext.h +++ b/gfx/include/GL/glext.h @@ -6220,8 +6220,8 @@ typedef uint64_t GLuint64EXT; #ifndef GL_ARB_sync typedef int64_t GLint64; typedef uint64_t GLuint64; -typedef struct __GLsync *GLsync; #endif +typedef struct __GLsync *GLsync; #ifndef GL_ARB_cl_event /* These incomplete types let us declare types compatible with OpenCL's cl_context and cl_event */ From 38b899e4d6c9f72bedc0b3541ed34b0ff55a880e Mon Sep 17 00:00:00 2001 From: Jean-Paul Mari Date: Tue, 5 Dec 2017 11:23:38 -0500 Subject: [PATCH 227/394] Added Visual Studio 2017 support The msvc-2017 is based on msvc-2015 --- .gitignore | 2 + pkg/msvc/RetroArch-msvc2017.sln | 34 ++ pkg/msvc/msvc-2017/RetroArch-msvc2017.vcxproj | 379 ++++++++++++++++++ .../RetroArch-msvc2017.vcxproj.filters | 19 + 4 files changed, 434 insertions(+) create mode 100644 pkg/msvc/RetroArch-msvc2017.sln create mode 100644 pkg/msvc/msvc-2017/RetroArch-msvc2017.vcxproj create mode 100644 pkg/msvc/msvc-2017/RetroArch-msvc2017.vcxproj.filters diff --git a/.gitignore b/.gitignore index ad6ea6ab19..292bff2bbd 100644 --- a/.gitignore +++ b/.gitignore @@ -102,6 +102,8 @@ obj-unix/ /pkg/msvc/Release Cg/*.lpl /pkg/msvc/Release Cg/*.cfg /pkg/msvc/*.db +/pkg/msvc/.vs +/pkg/msvc/*/.vs /pkg/msvc/msvc-2010/Release Cg/RetroArc.27FF7CE1.tlog/*.tlog /pkg/msvc/msvc-2010/Release Cg/RetroArc.27FF7CE1.tlog/*.lastbuildstate /pkg/msvc/msvc-2010/Release Cg/*.log diff --git a/pkg/msvc/RetroArch-msvc2017.sln b/pkg/msvc/RetroArch-msvc2017.sln new file mode 100644 index 0000000000..31c8e476ac --- /dev/null +++ b/pkg/msvc/RetroArch-msvc2017.sln @@ -0,0 +1,34 @@ + +Microsoft Visual Studio Solution File, Format Version 11.00 +# Visual C++ Express 2015 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "RetroArch-msvc2017", "msvc-2017\RetroArch-msvc2017.vcxproj", "{27FF7CE1-4059-4AA1-8062-FD529560FA54}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug Cg|Win32 = Debug Cg|Win32 + Debug Cg|x64 = Debug Cg|x64 + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release Cg|Win32 = Release Cg|Win32 + Release Cg|x64 = Release Cg|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Debug Cg|Win32.ActiveCfg = Debug Cg|Win32 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Debug Cg|Win32.Build.0 = Debug Cg|Win32 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Debug Cg|x64.ActiveCfg = Debug Cg|Win32 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Debug|Win32.ActiveCfg = Debug|Win32 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Debug|Win32.Build.0 = Debug|Win32 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Debug|x64.ActiveCfg = Debug|Win32 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Release Cg|Win32.ActiveCfg = Release Cg|Win32 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Release Cg|Win32.Build.0 = Release Cg|Win32 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Release Cg|x64.ActiveCfg = Release Cg|Win32 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Release|Win32.ActiveCfg = Release|Win32 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Release|Win32.Build.0 = Release|Win32 + {27FF7CE1-4059-4AA1-8062-FD529560FA54}.Release|x64.ActiveCfg = Release|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/pkg/msvc/msvc-2017/RetroArch-msvc2017.vcxproj b/pkg/msvc/msvc-2017/RetroArch-msvc2017.vcxproj new file mode 100644 index 0000000000..447350a93f --- /dev/null +++ b/pkg/msvc/msvc-2017/RetroArch-msvc2017.vcxproj @@ -0,0 +1,379 @@ + + + + + Debug Cg + Win32 + + + Debug Cg + x64 + + + Debug + Win32 + + + Debug + x64 + + + Release Cg + Win32 + + + Release Cg + x64 + + + Release + Win32 + + + Release + x64 + + + + {27FF7CE1-4059-4AA1-8062-FD529560FA54} + Win32Proj + RetroArchmsvc2015 + 10.0.16299.0 + + + + Application + true + NotSet + v141 + + + Application + true + NotSet + v141 + + + Application + true + NotSet + v141 + + + Application + true + NotSet + v141 + + + Application + false + true + NotSet + v141 + + + Application + false + true + NotSet + v141 + + + Application + false + true + NotSet + v141 + + + Application + false + true + NotSet + v141 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + $(DXSDK_DIR)Include;$(IncludePath) + $(DXSDK_DIR)Lib\x86;$(LibraryPath) + AllRules.ruleset + + + + + true + $(DXSDK_DIR)Include;$(CG_INC_PATH);$(IncludePath) + $(DXSDK_DIR)Lib\x86;$(CG_LIB_PATH);$(LibraryPath) + AllRules.ruleset + + + + + true + $(DXSDK_DIR)Include;$(IncludePath) + $(DXSDK_DIR)Lib\x64;$(LibraryPath) + AllRules.ruleset + + + + + true + $(DXSDK_DIR)Include;$(CG_INC_PATH);$(IncludePath) + $(DXSDK_DIR)Lib\x64;$(CG_LIB64_PATH);$(LibraryPath) + AllRules.ruleset + + + + + false + $(DXSDK_DIR)Include;$(IncludePath) + $(DXSDK_DIR)Lib\x86;$(LibraryPath) + AllRules.ruleset + + + + + false + $(DXSDK_DIR)Include;$(CG_INC_PATH);$(IncludePath) + $(DXSDK_DIR)Lib\x86;$(CG_LIB_PATH);$(LibraryPath) + AllRules.ruleset + + + + + false + $(DXSDK_DIR)Include;$(IncludePath) + $(DXSDK_DIR)Lib\x64;$(LibraryPath) + AllRules.ruleset + + + + + false + $(DXSDK_DIR)Include;$(CG_INC_PATH);$(IncludePath) + $(DXSDK_DIR)Lib\x64;$(CG_LIB64_PATH);$(LibraryPath) + AllRules.ruleset + + + + + + + + Level3 + Disabled + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) + MultiThreadedDebug + CompileAsCpp + Fast + StreamingSIMDExtensions + + + Console + true + msimg32.lib;winmm.lib;Dinput8.lib;dxguid.lib;Iphlpapi.lib;%(AdditionalDependencies) + + + + + + + Level3 + Disabled + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_CG;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;HAVE_FBO;WANT_ZLIB;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(CG_INC_PATH);$(MSBuildProjectDirectory)\..\..\..\deps\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) + MultiThreadedDebug + CompileAsCpp + Fast + StreamingSIMDExtensions + + + Console + true + msimg32.lib;winmm.lib;Dinput8.lib;dxguid.lib;Iphlpapi.lib;%(AdditionalDependencies) + $(CG_LIB_PATH) + + + + + + + Level3 + Disabled + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_SECURE_NO_WARNINGS;__SSE__;__SSE2__;__x86_64__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) + MultiThreadedDebug + CompileAsCpp + Fast + StreamingSIMDExtensions2 + + + Console + true + msimg32.lib;winmm.lib;Dinput8.lib;dxguid.lib;Iphlpapi.lib;%(AdditionalDependencies) + + + + + + + Level3 + Disabled + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_CG;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;HAVE_FBO;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;WANT_ZLIB;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_SECURE_NO_WARNINGS;__SSE__;__SSE2__;__x86_64__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(CG_INC_PATH);$(MSBuildProjectDirectory)\..\..\..\deps\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) + MultiThreadedDebug + CompileAsCpp + Fast + StreamingSIMDExtensions2 + + + Console + true + msimg32.lib;winmm.lib;Dinput8.lib;dxguid.lib;Iphlpapi.lib;%(AdditionalDependencies) + $(CG_LIB64_PATH) + + + + + Level3 + + + MaxSpeed + true + true + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_MENU;HAVE_RGUI;HAVE_GL_SYNC;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) + MultiThreaded + CompileAsCpp + Fast + StreamingSIMDExtensions + true + + + Console + true + true + true + msimg32.lib;winmm.lib;Dinput8.lib;dxguid.lib;Iphlpapi.lib;%(AdditionalDependencies) + + + + + Level3 + + + MaxSpeed + true + true + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_CG;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;HAVE_FBO;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;WANT_ZLIB;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_MENU;HAVE_RGUI;HAVE_GL_SYNC;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(CG_INC_PATH);$(MSBuildProjectDirectory)\..\..\..\deps\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) + MultiThreaded + CompileAsCpp + Fast + StreamingSIMDExtensions + true + + + Console + true + true + true + msimg32.lib;winmm.lib;Dinput8.lib;dxguid.lib;Iphlpapi.lib;%(AdditionalDependencies) + $(CG_LIB_PATH) + + + + + Level3 + + + MaxSpeed + true + true + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;_CRT_SECURE_NO_WARNINGS;__SSE__;__SSE2__;__x86_64__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) + MultiThreaded + CompileAsCpp + Fast + StreamingSIMDExtensions2 + true + + + Console + true + true + true + msimg32.lib;winmm.lib;Dinput8.lib;dxguid.lib;Iphlpapi.lib;%(AdditionalDependencies) + + + + + Level3 + + + MaxSpeed + true + true + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_CG;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;HAVE_FBO;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;WANT_ZLIB;_CRT_SECURE_NO_WARNINGS;__SSE__;__SSE2__;__x86_64__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(CG_INC_PATH);$(MSBuildProjectDirectory)\..\..\..\deps\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) + MultiThreaded + CompileAsCpp + Fast + StreamingSIMDExtensions2 + true + + + Console + true + true + true + msimg32.lib;winmm.lib;Dinput8.lib;dxguid.lib;Iphlpapi.lib;%(AdditionalDependencies) + $(CG_LIB64_PATH) + + + + + + + + CompileAsC + CompileAsC + CompileAsC + CompileAsC + + + + + + + \ No newline at end of file diff --git a/pkg/msvc/msvc-2017/RetroArch-msvc2017.vcxproj.filters b/pkg/msvc/msvc-2017/RetroArch-msvc2017.vcxproj.filters new file mode 100644 index 0000000000..0b7f0bbd44 --- /dev/null +++ b/pkg/msvc/msvc-2017/RetroArch-msvc2017.vcxproj.filters @@ -0,0 +1,19 @@ + + + + + + + + {9fc175c7-a869-47cf-a0ce-5447d6015ce9} + + + + + griffin + + + griffin + + + From 35ab48ee615421c666cb75f8fc9935504d530049 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Tue, 5 Dec 2017 12:47:16 -0500 Subject: [PATCH 228/394] xinput: copy VID/PID from dinput so autoconfig does not rely solely on HID name --- input/drivers_joypad/dinput_joypad.c | 23 ++++++++++++++++++++++ input/drivers_joypad/dinput_joypad.h | 29 ++++++++++++++++++++++++++++ input/drivers_joypad/xinput_joypad.c | 28 ++++++++++++++++++++------- 3 files changed, 73 insertions(+), 7 deletions(-) create mode 100644 input/drivers_joypad/dinput_joypad.h diff --git a/input/drivers_joypad/dinput_joypad.c b/input/drivers_joypad/dinput_joypad.c index 4793d83256..403a13a56a 100644 --- a/input/drivers_joypad/dinput_joypad.c +++ b/input/drivers_joypad/dinput_joypad.c @@ -63,6 +63,29 @@ extern bool g_xinput_block_pads; extern int g_xinput_pad_indexes[MAX_USERS]; extern LPDIRECTINPUT8 g_dinput_ctx; +bool dinput_joypad_get_vidpid_from_xinput_index(int index, int *vid, int *pid) +{ + int i; + + for (i = 0; i < ARRAY_SIZE(g_xinput_pad_indexes); i++) + { + if (index == g_xinput_pad_indexes[i]) + { + RARCH_LOG("[DINPUT]: Found XInput pad at index %d (DINPUT index %d)\n", index, i); + + if (vid) + *vid = g_pads[i].vid; + + if (pid) + *pid = g_pads[i].pid; + + return true; + } + } + + return false; +} + static void dinput_joypad_destroy(void) { unsigned i; diff --git a/input/drivers_joypad/dinput_joypad.h b/input/drivers_joypad/dinput_joypad.h new file mode 100644 index 0000000000..e7705bfa30 --- /dev/null +++ b/input/drivers_joypad/dinput_joypad.h @@ -0,0 +1,29 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2014 - Hans-Kristian Arntzen + * Copyright (C) 2011-2016 - Daniel De Matteis + * Copyright (C) 2016-2017 - Brad Parker + * + * RetroArch 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 Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch 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 RetroArch. + * If not, see . + */ + +#ifndef __DINPUT_JOYPAD_H +#define __DINPUT_JOYPAD_H + +#include + +RETRO_BEGIN_DECLS + +bool dinput_joypad_get_vidpid_from_xinput_index(int index, int *vid, int *pid, int *dinput_index); + +RETRO_END_DECLS + +#endif diff --git a/input/drivers_joypad/xinput_joypad.c b/input/drivers_joypad/xinput_joypad.c index d753a889dc..17d3a42973 100644 --- a/input/drivers_joypad/xinput_joypad.c +++ b/input/drivers_joypad/xinput_joypad.c @@ -40,6 +40,12 @@ #include "../../verbosity.h" +#ifndef HAVE_DINPUT +#error Cannot compile xinput without dinput. +#endif + +#include "dinput_joypad.h" + /* Check if the definitions do not already exist. * Official and mingw xinput headers have different include guards. */ @@ -92,10 +98,6 @@ typedef struct #define ERROR_DEVICE_NOT_CONNECTED 1167 #endif -#ifndef HAVE_DINPUT -#error Cannot compile xinput without dinput. -#endif - /* Due to 360 pads showing up under both XInput and DirectInput, * and since we are going to have to pass through unhandled * joypad numbers to DirectInput, a slightly ugly @@ -270,16 +272,28 @@ static bool xinput_joypad_init(void *data) for (j = 0; j < MAX_USERS; j++) { - RARCH_LOG("[XInput]: Attempting autoconf for, user #%u\n", j); + if (xinput_joypad_name(j)) + RARCH_LOG("[XInput]: Attempting autoconf for \"%s\", user #%u\n", xinput_joypad_name(j), j); + else + RARCH_LOG("[XInput]: Attempting autoconf for user #%u\n", j); + if (pad_index_to_xuser_index(j) > -1) { + int vid = 0; + int pid = 0; + int dinput_index = 0; + bool success = dinput_joypad_get_vidpid_from_xinput_index(j, &vid, &pid, &dinput_index); + + if (success) + RARCH_LOG("[XInput]: Found VID/PID (%04X/%04X) from DINPUT index %d for \"%s\", user #%u\n", vid, pid, dinput_index, xinput_joypad_name(j), j); + if (!input_autoconfigure_connect( xinput_joypad_name(j), NULL, xinput_joypad.ident, j, - 0, - 0)) + vid, + pid)) input_config_set_device_name(j, xinput_joypad_name(j)); } } From 4c9bde61b534a0d0422e871899ca734a67c1f03f Mon Sep 17 00:00:00 2001 From: bparker06 Date: Tue, 5 Dec 2017 13:54:15 -0500 Subject: [PATCH 229/394] dinput: fix memory leak of joypad name --- input/drivers/dinput.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/input/drivers/dinput.c b/input/drivers/dinput.c index 9b2e14f66e..6550bec50e 100644 --- a/input/drivers/dinput.c +++ b/input/drivers/dinput.c @@ -852,7 +852,7 @@ static void dinput_free(void *data) if (di->mouse) IDirectInputDevice8_Release(di->mouse); - if (string_is_empty(di->joypad_driver_name)) + if (di->joypad_driver_name) free(di->joypad_driver_name); free(di); From 408878a7e10685a11b7956d821160c68211922fe Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 5 Dec 2017 20:04:12 +0100 Subject: [PATCH 230/394] Start making it possible for xinput_joypad to be used without DirectInput --- input/drivers_joypad/xinput_joypad.c | 36 +++++++++++++++++++++------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/input/drivers_joypad/xinput_joypad.c b/input/drivers_joypad/xinput_joypad.c index 17d3a42973..5cc96815f6 100644 --- a/input/drivers_joypad/xinput_joypad.c +++ b/input/drivers_joypad/xinput_joypad.c @@ -40,11 +40,9 @@ #include "../../verbosity.h" -#ifndef HAVE_DINPUT -#error Cannot compile xinput without dinput. -#endif - +#ifdef HAVE_DINPUT #include "dinput_joypad.h" +#endif /* Check if the definitions do not already exist. * Official and mingw xinput headers have different include guards. @@ -159,6 +157,8 @@ static const char* const XBOX_ONE_CONTROLLER_NAMES[4] = const char *xinput_joypad_name(unsigned pad) { int xuser = pad_index_to_xuser_index(pad); + +#ifdef HAVE_DINPUT /* Use the real controller name for XBOX One controllers since they are slightly different */ if (xuser < 0) @@ -166,6 +166,7 @@ const char *xinput_joypad_name(unsigned pad) if (strstr(dinput_joypad.name(pad), "Xbox One For Windows")) return XBOX_ONE_CONTROLLER_NAMES[xuser]; +#endif return XBOX_CONTROLLER_NAMES[xuser]; } @@ -262,6 +263,7 @@ static bool xinput_joypad_init(void *data) #endif g_xinput_block_pads = true; +#ifdef HAVE_DINPUT /* We're going to have to be buddies with dinput if we want to be able * to use XInput and non-XInput controllers together. */ if (!dinput_joypad.init(data)) @@ -269,6 +271,7 @@ static bool xinput_joypad_init(void *data) g_xinput_block_pads = false; return false; } +#endif for (j = 0; j < MAX_USERS; j++) { @@ -279,13 +282,16 @@ static bool xinput_joypad_init(void *data) if (pad_index_to_xuser_index(j) > -1) { - int vid = 0; - int pid = 0; + int vid = 0; + int pid = 0; +#ifdef HAVE_DINPUT int dinput_index = 0; - bool success = dinput_joypad_get_vidpid_from_xinput_index(j, &vid, &pid, &dinput_index); + bool success = dinput_joypad_get_vidpid_from_xinput_index(j, &vid, &pid, &dinput_index); if (success) - RARCH_LOG("[XInput]: Found VID/PID (%04X/%04X) from DINPUT index %d for \"%s\", user #%u\n", vid, pid, dinput_index, xinput_joypad_name(j), j); + RARCH_LOG("[XInput]: Found VID/PID (%04X/%04X) from DINPUT index %d for \"%s\", user #%u\n", + vid, pid, dinput_index, xinput_joypad_name(j), j); +#endif if (!input_autoconfigure_connect( xinput_joypad_name(j), @@ -306,7 +312,11 @@ static bool xinput_joypad_query_pad(unsigned pad) int xuser = pad_index_to_xuser_index(pad); if (xuser > -1) return g_xinput_states[xuser].connected; +#ifdef HAVE_DINPUT return dinput_joypad.query_pad(pad); +#else + return false; +#endif } static void xinput_joypad_destroy(void) @@ -322,7 +332,9 @@ static void xinput_joypad_destroy(void) g_XInputGetStateEx = NULL; g_XInputSetState = NULL; +#ifdef HAVE_DINPUT dinput_joypad.destroy(); +#endif g_xinput_block_pads = false; } @@ -351,8 +363,10 @@ static bool xinput_joypad_button(unsigned port_num, uint16_t joykey) unsigned hat_dir = 0; int xuser = pad_index_to_xuser_index(port_num); +#ifdef HAVE_DINPUT if (xuser == -1) return dinput_joypad.button(port_num, joykey); +#endif if (!(g_xinput_states[xuser].connected)) return false; @@ -400,8 +414,10 @@ static int16_t xinput_joypad_axis (unsigned port_num, uint32_t joyaxis) xuser = pad_index_to_xuser_index(port_num); +#ifdef HAVE_DINPUT if (xuser == -1) return dinput_joypad.axis(port_num, joyaxis); +#endif if (!(g_xinput_states[xuser].connected)) return 0; @@ -469,7 +485,9 @@ static void xinput_joypad_poll(void) } } +#ifdef HAVE_DINPUT dinput_joypad.poll(); +#endif } static bool xinput_joypad_rumble(unsigned pad, @@ -479,8 +497,10 @@ static bool xinput_joypad_rumble(unsigned pad, if (xuser == -1) { +#ifdef HAVE_DINPUT if (dinput_joypad.set_rumble) return dinput_joypad.set_rumble(pad, effect, strength); +#endif return false; } From 2bdf4a5bb481f7a2f79d619750f8d8a619ba67ae Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 5 Dec 2017 20:08:18 +0100 Subject: [PATCH 231/394] update --- input/drivers_joypad/xinput_joypad.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/input/drivers_joypad/xinput_joypad.c b/input/drivers_joypad/xinput_joypad.c index 5cc96815f6..e2d08929d5 100644 --- a/input/drivers_joypad/xinput_joypad.c +++ b/input/drivers_joypad/xinput_joypad.c @@ -254,13 +254,9 @@ static bool xinput_joypad_init(void *data) (!g_xinput_states[2].connected) && (!g_xinput_states[3].connected)) return false; -#if (1) - else - { - RARCH_LOG("[XInput]: Pads connected: %d\n", g_xinput_states[0].connected + - g_xinput_states[1].connected + g_xinput_states[2].connected + g_xinput_states[3].connected); - } -#endif + + RARCH_LOG("[XInput]: Pads connected: %d\n", g_xinput_states[0].connected + + g_xinput_states[1].connected + g_xinput_states[2].connected + g_xinput_states[3].connected); g_xinput_block_pads = true; #ifdef HAVE_DINPUT From bc4bbe79aa2172b0a987b0f198d21896b3cfe306 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Tue, 5 Dec 2017 14:26:41 -0500 Subject: [PATCH 232/394] don't define UNICODE at all, we don't need it and it causes dinput problems (names are wchar_t) --- gfx/drivers_context/wgl_ctx.c | 4 ---- input/drivers_joypad/dinput_joypad.c | 2 +- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/gfx/drivers_context/wgl_ctx.c b/gfx/drivers_context/wgl_ctx.c index 64c4be8a09..39dbb26cdb 100644 --- a/gfx/drivers_context/wgl_ctx.c +++ b/gfx/drivers_context/wgl_ctx.c @@ -23,10 +23,6 @@ #define _WIN32_WINNT 0x0500 //_WIN32_WINNT_WIN2K #endif -#if !defined(_MSC_VER) || _MSC_VER > 1400 -#define UNICODE -#endif - #include #include diff --git a/input/drivers_joypad/dinput_joypad.c b/input/drivers_joypad/dinput_joypad.c index 403a13a56a..b390e315cf 100644 --- a/input/drivers_joypad/dinput_joypad.c +++ b/input/drivers_joypad/dinput_joypad.c @@ -97,7 +97,7 @@ static void dinput_joypad_destroy(void) IDirectInputDevice8_Unacquire(g_pads[i].joypad); IDirectInputDevice8_Release(g_pads[i].joypad); } - + free(g_pads[i].joy_name); g_pads[i].joy_name = NULL; free(g_pads[i].joy_friendly_name); From dbe6af08ddc39a52a3509daedb0046927399901f Mon Sep 17 00:00:00 2001 From: radius Date: Tue, 5 Dec 2017 14:28:24 -0500 Subject: [PATCH 233/394] Improve vscode support add c properties add ming32 config too rename tasks to allow other targets --- .vscode/c_cpp_properties.json | 125 ++++++++++++++++++++++++++++++++++ .vscode/launch.json | 22 +++++- .vscode/tasks.json | 10 +-- 3 files changed, 151 insertions(+), 6 deletions(-) create mode 100644 .vscode/c_cpp_properties.json diff --git a/.vscode/c_cpp_properties.json b/.vscode/c_cpp_properties.json new file mode 100644 index 0000000000..81c2529184 --- /dev/null +++ b/.vscode/c_cpp_properties.json @@ -0,0 +1,125 @@ +{ + "configurations": [ + { + "name": "Mac", + "includePath": [ + "/usr/include", + "/usr/local/include", + "${workspaceRoot}" + ], + "defines": [], + "intelliSenseMode": "clang-x64", + "browse": { + "path": [ + "/usr/include", + "/usr/local/include", + "${workspaceRoot}" + ], + "limitSymbolsToIncludedHeaders": true, + "databaseFilename": "" + }, + "macFrameworkPath": [ + "/System/Library/Frameworks", + "/Library/Frameworks" + ] + }, + { + "name": "Linux", + "includePath": [ + "/usr/include", + "/usr/local/include", + "${workspaceRoot}" + ], + "defines": [], + "intelliSenseMode": "clang-x64", + "browse": { + "path": [ + "/usr/include", + "/usr/local/include", + "${workspaceRoot}" + ], + "limitSymbolsToIncludedHeaders": true, + "databaseFilename": "" + } + }, + { + "name": "Win32", + "includePath": [ + "C:/Program Files (x86)/Windows Kits/10/Include/10.0.15063.0/um", + "C:/Program Files (x86)/Windows Kits/10/Include/10.0.15063.0/ucrt", + "C:/Program Files (x86)/Windows Kits/10/Include/10.0.15063.0/shared", + "C:/Program Files (x86)/Windows Kits/10/Include/10.0.15063.0/winrt", + "${workspaceRoot}" + ], + "defines": [ + "_DEBUG", + "UNICODE" + ], + "intelliSenseMode": "msvc-x64", + "browse": { + "path": [ + "C:/Program Files (x86)/Windows Kits/10/Include/10.0.15063.0/um", + "C:/Program Files (x86)/Windows Kits/10/Include/10.0.15063.0/ucrt", + "C:/Program Files (x86)/Windows Kits/10/Include/10.0.15063.0/shared", + "C:/Program Files (x86)/Windows Kits/10/Include/10.0.15063.0/winrt", + "${workspaceRoot}" + ], + "limitSymbolsToIncludedHeaders": true, + "databaseFilename": "" + } + }, + { + "name": "msys2-mingw32", + "includePath": [ + "C:/msys64/mingw32/include", + "C:/msys64/mingw32/i686-w64-mingw32/include", + "${workspaceRoot}/libretro-common/include", + "${workspaceRoot}/include", + "${workspaceRoot}" + ], + "defines": [ + "_DEBUG", + "UNICODE" + ], + "intelliSenseMode": "msvc-x64", + "browse": { + "path": [ + "C:/msys64/mingw32/include", + "C:/msys64/mingw32/i686-w64-mingw32/include", + "${workspaceRoot}/libretro-common/include", + "${workspaceRoot}/include", + "${workspaceRoot}" + ], + "limitSymbolsToIncludedHeaders": true, + "databaseFilename": "" + } + }, + { + "name": "msys2-mingw64", + "includePath": [ + "C:/msys64/mingw64/include", + "C:/msys64/mingw64/x86_64-w64-mingw32/include", + "${workspaceRoot}/libretro-common/include", + "${workspaceRoot}/include", + "${workspaceRoot}" + ], + "defines": [ + "_DEBUG", + "UNICODE" + ], + "intelliSenseMode": "msvc-x64", + "browse": { + "path": [ + "C:/msys64/mingw64/include", + "C:/msys64/mingw64/x86_64-w64-mingw32/include", + "${workspaceRoot}/libretro-common/include", + "${workspaceRoot}/include", + "${workspaceRoot}" + ], + "limitSymbolsToIncludedHeaders": true, + "databaseFilename": "" + } + } + ], + "version": 3 +} \ No newline at end of file diff --git a/.vscode/launch.json b/.vscode/launch.json index 53837e538f..6e1f69631a 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -5,7 +5,7 @@ "version": "0.2.0", "configurations": [ { - "name": "MINGW64 (MSYS2) debug", + "name": "msys2-mingw64 debug", "type": "cppdbg", "request": "launch", "program": "${workspaceFolder}/retroarch.exe", @@ -23,6 +23,26 @@ "ignoreFailures": true } ] + }, + { + "name": "msys2-mingw32 debug", + "type": "cppdbg", + "request": "launch", + "program": "${workspaceFolder}/retroarch.exe", + "args": [], + "stopAtEntry": false, + "cwd": "${workspaceFolder}", + "environment": [], + "externalConsole": true, + "MIMode": "gdb", + "miDebuggerPath": "c:\\msys64\\mingw32\\bin\\gdb.exe", + "setupCommands": [ + { + "description": "Enable pretty-printing for gdb", + "text": "-enable-pretty-printing", + "ignoreFailures": true + } + ] } ] } \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 496810ecfa..b271c66e8f 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -4,7 +4,7 @@ "version": "2.0.0", "tasks": [ { - "taskName": "Build", + "taskName": "msys2-mingw64 build", "type": "shell", "group": { @@ -22,7 +22,7 @@ } } { - "taskName": "Build with debugging symbols", + "taskName": "msys2-mingw64 build with debug symbols", "type": "shell", "group": "build", @@ -38,7 +38,7 @@ } } { - "taskName": "Build without reconfiguring", + "taskName": "msys2-mingw64 rebuild", "type": "shell", "group": "build", @@ -54,7 +54,7 @@ } } { - "taskName": "Clean", + "taskName": "msys2-mingw64 clean", "type": "shell", "group": "build", @@ -70,7 +70,7 @@ } } { - "taskName": "Start", + "taskName": "msys2-mingw64 run", "type": "shell", "group": { From 6bb2a0e14266bb363fd72c761020f134706b7335 Mon Sep 17 00:00:00 2001 From: ToKe79 Date: Tue, 5 Dec 2017 21:58:01 +0100 Subject: [PATCH 234/394] GLsync build fix for HAVE_OPENGLES2 --- gfx/drivers_renderchain/gl2_renderchain.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gfx/drivers_renderchain/gl2_renderchain.c b/gfx/drivers_renderchain/gl2_renderchain.c index d2a4d2c3a1..81a6f9ff78 100644 --- a/gfx/drivers_renderchain/gl2_renderchain.c +++ b/gfx/drivers_renderchain/gl2_renderchain.c @@ -53,6 +53,12 @@ #define MAX_FENCES 4 +#ifndef HAVE_PSGL +#if defined(HAVE_OPENGLES2) + typedef struct __GLsync *GLsync; +#endif +#endif + typedef struct gl2_renderchain { bool egl_images; From 0d189ae0670efe77c694427d25518970eda44a4e Mon Sep 17 00:00:00 2001 From: David Walters Date: Tue, 5 Dec 2017 21:21:29 +0000 Subject: [PATCH 235/394] Don't limit available input devices to user count. --- input/input_defines.h | 2 ++ input/input_driver.c | 14 +++++++++++++- input/input_driver.h | 2 ++ menu/menu_setting.c | 14 +++++++------- 4 files changed, 24 insertions(+), 8 deletions(-) diff --git a/input/input_defines.h b/input/input_defines.h index b005e90f58..3255a85180 100644 --- a/input/input_defines.h +++ b/input/input_defines.h @@ -26,6 +26,8 @@ RETRO_BEGIN_DECLS #define MAX_USERS 16 +#define MAX_INPUT_DEVICES 16 + #define RARCH_FIRST_CUSTOM_BIND 16 #define RARCH_FIRST_LIGHTGUN_BIND RARCH_ANALOG_BIND_LIST_END #define RARCH_FIRST_MISC_CUSTOM_BIND RARCH_LIGHTGUN_BIND_LIST_END diff --git a/input/input_driver.c b/input/input_driver.c index d17fb5fc61..59ca11e205 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -233,7 +233,7 @@ static const uint8_t buttons[] = { static uint16_t input_config_vid[MAX_USERS]; static uint16_t input_config_pid[MAX_USERS]; -char input_device_names[MAX_USERS][64]; +char input_device_names[MAX_INPUT_DEVICES][64]; struct retro_keybind input_config_binds[MAX_USERS][RARCH_BIND_LIST_END]; struct retro_keybind input_autoconf_binds[MAX_USERS][RARCH_BIND_LIST_END]; const struct retro_keybind *libretro_input_binds[MAX_USERS]; @@ -2691,6 +2691,18 @@ void input_config_get_bind_string(char *buf, const struct retro_keybind *bind, strlcat(buf, "---", size); } +unsigned input_config_get_device_count() +{ + unsigned num_devices; + for ( num_devices = 0; num_devices < MAX_INPUT_DEVICES; ++num_devices ) + { + const char *device_name = input_config_get_device_name(num_devices); + if ( string_is_empty(device_name) ) + break; + } + return num_devices; +} + const char *input_config_get_device_name(unsigned port) { if (string_is_empty(input_device_names[port])) diff --git a/input/input_driver.h b/input/input_driver.h index 3222237a41..1f7b711917 100644 --- a/input/input_driver.h +++ b/input/input_driver.h @@ -761,6 +761,8 @@ void input_config_set_device_name(unsigned port, const char *name); void input_config_clear_device_name(unsigned port); +unsigned input_config_get_device_count(); + unsigned *input_config_get_device_ptr(unsigned port); unsigned input_config_get_device(unsigned port); diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 86cca1a42a..112ce021f5 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -1305,7 +1305,7 @@ static int setting_action_left_bind_device(void *data, bool wraparound) { unsigned index_offset; unsigned *p = NULL; - unsigned max_users = *(input_driver_get_uint(INPUT_ACTION_MAX_USERS)); + unsigned max_devices = input_config_get_device_count(); rarch_setting_t *setting = (rarch_setting_t*)data; settings_t *settings = config_get_ptr(); @@ -1316,8 +1316,8 @@ static int setting_action_left_bind_device(void *data, bool wraparound) p = &settings->uints.input_joypad_map[index_offset]; - if ((*p) >= max_users) - *p = max_users - 1; + if ((*p) >= max_devices) + *p = max_devices - 1; else if ((*p) > 0) (*p)--; @@ -1328,7 +1328,7 @@ static int setting_action_right_bind_device(void *data, bool wraparound) { unsigned index_offset; unsigned *p = NULL; - unsigned max_users = *(input_driver_get_uint(INPUT_ACTION_MAX_USERS)); + unsigned max_devices = input_config_get_device_count(); rarch_setting_t *setting = (rarch_setting_t*)data; settings_t *settings = config_get_ptr(); @@ -1339,7 +1339,7 @@ static int setting_action_right_bind_device(void *data, bool wraparound) p = &settings->uints.input_joypad_map[index_offset]; - if (*p < max_users) + if (*p < max_devices) (*p)++; return 0; @@ -1497,7 +1497,7 @@ static void get_string_representation_bind_device(void * data, char *s, size_t len) { unsigned index_offset, map = 0; - unsigned max_users = *(input_driver_get_uint(INPUT_ACTION_MAX_USERS)); + unsigned max_devices = input_config_get_device_count(); rarch_setting_t *setting = (rarch_setting_t*)data; settings_t *settings = config_get_ptr(); @@ -1507,7 +1507,7 @@ static void get_string_representation_bind_device(void * data, char *s, index_offset = setting->index_offset; map = settings->uints.input_joypad_map[index_offset]; - if (map < max_users) + if (map < max_devices) { const char *device_name = input_config_get_device_name(map); From 609bcb4dc209f0fa8273ca11d544588c20a00a2a Mon Sep 17 00:00:00 2001 From: David Walters Date: Tue, 5 Dec 2017 22:03:56 +0000 Subject: [PATCH 236/394] fix device indexing --- input/input_driver.c | 5 +++++ tasks/task_autodetect.c | 48 ++++++++++++++++++++++++++--------------- tasks/tasks_internal.h | 2 ++ 3 files changed, 38 insertions(+), 17 deletions(-) diff --git a/input/input_driver.c b/input/input_driver.c index 59ca11e205..0866d5e890 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -2713,14 +2713,19 @@ const char *input_config_get_device_name(unsigned port) void input_config_set_device_name(unsigned port, const char *name) { if (!string_is_empty(name)) + { strlcpy(input_device_names[port], name, sizeof(input_device_names[port])); + + input_autoconfigure_joypad_reindex_devices(); + } } void input_config_clear_device_name(unsigned port) { input_device_names[port][0] = '\0'; + input_autoconfigure_joypad_reindex_devices(); } unsigned *input_config_get_device_ptr(unsigned port) diff --git a/tasks/task_autodetect.c b/tasks/task_autodetect.c index 66080478f8..be8e9ee4ed 100644 --- a/tasks/task_autodetect.c +++ b/tasks/task_autodetect.c @@ -96,7 +96,7 @@ struct autoconfig_params }; static bool input_autoconfigured[MAX_USERS]; -static unsigned input_device_name_index[MAX_USERS]; +static unsigned input_device_name_index[MAX_INPUT_DEVICES]; static bool input_autoconfigure_swap_override; bool input_autoconfigure_get_swap_override(void) @@ -106,24 +106,38 @@ bool input_autoconfigure_get_swap_override(void) /* Adds an index for devices with the same name, * so they can be identified in the GUI. */ -static void input_autoconfigure_joypad_reindex_devices(autoconfig_params_t *params) +void input_autoconfigure_joypad_reindex_devices() { - unsigned i; + unsigned i, j, k; - for(i = 0; i < params->max_users; i++) + for(i = 0; i < MAX_INPUT_DEVICES; i++) input_device_name_index[i] = 0; - for(i = 0; i < params->max_users; i++) + for(i = 0; i < MAX_INPUT_DEVICES; i++) { - unsigned j; const char *tmp = input_config_get_device_name(i); - int k = 1; + if ( !tmp || input_device_name_index[i] ) + continue; - for(j = 0; j < params->max_users; j++) + k = 2; /*Additional devices start at two*/ + + for(j = i+1; j < MAX_INPUT_DEVICES; j++) { - if(string_is_equal(tmp, input_config_get_device_name(j)) - && input_device_name_index[i] == 0) + const char *other = input_config_get_device_name(j); + + if (!other) + continue; + + /*another device with the same name found, for the first time*/ + if(string_is_equal(tmp, other) && + input_device_name_index[j]==0 ) + { + /*Mark the first device of the set*/ + input_device_name_index[i] = 1; + + /*count this additional device, from two up*/ input_device_name_index[j] = k++; + } } } } @@ -190,7 +204,7 @@ static void input_autoconfigure_joypad_add(config_file_t *conf, char msg[128], display_name[128], device_type[128]; /* This will be the case if input driver is reinitialized. * No reason to spam autoconfigure messages every time. */ - bool block_osd_spam = + bool block_osd_spam = input_autoconfigured[params->idx] && !string_is_empty(params->name); @@ -228,7 +242,7 @@ static void input_autoconfigure_joypad_add(config_file_t *conf, bool tmp = false; snprintf(msg, sizeof(msg), "%s %s #%u.", (string_is_empty(display_name) && - !string_is_empty(params->name)) + !string_is_empty(params->name)) ? params->name : (!string_is_empty(display_name) ? display_name : "N/A"), msg_hash_to_str(MSG_DEVICE_CONFIGURED_IN_PORT), params->idx); @@ -250,7 +264,7 @@ static void input_autoconfigure_joypad_add(config_file_t *conf, } - input_autoconfigure_joypad_reindex_devices(params); + input_autoconfigure_joypad_reindex_devices(); } static int input_autoconfigure_joypad_from_conf( @@ -393,7 +407,7 @@ static const blissbox_pad_type_t* input_autoconfigure_get_blissbox_pad_type_win3 BOOL bResult = TRUE; BOOL success = FALSE; GUID guidDeviceInterface = {0}; - PSP_DEVICE_INTERFACE_DETAIL_DATA + PSP_DEVICE_INTERFACE_DETAIL_DATA pInterfaceDetailData = NULL; ULONG requiredLength = 0; LPTSTR lpDevicePath = NULL; @@ -845,7 +859,7 @@ bool input_autoconfigure_disconnect(unsigned i, const char *ident) state->idx = i; - snprintf(msg, sizeof(msg), "%s #%u (%s).", + snprintf(msg, sizeof(msg), "%s #%u (%s).", msg_hash_to_str(MSG_DEVICE_DISCONNECTED_FROM_PORT), i, ident); @@ -942,10 +956,10 @@ bool input_autoconfigure_connect( { input_autoconf_binds[state->idx][i].joykey = NO_BTN; input_autoconf_binds[state->idx][i].joyaxis = AXIS_NONE; - if ( + if ( !string_is_empty(input_autoconf_binds[state->idx][i].joykey_label)) free(input_autoconf_binds[state->idx][i].joykey_label); - if ( + if ( !string_is_empty(input_autoconf_binds[state->idx][i].joyaxis_label)) free(input_autoconf_binds[state->idx][i].joyaxis_label); input_autoconf_binds[state->idx][i].joykey_label = NULL; diff --git a/tasks/tasks_internal.h b/tasks/tasks_internal.h index bf32504ef0..dc5c160b52 100644 --- a/tasks/tasks_internal.h +++ b/tasks/tasks_internal.h @@ -245,6 +245,8 @@ bool input_autoconfigure_disconnect(unsigned i, const char *ident); bool input_autoconfigure_get_swap_override(void); +void input_autoconfigure_joypad_reindex_devices(void); + void task_push_get_powerstate(void); enum frontend_powerstate get_last_powerstate(int *percent); From 8907a1251ee8f50a3fcfc071cc5bb6955d7dabe6 Mon Sep 17 00:00:00 2001 From: David Walters Date: Tue, 5 Dec 2017 22:10:34 +0000 Subject: [PATCH 237/394] Only show " (#x)" after a device name if it's part of a set (x of y similarly named devices) --- menu/menu_setting.c | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 112ce021f5..31d1d618b8 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -1512,16 +1512,32 @@ static void get_string_representation_bind_device(void * data, char *s, const char *device_name = input_config_get_device_name(map); if (!string_is_empty(device_name)) - snprintf(s, len, - "%s (#%u)", - device_name, - input_autoconfigure_get_device_name_index(map)); + { + unsigned idx = input_autoconfigure_get_device_name_index(map); + + /*if idx is non-zero, it's part of a set*/ + if ( idx > 0 ) + { + snprintf(s, len, + "%s (#%u)", + device_name, + idx); + } + else + { + snprintf(s, len, + "%s", + device_name); + } + } else + { snprintf(s, len, "%s (%s #%u)", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE), msg_hash_to_str(MENU_ENUM_LABEL_VALUE_PORT), map); + } } else strlcpy(s, msg_hash_to_str(MENU_ENUM_LABEL_VALUE_DISABLED), len); From f5ea4a0c65edbf83b15e699524db8f8462ced776 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Tue, 5 Dec 2017 17:19:17 -0500 Subject: [PATCH 238/394] dinput: add missing function parameter --- input/drivers_joypad/dinput_joypad.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/input/drivers_joypad/dinput_joypad.c b/input/drivers_joypad/dinput_joypad.c index b390e315cf..1a9f6325eb 100644 --- a/input/drivers_joypad/dinput_joypad.c +++ b/input/drivers_joypad/dinput_joypad.c @@ -63,7 +63,7 @@ extern bool g_xinput_block_pads; extern int g_xinput_pad_indexes[MAX_USERS]; extern LPDIRECTINPUT8 g_dinput_ctx; -bool dinput_joypad_get_vidpid_from_xinput_index(int index, int *vid, int *pid) +bool dinput_joypad_get_vidpid_from_xinput_index(int index, int *vid, int *pid, int *dinput_index) { int i; @@ -79,6 +79,9 @@ bool dinput_joypad_get_vidpid_from_xinput_index(int index, int *vid, int *pid) if (pid) *pid = g_pads[i].pid; + if (dinput_index) + *dinput_index = i; + return true; } } From 27e5adad27214715f1d363360630b632122e7168 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 6 Dec 2017 04:05:38 +0100 Subject: [PATCH 239/394] Cleanups --- menu/cbs/menu_cbs_deferred_push.c | 63 +++++++++---------------------- 1 file changed, 18 insertions(+), 45 deletions(-) diff --git a/menu/cbs/menu_cbs_deferred_push.c b/menu/cbs/menu_cbs_deferred_push.c index 9a93e60dda..4040f46aa3 100644 --- a/menu/cbs/menu_cbs_deferred_push.c +++ b/menu/cbs/menu_cbs_deferred_push.c @@ -559,56 +559,29 @@ static int general_push(menu_displaylist_info_t *info, return deferred_push_dlist(info, state); } -static int deferred_push_detect_core_list(menu_displaylist_info_t *info) -{ - return general_push(info, PUSH_DETECT_CORE_LIST, - DISPLAYLIST_CORES_DETECTED); +#define generic_deferred_push_general(name, a, b) \ +static int (name)(menu_displaylist_info_t *info) \ +{ \ + return general_push(info, a, b); \ } -static int deferred_playlist_list(menu_displaylist_info_t *info) -{ - menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, info->list); - return general_push(info, PUSH_DEFAULT, DISPLAYLIST_PLAYLIST); +#define generic_deferred_push_clear_general(name, a, b) \ +static int (name)(menu_displaylist_info_t *info) \ +{ \ + menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, info->list); \ + return general_push(info, a, b); \ } -static int deferred_music_history_list(menu_displaylist_info_t *info) -{ - menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, info->list); - return general_push(info, PUSH_DEFAULT, DISPLAYLIST_MUSIC_HISTORY); -} +generic_deferred_push_general(deferred_push_detect_core_list, PUSH_DETECT_CORE_LIST, DISPLAYLIST_CORES_DETECTED) +generic_deferred_push_general(deferred_archive_open_detect_core, PUSH_ARCHIVE_OPEN_DETECT_CORE, DISPLAYLIST_DEFAULT) +generic_deferred_push_general(deferred_archive_open, PUSH_ARCHIVE_OPEN, DISPLAYLIST_DEFAULT) +generic_deferred_push_general(deferred_push_default, PUSH_DEFAULT, DISPLAYLIST_DEFAULT) +generic_deferred_push_general(deferred_push_favorites_list, PUSH_DEFAULT, DISPLAYLIST_FAVORITES) -static int deferred_image_history_list(menu_displaylist_info_t *info) -{ - menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, info->list); - return general_push(info, PUSH_DEFAULT, DISPLAYLIST_IMAGES_HISTORY); -} - -static int deferred_video_history_list(menu_displaylist_info_t *info) -{ - menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, info->list); - return general_push(info, PUSH_DEFAULT, DISPLAYLIST_VIDEO_HISTORY); -} - -static int deferred_archive_open_detect_core(menu_displaylist_info_t *info) -{ - return general_push(info, PUSH_ARCHIVE_OPEN_DETECT_CORE, - DISPLAYLIST_DEFAULT); -} - -static int deferred_archive_open(menu_displaylist_info_t *info) -{ - return general_push(info, PUSH_ARCHIVE_OPEN, DISPLAYLIST_DEFAULT); -} - -static int deferred_push_default(menu_displaylist_info_t *info) -{ - return general_push(info, PUSH_DEFAULT, DISPLAYLIST_DEFAULT); -} - -static int deferred_push_favorites_list(menu_displaylist_info_t *info) -{ - return general_push(info, PUSH_DEFAULT, DISPLAYLIST_FAVORITES); -} +generic_deferred_push_clear_general(deferred_playlist_list, PUSH_DEFAULT, DISPLAYLIST_PLAYLIST) +generic_deferred_push_clear_general(deferred_music_history_list, PUSH_DEFAULT, DISPLAYLIST_MUSIC_HISTORY) +generic_deferred_push_clear_general(deferred_image_history_list, PUSH_DEFAULT, DISPLAYLIST_IMAGES_HISTORY) +generic_deferred_push_clear_general(deferred_video_history_list, PUSH_DEFAULT, DISPLAYLIST_VIDEO_HISTORY) static int menu_cbs_init_bind_deferred_push_compare_label( menu_file_list_cbs_t *cbs, From 0c9fce98a26edf933f079198df3346c0ba5fbe37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s?= Date: Tue, 5 Dec 2017 22:07:48 -0500 Subject: [PATCH 240/394] fix vid/pid enumeration on xinput controllers when the xinput controllers are interleaved with dinput (#5872) --- input/drivers_joypad/xinput_joypad.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/input/drivers_joypad/xinput_joypad.c b/input/drivers_joypad/xinput_joypad.c index e2d08929d5..524d461160 100644 --- a/input/drivers_joypad/xinput_joypad.c +++ b/input/drivers_joypad/xinput_joypad.c @@ -282,7 +282,7 @@ static bool xinput_joypad_init(void *data) int pid = 0; #ifdef HAVE_DINPUT int dinput_index = 0; - bool success = dinput_joypad_get_vidpid_from_xinput_index(j, &vid, &pid, &dinput_index); + bool success = dinput_joypad_get_vidpid_from_xinput_index(pad_index_to_xuser_index(j), &vid, &pid, &dinput_index); if (success) RARCH_LOG("[XInput]: Found VID/PID (%04X/%04X) from DINPUT index %d for \"%s\", user #%u\n", From de9b0127f87c51e0a9bc517334348c48770a85cc Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 6 Dec 2017 04:33:54 +0100 Subject: [PATCH 241/394] (MSVC) Buildfix --- input/drivers_joypad/dinput_joypad.c | 3 ++- input/drivers_joypad/dinput_joypad.h | 4 +++- input/drivers_joypad/xinput_joypad.c | 9 +++++---- 3 files changed, 10 insertions(+), 6 deletions(-) diff --git a/input/drivers_joypad/dinput_joypad.c b/input/drivers_joypad/dinput_joypad.c index 1a9f6325eb..b04e739790 100644 --- a/input/drivers_joypad/dinput_joypad.c +++ b/input/drivers_joypad/dinput_joypad.c @@ -34,6 +34,7 @@ #include "../input_driver.h" #include "../input_keymaps.h" #include "../../verbosity.h" +#include "dinput_joypad.h" struct dinput_joypad { @@ -63,7 +64,7 @@ extern bool g_xinput_block_pads; extern int g_xinput_pad_indexes[MAX_USERS]; extern LPDIRECTINPUT8 g_dinput_ctx; -bool dinput_joypad_get_vidpid_from_xinput_index(int index, int *vid, int *pid, int *dinput_index) +bool dinput_joypad_get_vidpid_from_xinput_index(int32_t index, int32_t *vid, int32_t *pid, int32_t *dinput_index) { int i; diff --git a/input/drivers_joypad/dinput_joypad.h b/input/drivers_joypad/dinput_joypad.h index e7705bfa30..12d491f3b9 100644 --- a/input/drivers_joypad/dinput_joypad.h +++ b/input/drivers_joypad/dinput_joypad.h @@ -18,11 +18,13 @@ #ifndef __DINPUT_JOYPAD_H #define __DINPUT_JOYPAD_H +#include +#include #include RETRO_BEGIN_DECLS -bool dinput_joypad_get_vidpid_from_xinput_index(int index, int *vid, int *pid, int *dinput_index); +bool dinput_joypad_get_vidpid_from_xinput_index(int32_t index, int32_t *vid, int32_t *pid, int32_t *dinput_index); RETRO_END_DECLS diff --git a/input/drivers_joypad/xinput_joypad.c b/input/drivers_joypad/xinput_joypad.c index 524d461160..f7eb8bd347 100644 --- a/input/drivers_joypad/xinput_joypad.c +++ b/input/drivers_joypad/xinput_joypad.c @@ -278,11 +278,12 @@ static bool xinput_joypad_init(void *data) if (pad_index_to_xuser_index(j) > -1) { - int vid = 0; - int pid = 0; + int32_t vid = 0; + int32_t pid = 0; #ifdef HAVE_DINPUT - int dinput_index = 0; - bool success = dinput_joypad_get_vidpid_from_xinput_index(pad_index_to_xuser_index(j), &vid, &pid, &dinput_index); + int32_t dinput_index = 0; + bool success = dinput_joypad_get_vidpid_from_xinput_index((int32_t)pad_index_to_xuser_index(j), (int32_t*)&vid, (int32_t*)&pid, + (int32_t*)&dinput_index); if (success) RARCH_LOG("[XInput]: Found VID/PID (%04X/%04X) from DINPUT index %d for \"%s\", user #%u\n", From 24b02bc06213252510b1e3845d6adac0929443ba Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 6 Dec 2017 04:52:51 +0100 Subject: [PATCH 242/394] Update CHANGES.md --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index 9a962e0dcf..bb2dfb3d35 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -16,6 +16,7 @@ - OSX/PPC: Fix the GL2 renderchain, had to use EXT versions of framebuffer/renderbuffer functions. - SCANNER: Fix crash from Windows-incompatible format string. - WIIU: Disabled the controller patcher for now since it was the source of many stability issues. +- WINDOWS: Add MSVC 2017 solution. - WINDOWS: Raw input driver now supports new lightgun code. # 1.6.9 From 21dc6500003901994eac5671f190ae33a15bb690 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Wed, 6 Dec 2017 00:57:35 -0500 Subject: [PATCH 243/394] update JP translation --- intl/msg_hash_ja.h | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/intl/msg_hash_ja.h b/intl/msg_hash_ja.h index c1087e8ede..ec16dabcc3 100644 --- a/intl/msg_hash_ja.h +++ b/intl/msg_hash_ja.h @@ -438,6 +438,14 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_CHEEVOS_HARDCORE_MODE_ENABLE, "ハードコアモード" ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_CHEEVOS_LEADERBOARDS_ENABLE, + "ランキング" + ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_CHEEVOS_BADGES_ENABLE, + "実績バッジ" + ) MSG_HASH( MENU_ENUM_LABEL_VALUE_CHEEVOS_LOCKED_ACHIEVEMENTS, "解除された実績:" @@ -466,6 +474,10 @@ MSG_HASH( MENU_ENUM_LABEL_VALUE_CHEEVOS_UNLOCKED_ENTRY, "解除されている" ) +MSG_HASH( + MENU_ENUM_LABEL_VALUE_CHEEVOS_UNLOCKED_ENTRY_HARDCORE, + "解除されている(ハードコア)" + ) MSG_HASH( MENU_ENUM_LABEL_VALUE_CLOSE_CONTENT, "閉じる" @@ -2514,6 +2526,8 @@ MSG_HASH( ) MSG_HASH(MENU_ENUM_LABEL_VALUE_SHADER_PIPELINE_BOKEH, "ボケ") +MSG_HASH(MENU_ENUM_LABEL_VALUE_SHADER_PIPELINE_SNOWFLAKE, + "スノーフレーク") MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_REFRESH_ROOMS, "ルーム表を更新") MSG_HASH(MENU_ENUM_LABEL_VALUE_NETPLAY_ROOM_NICKNAME, From 1828e891ad98155da724c1712d4c1f9c0917e769 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Wed, 6 Dec 2017 00:57:57 -0500 Subject: [PATCH 244/394] Update CHANGES.md --- CHANGES.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGES.md b/CHANGES.md index bb2dfb3d35..570c2afade 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -11,6 +11,7 @@ - LINUX/X11: Add RetroArch logo to window title bar. - LINUX/X11: Input driver now supports new lightgun code. - LOCALIZATION: Update Italian translation. +- LOCALIZATION: Update Japanese translation. - LOCALIZATION: Update Portuguese-Brazilian translation. - LOCALIZATION: Update Russian translation. - OSX/PPC: Fix the GL2 renderchain, had to use EXT versions of framebuffer/renderbuffer functions. From 75eed7997b6ca2742bdd1ee8e6a7a58e153eefaa Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Wed, 6 Dec 2017 01:41:00 -0500 Subject: [PATCH 245/394] GDI: use configured message color for OSD/menu text --- gfx/drivers_font/gdi_font.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/gfx/drivers_font/gdi_font.c b/gfx/drivers_font/gdi_font.c index c89eb99df9..177b38b2bf 100644 --- a/gfx/drivers_font/gdi_font.c +++ b/gfx/drivers_font/gdi_font.c @@ -91,6 +91,9 @@ static void gdi_render_msg( const struct font_params *params = (const struct font_params*)userdata; unsigned width = video_info->width; unsigned height = video_info->height; + unsigned red; + unsigned green; + unsigned blue; if (!font || string_is_empty(msg)) return; @@ -101,6 +104,9 @@ static void gdi_render_msg( y = params->y; scale = params->scale; align = params->text_align; + red = FONT_COLOR_GET_RED(params->color); + green = FONT_COLOR_GET_GREEN(params->color); + blue = FONT_COLOR_GET_BLUE(params->color); } else { @@ -108,6 +114,9 @@ static void gdi_render_msg( y = video_info->font_msg_pos_y; scale = 1.0f; align = TEXT_ALIGN_LEFT; + red = video_info->font_msg_color_r * 255.0f; + green = video_info->font_msg_color_g * 255.0f; + blue = video_info->font_msg_color_b * 255.0f; } if (!font->gdi) @@ -135,7 +144,7 @@ static void gdi_render_msg( font->gdi->bmp_old = (HBITMAP)SelectObject(font->gdi->memDC, font->gdi->bmp); SetBkMode(font->gdi->memDC, TRANSPARENT); - SetTextColor(font->gdi->memDC, RGB(255,255,255)); + SetTextColor(font->gdi->memDC, RGB(red, green, blue)); TextOut(font->gdi->memDC, newX, newY, msg, len); SelectObject(font->gdi->memDC, font->gdi->bmp_old); } From 1755cdcdf356b627a8ad4c78db4f8dcbdfa6717e Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Wed, 6 Dec 2017 01:41:06 -0500 Subject: [PATCH 246/394] Update CHANGES.md --- CHANGES.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGES.md b/CHANGES.md index 570c2afade..dfa858dfe6 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -8,6 +8,7 @@ - COMMON: Fixed some playlist bugs. - FREEBSD: Support libusb HID input driver. - HAIKU: Buildfix. +- INPUT: Populate XInput VID/PID from DInput so autoconfig doesn't rely solely on joypad names - LINUX/X11: Add RetroArch logo to window title bar. - LINUX/X11: Input driver now supports new lightgun code. - LOCALIZATION: Update Italian translation. @@ -19,6 +20,7 @@ - WIIU: Disabled the controller patcher for now since it was the source of many stability issues. - WINDOWS: Add MSVC 2017 solution. - WINDOWS: Raw input driver now supports new lightgun code. +- WINDOWS: Use configured OSD/text message color on GDI driver. # 1.6.9 - COMMON: Small memory leak. From 0cd5b9d14cddadabfbd872fccac5fd438891f902 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 6 Dec 2017 12:04:04 +0100 Subject: [PATCH 247/394] Update CHANGES.md --- CHANGES.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGES.md b/CHANGES.md index dfa858dfe6..8a96ac498c 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -8,7 +8,6 @@ - COMMON: Fixed some playlist bugs. - FREEBSD: Support libusb HID input driver. - HAIKU: Buildfix. -- INPUT: Populate XInput VID/PID from DInput so autoconfig doesn't rely solely on joypad names - LINUX/X11: Add RetroArch logo to window title bar. - LINUX/X11: Input driver now supports new lightgun code. - LOCALIZATION: Update Italian translation. @@ -21,6 +20,7 @@ - WINDOWS: Add MSVC 2017 solution. - WINDOWS: Raw input driver now supports new lightgun code. - WINDOWS: Use configured OSD/text message color on GDI driver. +- WINDOWS/XINPUT: Populate XInput VID/PID from DInput so autoconfig doesn't rely solely on joypad names # 1.6.9 - COMMON: Small memory leak. From 47a19483d15c9624509ac7863a068d825dd060e5 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 6 Dec 2017 12:43:02 +0100 Subject: [PATCH 248/394] Don't show Overlay Settings if HAVE_OVERLAY is not defined --- menu/menu_displaylist.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index b42384394d..051f17d62a 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -5205,8 +5205,10 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) break; case DISPLAYLIST_ONSCREEN_DISPLAY_SETTINGS_LIST: menu_entries_ctl(MENU_ENTRIES_CTL_CLEAR, info->list); +#ifdef HAVE_OVERLAY menu_displaylist_parse_settings_enum(menu, info, MENU_ENUM_LABEL_ONSCREEN_OVERLAY_SETTINGS, PARSE_ACTION, false); +#endif menu_displaylist_parse_settings_enum(menu, info, MENU_ENUM_LABEL_ONSCREEN_NOTIFICATIONS_SETTINGS, PARSE_ACTION, false); From 30eb7f91b4c91a4f49a4b5d1ccb5b87d802ec2fb Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 6 Dec 2017 14:25:41 +0100 Subject: [PATCH 249/394] Fix Coverity warning --- menu/cbs/menu_cbs_ok.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index dedf26bd8e..006fe6d43f 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -1633,7 +1633,7 @@ static int action_ok_playlist_entry(const char *path, NULL, new_core_path); } - else + else if (!string_is_empty(core_path)) strlcpy(new_core_path, core_path, sizeof(new_core_path)); playlist_info.data = playlist; @@ -1651,7 +1651,8 @@ static int action_ok_playlist_entry(const char *path, playlist_info.idx, &path, NULL, NULL, NULL, NULL, NULL); - return default_action_ok_load_content_from_playlist_from_menu(new_core_path, path, entry_label); + return default_action_ok_load_content_from_playlist_from_menu( + new_core_path, path, entry_label); } static int action_ok_playlist_entry_start_content(const char *path, From 06a948c706dc8dab3a164a3fcdedb41de05a70b7 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 6 Dec 2017 14:27:14 +0100 Subject: [PATCH 250/394] Update --- deps/stb/stb_vorbis.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/deps/stb/stb_vorbis.h b/deps/stb/stb_vorbis.h index fd27e6eedc..f662695711 100644 --- a/deps/stb/stb_vorbis.h +++ b/deps/stb/stb_vorbis.h @@ -2497,7 +2497,7 @@ static int vorbis_decode_packet_rest(vorb *f, int *len, Mode *m, int left_start, for (i=0; i < map->submaps; ++i) { float *residue_buffers[STB_VORBIS_MAX_CHANNELS]; int r; - uint8_t do_not_decode[256]; + uint8_t do_not_decode[256] = {0}; int ch = 0; for (j=0; j < f->channels; ++j) { if (map->chan[j].mux == i) { From a53927c5aad8675434b8f6f72d9e8be318b5ec57 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 6 Dec 2017 16:53:19 +0100 Subject: [PATCH 251/394] Fix PS3 build --- gfx/drivers_renderchain/gl2_renderchain.c | 17 +++++++++++++++-- libretro-common/net/net_compat.c | 2 +- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/gfx/drivers_renderchain/gl2_renderchain.c b/gfx/drivers_renderchain/gl2_renderchain.c index 81a6f9ff78..9981c7996c 100644 --- a/gfx/drivers_renderchain/gl2_renderchain.c +++ b/gfx/drivers_renderchain/gl2_renderchain.c @@ -53,9 +53,13 @@ #define MAX_FENCES 4 -#ifndef HAVE_PSGL +#if !defined(HAVE_PSGL) +#define HAVE_GL_SYNC +#endif + +#ifdef HAVE_GL_SYNC #if defined(HAVE_OPENGLES2) - typedef struct __GLsync *GLsync; +typedef struct __GLsync *GLsync; #endif #endif @@ -76,7 +80,9 @@ typedef struct gl2_renderchain unsigned fence_count; +#ifdef HAVE_GL_SYNC GLsync fences[MAX_FENCES]; +#endif struct gfx_fbo_scale fbo_scale[GFX_MAX_SHADERS]; } gl2_renderchain_t; @@ -1449,6 +1455,7 @@ static void gl2_renderchain_fence_iterate( void *chain_data, unsigned hard_sync_frames) { +#ifdef HAVE_GL_SYNC gl2_renderchain_t *chain = (gl2_renderchain_t*)chain_data; chain->fences[chain->fence_count++] = @@ -1464,11 +1471,13 @@ static void gl2_renderchain_fence_iterate( memmove(chain->fences, chain->fences + 1, chain->fence_count * sizeof(void*)); } +#endif } static void gl2_renderchain_fence_free(void *data, void *chain_data) { +#ifdef HAVE_GL_SYNC unsigned i; gl2_renderchain_t *chain = (gl2_renderchain_t*)chain_data; @@ -1479,6 +1488,7 @@ static void gl2_renderchain_fence_free(void *data, glDeleteSync(chain->fences[i]); } chain->fence_count = 0; +#endif } #endif @@ -1489,6 +1499,9 @@ static void gl2_renderchain_init_textures_reference( { gl_t *gl = (gl_t*)data; gl2_renderchain_t *chain = (gl2_renderchain_t*)chain_data; + + (void)chain; + #ifdef HAVE_PSGL glTextureReferenceSCE(GL_TEXTURE_2D, 1, gl->tex_w, gl->tex_h, 0, diff --git a/libretro-common/net/net_compat.c b/libretro-common/net/net_compat.c index d9de1d8ceb..614a2a8228 100644 --- a/libretro-common/net/net_compat.c +++ b/libretro-common/net/net_compat.c @@ -525,7 +525,7 @@ const char *inet_ntop_compat(int af, const void *src, char *dst, socklen_t cnt) { #if defined(VITA) || defined(__ORBIS__) return sceNetInetNtop(af,src,dst,cnt); -#elif defined(WIIU) +#elif defined(WIIU) || defined(__CELLOS_LV2__) return inet_ntop(af, src, dst, cnt); #elif defined(_XBOX) return isockaddr_ntop(af, src, dst, cnt); From 23e6f0be3700aa3d61ab2c6749bba2da05b95488 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 6 Dec 2017 16:54:23 +0100 Subject: [PATCH 252/394] Update --- libretro-common/net/net_compat.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libretro-common/net/net_compat.c b/libretro-common/net/net_compat.c index 614a2a8228..d9de1d8ceb 100644 --- a/libretro-common/net/net_compat.c +++ b/libretro-common/net/net_compat.c @@ -525,7 +525,7 @@ const char *inet_ntop_compat(int af, const void *src, char *dst, socklen_t cnt) { #if defined(VITA) || defined(__ORBIS__) return sceNetInetNtop(af,src,dst,cnt); -#elif defined(WIIU) || defined(__CELLOS_LV2__) +#elif defined(WIIU) return inet_ntop(af, src, dst, cnt); #elif defined(_XBOX) return isockaddr_ntop(af, src, dst, cnt); From b1f1f519d5bf4a7118ef54bb62267ef98f87003e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 6 Dec 2017 18:28:57 +0100 Subject: [PATCH 253/394] Don't redefine HAVE_GL_SYNC --- gfx/drivers_renderchain/gl2_renderchain.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gfx/drivers_renderchain/gl2_renderchain.c b/gfx/drivers_renderchain/gl2_renderchain.c index 9981c7996c..9f4a14fb07 100644 --- a/gfx/drivers_renderchain/gl2_renderchain.c +++ b/gfx/drivers_renderchain/gl2_renderchain.c @@ -54,9 +54,13 @@ #define MAX_FENCES 4 #if !defined(HAVE_PSGL) + +#ifndef HAVE_GL_SYNC #define HAVE_GL_SYNC #endif +#endif + #ifdef HAVE_GL_SYNC #if defined(HAVE_OPENGLES2) typedef struct __GLsync *GLsync; From d5b3104cfb121dbab04f5a0c3a1e64a0f4046f87 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 6 Dec 2017 19:51:07 +0100 Subject: [PATCH 254/394] Cleanups/warning fixes --- gfx/common/vulkan_common.c | 3 +- gfx/drivers_font/vulkan_raster_font.c | 10 +- menu/drivers_display/menu_display_vulkan.c | 7 +- pkg/msvc/msvc-2017/RetroArch-msvc2017.vcxproj | 762 +++++++++--------- 4 files changed, 394 insertions(+), 388 deletions(-) diff --git a/gfx/common/vulkan_common.c b/gfx/common/vulkan_common.c index 461e61131e..553655372f 100644 --- a/gfx/common/vulkan_common.c +++ b/gfx/common/vulkan_common.c @@ -1,4 +1,4 @@ -/* RetroArch - A frontend for libretro. +/* RetroArch - A frontend for libretro. * Copyright (C) 2016-2017 - Hans-Kristian Arntzen * * RetroArch is free software: you can redistribute it and/or modify it under the terms @@ -1398,7 +1398,6 @@ static bool vulkan_context_init_device(gfx_ctx_vulkan_data_t *vk) { bool use_device_ext; uint32_t queue_count; - VkResult res; unsigned i; static const float one = 1.0f; bool found_queue = false; diff --git a/gfx/drivers_font/vulkan_raster_font.c b/gfx/drivers_font/vulkan_raster_font.c index 5897637f12..c76910b500 100644 --- a/gfx/drivers_font/vulkan_raster_font.c +++ b/gfx/drivers_font/vulkan_raster_font.c @@ -1,4 +1,4 @@ -/* RetroArch - A frontend for libretro. +/* RetroArch - A frontend for libretro. * Copyright (C) 2016-2017 - Hans-Kristian Arntzen * * RetroArch is free software: you can redistribute it and/or modify it under the terms @@ -107,11 +107,11 @@ static INLINE void vulkan_raster_font_update_glyph(vulkan_raster_t *font, const { if(font->atlas->dirty) { - int row; - for(row = glyph->atlas_offset_y; row < (glyph->atlas_offset_y + glyph->height); row++) + unsigned row; + for (row = glyph->atlas_offset_y; row < (glyph->atlas_offset_y + glyph->height); row++) { - uint8_t* src = font->atlas->buffer + row * font->atlas->width + glyph->atlas_offset_x; - uint8_t* dst = (uint8_t*)font->texture.mapped + row * font->texture.stride + glyph->atlas_offset_x; + uint8_t *src = font->atlas->buffer + row * font->atlas->width + glyph->atlas_offset_x; + uint8_t *dst = (uint8_t*)font->texture.mapped + row * font->texture.stride + glyph->atlas_offset_x; memcpy(dst, src, glyph->width); } diff --git a/menu/drivers_display/menu_display_vulkan.c b/menu/drivers_display/menu_display_vulkan.c index 385ca402a8..0e7bf488d9 100644 --- a/menu/drivers_display/menu_display_vulkan.c +++ b/menu/drivers_display/menu_display_vulkan.c @@ -1,4 +1,4 @@ -/* RetroArch - A frontend for libretro. +/* RetroArch - A frontend for libretro. * Copyright (C) 2016-2017 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis * @@ -328,7 +328,10 @@ static bool menu_display_vk_font_init_first( is_threaded, FONT_DRIVER_RENDER_VULKAN_API); - return *handle; + if (*handle) + return true; + + return false; } menu_display_ctx_driver_t menu_display_ctx_vulkan = { diff --git a/pkg/msvc/msvc-2017/RetroArch-msvc2017.vcxproj b/pkg/msvc/msvc-2017/RetroArch-msvc2017.vcxproj index 447350a93f..5b77affb19 100644 --- a/pkg/msvc/msvc-2017/RetroArch-msvc2017.vcxproj +++ b/pkg/msvc/msvc-2017/RetroArch-msvc2017.vcxproj @@ -1,379 +1,383 @@ - - - - - Debug Cg - Win32 - - - Debug Cg - x64 - - - Debug - Win32 - - - Debug - x64 - - - Release Cg - Win32 - - - Release Cg - x64 - - - Release - Win32 - - - Release - x64 - - - - {27FF7CE1-4059-4AA1-8062-FD529560FA54} - Win32Proj - RetroArchmsvc2015 - 10.0.16299.0 - - - - Application - true - NotSet - v141 - - - Application - true - NotSet - v141 - - - Application - true - NotSet - v141 - - - Application - true - NotSet - v141 - - - Application - false - true - NotSet - v141 - - - Application - false - true - NotSet - v141 - - - Application - false - true - NotSet - v141 - - - Application - false - true - NotSet - v141 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - true - $(DXSDK_DIR)Include;$(IncludePath) - $(DXSDK_DIR)Lib\x86;$(LibraryPath) - AllRules.ruleset - - - - - true - $(DXSDK_DIR)Include;$(CG_INC_PATH);$(IncludePath) - $(DXSDK_DIR)Lib\x86;$(CG_LIB_PATH);$(LibraryPath) - AllRules.ruleset - - - - - true - $(DXSDK_DIR)Include;$(IncludePath) - $(DXSDK_DIR)Lib\x64;$(LibraryPath) - AllRules.ruleset - - - - - true - $(DXSDK_DIR)Include;$(CG_INC_PATH);$(IncludePath) - $(DXSDK_DIR)Lib\x64;$(CG_LIB64_PATH);$(LibraryPath) - AllRules.ruleset - - - - - false - $(DXSDK_DIR)Include;$(IncludePath) - $(DXSDK_DIR)Lib\x86;$(LibraryPath) - AllRules.ruleset - - - - - false - $(DXSDK_DIR)Include;$(CG_INC_PATH);$(IncludePath) - $(DXSDK_DIR)Lib\x86;$(CG_LIB_PATH);$(LibraryPath) - AllRules.ruleset - - - - - false - $(DXSDK_DIR)Include;$(IncludePath) - $(DXSDK_DIR)Lib\x64;$(LibraryPath) - AllRules.ruleset - - - - - false - $(DXSDK_DIR)Include;$(CG_INC_PATH);$(IncludePath) - $(DXSDK_DIR)Lib\x64;$(CG_LIB64_PATH);$(LibraryPath) - AllRules.ruleset - - - - - - - - Level3 - Disabled - WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT - $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) - MultiThreadedDebug - CompileAsCpp - Fast - StreamingSIMDExtensions - - - Console - true - msimg32.lib;winmm.lib;Dinput8.lib;dxguid.lib;Iphlpapi.lib;%(AdditionalDependencies) - - - - - - - Level3 - Disabled - WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_CG;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;HAVE_FBO;WANT_ZLIB;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT - $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(CG_INC_PATH);$(MSBuildProjectDirectory)\..\..\..\deps\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) - MultiThreadedDebug - CompileAsCpp - Fast - StreamingSIMDExtensions - - - Console - true - msimg32.lib;winmm.lib;Dinput8.lib;dxguid.lib;Iphlpapi.lib;%(AdditionalDependencies) - $(CG_LIB_PATH) - - - - - - - Level3 - Disabled - WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_SECURE_NO_WARNINGS;__SSE__;__SSE2__;__x86_64__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT - $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) - MultiThreadedDebug - CompileAsCpp - Fast - StreamingSIMDExtensions2 - - - Console - true - msimg32.lib;winmm.lib;Dinput8.lib;dxguid.lib;Iphlpapi.lib;%(AdditionalDependencies) - - - - - - - Level3 - Disabled - WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_CG;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;HAVE_FBO;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;WANT_ZLIB;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_SECURE_NO_WARNINGS;__SSE__;__SSE2__;__x86_64__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT - $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(CG_INC_PATH);$(MSBuildProjectDirectory)\..\..\..\deps\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) - MultiThreadedDebug - CompileAsCpp - Fast - StreamingSIMDExtensions2 - - - Console - true - msimg32.lib;winmm.lib;Dinput8.lib;dxguid.lib;Iphlpapi.lib;%(AdditionalDependencies) - $(CG_LIB64_PATH) - - - - - Level3 - - - MaxSpeed - true - true - WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_MENU;HAVE_RGUI;HAVE_GL_SYNC;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT - $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) - MultiThreaded - CompileAsCpp - Fast - StreamingSIMDExtensions - true - - - Console - true - true - true - msimg32.lib;winmm.lib;Dinput8.lib;dxguid.lib;Iphlpapi.lib;%(AdditionalDependencies) - - - - - Level3 - - - MaxSpeed - true - true - WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_CG;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;HAVE_FBO;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;WANT_ZLIB;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_MENU;HAVE_RGUI;HAVE_GL_SYNC;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT - $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(CG_INC_PATH);$(MSBuildProjectDirectory)\..\..\..\deps\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) - MultiThreaded - CompileAsCpp - Fast - StreamingSIMDExtensions - true - - - Console - true - true - true - msimg32.lib;winmm.lib;Dinput8.lib;dxguid.lib;Iphlpapi.lib;%(AdditionalDependencies) - $(CG_LIB_PATH) - - - - - Level3 - - - MaxSpeed - true - true - WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;_CRT_SECURE_NO_WARNINGS;__SSE__;__SSE2__;__x86_64__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT - $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) - MultiThreaded - CompileAsCpp - Fast - StreamingSIMDExtensions2 - true - - - Console - true - true - true - msimg32.lib;winmm.lib;Dinput8.lib;dxguid.lib;Iphlpapi.lib;%(AdditionalDependencies) - - - - - Level3 - - - MaxSpeed - true - true - WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_CG;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;HAVE_FBO;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;WANT_ZLIB;_CRT_SECURE_NO_WARNINGS;__SSE__;__SSE2__;__x86_64__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT - $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(CG_INC_PATH);$(MSBuildProjectDirectory)\..\..\..\deps\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) - MultiThreaded - CompileAsCpp - Fast - StreamingSIMDExtensions2 - true - - - Console - true - true - true - msimg32.lib;winmm.lib;Dinput8.lib;dxguid.lib;Iphlpapi.lib;%(AdditionalDependencies) - $(CG_LIB64_PATH) - - - - - - - - CompileAsC - CompileAsC - CompileAsC - CompileAsC - - - - - - - \ No newline at end of file + + + + + Debug Cg + Win32 + + + Debug Cg + x64 + + + Debug + Win32 + + + Debug + x64 + + + Release Cg + Win32 + + + Release Cg + x64 + + + Release + Win32 + + + Release + x64 + + + + {27FF7CE1-4059-4AA1-8062-FD529560FA54} + Win32Proj + RetroArchmsvc2015 + 10.0.16299.0 + + + + Application + true + NotSet + v141 + + + Application + true + NotSet + v141 + + + Application + true + NotSet + v141 + + + Application + true + NotSet + v141 + + + Application + false + true + NotSet + v141 + + + Application + false + true + NotSet + v141 + + + Application + false + true + NotSet + v141 + + + Application + false + true + NotSet + v141 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + true + $(DXSDK_DIR)Include;$(IncludePath) + $(DXSDK_DIR)Lib\x86;$(LibraryPath) + AllRules.ruleset + + + + + true + $(DXSDK_DIR)Include;$(CG_INC_PATH);$(IncludePath) + $(DXSDK_DIR)Lib\x86;$(CG_LIB_PATH);$(LibraryPath) + AllRules.ruleset + + + + + true + $(DXSDK_DIR)Include;$(IncludePath) + $(DXSDK_DIR)Lib\x64;$(LibraryPath) + AllRules.ruleset + + + + + true + $(DXSDK_DIR)Include;$(CG_INC_PATH);$(IncludePath) + $(DXSDK_DIR)Lib\x64;$(CG_LIB64_PATH);$(LibraryPath) + AllRules.ruleset + + + + + false + $(DXSDK_DIR)Include;$(IncludePath) + $(DXSDK_DIR)Lib\x86;$(LibraryPath) + AllRules.ruleset + + + + + false + $(DXSDK_DIR)Include;$(CG_INC_PATH);$(IncludePath) + $(DXSDK_DIR)Lib\x86;$(CG_LIB_PATH);$(LibraryPath) + AllRules.ruleset + + + + + false + $(DXSDK_DIR)Include;$(IncludePath) + $(DXSDK_DIR)Lib\x64;$(LibraryPath) + AllRules.ruleset + + + + + false + $(DXSDK_DIR)Include;$(CG_INC_PATH);$(IncludePath) + $(DXSDK_DIR)Lib\x64;$(CG_LIB64_PATH);$(LibraryPath) + AllRules.ruleset + + + + + + + + Level3 + Disabled + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) + MultiThreadedDebug + CompileAsCpp + Fast + StreamingSIMDExtensions + + + Console + true + msimg32.lib;winmm.lib;Dinput8.lib;dxguid.lib;Iphlpapi.lib;%(AdditionalDependencies) + + + + + + + Level3 + Disabled + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_CG;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;HAVE_FBO;WANT_ZLIB;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(CG_INC_PATH);$(MSBuildProjectDirectory)\..\..\..\deps\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) + MultiThreadedDebug + CompileAsCpp + Fast + StreamingSIMDExtensions + + + Console + true + msimg32.lib;winmm.lib;Dinput8.lib;dxguid.lib;Iphlpapi.lib;%(AdditionalDependencies) + $(CG_LIB_PATH) + + + + + + + Level3 + Disabled + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_SECURE_NO_WARNINGS;__SSE__;__SSE2__;__x86_64__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) + MultiThreadedDebug + CompileAsCpp + Fast + StreamingSIMDExtensions2 + + + Console + true + msimg32.lib;winmm.lib;Dinput8.lib;dxguid.lib;Iphlpapi.lib;%(AdditionalDependencies) + + + + + + + Level3 + Disabled + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_CG;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;HAVE_FBO;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;WANT_ZLIB;_DEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_SECURE_NO_WARNINGS;__SSE__;__SSE2__;__x86_64__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(CG_INC_PATH);$(MSBuildProjectDirectory)\..\..\..\deps\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) + MultiThreadedDebug + CompileAsCpp + Fast + StreamingSIMDExtensions2 + + + Console + true + msimg32.lib;winmm.lib;Dinput8.lib;dxguid.lib;Iphlpapi.lib;%(AdditionalDependencies) + $(CG_LIB64_PATH) + + + + + Level3 + + + MaxSpeed + true + true + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_MENU;HAVE_RGUI;HAVE_GL_SYNC;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) + MultiThreaded + CompileAsCpp + Fast + StreamingSIMDExtensions + true + + + Console + true + true + true + msimg32.lib;winmm.lib;Dinput8.lib;dxguid.lib;Iphlpapi.lib;%(AdditionalDependencies) + + + + + Level3 + + + MaxSpeed + true + true + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_CG;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;HAVE_FBO;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;WANT_ZLIB;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;_CRT_NONSTDC_NO_WARNINGS;_CRT_SECURE_NO_WARNINGS;__SSE__;__i686__;HAVE_OVERLAY;HAVE_MENU;HAVE_RGUI;HAVE_GL_SYNC;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(CG_INC_PATH);$(MSBuildProjectDirectory)\..\..\..\deps\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) + MultiThreaded + CompileAsCpp + Fast + StreamingSIMDExtensions + true + + + Console + true + true + true + msimg32.lib;winmm.lib;Dinput8.lib;dxguid.lib;Iphlpapi.lib;%(AdditionalDependencies) + $(CG_LIB_PATH) + + + + + Level3 + + + MaxSpeed + true + true + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;_CRT_SECURE_NO_WARNINGS;__SSE__;__SSE2__;__x86_64__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(MSBuildProjectDirectory)\..\..\..\deps\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) + MultiThreaded + CompileAsCpp + Fast + StreamingSIMDExtensions2 + true + + + Console + true + true + true + msimg32.lib;winmm.lib;Dinput8.lib;dxguid.lib;Iphlpapi.lib;%(AdditionalDependencies) + + + + + Level3 + + + MaxSpeed + true + true + WIN32;RARCH_INTERNAL;HAVE_CC_RESAMPLER;HAVE_UPDATE_ASSETS;HAVE_D3D;HAVE_D3D9;HAVE_CG;HAVE_GLSL;HAVE_GRIFFIN;HAVE_LANGEXTRA;HAVE_FBO;HAVE_ZLIB;HAVE_XMB;HAVE_SHADERPIPELINE;WANT_ZLIB;HAVE_FBO;NDEBUG;_WINDOWS;%(PreprocessorDefinitions);HAVE_DINPUT;HAVE_XINPUT;HAVE_XAUDIO;HAVE_DSOUND;HAVE_OPENGL;HAVE_DYLIB;HAVE_NETWORKING;HAVE_NETWORK_CMD;HAVE_COMMAND;HAVE_STDIN_CMD;HAVE_THREADS;HAVE_DYNAMIC;HAVE_RPNG;HAVE_RJPEG;HAVE_RBMP;HAVE_RTGA;HAVE_IMAGEVIEWER;WANT_ZLIB;_CRT_SECURE_NO_WARNINGS;__SSE__;__SSE2__;__x86_64__;HAVE_OVERLAY;HAVE_RGUI;HAVE_GL_SYNC;HAVE_MENU;HAVE_7ZIP;HAVE_MATERIALUI;HAVE_LIBRETRODB;HAVE_STB_FONT + $(MSBuildProjectDirectory);$(MSBuildProjectDirectory)\..\..\..\;$(CG_INC_PATH);$(MSBuildProjectDirectory)\..\..\..\deps\zlib;$(MSBuildProjectDirectory)\..\..\..\libretro-common\include;$(MSBuildProjectDirectory)\..\..\..\deps;$(MSBuildProjectDirectory)\..\..\..\deps\glslang;$(MSBuildProjectDirectory)\..\..\..\deps\SPIRV-Cross;$(MSBuildProjectDirectory)\..\..\..\deps\stb;$(MSBuildProjectDirectory)\..\..\..\gfx\include;%(AdditionalIncludeDirectories) + MultiThreaded + CompileAsCpp + Fast + StreamingSIMDExtensions2 + true + + + Console + true + true + true + msimg32.lib;winmm.lib;Dinput8.lib;dxguid.lib;Iphlpapi.lib;%(AdditionalDependencies) + $(CG_LIB64_PATH) + + + + + + + + CompileAsC + CompileAsC + CompileAsC + CompileAsC + CompileAsC + CompileAsC + CompileAsC + CompileAsC + + + + + + + From 494ba8685e10222d631af6709379b3ed68d56bab Mon Sep 17 00:00:00 2001 From: Rob Loach Date: Wed, 6 Dec 2017 14:34:20 -0500 Subject: [PATCH 255/394] Update make install for new retroarch-assets src The assets over at [retroarch-assets](https://github.com/libretro/retroarch-assets) have [moved the source files](https://github.com/libretro/retroarch-assets/pull/191) so that the asset installation process is a much easier. We no longer have the need to delete the theme src directories. --- Makefile | 7 ------- 1 file changed, 7 deletions(-) diff --git a/Makefile b/Makefile index 8e70dd430d..b820c54233 100644 --- a/Makefile +++ b/Makefile @@ -205,13 +205,6 @@ install: $(TARGET) mkdir -p $(DESTDIR)$(ASSETS_DIR)/retroarch/assets/glui; \ cp -r media/assets/xmb/ $(DESTDIR)$(ASSETS_DIR)/retroarch/assets; \ cp -r media/assets/glui/ $(DESTDIR)$(ASSETS_DIR)/retroarch/assets; \ - echo "Removing unneeded source image files.."; \ - rm -rf $(DESTDIR)$(ASSETS_DIR)/retroarch/assets/xmb/flatui/src; \ - rm -rf $(DESTDIR)$(ASSETS_DIR)/retroarch/assets/xmb/monochrome/src; \ - rm -rf $(DESTDIR)$(ASSETS_DIR)/retroarch/assets/xmb/retroactive/src; \ - rm -rf $(DESTDIR)$(ASSETS_DIR)/retroarch/assets/xmb/neoactive/src; \ - rm -rf $(DESTDIR)$(ASSETS_DIR)/retroarch/assets/xmb/retrosystem/src; \ - rm -rf $(DESTDIR)$(ASSETS_DIR)/retroarch/assets/xmb/dot-art/src; \ echo "Asset copying done."; \ fi From 4e9cb21e0322e4d1bfac006c47a392d43752a585 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 6 Dec 2017 20:38:22 +0100 Subject: [PATCH 256/394] Don't use hashes --- driver.c | 121 ++++++++++++++++++++++++++----------------------------- 1 file changed, 58 insertions(+), 63 deletions(-) diff --git a/driver.c b/driver.c index 96fc0c2c73..7fe0193d29 100644 --- a/driver.c +++ b/driver.c @@ -44,17 +44,6 @@ #include "retroarch.h" #include "verbosity.h" -#define HASH_LOCATION_DRIVER 0x09189689U -#define HASH_CAMERA_DRIVER 0xf25db959U -#define HASH_MENU_DRIVER 0xd607fb05U -#define HASH_INPUT_DRIVER 0x4c087840U -#define HASH_INPUT_JOYPAD_DRIVER 0xab124146U -#define HASH_VIDEO_DRIVER 0x1805a5e7U -#define HASH_AUDIO_DRIVER 0x26594002U -#define HASH_AUDIO_RESAMPLER_DRIVER 0xedcba9ecU -#define HASH_RECORD_DRIVER 0x144cd2cfU -#define HASH_WIFI_DRIVER 0x64d7d17fU - /** * find_driver_nonempty: * @label : string of driver type to be found. @@ -72,62 +61,68 @@ static const void *find_driver_nonempty(const char *label, int i, char *s, size_t len) { const void *drv = NULL; - uint32_t hash = msg_hash_calculate(label); - switch (hash) + if (string_is_equal(label, "camera_driver")) { - case HASH_CAMERA_DRIVER: - drv = camera_driver_find_handle(i); - if (drv) - strlcpy(s, camera_driver_find_ident(i), len); - break; - case HASH_LOCATION_DRIVER: - drv = location_driver_find_handle(i); - if (drv) - strlcpy(s, location_driver_find_ident(i), len); - break; - case HASH_MENU_DRIVER: + drv = camera_driver_find_handle(i); + if (drv) + strlcpy(s, camera_driver_find_ident(i), len); + } + else if (string_is_equal(label, "location_driver")) + { + drv = location_driver_find_handle(i); + if (drv) + strlcpy(s, location_driver_find_ident(i), len); + } #ifdef HAVE_MENU - drv = menu_driver_find_handle(i); - if (drv) - strlcpy(s, menu_driver_find_ident(i), len); + else if (string_is_equal(label, "menu_driver")) + { + drv = menu_driver_find_handle(i); + if (drv) + strlcpy(s, menu_driver_find_ident(i), len); + } #endif - break; - case HASH_INPUT_DRIVER: - drv = input_driver_find_handle(i); - if (drv) - strlcpy(s, input_driver_find_ident(i), len); - break; - case HASH_INPUT_JOYPAD_DRIVER: - drv = joypad_driver_find_handle(i); - if (drv) - strlcpy(s, joypad_driver_find_ident(i), len); - break; - case HASH_VIDEO_DRIVER: - drv = video_driver_find_handle(i); - if (drv) - strlcpy(s, video_driver_find_ident(i), len); - break; - case HASH_AUDIO_DRIVER: - drv = audio_driver_find_handle(i); - if (drv) - strlcpy(s, audio_driver_find_ident(i), len); - break; - case HASH_RECORD_DRIVER: - drv = record_driver_find_handle(i); - if (drv) - strlcpy(s, record_driver_find_ident(i), len); - break; - case HASH_AUDIO_RESAMPLER_DRIVER: - drv = audio_resampler_driver_find_handle(i); - if (drv) - strlcpy(s, audio_resampler_driver_find_ident(i), len); - break; - case HASH_WIFI_DRIVER: - drv = wifi_driver_find_handle(i); - if (drv) - strlcpy(s, wifi_driver_find_ident(i), len); - break; + else if (string_is_equal(label, "input_driver")) + { + drv = input_driver_find_handle(i); + if (drv) + strlcpy(s, input_driver_find_ident(i), len); + } + else if (string_is_equal(label, "joypad_driver")) + { + drv = joypad_driver_find_handle(i); + if (drv) + strlcpy(s, joypad_driver_find_ident(i), len); + } + else if (string_is_equal(label, "video_driver")) + { + drv = video_driver_find_handle(i); + if (drv) + strlcpy(s, video_driver_find_ident(i), len); + } + else if (string_is_equal(label, "audio_driver")) + { + drv = audio_driver_find_handle(i); + if (drv) + strlcpy(s, audio_driver_find_ident(i), len); + } + else if (string_is_equal(label, "record_driver")) + { + drv = record_driver_find_handle(i); + if (drv) + strlcpy(s, record_driver_find_ident(i), len); + } + else if (string_is_equal(label, "audio_resampler_driver")) + { + drv = audio_resampler_driver_find_handle(i); + if (drv) + strlcpy(s, audio_resampler_driver_find_ident(i), len); + } + else if (string_is_equal(label, "wifi_driver")) + { + drv = wifi_driver_find_handle(i); + if (drv) + strlcpy(s, wifi_driver_find_ident(i), len); } return drv; From fd23a751e40a5ef7362f0dbe60d371e2b38491e0 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 6 Dec 2017 20:40:18 +0100 Subject: [PATCH 257/394] Fix joypad_driver --- driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/driver.c b/driver.c index 7fe0193d29..fbee1c29f1 100644 --- a/driver.c +++ b/driver.c @@ -88,7 +88,7 @@ static const void *find_driver_nonempty(const char *label, int i, if (drv) strlcpy(s, input_driver_find_ident(i), len); } - else if (string_is_equal(label, "joypad_driver")) + else if (string_is_equal(label, "input_joypad_driver")) { drv = joypad_driver_find_handle(i); if (drv) From fbf4b4813c82dc6cb63968e71b9ae9f9a7c7938b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 6 Dec 2017 20:52:29 +0100 Subject: [PATCH 258/394] Cleanup path_set_redirect - no more hashes --- paths.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/paths.c b/paths.c index 1b831ca598..54698213be 100644 --- a/paths.c +++ b/paths.c @@ -62,8 +62,7 @@ void path_set_redirect(void) size_t path_size = PATH_MAX_LENGTH * sizeof(char); char *new_savefile_dir = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); char *new_savestate_dir = (char*)malloc(PATH_MAX_LENGTH * sizeof(char)); - uint32_t library_name_hash = 0; - bool check_library_name_hash = false; + bool check_library_name = false; global_t *global = global_get_ptr(); const char *old_savefile_dir = dir_get(RARCH_DIR_SAVEFILE); const char *old_savestate_dir = dir_get(RARCH_DIR_SAVESTATE); @@ -72,22 +71,21 @@ void path_set_redirect(void) new_savefile_dir[0] = new_savestate_dir[0] = '\0'; - if (info && !string_is_empty(info->info.library_name)) - library_name_hash = - msg_hash_calculate(info->info.library_name); - /* Initialize current save directories * with the values from the config. */ strlcpy(new_savefile_dir, old_savefile_dir, path_size); strlcpy(new_savestate_dir, old_savestate_dir, path_size); - check_library_name_hash = (library_name_hash != 0); + if (info && !string_is_empty(info->info.library_name)) + { #ifdef HAVE_MENU - check_library_name_hash = check_library_name_hash && - (library_name_hash != MENU_VALUE_NO_CORE); + if (!string_is_equal(info->info.library_name, + msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NO_CORE))) #endif + check_library_name = true; + } - if (check_library_name_hash) + if (check_library_name) { /* per-core saves: append the library_name to the save location */ if (settings->bools.sort_savefiles_enable From 542235ffd7c8b1807419a12dc9d041903df37cae Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 6 Dec 2017 21:55:21 +0100 Subject: [PATCH 259/394] (XMB) Get rid of hashes --- menu/drivers/xmb.c | 41 ++++++++++++++++++++--------------------- 1 file changed, 20 insertions(+), 21 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 0185ec76ee..f51c088d71 100755 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -2376,30 +2376,29 @@ static int xmb_draw_item( } else { - enum msg_file_type type = FILE_TYPE_NONE; - if (!string_is_empty(entry->value)) - type = msg_hash_to_file_type(msg_hash_calculate(entry->value)); - - switch (type) { - case FILE_TYPE_IN_CARCHIVE: - case FILE_TYPE_COMPRESSED: - case FILE_TYPE_MORE: - case FILE_TYPE_CORE: - case FILE_TYPE_DIRECT_LOAD: - case FILE_TYPE_RDB: - case FILE_TYPE_CURSOR: - case FILE_TYPE_PLAIN: - case FILE_TYPE_DIRECTORY: - case FILE_TYPE_MUSIC: - case FILE_TYPE_IMAGE: - case FILE_TYPE_MOVIE: - break; - default: - do_draw_text = true; - break; + if ( + string_is_equal(entry->value, "...") || + string_is_equal(entry->value, "(COMP)") || + string_is_equal(entry->value, "(CORE)") || + string_is_equal(entry->value, "(MOVIE)") || + string_is_equal(entry->value, "(MUSIC)") || + string_is_equal(entry->value, "(DIR)") || + string_is_equal(entry->value, "(RDB)") || + string_is_equal(entry->value, "(CURSOR)")|| + string_is_equal(entry->value, "(CFILE)") || + string_is_equal(entry->value, "(FILE)") || + string_is_equal(entry->value, "(IMAGE)") + ) + { + } + else + do_draw_text = true; } + else + do_draw_text = true; + } if (string_is_empty(entry->value)) From 951918a245abd821bcfd533fc732cd6064420a98 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 7 Dec 2017 05:54:54 +0100 Subject: [PATCH 260/394] Reduce size of Makefiles --- Makefile.common | 44 ++++++++++++++++++++++++++++++++++++++++++++ Makefile.ctr | 30 ++---------------------------- Makefile.emscripten | 22 ++-------------------- Makefile.vita | 20 ++------------------ Makefile.wiiu | 20 ++------------------ 5 files changed, 52 insertions(+), 84 deletions(-) diff --git a/Makefile.common b/Makefile.common index 14caf2e201..07bf65126d 100644 --- a/Makefile.common +++ b/Makefile.common @@ -127,6 +127,10 @@ ifeq ($(HAVE_UNIX), 1) OBJ += frontend/drivers/platform_unix.o endif +ifeq ($(TARGET), retroarch_3ds) + OBJ += frontend/drivers/platform_ctr.o +endif + ifeq ($(findstring Haiku,$(OS)),) LIBS += -lm DEBUG_FLAG = -g @@ -570,12 +574,21 @@ ifeq ($(HAVE_CORETEXT), 1) OBJ += gfx/drivers_font_renderer/coretext.o endif +ifeq ($(TARGET), retroarch_3ds) + OBJ += gfx/drivers_font/ctr_font.o +endif + ifeq ($(HAVE_OSS), 1) OBJ += audio/drivers/oss.o else ifeq ($(HAVE_OSS_BSD), 1) OBJ += audio/drivers/oss.o endif +ifeq ($(TARGET), retroarch_3ds) + OBJ += audio/drivers/ctr_csnd_audio.o \ + audio/drivers/ctr_dsp_audio.o +endif + ifeq ($(HAVE_ALSA), 1) OBJ += audio/drivers/alsa.o @@ -845,6 +858,13 @@ endif CFLAGS += -I$(DEPS_DIR)/libvita2d/include endif +ifeq ($(TARGET), retroarch_3ds) + OBJ += gfx/drivers/ctr_gfx.o \ + menu/drivers_display/menu_display_ctr.o \ + input/drivers/ctr_input.o \ + input/drivers_joypad/ctr_joypad.o +endif + ifeq ($(HAVE_WAYLAND), 1) OBJ += gfx/drivers_context/wayland_ctx.o \ input/drivers/wayland_input.o @@ -1584,3 +1604,27 @@ ifneq ($(findstring DOS,$(OS)),) OBJ += menu/drivers_display/menu_display_vga.o endif endif + +ifeq ($(HAVE_STATIC_VIDEO_FILTERS), 1) +OBJ += gfx/video_filters/2xsai.o \ + gfx/video_filters/super2xsai.o \ + gfx/video_filters/supereagle.o \ + gfx/video_filters/2xbr.o \ + gfx/video_filters/darken.o \ + gfx/video_filters/epx.o \ + gfx/video_filters/scale2x.o \ + gfx/video_filters/blargg_ntsc_snes.o \ + gfx/video_filters/lq2x.o \ + gfx/video_filters/phosphor2x.o +endif + +ifeq ($(HAVE_STATIC_AUDIO_FILTERS), 1) +OBJ += libretro-common/audio/dsp_filters/echo.o \ + libretro-common/audio/dsp_filters/eq.o \ + libretro-common/audio/dsp_filters/chorus.o \ + libretro-common/audio/dsp_filters/iir.o \ + libretro-common/audio/dsp_filters/panning.o \ + libretro-common/audio/dsp_filters/phaser.o \ + libretro-common/audio/dsp_filters/reverb.o \ + libretro-common/audio/dsp_filters/wahwah.o +endif diff --git a/Makefile.ctr b/Makefile.ctr index c277d3df77..79e34c8a8c 100644 --- a/Makefile.ctr +++ b/Makefile.ctr @@ -61,42 +61,16 @@ else HAVE_ZARCH = 0 HAVE_MATERIALUI = 1 HAVE_XMB = 1 + HAVE_STATIC_VIDEO_FILTERS = 1 + HAVE_STATIC_AUDIO_FILTERS = 1 include Makefile.common BLACKLIST := BLACKLIST += input/input_overlay.o BLACKLIST += tasks/task_overlay.o OBJ := $(filter-out $(BLACKLIST),$(OBJ)) - - OBJ += gfx/drivers/ctr_gfx.o - OBJ += gfx/drivers_font/ctr_font.o - OBJ += menu/drivers_display/menu_display_ctr.o - OBJ += input/drivers/ctr_input.o - OBJ += input/drivers_joypad/ctr_joypad.o - OBJ += audio/drivers/ctr_csnd_audio.o - OBJ += audio/drivers/ctr_dsp_audio.o - OBJ += frontend/drivers/platform_ctr.o - OBJ += gfx/video_filters/2xsai.o - OBJ += gfx/video_filters/super2xsai.o - OBJ += gfx/video_filters/supereagle.o - OBJ += gfx/video_filters/2xbr.o - OBJ += gfx/video_filters/darken.o - OBJ += gfx/video_filters/epx.o - OBJ += gfx/video_filters/scale2x.o - OBJ += gfx/video_filters/blargg_ntsc_snes.o - OBJ += gfx/video_filters/lq2x.o - OBJ += gfx/video_filters/phosphor2x.o - OBJ += libretro-common/audio/dsp_filters/echo.o - OBJ += libretro-common/audio/dsp_filters/eq.o - OBJ += libretro-common/audio/dsp_filters/chorus.o - OBJ += libretro-common/audio/dsp_filters/iir.o - OBJ += libretro-common/audio/dsp_filters/panning.o - OBJ += libretro-common/audio/dsp_filters/phaser.o - OBJ += libretro-common/audio/dsp_filters/reverb.o - OBJ += libretro-common/audio/dsp_filters/wahwah.o endif - ifeq ($(strip $(DEVKITPRO)),) $(error "Please set DEVKITPRO in your environment. export DEVKITPRO=devkitpro") endif diff --git a/Makefile.emscripten b/Makefile.emscripten index fb3a215339..e191cfd874 100644 --- a/Makefile.emscripten +++ b/Makefile.emscripten @@ -20,6 +20,8 @@ HAVE_SDL = 0 HAVE_SDL2 = 1 HAVE_ZLIB = 1 WANT_ZLIB = 1 +HAVE_STATIC_VIDEO_FILTERS = 1 +HAVE_STATIC_AUDIO_FILTERS = 1 MEMORY = 536870912 # XXX: setting this to 1/2 currently crashes Firefox nightly @@ -51,26 +53,6 @@ endif include Makefile.common -OBJ += gfx/video_filters/2xsai.o -OBJ += gfx/video_filters/super2xsai.o -OBJ += gfx/video_filters/supereagle.o -OBJ += gfx/video_filters/2xbr.o -OBJ += gfx/video_filters/darken.o -OBJ += gfx/video_filters/epx.o -OBJ += gfx/video_filters/scale2x.o -OBJ += gfx/video_filters/blargg_ntsc_snes.o -OBJ += gfx/video_filters/lq2x.o -OBJ += gfx/video_filters/phosphor2x.o - -OBJ += libretro-common/audio/dsp_filters/echo.o -OBJ += libretro-common/audio/dsp_filters/eq.o -OBJ += libretro-common/audio/dsp_filters/chorus.o -OBJ += libretro-common/audio/dsp_filters/iir.o -OBJ += libretro-common/audio/dsp_filters/panning.o -OBJ += libretro-common/audio/dsp_filters/phaser.o -OBJ += libretro-common/audio/dsp_filters/reverb.o -OBJ += libretro-common/audio/dsp_filters/wahwah.o - CFLAGS += -Ideps/libz -Ideps -Ideps/stb libretro = libretro_emscripten.bc diff --git a/Makefile.vita b/Makefile.vita index 3138442913..25d79a673e 100644 --- a/Makefile.vita +++ b/Makefile.vita @@ -47,6 +47,8 @@ else HAVE_CC_RESAMPLER := 1 HAVE_CHEEVOS := 1 RARCH_CONSOLE := 1 + HAVE_STATIC_VIDEO_FILTERS = 1 + HAVE_STATIC_AUDIO_FILTERS = 1 ifeq ($(DEBUG), 1) HAVE_NETLOGGER = 1 @@ -60,24 +62,6 @@ else OBJ += input/drivers_joypad/psp_joypad.o OBJ += audio/drivers/psp_audio.o OBJ += frontend/drivers/platform_psp.o - OBJ += gfx/video_filters/2xsai.o - OBJ += gfx/video_filters/super2xsai.o - OBJ += gfx/video_filters/supereagle.o - OBJ += gfx/video_filters/2xbr.o - OBJ += gfx/video_filters/darken.o - OBJ += gfx/video_filters/epx.o - OBJ += gfx/video_filters/scale2x.o - OBJ += gfx/video_filters/blargg_ntsc_snes.o - OBJ += gfx/video_filters/lq2x.o - OBJ += gfx/video_filters/phosphor2x.o - OBJ += libretro-common/audio/dsp_filters/echo.o - OBJ += libretro-common/audio/dsp_filters/eq.o - OBJ += libretro-common/audio/dsp_filters/chorus.o - OBJ += libretro-common/audio/dsp_filters/iir.o - OBJ += libretro-common/audio/dsp_filters/panning.o - OBJ += libretro-common/audio/dsp_filters/phaser.o - OBJ += libretro-common/audio/dsp_filters/reverb.o - OBJ += libretro-common/audio/dsp_filters/wahwah.o endif diff --git a/Makefile.wiiu b/Makefile.wiiu index 00881ed117..b3389af1af 100644 --- a/Makefile.wiiu +++ b/Makefile.wiiu @@ -71,6 +71,8 @@ else HAVE_NETWORKING = 1 HAVE_CHEEVOS = 1 # WANT_IFADDRS = 1 + HAVE_STATIC_VIDEO_FILTERS = 1 + HAVE_STATIC_AUDIO_FILTERS = 1 include Makefile.common BLACKLIST := @@ -86,24 +88,6 @@ else OBJ += input/drivers_joypad/wiiu_joypad.o OBJ += audio/drivers/wiiu_audio.o OBJ += frontend/drivers/platform_wiiu.o - OBJ += gfx/video_filters/2xsai.o - OBJ += gfx/video_filters/super2xsai.o - OBJ += gfx/video_filters/supereagle.o - OBJ += gfx/video_filters/2xbr.o - OBJ += gfx/video_filters/darken.o - OBJ += gfx/video_filters/epx.o - OBJ += gfx/video_filters/scale2x.o - OBJ += gfx/video_filters/blargg_ntsc_snes.o - OBJ += gfx/video_filters/lq2x.o - OBJ += gfx/video_filters/phosphor2x.o - OBJ += libretro-common/audio/dsp_filters/echo.o - OBJ += libretro-common/audio/dsp_filters/eq.o - OBJ += libretro-common/audio/dsp_filters/chorus.o - OBJ += libretro-common/audio/dsp_filters/iir.o - OBJ += libretro-common/audio/dsp_filters/panning.o - OBJ += libretro-common/audio/dsp_filters/phaser.o - OBJ += libretro-common/audio/dsp_filters/reverb.o - OBJ += libretro-common/audio/dsp_filters/wahwah.o endif DEFINES += -DHAVE_KEYMAPPER From fa7cd77d7d16dca7ddd18a647b2316c63c7ec12f Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Thu, 7 Dec 2017 13:49:07 -0500 Subject: [PATCH 261/394] win32: improve version reporting under System Information --- CHANGES.md | 1 + frontend/drivers/platform_win32.c | 122 ++++++++++++++++++++++++++---- menu/menu_displaylist.c | 2 +- 3 files changed, 109 insertions(+), 16 deletions(-) diff --git a/CHANGES.md b/CHANGES.md index 8a96ac498c..ddb34e00e7 100644 --- a/CHANGES.md +++ b/CHANGES.md @@ -21,6 +21,7 @@ - WINDOWS: Raw input driver now supports new lightgun code. - WINDOWS: Use configured OSD/text message color on GDI driver. - WINDOWS/XINPUT: Populate XInput VID/PID from DInput so autoconfig doesn't rely solely on joypad names +- WINDOWS: Improve version reporting under System Information. # 1.6.9 - COMMON: Small memory leak. diff --git a/frontend/drivers/platform_win32.c b/frontend/drivers/platform_win32.c index 2988b75c4e..b523c487a0 100644 --- a/frontend/drivers/platform_win32.c +++ b/frontend/drivers/platform_win32.c @@ -1,5 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2011-2017 - Daniel De Matteis + * Copyright (C) 2016-2017 - Brad Parker * * RetroArch 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 Found- @@ -25,6 +26,7 @@ #include #include #include +#include #ifdef HAVE_CONFIG_H #include "../../config.h" @@ -130,40 +132,110 @@ static void gfx_set_dwm(void) static void frontend_win32_get_os(char *s, size_t len, int *major, int *minor) { - uint32_t version = GetVersion(); + char buildStr[11] = {0}; + bool server = false; + const char *arch = ""; + bool serverR2 = false; - *major = (DWORD)(LOBYTE(LOWORD(version))); - *minor = (DWORD)(HIBYTE(LOWORD(version))); +#if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0500 + /* Windows 2000 and later */ + SYSTEM_INFO si = {0}; + OSVERSIONINFOEX vi = {0}; + vi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); - switch (*major) + server = vi.wProductType != VER_NT_WORKSTATION; + + serverR2 = GetSystemMetrics(SM_SERVERR2); + + GetSystemInfo(&si); + + switch (si.wProcessorArchitecture) + { + case PROCESSOR_ARCHITECTURE_AMD64: + arch = "x64"; + break; + case PROCESSOR_ARCHITECTURE_INTEL: + arch = "x86"; + break; + case PROCESSOR_ARCHITECTURE_ARM: + arch = "ARM"; + break; + default: + break; + } +#else + OSVERSIONINFO vi = {0}; + vi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); +#endif + + /* Available from NT 3.5 and Win95 */ + GetVersionEx((OSVERSIONINFO*)&vi); + + if (major) + *major = vi.dwMajorVersion; + + if (minor) + *minor = vi.dwMinorVersion; + + if (vi.dwMajorVersion == 4 && vi.dwMinorVersion == 0) + snprintf(buildStr, sizeof(buildStr), "%lu", (DWORD)(LOWORD(vi.dwBuildNumber))); /* Windows 95 build number is in the low-order word only */ + else + snprintf(buildStr, sizeof(buildStr), "%lu", vi.dwBuildNumber); + + switch (vi.dwMajorVersion) { case 10: - strlcpy(s, "Windows 10", len); + if (server) + strlcpy(s, "Windows Server 2016", len); + else + strlcpy(s, "Windows 10", len); break; case 6: - switch (*minor) + switch (vi.dwMinorVersion) { case 3: - strlcpy(s, "Windows 8.1", len); + if (server) + strlcpy(s, "Windows Server 2012 R2", len); + else + strlcpy(s, "Windows 8.1", len); break; case 2: - strlcpy(s, "Windows 8", len); + if (server) + strlcpy(s, "Windows Server 2012", len); + else + strlcpy(s, "Windows 8", len); break; case 1: - strlcpy(s, "Windows 7/2008 R2", len); + if (server) + strlcpy(s, "Windows Server 2008 R2", len); + else + strlcpy(s, "Windows 7", len); break; case 0: - strlcpy(s, "Windows Vista/2008", len); + if (server) + strlcpy(s, "Windows Server 2008", len); + else + strlcpy(s, "Windows Vista", len); break; default: break; } break; case 5: - switch (*minor) + switch (vi.dwMinorVersion) { case 2: - strlcpy(s, "Windows 2003", len); + if (server) + if (serverR2) + strlcpy(s, "Windows Server 2003 R2", len); + else + strlcpy(s, "Windows Server 2003", len); + else + { + /* Yes, XP Pro x64 is a higher version number than XP x86 */ + if (string_is_equal(arch, "x64")) + strlcpy(s, "Windows XP", len); + } break; case 1: strlcpy(s, "Windows XP", len); @@ -174,10 +246,15 @@ static void frontend_win32_get_os(char *s, size_t len, int *major, int *minor) } break; case 4: - switch (*minor) + switch (vi.dwMinorVersion) { case 0: - strlcpy(s, "Windows NT 4.0", len); + if (vi.dwPlatformId == VER_PLATFORM_WIN32_WINDOWS) + strlcpy(s, "Windows 95", len); + else if (vi.dwPlatformId == VER_PLATFORM_WIN32_NT) + strlcpy(s, "Windows NT 4.0", len); + else + strlcpy(s, "Unknown", len); break; case 90: strlcpy(s, "Windows ME", len); @@ -188,9 +265,24 @@ static void frontend_win32_get_os(char *s, size_t len, int *major, int *minor) } break; default: - sprintf(s, "Windows %i.%i", *major, *minor); + snprintf(s, len, "Windows %i.%i", *major, *minor); break; } + + if (!string_is_empty(arch)) + { + strlcat(s, " ", len); + strlcat(s, arch, len); + } + + strlcat(s, " Build ", len); + strlcat(s, buildStr, len); + + if (!string_is_empty(vi.szCSDVersion)) + { + strlcat(s, " ", len); + strlcat(s, vi.szCSDVersion, len); + } } static void frontend_win32_init(void *data) diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 051f17d62a..a7da756206 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -805,7 +805,7 @@ static int menu_displaylist_parse_system_info(menu_displaylist_info_t *info) if (frontend->get_os) { frontend->get_os(tmp2, sizeof(tmp2), &major, &minor); - snprintf(tmp, sizeof(tmp), "%s : %s %d.%d", + snprintf(tmp, sizeof(tmp), "%s : %s (v%d.%d)", msg_hash_to_str(MENU_ENUM_LABEL_VALUE_SYSTEM_INFO_FRONTEND_OS), frontend->get_os ? tmp2 : msg_hash_to_str(MENU_ENUM_LABEL_VALUE_NOT_AVAILABLE), From d6daf2f573705b521e39870754814d5cc21a168e Mon Sep 17 00:00:00 2001 From: clienthax Date: Thu, 7 Dec 2017 19:49:11 +0000 Subject: [PATCH 262/394] [PS3] Possible fix for 0x0 resolution on --- gfx/drivers_context/ps3_ctx.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/gfx/drivers_context/ps3_ctx.c b/gfx/drivers_context/ps3_ctx.c index e7c48bfdcd..0c3775ec58 100644 --- a/gfx/drivers_context/ps3_ctx.c +++ b/gfx/drivers_context/ps3_ctx.c @@ -129,10 +129,11 @@ static void gfx_ctx_ps3_get_available_resolutions(void) * make the last resolution that was added to the list (the highest resolution) the default resolution */ - if (global->console.screen.resolutions.current.id > num_videomodes - || defaultresolution) - global->console.screen.resolutions.current.idx = - global->console.screen.resolutions.count - 1; + if (global->console.screen.resolutions.current.id > num_videomodes || defaultresolution) + { + global->console.screen.resolutions.current.idx = resolution_count - 1; + global->console.screen.resolutions.current.id = global->console.screen.resolutions.list[global->console.screen.resolutions.current.idx]; + } global->console.screen.resolutions.check = true; } From 130a0018469b5452d4f79d55e7ecfa6c4e258599 Mon Sep 17 00:00:00 2001 From: leiradel Date: Thu, 7 Dec 2017 19:49:39 +0000 Subject: [PATCH 263/394] Fixed wrong leaderboard count --- cheevos/cheevos.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/cheevos/cheevos.c b/cheevos/cheevos.c index 662c8b6dea..e70e425667 100644 --- a/cheevos/cheevos.c +++ b/cheevos/cheevos.c @@ -802,6 +802,7 @@ static int cheevos_count_cheevos(const char *json, int res; cheevos_countud_t ud; ud.in_cheevos = 0; + ud.in_lboards = 0; ud.core_count = 0; ud.unofficial_count = 0; ud.lboard_count = 0; @@ -2829,6 +2830,7 @@ static int cheevos_iterate(coro_t* coro) && cheevos_locals.lboard_count == 0) cheevos_unload(); + CORO_GOSUB(GET_BADGES); CORO_STOP(); /************************************************************************** From 55b738a07ab6b50796f6b1d11b8570fcb2d95279 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Thu, 7 Dec 2017 16:32:01 -0500 Subject: [PATCH 264/394] implement frontend get_architecture() for windows --- frontend/drivers/platform_win32.c | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/frontend/drivers/platform_win32.c b/frontend/drivers/platform_win32.c index b523c487a0..d3d466a40a 100644 --- a/frontend/drivers/platform_win32.c +++ b/frontend/drivers/platform_win32.c @@ -338,7 +338,28 @@ enum frontend_powerstate frontend_win32_get_powerstate(int *seconds, int *percen enum frontend_architecture frontend_win32_get_architecture(void) { - /* stub */ +#if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0500 + /* Windows 2000 and later */ + SYSTEM_INFO si = {0}; + + GetSystemInfo(&si); + + switch (si.wProcessorArchitecture) + { + case PROCESSOR_ARCHITECTURE_AMD64: + return FRONTEND_ARCH_X86_64; + break; + case PROCESSOR_ARCHITECTURE_INTEL: + return FRONTEND_ARCH_X86; + break; + case PROCESSOR_ARCHITECTURE_ARM: + return FRONTEND_ARCH_ARM; + break; + default: + break; + } +#endif + return FRONTEND_ARCH_NONE; } From a565ba0149cf91fe4aecb1b7cd93d9925627bef9 Mon Sep 17 00:00:00 2001 From: clienthax Date: Thu, 7 Dec 2017 22:20:02 +0000 Subject: [PATCH 265/394] [PS3] Partial fix of networking --- libretro-common/net/net_compat.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/libretro-common/net/net_compat.c b/libretro-common/net/net_compat.c index d9de1d8ceb..13fdbfff87 100644 --- a/libretro-common/net/net_compat.c +++ b/libretro-common/net/net_compat.c @@ -193,6 +193,12 @@ int getaddrinfo_retro(const char *node, const char *service, in_addr->sin_family = AF_INET; in_addr->sin_port = inet_htons(strtoul(service, NULL, 0)); + //sin_port seems to be the wrong endian for ps3 + #if defined(__CELLOS_LV2__) && !defined(__PSL1GHT__) + in_addr->sin_port = (in_addr->sin_port>>8) | (in_addr->sin_port<<8); + #endif + + if (!node && (hints->ai_flags & AI_PASSIVE)) in_addr->sin_addr.s_addr = INADDR_ANY; else if (node && isdigit(*node)) @@ -204,7 +210,8 @@ int getaddrinfo_retro(const char *node, const char *service, if (!host || !host->h_addr_list[0]) goto error; - in_addr->sin_addr.s_addr = inet_addr(host->h_addr_list[0]); + in_addr->sin_family = host->h_addrtype; + memcpy(&in_addr->sin_addr, host->h_addr, host->h_length); } else goto error; From b0445e1e210ef2c47ff1b58e1eebfc20a0e0c299 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Thu, 7 Dec 2017 17:47:16 -0500 Subject: [PATCH 266/394] Bliss-Box: Work around Windows sharing violation bug by trying to open device as read/write if read-only fails. Show OSD message if it still fails. --- tasks/task_autodetect.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/tasks/task_autodetect.c b/tasks/task_autodetect.c index be8e9ee4ed..f29dd82e7f 100644 --- a/tasks/task_autodetect.c +++ b/tasks/task_autodetect.c @@ -60,6 +60,7 @@ const GUID GUID_NULL = {0, 0, 0, {0, 0, 0, 0, 0, 0, 0, 0}}; #include "../file_path_special.h" #include "../list_special.h" #include "../verbosity.h" +#include "../retroarch.h" #include "tasks_internal.h" @@ -591,8 +592,27 @@ found: if (hDeviceHandle == INVALID_HANDLE_VALUE) { - RARCH_ERR("[Autoconf]: Can't open device: %d.", GetLastError()); - goto done; + /* Windows sometimes erroneously fails to open with a sharing violation: + * https://github.com/signal11/hidapi/issues/231 + * If this happens, trying again with read + write usually works for some reason. + */ + + /* Open the device */ + hDeviceHandle = CreateFileA( + devicePath, + GENERIC_READ | GENERIC_WRITE, + FILE_SHARE_READ | FILE_SHARE_WRITE, + NULL, + OPEN_EXISTING, + 0, /*FILE_FLAG_OVERLAPPED,*/ + NULL); + + if (hDeviceHandle == INVALID_HANDLE_VALUE) + { + RARCH_ERR("[Autoconf]: Can't open device for reading and writing: %d.", GetLastError()); + runloop_msg_queue_push("Bliss-Box already in use. Please make sure other programs are not using it.", 2, 300, false); + goto done; + } } done: From bf8f7b444bdd92240b67bb33a4a81a3dc82083ac Mon Sep 17 00:00:00 2001 From: leiradel Date: Thu, 7 Dec 2017 23:48:03 +0000 Subject: [PATCH 267/394] Fixed cheevos_expr_value to be C89 compliant --- cheevos/cheevos.c | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/cheevos/cheevos.c b/cheevos/cheevos.c index 87517d6164..c11984a229 100644 --- a/cheevos/cheevos.c +++ b/cheevos/cheevos.c @@ -1859,13 +1859,26 @@ static int cheevos_expr_value(cheevos_expr_t* expr) /* Separate possible values with '$' operator, submit the largest */ unsigned current_value = 0; /* TODO/FIXME - variable length forbidden in C89 - rewrite this! */ - int values[expr->compare_count]; + int values[16]; + + if (expr->compare_count >= sizeof(values) / sizeof(values[0])) + { + RARCH_ERR("[CHEEVOS]: too many values in the leaderboard expression: %u\n", expr->compare_count); + return 0; + } memset(values, 0, sizeof values); for (i = expr->count; i != 0; i--, term++) { + if (current_value >= sizeof(values) / sizeof(values[0])) + { + RARCH_ERR("[CHEEVOS]: too many values in the leaderboard expression: %u\n", current_value); + return 0; + } + values[current_value] += cheevos_var_get_value(&term->var) * term->multiplier; + if (term->compare_next) current_value++; } @@ -1880,7 +1893,8 @@ static int cheevos_expr_value(cheevos_expr_t* expr) return maximum; } - else return values[0]; + else + return values[0]; } static void cheevos_make_lboard_url(const cheevos_leaderboard_t *lboard, From 305cb6d6472c631301878ed1044bcfab4b65e0f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s?= Date: Thu, 7 Dec 2017 18:49:35 -0500 Subject: [PATCH 268/394] fix OS identification (#5880) --- frontend/drivers/platform_win32.c | 15 +++++++++------ menu/menu_displaylist.c | 2 +- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/frontend/drivers/platform_win32.c b/frontend/drivers/platform_win32.c index d3d466a40a..64703e4dcb 100644 --- a/frontend/drivers/platform_win32.c +++ b/frontend/drivers/platform_win32.c @@ -143,12 +143,14 @@ static void frontend_win32_get_os(char *s, size_t len, int *major, int *minor) OSVERSIONINFOEX vi = {0}; vi.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEX); - server = vi.wProductType != VER_NT_WORKSTATION; - - serverR2 = GetSystemMetrics(SM_SERVERR2); - GetSystemInfo(&si); + /* Available from NT 3.5 and Win95 */ + GetVersionEx((OSVERSIONINFO*)&vi); + + server = vi.wProductType != VER_NT_WORKSTATION; + serverR2 = GetSystemMetrics(SM_SERVERR2); + switch (si.wProcessorArchitecture) { case PROCESSOR_ARCHITECTURE_AMD64: @@ -166,10 +168,11 @@ static void frontend_win32_get_os(char *s, size_t len, int *major, int *minor) #else OSVERSIONINFO vi = {0}; vi.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); -#endif /* Available from NT 3.5 and Win95 */ - GetVersionEx((OSVERSIONINFO*)&vi); + GetVersionEx(&vi); +#endif + if (major) *major = vi.dwMajorVersion; diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index a7da756206..8a60cf2735 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -681,7 +681,7 @@ static int menu_displaylist_parse_system_info(menu_displaylist_info_t *info) strlcpy(cpu_arch_str, "x86", sizeof(cpu_arch_str)); break; case FRONTEND_ARCH_X86_64: - strlcpy(cpu_arch_str, "x86-64", sizeof(cpu_arch_str)); + strlcpy(cpu_arch_str, "x64", sizeof(cpu_arch_str)); break; case FRONTEND_ARCH_PPC: strlcpy(cpu_arch_str, "PPC", sizeof(cpu_arch_str)); From c53d3d35b8962962b47ce86f22ab7b095cef5b3c Mon Sep 17 00:00:00 2001 From: leiradel Date: Thu, 7 Dec 2017 23:51:15 +0000 Subject: [PATCH 269/394] Removed TODO comment --- cheevos/cheevos.c | 1 - 1 file changed, 1 deletion(-) diff --git a/cheevos/cheevos.c b/cheevos/cheevos.c index c11984a229..5a7687dc64 100644 --- a/cheevos/cheevos.c +++ b/cheevos/cheevos.c @@ -1858,7 +1858,6 @@ static int cheevos_expr_value(cheevos_expr_t* expr) unsigned i; /* Separate possible values with '$' operator, submit the largest */ unsigned current_value = 0; - /* TODO/FIXME - variable length forbidden in C89 - rewrite this! */ int values[16]; if (expr->compare_count >= sizeof(values) / sizeof(values[0])) From 8c1e3e5d5b5ae80932b96bfc502d8db9e46ff8aa Mon Sep 17 00:00:00 2001 From: leiradel Date: Fri, 8 Dec 2017 00:08:16 +0000 Subject: [PATCH 270/394] Fixed CXX_BUILD --- cheevos/cheevos.c | 6 +++--- cheevos/cheevos.h | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/cheevos/cheevos.c b/cheevos/cheevos.c index 5a7687dc64..0b9a1ea075 100644 --- a/cheevos/cheevos.c +++ b/cheevos/cheevos.c @@ -258,7 +258,7 @@ typedef struct typedef struct { - int console_id; + cheevos_console_t console_id; bool core_supports; bool addrs_patched; int add_buffer; @@ -276,7 +276,7 @@ typedef struct static cheevos_locals_t cheevos_locals = { - /* console_id */ 0, + /* console_id */ CHEEVOS_CONSOLE_NONE, /* core_supports */ true, /* addrs_patched */ false, /* add_buffer */ 0, @@ -1385,7 +1385,7 @@ static int cheevos_read__json_number(void *userdata, } else if (ud->is_console_id) { - cheevos_locals.console_id = (int)strtol(number, NULL, 10); + cheevos_locals.console_id = (cheevos_console_t)strtol(number, NULL, 10); ud->is_console_id = 0; } diff --git a/cheevos/cheevos.h b/cheevos/cheevos.h index cf2526e504..ed1baae311 100644 --- a/cheevos/cheevos.h +++ b/cheevos/cheevos.h @@ -47,6 +47,7 @@ typedef struct cheevos_ctx_desc typedef enum { + CHEEVOS_CONSOLE_NONE = 0, /* Don't change those, the values match the console IDs * at retroachievements.org. */ CHEEVOS_CONSOLE_MEGA_DRIVE = 1, From a15820f86a91189ed8563e390fde35270b605955 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andr=C3=A9s?= Date: Fri, 8 Dec 2017 10:25:00 -0500 Subject: [PATCH 271/394] Update index.html --- pkg/emscripten/libretro/index.html | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/emscripten/libretro/index.html b/pkg/emscripten/libretro/index.html index 37cfe0cc30..2f450e7e41 100644 --- a/pkg/emscripten/libretro/index.html +++ b/pkg/emscripten/libretro/index.html @@ -146,7 +146,7 @@ - +
From 8f7810d92167028ac966eb9929097b6bbef199f6 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Fri, 8 Dec 2017 18:15:22 -0500 Subject: [PATCH 272/394] emscripten: only fire keyup once, and don't wait so long to do so (libretro.js) --- pkg/emscripten/libretro/libretro.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/emscripten/libretro/libretro.js b/pkg/emscripten/libretro/libretro.js index 5b45e7353b..300c6ff1bd 100644 --- a/pkg/emscripten/libretro/libretro.js +++ b/pkg/emscripten/libretro/libretro.js @@ -389,7 +389,7 @@ $(function() { function keyPress(k) { kp(k, "keydown"); - setInterval(function(){kp(k, "keyup")}, 1000); + setTimeout(function(){kp(k, "keyup")}, 50); } kp = function(k, event) { From 004c1d2f0a18c513e32014a27ea39b82486651e8 Mon Sep 17 00:00:00 2001 From: David Walters Date: Fri, 8 Dec 2017 23:37:07 +0000 Subject: [PATCH 273/394] Fix for relative paths being normalised and generating a duplicate history entry. --- tasks/task_content.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/task_content.c b/tasks/task_content.c index 0c8f0b4129..926d2e1d62 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -996,7 +996,7 @@ static bool command_event_cmd_exec(const char *data, #if defined(HAVE_DYNAMIC) if (!task_load_content(&content_info, content_ctx, - false, launched_from_cli, error_string)) + true, launched_from_cli, error_string)) return false; #else frontend_driver_set_fork(FRONTEND_FORK_CORE_WITH_ARGS); From deb017e17f9cf0da499c6df692b332535b7064e7 Mon Sep 17 00:00:00 2001 From: David Walters Date: Fri, 8 Dec 2017 23:50:00 +0000 Subject: [PATCH 274/394] On Windows builds, don't use case sensitive path comparisons when pushing to a playlist. --- playlist.c | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/playlist.c b/playlist.c index 5ccc40cd2e..7406e75df0 100644 --- a/playlist.c +++ b/playlist.c @@ -309,9 +309,17 @@ bool playlist_push(playlist_t *playlist, for (i = 0; i < playlist->size; i++) { struct playlist_entry tmp; - bool equal_path = (!path && !playlist->entries[i].path) || + bool equal_path; + + equal_path = (!path && !playlist->entries[i].path) || (path && playlist->entries[i].path && - string_is_equal(path,playlist->entries[i].path)); +#ifdef _WIN32 + /*prevent duplicates on case-insensitive operating systems*/ + string_is_equal_noncase(path,playlist->entries[i].path) +#else + string_is_equal(path,playlist->entries[i].path) +#endif + ); /* Core name can have changed while still being the same core. * Differentiate based on the core path only. */ From ed1a920f465beee58040daabfb44ecd563dc8492 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Sat, 9 Dec 2017 01:05:55 +0100 Subject: [PATCH 275/394] Update config.def.h --- config.def.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.def.h b/config.def.h index c3fb49f6f6..34eefd9fa4 100644 --- a/config.def.h +++ b/config.def.h @@ -293,7 +293,7 @@ static bool xmb_show_add = true; #endif #endif -#if defined(HAVE_LIBRETRODB) && !defined(RARCH_CONSOLE) +#if defined(HAVE_LIBRETRODB) && !defined(RARCH_CONSOLE) && !defined(EMSCRIPTEN) static bool automatically_add_content_to_playlist = true; #else static bool automatically_add_content_to_playlist = false; From 0d58d9ca0d642933c271c0dcbe1528002288b467 Mon Sep 17 00:00:00 2001 From: Fabio Date: Sat, 9 Dec 2017 08:24:19 +0100 Subject: [PATCH 276/394] Added label to wii controllers, inverted the right stick Y axis of classic controller The right stick Y axis of classic controller was wrong --- input/input_autodetect_builtin.c | 99 ++++++++++++++++---------------- 1 file changed, 51 insertions(+), 48 deletions(-) diff --git a/input/input_autodetect_builtin.c b/input/input_autodetect_builtin.c index bd6fdaf768..e9fb439510 100644 --- a/input/input_autodetect_builtin.c +++ b/input/input_autodetect_builtin.c @@ -361,58 +361,61 @@ DECL_AXIS(r_y_plus, -3) \ DECL_AXIS(r_y_minus, +3) #define GXINPUT_WIIMOTE_DEFAULT_BINDS \ -DECL_BTN(a, 31) \ -DECL_BTN(b, 30) \ -DECL_BTN(x, 29) \ -DECL_BTN(y, 28) \ -DECL_BTN(start, 32) \ -DECL_BTN(select, 33) \ -DECL_BTN(up, 35) \ -DECL_BTN(down, 36) \ -DECL_BTN(left, 37) \ -DECL_BTN(right, 38) +DECL_BTN_EX(a, 31, "2") \ +DECL_BTN_EX(b, 30, "1") \ +DECL_BTN_EX(x, 29, "B") \ +DECL_BTN_EX(y, 28, "A") \ +DECL_BTN_EX(start, 32, "+") \ +DECL_BTN_EX(select, 33, "-") \ +DECL_BTN_EX(menu_toggle, 34, "Home") \ +DECL_BTN_EX(up, 35, "D-Pad Up") \ +DECL_BTN_EX(down, 36, "D-Pad Down") \ +DECL_BTN_EX(left, 37, "D-Pad Left") \ +DECL_BTN_EX(right, 38, "D-Pad right") #define GXINPUT_NUNCHUK_DEFAULT_BINDS \ -DECL_BTN(a, 28) \ -DECL_BTN(b, 29) \ -DECL_BTN(x, 30) \ -DECL_BTN(y, 31) \ -DECL_BTN(start, 32) \ -DECL_BTN(select, 33) \ -DECL_BTN(up, 35) \ -DECL_BTN(down, 36) \ -DECL_BTN(left, 37) \ -DECL_BTN(right, 38) \ -DECL_BTN(l, 39) \ -DECL_BTN(r, 40) \ -DECL_AXIS(l_x_plus, +0) \ -DECL_AXIS(l_x_minus, -0) \ -DECL_AXIS(l_y_plus, +1) \ -DECL_AXIS(l_y_minus, -1) +DECL_BTN_EX(a, 28, "A") \ +DECL_BTN_EX(b, 29, "B") \ +DECL_BTN_EX(x, 30, "1") \ +DECL_BTN_EX(y, 31, "2") \ +DECL_BTN_EX(start, 32, "+") \ +DECL_BTN_EX(select, 33, "-") \ +DECL_BTN_EX(menu_toggle, 34, "Home") \ +DECL_BTN_EX(up, 35, "D-Pad Up" ) \ +DECL_BTN_EX(down, 36, "D-Pad Down") \ +DECL_BTN_EX(left, 37, "D-Pad Left") \ +DECL_BTN_EX(right, 38, "D-Pad right") \ +DECL_BTN_EX(l, 39, "Z") \ +DECL_BTN_EX(r, 40, "C") \ +DECL_AXIS_EX(l_x_plus, +0, "Stick Right") \ +DECL_AXIS_EX(l_x_minus, -0, "Stick Left") \ +DECL_AXIS_EX(l_y_plus, +1, "Stick Down") \ +DECL_AXIS_EX(l_y_minus, -1, "Stick Up") #define GXINPUT_CLASSIC_DEFAULT_BINDS \ -DECL_BTN(a, 13) \ -DECL_BTN(b, 14) \ -DECL_BTN(x, 15) \ -DECL_BTN(y, 16) \ -DECL_BTN(start, 17) \ -DECL_BTN(select, 18) \ -DECL_BTN(up, 24) \ -DECL_BTN(down, 25) \ -DECL_BTN(left, 26) \ -DECL_BTN(right, 27) \ -DECL_BTN(l, 20) \ -DECL_BTN(r, 21) \ -DECL_BTN(l2, 22) \ -DECL_BTN(r2, 23) \ -DECL_AXIS(l_x_plus, +0) \ -DECL_AXIS(l_x_minus, -0) \ -DECL_AXIS(l_y_plus, +1) \ -DECL_AXIS(l_y_minus, -1) \ -DECL_AXIS(r_x_plus, +2) \ -DECL_AXIS(r_x_minus, -2) \ -DECL_AXIS(r_y_plus, -3) \ -DECL_AXIS(r_y_minus, +3) +DECL_BTN_EX(a, 13, "A") \ +DECL_BTN_EX(b, 14, "B") \ +DECL_BTN_EX(x, 15, "X") \ +DECL_BTN_EX(y, 16, "Y") \ +DECL_BTN_EX(start, 17, "+") \ +DECL_BTN_EX(select, 18, "-") \ +DECL_BTN_EX(menu_toggle, 19, "Home") \ +DECL_BTN_EX(up, 24, "D-Pad Up") \ +DECL_BTN_EX(down, 25, "D-Pad Down") \ +DECL_BTN_EX(left, 26, "D-Pad left") \ +DECL_BTN_EX(right, 27, "D-Pad right") \ +DECL_BTN_EX(l, 20, "L") \ +DECL_BTN_EX(r, 21, "R") \ +DECL_BTN_EX(l2, 22, "ZL") \ +DECL_BTN_EX(r2, 23, "ZR") \ +DECL_AXIS_EX(l_x_plus, +0, "L-Stick Right") \ +DECL_AXIS_EX(l_x_minus, -0, "L-Stick Left") \ +DECL_AXIS_EX(l_y_plus, +1, "L-Stick Down") \ +DECL_AXIS_EX(l_y_minus, -1, "L-Stick Up") \ +DECL_AXIS_EX(r_x_plus, +2, "R-Stick Right") \ +DECL_AXIS_EX(r_x_minus, -2, "R-Stick Left") \ +DECL_AXIS_EX(r_y_plus, +3, "R-Stick Down") \ +DECL_AXIS_EX(r_y_minus, -3, "R-Stick Up") #define PS3INPUT_DEFAULT_BINDS \ DECL_BTN(a, 8) \ From 54aec6c9e8db5882ed7d4edbfb473d27deabe01a Mon Sep 17 00:00:00 2001 From: cpsw <33490332+cpsw@users.noreply.github.com> Date: Sat, 9 Dec 2017 11:01:03 -0300 Subject: [PATCH 277/394] Small code style change Suggesting a code style change. --- ctr/ctr_system.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/ctr/ctr_system.c b/ctr/ctr_system.c index 5f118dfc7e..29594251e7 100644 --- a/ctr/ctr_system.c +++ b/ctr/ctr_system.c @@ -77,7 +77,10 @@ void __system_allocateHeaps(void) void __attribute__((weak)) __libctru_init(void (*retAddr)(void)) { /* Store the return address */ - __system_retAddr = envIsHomebrew() ? retAddr : NULL; + __system_retAddr = NULL; + if (envIsHomebrew()) { + __system_retAddr = retAddr; + } /* Initialize the synchronization subsystem */ __sync_init(); From 714684a4d33b22ba2e55147f298dd319c6f5befc Mon Sep 17 00:00:00 2001 From: Themaister Date: Fri, 8 Dec 2017 14:38:57 +0100 Subject: [PATCH 278/394] Don't wait for WSI fence unless it has been signalled. --- gfx/common/vulkan_common.c | 8 +++++--- gfx/common/vulkan_common.h | 1 + gfx/drivers/vulkan.c | 2 ++ 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/gfx/common/vulkan_common.c b/gfx/common/vulkan_common.c index 553655372f..314f0f415d 100644 --- a/gfx/common/vulkan_common.c +++ b/gfx/common/vulkan_common.c @@ -2275,16 +2275,18 @@ void vulkan_acquire_next_image(gfx_ctx_vulkan_data_t *vk) vkCreateSemaphore(vk->context.device, &sem_info, NULL, &vk->context.swapchain_semaphores[index]); - vkWaitForFences(vk->context.device, 1, &fence, true, UINT64_MAX); + if (err == VK_SUCCESS) + vkWaitForFences(vk->context.device, 1, &fence, true, UINT64_MAX); vkDestroyFence(vk->context.device, fence, NULL); next_fence = &vk->context.swapchain_fences[index]; if (*next_fence != VK_NULL_HANDLE) { - vkWaitForFences(vk->context.device, 1, next_fence, true, UINT64_MAX); - + if (vk->context.swapchain_fences_signalled[index]) + vkWaitForFences(vk->context.device, 1, next_fence, true, UINT64_MAX); vkResetFences(vk->context.device, 1, next_fence); + vk->context.swapchain_fences_signalled[index] = false; } else vkCreateFence(vk->context.device, &fence_info, NULL, next_fence); diff --git a/gfx/common/vulkan_common.h b/gfx/common/vulkan_common.h index 04785517fd..26ade3cd30 100644 --- a/gfx/common/vulkan_common.h +++ b/gfx/common/vulkan_common.h @@ -109,6 +109,7 @@ typedef struct vulkan_context VkImage swapchain_images[VULKAN_MAX_SWAPCHAIN_IMAGES]; VkFence swapchain_fences[VULKAN_MAX_SWAPCHAIN_IMAGES]; + bool swapchain_fences_signalled[VULKAN_MAX_SWAPCHAIN_IMAGES]; VkSemaphore swapchain_semaphores[VULKAN_MAX_SWAPCHAIN_IMAGES]; VkFormat swapchain_format; diff --git a/gfx/drivers/vulkan.c b/gfx/drivers/vulkan.c index 45be4a4e70..1e14aeb11b 100644 --- a/gfx/drivers/vulkan.c +++ b/gfx/drivers/vulkan.c @@ -1569,6 +1569,7 @@ static void vulkan_inject_black_frame(vk_t *vk, video_frame_info_t *video_info) #endif vkQueueSubmit(vk->context->queue, 1, &submit_info, vk->context->swapchain_fences[frame_index]); + vk->context->swapchain_fences_signalled[frame_index] = true; #ifdef HAVE_THREADS slock_unlock(vk->context->queue_lock); #endif @@ -1935,6 +1936,7 @@ static bool vulkan_frame(void *data, const void *frame, #endif vkQueueSubmit(vk->context->queue, 1, &submit_info, vk->context->swapchain_fences[frame_index]); + vk->context->swapchain_fences_signalled[frame_index] = true; #ifdef HAVE_THREADS slock_unlock(vk->context->queue_lock); #endif From ac42b874009dfdf7cdd203d764dad5956a1df4c8 Mon Sep 17 00:00:00 2001 From: Themaister Date: Fri, 8 Dec 2017 14:52:53 +0100 Subject: [PATCH 279/394] Recreate swapchain directly if vkAcquireNextImageKHR fails. --- gfx/common/vulkan_common.c | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) diff --git a/gfx/common/vulkan_common.c b/gfx/common/vulkan_common.c index 314f0f415d..970c228380 100644 --- a/gfx/common/vulkan_common.c +++ b/gfx/common/vulkan_common.c @@ -2263,7 +2263,9 @@ void vulkan_acquire_next_image(gfx_ctx_vulkan_data_t *vk) VkFenceCreateInfo fence_info = { VK_STRUCTURE_TYPE_FENCE_CREATE_INFO }; VkFence *next_fence = NULL; + bool is_retrying = false; +retry: vkCreateFence(vk->context.device, &fence_info, NULL, &fence); err = vkAcquireNextImageKHR(vk->context.device, @@ -2293,8 +2295,27 @@ void vulkan_acquire_next_image(gfx_ctx_vulkan_data_t *vk) if (err != VK_SUCCESS) { - RARCH_LOG("[Vulkan]: AcquireNextImage failed, invalidating swapchain.\n"); - vk->context.invalid_swapchain = true; + if (is_retrying) + { + RARCH_ERR("[Vulkan]: Tried acquring next swapchain image after creating new one, but failed ...\n"); + } + else + { + RARCH_LOG("[Vulkan]: AcquireNextImage failed, invalidating swapchain.\n"); + vk->context.invalid_swapchain = true; + + RARCH_LOG("[Vulkan]: AcquireNextImage failed, so trying to recreate swapchain.\n"); + if (!vulkan_create_swapchain(vk, vk->context.swapchain_width, + vk->context.swapchain_height, vk->context.swap_interval)) + { + RARCH_ERR("[Vulkan]: Failed to create new swapchain.\n"); + } + else + { + is_retrying = true; + goto retry; + } + } } } @@ -2517,6 +2538,7 @@ bool vulkan_create_swapchain(gfx_ctx_vulkan_data_t *vk, vkDestroyFence(vk->context.device, vk->context.swapchain_fences[i], NULL); vk->context.swapchain_fences[i] = VK_NULL_HANDLE; + vk->context.swapchain_fences_signalled[i] = false; } } From 75b84b4f94e64cc1999332d7fadbfbd400d72dd8 Mon Sep 17 00:00:00 2001 From: Themaister Date: Sat, 9 Dec 2017 12:58:11 +0100 Subject: [PATCH 280/394] Support pending swapchain creation. --- gfx/common/vulkan_common.c | 131 ++++++++++++++++++----- gfx/drivers/vulkan.c | 145 ++++++++++++++------------ gfx/drivers_context/android_ctx.c | 1 + gfx/drivers_context/khr_display_ctx.c | 2 + gfx/drivers_context/wayland_ctx.c | 3 + gfx/drivers_context/wgl_ctx.c | 1 + gfx/drivers_context/x_ctx.c | 1 + 7 files changed, 194 insertions(+), 90 deletions(-) diff --git a/gfx/common/vulkan_common.c b/gfx/common/vulkan_common.c index 970c228380..d7f9d2e239 100644 --- a/gfx/common/vulkan_common.c +++ b/gfx/common/vulkan_common.c @@ -28,6 +28,7 @@ #endif #include "vulkan_common.h" +#include "../../libretro-common/include/retro_timers.h" #include "../../configuration.h" static dylib_t vulkan_library; @@ -2162,6 +2163,7 @@ bool vulkan_surface_create(gfx_ctx_vulkan_data_t *vk, vk, width, height, swap_interval)) return false; + vulkan_acquire_next_image(vk); return true; } @@ -2171,6 +2173,13 @@ void vulkan_present(gfx_ctx_vulkan_data_t *vk, unsigned index) VkResult result = VK_SUCCESS; VkResult err = VK_SUCCESS; + /* We're still waiting for a proper swapchain, so just fake it. */ + if (vk->swapchain == VK_NULL_HANDLE) + { + retro_sleep(10); + return; + } + present.swapchainCount = 1; present.pSwapchains = &vk->swapchain; present.pImageIndices = &index; @@ -2253,18 +2262,71 @@ void vulkan_context_destroy(gfx_ctx_vulkan_data_t *vk, } } +static void vulkan_acquire_clear_fences(gfx_ctx_vulkan_data_t *vk) +{ + unsigned i; + for (i = 0; i < vk->context.num_swapchain_images; i++) + { + if (vk->context.swapchain_fences[i]) + { + vkDestroyFence(vk->context.device, + vk->context.swapchain_fences[i], NULL); + vk->context.swapchain_fences[i] = VK_NULL_HANDLE; + vk->context.swapchain_fences_signalled[i] = false; + } + } +} + +static void vulkan_acquire_wait_fences(gfx_ctx_vulkan_data_t *vk) +{ + VkFenceCreateInfo fence_info = + { VK_STRUCTURE_TYPE_FENCE_CREATE_INFO }; + + unsigned index = vk->context.current_swapchain_index; + VkFence *next_fence = &vk->context.swapchain_fences[index]; + + if (*next_fence != VK_NULL_HANDLE) + { + if (vk->context.swapchain_fences_signalled[index]) + vkWaitForFences(vk->context.device, 1, next_fence, true, UINT64_MAX); + vkResetFences(vk->context.device, 1, next_fence); + vk->context.swapchain_fences_signalled[index] = false; + } + else + vkCreateFence(vk->context.device, &fence_info, NULL, next_fence); +} + void vulkan_acquire_next_image(gfx_ctx_vulkan_data_t *vk) { unsigned index; VkResult err; VkFence fence; - VkSemaphoreCreateInfo sem_info = - { VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO }; VkFenceCreateInfo fence_info = { VK_STRUCTURE_TYPE_FENCE_CREATE_INFO }; - VkFence *next_fence = NULL; + VkSemaphoreCreateInfo sem_info = + { VK_STRUCTURE_TYPE_SEMAPHORE_CREATE_INFO }; bool is_retrying = false; + if (vk->swapchain == VK_NULL_HANDLE) + { + /* We don't have a swapchain, try to create one now. */ + if (!vulkan_create_swapchain(vk, vk->context.swapchain_width, + vk->context.swapchain_height, vk->context.swap_interval)) + { + RARCH_ERR("[Vulkan]: Failed to create new swapchain.\n"); + return; + } + + if (vk->swapchain == VK_NULL_HANDLE) + { + /* We still don't have a swapchain, so just fake it ... */ + vk->context.current_swapchain_index = 0; + vulkan_acquire_clear_fences(vk); + vulkan_acquire_wait_fences(vk); + return; + } + } + retry: vkCreateFence(vk->context.device, &fence_info, NULL, &fence); @@ -2281,17 +2343,7 @@ retry: vkWaitForFences(vk->context.device, 1, &fence, true, UINT64_MAX); vkDestroyFence(vk->context.device, fence, NULL); - next_fence = &vk->context.swapchain_fences[index]; - - if (*next_fence != VK_NULL_HANDLE) - { - if (vk->context.swapchain_fences_signalled[index]) - vkWaitForFences(vk->context.device, 1, next_fence, true, UINT64_MAX); - vkResetFences(vk->context.device, 1, next_fence); - vk->context.swapchain_fences_signalled[index] = false; - } - else - vkCreateFence(vk->context.device, &fence_info, NULL, next_fence); + vulkan_acquire_wait_fences(vk); if (err != VK_SUCCESS) { @@ -2430,6 +2482,43 @@ bool vulkan_create_swapchain(gfx_ctx_vulkan_data_t *vk, else swapchain_size = surface_properties.currentExtent; +#if 0 + /* Tests for deferred creation. */ + static unsigned retry_count = 0; + if (++retry_count < 50) + { + surface_properties.maxImageExtent.width = 0; + surface_properties.maxImageExtent.height = 0; + surface_properties.minImageExtent.width = 0; + surface_properties.minImageExtent.height = 0; + } +#endif + + /* Clamp swapchain size to boundaries. */ + if (swapchain_size.width > surface_properties.maxImageExtent.width) + swapchain_size.width = surface_properties.maxImageExtent.width; + if (swapchain_size.width < surface_properties.minImageExtent.width) + swapchain_size.width = surface_properties.minImageExtent.width; + if (swapchain_size.height > surface_properties.maxImageExtent.height) + swapchain_size.height = surface_properties.maxImageExtent.height; + if (swapchain_size.height < surface_properties.minImageExtent.height) + swapchain_size.height = surface_properties.minImageExtent.height; + + if (swapchain_size.width == 0 && swapchain_size.height == 0) + { + /* Cannot create swapchain yet, try again later. */ + if (vk->swapchain != VK_NULL_HANDLE) + vkDestroySwapchainKHR(vk->context.device, vk->swapchain, NULL); + vk->swapchain = VK_NULL_HANDLE; + vk->context.swapchain_width = width; + vk->context.swapchain_height = height; + vk->context.num_swapchain_images = 1; + + memset(vk->context.swapchain_images, 0, sizeof(vk->context.swapchain_images)); + RARCH_LOG("[Vulkan]: Cannot create a swapchain yet. Will try again later ...\n"); + return true; + } + RARCH_LOG("[Vulkan]: Using swapchain size %u x %u.\n", swapchain_size.width, swapchain_size.height); @@ -2531,18 +2620,8 @@ bool vulkan_create_swapchain(gfx_ctx_vulkan_data_t *vk, RARCH_LOG("[Vulkan]: Got %u swapchain images.\n", vk->context.num_swapchain_images); - for (i = 0; i < vk->context.num_swapchain_images; i++) - { - if (vk->context.swapchain_fences[i]) - { - vkDestroyFence(vk->context.device, - vk->context.swapchain_fences[i], NULL); - vk->context.swapchain_fences[i] = VK_NULL_HANDLE; - vk->context.swapchain_fences_signalled[i] = false; - } - } - - vulkan_acquire_next_image(vk); + vulkan_acquire_clear_fences(vk); + vk->context.invalid_swapchain = true; return true; } diff --git a/gfx/drivers/vulkan.c b/gfx/drivers/vulkan.c index 1e14aeb11b..dafcb40fb7 100644 --- a/gfx/drivers/vulkan.c +++ b/gfx/drivers/vulkan.c @@ -128,7 +128,14 @@ static void vulkan_init_framebuffers( VkFramebufferCreateInfo info = { VK_STRUCTURE_TYPE_FRAMEBUFFER_CREATE_INFO }; - vk->swapchain[i].backbuffer.image = vk->context->swapchain_images[i]; + vk->swapchain[i].backbuffer.image = vk->context->swapchain_images[i]; + + if (vk->context->swapchain_images[i] == VK_NULL_HANDLE) + { + vk->swapchain[i].backbuffer.view = VK_NULL_HANDLE; + vk->swapchain[i].backbuffer.framebuffer = VK_NULL_HANDLE; + continue; + } /* Create an image view which we can render into. */ view.viewType = VK_IMAGE_VIEW_TYPE_2D; @@ -716,10 +723,17 @@ static void vulkan_deinit_framebuffers(vk_t *vk) unsigned i; for (i = 0; i < vk->num_swapchain_images; i++) { - vkDestroyFramebuffer(vk->context->device, - vk->swapchain[i].backbuffer.framebuffer, NULL); - vkDestroyImageView(vk->context->device, - vk->swapchain[i].backbuffer.view, NULL); + if (vk->swapchain[i].backbuffer.framebuffer) + { + vkDestroyFramebuffer(vk->context->device, + vk->swapchain[i].backbuffer.framebuffer, NULL); + } + + if (vk->swapchain[i].backbuffer.view) + { + vkDestroyImageView(vk->context->device, + vk->swapchain[i].backbuffer.view, NULL); + } } vkDestroyRenderPass(vk->context->device, vk->render_pass, NULL); @@ -1748,88 +1762,92 @@ static bool vulkan_frame(void *data, const void *frame, (vulkan_filter_chain_t*)vk->filter_chain, vk->cmd, &vk->vk_vp); /* Render to backbuffer. */ - rp_info.renderPass = vk->render_pass; - rp_info.framebuffer = chain->backbuffer.framebuffer; - rp_info.renderArea.extent.width = vk->context->swapchain_width; - rp_info.renderArea.extent.height = vk->context->swapchain_height; - rp_info.clearValueCount = 1; - rp_info.pClearValues = &clear_color; + if (chain->backbuffer.image != VK_NULL_HANDLE) + { + rp_info.renderPass = vk->render_pass; + rp_info.framebuffer = chain->backbuffer.framebuffer; + rp_info.renderArea.extent.width = vk->context->swapchain_width; + rp_info.renderArea.extent.height = vk->context->swapchain_height; + rp_info.clearValueCount = 1; + rp_info.pClearValues = &clear_color; - clear_color.color.float32[0] = 0.0f; - clear_color.color.float32[1] = 0.0f; - clear_color.color.float32[2] = 0.0f; - clear_color.color.float32[3] = 0.0f; + clear_color.color.float32[0] = 0.0f; + clear_color.color.float32[1] = 0.0f; + clear_color.color.float32[2] = 0.0f; + clear_color.color.float32[3] = 0.0f; - /* Prepare backbuffer for rendering. We don't use WSI semaphores here. */ - vulkan_image_layout_transition(vk, vk->cmd, chain->backbuffer.image, - VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, - 0, VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_COLOR_ATTACHMENT_READ_BIT, - VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, - VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT); + /* Prepare backbuffer for rendering. We don't use WSI semaphores here. */ + vulkan_image_layout_transition(vk, vk->cmd, chain->backbuffer.image, + VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL, + 0, VK_ACCESS_COLOR_ATTACHMENT_WRITE_BIT | VK_ACCESS_COLOR_ATTACHMENT_READ_BIT, + VK_PIPELINE_STAGE_TOP_OF_PIPE_BIT, + VK_PIPELINE_STAGE_COLOR_ATTACHMENT_OUTPUT_BIT); - /* Begin render pass and set up viewport */ - vkCmdBeginRenderPass(vk->cmd, &rp_info, VK_SUBPASS_CONTENTS_INLINE); + /* Begin render pass and set up viewport */ + vkCmdBeginRenderPass(vk->cmd, &rp_info, VK_SUBPASS_CONTENTS_INLINE); - vulkan_filter_chain_build_viewport_pass( - (vulkan_filter_chain_t*)vk->filter_chain, vk->cmd, - &vk->vk_vp, vk->mvp.data); + vulkan_filter_chain_build_viewport_pass( + (vulkan_filter_chain_t*)vk->filter_chain, vk->cmd, + &vk->vk_vp, vk->mvp.data); #if defined(HAVE_MENU) - if (vk->menu.enable) - { - menu_driver_frame(video_info); - - if (vk->menu.textures[vk->menu.last_index].image != VK_NULL_HANDLE) + if (vk->menu.enable) { - struct vk_draw_quad quad; - struct vk_texture *optimal = &vk->menu.textures_optimal[vk->menu.last_index]; - vulkan_set_viewport(vk, width, height, vk->menu.full_screen, false); + menu_driver_frame(video_info); - quad.pipeline = vk->pipelines.alpha_blend; - quad.texture = &vk->menu.textures[vk->menu.last_index]; - - if (optimal->memory != VK_NULL_HANDLE) + if (vk->menu.textures[vk->menu.last_index].image != VK_NULL_HANDLE) { - if (vk->menu.dirty[vk->menu.last_index]) + struct vk_draw_quad quad; + struct vk_texture *optimal = &vk->menu.textures_optimal[vk->menu.last_index]; + vulkan_set_viewport(vk, width, height, vk->menu.full_screen, false); + + quad.pipeline = vk->pipelines.alpha_blend; + quad.texture = &vk->menu.textures[vk->menu.last_index]; + + if (optimal->memory != VK_NULL_HANDLE) { - vulkan_copy_staging_to_dynamic(vk, vk->cmd, - optimal, - quad.texture); - vk->menu.dirty[vk->menu.last_index] = false; + if (vk->menu.dirty[vk->menu.last_index]) + { + vulkan_copy_staging_to_dynamic(vk, vk->cmd, + optimal, + quad.texture); + vk->menu.dirty[vk->menu.last_index] = false; + } + quad.texture = optimal; } - quad.texture = optimal; + + quad.sampler = optimal->mipmap ? + vk->samplers.mipmap_linear : vk->samplers.linear; + + quad.mvp = &vk->mvp_no_rot; + quad.color.r = 1.0f; + quad.color.g = 1.0f; + quad.color.b = 1.0f; + quad.color.a = vk->menu.alpha; + vulkan_draw_quad(vk, &quad); } - - quad.sampler = optimal->mipmap ? - vk->samplers.mipmap_linear : vk->samplers.linear; - - quad.mvp = &vk->mvp_no_rot; - quad.color.r = 1.0f; - quad.color.g = 1.0f; - quad.color.b = 1.0f; - quad.color.a = vk->menu.alpha; - vulkan_draw_quad(vk, &quad); } - } #endif - if (msg) - font_driver_render_msg(video_info, NULL, msg, NULL); + if (msg) + font_driver_render_msg(video_info, NULL, msg, NULL); #ifdef HAVE_OVERLAY - if (vk->overlay.enable) - vulkan_render_overlay(vk, video_info); + if (vk->overlay.enable) + vulkan_render_overlay(vk, video_info); #endif - /* End the render pass. We're done rendering to backbuffer now. */ - vkCmdEndRenderPass(vk->cmd); + /* End the render pass. We're done rendering to backbuffer now. */ + vkCmdEndRenderPass(vk->cmd); + } /* End the filter chain frame. * This must happen outside a render pass. */ vulkan_filter_chain_end_frame((vulkan_filter_chain_t*)vk->filter_chain, vk->cmd); - if (vk->readback.pending || vk->readback.streamed) + if (chain->backbuffer.image != VK_NULL_HANDLE && + (vk->readback.pending || vk->readback.streamed)) { /* We cannot safely read back from an image which * has already been presented as we need to @@ -1860,7 +1878,7 @@ static bool vulkan_frame(void *data, const void *frame, vk->readback.pending = false; } - else + else if (chain->backbuffer.image != VK_NULL_HANDLE) { /* Prepare backbuffer for presentation. */ vulkan_image_layout_transition(vk, vk->cmd, @@ -1930,7 +1948,6 @@ static bool vulkan_frame(void *data, const void *frame, } submit_info.pSignalSemaphores = submit_info.signalSemaphoreCount ? signal_semaphores : NULL; - #ifdef HAVE_THREADS slock_lock(vk->context->queue_lock); #endif diff --git a/gfx/drivers_context/android_ctx.c b/gfx/drivers_context/android_ctx.c index d2212f94c9..341aa465c6 100644 --- a/gfx/drivers_context/android_ctx.c +++ b/gfx/drivers_context/android_ctx.c @@ -281,6 +281,7 @@ static bool android_gfx_ctx_set_resize(void *data, return false; } + vulkan_acquire_next_image(&and->vk); and->vk.context.invalid_swapchain = true; and->vk.need_new_swapchain = false; #endif diff --git a/gfx/drivers_context/khr_display_ctx.c b/gfx/drivers_context/khr_display_ctx.c index 745d770055..53e3bfb528 100644 --- a/gfx/drivers_context/khr_display_ctx.c +++ b/gfx/drivers_context/khr_display_ctx.c @@ -103,6 +103,8 @@ static bool gfx_ctx_khr_display_set_resize(void *data, return false; } + vulkan_acquire_next_image(&khr->vk); + khr->vk.context.invalid_swapchain = true; khr->vk.need_new_swapchain = false; return false; diff --git a/gfx/drivers_context/wayland_ctx.c b/gfx/drivers_context/wayland_ctx.c index 6c7b8be4be..cde0887fb0 100644 --- a/gfx/drivers_context/wayland_ctx.c +++ b/gfx/drivers_context/wayland_ctx.c @@ -684,7 +684,10 @@ static bool gfx_ctx_wl_set_resize(void *data, unsigned width, unsigned height) wl->height = height; if (vulkan_create_swapchain(&wl->vk, width, height, wl->swap_interval)) + { wl->vk.context.invalid_swapchain = true; + vulkan_acquire_next_image(&wl->vk); + } else { RARCH_ERR("[Wayland/Vulkan]: Failed to update swapchain.\n"); diff --git a/gfx/drivers_context/wgl_ctx.c b/gfx/drivers_context/wgl_ctx.c index 39dbb26cdb..9b5e441503 100644 --- a/gfx/drivers_context/wgl_ctx.c +++ b/gfx/drivers_context/wgl_ctx.c @@ -395,6 +395,7 @@ static bool gfx_ctx_wgl_set_resize(void *data, return false; } + vulkan_acquire_next_image(&win32_vk); win32_vk.context.invalid_swapchain = true; win32_vk.need_new_swapchain = false; #endif diff --git a/gfx/drivers_context/x_ctx.c b/gfx/drivers_context/x_ctx.c index 08e6b7bcef..1faa28b95f 100644 --- a/gfx/drivers_context/x_ctx.c +++ b/gfx/drivers_context/x_ctx.c @@ -448,6 +448,7 @@ static bool gfx_ctx_x_set_resize(void *data, return false; } + vulkan_acquire_next_image(&x->vk); x->vk.context.invalid_swapchain = true; x->vk.need_new_swapchain = false; } From f8447c46483ff4c97c0264ae6d89d892b862cf22 Mon Sep 17 00:00:00 2001 From: Themaister Date: Sat, 9 Dec 2017 15:59:21 +0100 Subject: [PATCH 281/394] Set correct buffer size. --- gfx/common/vulkan_common.c | 2 +- gfx/common/vulkan_common.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gfx/common/vulkan_common.c b/gfx/common/vulkan_common.c index d7f9d2e239..cab3af0bd3 100644 --- a/gfx/common/vulkan_common.c +++ b/gfx/common/vulkan_common.c @@ -987,7 +987,7 @@ struct vk_buffer vulkan_create_buffer( vkAllocateMemory(context->device, &alloc, NULL, &buffer.memory); vkBindBufferMemory(context->device, buffer.buffer, buffer.memory, 0); - buffer.size = alloc.allocationSize; + buffer.size = size; vkMapMemory(context->device, buffer.memory, 0, buffer.size, 0, &buffer.mapped); diff --git a/gfx/common/vulkan_common.h b/gfx/common/vulkan_common.h index 26ade3cd30..732e7173e1 100644 --- a/gfx/common/vulkan_common.h +++ b/gfx/common/vulkan_common.h @@ -22,7 +22,7 @@ #define VULKAN_DESCRIPTOR_MANAGER_BLOCK_SETS 16 #define VULKAN_MAX_DESCRIPTOR_POOL_SIZES 16 -#define VULKAN_BUFFER_BLOCK_SIZE (4 * 1024) +#define VULKAN_BUFFER_BLOCK_SIZE (64 * 1024) #define VULKAN_MAX_SWAPCHAIN_IMAGES 8 From 3318cd969ba826c6b1dadb2d67bc39d2b3423bca Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Sat, 9 Dec 2017 14:26:21 -0500 Subject: [PATCH 282/394] win95: fallback to strdup when MultiByteToWideChar fails (it only works with MSLU) --- libretro-common/encodings/encoding_utf.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/libretro-common/encodings/encoding_utf.c b/libretro-common/encodings/encoding_utf.c index 2148fcb470..11cf363de1 100644 --- a/libretro-common/encodings/encoding_utf.c +++ b/libretro-common/encodings/encoding_utf.c @@ -297,6 +297,10 @@ static char* mb_to_mb_string_alloc(const char *str, return strdup(str); #else + /* Windows 95 will return 0 from these functions with a UTF8 codepage set without MSLU. From an unknown MSDN version (others omit this info): + * - CP_UTF8 Windows 98/Me, Windows NT 4.0 and later: Translate using UTF-8. When this is set, dwFlags must be zero. + * - Windows 95: Under the Microsoft Layer for Unicode, MultiByteToWideChar also supports CP_UTF7 and CP_UTF8. + */ path_buf_wide_len = MultiByteToWideChar(cp_in, 0, str, -1, NULL, 0); if (path_buf_wide_len) @@ -334,9 +338,16 @@ static char* mb_to_mb_string_alloc(const char *str, return NULL; } } + else + { + free(path_buf_wide); + return strdup(str); + } } } } + else + return strdup(str); if (path_buf_wide) free(path_buf_wide); @@ -385,6 +396,8 @@ wchar_t* utf8_to_utf16_string_alloc(const char *str) out_len = MultiByteToWideChar(CP_UTF8, 0, str, -1, buf, len); } + else + return strdup(str); if (out_len < 0) { @@ -442,6 +455,8 @@ char* utf16_to_utf8_string_alloc(const wchar_t *str) out_len = WideCharToMultiByte(CP_UTF8, 0, str, -1, buf, len, NULL, NULL); } + else + return strdup(str); if (out_len < 0) { From 812a99e5ca580c4fac1b80e6d9a14fc8054c98f2 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Sat, 9 Dec 2017 14:35:58 -0500 Subject: [PATCH 283/394] utf: fallback to ANSI codepage on windows if UTF8 conversion isn't available --- libretro-common/encodings/encoding_utf.c | 30 ++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/libretro-common/encodings/encoding_utf.c b/libretro-common/encodings/encoding_utf.c index 11cf363de1..6a89da543f 100644 --- a/libretro-common/encodings/encoding_utf.c +++ b/libretro-common/encodings/encoding_utf.c @@ -397,7 +397,20 @@ wchar_t* utf8_to_utf16_string_alloc(const char *str) out_len = MultiByteToWideChar(CP_UTF8, 0, str, -1, buf, len); } else - return strdup(str); + { + /* fallback to ANSI codepage instead */ + len = MultiByteToWideChar(CP_ACP, 0, str, -1, NULL, 0); + + if (len) + { + buf = (wchar_t*)calloc(len, sizeof(wchar_t)); + + if (!buf) + return NULL; + + out_len = MultiByteToWideChar(CP_ACP, 0, str, -1, buf, len); + } + } if (out_len < 0) { @@ -456,7 +469,20 @@ char* utf16_to_utf8_string_alloc(const wchar_t *str) out_len = WideCharToMultiByte(CP_UTF8, 0, str, -1, buf, len, NULL, NULL); } else - return strdup(str); + { + /* fallback to ANSI codepage instead */ + len = WideCharToMultiByte(CP_ACP, 0, str, -1, NULL, 0, NULL, NULL); + + if (len) + { + buf = (char*)calloc(len, sizeof(char)); + + if (!buf) + return NULL; + + out_len = WideCharToMultiByte(CP_ACP, 0, str, -1, buf, len, NULL, NULL); + } + } if (out_len < 0) { From cfde6a44db7304e6eac4f9cabc65b8e4590d3d21 Mon Sep 17 00:00:00 2001 From: Monroe88 Date: Sat, 9 Dec 2017 14:17:54 -0600 Subject: [PATCH 284/394] input_driver: Map Delete key to Y button for non-unified menu keyboard controls --- input/input_driver.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/input/input_driver.c b/input/input_driver.c index 0866d5e890..bbd4ed099b 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -968,7 +968,7 @@ void input_menu_keys_pressed(void *data, retro_bits_t* p_new_state) if (!menu_input_dialog_get_display_kb()) { - unsigned ids[13][2]; + unsigned ids[14][2]; const struct retro_keybind *quitkey = &input_config_binds[0][RARCH_QUIT_KEY]; const struct retro_keybind *fskey = &input_config_binds[0][RARCH_FULLSCREEN_TOGGLE_KEY]; @@ -998,6 +998,8 @@ void input_menu_keys_pressed(void *data, retro_bits_t* p_new_state) ids[11][1] = RETRO_DEVICE_ID_JOYPAD_B; ids[12][0] = RETROK_RETURN; ids[12][1] = RETRO_DEVICE_ID_JOYPAD_A; + ids[13][0] = RETROK_DELETE; + ids[13][1] = RETRO_DEVICE_ID_JOYPAD_Y; if (settings->bools.input_menu_swap_ok_cancel_buttons) { @@ -1005,7 +1007,7 @@ void input_menu_keys_pressed(void *data, retro_bits_t* p_new_state) ids[12][1] = RETRO_DEVICE_ID_JOYPAD_B; } - for (i = 0; i < 13; i++) + for (i = 0; i < 14; i++) { if (current_input->input_state(current_input_data, joypad_info, binds, 0, From 1a928b9c5045dc518ad742305999f3ea0f0a4809 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Sat, 9 Dec 2017 16:38:33 -0500 Subject: [PATCH 285/394] omit extra slash at end of path, Win95/98 doesn't like them --- libretro-common/file/retro_dirent.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/libretro-common/file/retro_dirent.c b/libretro-common/file/retro_dirent.c index aa221c888c..0b716e6e56 100644 --- a/libretro-common/file/retro_dirent.c +++ b/libretro-common/file/retro_dirent.c @@ -103,6 +103,7 @@ struct RDIR *retro_opendir(const char *name) char path_buf[1024]; char *path_local = NULL; wchar_t *path_wide = NULL; + unsigned path_len; #endif struct RDIR *rdir = (struct RDIR*)calloc(1, sizeof(*rdir)); @@ -114,7 +115,13 @@ struct RDIR *retro_opendir(const char *name) (void)path_local; path_buf[0] = '\0'; - snprintf(path_buf, sizeof(path_buf), "%s\\*", name); + path_len = strlen(name); + + /* Non-NT platforms don't like extra slashes in the path */ + if (name[path_len - 1] == '\\') + snprintf(path_buf, sizeof(path_buf), "%s*", name); + else + snprintf(path_buf, sizeof(path_buf), "%s\\*", name); #if defined(LEGACY_WIN32) path_local = utf8_to_local_string_alloc(path_buf); rdir->directory = FindFirstFile(path_local, &rdir->entry); From d6fd9f0cc1ced58bcb75258bbf898c1ed09bd577 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 10 Dec 2017 01:19:58 +0100 Subject: [PATCH 286/394] Add fallback AF_INET6 path --- libretro-common/net/net_compat.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libretro-common/net/net_compat.c b/libretro-common/net/net_compat.c index 13fdbfff87..8ef567eb88 100644 --- a/libretro-common/net/net_compat.c +++ b/libretro-common/net/net_compat.c @@ -211,7 +211,13 @@ int getaddrinfo_retro(const char *node, const char *service, goto error; in_addr->sin_family = host->h_addrtype; + +#ifdef AF_INET6 + /* TODO/FIXME - In case we ever want to support IPv6 */ + in_addr->sin_addr.s_addr = inet_addr(host->h_addr_list[0]); +#else memcpy(&in_addr->sin_addr, host->h_addr, host->h_length); +#endif } else goto error; From e07ed18105420db831d6c8965f30c515934d784c Mon Sep 17 00:00:00 2001 From: Alcaro Date: Sun, 10 Dec 2017 21:00:24 +0100 Subject: [PATCH 287/394] Fix text mode dependency --- libretro-common/file/config_file.c | 4 +++- playlist.c | 8 ++++---- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/libretro-common/file/config_file.c b/libretro-common/file/config_file.c index cf105bbc3a..d345338bfe 100644 --- a/libretro-common/file/config_file.c +++ b/libretro-common/file/config_file.c @@ -107,7 +107,9 @@ static char *getaline(RFILE *file) newline = newline_tmp; } - newline[idx++] = in; + /* ignore MS line endings */ + if (in != '\r') + newline[idx++] = in; in = filestream_getc(file); } newline[idx] = '\0'; diff --git a/playlist.c b/playlist.c index 7406e75df0..1911fb799e 100644 --- a/playlist.c +++ b/playlist.c @@ -519,10 +519,10 @@ static bool playlist_read_file( /* Read playlist entry and terminate string with NUL character * regardless of Windows or Unix line endings */ - if((last = strrchr(buf[i], '\r'))) - *last = '\0'; - else if((last = strrchr(buf[i], '\n'))) - *last = '\0'; + if((last = strrchr(buf[i], '\r'))) + *last = '\0'; + else if((last = strrchr(buf[i], '\n'))) + *last = '\0'; } entry = &playlist->entries[playlist->size]; From 95cc8e12d266914d25d63fde376930eb8eaf8119 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 10 Dec 2017 21:28:13 +0100 Subject: [PATCH 288/394] Get rid of RFILE_MODE_READ_TEXT dependency for config file/playlist --- libretro-common/file/config_file.c | 2 +- playlist.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libretro-common/file/config_file.c b/libretro-common/file/config_file.c index d345338bfe..e613f02a34 100644 --- a/libretro-common/file/config_file.c +++ b/libretro-common/file/config_file.c @@ -392,7 +392,7 @@ static config_file_t *config_file_new_internal( goto error; conf->include_depth = depth; - file = filestream_open(path, RFILE_MODE_READ_TEXT, 0x4000); + file = filestream_open(path, RFILE_MODE_READ, 0x4000); if (!file) { diff --git a/playlist.c b/playlist.c index 1911fb799e..13154d6bbe 100644 --- a/playlist.c +++ b/playlist.c @@ -493,7 +493,7 @@ static bool playlist_read_file( unsigned i; char buf[PLAYLIST_ENTRIES][1024]; RFILE *file = filestream_open( - path, RFILE_MODE_READ_TEXT, -1); + path, RFILE_MODE_READ, -1); for (i = 0; i < PLAYLIST_ENTRIES; i++) buf[i][0] = '\0'; From 9d54da14b68c93b6b4c6ddcda2afcb78d6c8e8db Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 10 Dec 2017 21:29:49 +0100 Subject: [PATCH 289/394] Get rid of READ_TEXT requirement for features_cpu --- libretro-common/features/features_cpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libretro-common/features/features_cpu.c b/libretro-common/features/features_cpu.c index 94bf644b1f..aa43eaa2d2 100644 --- a/libretro-common/features/features_cpu.c +++ b/libretro-common/features/features_cpu.c @@ -320,7 +320,7 @@ static unsigned char check_arm_cpu_feature(const char* feature) { char line[1024]; unsigned char status = 0; - RFILE *fp = filestream_open("/proc/cpuinfo", RFILE_MODE_READ_TEXT, -1); + RFILE *fp = filestream_open("/proc/cpuinfo", RFILE_MODE_READ, -1); if (!fp) return 0; From 40f82c26f7e7ca6cf9ea80fe1323c0a95861d2b2 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 10 Dec 2017 22:01:48 +0100 Subject: [PATCH 290/394] use RFILE_MODE_READ for video_shader_parse --- gfx/video_shader_parse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfx/video_shader_parse.c b/gfx/video_shader_parse.c index 26aee9aedd..5b88be1608 100644 --- a/gfx/video_shader_parse.c +++ b/gfx/video_shader_parse.c @@ -545,7 +545,7 @@ bool video_shader_resolve_parameters(config_file_t *conf, /* If that doesn't work, fallback to the old path. * Ideally, we'd get rid of this path sooner or later. */ #endif - file = filestream_open(path, RFILE_MODE_READ_TEXT, -1); + file = filestream_open(path, RFILE_MODE_READ, -1); if (!file) { From a8e031777e38dcf6e42cc246db0b627dc2b578b6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 10 Dec 2017 22:05:24 +0100 Subject: [PATCH 291/394] * Get rid of RFILE_MODE_READ_TEXT * Get rid of PSP ifdef sinside file_stream.c --- libretro-common/include/streams/file_stream.h | 1 - libretro-common/streams/file_stream.c | 79 ++----------------- .../streams/file_stream_transforms.c | 2 +- 3 files changed, 7 insertions(+), 75 deletions(-) diff --git a/libretro-common/include/streams/file_stream.h b/libretro-common/include/streams/file_stream.h index 06cdf33ded..85f086b030 100644 --- a/libretro-common/include/streams/file_stream.h +++ b/libretro-common/include/streams/file_stream.h @@ -41,7 +41,6 @@ typedef struct RFILE RFILE; enum { RFILE_MODE_READ = 0, - RFILE_MODE_READ_TEXT, RFILE_MODE_WRITE, RFILE_MODE_READ_WRITE, diff --git a/libretro-common/streams/file_stream.c b/libretro-common/streams/file_stream.c index da29d4864d..553b087bb6 100644 --- a/libretro-common/streams/file_stream.c +++ b/libretro-common/streams/file_stream.c @@ -86,9 +86,6 @@ struct RFILE char *ext; int64_t size; FILE *fp; -#if defined(PSP) - SceUID fd; -#else #define HAVE_BUFFERED_IO 1 @@ -110,7 +107,6 @@ struct RFILE uint64_t mapsize; #endif int fd; -#endif char *buf; }; @@ -185,36 +181,22 @@ RFILE *filestream_open(const char *path, unsigned mode, ssize_t unused) switch (mode & 0xff) { case RFILE_MODE_READ_TEXT: -#if defined(PSP) - mode_int = 0666; - flags = PSP_O_RDONLY; -#else #if defined(HAVE_BUFFERED_IO) if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0) mode_str = MODE_STR_READ; #endif /* No "else" here */ flags = O_RDONLY; -#endif break; case RFILE_MODE_READ: -#if defined(PSP) - mode_int = 0666; - flags = PSP_O_RDONLY; -#else #if defined(HAVE_BUFFERED_IO) if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0) mode_str = MODE_STR_READ_UNBUF; #endif /* No "else" here */ flags = O_RDONLY; -#endif break; case RFILE_MODE_WRITE: -#if defined(PSP) - mode_int = 0666; - flags = PSP_O_CREAT | PSP_O_WRONLY | PSP_O_TRUNC; -#else #if defined(HAVE_BUFFERED_IO) if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0) mode_str = MODE_STR_WRITE_UNBUF; @@ -226,13 +208,8 @@ RFILE *filestream_open(const char *path, unsigned mode, ssize_t unused) flags |= S_IRUSR | S_IWUSR; #endif } -#endif break; case RFILE_MODE_READ_WRITE: -#if defined(PSP) - mode_int = 0666; - flags = PSP_O_RDWR; -#else #if defined(HAVE_BUFFERED_IO) if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0) mode_str = MODE_STR_WRITE_PLUS; @@ -244,16 +221,9 @@ RFILE *filestream_open(const char *path, unsigned mode, ssize_t unused) flags |= O_BINARY; #endif } -#endif break; } -#if defined(PSP) - stream->fd = sceIoOpen(path, flags, mode_int); - - if (stream->fd < 0) - goto error; -#else #if defined(HAVE_BUFFERED_IO) if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0 && mode_str) { @@ -335,7 +305,6 @@ RFILE *filestream_open(const char *path, unsigned mode, ssize_t unused) } #endif } -#endif { const char *ld = (const char*)strrchr(path, '.'); @@ -391,15 +360,7 @@ char *filestream_gets(RFILE *stream, char *s, size_t len) { if (!stream) return NULL; -#if defined(HAVE_BUFFERED_IO) return fgets(s, (int)len, stream->fp); -#elif defined(PSP) - if(filestream_read(stream,s,len)==len) - return s; - return NULL; -#else - return gets(s); -#endif } int filestream_getc(RFILE *stream) @@ -408,15 +369,7 @@ int filestream_getc(RFILE *stream) (void)c; if (!stream) return 0; -#if defined(HAVE_BUFFERED_IO) - return fgetc(stream->fp); -#elif defined(PSP) - if(filestream_read(stream, &c, 1) == 1) - return (int)c; - return EOF; -#else - return getc(stream->fd); -#endif + return fgetc(stream->fp); } ssize_t filestream_seek(RFILE *stream, ssize_t offset, int whence) @@ -424,11 +377,6 @@ ssize_t filestream_seek(RFILE *stream, ssize_t offset, int whence) if (!stream) goto error; -#if defined(PSP) - if (sceIoLseek(stream->fd, (SceOff)offset, whence) == -1) - goto error; -#else - #if defined(HAVE_BUFFERED_IO) if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0) return fseek(stream->fp, (long)offset, whence); @@ -472,8 +420,6 @@ ssize_t filestream_seek(RFILE *stream, ssize_t offset, int whence) if (lseek(stream->fd, offset, whence) < 0) goto error; -#endif - return 0; error: @@ -508,10 +454,7 @@ ssize_t filestream_tell(RFILE *stream) { if (!stream) goto error; -#if defined(PSP) - if (sceIoLseek(stream->fd, 0, SEEK_CUR) < 0) - goto error; -#else + #if defined(HAVE_BUFFERED_IO) if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0) return ftell(stream->fp); @@ -524,7 +467,6 @@ ssize_t filestream_tell(RFILE *stream) #endif if (lseek(stream->fd, 0, SEEK_CUR) < 0) goto error; -#endif return 0; @@ -541,13 +483,12 @@ ssize_t filestream_read(RFILE *stream, void *s, size_t len) { if (!stream || !s) goto error; -#if defined(PSP) - return sceIoRead(stream->fd, s, len); -#else + #if defined(HAVE_BUFFERED_IO) if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0) return fread(s, 1, len, stream->fp); #endif + #ifdef HAVE_MMAP if (stream->hints & RFILE_HINT_MMAP) { @@ -563,8 +504,8 @@ ssize_t filestream_read(RFILE *stream, void *s, size_t len) return len; } #endif + return read(stream->fd, s, len); -#endif error: return -1; @@ -583,9 +524,7 @@ ssize_t filestream_write(RFILE *stream, const void *s, size_t len) { if (!stream) goto error; -#if defined(PSP) - return sceIoWrite(stream->fd, s, len); -#else + #if defined(HAVE_BUFFERED_IO) if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0) return fwrite(s, 1, len, stream->fp); @@ -595,7 +534,6 @@ ssize_t filestream_write(RFILE *stream, const void *s, size_t len) goto error; #endif return write(stream->fd, s, len); -#endif error: return -1; @@ -655,10 +593,6 @@ int filestream_close(RFILE *stream) if (!string_is_empty(stream->ext)) free(stream->ext); -#if defined(PSP) - if (stream->fd > 0) - sceIoClose(stream->fd); -#else #if defined(HAVE_BUFFERED_IO) if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0) { @@ -674,7 +608,6 @@ int filestream_close(RFILE *stream) if (stream->fd > 0) close(stream->fd); -#endif if (stream->buf) free(stream->buf); free(stream); diff --git a/libretro-common/streams/file_stream_transforms.c b/libretro-common/streams/file_stream_transforms.c index d1e8f2f26e..cec3a4c458 100644 --- a/libretro-common/streams/file_stream_transforms.c +++ b/libretro-common/streams/file_stream_transforms.c @@ -26,7 +26,7 @@ RFILE* rfopen(const char *path, const char *mode) { - unsigned int retro_mode = RFILE_MODE_READ_TEXT; + unsigned int retro_mode = 0; if (strstr(mode, "r")) if (strstr(mode, "b")) retro_mode = RFILE_MODE_READ; From 1298a257ae14871941d2bbac247dd7016ad21694 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 10 Dec 2017 22:07:42 +0100 Subject: [PATCH 292/394] Make HAVE_BUFFERED_IO the new default --- libretro-common/streams/file_stream.c | 61 ++++++--------------------- 1 file changed, 13 insertions(+), 48 deletions(-) diff --git a/libretro-common/streams/file_stream.c b/libretro-common/streams/file_stream.c index 553b087bb6..1b342290ca 100644 --- a/libretro-common/streams/file_stream.c +++ b/libretro-common/streams/file_stream.c @@ -87,8 +87,6 @@ struct RFILE int64_t size; FILE *fp; -#define HAVE_BUFFERED_IO 1 - #if !defined(_WIN32) || defined(LEGACY_WIN32) #define MODE_STR_READ "r" #define MODE_STR_READ_UNBUF "rb" @@ -148,19 +146,17 @@ void filestream_set_size(RFILE *stream) **/ RFILE *filestream_open(const char *path, unsigned mode, ssize_t unused) { - int flags = 0; - int mode_int = 0; -#if defined(HAVE_BUFFERED_IO) + int flags = 0; + int mode_int = 0; #if !defined(_WIN32) || defined(LEGACY_WIN32) - const char *mode_str = NULL; + const char *mode_str = NULL; #else const wchar_t *mode_str = NULL; #endif -#endif - RFILE *stream = (RFILE*)calloc(1, sizeof(*stream)); + RFILE *stream = (RFILE*)calloc(1, sizeof(*stream)); #if defined(_WIN32) && !defined(_XBOX) - char *path_local = NULL; - wchar_t *path_wide = NULL; + char *path_local = NULL; + wchar_t *path_wide = NULL; #endif if (!stream) @@ -181,26 +177,20 @@ RFILE *filestream_open(const char *path, unsigned mode, ssize_t unused) switch (mode & 0xff) { case RFILE_MODE_READ_TEXT: -#if defined(HAVE_BUFFERED_IO) if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0) mode_str = MODE_STR_READ; -#endif /* No "else" here */ flags = O_RDONLY; break; case RFILE_MODE_READ: -#if defined(HAVE_BUFFERED_IO) if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0) mode_str = MODE_STR_READ_UNBUF; -#endif /* No "else" here */ flags = O_RDONLY; break; case RFILE_MODE_WRITE: -#if defined(HAVE_BUFFERED_IO) if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0) mode_str = MODE_STR_WRITE_UNBUF; -#endif else { flags = O_WRONLY | O_CREAT | O_TRUNC; @@ -210,10 +200,8 @@ RFILE *filestream_open(const char *path, unsigned mode, ssize_t unused) } break; case RFILE_MODE_READ_WRITE: -#if defined(HAVE_BUFFERED_IO) if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0) mode_str = MODE_STR_WRITE_PLUS; -#endif else { flags = O_RDWR; @@ -224,7 +212,6 @@ RFILE *filestream_open(const char *path, unsigned mode, ssize_t unused) break; } -#if defined(HAVE_BUFFERED_IO) if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0 && mode_str) { #if defined(_WIN32) && !defined(_XBOX) @@ -262,7 +249,6 @@ RFILE *filestream_open(const char *path, unsigned mode, ssize_t unused) setvbuf(stream->fp, stream->buf, _IOFBF, 0x4000); } else -#endif { #if defined(_WIN32) && !defined(_XBOX) #if defined(LEGACY_WIN32) @@ -279,7 +265,6 @@ RFILE *filestream_open(const char *path, unsigned mode, ssize_t unused) free(path_wide); #endif #else - /* FIXME: HAVE_BUFFERED_IO is always 1, but if it is ever changed, this open() needs to have an alternate _wopen() for Windows. */ stream->fd = open(path, flags, mode_int); #endif @@ -377,10 +362,8 @@ ssize_t filestream_seek(RFILE *stream, ssize_t offset, int whence) if (!stream) goto error; -#if defined(HAVE_BUFFERED_IO) if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0) return fseek(stream->fp, (long)offset, whence); -#endif #ifdef HAVE_MMAP /* Need to check stream->mapped because this function is @@ -455,10 +438,9 @@ ssize_t filestream_tell(RFILE *stream) if (!stream) goto error; -#if defined(HAVE_BUFFERED_IO) if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0) return ftell(stream->fp); -#endif + #ifdef HAVE_MMAP /* Need to check stream->mapped because this function * is called in filestream_open() */ @@ -484,10 +466,8 @@ ssize_t filestream_read(RFILE *stream, void *s, size_t len) if (!stream || !s) goto error; -#if defined(HAVE_BUFFERED_IO) if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0) return fread(s, 1, len, stream->fp); -#endif #ifdef HAVE_MMAP if (stream->hints & RFILE_HINT_MMAP) @@ -513,11 +493,7 @@ error: int filestream_flush(RFILE *stream) { -#if defined(HAVE_BUFFERED_IO) return fflush(stream->fp); -#else - return 0; -#endif } ssize_t filestream_write(RFILE *stream, const void *s, size_t len) @@ -525,10 +501,9 @@ ssize_t filestream_write(RFILE *stream, const void *s, size_t len) if (!stream) goto error; -#if defined(HAVE_BUFFERED_IO) if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0) return fwrite(s, 1, len, stream->fp); -#endif + #ifdef HAVE_MMAP if (stream->hints & RFILE_HINT_MMAP) goto error; @@ -544,22 +519,17 @@ int filestream_putc(RFILE *stream, int c) if (!stream) return EOF; -#if defined(HAVE_BUFFERED_IO) return fputc(c, stream->fp); -#else - /* unimplemented */ - return EOF; -#endif } int filestream_vprintf(RFILE *stream, const char* format, va_list args) { static char buffer[8 * 1024]; - int numChars = vsprintf(buffer, format, args); + int num_chars = vsprintf(buffer, format, args); - if (numChars < 0) + if (num_chars < 0) return -1; - else if (numChars == 0) + else if (num_chars == 0) return 0; return filestream_write(stream, buffer, numChars); @@ -577,12 +547,7 @@ int filestream_printf(RFILE *stream, const char* format, ...) int filestream_error(RFILE *stream) { -#if defined(HAVE_BUFFERED_IO) return ferror(stream->fp); -#else - /* stub */ - return 0; -#endif } int filestream_close(RFILE *stream) @@ -593,18 +558,18 @@ int filestream_close(RFILE *stream) if (!string_is_empty(stream->ext)) free(stream->ext); -#if defined(HAVE_BUFFERED_IO) if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0) { if (stream->fp) fclose(stream->fp); } else -#endif + { #ifdef HAVE_MMAP if (stream->hints & RFILE_HINT_MMAP) munmap(stream->mapped, stream->mapsize); #endif + } if (stream->fd > 0) close(stream->fd); From d19eaeaab8d6a24a85e5cda7077eccd1c06be469 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 10 Dec 2017 22:10:32 +0100 Subject: [PATCH 293/394] (file_stream.c) Cleanups; buildfix --- libretro-common/streams/file_stream.c | 36 ++++++++------------------- 1 file changed, 10 insertions(+), 26 deletions(-) diff --git a/libretro-common/streams/file_stream.c b/libretro-common/streams/file_stream.c index 1b342290ca..6f3ce60e6f 100644 --- a/libretro-common/streams/file_stream.c +++ b/libretro-common/streams/file_stream.c @@ -147,22 +147,16 @@ void filestream_set_size(RFILE *stream) RFILE *filestream_open(const char *path, unsigned mode, ssize_t unused) { int flags = 0; - int mode_int = 0; #if !defined(_WIN32) || defined(LEGACY_WIN32) const char *mode_str = NULL; #else const wchar_t *mode_str = NULL; #endif RFILE *stream = (RFILE*)calloc(1, sizeof(*stream)); -#if defined(_WIN32) && !defined(_XBOX) - char *path_local = NULL; - wchar_t *path_wide = NULL; -#endif if (!stream) return NULL; - (void)mode_int; (void)flags; stream->hints = mode; @@ -176,12 +170,6 @@ RFILE *filestream_open(const char *path, unsigned mode, ssize_t unused) switch (mode & 0xff) { - case RFILE_MODE_READ_TEXT: - if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0) - mode_str = MODE_STR_READ; - /* No "else" here */ - flags = O_RDONLY; - break; case RFILE_MODE_READ: if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0) mode_str = MODE_STR_READ_UNBUF; @@ -215,16 +203,14 @@ RFILE *filestream_open(const char *path, unsigned mode, ssize_t unused) if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0 && mode_str) { #if defined(_WIN32) && !defined(_XBOX) - (void)path_local; - (void)path_wide; #if defined(LEGACY_WIN32) - path_local = utf8_to_local_string_alloc(path); - stream->fp = fopen(path_local, mode_str); + char *path_local = utf8_to_local_string_alloc(path); + stream->fp = fopen(path_local, mode_str); if (path_local) free(path_local); #else - path_wide = utf8_to_utf16_string_alloc(path); - stream->fp = _wfopen(path_wide, mode_str); + wchar_t * path_wide = utf8_to_utf16_string_alloc(path); + stream->fp = _wfopen(path_wide, mode_str); if (path_wide) free(path_wide); #endif @@ -252,20 +238,18 @@ RFILE *filestream_open(const char *path, unsigned mode, ssize_t unused) { #if defined(_WIN32) && !defined(_XBOX) #if defined(LEGACY_WIN32) - (void)path_wide; - path_local = utf8_to_local_string_alloc(path); - stream->fd = open(path_local, flags, mode_int); + char *path_local = utf8_to_local_string_alloc(path); + stream->fd = open(path_local, flags, 0); if (path_local) free(path_local); #else - (void)path_local; - path_wide = utf8_to_utf16_string_alloc(path); - stream->fd = _wopen(path_wide, flags, mode_int); + wchar_t * path_wide = utf8_to_utf16_string_alloc(path); + stream->fd = _wopen(path_wide, flags, 0); if (path_wide) free(path_wide); #endif #else - stream->fd = open(path, flags, mode_int); + stream->fd = open(path, flags, 0); #endif if (stream->fd == -1) @@ -532,7 +516,7 @@ int filestream_vprintf(RFILE *stream, const char* format, va_list args) else if (num_chars == 0) return 0; - return filestream_write(stream, buffer, numChars); + return filestream_write(stream, buffer, num_chars); } int filestream_printf(RFILE *stream, const char* format, ...) From 2e979ec53746b8693cc17ee843c18e2589a13354 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 10 Dec 2017 22:25:38 +0100 Subject: [PATCH 294/394] Replace function signatures of file_stream file functions --- cheevos/cheevos.c | 3 ++- configuration.c | 9 ++++++--- gfx/drivers/gx_gfx.c | 2 +- gfx/video_shader_parse.c | 2 +- libretro-common/features/features_cpu.c | 3 ++- libretro-common/file/config_file.c | 3 ++- libretro-common/file/file_path.c | 2 +- libretro-common/formats/bmp/rbmp_encode.c | 2 +- libretro-common/formats/png/rpng_encode.c | 2 +- libretro-common/formats/xml/rxml.c | 2 +- libretro-common/hash/rhash.c | 2 +- libretro-common/include/streams/file_stream.h | 14 ++++++++------ libretro-common/include/streams/interface_stream.h | 2 +- libretro-common/streams/file_stream.c | 13 +++++++------ libretro-common/streams/interface_stream.c | 4 ++-- libretro-db/c_converter.c | 2 +- libretro-db/libretrodb.c | 4 ++-- libretro-db/lua/lua_converter.c | 3 ++- libretro-db/lua/testlib.c | 2 +- libretro-db/rmsgpack_test.c | 2 +- menu/menu_setting.c | 3 ++- movie.c | 4 ++-- playlist.c | 5 +++-- tasks/task_database.c | 6 +++--- tasks/task_database_cue.c | 9 ++++----- tasks/task_save.c | 9 ++++++--- 26 files changed, 64 insertions(+), 50 deletions(-) diff --git a/cheevos/cheevos.c b/cheevos/cheevos.c index 3e12224565..e92c796397 100644 --- a/cheevos/cheevos.c +++ b/cheevos/cheevos.c @@ -2640,7 +2640,8 @@ static int cheevos_iterate(coro_t* coro) /* Load the content into memory, or copy it over to our own buffer */ if (!CHEEVOS_VAR_DATA) { - CHEEVOS_VAR_STREAM = filestream_open(CHEEVOS_VAR_PATH, RFILE_MODE_READ, -1); + CHEEVOS_VAR_STREAM = filestream_open(CHEEVOS_VAR_PATH, + RFILE_MODE_READ, RFILE_HINT_NONE); if (!CHEEVOS_VAR_STREAM) CORO_STOP(); diff --git a/configuration.c b/configuration.c index 8edb392412..bb4ef4cc3e 100644 --- a/configuration.c +++ b/configuration.c @@ -3791,15 +3791,18 @@ bool config_save_file(const char *path) #ifdef HAVE_LAKKA if (settings->bools.ssh_enable) - filestream_close(filestream_open(LAKKA_SSH_PATH, RFILE_MODE_WRITE, -1)); + filestream_close(filestream_open(LAKKA_SSH_PATH, + RFILE_MODE_WRITE, RFILE_HINT_NONE)); else path_file_remove(LAKKA_SSH_PATH); if (settings->bools.samba_enable) - filestream_close(filestream_open(LAKKA_SAMBA_PATH, RFILE_MODE_WRITE, -1)); + filestream_close(filestream_open(LAKKA_SAMBA_PATH, + RFILE_MODE_WRITE, RFILE_HINT_NONE)); else path_file_remove(LAKKA_SAMBA_PATH); if (settings->bools.bluetooth_enable) - filestream_close(filestream_open(LAKKA_BLUETOOTH_PATH, RFILE_MODE_WRITE, -1)); + filestream_close(filestream_open(LAKKA_BLUETOOTH_PATH, + RFILE_MODE_WRITE, RFILE_HINT_NONE)); else path_file_remove(LAKKA_BLUETOOTH_PATH); #endif diff --git a/gfx/drivers/gx_gfx.c b/gfx/drivers/gx_gfx.c index bf7727909e..0aa1e9c976 100644 --- a/gfx/drivers/gx_gfx.c +++ b/gfx/drivers/gx_gfx.c @@ -719,7 +719,7 @@ static void gx_efb_screenshot(void) { int x, y; uint8_t tga_header[] = {0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x02, 0xE0, 0x01, 0x18, 0x00}; - RFILE *out = filestream_open("/screenshot.tga", RFILE_MODE_WRITE, -1); + RFILE *out = filestream_open("/screenshot.tga", RFILE_MODE_WRITE, RFILE_HINT_NONE); if (!out) return; diff --git a/gfx/video_shader_parse.c b/gfx/video_shader_parse.c index 5b88be1608..0d3a6434cb 100644 --- a/gfx/video_shader_parse.c +++ b/gfx/video_shader_parse.c @@ -545,7 +545,7 @@ bool video_shader_resolve_parameters(config_file_t *conf, /* If that doesn't work, fallback to the old path. * Ideally, we'd get rid of this path sooner or later. */ #endif - file = filestream_open(path, RFILE_MODE_READ, -1); + file = filestream_open(path, RFILE_MODE_READ, RFILE_HINT_NONE); if (!file) { diff --git a/libretro-common/features/features_cpu.c b/libretro-common/features/features_cpu.c index aa43eaa2d2..a52df70056 100644 --- a/libretro-common/features/features_cpu.c +++ b/libretro-common/features/features_cpu.c @@ -320,7 +320,8 @@ static unsigned char check_arm_cpu_feature(const char* feature) { char line[1024]; unsigned char status = 0; - RFILE *fp = filestream_open("/proc/cpuinfo", RFILE_MODE_READ, -1); + RFILE *fp = filestream_open("/proc/cpuinfo", + RFILE_MODE_READ, RFILE_HINT_NONE); if (!fp) return 0; diff --git a/libretro-common/file/config_file.c b/libretro-common/file/config_file.c index e613f02a34..b4d7251d1a 100644 --- a/libretro-common/file/config_file.c +++ b/libretro-common/file/config_file.c @@ -392,7 +392,8 @@ static config_file_t *config_file_new_internal( goto error; conf->include_depth = depth; - file = filestream_open(path, RFILE_MODE_READ, 0x4000); + file = filestream_open(path, + RFILE_MODE_READ, RFILE_HINT_NONE); if (!file) { diff --git a/libretro-common/file/file_path.c b/libretro-common/file/file_path.c index 8d9f8414b2..f5493017e5 100644 --- a/libretro-common/file/file_path.c +++ b/libretro-common/file/file_path.c @@ -410,7 +410,7 @@ bool path_file_exists(const char *path) if (!path || !*path) return false; - dummy = filestream_open(path, RFILE_MODE_READ, -1); + dummy = filestream_open(path, RFILE_MODE_READ, RFILE_HINT_NONE); if (!dummy) return false; diff --git a/libretro-common/formats/bmp/rbmp_encode.c b/libretro-common/formats/bmp/rbmp_encode.c index 9c2e199ab0..9a30b27a92 100644 --- a/libretro-common/formats/bmp/rbmp_encode.c +++ b/libretro-common/formats/bmp/rbmp_encode.c @@ -215,7 +215,7 @@ bool rbmp_save_image( unsigned pitch, enum rbmp_source_type type) { bool ret = false; - RFILE *file = filestream_open(filename, RFILE_MODE_WRITE, -1); + RFILE *file = filestream_open(filename, RFILE_MODE_WRITE, RFILE_HINT_NONE); if (!file) return false; diff --git a/libretro-common/formats/png/rpng_encode.c b/libretro-common/formats/png/rpng_encode.c index fe46e03598..ab67614a73 100644 --- a/libretro-common/formats/png/rpng_encode.c +++ b/libretro-common/formats/png/rpng_encode.c @@ -227,7 +227,7 @@ static bool rpng_save_image(const char *path, void *stream = NULL; uint32_t total_in = 0; uint32_t total_out = 0; - RFILE *file = filestream_open(path, RFILE_MODE_WRITE, -1); + RFILE *file = filestream_open(path, RFILE_MODE_WRITE, RFILE_HINT_NONE); if (!file) GOTO_END_ERROR(); diff --git a/libretro-common/formats/xml/rxml.c b/libretro-common/formats/xml/rxml.c index c53ed9220a..b00129c99c 100644 --- a/libretro-common/formats/xml/rxml.c +++ b/libretro-common/formats/xml/rxml.c @@ -419,7 +419,7 @@ rxml_document_t *rxml_load_document(const char *path) char *new_memory_buffer = NULL; const char *mem_ptr = NULL; long len = 0; - RFILE *file = filestream_open(path, RFILE_MODE_READ, -1); + RFILE *file = filestream_open(path, RFILE_MODE_READ, RFILE_HINT_NONE); if (!file) return NULL; diff --git a/libretro-common/hash/rhash.c b/libretro-common/hash/rhash.c index 3d4aa1ca5d..03f96d7e92 100644 --- a/libretro-common/hash/rhash.c +++ b/libretro-common/hash/rhash.c @@ -511,7 +511,7 @@ int sha1_calculate(const char *path, char *result) SHA1Context sha; unsigned char buff[4096]; int rv = 1; - RFILE *fd = filestream_open(path, RFILE_MODE_READ, -1); + RFILE *fd = filestream_open(path, RFILE_MODE_READ, RFILE_HINT_NONE); if (!fd) goto error; diff --git a/libretro-common/include/streams/file_stream.h b/libretro-common/include/streams/file_stream.h index 85f086b030..fde5b36a4c 100644 --- a/libretro-common/include/streams/file_stream.h +++ b/libretro-common/include/streams/file_stream.h @@ -38,15 +38,17 @@ RETRO_BEGIN_DECLS typedef struct RFILE RFILE; +#define RFILE_HINT_NONE (0) +/* There is no guarantee these requests will be attended. */ +#define RFILE_HINT_UNBUFFERED (1 << 8) +/* requires RFILE_MODE_READ */ +#define RFILE_HINT_MMAP (1 << 9) + enum { RFILE_MODE_READ = 0, RFILE_MODE_WRITE, - RFILE_MODE_READ_WRITE, - - /* There is no guarantee these requests will be attended. */ - RFILE_HINT_UNBUFFERED = 1<<8, - RFILE_HINT_MMAP = 1<<9 /* requires RFILE_MODE_READ */ + RFILE_MODE_READ_WRITE }; int64_t filestream_get_size(RFILE *stream); @@ -64,7 +66,7 @@ const char *filestream_get_ext(RFILE *stream); * Opens a file for reading or writing, depending on the requested mode. * Returns a pointer to an RFILE if opened successfully, otherwise NULL. **/ -RFILE *filestream_open(const char *path, unsigned mode, ssize_t unused); +RFILE *filestream_open(const char *path, unsigned mode, unsigned hints); ssize_t filestream_seek(RFILE *stream, ssize_t offset, int whence); diff --git a/libretro-common/include/streams/interface_stream.h b/libretro-common/include/streams/interface_stream.h index 7eda0e7f8f..b6d437e058 100644 --- a/libretro-common/include/streams/interface_stream.h +++ b/libretro-common/include/streams/interface_stream.h @@ -66,7 +66,7 @@ bool intfstream_resize(intfstream_internal_t *intf, intfstream_info_t *info); bool intfstream_open(intfstream_internal_t *intf, - const char *path, unsigned mode, ssize_t len); + const char *path, unsigned mode, unsigned hints); ssize_t intfstream_read(intfstream_internal_t *intf, void *s, size_t len); diff --git a/libretro-common/streams/file_stream.c b/libretro-common/streams/file_stream.c index 6f3ce60e6f..4e601e31f8 100644 --- a/libretro-common/streams/file_stream.c +++ b/libretro-common/streams/file_stream.c @@ -144,7 +144,7 @@ void filestream_set_size(RFILE *stream) * Opens a file for reading or writing, depending on the requested mode. * Returns a pointer to an RFILE if opened successfully, otherwise NULL. **/ -RFILE *filestream_open(const char *path, unsigned mode, ssize_t unused) +RFILE *filestream_open(const char *path, unsigned mode, unsigned hints) { int flags = 0; #if !defined(_WIN32) || defined(LEGACY_WIN32) @@ -159,16 +159,16 @@ RFILE *filestream_open(const char *path, unsigned mode, ssize_t unused) (void)flags; - stream->hints = mode; + stream->hints = hints; #ifdef HAVE_MMAP - if (stream->hints & RFILE_HINT_MMAP && (stream->hints & 0xff) == RFILE_MODE_READ) + if (stream->hints & RFILE_HINT_MMAP && (stream->mode == RFILE_MODE_READ)) stream->hints |= RFILE_HINT_UNBUFFERED; else #endif stream->hints &= ~RFILE_HINT_MMAP; - switch (mode & 0xff) + switch (mode) { case RFILE_MODE_READ: if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0) @@ -582,7 +582,8 @@ int filestream_read_file(const char *path, void **buf, ssize_t *len) ssize_t ret = 0; ssize_t content_buf_size = 0; void *content_buf = NULL; - RFILE *file = filestream_open(path, RFILE_MODE_READ, -1); + RFILE *file = filestream_open(path, + RFILE_MODE_READ, RFILE_HINT_NONE); if (!file) { @@ -648,7 +649,7 @@ error: bool filestream_write_file(const char *path, const void *data, ssize_t size) { ssize_t ret = 0; - RFILE *file = filestream_open(path, RFILE_MODE_WRITE, -1); + RFILE *file = filestream_open(path, RFILE_MODE_WRITE, RFILE_HINT_NONE); if (!file) return false; diff --git a/libretro-common/streams/interface_stream.c b/libretro-common/streams/interface_stream.c index fcd1edf8cc..0f4f175197 100644 --- a/libretro-common/streams/interface_stream.c +++ b/libretro-common/streams/interface_stream.c @@ -83,7 +83,7 @@ bool intfstream_resize(intfstream_internal_t *intf, intfstream_info_t *info) } bool intfstream_open(intfstream_internal_t *intf, const char *path, - unsigned mode, ssize_t len) + unsigned mode, unsigned hints) { if (!intf) return false; @@ -91,7 +91,7 @@ bool intfstream_open(intfstream_internal_t *intf, const char *path, switch (intf->type) { case INTFSTREAM_FILE: - intf->file.fp = filestream_open(path, mode, len); + intf->file.fp = filestream_open(path, mode, hints); if (!intf->file.fp) return false; break; diff --git a/libretro-db/c_converter.c b/libretro-db/c_converter.c index ae6b219d0b..edc8c10cf1 100644 --- a/libretro-db/c_converter.c +++ b/libretro-db/c_converter.c @@ -804,7 +804,7 @@ int main(int argc, char** argv) dat_buffer++; } - rdb_file = filestream_open(rdb_path, RFILE_MODE_WRITE, -1); + rdb_file = filestream_open(rdb_path, RFILE_MODE_WRITE, RFILE_HINT_NONE); if (!rdb_file) { diff --git a/libretro-db/libretrodb.c b/libretro-db/libretrodb.c index c4d39d0be8..1ba782afe8 100644 --- a/libretro-db/libretrodb.c +++ b/libretro-db/libretrodb.c @@ -217,7 +217,7 @@ int libretrodb_open(const char *path, libretrodb_t *db) libretrodb_header_t header; libretrodb_metadata_t md; int rv; - RFILE *fd = filestream_open(path, RFILE_MODE_READ, -1); + RFILE *fd = filestream_open(path, RFILE_MODE_READ, RFILE_HINT_NONE); if (!fd) return -errno; @@ -431,7 +431,7 @@ int libretrodb_cursor_open(libretrodb_t *db, libretrodb_cursor_t *cursor, if (!db || string_is_empty(db->path)) return -errno; - cursor->fd = filestream_open(db->path, RFILE_MODE_READ | RFILE_HINT_MMAP, -1); + cursor->fd = filestream_open(db->path, RFILE_MODE_READ, RFILE_HINT_MMAP); if (!cursor->fd) return -errno; diff --git a/libretro-db/lua/lua_converter.c b/libretro-db/lua/lua_converter.c index a60dc1d22d..2c70a7bc3b 100644 --- a/libretro-db/lua/lua_converter.c +++ b/libretro-db/lua/lua_converter.c @@ -92,7 +92,8 @@ int main(int argc, char ** argv) call_init(L, argc - 2, (const char **) argv + 2); - dst = filestream_open(db_file, RFILE_MODE_WRITE, -1); + dst = filestream_open(db_file, RFILE_MODE_WRITE, RFILE_HINT_NONE); + if (!dst) { printf( diff --git a/libretro-db/lua/testlib.c b/libretro-db/lua/testlib.c index 524b9fe353..b2c9874db7 100644 --- a/libretro-db/lua/testlib.c +++ b/libretro-db/lua/testlib.c @@ -106,7 +106,7 @@ static int create_db(lua_State *L) } lua_setfield(L, LUA_REGISTRYINDEX, "testlib_get_value"); - dst = filestream_open(db_file, RFILE_MODE_WRITE, -1); + dst = filestream_open(db_file, RFILE_MODE_WRITE, RFILE_HINT_NONE); if (!dst) { lua_pushstring(L, "Could not open destination file"); diff --git a/libretro-db/rmsgpack_test.c b/libretro-db/rmsgpack_test.c index 1c6f03cb57..b1e74dc981 100644 --- a/libretro-db/rmsgpack_test.c +++ b/libretro-db/rmsgpack_test.c @@ -186,7 +186,7 @@ static struct rmsgpack_read_callbacks stub_callbacks = { int main(void) { struct stub_state state; - RFILE *fd = filestream_open("test.msgpack", RFILE_MODE_READ, -1); + RFILE *fd = filestream_open("test.msgpack", RFILE_MODE_READ, RFILE_HINT_NONE); state.i = 0; state.stack[0] = 0; diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 31d1d618b8..cddca2d23f 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -1876,7 +1876,8 @@ static void systemd_service_toggle(const char *path, char *unit, bool enable) args[2] = unit; if (enable) - filestream_close(filestream_open(path, RFILE_MODE_WRITE, -1)); + filestream_close(filestream_open(path, + RFILE_MODE_WRITE, RFILE_HINT_NONE)); else path_file_remove(path); diff --git a/movie.c b/movie.c index 8ca184906e..0135d1c332 100644 --- a/movie.c +++ b/movie.c @@ -75,7 +75,7 @@ static bool bsv_movie_init_playback(bsv_movie_t *handle, const char *path) uint32_t state_size = 0; uint32_t content_crc = 0; uint32_t header[4] = {0}; - RFILE *file = filestream_open(path, RFILE_MODE_READ, -1); + RFILE *file = filestream_open(path, RFILE_MODE_READ, RFILE_HINT_NONE); if (!file) { @@ -152,7 +152,7 @@ static bool bsv_movie_init_record(bsv_movie_t *handle, const char *path) uint32_t state_size = 0; uint32_t content_crc = 0; uint32_t header[4] = {0}; - RFILE *file = filestream_open(path, RFILE_MODE_WRITE, -1); + RFILE *file = filestream_open(path, RFILE_MODE_WRITE, RFILE_HINT_NONE); if (!file) { diff --git a/playlist.c b/playlist.c index 13154d6bbe..f79278a4ef 100644 --- a/playlist.c +++ b/playlist.c @@ -393,7 +393,8 @@ void playlist_write_file(playlist_t *playlist) if (!playlist || !playlist->modified) return; - file = filestream_open(playlist->conf_path, RFILE_MODE_WRITE, -1); + file = filestream_open(playlist->conf_path, + RFILE_MODE_WRITE, RFILE_HINT_NONE); if (!file) { @@ -493,7 +494,7 @@ static bool playlist_read_file( unsigned i; char buf[PLAYLIST_ENTRIES][1024]; RFILE *file = filestream_open( - path, RFILE_MODE_READ, -1); + path, RFILE_MODE_READ, RFILE_HINT_NONE); for (i = 0; i < PLAYLIST_ENTRIES; i++) buf[i][0] = '\0'; diff --git a/tasks/task_database.c b/tasks/task_database.c index afe42dd83e..10382a4853 100644 --- a/tasks/task_database.c +++ b/tasks/task_database.c @@ -101,7 +101,7 @@ static intfstream_t* intfstream_open_file(const char *path) if (!fd) return NULL; - if (!intfstream_open(fd, path, RFILE_MODE_READ, -1)) + if (!intfstream_open(fd, path, RFILE_MODE_READ, RFILE_HINT_NONE)) goto error; return fd; @@ -130,7 +130,7 @@ static intfstream_t *open_memory(void *data, size_t size) if (!fd) return NULL; - if (!intfstream_open(fd, NULL, RFILE_MODE_READ, -1)) + if (!intfstream_open(fd, NULL, RFILE_MODE_READ, RFILE_HINT_NONE)) goto error; return fd; @@ -158,7 +158,7 @@ open_chd_track(const char *path, int32_t track) if (!fd) return NULL; - if (!intfstream_open(fd, path, RFILE_MODE_READ, -1)) + if (!intfstream_open(fd, path, RFILE_MODE_READ, RFILE_HINT_NONE)) goto error; return fd; diff --git a/tasks/task_database_cue.c b/tasks/task_database_cue.c index 09557c2280..5e3ef10d51 100644 --- a/tasks/task_database_cue.c +++ b/tasks/task_database_cue.c @@ -413,10 +413,9 @@ clean: static ssize_t get_file_size(const char *path) { ssize_t rv; - RFILE *fd = filestream_open(path, RFILE_MODE_READ, -1); - if (fd == NULL) { + RFILE *fd = filestream_open(path, RFILE_MODE_READ, RFILE_HINT_NONE); + if (fd == NULL) return -1; - } rv = filestream_get_size(fd); filestream_close(fd); return rv; @@ -468,7 +467,7 @@ int cue_find_track(const char *cue_path, bool first, if (!fd) goto error; - if (!intfstream_open(fd, cue_path, RFILE_MODE_READ, -1)) + if (!intfstream_open(fd, cue_path, RFILE_MODE_READ, RFILE_HINT_NONE)) { RARCH_LOG("Could not open CUE file '%s': %s\n", cue_path, strerror(errno)); @@ -622,7 +621,7 @@ int gdi_find_track(const char *gdi_path, bool first, if (!fd) goto error; - if (!intfstream_open(fd, gdi_path, RFILE_MODE_READ, -1)) + if (!intfstream_open(fd, gdi_path, RFILE_MODE_READ, RFILE_HINT_NONE)) { RARCH_LOG("Could not open GDI file '%s': %s\n", gdi_path, strerror(errno)); diff --git a/tasks/task_save.c b/tasks/task_save.c index 0986f79a8f..e1b64f9c90 100644 --- a/tasks/task_save.c +++ b/tasks/task_save.c @@ -157,7 +157,8 @@ static void autosave_thread(void *data) if (differ) { /* Should probably deal with this more elegantly. */ - RFILE *file = filestream_open(save->path, RFILE_MODE_WRITE, -1); + RFILE *file = filestream_open(save->path, + RFILE_MODE_WRITE, RFILE_HINT_NONE); if (file) { @@ -564,7 +565,8 @@ static void task_save_handler(retro_task_t *task) if (!state->file) { - state->file = filestream_open(state->path, RFILE_MODE_WRITE, -1); + state->file = filestream_open(state->path, RFILE_MODE_WRITE, + RFILE_HINT_NONE); if (!state->file) return; @@ -736,7 +738,8 @@ static void task_load_handler(retro_task_t *task) if (!state->file) { - state->file = filestream_open(state->path, RFILE_MODE_READ, -1); + state->file = filestream_open(state->path, RFILE_MODE_READ, + RFILE_HINT_NONE); if (!state->file) goto error; From 2fd8210e597c512375ddc6c95ad46fe36855aa75 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 10 Dec 2017 22:35:08 +0100 Subject: [PATCH 295/394] Create shareable filestream_getline --- libretro-common/file/config_file.c | 38 +----------------- libretro-common/include/streams/file_stream.h | 39 ++++++++++++++++++- libretro-common/streams/file_stream.c | 35 ----------------- 3 files changed, 38 insertions(+), 74 deletions(-) diff --git a/libretro-common/file/config_file.c b/libretro-common/file/config_file.c index b4d7251d1a..c7b6a92f24 100644 --- a/libretro-common/file/config_file.c +++ b/libretro-common/file/config_file.c @@ -80,42 +80,6 @@ struct config_file static config_file_t *config_file_new_internal( const char *path, unsigned depth); -static char *getaline(RFILE *file) -{ - char* newline = (char*)malloc(9); - char* newline_tmp = NULL; - size_t cur_size = 8; - size_t idx = 0; - int in = filestream_getc(file); - - if (!newline) - return NULL; - - while (in != EOF && in != '\n') - { - if (idx == cur_size) - { - cur_size *= 2; - newline_tmp = (char*)realloc(newline, cur_size + 1); - - if (!newline_tmp) - { - free(newline); - return NULL; - } - - newline = newline_tmp; - } - - /* ignore MS line endings */ - if (in != '\r') - newline[idx++] = in; - in = filestream_getc(file); - } - newline[idx] = '\0'; - return newline; -} - static char *strip_comment(char *str) { /* Remove everything after comment. @@ -419,7 +383,7 @@ static config_file_t *config_file_new_internal( list->value = NULL; list->next = NULL; - line = getaline(file); + line = filestream_getline(file); if (!line) { diff --git a/libretro-common/include/streams/file_stream.h b/libretro-common/include/streams/file_stream.h index fde5b36a4c..c1b6fe951a 100644 --- a/libretro-common/include/streams/file_stream.h +++ b/libretro-common/include/streams/file_stream.h @@ -25,11 +25,13 @@ #include #include +#include #include #include #include +#include #include #include @@ -84,8 +86,6 @@ int filestream_read_file(const char *path, void **buf, ssize_t *len); char *filestream_gets(RFILE *stream, char *s, size_t len); -char *filestream_getline(RFILE *stream); - int filestream_getc(RFILE *stream); int filestream_eof(RFILE *stream); @@ -107,6 +107,41 @@ FILE* filestream_get_fp(RFILE *stream); */ int filestream_flush(RFILE *stream); +static INLINE char *filestream_getline(RFILE *stream) +{ + char* newline = (char*)malloc(9); + char* newline_tmp = NULL; + size_t cur_size = 8; + size_t idx = 0; + int in = filestream_getc(stream); + + if (!newline) + return NULL; + + while (in != EOF && in != '\n') + { + if (idx == cur_size) + { + cur_size *= 2; + newline_tmp = (char*)realloc(newline, cur_size + 1); + + if (!newline_tmp) + { + free(newline); + return NULL; + } + + newline = newline_tmp; + } + + newline[idx++] = in; + in = filestream_getc(stream); + } + + newline[idx] = '\0'; + return newline; +} + RETRO_END_DECLS #endif diff --git a/libretro-common/streams/file_stream.c b/libretro-common/streams/file_stream.c index 4e601e31f8..845e12c348 100644 --- a/libretro-common/streams/file_stream.c +++ b/libretro-common/streams/file_stream.c @@ -290,41 +290,6 @@ error: return NULL; } -char *filestream_getline(RFILE *stream) -{ - char* newline = (char*)malloc(9); - char* newline_tmp = NULL; - size_t cur_size = 8; - size_t idx = 0; - int in = filestream_getc(stream); - - if (!newline) - return NULL; - - while (in != EOF && in != '\n') - { - if (idx == cur_size) - { - cur_size *= 2; - newline_tmp = (char*)realloc(newline, cur_size + 1); - - if (!newline_tmp) - { - free(newline); - return NULL; - } - - newline = newline_tmp; - } - - newline[idx++] = in; - in = filestream_getc(stream); - } - - newline[idx] = '\0'; - return newline; -} - char *filestream_gets(RFILE *stream, char *s, size_t len) { if (!stream) From 85d9d986ebca44c909a4f249e161a48081109ddb Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Sun, 10 Dec 2017 22:46:39 +0100 Subject: [PATCH 296/394] Buildfix --- libretro-common/streams/file_stream.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libretro-common/streams/file_stream.c b/libretro-common/streams/file_stream.c index 845e12c348..3759e33090 100644 --- a/libretro-common/streams/file_stream.c +++ b/libretro-common/streams/file_stream.c @@ -162,7 +162,7 @@ RFILE *filestream_open(const char *path, unsigned mode, unsigned hints) stream->hints = hints; #ifdef HAVE_MMAP - if (stream->hints & RFILE_HINT_MMAP && (stream->mode == RFILE_MODE_READ)) + if (stream->hints & RFILE_HINT_MMAP && mode == RFILE_MODE_READ) stream->hints |= RFILE_HINT_UNBUFFERED; else #endif From e877595ff7a40692fcc52a43504315e66fa40ec1 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Sun, 10 Dec 2017 20:16:41 -0500 Subject: [PATCH 297/394] add buildbot url for msvc2003 (Windows 95) --- config.def.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/config.def.h b/config.def.h index 34eefd9fa4..38dd96eb3f 100644 --- a/config.def.h +++ b/config.def.h @@ -662,11 +662,10 @@ static char buildbot_server_url[] = "http://buildbot.libretro.com/nightly/window static char buildbot_server_url[] = "http://buildbot.libretro.com/nightly/windows-msvc2010/x86/latest/"; #endif #elif _MSC_VER == 1400 -#if defined(__x86_64__) -static char buildbot_server_url[] = "http://buildbot.libretro.com/nightly/windows-msvc2005/x86_64/latest/"; -#elif defined(__i386__) || defined(__i486__) || defined(__i686__) || defined(_M_IX86) || defined(_M_IA64) static char buildbot_server_url[] = "http://buildbot.libretro.com/nightly/windows-msvc2005/x86/latest/"; #endif +#elif _MSC_VER == 1310 +static char buildbot_server_url[] = "http://buildbot.libretro.com/nightly/windows-msvc2003/x86/latest/"; #else #if defined(__x86_64__) static char buildbot_server_url[] = "http://buildbot.libretro.com/nightly/windows/x86_64/latest/"; From f3a58f4ff337cf8de60924978f1a1e1fe8fdb1e7 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Sun, 10 Dec 2017 22:07:25 -0500 Subject: [PATCH 298/394] remove extra #endif --- config.def.h | 1 - 1 file changed, 1 deletion(-) diff --git a/config.def.h b/config.def.h index 38dd96eb3f..4145be9d77 100644 --- a/config.def.h +++ b/config.def.h @@ -663,7 +663,6 @@ static char buildbot_server_url[] = "http://buildbot.libretro.com/nightly/window #endif #elif _MSC_VER == 1400 static char buildbot_server_url[] = "http://buildbot.libretro.com/nightly/windows-msvc2005/x86/latest/"; -#endif #elif _MSC_VER == 1310 static char buildbot_server_url[] = "http://buildbot.libretro.com/nightly/windows-msvc2003/x86/latest/"; #else From b14598657c4b813c555b6cc6c6e81ec0830621c4 Mon Sep 17 00:00:00 2001 From: "Peter Y. Hammond" Date: Sun, 10 Dec 2017 22:22:01 -0700 Subject: [PATCH 299/394] Fixed a bug where the joypad devices were not always being assigned in the same order as they were numbered under /dev/input/. This showed up mainly when using an external USB Bluetooth dongle. In that case, controllers would be assigned often in reverse order. --- input/drivers_joypad/udev_joypad.c | 34 ++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/input/drivers_joypad/udev_joypad.c b/input/drivers_joypad/udev_joypad.c index 20ee084ec8..902367ee67 100644 --- a/input/drivers_joypad/udev_joypad.c +++ b/input/drivers_joypad/udev_joypad.c @@ -82,6 +82,12 @@ struct udev_joypad int32_t pid; }; +struct joypad_udev_entry +{ + const char *devnode; + struct udev_list_entry *item; +}; + static struct udev *udev_joypad_fd = NULL; static struct udev_monitor *udev_joypad_mon = NULL; static struct udev_joypad udev_pads[MAX_USERS]; @@ -526,12 +532,22 @@ static void udev_joypad_poll(void) } } +// Used for sorting devnodes to appear in the correct order +static int sort_devnodes(const void *a, const void *b) +{ + const struct joypad_udev_entry *aa = a; + const struct joypad_udev_entry *bb = b; + return strcmp(aa->devnode, bb->devnode); +} + static bool udev_joypad_init(void *data) { unsigned i; + unsigned sorted_count = 0; struct udev_list_entry *devs = NULL; struct udev_list_entry *item = NULL; struct udev_enumerate *enumerate = NULL; + struct joypad_udev_entry sorted[MAX_USERS]; (void)data; @@ -564,6 +580,24 @@ static bool udev_joypad_init(void *data) struct udev_device *dev = udev_device_new_from_syspath(udev_joypad_fd, name); const char *devnode = udev_device_get_devnode(dev); + if (devnode != NULL) { + sorted[sorted_count].devnode = devnode; + sorted[sorted_count].item = item; + sorted_count++; + } else { + udev_device_unref(dev); + } + } + + // Sort the udev entries by devnode name so that they are created in the proper order + qsort(sorted, sorted_count, sizeof(struct joypad_udev_entry), sort_devnodes); + + for (i = 0; i < sorted_count; i++) + { + const char *name = udev_list_entry_get_name(sorted[i].item); + struct udev_device *dev = udev_device_new_from_syspath(udev_joypad_fd, name); + const char *devnode = udev_device_get_devnode(dev); + if (devnode) udev_check_device(dev, devnode); udev_device_unref(dev); From c950613098404c6438dd12578c6c791cd54bd901 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 11 Dec 2017 11:28:48 +0100 Subject: [PATCH 300/394] C comments --- input/drivers_joypad/udev_joypad.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/input/drivers_joypad/udev_joypad.c b/input/drivers_joypad/udev_joypad.c index 902367ee67..0bd8c0598e 100644 --- a/input/drivers_joypad/udev_joypad.c +++ b/input/drivers_joypad/udev_joypad.c @@ -532,7 +532,7 @@ static void udev_joypad_poll(void) } } -// Used for sorting devnodes to appear in the correct order +/* Used for sorting devnodes to appear in the correct order */ static int sort_devnodes(const void *a, const void *b) { const struct joypad_udev_entry *aa = a; @@ -589,8 +589,10 @@ static bool udev_joypad_init(void *data) } } - // Sort the udev entries by devnode name so that they are created in the proper order - qsort(sorted, sorted_count, sizeof(struct joypad_udev_entry), sort_devnodes); + /* Sort the udev entries by devnode name so that they are + * created in the proper order */ + qsort(sorted, sorted_count, + sizeof(struct joypad_udev_entry), sort_devnodes); for (i = 0; i < sorted_count; i++) { From e1461cc0de8bca4f3469783a176ff845b19698a0 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 11 Dec 2017 11:40:36 +0100 Subject: [PATCH 301/394] Get rid of hashes in config_file.c --- libretro-common/file/config_file.c | 24 ++++++------------- libretro-common/include/streams/file_stream.h | 5 ---- 2 files changed, 7 insertions(+), 22 deletions(-) diff --git a/libretro-common/file/config_file.c b/libretro-common/file/config_file.c index c7b6a92f24..334c9df62a 100644 --- a/libretro-common/file/config_file.c +++ b/libretro-common/file/config_file.c @@ -44,7 +44,6 @@ #include #include #include -#include #include #define MAX_INCLUDE_DEPTH 16 @@ -54,7 +53,6 @@ struct config_entry_list /* If we got this from an #include, * do not allow overwrite. */ bool readonly; - uint32_t key_hash; char *key; char *value; @@ -313,11 +311,11 @@ static bool parse_line(config_file_t *conf, key[idx++] = *line++; } - key[idx] = '\0'; - list->key = key; - list->key_hash = djb2_calculate(key); + key[idx] = '\0'; + list->key = key; + + list->value = extract_value(line, true); - list->value = extract_value(line, true); if (!list->value) { list->key = NULL; @@ -378,7 +376,6 @@ static config_file_t *config_file_new_internal( } list->readonly = false; - list->key_hash = 0; list->key = NULL; list->value = NULL; list->next = NULL; @@ -510,7 +507,6 @@ config_file_t *config_file_new_from_string(const char *from_string) } list->readonly = false; - list->key_hash = 0; list->key = NULL; list->value = NULL; list->next = NULL; @@ -545,17 +541,12 @@ config_file_t *config_file_new(const char *path) static struct config_entry_list *config_get_entry(const config_file_t *conf, const char *key, struct config_entry_list **prev) { - struct config_entry_list *entry; - struct config_entry_list *previous = NULL; - - uint32_t hash = djb2_calculate(key); - - if (prev) - previous = *prev; + struct config_entry_list *entry = NULL; + struct config_entry_list *previous = prev ? *prev : NULL; for (entry = conf->entries; entry; entry = entry->next) { - if (hash == entry->key_hash && string_is_equal(key, entry->key)) + if (string_is_equal(key, entry->key)) return entry; previous = entry; @@ -775,7 +766,6 @@ void config_set_string(config_file_t *conf, const char *key, const char *val) return; entry->readonly = false; - entry->key_hash = 0; entry->key = strdup(key); entry->value = strdup(val); entry->next = NULL; diff --git a/libretro-common/include/streams/file_stream.h b/libretro-common/include/streams/file_stream.h index c1b6fe951a..be380f0fc6 100644 --- a/libretro-common/include/streams/file_stream.h +++ b/libretro-common/include/streams/file_stream.h @@ -100,11 +100,6 @@ int filestream_printf(RFILE *stream, const char* format, ...); int filestream_error(RFILE *stream); -/* DO NOT put these functions back, unless you want to deal with - the UNAVOIDABLE REGRESSIONS on platforms using unexpected rfile backends -int filestream_get_fd(RFILE *stream); -FILE* filestream_get_fp(RFILE *stream); */ - int filestream_flush(RFILE *stream); static INLINE char *filestream_getline(RFILE *stream) From 93ee4df5f5bce7fc5d66ff63285823cd5fb98d7e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 11 Dec 2017 11:47:13 +0100 Subject: [PATCH 302/394] Move RFILE_HINT_UNBUFFERED to file_stream.c --- libretro-common/include/streams/file_stream.h | 2 -- libretro-common/streams/file_stream.c | 2 ++ 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libretro-common/include/streams/file_stream.h b/libretro-common/include/streams/file_stream.h index be380f0fc6..95d39a7c99 100644 --- a/libretro-common/include/streams/file_stream.h +++ b/libretro-common/include/streams/file_stream.h @@ -41,8 +41,6 @@ RETRO_BEGIN_DECLS typedef struct RFILE RFILE; #define RFILE_HINT_NONE (0) -/* There is no guarantee these requests will be attended. */ -#define RFILE_HINT_UNBUFFERED (1 << 8) /* requires RFILE_MODE_READ */ #define RFILE_HINT_MMAP (1 << 9) diff --git a/libretro-common/streams/file_stream.c b/libretro-common/streams/file_stream.c index 3759e33090..30ea5eec52 100644 --- a/libretro-common/streams/file_stream.c +++ b/libretro-common/streams/file_stream.c @@ -74,6 +74,8 @@ #endif +#define RFILE_HINT_UNBUFFERED (1 << 8) + #include #include #include From 318f17c4cb20a87d25efc0d81c1b3b3d4359bb2d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 11 Dec 2017 12:15:00 +0100 Subject: [PATCH 303/394] Start using VFS API constant defines --- cheevos/cheevos.c | 2 +- configuration.c | 7 ++++--- gfx/drivers/gx_gfx.c | 4 +++- gfx/video_shader_parse.c | 4 +++- libretro-common/features/features_cpu.c | 2 +- libretro-common/file/config_file.c | 2 +- libretro-common/file/file_path.c | 4 +++- libretro-common/formats/bmp/rbmp_encode.c | 3 ++- libretro-common/formats/png/rpng_encode.c | 3 ++- libretro-common/formats/xml/rxml.c | 3 ++- libretro-common/hash/rhash.c | 3 ++- libretro-common/include/libretro.h | 7 +++++++ libretro-common/include/streams/file_stream.h | 14 +++++--------- libretro-common/streams/file_stream.c | 16 ++++++++++------ libretro-common/streams/file_stream_transforms.c | 11 ++++++----- libretro-db/c_converter.c | 3 ++- libretro-db/libretrodb.c | 16 ++++++++++------ libretro-db/lua/lua_converter.c | 3 ++- libretro-db/lua/testlib.c | 3 ++- libretro-db/rmsgpack_test.c | 5 +++-- menu/menu_setting.c | 3 ++- movie.c | 6 ++++-- playlist.c | 5 +++-- tasks/task_database.c | 7 ++++--- tasks/task_database_cue.c | 9 ++++++--- tasks/task_save.c | 7 ++++--- 26 files changed, 94 insertions(+), 58 deletions(-) diff --git a/cheevos/cheevos.c b/cheevos/cheevos.c index e92c796397..08af2a72be 100644 --- a/cheevos/cheevos.c +++ b/cheevos/cheevos.c @@ -2641,7 +2641,7 @@ static int cheevos_iterate(coro_t* coro) if (!CHEEVOS_VAR_DATA) { CHEEVOS_VAR_STREAM = filestream_open(CHEEVOS_VAR_PATH, - RFILE_MODE_READ, RFILE_HINT_NONE); + RETRO_VFS_FILE_ACCESS_READ, RFILE_HINT_NONE); if (!CHEEVOS_VAR_STREAM) CORO_STOP(); diff --git a/configuration.c b/configuration.c index bb4ef4cc3e..77975d470e 100644 --- a/configuration.c +++ b/configuration.c @@ -19,6 +19,7 @@ #include +#include #include #include #include @@ -3792,17 +3793,17 @@ bool config_save_file(const char *path) #ifdef HAVE_LAKKA if (settings->bools.ssh_enable) filestream_close(filestream_open(LAKKA_SSH_PATH, - RFILE_MODE_WRITE, RFILE_HINT_NONE)); + RETRO_VFS_FILE_ACCESS_WRITE, RFILE_HINT_NONE)); else path_file_remove(LAKKA_SSH_PATH); if (settings->bools.samba_enable) filestream_close(filestream_open(LAKKA_SAMBA_PATH, - RFILE_MODE_WRITE, RFILE_HINT_NONE)); + RETRO_VFS_FILE_ACCESS_WRITE, RFILE_HINT_NONE)); else path_file_remove(LAKKA_SAMBA_PATH); if (settings->bools.bluetooth_enable) filestream_close(filestream_open(LAKKA_BLUETOOTH_PATH, - RFILE_MODE_WRITE, RFILE_HINT_NONE)); + RETRO_VFS_FILE_ACCESS_WRITE, RFILE_HINT_NONE)); else path_file_remove(LAKKA_BLUETOOTH_PATH); #endif diff --git a/gfx/drivers/gx_gfx.c b/gfx/drivers/gx_gfx.c index 0aa1e9c976..c4886f199e 100644 --- a/gfx/drivers/gx_gfx.c +++ b/gfx/drivers/gx_gfx.c @@ -21,6 +21,7 @@ #include #include +#include #include #ifdef HAVE_CONFIG_H @@ -719,7 +720,8 @@ static void gx_efb_screenshot(void) { int x, y; uint8_t tga_header[] = {0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x02, 0xE0, 0x01, 0x18, 0x00}; - RFILE *out = filestream_open("/screenshot.tga", RFILE_MODE_WRITE, RFILE_HINT_NONE); + RFILE *out = filestream_open("/screenshot.tga", + RETRO_VFS_FILE_ACCESS_WRITE, RFILE_HINT_NONE); if (!out) return; diff --git a/gfx/video_shader_parse.c b/gfx/video_shader_parse.c index 0d3a6434cb..32cdae25c4 100644 --- a/gfx/video_shader_parse.c +++ b/gfx/video_shader_parse.c @@ -17,6 +17,7 @@ #include #include +#include #include #include #include @@ -545,7 +546,8 @@ bool video_shader_resolve_parameters(config_file_t *conf, /* If that doesn't work, fallback to the old path. * Ideally, we'd get rid of this path sooner or later. */ #endif - file = filestream_open(path, RFILE_MODE_READ, RFILE_HINT_NONE); + file = filestream_open(path, + RETRO_VFS_FILE_ACCESS_READ, RFILE_HINT_NONE); if (!file) { diff --git a/libretro-common/features/features_cpu.c b/libretro-common/features/features_cpu.c index a52df70056..a64be01004 100644 --- a/libretro-common/features/features_cpu.c +++ b/libretro-common/features/features_cpu.c @@ -321,7 +321,7 @@ static unsigned char check_arm_cpu_feature(const char* feature) char line[1024]; unsigned char status = 0; RFILE *fp = filestream_open("/proc/cpuinfo", - RFILE_MODE_READ, RFILE_HINT_NONE); + RETRO_VFS_FILE_ACCESS_READ, RFILE_HINT_NONE); if (!fp) return 0; diff --git a/libretro-common/file/config_file.c b/libretro-common/file/config_file.c index 334c9df62a..4ab05e7e47 100644 --- a/libretro-common/file/config_file.c +++ b/libretro-common/file/config_file.c @@ -355,7 +355,7 @@ static config_file_t *config_file_new_internal( conf->include_depth = depth; file = filestream_open(path, - RFILE_MODE_READ, RFILE_HINT_NONE); + RETRO_VFS_FILE_ACCESS_READ, RFILE_HINT_NONE); if (!file) { diff --git a/libretro-common/file/file_path.c b/libretro-common/file/file_path.c index f5493017e5..f5e7eccd73 100644 --- a/libretro-common/file/file_path.c +++ b/libretro-common/file/file_path.c @@ -28,6 +28,7 @@ #include +#include #include #include #include @@ -410,7 +411,8 @@ bool path_file_exists(const char *path) if (!path || !*path) return false; - dummy = filestream_open(path, RFILE_MODE_READ, RFILE_HINT_NONE); + dummy = filestream_open(path, + RETRO_VFS_FILE_ACCESS_READ, RFILE_HINT_NONE); if (!dummy) return false; diff --git a/libretro-common/formats/bmp/rbmp_encode.c b/libretro-common/formats/bmp/rbmp_encode.c index 9a30b27a92..c0502d8e52 100644 --- a/libretro-common/formats/bmp/rbmp_encode.c +++ b/libretro-common/formats/bmp/rbmp_encode.c @@ -215,7 +215,8 @@ bool rbmp_save_image( unsigned pitch, enum rbmp_source_type type) { bool ret = false; - RFILE *file = filestream_open(filename, RFILE_MODE_WRITE, RFILE_HINT_NONE); + RFILE *file = filestream_open(filename, + RETRO_VFS_FILE_ACCESS_WRITE, RFILE_HINT_NONE); if (!file) return false; diff --git a/libretro-common/formats/png/rpng_encode.c b/libretro-common/formats/png/rpng_encode.c index ab67614a73..9be5f857c1 100644 --- a/libretro-common/formats/png/rpng_encode.c +++ b/libretro-common/formats/png/rpng_encode.c @@ -227,7 +227,8 @@ static bool rpng_save_image(const char *path, void *stream = NULL; uint32_t total_in = 0; uint32_t total_out = 0; - RFILE *file = filestream_open(path, RFILE_MODE_WRITE, RFILE_HINT_NONE); + RFILE *file = filestream_open(path, + RETRO_VFS_FILE_ACCESS_WRITE, RFILE_HINT_NONE); if (!file) GOTO_END_ERROR(); diff --git a/libretro-common/formats/xml/rxml.c b/libretro-common/formats/xml/rxml.c index b00129c99c..2bac625b74 100644 --- a/libretro-common/formats/xml/rxml.c +++ b/libretro-common/formats/xml/rxml.c @@ -419,7 +419,8 @@ rxml_document_t *rxml_load_document(const char *path) char *new_memory_buffer = NULL; const char *mem_ptr = NULL; long len = 0; - RFILE *file = filestream_open(path, RFILE_MODE_READ, RFILE_HINT_NONE); + RFILE *file = filestream_open(path, + RETRO_VFS_FILE_ACCESS_READ, RFILE_HINT_NONE); if (!file) return NULL; diff --git a/libretro-common/hash/rhash.c b/libretro-common/hash/rhash.c index 03f96d7e92..3ba15eeda8 100644 --- a/libretro-common/hash/rhash.c +++ b/libretro-common/hash/rhash.c @@ -511,7 +511,8 @@ int sha1_calculate(const char *path, char *result) SHA1Context sha; unsigned char buff[4096]; int rv = 1; - RFILE *fd = filestream_open(path, RFILE_MODE_READ, RFILE_HINT_NONE); + RFILE *fd = filestream_open(path, + RETRO_VFS_FILE_ACCESS_READ, RFILE_HINT_NONE); if (!fd) goto error; diff --git a/libretro-common/include/libretro.h b/libretro-common/include/libretro.h index b900ac93e6..b10f18b968 100644 --- a/libretro-common/include/libretro.h +++ b/libretro-common/include/libretro.h @@ -1044,6 +1044,13 @@ struct retro_hw_render_context_negotiation_interface * recognize or support. Should be set in either retro_init or retro_load_game, but not both. */ +/* File open flags + * Introduced in VFS API v1 */ +#define RETRO_VFS_FILE_ACCESS_READ (1 << 0) /* Read only mode */ +#define RETRO_VFS_FILE_ACCESS_WRITE (1 << 1) /* Write only mode, discard contents and overwrites existing file unless RETRO_VFS_FILE_ACCESS_UPDATE is also specified */ +#define RETRO_VFS_FILE_ACCESS_READ_WRITE (RETRO_VFS_FILE_ACCESS_READ | RETRO_VFS_FILE_ACCESS_WRITE) /* Read-write mode, discard contents and overwrites existing file unless RETRO_VFS_FILE_ACCESS_UPDATE is also specified*/ +#define RETRO_VFS_FILE_ACCESS_UPDATE_EXISTING (1 << 2) /* Prevents discarding content of existing files opened for writing */ + #define RETRO_MEMDESC_CONST (1 << 0) /* The frontend will never change this memory area once retro_load_game has returned. */ #define RETRO_MEMDESC_BIGENDIAN (1 << 1) /* The memory area contains big endian data. Default is little endian. */ diff --git a/libretro-common/include/streams/file_stream.h b/libretro-common/include/streams/file_stream.h index 95d39a7c99..faf154723c 100644 --- a/libretro-common/include/streams/file_stream.h +++ b/libretro-common/include/streams/file_stream.h @@ -30,6 +30,7 @@ #include +#include #include #include #include @@ -40,16 +41,11 @@ RETRO_BEGIN_DECLS typedef struct RFILE RFILE; -#define RFILE_HINT_NONE (0) -/* requires RFILE_MODE_READ */ -#define RFILE_HINT_MMAP (1 << 9) +#define FILESTREAM_REQUIRED_VFS_VERSION 1 -enum -{ - RFILE_MODE_READ = 0, - RFILE_MODE_WRITE, - RFILE_MODE_READ_WRITE -}; +#define RFILE_HINT_NONE (0) +/* requires RETRO_VFS_FILE_ACCESS_READ */ +#define RFILE_HINT_MMAP (1 << 9) int64_t filestream_get_size(RFILE *stream); diff --git a/libretro-common/streams/file_stream.c b/libretro-common/streams/file_stream.c index 30ea5eec52..59468832fb 100644 --- a/libretro-common/streams/file_stream.c +++ b/libretro-common/streams/file_stream.c @@ -164,7 +164,7 @@ RFILE *filestream_open(const char *path, unsigned mode, unsigned hints) stream->hints = hints; #ifdef HAVE_MMAP - if (stream->hints & RFILE_HINT_MMAP && mode == RFILE_MODE_READ) + if (stream->hints & RFILE_HINT_MMAP && mode == RETRO_VFS_FILE_ACCESS_READ) stream->hints |= RFILE_HINT_UNBUFFERED; else #endif @@ -172,13 +172,13 @@ RFILE *filestream_open(const char *path, unsigned mode, unsigned hints) switch (mode) { - case RFILE_MODE_READ: + case RETRO_VFS_FILE_ACCESS_READ: if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0) mode_str = MODE_STR_READ_UNBUF; /* No "else" here */ flags = O_RDONLY; break; - case RFILE_MODE_WRITE: + case RETRO_VFS_FILE_ACCESS_WRITE: if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0) mode_str = MODE_STR_WRITE_UNBUF; else @@ -189,7 +189,7 @@ RFILE *filestream_open(const char *path, unsigned mode, unsigned hints) #endif } break; - case RFILE_MODE_READ_WRITE: + case RETRO_VFS_FILE_ACCESS_READ_WRITE: if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0) mode_str = MODE_STR_WRITE_PLUS; else @@ -200,6 +200,9 @@ RFILE *filestream_open(const char *path, unsigned mode, unsigned hints) #endif } break; + /* TODO/FIXME - implement */ + case RETRO_VFS_FILE_ACCESS_UPDATE_EXISTING: + break; } if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0 && mode_str) @@ -550,7 +553,7 @@ int filestream_read_file(const char *path, void **buf, ssize_t *len) ssize_t content_buf_size = 0; void *content_buf = NULL; RFILE *file = filestream_open(path, - RFILE_MODE_READ, RFILE_HINT_NONE); + RETRO_VFS_FILE_ACCESS_READ, RFILE_HINT_NONE); if (!file) { @@ -616,7 +619,8 @@ error: bool filestream_write_file(const char *path, const void *data, ssize_t size) { ssize_t ret = 0; - RFILE *file = filestream_open(path, RFILE_MODE_WRITE, RFILE_HINT_NONE); + RFILE *file = filestream_open(path, + RETRO_VFS_FILE_ACCESS_WRITE, RFILE_HINT_NONE); if (!file) return false; diff --git a/libretro-common/streams/file_stream_transforms.c b/libretro-common/streams/file_stream_transforms.c index cec3a4c458..0833040be3 100644 --- a/libretro-common/streams/file_stream_transforms.c +++ b/libretro-common/streams/file_stream_transforms.c @@ -19,22 +19,23 @@ * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ - -#include #include #include +#include +#include + RFILE* rfopen(const char *path, const char *mode) { unsigned int retro_mode = 0; if (strstr(mode, "r")) if (strstr(mode, "b")) - retro_mode = RFILE_MODE_READ; + retro_mode = RETRO_VFS_FILE_ACCESS_READ; if (strstr(mode, "w")) - retro_mode = RFILE_MODE_WRITE; + retro_mode = RETRO_VFS_FILE_ACCESS_WRITE; if (strstr(mode, "+")) - retro_mode = RFILE_MODE_READ_WRITE; + retro_mode = RETRO_VFS_FILE_ACCESS_READ_WRITE; return filestream_open(path, retro_mode, -1); } diff --git a/libretro-db/c_converter.c b/libretro-db/c_converter.c index edc8c10cf1..3dc51496c3 100644 --- a/libretro-db/c_converter.c +++ b/libretro-db/c_converter.c @@ -804,7 +804,8 @@ int main(int argc, char** argv) dat_buffer++; } - rdb_file = filestream_open(rdb_path, RFILE_MODE_WRITE, RFILE_HINT_NONE); + rdb_file = filestream_open(rdb_path, + RETRO_VFS_FILE_ACCESS_WRITE, RFILE_HINT_NONE); if (!rdb_file) { diff --git a/libretro-db/libretrodb.c b/libretro-db/libretrodb.c index 1ba782afe8..5deed1d426 100644 --- a/libretro-db/libretrodb.c +++ b/libretro-db/libretrodb.c @@ -216,8 +216,9 @@ int libretrodb_open(const char *path, libretrodb_t *db) { libretrodb_header_t header; libretrodb_metadata_t md; - int rv; - RFILE *fd = filestream_open(path, RFILE_MODE_READ, RFILE_HINT_NONE); + int rv = 0; + RFILE *fd = filestream_open(path, + RETRO_VFS_FILE_ACCESS_READ, RFILE_HINT_NONE); if (!fd) return -errno; @@ -428,18 +429,21 @@ void libretrodb_cursor_close(libretrodb_cursor_t *cursor) int libretrodb_cursor_open(libretrodb_t *db, libretrodb_cursor_t *cursor, libretrodb_query_t *q) { + RFILE *fd = NULL; if (!db || string_is_empty(db->path)) return -errno; - cursor->fd = filestream_open(db->path, RFILE_MODE_READ, RFILE_HINT_MMAP); + fd = filestream_open(db->path, + RETRO_VFS_FILE_ACCESS_READ, RFILE_HINT_MMAP); - if (!cursor->fd) + if (!fd) return -errno; - cursor->db = db; + cursor->fd = fd; + cursor->db = db; cursor->is_valid = 1; libretrodb_cursor_reset(cursor); - cursor->query = q; + cursor->query = q; if (q) libretrodb_query_inc_ref(q); diff --git a/libretro-db/lua/lua_converter.c b/libretro-db/lua/lua_converter.c index 2c70a7bc3b..81c495f455 100644 --- a/libretro-db/lua/lua_converter.c +++ b/libretro-db/lua/lua_converter.c @@ -92,7 +92,8 @@ int main(int argc, char ** argv) call_init(L, argc - 2, (const char **) argv + 2); - dst = filestream_open(db_file, RFILE_MODE_WRITE, RFILE_HINT_NONE); + dst = filestream_open(db_file, + RETRO_VFS_FILE_ACCESS_WRITE, RFILE_HINT_NONE); if (!dst) { diff --git a/libretro-db/lua/testlib.c b/libretro-db/lua/testlib.c index b2c9874db7..bc5bd56a4c 100644 --- a/libretro-db/lua/testlib.c +++ b/libretro-db/lua/testlib.c @@ -106,7 +106,8 @@ static int create_db(lua_State *L) } lua_setfield(L, LUA_REGISTRYINDEX, "testlib_get_value"); - dst = filestream_open(db_file, RFILE_MODE_WRITE, RFILE_HINT_NONE); + dst = filestream_open(db_file, + RETRO_VFS_FILE_ACCESS_WRITE, RFILE_HINT_NONE); if (!dst) { lua_pushstring(L, "Could not open destination file"); diff --git a/libretro-db/rmsgpack_test.c b/libretro-db/rmsgpack_test.c index b1e74dc981..c6383cdc0e 100644 --- a/libretro-db/rmsgpack_test.c +++ b/libretro-db/rmsgpack_test.c @@ -186,9 +186,10 @@ static struct rmsgpack_read_callbacks stub_callbacks = { int main(void) { struct stub_state state; - RFILE *fd = filestream_open("test.msgpack", RFILE_MODE_READ, RFILE_HINT_NONE); + RFILE *fd = filestream_open("test.msgpack", + RETRO_VFS_FILE_ACCESS_READ, RFILE_HINT_NONE); - state.i = 0; + state.i = 0; state.stack[0] = 0; rmsgpack_read(fd, &stub_callbacks, &state); diff --git a/menu/menu_setting.c b/menu/menu_setting.c index cddca2d23f..f2307cfbc3 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -22,6 +22,7 @@ #include #endif +#include #include #include #include @@ -1877,7 +1878,7 @@ static void systemd_service_toggle(const char *path, char *unit, bool enable) if (enable) filestream_close(filestream_open(path, - RFILE_MODE_WRITE, RFILE_HINT_NONE)); + RETRO_VFS_FILE_ACCESS_WRITE, RFILE_HINT_NONE)); else path_file_remove(path); diff --git a/movie.c b/movie.c index 0135d1c332..9e6e6bcc04 100644 --- a/movie.c +++ b/movie.c @@ -75,7 +75,8 @@ static bool bsv_movie_init_playback(bsv_movie_t *handle, const char *path) uint32_t state_size = 0; uint32_t content_crc = 0; uint32_t header[4] = {0}; - RFILE *file = filestream_open(path, RFILE_MODE_READ, RFILE_HINT_NONE); + RFILE *file = filestream_open(path, + RETRO_VFS_FILE_ACCESS_READ, RFILE_HINT_NONE); if (!file) { @@ -152,7 +153,8 @@ static bool bsv_movie_init_record(bsv_movie_t *handle, const char *path) uint32_t state_size = 0; uint32_t content_crc = 0; uint32_t header[4] = {0}; - RFILE *file = filestream_open(path, RFILE_MODE_WRITE, RFILE_HINT_NONE); + RFILE *file = filestream_open(path, + RETRO_VFS_FILE_ACCESS_WRITE, RFILE_HINT_NONE); if (!file) { diff --git a/playlist.c b/playlist.c index f79278a4ef..2168272214 100644 --- a/playlist.c +++ b/playlist.c @@ -18,6 +18,7 @@ #include #include +#include #include #include #include @@ -394,7 +395,7 @@ void playlist_write_file(playlist_t *playlist) return; file = filestream_open(playlist->conf_path, - RFILE_MODE_WRITE, RFILE_HINT_NONE); + RETRO_VFS_FILE_ACCESS_WRITE, RFILE_HINT_NONE); if (!file) { @@ -494,7 +495,7 @@ static bool playlist_read_file( unsigned i; char buf[PLAYLIST_ENTRIES][1024]; RFILE *file = filestream_open( - path, RFILE_MODE_READ, RFILE_HINT_NONE); + path, RETRO_VFS_FILE_ACCESS_READ, RFILE_HINT_NONE); for (i = 0; i < PLAYLIST_ENTRIES; i++) buf[i][0] = '\0'; diff --git a/tasks/task_database.c b/tasks/task_database.c index 10382a4853..14e4af2a88 100644 --- a/tasks/task_database.c +++ b/tasks/task_database.c @@ -101,7 +101,7 @@ static intfstream_t* intfstream_open_file(const char *path) if (!fd) return NULL; - if (!intfstream_open(fd, path, RFILE_MODE_READ, RFILE_HINT_NONE)) + if (!intfstream_open(fd, path, RETRO_VFS_FILE_ACCESS_READ, RFILE_HINT_NONE)) goto error; return fd; @@ -130,7 +130,7 @@ static intfstream_t *open_memory(void *data, size_t size) if (!fd) return NULL; - if (!intfstream_open(fd, NULL, RFILE_MODE_READ, RFILE_HINT_NONE)) + if (!intfstream_open(fd, NULL, RETRO_VFS_FILE_ACCESS_READ, RFILE_HINT_NONE)) goto error; return fd; @@ -158,7 +158,8 @@ open_chd_track(const char *path, int32_t track) if (!fd) return NULL; - if (!intfstream_open(fd, path, RFILE_MODE_READ, RFILE_HINT_NONE)) + if (!intfstream_open(fd, path, + RETRO_VFS_FILE_ACCESS_READ, RFILE_HINT_NONE)) goto error; return fd; diff --git a/tasks/task_database_cue.c b/tasks/task_database_cue.c index 5e3ef10d51..ae134aee63 100644 --- a/tasks/task_database_cue.c +++ b/tasks/task_database_cue.c @@ -413,7 +413,8 @@ clean: static ssize_t get_file_size(const char *path) { ssize_t rv; - RFILE *fd = filestream_open(path, RFILE_MODE_READ, RFILE_HINT_NONE); + RFILE *fd = filestream_open(path, + RETRO_VFS_FILE_ACCESS_READ, RFILE_HINT_NONE); if (fd == NULL) return -1; rv = filestream_get_size(fd); @@ -467,7 +468,8 @@ int cue_find_track(const char *cue_path, bool first, if (!fd) goto error; - if (!intfstream_open(fd, cue_path, RFILE_MODE_READ, RFILE_HINT_NONE)) + if (!intfstream_open(fd, cue_path, + RETRO_VFS_FILE_ACCESS_READ, RFILE_HINT_NONE)) { RARCH_LOG("Could not open CUE file '%s': %s\n", cue_path, strerror(errno)); @@ -621,7 +623,8 @@ int gdi_find_track(const char *gdi_path, bool first, if (!fd) goto error; - if (!intfstream_open(fd, gdi_path, RFILE_MODE_READ, RFILE_HINT_NONE)) + if (!intfstream_open(fd, gdi_path, + RETRO_VFS_FILE_ACCESS_READ, RFILE_HINT_NONE)) { RARCH_LOG("Could not open GDI file '%s': %s\n", gdi_path, strerror(errno)); diff --git a/tasks/task_save.c b/tasks/task_save.c index e1b64f9c90..5d29865a6a 100644 --- a/tasks/task_save.c +++ b/tasks/task_save.c @@ -158,7 +158,7 @@ static void autosave_thread(void *data) { /* Should probably deal with this more elegantly. */ RFILE *file = filestream_open(save->path, - RFILE_MODE_WRITE, RFILE_HINT_NONE); + RETRO_VFS_FILE_ACCESS_WRITE, RFILE_HINT_NONE); if (file) { @@ -565,7 +565,7 @@ static void task_save_handler(retro_task_t *task) if (!state->file) { - state->file = filestream_open(state->path, RFILE_MODE_WRITE, + state->file = filestream_open(state->path, RETRO_VFS_FILE_ACCESS_WRITE, RFILE_HINT_NONE); if (!state->file) @@ -738,7 +738,8 @@ static void task_load_handler(retro_task_t *task) if (!state->file) { - state->file = filestream_open(state->path, RFILE_MODE_READ, + state->file = filestream_open(state->path, + RETRO_VFS_FILE_ACCESS_READ, RFILE_HINT_NONE); if (!state->file) From 6897f9a987e71f2a1585e9ac1035ede843d8dc6f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 11 Dec 2017 12:20:06 +0100 Subject: [PATCH 304/394] Pass hints to intfstream_open_file --- tasks/task_database.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/tasks/task_database.c b/tasks/task_database.c index 14e4af2a88..8d1b8f3325 100644 --- a/tasks/task_database.c +++ b/tasks/task_database.c @@ -90,7 +90,7 @@ int detect_gc_game(intfstream_t *fd, char *game_id); int detect_serial_ascii_game(intfstream_t *fd, char *game_id); -static intfstream_t* intfstream_open_file(const char *path) +static intfstream_t* intfstream_open_file(const char *path, unsigned hints) { intfstream_info_t info; intfstream_t *fd = NULL; @@ -101,7 +101,7 @@ static intfstream_t* intfstream_open_file(const char *path) if (!fd) return NULL; - if (!intfstream_open(fd, path, RETRO_VFS_FILE_ACCESS_READ, RFILE_HINT_NONE)) + if (!intfstream_open(fd, path, RETRO_VFS_FILE_ACCESS_READ, hints)) goto error; return fd; @@ -289,7 +289,7 @@ static bool intfstream_file_get_serial(const char *name, int rv; uint8_t *data = NULL; ssize_t file_size = -1; - intfstream_t *fd = intfstream_open_file(name); + intfstream_t *fd = intfstream_open_file(name, RFILE_HINT_NONE); if (!fd) return 0; @@ -432,7 +432,7 @@ static bool intfstream_file_get_crc(const char *name, size_t offset, size_t size, uint32_t *crc) { int rv; - intfstream_t *fd = intfstream_open_file(name); + intfstream_t *fd = intfstream_open_file(name, RFILE_HINT_NONE); uint8_t *data = NULL; ssize_t file_size = -1; @@ -574,7 +574,7 @@ static void task_database_cue_prune(database_info_handle_t *db, { size_t i; char *path = (char *)malloc(PATH_MAX_LENGTH + 1); - intfstream_t *fd = intfstream_open_file(name); + intfstream_t *fd = intfstream_open_file(name, RFILE_HINT_NONE); if (!fd) goto end; @@ -606,7 +606,7 @@ static void gdi_prune(database_info_handle_t *db, const char *name) { size_t i; char *path = (char *)malloc(PATH_MAX_LENGTH + 1); - intfstream_t *fd = intfstream_open_file(name); + intfstream_t *fd = intfstream_open_file(name, RFILE_HINT_NONE); if (!fd) goto end; From 8aa4d6d1487a6961ef6d9c089d335fd9ef0c3c40 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 11 Dec 2017 12:23:40 +0100 Subject: [PATCH 305/394] Move convenience functions to interface_stream.c --- .../include/streams/interface_stream.h | 9 ++ libretro-common/streams/interface_stream.c | 83 ++++++++++++++++ tasks/task_database.c | 95 ++----------------- 3 files changed, 100 insertions(+), 87 deletions(-) diff --git a/libretro-common/include/streams/interface_stream.h b/libretro-common/include/streams/interface_stream.h index b6d437e058..a0a26caeba 100644 --- a/libretro-common/include/streams/interface_stream.h +++ b/libretro-common/include/streams/interface_stream.h @@ -90,6 +90,15 @@ void intfstream_putc(intfstream_internal_t *intf, int c); int intfstream_close(intfstream_internal_t *intf); +intfstream_t* intfstream_open_file(const char *path, + unsigned hints); + +intfstream_t *intfstream_open_memory(void *data, + size_t size, unsigned hints); + +intfstream_t *intfstream_open_chd_track(const char *path, + int32_t track, unsigned hints); + RETRO_END_DECLS #endif diff --git a/libretro-common/streams/interface_stream.c b/libretro-common/streams/interface_stream.c index 0f4f175197..0363231b56 100644 --- a/libretro-common/streams/interface_stream.c +++ b/libretro-common/streams/interface_stream.c @@ -340,3 +340,86 @@ void intfstream_putc(intfstream_internal_t *intf, int c) break; } } + +intfstream_t* intfstream_open_file(const char *path, unsigned hints) +{ + intfstream_info_t info; + intfstream_t *fd = NULL; + + info.type = INTFSTREAM_FILE; + fd = (intfstream_t*)intfstream_init(&info); + + if (!fd) + return NULL; + + if (!intfstream_open(fd, path, RETRO_VFS_FILE_ACCESS_READ, hints)) + goto error; + + return fd; + +error: + if (fd) + { + intfstream_close(fd); + free(fd); + } + return NULL; +} + +intfstream_t *intfstream_open_memory(void *data, size_t size, unsigned hints) +{ + intfstream_info_t info; + intfstream_t *fd = NULL; + + info.type = INTFSTREAM_MEMORY; + info.memory.buf.data = (uint8_t*)data; + info.memory.buf.size = size; + info.memory.writable = false; + + fd = (intfstream_t*)intfstream_init(&info); + + if (!fd) + return NULL; + + if (!intfstream_open(fd, NULL, RETRO_VFS_FILE_ACCESS_READ, hints)) + goto error; + + return fd; + +error: + if (fd) + { + intfstream_close(fd); + free(fd); + } + return NULL; +} + +intfstream_t *intfstream_open_chd_track(const char *path, + int32_t track, unsigned hints) +{ + intfstream_info_t info; + intfstream_t *fd = NULL; + + info.type = INTFSTREAM_CHD; + info.chd.track = track; + + fd = (intfstream_t*)intfstream_init(&info); + + if (!fd) + return NULL; + + if (!intfstream_open(fd, path, + RETRO_VFS_FILE_ACCESS_READ, RFILE_HINT_NONE)) + goto error; + + return fd; + +error: + if (fd) + { + intfstream_close(fd); + free(fd); + } + return NULL; +} diff --git a/tasks/task_database.c b/tasks/task_database.c index 8d1b8f3325..7169d65ce4 100644 --- a/tasks/task_database.c +++ b/tasks/task_database.c @@ -90,89 +90,6 @@ int detect_gc_game(intfstream_t *fd, char *game_id); int detect_serial_ascii_game(intfstream_t *fd, char *game_id); -static intfstream_t* intfstream_open_file(const char *path, unsigned hints) -{ - intfstream_info_t info; - intfstream_t *fd = NULL; - - info.type = INTFSTREAM_FILE; - fd = (intfstream_t*)intfstream_init(&info); - - if (!fd) - return NULL; - - if (!intfstream_open(fd, path, RETRO_VFS_FILE_ACCESS_READ, hints)) - goto error; - - return fd; - -error: - if (fd) - { - intfstream_close(fd); - free(fd); - } - return NULL; -} - -static intfstream_t *open_memory(void *data, size_t size) -{ - intfstream_info_t info; - intfstream_t *fd = NULL; - - info.type = INTFSTREAM_MEMORY; - info.memory.buf.data = (uint8_t*)data; - info.memory.buf.size = size; - info.memory.writable = false; - - fd = (intfstream_t*)intfstream_init(&info); - - if (!fd) - return NULL; - - if (!intfstream_open(fd, NULL, RETRO_VFS_FILE_ACCESS_READ, RFILE_HINT_NONE)) - goto error; - - return fd; - -error: - if (fd) - { - intfstream_close(fd); - free(fd); - } - return NULL; -} - -static intfstream_t* -open_chd_track(const char *path, int32_t track) -{ - intfstream_info_t info; - intfstream_t *fd = NULL; - - info.type = INTFSTREAM_CHD; - info.chd.track = track; - - fd = (intfstream_t*)intfstream_init(&info); - - if (!fd) - return NULL; - - if (!intfstream_open(fd, path, - RETRO_VFS_FILE_ACCESS_READ, RFILE_HINT_NONE)) - goto error; - - return fd; - -error: - if (fd) - { - intfstream_close(fd); - free(fd); - } - return NULL; -} - static void database_info_set_type( database_info_handle_t *handle, enum database_type type) @@ -320,7 +237,7 @@ static bool intfstream_file_get_serial(const char *name, intfstream_close(fd); free(fd); - fd = open_memory(data, size); + fd = intfstream_open_memory(data, size, RFILE_HINT_NONE); if (!fd) { free(data); @@ -401,7 +318,9 @@ static int task_database_gdi_get_serial(const char *name, char* serial) static int task_database_chd_get_serial(const char *name, char* serial) { int result; - intfstream_t *fd = open_chd_track(name, CHDSTREAM_TRACK_FIRST_DATA); + intfstream_t *fd = intfstream_open_chd_track( + name, CHDSTREAM_TRACK_FIRST_DATA, + RFILE_HINT_NONE); if (!fd) return 0; @@ -462,7 +381,7 @@ static bool intfstream_file_get_crc(const char *name, intfstream_close(fd); free(fd); - fd = open_memory(data, size); + fd = intfstream_open_memory(data, size, RFILE_HINT_NONE); if (!fd) goto error; @@ -552,7 +471,9 @@ static int task_database_gdi_get_crc(const char *name, uint32_t *crc) static bool task_database_chd_get_crc(const char *name, uint32_t *crc) { int rv; - intfstream_t *fd = open_chd_track(name, CHDSTREAM_TRACK_PRIMARY); + intfstream_t *fd = intfstream_open_chd_track( + name, CHDSTREAM_TRACK_PRIMARY, + RFILE_HINT_NONE); if (!fd) return 0; From fde596fae4f851720f63be6ed3db75fd9c17585b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 11 Dec 2017 12:25:44 +0100 Subject: [PATCH 306/394] Cleanups --- libretro-common/streams/interface_stream.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libretro-common/streams/interface_stream.c b/libretro-common/streams/interface_stream.c index 0363231b56..06a4113526 100644 --- a/libretro-common/streams/interface_stream.c +++ b/libretro-common/streams/interface_stream.c @@ -276,7 +276,7 @@ int intfstream_getc(intfstream_internal_t *intf) #ifdef HAVE_CHD return chdstream_getc(intf->chd.fp); #else - return -1; + break; #endif } @@ -298,7 +298,7 @@ int intfstream_tell(intfstream_internal_t *intf) #ifdef HAVE_CHD return (int)chdstream_tell(intf->chd.fp); #else - return -1; + break; #endif } From 38e6d2443fcd162d17d90f52742c82a3dd8f1d80 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 11 Dec 2017 12:31:14 +0100 Subject: [PATCH 307/394] Change functions --- .../include/streams/interface_stream.h | 6 ++-- libretro-common/streams/interface_stream.c | 15 ++++----- tasks/task_database.c | 31 +++++++++++++------ 3 files changed, 32 insertions(+), 20 deletions(-) diff --git a/libretro-common/include/streams/interface_stream.h b/libretro-common/include/streams/interface_stream.h index a0a26caeba..3a21567d3f 100644 --- a/libretro-common/include/streams/interface_stream.h +++ b/libretro-common/include/streams/interface_stream.h @@ -91,13 +91,13 @@ void intfstream_putc(intfstream_internal_t *intf, int c); int intfstream_close(intfstream_internal_t *intf); intfstream_t* intfstream_open_file(const char *path, - unsigned hints); + unsigned mode, unsigned hints); intfstream_t *intfstream_open_memory(void *data, - size_t size, unsigned hints); + unsigned mode, unsigned hints, size_t size); intfstream_t *intfstream_open_chd_track(const char *path, - int32_t track, unsigned hints); + unsigned mode, unsigned hints, int32_t track); RETRO_END_DECLS diff --git a/libretro-common/streams/interface_stream.c b/libretro-common/streams/interface_stream.c index 06a4113526..78bb4c525a 100644 --- a/libretro-common/streams/interface_stream.c +++ b/libretro-common/streams/interface_stream.c @@ -341,7 +341,8 @@ void intfstream_putc(intfstream_internal_t *intf, int c) } } -intfstream_t* intfstream_open_file(const char *path, unsigned hints) +intfstream_t* intfstream_open_file(const char *path, + unsigned mode, unsigned hints) { intfstream_info_t info; intfstream_t *fd = NULL; @@ -352,7 +353,7 @@ intfstream_t* intfstream_open_file(const char *path, unsigned hints) if (!fd) return NULL; - if (!intfstream_open(fd, path, RETRO_VFS_FILE_ACCESS_READ, hints)) + if (!intfstream_open(fd, path, mode, hints)) goto error; return fd; @@ -366,7 +367,8 @@ error: return NULL; } -intfstream_t *intfstream_open_memory(void *data, size_t size, unsigned hints) +intfstream_t *intfstream_open_memory(void *data, + unsigned mode, unsigned hints, size_t size) { intfstream_info_t info; intfstream_t *fd = NULL; @@ -381,7 +383,7 @@ intfstream_t *intfstream_open_memory(void *data, size_t size, unsigned hints) if (!fd) return NULL; - if (!intfstream_open(fd, NULL, RETRO_VFS_FILE_ACCESS_READ, hints)) + if (!intfstream_open(fd, NULL, mode, hints)) goto error; return fd; @@ -396,7 +398,7 @@ error: } intfstream_t *intfstream_open_chd_track(const char *path, - int32_t track, unsigned hints) + unsigned mode, unsigned hints, int32_t track) { intfstream_info_t info; intfstream_t *fd = NULL; @@ -409,8 +411,7 @@ intfstream_t *intfstream_open_chd_track(const char *path, if (!fd) return NULL; - if (!intfstream_open(fd, path, - RETRO_VFS_FILE_ACCESS_READ, RFILE_HINT_NONE)) + if (!intfstream_open(fd, path, mode, hints)) goto error; return fd; diff --git a/tasks/task_database.c b/tasks/task_database.c index 7169d65ce4..48f59bfbfe 100644 --- a/tasks/task_database.c +++ b/tasks/task_database.c @@ -206,7 +206,8 @@ static bool intfstream_file_get_serial(const char *name, int rv; uint8_t *data = NULL; ssize_t file_size = -1; - intfstream_t *fd = intfstream_open_file(name, RFILE_HINT_NONE); + intfstream_t *fd = intfstream_open_file(name, + RETRO_VFS_FILE_ACCESS_READ, RFILE_HINT_NONE); if (!fd) return 0; @@ -237,7 +238,9 @@ static bool intfstream_file_get_serial(const char *name, intfstream_close(fd); free(fd); - fd = intfstream_open_memory(data, size, RFILE_HINT_NONE); + fd = intfstream_open_memory(data, RETRO_VFS_FILE_ACCESS_READ, + RFILE_HINT_NONE, + size); if (!fd) { free(data); @@ -319,8 +322,10 @@ static int task_database_chd_get_serial(const char *name, char* serial) { int result; intfstream_t *fd = intfstream_open_chd_track( - name, CHDSTREAM_TRACK_FIRST_DATA, - RFILE_HINT_NONE); + name, + RETRO_VFS_FILE_ACCESS_READ, + RFILE_HINT_NONE, + CHDSTREAM_TRACK_FIRST_DATA); if (!fd) return 0; @@ -351,7 +356,8 @@ static bool intfstream_file_get_crc(const char *name, size_t offset, size_t size, uint32_t *crc) { int rv; - intfstream_t *fd = intfstream_open_file(name, RFILE_HINT_NONE); + intfstream_t *fd = intfstream_open_file(name, + RETRO_VFS_FILE_ACCESS_READ, RFILE_HINT_NONE); uint8_t *data = NULL; ssize_t file_size = -1; @@ -381,7 +387,8 @@ static bool intfstream_file_get_crc(const char *name, intfstream_close(fd); free(fd); - fd = intfstream_open_memory(data, size, RFILE_HINT_NONE); + fd = intfstream_open_memory(data, RETRO_VFS_FILE_ACCESS_READ, + RFILE_HINT_NONE, size); if (!fd) goto error; @@ -472,8 +479,10 @@ static bool task_database_chd_get_crc(const char *name, uint32_t *crc) { int rv; intfstream_t *fd = intfstream_open_chd_track( - name, CHDSTREAM_TRACK_PRIMARY, - RFILE_HINT_NONE); + name, + RETRO_VFS_FILE_ACCESS_READ, + RFILE_HINT_NONE, + CHDSTREAM_TRACK_PRIMARY); if (!fd) return 0; @@ -495,7 +504,8 @@ static void task_database_cue_prune(database_info_handle_t *db, { size_t i; char *path = (char *)malloc(PATH_MAX_LENGTH + 1); - intfstream_t *fd = intfstream_open_file(name, RFILE_HINT_NONE); + intfstream_t *fd = intfstream_open_file(name, + RETRO_VFS_FILE_ACCESS_READ, RFILE_HINT_NONE); if (!fd) goto end; @@ -527,7 +537,8 @@ static void gdi_prune(database_info_handle_t *db, const char *name) { size_t i; char *path = (char *)malloc(PATH_MAX_LENGTH + 1); - intfstream_t *fd = intfstream_open_file(name, RFILE_HINT_NONE); + intfstream_t *fd = intfstream_open_file(name, + RETRO_VFS_FILE_ACCESS_READ, RFILE_HINT_NONE); if (!fd) goto end; From 61d3f90cae77f747bc6495f3f247f4911f9fe94b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 11 Dec 2017 12:53:47 +0100 Subject: [PATCH 308/394] Add hint defines to libretro.h --- cheevos/cheevos.c | 6 ++- configuration.c | 9 ++-- gfx/drivers/gx_gfx.c | 3 +- gfx/video_shader_parse.c | 3 +- libretro-common/features/features_cpu.c | 3 +- libretro-common/file/config_file.c | 3 +- libretro-common/file/file_path.c | 3 +- libretro-common/formats/bmp/rbmp_encode.c | 3 +- libretro-common/formats/png/rpng_encode.c | 3 +- libretro-common/formats/xml/rxml.c | 3 +- libretro-common/hash/rhash.c | 3 +- libretro-common/include/libretro.h | 3 ++ libretro-common/include/streams/file_stream.h | 4 -- libretro-common/streams/file_stream.c | 25 ++++++----- libretro-db/c_converter.c | 3 +- libretro-db/libretrodb.c | 6 ++- libretro-db/lua/lua_converter.c | 3 +- libretro-db/lua/testlib.c | 3 +- libretro-db/rmsgpack_test.c | 3 +- menu/menu_setting.c | 3 +- movie.c | 44 ++++++++++--------- playlist.c | 5 ++- tasks/task_database.c | 16 +++---- tasks/task_database_cue.c | 6 +-- tasks/task_save.c | 6 +-- 25 files changed, 100 insertions(+), 72 deletions(-) diff --git a/cheevos/cheevos.c b/cheevos/cheevos.c index 08af2a72be..34f7b5e4d4 100644 --- a/cheevos/cheevos.c +++ b/cheevos/cheevos.c @@ -2640,8 +2640,10 @@ static int cheevos_iterate(coro_t* coro) /* Load the content into memory, or copy it over to our own buffer */ if (!CHEEVOS_VAR_DATA) { - CHEEVOS_VAR_STREAM = filestream_open(CHEEVOS_VAR_PATH, - RETRO_VFS_FILE_ACCESS_READ, RFILE_HINT_NONE); + CHEEVOS_VAR_STREAM = filestream_open( + CHEEVOS_VAR_PATH, + RETRO_VFS_FILE_ACCESS_READ, + RETRO_VFS_FILE_ACCESS_HINT_NONE); if (!CHEEVOS_VAR_STREAM) CORO_STOP(); diff --git a/configuration.c b/configuration.c index 77975d470e..bcb7b0c578 100644 --- a/configuration.c +++ b/configuration.c @@ -3793,17 +3793,20 @@ bool config_save_file(const char *path) #ifdef HAVE_LAKKA if (settings->bools.ssh_enable) filestream_close(filestream_open(LAKKA_SSH_PATH, - RETRO_VFS_FILE_ACCESS_WRITE, RFILE_HINT_NONE)); + RETRO_VFS_FILE_ACCESS_WRITE, + RETRO_VFS_FILE_ACCESS_HINT_NONE)); else path_file_remove(LAKKA_SSH_PATH); if (settings->bools.samba_enable) filestream_close(filestream_open(LAKKA_SAMBA_PATH, - RETRO_VFS_FILE_ACCESS_WRITE, RFILE_HINT_NONE)); + RETRO_VFS_FILE_ACCESS_WRITE, + RETRO_VFS_FILE_ACCESS_HINT_NONE)); else path_file_remove(LAKKA_SAMBA_PATH); if (settings->bools.bluetooth_enable) filestream_close(filestream_open(LAKKA_BLUETOOTH_PATH, - RETRO_VFS_FILE_ACCESS_WRITE, RFILE_HINT_NONE)); + RETRO_VFS_FILE_ACCESS_WRITE, + RETRO_VFS_FILE_ACCESS_HINT_NONE)); else path_file_remove(LAKKA_BLUETOOTH_PATH); #endif diff --git a/gfx/drivers/gx_gfx.c b/gfx/drivers/gx_gfx.c index c4886f199e..ef676d6312 100644 --- a/gfx/drivers/gx_gfx.c +++ b/gfx/drivers/gx_gfx.c @@ -721,7 +721,8 @@ static void gx_efb_screenshot(void) int x, y; uint8_t tga_header[] = {0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x02, 0xE0, 0x01, 0x18, 0x00}; RFILE *out = filestream_open("/screenshot.tga", - RETRO_VFS_FILE_ACCESS_WRITE, RFILE_HINT_NONE); + RETRO_VFS_FILE_ACCESS_WRITE, + RETRO_VFS_FILE_ACCESS_HINT_NONE); if (!out) return; diff --git a/gfx/video_shader_parse.c b/gfx/video_shader_parse.c index 32cdae25c4..d2e8aa7801 100644 --- a/gfx/video_shader_parse.c +++ b/gfx/video_shader_parse.c @@ -547,7 +547,8 @@ bool video_shader_resolve_parameters(config_file_t *conf, * Ideally, we'd get rid of this path sooner or later. */ #endif file = filestream_open(path, - RETRO_VFS_FILE_ACCESS_READ, RFILE_HINT_NONE); + RETRO_VFS_FILE_ACCESS_READ, + RETRO_VFS_FILE_ACCESS_HINT_NONE); if (!file) { diff --git a/libretro-common/features/features_cpu.c b/libretro-common/features/features_cpu.c index a64be01004..0188375999 100644 --- a/libretro-common/features/features_cpu.c +++ b/libretro-common/features/features_cpu.c @@ -321,7 +321,8 @@ static unsigned char check_arm_cpu_feature(const char* feature) char line[1024]; unsigned char status = 0; RFILE *fp = filestream_open("/proc/cpuinfo", - RETRO_VFS_FILE_ACCESS_READ, RFILE_HINT_NONE); + RETRO_VFS_FILE_ACCESS_READ, + RETRO_VFS_FILE_ACCESS_HINT_NONE); if (!fp) return 0; diff --git a/libretro-common/file/config_file.c b/libretro-common/file/config_file.c index 4ab05e7e47..c762efc310 100644 --- a/libretro-common/file/config_file.c +++ b/libretro-common/file/config_file.c @@ -355,7 +355,8 @@ static config_file_t *config_file_new_internal( conf->include_depth = depth; file = filestream_open(path, - RETRO_VFS_FILE_ACCESS_READ, RFILE_HINT_NONE); + RETRO_VFS_FILE_ACCESS_READ, + RETRO_VFS_FILE_ACCESS_HINT_NONE); if (!file) { diff --git a/libretro-common/file/file_path.c b/libretro-common/file/file_path.c index f5e7eccd73..753a1a9c09 100644 --- a/libretro-common/file/file_path.c +++ b/libretro-common/file/file_path.c @@ -412,7 +412,8 @@ bool path_file_exists(const char *path) return false; dummy = filestream_open(path, - RETRO_VFS_FILE_ACCESS_READ, RFILE_HINT_NONE); + RETRO_VFS_FILE_ACCESS_READ, + RETRO_VFS_FILE_ACCESS_HINT_NONE); if (!dummy) return false; diff --git a/libretro-common/formats/bmp/rbmp_encode.c b/libretro-common/formats/bmp/rbmp_encode.c index c0502d8e52..8b22f5ce31 100644 --- a/libretro-common/formats/bmp/rbmp_encode.c +++ b/libretro-common/formats/bmp/rbmp_encode.c @@ -216,7 +216,8 @@ bool rbmp_save_image( { bool ret = false; RFILE *file = filestream_open(filename, - RETRO_VFS_FILE_ACCESS_WRITE, RFILE_HINT_NONE); + RETRO_VFS_FILE_ACCESS_WRITE, + RETRO_VFS_FILE_ACCESS_HINT_NONE); if (!file) return false; diff --git a/libretro-common/formats/png/rpng_encode.c b/libretro-common/formats/png/rpng_encode.c index 9be5f857c1..5599e5290a 100644 --- a/libretro-common/formats/png/rpng_encode.c +++ b/libretro-common/formats/png/rpng_encode.c @@ -228,7 +228,8 @@ static bool rpng_save_image(const char *path, uint32_t total_in = 0; uint32_t total_out = 0; RFILE *file = filestream_open(path, - RETRO_VFS_FILE_ACCESS_WRITE, RFILE_HINT_NONE); + RETRO_VFS_FILE_ACCESS_WRITE, + RETRO_VFS_FILE_ACCESS_HINT_NONE); if (!file) GOTO_END_ERROR(); diff --git a/libretro-common/formats/xml/rxml.c b/libretro-common/formats/xml/rxml.c index 2bac625b74..59e3e5a793 100644 --- a/libretro-common/formats/xml/rxml.c +++ b/libretro-common/formats/xml/rxml.c @@ -420,7 +420,8 @@ rxml_document_t *rxml_load_document(const char *path) const char *mem_ptr = NULL; long len = 0; RFILE *file = filestream_open(path, - RETRO_VFS_FILE_ACCESS_READ, RFILE_HINT_NONE); + RETRO_VFS_FILE_ACCESS_READ, + RETRO_VFS_FILE_ACCESS_HINT_NONE); if (!file) return NULL; diff --git a/libretro-common/hash/rhash.c b/libretro-common/hash/rhash.c index 3ba15eeda8..7dbadea78a 100644 --- a/libretro-common/hash/rhash.c +++ b/libretro-common/hash/rhash.c @@ -512,7 +512,8 @@ int sha1_calculate(const char *path, char *result) unsigned char buff[4096]; int rv = 1; RFILE *fd = filestream_open(path, - RETRO_VFS_FILE_ACCESS_READ, RFILE_HINT_NONE); + RETRO_VFS_FILE_ACCESS_READ, + RETRO_VFS_FILE_ACCESS_HINT_NONE); if (!fd) goto error; diff --git a/libretro-common/include/libretro.h b/libretro-common/include/libretro.h index b10f18b968..6a0929b302 100644 --- a/libretro-common/include/libretro.h +++ b/libretro-common/include/libretro.h @@ -1051,6 +1051,9 @@ struct retro_hw_render_context_negotiation_interface #define RETRO_VFS_FILE_ACCESS_READ_WRITE (RETRO_VFS_FILE_ACCESS_READ | RETRO_VFS_FILE_ACCESS_WRITE) /* Read-write mode, discard contents and overwrites existing file unless RETRO_VFS_FILE_ACCESS_UPDATE is also specified*/ #define RETRO_VFS_FILE_ACCESS_UPDATE_EXISTING (1 << 2) /* Prevents discarding content of existing files opened for writing */ +#define RETRO_VFS_FILE_ACCESS_HINT_NONE (0) +/* Indicate that we would want to map the file into memory if possible. Requires RETRO_VFS_FILE_ACCESS_READ. This is only a hint and it is up to the frontend to honor and implement it. */ +#define RETRO_VFS_FILE_ACCESS_HINT_MEMORY_MAP (1 << 0) #define RETRO_MEMDESC_CONST (1 << 0) /* The frontend will never change this memory area once retro_load_game has returned. */ #define RETRO_MEMDESC_BIGENDIAN (1 << 1) /* The memory area contains big endian data. Default is little endian. */ diff --git a/libretro-common/include/streams/file_stream.h b/libretro-common/include/streams/file_stream.h index faf154723c..543de8621a 100644 --- a/libretro-common/include/streams/file_stream.h +++ b/libretro-common/include/streams/file_stream.h @@ -43,10 +43,6 @@ typedef struct RFILE RFILE; #define FILESTREAM_REQUIRED_VFS_VERSION 1 -#define RFILE_HINT_NONE (0) -/* requires RETRO_VFS_FILE_ACCESS_READ */ -#define RFILE_HINT_MMAP (1 << 9) - int64_t filestream_get_size(RFILE *stream); void filestream_set_size(RFILE *stream); diff --git a/libretro-common/streams/file_stream.c b/libretro-common/streams/file_stream.c index 59468832fb..d6bfc020da 100644 --- a/libretro-common/streams/file_stream.c +++ b/libretro-common/streams/file_stream.c @@ -76,6 +76,7 @@ #define RFILE_HINT_UNBUFFERED (1 << 8) +#include #include #include #include @@ -164,11 +165,11 @@ RFILE *filestream_open(const char *path, unsigned mode, unsigned hints) stream->hints = hints; #ifdef HAVE_MMAP - if (stream->hints & RFILE_HINT_MMAP && mode == RETRO_VFS_FILE_ACCESS_READ) + if (stream->hints & RETRO_VFS_FILE_ACCESS_HINT_MEMORY_MAP && mode == RETRO_VFS_FILE_ACCESS_READ) stream->hints |= RFILE_HINT_UNBUFFERED; else #endif - stream->hints &= ~RFILE_HINT_MMAP; + stream->hints &= ~RETRO_VFS_FILE_ACCESS_HINT_MEMORY_MAP; switch (mode) { @@ -260,7 +261,7 @@ RFILE *filestream_open(const char *path, unsigned mode, unsigned hints) if (stream->fd == -1) goto error; #ifdef HAVE_MMAP - if (stream->hints & RFILE_HINT_MMAP) + if (stream->hints & RETRO_VFS_FILE_ACCESS_HINT_MEMORY_MAP) { stream->mappos = 0; stream->mapped = NULL; @@ -275,7 +276,7 @@ RFILE *filestream_open(const char *path, unsigned mode, unsigned hints) stream->mapsize, PROT_READ, MAP_SHARED, stream->fd, 0); if (stream->mapped == MAP_FAILED) - stream->hints &= ~RFILE_HINT_MMAP; + stream->hints &= ~RETRO_VFS_FILE_ACCESS_HINT_MEMORY_MAP; } #endif } @@ -322,7 +323,7 @@ ssize_t filestream_seek(RFILE *stream, ssize_t offset, int whence) #ifdef HAVE_MMAP /* Need to check stream->mapped because this function is * called in filestream_open() */ - if (stream->mapped && stream->hints & RFILE_HINT_MMAP) + if (stream->mapped && stream->hints & RETRO_VFS_FILE_ACCESS_HINT_MEMORY_MAP) { /* fseek() returns error on under/overflow but allows cursor > EOF for read-only file descriptors. */ @@ -398,7 +399,7 @@ ssize_t filestream_tell(RFILE *stream) #ifdef HAVE_MMAP /* Need to check stream->mapped because this function * is called in filestream_open() */ - if (stream->mapped && stream->hints & RFILE_HINT_MMAP) + if (stream->mapped && stream->hints & RETRO_VFS_FILE_ACCESS_HINT_MEMORY_MAP) return stream->mappos; #endif if (lseek(stream->fd, 0, SEEK_CUR) < 0) @@ -424,7 +425,7 @@ ssize_t filestream_read(RFILE *stream, void *s, size_t len) return fread(s, 1, len, stream->fp); #ifdef HAVE_MMAP - if (stream->hints & RFILE_HINT_MMAP) + if (stream->hints & RETRO_VFS_FILE_ACCESS_HINT_MEMORY_MAP) { if (stream->mappos > stream->mapsize) goto error; @@ -459,7 +460,7 @@ ssize_t filestream_write(RFILE *stream, const void *s, size_t len) return fwrite(s, 1, len, stream->fp); #ifdef HAVE_MMAP - if (stream->hints & RFILE_HINT_MMAP) + if (stream->hints & RETRO_VFS_FILE_ACCESS_HINT_MEMORY_MAP) goto error; #endif return write(stream->fd, s, len); @@ -520,7 +521,7 @@ int filestream_close(RFILE *stream) else { #ifdef HAVE_MMAP - if (stream->hints & RFILE_HINT_MMAP) + if (stream->hints & RETRO_VFS_FILE_ACCESS_HINT_MEMORY_MAP) munmap(stream->mapped, stream->mapsize); #endif } @@ -553,7 +554,8 @@ int filestream_read_file(const char *path, void **buf, ssize_t *len) ssize_t content_buf_size = 0; void *content_buf = NULL; RFILE *file = filestream_open(path, - RETRO_VFS_FILE_ACCESS_READ, RFILE_HINT_NONE); + RETRO_VFS_FILE_ACCESS_READ, + RETRO_VFS_FILE_ACCESS_HINT_NONE); if (!file) { @@ -620,7 +622,8 @@ bool filestream_write_file(const char *path, const void *data, ssize_t size) { ssize_t ret = 0; RFILE *file = filestream_open(path, - RETRO_VFS_FILE_ACCESS_WRITE, RFILE_HINT_NONE); + RETRO_VFS_FILE_ACCESS_WRITE, + RETRO_VFS_FILE_ACCESS_HINT_NONE); if (!file) return false; diff --git a/libretro-db/c_converter.c b/libretro-db/c_converter.c index 3dc51496c3..d114188553 100644 --- a/libretro-db/c_converter.c +++ b/libretro-db/c_converter.c @@ -805,7 +805,8 @@ int main(int argc, char** argv) } rdb_file = filestream_open(rdb_path, - RETRO_VFS_FILE_ACCESS_WRITE, RFILE_HINT_NONE); + RETRO_VFS_FILE_ACCESS_WRITE, + RETRO_VFS_FILE_ACCESS_HINT_NONE); if (!rdb_file) { diff --git a/libretro-db/libretrodb.c b/libretro-db/libretrodb.c index 5deed1d426..6bbc076c66 100644 --- a/libretro-db/libretrodb.c +++ b/libretro-db/libretrodb.c @@ -218,7 +218,8 @@ int libretrodb_open(const char *path, libretrodb_t *db) libretrodb_metadata_t md; int rv = 0; RFILE *fd = filestream_open(path, - RETRO_VFS_FILE_ACCESS_READ, RFILE_HINT_NONE); + RETRO_VFS_FILE_ACCESS_READ, + RETRO_VFS_FILE_ACCESS_HINT_NONE); if (!fd) return -errno; @@ -434,7 +435,8 @@ int libretrodb_cursor_open(libretrodb_t *db, libretrodb_cursor_t *cursor, return -errno; fd = filestream_open(db->path, - RETRO_VFS_FILE_ACCESS_READ, RFILE_HINT_MMAP); + RETRO_VFS_FILE_ACCESS_READ, + RETRO_VFS_FILE_ACCESS_HINT_MEMORY_MAP); if (!fd) return -errno; diff --git a/libretro-db/lua/lua_converter.c b/libretro-db/lua/lua_converter.c index 81c495f455..c99bd7f70f 100644 --- a/libretro-db/lua/lua_converter.c +++ b/libretro-db/lua/lua_converter.c @@ -93,7 +93,8 @@ int main(int argc, char ** argv) call_init(L, argc - 2, (const char **) argv + 2); dst = filestream_open(db_file, - RETRO_VFS_FILE_ACCESS_WRITE, RFILE_HINT_NONE); + RETRO_VFS_FILE_ACCESS_WRITE, + RETRO_VFS_FILE_ACCESS_HINT_NONE); if (!dst) { diff --git a/libretro-db/lua/testlib.c b/libretro-db/lua/testlib.c index bc5bd56a4c..cf4f8d2317 100644 --- a/libretro-db/lua/testlib.c +++ b/libretro-db/lua/testlib.c @@ -107,7 +107,8 @@ static int create_db(lua_State *L) lua_setfield(L, LUA_REGISTRYINDEX, "testlib_get_value"); dst = filestream_open(db_file, - RETRO_VFS_FILE_ACCESS_WRITE, RFILE_HINT_NONE); + RETRO_VFS_FILE_ACCESS_WRITE, + RETRO_VFS_FILE_ACCESS_HINT_NONE); if (!dst) { lua_pushstring(L, "Could not open destination file"); diff --git a/libretro-db/rmsgpack_test.c b/libretro-db/rmsgpack_test.c index c6383cdc0e..da281c8ef5 100644 --- a/libretro-db/rmsgpack_test.c +++ b/libretro-db/rmsgpack_test.c @@ -187,7 +187,8 @@ int main(void) { struct stub_state state; RFILE *fd = filestream_open("test.msgpack", - RETRO_VFS_FILE_ACCESS_READ, RFILE_HINT_NONE); + RETRO_VFS_FILE_ACCESS_READ, + RETRO_VFS_FILE_ACCESS_HINT_NONE); state.i = 0; state.stack[0] = 0; diff --git a/menu/menu_setting.c b/menu/menu_setting.c index f2307cfbc3..d55a5c8c81 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -1878,7 +1878,8 @@ static void systemd_service_toggle(const char *path, char *unit, bool enable) if (enable) filestream_close(filestream_open(path, - RETRO_VFS_FILE_ACCESS_WRITE, RFILE_HINT_NONE)); + RETRO_VFS_FILE_ACCESS_WRITE, + RETRO_VFS_FILE_ACCESS_HINT_NONE)); else path_file_remove(path); diff --git a/movie.c b/movie.c index 9e6e6bcc04..1e8f99402a 100644 --- a/movie.c +++ b/movie.c @@ -20,7 +20,7 @@ #include #include #include -#include +#include #include "configuration.h" #include "movie.h" @@ -35,7 +35,7 @@ struct bsv_movie { - RFILE *file; + intfstream_t *file; /* A ring buffer keeping track of positions * in the file for each frame. */ @@ -75,8 +75,9 @@ static bool bsv_movie_init_playback(bsv_movie_t *handle, const char *path) uint32_t state_size = 0; uint32_t content_crc = 0; uint32_t header[4] = {0}; - RFILE *file = filestream_open(path, - RETRO_VFS_FILE_ACCESS_READ, RFILE_HINT_NONE); + intfstream_t *file = intfstream_open_file(path, + RETRO_VFS_FILE_ACCESS_READ, + RETRO_VFS_FILE_ACCESS_HINT_NONE); if (!file) { @@ -87,7 +88,7 @@ static bool bsv_movie_init_playback(bsv_movie_t *handle, const char *path) handle->file = file; handle->playback = true; - filestream_read(handle->file, header, sizeof(uint32_t) * 4); + intfstream_read(handle->file, header, sizeof(uint32_t) * 4); /* Compatibility with old implementation that * used incorrect documentation. */ if (swap_if_little32(header[MAGIC_INDEX]) != BSV_MAGIC @@ -123,7 +124,8 @@ static bool bsv_movie_init_playback(bsv_movie_t *handle, const char *path) handle->state = buf; handle->state_size = state_size; - if (filestream_read(handle->file, handle->state, state_size) != state_size) + if (intfstream_read(handle->file, + handle->state, state_size) != state_size) { RARCH_ERR("%s\n", msg_hash_to_str(MSG_COULD_NOT_READ_STATE_FROM_MOVIE)); return false; @@ -153,8 +155,9 @@ static bool bsv_movie_init_record(bsv_movie_t *handle, const char *path) uint32_t state_size = 0; uint32_t content_crc = 0; uint32_t header[4] = {0}; - RFILE *file = filestream_open(path, - RETRO_VFS_FILE_ACCESS_WRITE, RFILE_HINT_NONE); + intfstream_t *file = intfstream_open_file(path, + RETRO_VFS_FILE_ACCESS_WRITE, + RETRO_VFS_FILE_ACCESS_HINT_NONE); if (!file) { @@ -183,7 +186,7 @@ static bool bsv_movie_init_record(bsv_movie_t *handle, const char *path) RARCH_ERR("----- debug %u -----\n", header[3]); #endif - filestream_write(handle->file, header, 4 * sizeof(uint32_t)); + intfstream_write(handle->file, header, 4 * sizeof(uint32_t)); handle->min_file_pos = sizeof(header) + state_size; handle->state_size = state_size; @@ -201,7 +204,8 @@ static bool bsv_movie_init_record(bsv_movie_t *handle, const char *path) core_serialize(&serial_info); - filestream_write(handle->file, handle->state, state_size); + intfstream_write(handle->file, + handle->state, state_size); } return true; @@ -212,7 +216,7 @@ static void bsv_movie_free(bsv_movie_t *handle) if (!handle) return; - filestream_close(handle->file); + intfstream_close(handle->file); free(handle->state); free(handle->frame_pos); @@ -258,7 +262,7 @@ void bsv_movie_set_frame_start(void) { if (bsv_movie_state_handle) bsv_movie_state_handle->frame_pos[bsv_movie_state_handle->frame_ptr] - = filestream_tell(bsv_movie_state_handle->file); + = intfstream_tell(bsv_movie_state_handle->file); } void bsv_movie_set_frame_end(void) @@ -284,7 +288,7 @@ static void bsv_movie_frame_rewind(bsv_movie_t *handle) { /* If we're at the beginning... */ handle->frame_ptr = 0; - filestream_seek(handle->file, handle->min_file_pos, SEEK_SET); + intfstream_seek(handle->file, handle->min_file_pos, SEEK_SET); } else { @@ -296,11 +300,11 @@ static void bsv_movie_frame_rewind(bsv_movie_t *handle) * plus another. */ handle->frame_ptr = (handle->frame_ptr - (handle->first_rewind ? 1 : 2)) & handle->frame_mask; - filestream_seek(handle->file, + intfstream_seek(handle->file, handle->frame_pos[handle->frame_ptr], SEEK_SET); } - if (filestream_tell(handle->file) <= (long)handle->min_file_pos) + if (intfstream_tell(handle->file) <= (long)handle->min_file_pos) { /* We rewound past the beginning. */ @@ -311,17 +315,17 @@ static void bsv_movie_frame_rewind(bsv_movie_t *handle) /* If recording, we simply reset * the starting point. Nice and easy. */ - filestream_seek(handle->file, 4 * sizeof(uint32_t), SEEK_SET); + intfstream_seek(handle->file, 4 * sizeof(uint32_t), SEEK_SET); serial_info.data = handle->state; serial_info.size = handle->state_size; core_serialize(&serial_info); - filestream_write(handle->file, handle->state, handle->state_size); + intfstream_write(handle->file, handle->state, handle->state_size); } else - filestream_seek(handle->file, handle->min_file_pos, SEEK_SET); + intfstream_seek(handle->file, handle->min_file_pos, SEEK_SET); } } @@ -389,7 +393,7 @@ bool bsv_movie_init(void) bool bsv_movie_get_input(int16_t *bsv_data) { - if (filestream_read(bsv_movie_state_handle->file, bsv_data, 1) != 1) + if (intfstream_read(bsv_movie_state_handle->file, bsv_data, 1) != 1) return false; *bsv_data = swap_if_big16(*bsv_data); @@ -450,7 +454,7 @@ bool bsv_movie_ctl(enum bsv_ctl_state state, void *data) int16_t *bsv_data = (int16_t*)data; *bsv_data = swap_if_big16(*bsv_data); - filestream_write(bsv_movie_state_handle->file, bsv_data, 1); + intfstream_write(bsv_movie_state_handle->file, bsv_data, 1); } break; case BSV_MOVIE_CTL_NONE: diff --git a/playlist.c b/playlist.c index 2168272214..9a8924740f 100644 --- a/playlist.c +++ b/playlist.c @@ -395,7 +395,7 @@ void playlist_write_file(playlist_t *playlist) return; file = filestream_open(playlist->conf_path, - RETRO_VFS_FILE_ACCESS_WRITE, RFILE_HINT_NONE); + RETRO_VFS_FILE_ACCESS_WRITE, RETRO_VFS_FILE_ACCESS_HINT_NONE); if (!file) { @@ -495,7 +495,8 @@ static bool playlist_read_file( unsigned i; char buf[PLAYLIST_ENTRIES][1024]; RFILE *file = filestream_open( - path, RETRO_VFS_FILE_ACCESS_READ, RFILE_HINT_NONE); + path, RETRO_VFS_FILE_ACCESS_READ, + RETRO_VFS_FILE_ACCESS_HINT_NONE); for (i = 0; i < PLAYLIST_ENTRIES; i++) buf[i][0] = '\0'; diff --git a/tasks/task_database.c b/tasks/task_database.c index 48f59bfbfe..f274fc554b 100644 --- a/tasks/task_database.c +++ b/tasks/task_database.c @@ -207,7 +207,7 @@ static bool intfstream_file_get_serial(const char *name, uint8_t *data = NULL; ssize_t file_size = -1; intfstream_t *fd = intfstream_open_file(name, - RETRO_VFS_FILE_ACCESS_READ, RFILE_HINT_NONE); + RETRO_VFS_FILE_ACCESS_READ, RETRO_VFS_FILE_ACCESS_HINT_NONE); if (!fd) return 0; @@ -239,7 +239,7 @@ static bool intfstream_file_get_serial(const char *name, intfstream_close(fd); free(fd); fd = intfstream_open_memory(data, RETRO_VFS_FILE_ACCESS_READ, - RFILE_HINT_NONE, + RETRO_VFS_FILE_ACCESS_HINT_NONE, size); if (!fd) { @@ -324,7 +324,7 @@ static int task_database_chd_get_serial(const char *name, char* serial) intfstream_t *fd = intfstream_open_chd_track( name, RETRO_VFS_FILE_ACCESS_READ, - RFILE_HINT_NONE, + RETRO_VFS_FILE_ACCESS_HINT_NONE, CHDSTREAM_TRACK_FIRST_DATA); if (!fd) return 0; @@ -357,7 +357,7 @@ static bool intfstream_file_get_crc(const char *name, { int rv; intfstream_t *fd = intfstream_open_file(name, - RETRO_VFS_FILE_ACCESS_READ, RFILE_HINT_NONE); + RETRO_VFS_FILE_ACCESS_READ, RETRO_VFS_FILE_ACCESS_HINT_NONE); uint8_t *data = NULL; ssize_t file_size = -1; @@ -388,7 +388,7 @@ static bool intfstream_file_get_crc(const char *name, intfstream_close(fd); free(fd); fd = intfstream_open_memory(data, RETRO_VFS_FILE_ACCESS_READ, - RFILE_HINT_NONE, size); + RETRO_VFS_FILE_ACCESS_HINT_NONE, size); if (!fd) goto error; @@ -481,7 +481,7 @@ static bool task_database_chd_get_crc(const char *name, uint32_t *crc) intfstream_t *fd = intfstream_open_chd_track( name, RETRO_VFS_FILE_ACCESS_READ, - RFILE_HINT_NONE, + RETRO_VFS_FILE_ACCESS_HINT_NONE, CHDSTREAM_TRACK_PRIMARY); if (!fd) return 0; @@ -505,7 +505,7 @@ static void task_database_cue_prune(database_info_handle_t *db, size_t i; char *path = (char *)malloc(PATH_MAX_LENGTH + 1); intfstream_t *fd = intfstream_open_file(name, - RETRO_VFS_FILE_ACCESS_READ, RFILE_HINT_NONE); + RETRO_VFS_FILE_ACCESS_READ, RETRO_VFS_FILE_ACCESS_HINT_NONE); if (!fd) goto end; @@ -538,7 +538,7 @@ static void gdi_prune(database_info_handle_t *db, const char *name) size_t i; char *path = (char *)malloc(PATH_MAX_LENGTH + 1); intfstream_t *fd = intfstream_open_file(name, - RETRO_VFS_FILE_ACCESS_READ, RFILE_HINT_NONE); + RETRO_VFS_FILE_ACCESS_READ, RETRO_VFS_FILE_ACCESS_HINT_NONE); if (!fd) goto end; diff --git a/tasks/task_database_cue.c b/tasks/task_database_cue.c index ae134aee63..2215d8c975 100644 --- a/tasks/task_database_cue.c +++ b/tasks/task_database_cue.c @@ -414,7 +414,7 @@ static ssize_t get_file_size(const char *path) { ssize_t rv; RFILE *fd = filestream_open(path, - RETRO_VFS_FILE_ACCESS_READ, RFILE_HINT_NONE); + RETRO_VFS_FILE_ACCESS_READ, RETRO_VFS_FILE_ACCESS_HINT_NONE); if (fd == NULL) return -1; rv = filestream_get_size(fd); @@ -469,7 +469,7 @@ int cue_find_track(const char *cue_path, bool first, goto error; if (!intfstream_open(fd, cue_path, - RETRO_VFS_FILE_ACCESS_READ, RFILE_HINT_NONE)) + RETRO_VFS_FILE_ACCESS_READ, RETRO_VFS_FILE_ACCESS_HINT_NONE)) { RARCH_LOG("Could not open CUE file '%s': %s\n", cue_path, strerror(errno)); @@ -624,7 +624,7 @@ int gdi_find_track(const char *gdi_path, bool first, goto error; if (!intfstream_open(fd, gdi_path, - RETRO_VFS_FILE_ACCESS_READ, RFILE_HINT_NONE)) + RETRO_VFS_FILE_ACCESS_READ, RETRO_VFS_FILE_ACCESS_HINT_NONE)) { RARCH_LOG("Could not open GDI file '%s': %s\n", gdi_path, strerror(errno)); diff --git a/tasks/task_save.c b/tasks/task_save.c index 5d29865a6a..c3538aa905 100644 --- a/tasks/task_save.c +++ b/tasks/task_save.c @@ -158,7 +158,7 @@ static void autosave_thread(void *data) { /* Should probably deal with this more elegantly. */ RFILE *file = filestream_open(save->path, - RETRO_VFS_FILE_ACCESS_WRITE, RFILE_HINT_NONE); + RETRO_VFS_FILE_ACCESS_WRITE, RETRO_VFS_FILE_ACCESS_HINT_NONE); if (file) { @@ -566,7 +566,7 @@ static void task_save_handler(retro_task_t *task) if (!state->file) { state->file = filestream_open(state->path, RETRO_VFS_FILE_ACCESS_WRITE, - RFILE_HINT_NONE); + RETRO_VFS_FILE_ACCESS_HINT_NONE); if (!state->file) return; @@ -740,7 +740,7 @@ static void task_load_handler(retro_task_t *task) { state->file = filestream_open(state->path, RETRO_VFS_FILE_ACCESS_READ, - RFILE_HINT_NONE); + RETRO_VFS_FILE_ACCESS_HINT_NONE); if (!state->file) goto error; From 54ce2ec5e94e859fc9236a50247172ab6525aa27 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 11 Dec 2017 12:57:53 +0100 Subject: [PATCH 309/394] playlist.c - use intfstream --- playlist.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/playlist.c b/playlist.c index 9a8924740f..87b7632d9d 100644 --- a/playlist.c +++ b/playlist.c @@ -22,6 +22,7 @@ #include #include #include +#include #include #include @@ -494,19 +495,19 @@ static bool playlist_read_file( { unsigned i; char buf[PLAYLIST_ENTRIES][1024]; - RFILE *file = filestream_open( + intfstream_t *file = intfstream_open_file( path, RETRO_VFS_FILE_ACCESS_READ, RETRO_VFS_FILE_ACCESS_HINT_NONE); - for (i = 0; i < PLAYLIST_ENTRIES; i++) - buf[i][0] = '\0'; - /* If playlist file does not exist, * create an empty playlist instead. */ if (!file) return true; + for (i = 0; i < PLAYLIST_ENTRIES; i++) + buf[i][0] = '\0'; + for (playlist->size = 0; playlist->size < playlist->cap; ) { unsigned i; @@ -516,7 +517,7 @@ static bool playlist_read_file( char *last = NULL; *buf[i] = '\0'; - if (!filestream_gets(file, buf[i], sizeof(buf[i]))) + if (!intfstream_gets(file, buf[i], sizeof(buf[i]))) goto end; /* Read playlist entry and terminate string with NUL character @@ -548,7 +549,7 @@ static bool playlist_read_file( } end: - filestream_close(file); + intfstream_close(file); return true; } From 12e6f389997274658eba5f197f35e0b9f4a6ef65 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 11 Dec 2017 13:01:17 +0100 Subject: [PATCH 310/394] (gfx/video_shader_parse) Use intfstream instead of file_stream --- gfx/video_shader_parse.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/gfx/video_shader_parse.c b/gfx/video_shader_parse.c index d2e8aa7801..c25d309124 100644 --- a/gfx/video_shader_parse.c +++ b/gfx/video_shader_parse.c @@ -25,7 +25,7 @@ #include "video_driver.h" /* video_context_driver_get_api */ #include #include -#include +#include #include "../msg_hash.h" #include "../verbosity.h" @@ -521,10 +521,10 @@ bool video_shader_resolve_parameters(config_file_t *conf, for (i = 0; i < shader->passes; i++) { - RFILE *file = NULL; - size_t line_size = 4096 * sizeof(char); - char *line = (char*)malloc(4096 * sizeof(char)); - const char *path = shader->pass[i].source.path; + intfstream_t *file = NULL; + size_t line_size = 4096 * sizeof(char); + char *line = (char*)malloc(4096 * sizeof(char)); + const char *path = shader->pass[i].source.path; if (string_is_empty(path)) { @@ -546,7 +546,7 @@ bool video_shader_resolve_parameters(config_file_t *conf, /* If that doesn't work, fallback to the old path. * Ideally, we'd get rid of this path sooner or later. */ #endif - file = filestream_open(path, + file = intfstream_open_file(path, RETRO_VFS_FILE_ACCESS_READ, RETRO_VFS_FILE_ACCESS_HINT_NONE); @@ -559,7 +559,7 @@ bool video_shader_resolve_parameters(config_file_t *conf, line[0] = '\0'; while (shader->num_parameters < ARRAY_SIZE(shader->parameters) - && filestream_gets(file, line, line_size)) + && intfstream_gets(file, line, line_size)) { int ret = sscanf(line, "#pragma parameter %63s \"%63[^\"]\" %f %f %f %f", @@ -585,7 +585,7 @@ bool video_shader_resolve_parameters(config_file_t *conf, } free(line); - filestream_close(file); + intfstream_close(file); } if (conf && !video_shader_resolve_current_parameters(conf, shader)) From e62e9233d7a92027c777b3ff637ce41f2c28b89d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 11 Dec 2017 13:21:44 +0100 Subject: [PATCH 311/394] Add intfstream_get_size --- cheevos/cheevos.c | 13 +++++++------ .../include/streams/interface_stream.h | 3 +++ libretro-common/streams/interface_stream.c | 19 +++++++++++++++++++ tasks/task_database_cue.c | 14 +++++++------- 4 files changed, 36 insertions(+), 13 deletions(-) diff --git a/cheevos/cheevos.c b/cheevos/cheevos.c index 34f7b5e4d4..dae27cbb5c 100644 --- a/cheevos/cheevos.c +++ b/cheevos/cheevos.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -2488,7 +2489,7 @@ typedef struct size_t romsize, bytes; \ int mapper; \ bool round; \ - RFILE* stream; \ + intfstream_t *stream; \ size_t size; \ char url[256]; \ struct http_connection_t *conn; \ @@ -2640,7 +2641,7 @@ static int cheevos_iterate(coro_t* coro) /* Load the content into memory, or copy it over to our own buffer */ if (!CHEEVOS_VAR_DATA) { - CHEEVOS_VAR_STREAM = filestream_open( + CHEEVOS_VAR_STREAM = intfstream_open_file( CHEEVOS_VAR_PATH, RETRO_VFS_FILE_ACCESS_READ, RETRO_VFS_FILE_ACCESS_HINT_NONE); @@ -2650,7 +2651,7 @@ static int cheevos_iterate(coro_t* coro) CORO_YIELD(); CHEEVOS_VAR_LEN = 0; - CHEEVOS_VAR_COUNT = filestream_get_size(CHEEVOS_VAR_STREAM); + CHEEVOS_VAR_COUNT = intfstream_get_size(CHEEVOS_VAR_STREAM); if (CHEEVOS_VAR_COUNT > CHEEVOS_SIZE_LIMIT) CHEEVOS_VAR_COUNT = CHEEVOS_SIZE_LIMIT; @@ -2659,7 +2660,7 @@ static int cheevos_iterate(coro_t* coro) if (!CHEEVOS_VAR_DATA) { - filestream_close(CHEEVOS_VAR_STREAM); + intfstream_close(CHEEVOS_VAR_STREAM); CORO_STOP(); } @@ -2671,7 +2672,7 @@ static int cheevos_iterate(coro_t* coro) if (to_read > CHEEVOS_VAR_COUNT) to_read = CHEEVOS_VAR_COUNT; - num_read = filestream_read(CHEEVOS_VAR_STREAM, (void*)buffer, to_read); + num_read = intfstream_read(CHEEVOS_VAR_STREAM, (void*)buffer, to_read); if (num_read <= 0) break; @@ -2685,7 +2686,7 @@ static int cheevos_iterate(coro_t* coro) CORO_YIELD(); } - filestream_close(CHEEVOS_VAR_STREAM); + intfstream_close(CHEEVOS_VAR_STREAM); } /* Use the supported extensions as a hint diff --git a/libretro-common/include/streams/interface_stream.h b/libretro-common/include/streams/interface_stream.h index 3a21567d3f..ebcb8fda7d 100644 --- a/libretro-common/include/streams/interface_stream.h +++ b/libretro-common/include/streams/interface_stream.h @@ -90,6 +90,8 @@ void intfstream_putc(intfstream_internal_t *intf, int c); int intfstream_close(intfstream_internal_t *intf); +int64_t intfstream_get_size(intfstream_internal_t *intf); + intfstream_t* intfstream_open_file(const char *path, unsigned mode, unsigned hints); @@ -99,6 +101,7 @@ intfstream_t *intfstream_open_memory(void *data, intfstream_t *intfstream_open_chd_track(const char *path, unsigned mode, unsigned hints, int32_t track); + RETRO_END_DECLS #endif diff --git a/libretro-common/streams/interface_stream.c b/libretro-common/streams/interface_stream.c index 78bb4c525a..fb34bb3657 100644 --- a/libretro-common/streams/interface_stream.c +++ b/libretro-common/streams/interface_stream.c @@ -57,6 +57,25 @@ struct intfstream_internal #endif }; +int64_t intfstream_get_size(intfstream_internal_t *intf) +{ + if (!intf) + return 0; + + switch (intf->type) + { + case INTFSTREAM_FILE: + return filestream_get_size(intf->file.fp); + case INTFSTREAM_MEMORY: + return intf->memory.buf.size; + case INTFSTREAM_CHD: + /* TODO/FIXME - implement this */ + break; + } + + return 0; +} + bool intfstream_resize(intfstream_internal_t *intf, intfstream_info_t *info) { if (!intf || !info) diff --git a/tasks/task_database_cue.c b/tasks/task_database_cue.c index 2215d8c975..cb8e366c74 100644 --- a/tasks/task_database_cue.c +++ b/tasks/task_database_cue.c @@ -410,15 +410,15 @@ clean: return rv; } -static ssize_t get_file_size(const char *path) +static ssize_t intfstream_get_file_size(const char *path) { ssize_t rv; - RFILE *fd = filestream_open(path, + intfstream_t *fd = intfstream_open_file(path, RETRO_VFS_FILE_ACCESS_READ, RETRO_VFS_FILE_ACCESS_HINT_NONE); - if (fd == NULL) + if (!fd) return -1; - rv = filestream_get_size(fd); - filestream_close(fd); + rv = intfstream_get_size(fd); + intfstream_close(fd); return rv; } @@ -503,7 +503,7 @@ int cue_find_track(const char *cue_path, bool first, get_token(fd, tmp_token, MAX_TOKEN_LEN); fill_pathname_join(last_file, cue_dir, tmp_token, PATH_MAX_LENGTH); - file_size = get_file_size(last_file); + file_size = intfstream_get_file_size(last_file); get_token(fd, tmp_token, MAX_TOKEN_LEN); @@ -685,7 +685,7 @@ int gdi_find_track(const char *gdi_path, bool first, fill_pathname_join(last_file, gdi_dir, tmp_token, PATH_MAX_LENGTH); - file_size = get_file_size(last_file); + file_size = intfstream_get_file_size(last_file); if (file_size < 0) { free(gdi_dir); From 1cd7568f1fece1025c27be132b0e15fa218fc9ba Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 11 Dec 2017 13:26:52 +0100 Subject: [PATCH 312/394] (gx_gfx) Go through intfstream --- gfx/drivers/gx_gfx.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/gfx/drivers/gx_gfx.c b/gfx/drivers/gx_gfx.c index ef676d6312..e826b143dd 100644 --- a/gfx/drivers/gx_gfx.c +++ b/gfx/drivers/gx_gfx.c @@ -22,7 +22,7 @@ #include #include -#include +#include #ifdef HAVE_CONFIG_H #include "../../config.h" @@ -720,14 +720,14 @@ static void gx_efb_screenshot(void) { int x, y; uint8_t tga_header[] = {0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x02, 0xE0, 0x01, 0x18, 0x00}; - RFILE *out = filestream_open("/screenshot.tga", + intfstream_t *out = intfstream_open("/screenshot.tga", RETRO_VFS_FILE_ACCESS_WRITE, RETRO_VFS_FILE_ACCESS_HINT_NONE); if (!out) return; - filestream_write(out, tga_header, sizeof(tga_header)); + intfstream_write(out, tga_header, sizeof(tga_header)); for (y = 479; y >= 0; --y) { @@ -742,10 +742,10 @@ static void gx_efb_screenshot(void) line[i++] = color.g; line[i++] = color.r; } - filestream_write(out, line, sizeof(line)); + intfstream_write(out, line, sizeof(line)); } - filestream_close(out); + intfstream_close(out); } #endif From 32511090ca9eead8efcb3eb9ead02d4dba2d5acd Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 11 Dec 2017 14:56:58 +0100 Subject: [PATCH 313/394] (task_save.c) Move to intfstream --- .../include/streams/interface_stream.h | 2 ++ libretro-common/streams/interface_stream.c | 18 ++++++++++++ tasks/task_save.c | 29 ++++++++++--------- 3 files changed, 35 insertions(+), 14 deletions(-) diff --git a/libretro-common/include/streams/interface_stream.h b/libretro-common/include/streams/interface_stream.h index ebcb8fda7d..98c0d61f99 100644 --- a/libretro-common/include/streams/interface_stream.h +++ b/libretro-common/include/streams/interface_stream.h @@ -92,6 +92,8 @@ int intfstream_close(intfstream_internal_t *intf); int64_t intfstream_get_size(intfstream_internal_t *intf); +int intfstream_flush(intfstream_internal_t *intf); + intfstream_t* intfstream_open_file(const char *path, unsigned mode, unsigned hints); diff --git a/libretro-common/streams/interface_stream.c b/libretro-common/streams/interface_stream.c index fb34bb3657..c1156ecb47 100644 --- a/libretro-common/streams/interface_stream.c +++ b/libretro-common/streams/interface_stream.c @@ -133,6 +133,24 @@ bool intfstream_open(intfstream_internal_t *intf, const char *path, return true; } +int intfstream_flush(intfstream_internal_t *intf) +{ + if (!intf) + return -1; + + switch (intf->type) + { + case INTFSTREAM_FILE: + return filestream_flush(intf->file.fp); + case INTFSTREAM_MEMORY: + case INTFSTREAM_CHD: + /* Should we stub this for these interfaces? */ + break; + } + + return 0; +} + int intfstream_close(intfstream_internal_t *intf) { if (!intf) diff --git a/tasks/task_save.c b/tasks/task_save.c index c3538aa905..eab39754b1 100644 --- a/tasks/task_save.c +++ b/tasks/task_save.c @@ -29,6 +29,7 @@ #include #include #include +#include #include #include #include @@ -78,7 +79,7 @@ struct sram_block typedef struct { - RFILE *file; + intfstream_t *file; char path[PATH_MAX_LENGTH]; void *data; void *undo_data; @@ -157,7 +158,7 @@ static void autosave_thread(void *data) if (differ) { /* Should probably deal with this more elegantly. */ - RFILE *file = filestream_open(save->path, + intfstream_t *file = intfstream_open_file(save->path, RETRO_VFS_FILE_ACCESS_WRITE, RETRO_VFS_FILE_ACCESS_HINT_NONE); if (file) @@ -174,9 +175,9 @@ static void autosave_thread(void *data) else RARCH_LOG("SRAM changed ... autosaving ...\n"); - failed |= ((size_t)filestream_write(file, save->buffer, save->bufsize) != save->bufsize); - failed |= (filestream_flush(file) != 0); - failed |= (filestream_close(file) != 0); + failed |= ((size_t)intfstream_write(file, save->buffer, save->bufsize) != save->bufsize); + failed |= (intfstream_flush(file) != 0); + failed |= (intfstream_close(file) != 0); if (failed) RARCH_WARN("Failed to autosave SRAM. Disk might be full.\n"); } @@ -530,7 +531,7 @@ static void task_save_handler_finished(retro_task_t *task, task_set_finished(task, true); - filestream_close(state->file); + intfstream_close(state->file); if (!task_get_error(task) && task_get_cancelled(task)) task_set_error(task, strdup("Task canceled")); @@ -565,7 +566,7 @@ static void task_save_handler(retro_task_t *task) if (!state->file) { - state->file = filestream_open(state->path, RETRO_VFS_FILE_ACCESS_WRITE, + state->file = intfstream_open_file(state->path, RETRO_VFS_FILE_ACCESS_WRITE, RETRO_VFS_FILE_ACCESS_HINT_NONE); if (!state->file) @@ -573,7 +574,7 @@ static void task_save_handler(retro_task_t *task) } remaining = MIN(state->size - state->written, SAVE_STATE_CHUNK); - written = (int)filestream_write(state->file, + written = (int)intfstream_write(state->file, (uint8_t*)state->data + state->written, remaining); state->written += written; @@ -712,7 +713,7 @@ static void task_load_handler_finished(retro_task_t *task, task_set_finished(task, true); if (state->file) - filestream_close(state->file); + intfstream_close(state->file); if (!task_get_error(task) && task_get_cancelled(task)) task_set_error(task, strdup("Task canceled")); @@ -738,22 +739,22 @@ static void task_load_handler(retro_task_t *task) if (!state->file) { - state->file = filestream_open(state->path, + state->file = intfstream_open_file(state->path, RETRO_VFS_FILE_ACCESS_READ, RETRO_VFS_FILE_ACCESS_HINT_NONE); if (!state->file) goto error; - if (filestream_seek(state->file, 0, SEEK_END) != 0) + if (intfstream_seek(state->file, 0, SEEK_END) != 0) goto error; - state->size = filestream_tell(state->file); + state->size = intfstream_tell(state->file); if (state->size < 0) goto error; - filestream_rewind(state->file); + intfstream_rewind(state->file); state->data = malloc(state->size + 1); @@ -762,7 +763,7 @@ static void task_load_handler(retro_task_t *task) } remaining = MIN(state->size - state->bytes_read, SAVE_STATE_CHUNK); - bytes_read = filestream_read(state->file, + bytes_read = intfstream_read(state->file, (uint8_t*)state->data + state->bytes_read, remaining); state->bytes_read += bytes_read; From 5b8f8b50e3a9335fa9ee710dd42f369f81b526ae Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 11 Dec 2017 17:36:20 +0100 Subject: [PATCH 314/394] Reimplement filestream_eof --- libretro-common/streams/file_stream.c | 18 ++---------------- 1 file changed, 2 insertions(+), 16 deletions(-) diff --git a/libretro-common/streams/file_stream.c b/libretro-common/streams/file_stream.c index d6bfc020da..bb60a9b9f7 100644 --- a/libretro-common/streams/file_stream.c +++ b/libretro-common/streams/file_stream.c @@ -366,26 +366,12 @@ error: int filestream_eof(RFILE *stream) { - return feof(stream->fp); - - /* TODO: FIXME: I can't figure out why this breaks on Windows. - The while loop in config_file_new_internal just never exits. - The current position seems to jump backwards a few lines, - but it doesn't start until somewhere in the middle of the file. - */ - /* - size_t current_position = filestream_tell(stream); - size_t end_position; - - filestream_seek(stream, 0, SEEK_END); - end_position = filestream_tell(stream); - - filestream_seek(stream, current_position, SEEK_SET); + int64_t current_position = filestream_tell(stream); + int64_t end_position = filestream_get_size(stream); if (current_position >= end_position) return 1; return 0; - */ } ssize_t filestream_tell(RFILE *stream) From 43c9bb374d96743f7ece5cfbebdd027fac5bf07d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 11 Dec 2017 17:39:56 +0100 Subject: [PATCH 315/394] filestream_set_size can be made a static function --- libretro-common/include/streams/file_stream.h | 2 -- libretro-common/streams/file_stream.c | 5 +---- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/libretro-common/include/streams/file_stream.h b/libretro-common/include/streams/file_stream.h index 543de8621a..ebcfa056d6 100644 --- a/libretro-common/include/streams/file_stream.h +++ b/libretro-common/include/streams/file_stream.h @@ -45,8 +45,6 @@ typedef struct RFILE RFILE; int64_t filestream_get_size(RFILE *stream); -void filestream_set_size(RFILE *stream); - const char *filestream_get_ext(RFILE *stream); /** diff --git a/libretro-common/streams/file_stream.c b/libretro-common/streams/file_stream.c index bb60a9b9f7..8c654d6351 100644 --- a/libretro-common/streams/file_stream.c +++ b/libretro-common/streams/file_stream.c @@ -125,11 +125,8 @@ int64_t filestream_get_size(RFILE *stream) return stream->size; } -void filestream_set_size(RFILE *stream) +static void filestream_set_size(RFILE *stream) { - if (!stream) - return; - filestream_seek(stream, 0, SEEK_SET); filestream_seek(stream, 0, SEEK_END); From ad70bb9866dd009a5fa74902692e67458d03469f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 11 Dec 2017 17:42:00 +0100 Subject: [PATCH 316/394] Get rid of unused filestream_get_ext --- libretro-common/include/streams/file_stream.h | 2 -- libretro-common/streams/file_stream.c | 17 ----------------- 2 files changed, 19 deletions(-) diff --git a/libretro-common/include/streams/file_stream.h b/libretro-common/include/streams/file_stream.h index ebcfa056d6..2ee44ec096 100644 --- a/libretro-common/include/streams/file_stream.h +++ b/libretro-common/include/streams/file_stream.h @@ -45,8 +45,6 @@ typedef struct RFILE RFILE; int64_t filestream_get_size(RFILE *stream); -const char *filestream_get_ext(RFILE *stream); - /** * filestream_open: * @path : path to file diff --git a/libretro-common/streams/file_stream.c b/libretro-common/streams/file_stream.c index 8c654d6351..36b9f94b3a 100644 --- a/libretro-common/streams/file_stream.c +++ b/libretro-common/streams/file_stream.c @@ -86,7 +86,6 @@ struct RFILE { unsigned hints; - char *ext; int64_t size; FILE *fp; @@ -111,13 +110,6 @@ struct RFILE char *buf; }; -const char *filestream_get_ext(RFILE *stream) -{ - if (!stream) - return NULL; - return stream->ext; -} - int64_t filestream_get_size(RFILE *stream) { if (!stream) @@ -278,12 +270,6 @@ RFILE *filestream_open(const char *path, unsigned mode, unsigned hints) #endif } - { - const char *ld = (const char*)strrchr(path, '.'); - if (ld) - stream->ext = strdup(ld + 1); - } - filestream_set_size(stream); return stream; @@ -493,9 +479,6 @@ int filestream_close(RFILE *stream) if (!stream) goto error; - if (!string_is_empty(stream->ext)) - free(stream->ext); - if ((stream->hints & RFILE_HINT_UNBUFFERED) == 0) { if (stream->fp) From 5960cd80d2073d499c8390fe73a236c898f39cdc Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 11 Dec 2017 17:59:18 +0100 Subject: [PATCH 317/394] Simplify filestream_read_file --- libretro-common/streams/file_stream.c | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/libretro-common/streams/file_stream.c b/libretro-common/streams/file_stream.c index 36b9f94b3a..224fea7a5a 100644 --- a/libretro-common/streams/file_stream.c +++ b/libretro-common/streams/file_stream.c @@ -517,7 +517,7 @@ error: int filestream_read_file(const char *path, void **buf, ssize_t *len) { ssize_t ret = 0; - ssize_t content_buf_size = 0; + int64_t content_buf_size = 0; void *content_buf = NULL; RFILE *file = filestream_open(path, RETRO_VFS_FILE_ACCESS_READ, @@ -529,15 +529,11 @@ int filestream_read_file(const char *path, void **buf, ssize_t *len) goto error; } - if (filestream_seek(file, 0, SEEK_END) != 0) - goto error; + content_buf_size = filestream_get_size(file); - content_buf_size = filestream_tell(file); if (content_buf_size < 0) goto error; - filestream_rewind(file); - content_buf = malloc(content_buf_size + 1); if (!content_buf) From a1ce8b58c4096103d2693313017164772930499e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 11 Dec 2017 18:01:56 +0100 Subject: [PATCH 318/394] Simply formats/xml/rxml.c --- libretro-common/formats/xml/rxml.c | 5 +---- libretro-common/streams/file_stream.c | 1 + 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/libretro-common/formats/xml/rxml.c b/libretro-common/formats/xml/rxml.c index 59e3e5a793..0f0b072a70 100644 --- a/libretro-common/formats/xml/rxml.c +++ b/libretro-common/formats/xml/rxml.c @@ -429,10 +429,7 @@ rxml_document_t *rxml_load_document(const char *path) if (!doc) goto error; - filestream_seek(file, 0, SEEK_END); - len = filestream_tell(file); - filestream_rewind(file); - + len = filestream_get_size(file); memory_buffer = (char*)malloc(len + 1); if (!memory_buffer) goto error; diff --git a/libretro-common/streams/file_stream.c b/libretro-common/streams/file_stream.c index 224fea7a5a..c34fcae506 100644 --- a/libretro-common/streams/file_stream.c +++ b/libretro-common/streams/file_stream.c @@ -249,6 +249,7 @@ RFILE *filestream_open(const char *path, unsigned mode, unsigned hints) if (stream->fd == -1) goto error; + #ifdef HAVE_MMAP if (stream->hints & RETRO_VFS_FILE_ACCESS_HINT_MEMORY_MAP) { From 784bb32c64d2249d8cc0cb53c99c3661606b2a47 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 11 Dec 2017 19:55:42 +0100 Subject: [PATCH 319/394] Cleanups --- libretro-common/streams/file_stream.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/libretro-common/streams/file_stream.c b/libretro-common/streams/file_stream.c index c34fcae506..59bc1f90d4 100644 --- a/libretro-common/streams/file_stream.c +++ b/libretro-common/streams/file_stream.c @@ -131,7 +131,7 @@ static void filestream_set_size(RFILE *stream) * filestream_open: * @path : path to file * @mode : file mode to use when opening (read/write) - * @bufsize : optional buffer size (-1 or 0 to use default) + * @hints : * * Opens a file for reading or writing, depending on the requested mode. * Returns a pointer to an RFILE if opened successfully, otherwise NULL. @@ -289,8 +289,6 @@ char *filestream_gets(RFILE *stream, char *s, size_t len) int filestream_getc(RFILE *stream) { - char c = 0; - (void)c; if (!stream) return 0; return fgetc(stream->fp); From c4d8a8c8008bad786fb072da36643ffb278c79d8 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 11 Dec 2017 20:24:00 +0100 Subject: [PATCH 320/394] Free after intfstream_close --- cheevos/cheevos.c | 2 ++ gfx/drivers/gx_gfx.c | 1 + gfx/video_shader_parse.c | 1 + movie.c | 1 + playlist.c | 1 + tasks/task_database.c | 2 +- tasks/task_database_cue.c | 1 + tasks/task_save.c | 5 +++++ 8 files changed, 13 insertions(+), 1 deletion(-) diff --git a/cheevos/cheevos.c b/cheevos/cheevos.c index dae27cbb5c..5d1c7515ac 100644 --- a/cheevos/cheevos.c +++ b/cheevos/cheevos.c @@ -2661,6 +2661,7 @@ static int cheevos_iterate(coro_t* coro) if (!CHEEVOS_VAR_DATA) { intfstream_close(CHEEVOS_VAR_STREAM); + free(CHEEVOS_VAR_STREAM); CORO_STOP(); } @@ -2687,6 +2688,7 @@ static int cheevos_iterate(coro_t* coro) } intfstream_close(CHEEVOS_VAR_STREAM); + free(CHEEVOS_VAR_STREAM); } /* Use the supported extensions as a hint diff --git a/gfx/drivers/gx_gfx.c b/gfx/drivers/gx_gfx.c index e826b143dd..14b7f61c38 100644 --- a/gfx/drivers/gx_gfx.c +++ b/gfx/drivers/gx_gfx.c @@ -746,6 +746,7 @@ static void gx_efb_screenshot(void) } intfstream_close(out); + free(out); } #endif diff --git a/gfx/video_shader_parse.c b/gfx/video_shader_parse.c index c25d309124..b7a36c7af4 100644 --- a/gfx/video_shader_parse.c +++ b/gfx/video_shader_parse.c @@ -586,6 +586,7 @@ bool video_shader_resolve_parameters(config_file_t *conf, free(line); intfstream_close(file); + free(file); } if (conf && !video_shader_resolve_current_parameters(conf, shader)) diff --git a/movie.c b/movie.c index 1e8f99402a..131062d42c 100644 --- a/movie.c +++ b/movie.c @@ -217,6 +217,7 @@ static void bsv_movie_free(bsv_movie_t *handle) return; intfstream_close(handle->file); + free(handle->file); free(handle->state); free(handle->frame_pos); diff --git a/playlist.c b/playlist.c index 87b7632d9d..ae48833cba 100644 --- a/playlist.c +++ b/playlist.c @@ -550,6 +550,7 @@ static bool playlist_read_file( end: intfstream_close(file); + free(file); return true; } diff --git a/tasks/task_database.c b/tasks/task_database.c index f274fc554b..8c8a26e57d 100644 --- a/tasks/task_database.c +++ b/tasks/task_database.c @@ -250,8 +250,8 @@ static bool intfstream_file_get_serial(const char *name, rv = intfstream_get_serial(fd, serial); intfstream_close(fd); - free(data); free(fd); + free(data); return rv; error: diff --git a/tasks/task_database_cue.c b/tasks/task_database_cue.c index cb8e366c74..ef43985101 100644 --- a/tasks/task_database_cue.c +++ b/tasks/task_database_cue.c @@ -419,6 +419,7 @@ static ssize_t intfstream_get_file_size(const char *path) return -1; rv = intfstream_get_size(fd); intfstream_close(fd); + free(fd); return rv; } diff --git a/tasks/task_save.c b/tasks/task_save.c index eab39754b1..ed081d89ef 100644 --- a/tasks/task_save.c +++ b/tasks/task_save.c @@ -178,6 +178,7 @@ static void autosave_thread(void *data) failed |= ((size_t)intfstream_write(file, save->buffer, save->bufsize) != save->bufsize); failed |= (intfstream_flush(file) != 0); failed |= (intfstream_close(file) != 0); + free(file); if (failed) RARCH_WARN("Failed to autosave SRAM. Disk might be full.\n"); } @@ -532,6 +533,7 @@ static void task_save_handler_finished(retro_task_t *task, task_set_finished(task, true); intfstream_close(state->file); + free(state->file); if (!task_get_error(task) && task_get_cancelled(task)) task_set_error(task, strdup("Task canceled")); @@ -713,7 +715,10 @@ static void task_load_handler_finished(retro_task_t *task, task_set_finished(task, true); if (state->file) + { intfstream_close(state->file); + free(state->file); + } if (!task_get_error(task) && task_get_cancelled(task)) task_set_error(task, strdup("Task canceled")); From 2a5bda2b14b843f5eba5178272aeb0c17bfad2ce Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 11 Dec 2017 20:40:59 +0100 Subject: [PATCH 321/394] C89_BUILD fix --- audio/drivers/wasapi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/audio/drivers/wasapi.c b/audio/drivers/wasapi.c index 973be6411c..e11d8056e0 100644 --- a/audio/drivers/wasapi.c +++ b/audio/drivers/wasapi.c @@ -336,8 +336,9 @@ static IAudioClient *wasapi_init_client_sh(IMMDevice *device, if (hr == AUDCLNT_E_ALREADY_INITIALIZED) { + HRESULT hr; WASAPI_RELEASE(client); - HRESULT hr = _IMMDevice_Activate(device, + hr = _IMMDevice_Activate(device, IID_IAudioClient, CLSCTX_ALL, NULL, (void**)&client); WASAPI_HR_CHECK(hr, "IMMDevice::Activate", return NULL); From c03b791b46073c63cdca912cf98cf4b82046bea8 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 11 Dec 2017 20:51:46 +0100 Subject: [PATCH 322/394] Start adding stub VFS implementation --- Makefile.common | 1 + griffin/griffin.c | 1 + .../include/vfs/vfs_implementation.h | 63 ++++++++++ libretro-common/vfs/vfs_implementation.c | 117 ++++++++++++++++++ 4 files changed, 182 insertions(+) create mode 100644 libretro-common/include/vfs/vfs_implementation.h create mode 100644 libretro-common/vfs/vfs_implementation.c diff --git a/Makefile.common b/Makefile.common index 07bf65126d..5192894c41 100644 --- a/Makefile.common +++ b/Makefile.common @@ -183,6 +183,7 @@ OBJ += frontend/frontend.o \ $(LIBRETRO_COMM_DIR)/streams/file_stream_transforms.o \ $(LIBRETRO_COMM_DIR)/streams/interface_stream.o \ $(LIBRETRO_COMM_DIR)/streams/memory_stream.o \ + $(LIBRETRO_COMM_DIR)/vfs/vfs_implementation.o \ $(LIBRETRO_COMM_DIR)/lists/string_list.o \ $(LIBRETRO_COMM_DIR)/string/stdstring.o \ $(LIBRETRO_COMM_DIR)/memmap/memalign.o \ diff --git a/griffin/griffin.c b/griffin/griffin.c index 8ac7762892..9d866cb00e 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -820,6 +820,7 @@ FILE #include "../libretro-common/streams/file_stream_transforms.c" #include "../libretro-common/streams/interface_stream.c" #include "../libretro-common/streams/memory_stream.c" +#include "../libretro-common/vfs/vfs_implementation.c" #include "../list_special.c" #include "../libretro-common/string/stdstring.c" #include "../libretro-common/file/nbio/nbio_stdio.c" diff --git a/libretro-common/include/vfs/vfs_implementation.h b/libretro-common/include/vfs/vfs_implementation.h new file mode 100644 index 0000000000..852907b5d2 --- /dev/null +++ b/libretro-common/include/vfs/vfs_implementation.h @@ -0,0 +1,63 @@ +/* Copyright (C) 2010-2017 The RetroArch team +* +* --------------------------------------------------------------------------------------- +* The following license statement only applies to this file (vfs_implementation.h). +* --------------------------------------------------------------------------------------- +* +* Permission is hereby granted, free of charge, +* to any person obtaining a copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation the rights to +* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, +* and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#ifndef __LIBRETRO_SDK_VFS_IMPLEMENTATION_H +#define __LIBRETRO_SDK_VFS_IMPLEMENTATION_H + +#include +#include + +/* Replace the following symbol with something appropriate + * to signify the file is being compiled for a front end instead of a core. + * This allows the same code to act as reference implementation + * for VFS and as fallbacks for when the front end does not provide VFS functionality. + */ + +#ifdef VFS_FRONTEND +typedef struct retro_vfs_file_handle libretro_vfs_implementation_file; +#else +typedef struct libretro_vfs_implementation_file libretro_vfs_implementation_file; +#endif + +libretro_vfs_implementation_file *retro_vfs_file_open_impl(const char *path, uint64_t flags); + +int retro_vfs_file_close_impl(libretro_vfs_implementation_file *stream); + +int retro_vfs_file_error_impl(libretro_vfs_implementation_file *stream); + +int64_t retro_vfs_file_size_impl(libretro_vfs_implementation_file *stream); + +int64_t retro_vfs_file_tell_impl(libretro_vfs_implementation_file *stream); + +int64_t retro_vfs_file_seek_impl(libretro_vfs_implementation_file *stream, int64_t offset); + +int64_t retro_vfs_file_read_impl(libretro_vfs_implementation_file *stream, void *s, uint64_t len); + +int64_t retro_vfs_file_write_impl(libretro_vfs_implementation_file *stream, const void *s, uint64_t len); + +int retro_vfs_file_flush_impl(libretro_vfs_implementation_file *stream); + +int retro_vfs_file_delete_impl(const char *path); + +const char *retro_vfs_file_get_path_impl(libretro_vfs_implementation_file *stream); + +#endif diff --git a/libretro-common/vfs/vfs_implementation.c b/libretro-common/vfs/vfs_implementation.c new file mode 100644 index 0000000000..d705e8be64 --- /dev/null +++ b/libretro-common/vfs/vfs_implementation.c @@ -0,0 +1,117 @@ +/* Copyright (C) 2010-2017 The RetroArch team +* +* --------------------------------------------------------------------------------------- +* The following license statement only applies to this file (vfs_implementation.c). +* --------------------------------------------------------------------------------------- +* +* Permission is hereby granted, free of charge, +* to any person obtaining a copy of this software and associated documentation files (the "Software"), +* to deal in the Software without restriction, including without limitation the rights to +* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, +* and to permit persons to whom the Software is furnished to do so, subject to the following conditions: +* +* The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. +* +* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, +* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. +* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, +* WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. +*/ + +#include +#include +#include +#include + +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + +#include +#include +#include +#include +#include + +enum libretro_file_hints +{ + RFILE_HINT_MMAP = 1 << 8, + RFILE_HINT_UNBUFFERED = 1 << 9 +}; + +#ifdef VFS_FRONTEND +struct retro_vfs_file_handle +#else +struct libretro_vfs_implementation_file +#endif +{ + void *empty; +}; + +int64_t retro_vfs_file_seek_internal(libretro_vfs_implementation_file *stream, int64_t offset, int whence) +{ + return -1; +} + +libretro_vfs_implementation_file *retro_vfs_file_open_impl(const char *path, uint64_t mode) +{ + libretro_vfs_implementation_file *stream = (libretro_vfs_implementation_file*)calloc(1, sizeof(*stream)); + + if (!stream) + return NULL; + + return stream; +} + +int retro_vfs_file_close_impl(libretro_vfs_implementation_file *stream) +{ + return -1; +} + +int retro_vfs_file_error_impl(libretro_vfs_implementation_file *stream) +{ + return 0; +} + +int64_t retro_vfs_file_size_impl(libretro_vfs_implementation_file *stream) +{ + return -1; +} + +int64_t retro_vfs_file_tell_impl(libretro_vfs_implementation_file *stream) +{ + return -1; +} + +int64_t retro_vfs_file_seek_impl(libretro_vfs_implementation_file *stream, int64_t offset) +{ + return retro_vfs_file_seek_internal(stream, offset, SEEK_SET); +} + +int64_t retro_vfs_file_read_impl(libretro_vfs_implementation_file *stream, void *s, uint64_t len) +{ + return -1; +} + +int64_t retro_vfs_file_write_impl(libretro_vfs_implementation_file *stream, const void *s, uint64_t len) +{ + return -1; +} + +int retro_vfs_file_flush_impl(libretro_vfs_implementation_file *stream) +{ + return 0; +} + +int retro_vfs_file_delete_impl(const char *path) +{ + return 0; +} + +const char *retro_vfs_file_get_path_impl(libretro_vfs_implementation_file *stream) +{ + return NULL; +} + From 57b730ab611406c989f507205c2f59688ce14c0d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 11 Dec 2017 21:24:14 +0100 Subject: [PATCH 323/394] Start implementing VFS layer ; first split up VFS libretro functionality to separate header until things are finalized --- gfx/video_shader_parse.c | 2 +- libretro-common/include/libretro.h | 11 -- libretro-common/include/libretro_vfs.h | 129 ++++++++++++++++++ libretro-common/include/streams/file_stream.h | 2 +- libretro-common/streams/file_stream.c | 48 +++++++ libretro-common/vfs/vfs_implementation.c | 6 - movie.c | 1 + 7 files changed, 180 insertions(+), 19 deletions(-) create mode 100644 libretro-common/include/libretro_vfs.h diff --git a/gfx/video_shader_parse.c b/gfx/video_shader_parse.c index b7a36c7af4..e8f18968a7 100644 --- a/gfx/video_shader_parse.c +++ b/gfx/video_shader_parse.c @@ -17,7 +17,7 @@ #include #include -#include +#include #include #include #include diff --git a/libretro-common/include/libretro.h b/libretro-common/include/libretro.h index 6a0929b302..0525d1a0eb 100644 --- a/libretro-common/include/libretro.h +++ b/libretro-common/include/libretro.h @@ -1044,17 +1044,6 @@ struct retro_hw_render_context_negotiation_interface * recognize or support. Should be set in either retro_init or retro_load_game, but not both. */ -/* File open flags - * Introduced in VFS API v1 */ -#define RETRO_VFS_FILE_ACCESS_READ (1 << 0) /* Read only mode */ -#define RETRO_VFS_FILE_ACCESS_WRITE (1 << 1) /* Write only mode, discard contents and overwrites existing file unless RETRO_VFS_FILE_ACCESS_UPDATE is also specified */ -#define RETRO_VFS_FILE_ACCESS_READ_WRITE (RETRO_VFS_FILE_ACCESS_READ | RETRO_VFS_FILE_ACCESS_WRITE) /* Read-write mode, discard contents and overwrites existing file unless RETRO_VFS_FILE_ACCESS_UPDATE is also specified*/ -#define RETRO_VFS_FILE_ACCESS_UPDATE_EXISTING (1 << 2) /* Prevents discarding content of existing files opened for writing */ - -#define RETRO_VFS_FILE_ACCESS_HINT_NONE (0) -/* Indicate that we would want to map the file into memory if possible. Requires RETRO_VFS_FILE_ACCESS_READ. This is only a hint and it is up to the frontend to honor and implement it. */ -#define RETRO_VFS_FILE_ACCESS_HINT_MEMORY_MAP (1 << 0) - #define RETRO_MEMDESC_CONST (1 << 0) /* The frontend will never change this memory area once retro_load_game has returned. */ #define RETRO_MEMDESC_BIGENDIAN (1 << 1) /* The memory area contains big endian data. Default is little endian. */ #define RETRO_MEMDESC_ALIGN_2 (1 << 16) /* All memory access in this area is aligned to their own size, or 2, whichever is smaller. */ diff --git a/libretro-common/include/libretro_vfs.h b/libretro-common/include/libretro_vfs.h new file mode 100644 index 0000000000..c0a40afe01 --- /dev/null +++ b/libretro-common/include/libretro_vfs.h @@ -0,0 +1,129 @@ +/* Copyright (C) 2010-2017 The RetroArch team + * + * --------------------------------------------------------------------------------------- + * The following license statement only applies to this libretro API header (libretro_vfs.h). + * --------------------------------------------------------------------------------------- + * + * Permission is hereby granted, free of charge, + * to any person obtaining a copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation the rights to + * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, + * and to permit persons to whom the Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, + * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. + * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, + * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +#ifndef LIBRETRO_VFS_H__ +#define LIBRETRO_VFS_H__ + +#ifdef __cplusplus +extern "C" { +#endif + +#include + +/* Opaque file handle + * Introduced in VFS API v1 */ +struct retro_vfs_file_handle; + +/* File open flags + * Introduced in VFS API v1 */ +#define RETRO_VFS_FILE_ACCESS_READ (1 << 0) /* Read only mode */ +#define RETRO_VFS_FILE_ACCESS_WRITE (1 << 1) /* Write only mode, discard contents and overwrites existing file unless RETRO_VFS_FILE_ACCESS_UPDATE is also specified */ +#define RETRO_VFS_FILE_ACCESS_READ_WRITE (RETRO_VFS_FILE_ACCESS_READ | RETRO_VFS_FILE_ACCESS_WRITE) /* Read-write mode, discard contents and overwrites existing file unless RETRO_VFS_FILE_ACCESS_UPDATE is also specified*/ +#define RETRO_VFS_FILE_ACCESS_UPDATE_EXISTING (1 << 2) /* Prevents discarding content of existing files opened for writing */ + +#define RETRO_VFS_FILE_ACCESS_HINT_NONE (0) +/* Indicate that we would want to map the file into memory if possible. Requires RETRO_VFS_FILE_ACCESS_READ. This is only a hint and it is up to the frontend to honor and implement it. */ +#define RETRO_VFS_FILE_ACCESS_HINT_MEMORY_MAP (1 << 0) + + +/* Get path from opaque handle. Returns the exact same path passed to file_open when getting the handle + * Introduced in VFS API v1 */ +typedef const char *(RETRO_CALLCONV *retro_vfs_file_get_path_t)(struct retro_vfs_file_handle *stream); + +/* Open a file for reading or writing. If path points to a directory, this will + * fail. Returns the opaque file handle, or NULL for error. + * Introduced in VFS API v1 */ +typedef struct retro_vfs_file_handle *(RETRO_CALLCONV *retro_vfs_file_open_t)(const char *path, uint64_t flags); + +/* Close the file and release its resources. Must be called if open_file returns non-NULL. Returns 0 on succes, -1 on failure. + * Whether the call succeeds ot not, the handle passed as parameter becomes invalid and should no longer be used. + * Introduced in VFS API v1 */ +typedef int (RETRO_CALLCONV *retro_vfs_file_close_t)(struct retro_vfs_file_handle *stream); + +/* Return the size of the file in bytes, or -1 for error. + * Introduced in VFS API v1 */ +typedef int64_t (RETRO_CALLCONV *retro_vfs_file_size_t)(struct retro_vfs_file_handle *stream); + +/* Get the current read / write position for the file. Returns - 1 for error. + * Introduced in VFS API v1 */ +typedef int64_t (RETRO_CALLCONV *retro_vfs_file_tell_t)(struct retro_vfs_file_handle *stream); + +/* Set the current read/write position for the file. Returns the new position, -1 for error. + * Introduced in VFS API v1 */ +typedef int64_t (RETRO_CALLCONV *retro_vfs_file_seek_t)(struct retro_vfs_file_handle *stream, int64_t offset); + +/* Read data from a file. Returns the number of bytes read, or -1 for error. + * Introduced in VFS API v1 */ +typedef int64_t (RETRO_CALLCONV *retro_vfs_file_read_t)(struct retro_vfs_file_handle *stream, void *s, uint64_t len); + +/* Write data to a file. Returns the number of bytes written, or -1 for error. + * Introduced in VFS API v1 */ +typedef int64_t (RETRO_CALLCONV *retro_vfs_file_write_t)(struct retro_vfs_file_handle *stream, const void *s, uint64_t len); + +/* Flush pending writes to file, if using buffered IO. Returns 0 on sucess, or -1 on failure. + * Introduced in VFS API v1 */ +typedef int (RETRO_CALLCONV *retro_vfs_file_flush_t)(struct retro_vfs_file_handle *stream); + +/* Delete the specified file. Returns 0 on success, -1 on failure + * Introduced in VFS API v1 */ +typedef int (RETRO_CALLCONV *retro_vfs_file_delete_t)(const char *path); + +struct retro_vfs_interface +{ + retro_vfs_file_get_path_t file_get_path; + retro_vfs_file_open_t file_open; + retro_vfs_file_close_t file_close; + retro_vfs_file_size_t file_size; + retro_vfs_file_tell_t file_tell; + retro_vfs_file_seek_t file_seek; + retro_vfs_file_read_t file_read; + retro_vfs_file_write_t file_write; + retro_vfs_file_flush_t file_flush; + retro_vfs_file_delete_t file_delete; +}; + +struct retro_vfs_interface_info +{ + /* Set by core: should this be higher than the version the front end supports, + * front end will return false in the RETRO_ENVIRONMENT_GET_VFS_INTERFACE call + * Introduced in VFS API v1 */ + uint32_t required_interface_version; + + /* Frontend writes interface pointer here. The frontend also sets the actual + * version, must be at least required_interface_version. + * Introduced in VFS API v1 */ + struct retro_vfs_interface *iface; +}; + +#define RETRO_ENVIRONMENT_GET_VFS_INTERFACE (45 | RETRO_ENVIRONMENT_EXPERIMENTAL) + /* struct retro_vfs_interface_info * -- + * Gets access to the VFS interface. + * VFS presence needs to be queried prior to load_game or any + * get_system/save/other_directory being called to let front end know + * core supports VFS before it starts handing out paths. + * It is recomended to do so in retro_set_environment */ + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libretro-common/include/streams/file_stream.h b/libretro-common/include/streams/file_stream.h index 2ee44ec096..41b7ed6c59 100644 --- a/libretro-common/include/streams/file_stream.h +++ b/libretro-common/include/streams/file_stream.h @@ -30,7 +30,7 @@ #include -#include +#include #include #include #include diff --git a/libretro-common/streams/file_stream.c b/libretro-common/streams/file_stream.c index 59bc1f90d4..c7d062a9ed 100644 --- a/libretro-common/streams/file_stream.c +++ b/libretro-common/streams/file_stream.c @@ -78,11 +78,23 @@ #include #include +#include #include #include #include #include +retro_vfs_file_get_path_t filestream_get_path_cb = NULL; +retro_vfs_file_open_t filestream_open_cb = NULL; +retro_vfs_file_close_t filestream_close_cb = NULL; +retro_vfs_file_size_t filestream_size_cb = NULL; +retro_vfs_file_tell_t filestream_tell_cb = NULL; +retro_vfs_file_seek_t filestream_seek_cb = NULL; +retro_vfs_file_read_t filestream_read_cb = NULL; +retro_vfs_file_write_t filestream_write_cb = NULL; +retro_vfs_file_flush_t filestream_flush_cb = NULL; +retro_vfs_file_delete_t filestream_delete_cb = NULL; + struct RFILE { unsigned hints; @@ -110,6 +122,42 @@ struct RFILE char *buf; }; +/* VFS Initialization */ + +void filestream_vfs_init(const struct retro_vfs_interface_info* vfs_info) +{ + const struct retro_vfs_interface* vfs_iface; + + filestream_get_path_cb = NULL; + filestream_open_cb = NULL; + filestream_close_cb = NULL; + filestream_tell_cb = NULL; + filestream_size_cb = NULL; + filestream_seek_cb = NULL; + filestream_read_cb = NULL; + filestream_write_cb = NULL; + filestream_flush_cb = NULL; + filestream_delete_cb = NULL; + + vfs_iface = vfs_info->iface; + + if (vfs_info->required_interface_version < FILESTREAM_REQUIRED_VFS_VERSION || vfs_iface == NULL) + return; + + filestream_get_path_cb = vfs_iface->file_get_path; + filestream_open_cb = vfs_iface->file_open; + filestream_close_cb = vfs_iface->file_close; + filestream_size_cb = vfs_iface->file_size; + filestream_tell_cb = vfs_iface->file_tell; + filestream_seek_cb = vfs_iface->file_seek; + filestream_read_cb = vfs_iface->file_read; + filestream_write_cb = vfs_iface->file_write; + filestream_flush_cb = vfs_iface->file_flush; + filestream_delete_cb = vfs_iface->file_delete; +} + +/* Callback wrappers */ + int64_t filestream_get_size(RFILE *stream) { if (!stream) diff --git a/libretro-common/vfs/vfs_implementation.c b/libretro-common/vfs/vfs_implementation.c index d705e8be64..b0046889b3 100644 --- a/libretro-common/vfs/vfs_implementation.c +++ b/libretro-common/vfs/vfs_implementation.c @@ -35,12 +35,6 @@ #include #include -enum libretro_file_hints -{ - RFILE_HINT_MMAP = 1 << 8, - RFILE_HINT_UNBUFFERED = 1 << 9 -}; - #ifdef VFS_FRONTEND struct retro_vfs_file_handle #else diff --git a/movie.c b/movie.c index 131062d42c..535b8eacef 100644 --- a/movie.c +++ b/movie.c @@ -17,6 +17,7 @@ #include #include +#include #include #include #include From dca96ba6ad2d924121534472c193a4d30d5281ef Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 11 Dec 2017 21:49:51 +0100 Subject: [PATCH 324/394] Reimplement filestream_getc --- libretro-common/streams/file_stream.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/libretro-common/streams/file_stream.c b/libretro-common/streams/file_stream.c index c7d062a9ed..7bcc85fade 100644 --- a/libretro-common/streams/file_stream.c +++ b/libretro-common/streams/file_stream.c @@ -337,9 +337,13 @@ char *filestream_gets(RFILE *stream, char *s, size_t len) int filestream_getc(RFILE *stream) { + char c = 0; + (void)c; if (!stream) return 0; - return fgetc(stream->fp); + if(filestream_read(stream, &c, 1) == 1) + return (int)c; + return EOF; } ssize_t filestream_seek(RFILE *stream, ssize_t offset, int whence) From 779d9a4258c9ce1af5bc4967d4d879650bbf63be Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 11 Dec 2017 21:58:17 +0100 Subject: [PATCH 325/394] Cleanup --- libretro-common/streams/file_stream.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libretro-common/streams/file_stream.c b/libretro-common/streams/file_stream.c index 7bcc85fade..a605b42a69 100644 --- a/libretro-common/streams/file_stream.c +++ b/libretro-common/streams/file_stream.c @@ -338,7 +338,6 @@ char *filestream_gets(RFILE *stream, char *s, size_t len) int filestream_getc(RFILE *stream) { char c = 0; - (void)c; if (!stream) return 0; if(filestream_read(stream, &c, 1) == 1) From 9aa3dc2423c5c00866781e9544ca9bfb2285d085 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Mon, 11 Dec 2017 22:01:54 +0100 Subject: [PATCH 326/394] Buildfix --- libretro-common/streams/file_stream.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libretro-common/streams/file_stream.c b/libretro-common/streams/file_stream.c index a605b42a69..7fe5b0d555 100644 --- a/libretro-common/streams/file_stream.c +++ b/libretro-common/streams/file_stream.c @@ -78,7 +78,7 @@ #include #include -#include +#include #include #include #include From 940f0c6b0b68c027e3c953802fa91e23102f6b60 Mon Sep 17 00:00:00 2001 From: ggf906 Date: Tue, 12 Dec 2017 00:04:35 +0100 Subject: [PATCH 327/394] (PSP) Strip and user 64MB where available --- Makefile.psp1 | 6 ++++-- Makefile.psp1.salamander | 7 ++++--- bootstrap/psp1/kernel_functions_prx/Makefile | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/Makefile.psp1 b/Makefile.psp1 index a99c89e754..b5e143cf0a 100644 --- a/Makefile.psp1 +++ b/Makefile.psp1 @@ -1,6 +1,8 @@ -BUILD_PRX = 1 +BUILD_PRX = 0 +PSP_LARGE_MEMORY = 1 DEBUG = 0 HAVE_KERNEL_PRX = 1 +HAVE_LOGGER = 0 HAVE_FILE_LOGGER = 0 HAVE_THREADS = 0 BIG_STACK = 0 @@ -11,7 +13,7 @@ TARGET = retroarchpsp ifeq ($(DEBUG), 1) OPTIMIZE_LV := -O0 -g else - OPTIMIZE_LV := -O3 -g + OPTIMIZE_LV := -O3 endif ifeq ($(WHOLE_ARCHIVE_LINK), 1) diff --git a/Makefile.psp1.salamander b/Makefile.psp1.salamander index 68e0732582..a59603fa93 100644 --- a/Makefile.psp1.salamander +++ b/Makefile.psp1.salamander @@ -1,4 +1,5 @@ -BUILD_PRX = 1 +BUILD_PRX = 0 +PSP_LARGE_MEMORY = 1 HAVE_FILE_LOGGER = 0 DEBUG = 0 @@ -7,7 +8,7 @@ TARGET = retroarchpsp_salamander ifeq ($(DEBUG), 1) OPTIMIZE_LV := -O0 -g else - OPTIMIZE_LV := -O2 -g + OPTIMIZE_LV := -O2 endif INCDIR = $(PSPPATH)/include libretro-common/include @@ -24,7 +25,7 @@ ifeq ($(HAVE_FILE_LOGGER), 1) CFLAGS += -DHAVE_FILE_LOGGER endif -CFLAGS += $(RARCH_DEFINES) +CFLAGS += $(RARCH_DEFINES) EXTRA_TARGETS = EBOOT.PBP PSP_EBOOT_TITLE = RetroArch diff --git a/bootstrap/psp1/kernel_functions_prx/Makefile b/bootstrap/psp1/kernel_functions_prx/Makefile index 0b6cdc3d41..810ade49ca 100644 --- a/bootstrap/psp1/kernel_functions_prx/Makefile +++ b/bootstrap/psp1/kernel_functions_prx/Makefile @@ -14,7 +14,7 @@ USE_KERNEL_LIBC=1 USE_KERNEL_LIBS=1 LIBDIR = -LDFLAGS = -mno-crt0 -nostartfiles +LDFLAGS = -nostartfiles LIBS = -lpspdebug -lpspge -lpspsdk -lc -lpspuser PSPSDK=$(shell psp-config --pspsdk-path) include $(PSPSDK)/lib/build.mak From 247b9ea97334857e35325d5f8be8fa7ee4c2cb5f Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Mon, 11 Dec 2017 18:12:32 -0500 Subject: [PATCH 328/394] add menu setting for window opacity, includes generic display server interface --- Makefile.common | 3 ++ config.def.h | 5 +++ configuration.c | 1 + configuration.h | 1 + gfx/common/win32_common.c | 10 +++++ gfx/display_servers/dispserv_null.c | 43 ++++++++++++++++++++ gfx/display_servers/dispserv_win32.c | 60 ++++++++++++++++++++++++++++ gfx/video_display_server.c | 55 +++++++++++++++++++++++++ gfx/video_display_server.h | 43 ++++++++++++++++++++ gfx/video_driver.c | 4 ++ griffin/griffin.c | 5 ++- intl/msg_hash_ja.h | 2 + intl/msg_hash_lbl.h | 2 + intl/msg_hash_us.h | 2 + menu/menu_displaylist.c | 3 ++ menu/menu_setting.c | 17 ++++++++ msg_hash.h | 1 + 17 files changed, 255 insertions(+), 2 deletions(-) create mode 100644 gfx/display_servers/dispserv_null.c create mode 100644 gfx/display_servers/dispserv_win32.c create mode 100644 gfx/video_display_server.c create mode 100644 gfx/video_display_server.h diff --git a/Makefile.common b/Makefile.common index 5192894c41..3c4e25dcc0 100644 --- a/Makefile.common +++ b/Makefile.common @@ -202,6 +202,7 @@ OBJ += frontend/frontend.o \ $(LIBRETRO_COMM_DIR)/audio/audio_mixer.o \ input/input_driver.o \ gfx/video_coord_array.o \ + gfx/video_display_server.o \ gfx/video_driver.o \ camera/camera_driver.o \ wifi/wifi_driver.o \ @@ -248,6 +249,7 @@ OBJ += frontend/frontend.o \ camera/drivers/nullcamera.o \ wifi/drivers/nullwifi.o \ gfx/drivers/nullgfx.o \ + gfx/display_servers/dispserv_null.o \ audio/drivers/nullaudio.o \ input/drivers/nullinput.o \ input/drivers_hid/null_hid.o \ @@ -1551,6 +1553,7 @@ ifneq ($(findstring Win32,$(OS)),) OBJ += gfx/drivers/gdi_gfx.o \ gfx/drivers_context/gdi_ctx.o \ gfx/drivers_font/gdi_font.o \ + gfx/display_servers/dispserv_win32.o \ menu/drivers_display/menu_display_gdi.o LIBS += -lmsimg32 -lhid -lsetupapi diff --git a/config.def.h b/config.def.h index 4145be9d77..50036db322 100644 --- a/config.def.h +++ b/config.def.h @@ -115,6 +115,11 @@ static const unsigned window_y = 0; static const unsigned fullscreen_x = 0; static const unsigned fullscreen_y = 0; +/* Amount of transparency to use for the main window. + * 1 is the most transparent while 100 is opaque. + */ +static const unsigned window_opacity = 100; + #if defined(RARCH_CONSOLE) || defined(__APPLE__) static const bool load_dummy_on_core_shutdown = false; #else diff --git a/configuration.c b/configuration.c index bcb7b0c578..bec0b42878 100644 --- a/configuration.c +++ b/configuration.c @@ -1378,6 +1378,7 @@ static struct config_uint_setting *populate_settings_uint(settings_t *settings, SETTING_UINT("video_fullscreen_y", &settings->uints.video_fullscreen_y, true, fullscreen_y, false); SETTING_UINT("video_window_x", &settings->uints.video_window_x, true, fullscreen_x, false); SETTING_UINT("video_window_y", &settings->uints.video_window_y, true, fullscreen_y, false); + SETTING_UINT("video_window_opacity", &settings->uints.video_window_opacity, true, window_opacity, false); #ifdef HAVE_COMMAND SETTING_UINT("network_cmd_port", &settings->uints.network_cmd_port, true, network_cmd_port, false); #endif diff --git a/configuration.h b/configuration.h index c81a53f962..c94b215209 100644 --- a/configuration.h +++ b/configuration.h @@ -325,6 +325,7 @@ typedef struct settings unsigned keymapper_port; unsigned video_window_x; unsigned video_window_y; + unsigned video_window_opacity; unsigned video_monitor_index; unsigned video_fullscreen_x; unsigned video_fullscreen_y; diff --git a/gfx/common/win32_common.c b/gfx/common/win32_common.c index a8a696cbb2..426632bbd0 100644 --- a/gfx/common/win32_common.c +++ b/gfx/common/win32_common.c @@ -45,6 +45,7 @@ #include "../../input/input_driver.h" #include "../../input/input_keymaps.h" #include "../video_thread_wrapper.h" +#include "../video_display_server.h" #include #ifdef HAVE_MENU @@ -742,6 +743,7 @@ bool win32_window_create(void *data, unsigned style, RECT *mon_rect, unsigned width, unsigned height, bool fullscreen) { + settings_t *settings = config_get_ptr(); #ifndef _XBOX main_window.hwnd = CreateWindowEx(0, "RetroArch", "RetroArch", @@ -756,6 +758,14 @@ bool win32_window_create(void *data, unsigned style, video_driver_display_type_set(RARCH_DISPLAY_WIN32); video_driver_display_set(0); video_driver_window_set((uintptr_t)main_window.hwnd); + +#if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0500 + /* Windows 2000 and above use layered windows to enable transparency */ + SetWindowLongPtr(main_window.hwnd, + GWL_EXSTYLE, + GetWindowLongPtr(main_window.hwnd, GWL_EXSTYLE) | WS_EX_LAYERED); + SetLayeredWindowAttributes(main_window.hwnd, 0, (255 * settings->uints.video_window_opacity) / 100, LWA_ALPHA); +#endif #endif return true; } diff --git a/gfx/display_servers/dispserv_null.c b/gfx/display_servers/dispserv_null.c new file mode 100644 index 0000000000..c40ef5bfc1 --- /dev/null +++ b/gfx/display_servers/dispserv_null.c @@ -0,0 +1,43 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2014 - Hans-Kristian Arntzen + * Copyright (C) 2011-2017 - Daniel De Matteis + * Copyright (C) 2016-2017 - Brad Parker + * + * RetroArch 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 Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch 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 RetroArch. + * If not, see . + */ + +#include "../video_display_server.h" + +static void* null_display_server_init() +{ + return NULL; +} + +static void null_display_server_destroy() +{ + +} + +static bool null_set_window_opacity(void *data, unsigned opacity) +{ + (void)data; + (void)opacity; + return true; +} + +const video_display_server_t dispserv_null = { + null_display_server_init, + null_display_server_destroy, + null_set_window_opacity, + "null" +}; + diff --git a/gfx/display_servers/dispserv_win32.c b/gfx/display_servers/dispserv_win32.c new file mode 100644 index 0000000000..fb66660640 --- /dev/null +++ b/gfx/display_servers/dispserv_win32.c @@ -0,0 +1,60 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2014 - Hans-Kristian Arntzen + * Copyright (C) 2011-2017 - Daniel De Matteis + * Copyright (C) 2016-2017 - Brad Parker + * + * RetroArch 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 Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch 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 RetroArch. + * If not, see . + */ + +#include +#include "../video_display_server.h" +#include "../common/win32_common.h" + +typedef struct +{ + unsigned opacity; +} dispserv_win32_t; + +static void* win32_display_server_init() +{ + dispserv_win32_t *dispserv = calloc(1, sizeof(*dispserv)); + + return dispserv; +} + +static void win32_display_server_destroy() +{ + +} + +static bool win32_set_window_opacity(void *data, unsigned opacity) +{ + HWND hwnd = win32_get_window(); + dispserv_win32_t *serv = (dispserv_win32_t*)data; + + serv->opacity = opacity; + +#if defined(_WIN32_WINNT) && _WIN32_WINNT >= 0x0500 + /* Set window transparency on Windows 2000 and above */ + return SetLayeredWindowAttributes(hwnd, 0, opacity, LWA_ALPHA); +#else + return false; +#endif +} + +const video_display_server_t dispserv_win32 = { + win32_display_server_init, + win32_display_server_destroy, + win32_set_window_opacity, + "win32" +}; + diff --git a/gfx/video_display_server.c b/gfx/video_display_server.c new file mode 100644 index 0000000000..67793d962f --- /dev/null +++ b/gfx/video_display_server.c @@ -0,0 +1,55 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2014 - Hans-Kristian Arntzen + * Copyright (C) 2011-2017 - Daniel De Matteis + * Copyright (C) 2016-2017 - Brad Parker + * + * RetroArch 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 Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch 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 RetroArch. + * If not, see . + */ + +#include +#include "video_display_server.h" +#include "video_driver.h" +#include "../verbosity.h" + +static const video_display_server_t *current_display_server = NULL; +static void *current_display_server_data = NULL; + +void* video_display_server_init() +{ + enum rarch_display_type type = video_driver_display_type_get(); + + switch (type) + { + case RARCH_DISPLAY_WIN32: + current_display_server = &dispserv_win32; + break; + default: + current_display_server = &dispserv_null; + break; + } + + current_display_server_data = current_display_server->init(); + + RARCH_LOG("[Video]: Found display server: %s\n", current_display_server->ident); + + return current_display_server_data; +} + +void video_display_server_destroy() +{ + +} + +bool video_display_server_set_window_opacity(unsigned opacity) +{ + return current_display_server->set_window_opacity(current_display_server_data, opacity); +} diff --git a/gfx/video_display_server.h b/gfx/video_display_server.h new file mode 100644 index 0000000000..1b16c75b97 --- /dev/null +++ b/gfx/video_display_server.h @@ -0,0 +1,43 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2014 - Hans-Kristian Arntzen + * Copyright (C) 2011-2017 - Daniel De Matteis + * Copyright (C) 2016-2017 - Brad Parker + * + * RetroArch 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 Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch 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 RetroArch. + * If not, see . + */ + +#ifndef __VIDEO_DISPLAY_SERVER__H +#define __VIDEO_DISPLAY_SERVER__H + +#include +#include + +RETRO_BEGIN_DECLS + +typedef struct video_display_server +{ + void *(*init)(void); + void (*destroy)(void); + bool (*set_window_opacity)(void *data, unsigned opacity); + const char *ident; +} video_display_server_t; + +void* video_display_server_init(void); +void video_display_server_destroy(void); +bool video_display_server_set_window_opacity(unsigned opacity); + +extern const video_display_server_t dispserv_win32; +extern const video_display_server_t dispserv_null; + +RETRO_END_DECLS + +#endif diff --git a/gfx/video_driver.c b/gfx/video_driver.c index c4174e6726..b07d869967 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -48,6 +48,7 @@ #include "video_thread_wrapper.h" #include "video_driver.h" +#include "video_display_server.h" #include "../frontend/frontend_driver.h" #include "../record/record_driver.h" @@ -1089,6 +1090,8 @@ static bool video_driver_init_internal(bool *video_is_threaded) video_context_driver_reset(); + video_display_server_init(); + return true; error: @@ -1550,6 +1553,7 @@ static void video_driver_lock_new(void) void video_driver_destroy(void) { + video_display_server_destroy(); video_driver_cb_has_focus = null_driver_has_focus; video_driver_use_rgba = false; video_driver_data_own = false; diff --git a/griffin/griffin.c b/griffin/griffin.c index 9d866cb00e..720965d34d 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -188,9 +188,8 @@ VIDEO CONTEXT #include "../gfx/drivers_context/wgl_ctx.c" #endif -#if defined(_WIN32) && !defined(_XBOX) #include "../gfx/drivers_context/gdi_ctx.c" -#endif +#include "../gfx/display_servers/dispserv_win32.c" #if defined(HAVE_FFMPEG) #if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES3) @@ -371,6 +370,7 @@ VIDEO DRIVER #endif #include "../gfx/drivers_renderchain/null_renderchain.c" +#include "../gfx/display_servers/dispserv_null.c" #ifdef HAVE_OPENGL #include "../gfx/common/gl_common.c" @@ -746,6 +746,7 @@ AUDIO DRIVERS ============================================================ */ #include "../gfx/video_driver.c" +#include "../gfx/video_display_server.c" #include "../gfx/video_coord_array.c" #include "../input/input_driver.c" #include "../audio/audio_driver.c" diff --git a/intl/msg_hash_ja.h b/intl/msg_hash_ja.h index ec16dabcc3..ab498da29b 100644 --- a/intl/msg_hash_ja.h +++ b/intl/msg_hash_ja.h @@ -3263,3 +3263,5 @@ MSG_HASH(MENU_ENUM_SUBLABEL_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, "Automatically scans loaded content so they appear inside playlists.") MSG_HASH(MSG_SCANNING_OF_FILE_FINISHED, "Scanning of file finished") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_OPACITY, + "ウィンドウの不透明性") diff --git a/intl/msg_hash_lbl.h b/intl/msg_hash_lbl.h index a097ee5c90..bc5721bce0 100644 --- a/intl/msg_hash_lbl.h +++ b/intl/msg_hash_lbl.h @@ -1377,3 +1377,5 @@ MSG_HASH(MENU_ENUM_LABEL_FRAMECOUNT_SHOW, "framecount_show") MSG_HASH(MENU_ENUM_LABEL_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, "automatically_add_content_to_playlist") +MSG_HASH(MENU_ENUM_LABEL_VIDEO_WINDOW_OPACITY, + "video_window_opacity") diff --git a/intl/msg_hash_us.h b/intl/msg_hash_us.h index 25a36dda4f..e7ad35b7cc 100644 --- a/intl/msg_hash_us.h +++ b/intl/msg_hash_us.h @@ -3341,3 +3341,5 @@ MSG_HASH(MENU_ENUM_SUBLABEL_AUTOMATICALLY_ADD_CONTENT_TO_PLAYLIST, "Automatically scans loaded content so they appear inside playlists.") MSG_HASH(MSG_SCANNING_OF_FILE_FINISHED, "Scanning of file finished") +MSG_HASH(MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_OPACITY, + "Window Opacity") diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 8a60cf2735..d3167f036a 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -6028,6 +6028,9 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) menu_displaylist_parse_settings_enum(menu, info, MENU_ENUM_LABEL_VIDEO_WINDOW_HEIGHT, PARSE_ONLY_UINT, false); + menu_displaylist_parse_settings_enum(menu, info, + MENU_ENUM_LABEL_VIDEO_WINDOW_OPACITY, + PARSE_ONLY_UINT, false); menu_displaylist_parse_settings_enum(menu, info, MENU_ENUM_LABEL_VIDEO_SCALE_INTEGER, PARSE_ONLY_BOOL, false); diff --git a/menu/menu_setting.c b/menu/menu_setting.c index d55a5c8c81..f9ddce0cc1 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -81,6 +81,7 @@ #include "../setting_list.h" #include "../lakka.h" #include "../retroarch.h" +#include "../gfx/video_display_server.h" #include "../tasks/tasks_internal.h" @@ -1834,6 +1835,9 @@ void general_write_handler(void *data) retroarch_override_setting_set(RARCH_OVERRIDE_SETTING_NETPLAY_CHECK_FRAMES, NULL); #endif break; + case MENU_ENUM_LABEL_VIDEO_WINDOW_OPACITY: + video_display_server_set_window_opacity((255 * settings->uints.video_window_opacity) / 100); + break; default: break; } @@ -3628,6 +3632,19 @@ static bool setting_append_list( general_read_handler); menu_settings_list_current_add_range(list, list_info, 0, 4320, 8, true, true); settings_data_list_current_add_flags(list, list_info, SD_FLAG_LAKKA_ADVANCED); + CONFIG_UINT( + list, list_info, + &settings->uints.video_window_opacity, + MENU_ENUM_LABEL_VIDEO_WINDOW_OPACITY, + MENU_ENUM_LABEL_VALUE_VIDEO_WINDOW_OPACITY, + window_opacity, + &group_info, + &subgroup_info, + parent_group, + general_write_handler, + general_read_handler); + menu_settings_list_current_add_range(list, list_info, 1, 100, 1, true, true); + settings_data_list_current_add_flags(list, list_info, SD_FLAG_LAKKA_ADVANCED); } CONFIG_BOOL( diff --git a/msg_hash.h b/msg_hash.h index f9e92af1d3..48b55122ee 100644 --- a/msg_hash.h +++ b/msg_hash.h @@ -676,6 +676,7 @@ enum msg_hash_enums MENU_LABEL(VIDEO_WINDOWED_FULLSCREEN), MENU_LABEL(VIDEO_WINDOW_WIDTH), MENU_LABEL(VIDEO_WINDOW_HEIGHT), + MENU_LABEL(VIDEO_WINDOW_OPACITY), MENU_LABEL(VIDEO_FULLSCREEN_X), MENU_LABEL(VIDEO_FULLSCREEN_Y), MENU_LABEL(VIDEO_FORCE_SRGB_DISABLE), From 621d89c52eaffec1834c632fd2c19b4c7cfb8990 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 12 Dec 2017 00:17:17 +0100 Subject: [PATCH 329/394] (PSP1) Change to -O2 --- Makefile.psp1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Makefile.psp1 b/Makefile.psp1 index b5e143cf0a..31f5751f74 100644 --- a/Makefile.psp1 +++ b/Makefile.psp1 @@ -13,7 +13,7 @@ TARGET = retroarchpsp ifeq ($(DEBUG), 1) OPTIMIZE_LV := -O0 -g else - OPTIMIZE_LV := -O3 + OPTIMIZE_LV := -O2 endif ifeq ($(WHOLE_ARCHIVE_LINK), 1) From c265c8328cf3f5f7a1a21958a40cc4772339f6be Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Mon, 11 Dec 2017 18:22:40 -0500 Subject: [PATCH 330/394] buildfixes --- gfx/display_servers/dispserv_null.c | 1 + gfx/display_servers/dispserv_win32.c | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/gfx/display_servers/dispserv_null.c b/gfx/display_servers/dispserv_null.c index c40ef5bfc1..7974726cb4 100644 --- a/gfx/display_servers/dispserv_null.c +++ b/gfx/display_servers/dispserv_null.c @@ -15,6 +15,7 @@ * If not, see . */ +#include #include "../video_display_server.h" static void* null_display_server_init() diff --git a/gfx/display_servers/dispserv_win32.c b/gfx/display_servers/dispserv_win32.c index fb66660640..53e942eefc 100644 --- a/gfx/display_servers/dispserv_win32.c +++ b/gfx/display_servers/dispserv_win32.c @@ -26,7 +26,7 @@ typedef struct static void* win32_display_server_init() { - dispserv_win32_t *dispserv = calloc(1, sizeof(*dispserv)); + dispserv_win32_t *dispserv = (dispserv_win32_t*)calloc(1, sizeof(*dispserv)); return dispserv; } From b6644e2c3a27ffe8f6b24d3045e64f416ba9228f Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Mon, 11 Dec 2017 18:27:11 -0500 Subject: [PATCH 331/394] buildfix again --- gfx/video_display_server.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gfx/video_display_server.c b/gfx/video_display_server.c index 67793d962f..6ae67590a2 100644 --- a/gfx/video_display_server.c +++ b/gfx/video_display_server.c @@ -29,9 +29,11 @@ void* video_display_server_init() switch (type) { +#if defined(_WIN32) && !defined(_XBOX) case RARCH_DISPLAY_WIN32: current_display_server = &dispserv_win32; break; +#endif default: current_display_server = &dispserv_null; break; From d53dbbfd4e593971f2d278adac8bf6bde3609929 Mon Sep 17 00:00:00 2001 From: Brad Parker Date: Mon, 11 Dec 2017 18:50:10 -0500 Subject: [PATCH 332/394] style nits --- gfx/display_servers/dispserv_null.c | 4 ++-- gfx/display_servers/dispserv_win32.c | 4 ++-- gfx/video_display_server.c | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/gfx/display_servers/dispserv_null.c b/gfx/display_servers/dispserv_null.c index 7974726cb4..40697ac0b8 100644 --- a/gfx/display_servers/dispserv_null.c +++ b/gfx/display_servers/dispserv_null.c @@ -18,12 +18,12 @@ #include #include "../video_display_server.h" -static void* null_display_server_init() +static void* null_display_server_init(void) { return NULL; } -static void null_display_server_destroy() +static void null_display_server_destroy(void) { } diff --git a/gfx/display_servers/dispserv_win32.c b/gfx/display_servers/dispserv_win32.c index 53e942eefc..41958aabd8 100644 --- a/gfx/display_servers/dispserv_win32.c +++ b/gfx/display_servers/dispserv_win32.c @@ -24,14 +24,14 @@ typedef struct unsigned opacity; } dispserv_win32_t; -static void* win32_display_server_init() +static void* win32_display_server_init(void) { dispserv_win32_t *dispserv = (dispserv_win32_t*)calloc(1, sizeof(*dispserv)); return dispserv; } -static void win32_display_server_destroy() +static void win32_display_server_destroy(void) { } diff --git a/gfx/video_display_server.c b/gfx/video_display_server.c index 6ae67590a2..22a3b06cd0 100644 --- a/gfx/video_display_server.c +++ b/gfx/video_display_server.c @@ -23,7 +23,7 @@ static const video_display_server_t *current_display_server = NULL; static void *current_display_server_data = NULL; -void* video_display_server_init() +void* video_display_server_init(void) { enum rarch_display_type type = video_driver_display_type_get(); @@ -46,7 +46,7 @@ void* video_display_server_init() return current_display_server_data; } -void video_display_server_destroy() +void video_display_server_destroy(void) { } From 6904101c4430b8cd213453fbfb0480838ccc958e Mon Sep 17 00:00:00 2001 From: gblues Date: Mon, 11 Dec 2017 23:55:31 -0800 Subject: [PATCH 333/394] Clean up trailing whitespace == DETAILS Really simple code cleanup, because my editor flags trailing whitespaces and it's pretty annoying. --- audio/audio_driver.c | 76 +- audio/audio_driver.h | 6 +- audio/audio_thread_wrapper.c | 10 +- audio/audio_thread_wrapper.h | 2 +- audio/drivers/alsa.c | 4 +- audio/drivers/alsa_qsa.c | 10 +- audio/drivers/alsathread.c | 6 +- audio/drivers/coreaudio.c | 20 +- audio/drivers/ctr_csnd_audio.c | 6 +- audio/drivers/dsound.c | 14 +- audio/drivers/gx_audio.c | 6 +- audio/drivers/jack.c | 6 +- audio/drivers/nullaudio.c | 2 +- audio/drivers/openal.c | 2 +- audio/drivers/opensl.c | 4 +- audio/drivers/oss.c | 4 +- audio/drivers/ps3_audio.c | 6 +- audio/drivers/psp_audio.c | 8 +- audio/drivers/pulse.c | 12 +- audio/drivers/roar.c | 2 +- audio/drivers/rsound.c | 2 +- audio/drivers/rsound.h | 72 +- audio/drivers/rwebaudio.c | 2 +- audio/drivers/sdl_audio.c | 6 +- audio/drivers/tinyalsa.c | 10 +- audio/drivers/wasapi.c | 24 +- audio/drivers/xaudio.c | 52 +- audio/drivers/xaudio.h | 44 +- audio/drivers/xenon360_audio.c | 4 +- audio/drivers_resampler/cc_resampler.c | 4 +- audio/librsound.c | 40 +- autosave.h | 2 +- bootstrap/psp1/kernel_functions_prx/main.c | 2 +- bootstrap/vita/threading.c | 10 +- camera/camera_driver.c | 14 +- camera/camera_driver.h | 2 +- camera/drivers/android.c | 8 +- camera/drivers/nullcamera.c | 2 +- camera/drivers/rwebcam.c | 2 +- camera/drivers/video4linux2.c | 2 +- cheevos/badges.c | 110 +- cheevos/badges.h | 58 +- cheevos/cheevos.c | 4 +- cheevos/var.c | 4 +- command.c | 12 +- command.h | 2 +- configuration.h | 2 +- core.h | 8 +- core_info.c | 28 +- core_info.h | 2 +- core_type.h | 4 +- cores/dynamic_dummy.c | 2 +- cores/internal_cores.h | 2 +- cores/libretro-ffmpeg/ffmpeg_core.c | 42 +- cores/libretro-ffmpeg/ffmpeg_fft.c | 14 +- .../gl_shaders/ffmpeg_es.glsl.frag.h | 2 +- .../gl_shaders/fft_heightmap.glsl.vert.h | 2 +- cores/libretro-imageviewer/image_core.c | 8 +- .../video_processor_v4l2.c | 16 +- defaults.h | 4 +- defines/d3d_defines.h | 4 +- defines/gx_defines.h | 2 +- defines/ps3_defines.h | 2 +- deps/7zip/7z.h | 414 +- deps/7zip/7zBuf.c | 74 +- deps/7zip/7zBuf.h | 54 +- deps/7zip/7zCrc.c | 152 +- deps/7zip/7zCrc.h | 58 +- deps/7zip/7zCrcOpt.c | 76 +- deps/7zip/7zDec.c | 720 +-- deps/7zip/7zFile.c | 570 +-- deps/7zip/7zFile.h | 174 +- deps/7zip/7zIn.c | 2742 ++++++------ deps/7zip/7zStream.c | 346 +- deps/7zip/7zVersion.h | 14 +- deps/7zip/Bcj2.c | 298 +- deps/7zip/Bcj2.h | 76 +- deps/7zip/Bra.c | 268 +- deps/7zip/Bra.h | 136 +- deps/7zip/Bra86.c | 172 +- deps/7zip/CpuArch.h | 142 +- deps/7zip/LzFind.c | 58 +- deps/7zip/LzFind.h | 4 +- deps/7zip/Lzma2Dec.c | 694 +-- deps/7zip/Lzma2Dec.h | 170 +- deps/7zip/LzmaDec.c | 2080 ++++----- deps/7zip/LzmaDec.h | 440 +- deps/7zip/LzmaEnc.c | 56 +- deps/SPIRV-Cross/GLSL.std.450.h | 2 +- deps/glslang/glslang/SPIRV/GLSL.std.450.h | 2 +- deps/glslang/glslang/SPIRV/SPVRemapper.h | 10 +- deps/glslang/glslang/SPIRV/SpvBuilder.h | 2 +- deps/glslang/glslang/SPIRV/doc.h | 2 +- deps/glslang/glslang/SPIRV/spvIR.h | 10 +- deps/glslang/glslang/StandAlone/Worklist.h | 10 +- .../glslang/glslang/Include/BaseTypes.h | 4 +- deps/glslang/glslang/glslang/Include/Common.h | 8 +- .../glslang/glslang/Include/ConstantUnion.h | 42 +- .../glslang/glslang/Include/InfoSink.h | 10 +- .../glslang/glslang/Include/PoolAlloc.h | 28 +- .../glslang/glslang/Include/ResourceLimits.h | 2 +- .../glslang/glslang/Include/ShHandle.h | 16 +- deps/glslang/glslang/glslang/Include/Types.h | 4 +- .../glslang/glslang/Include/intermediate.h | 18 +- .../glslang/MachineIndependent/Initialize.h | 4 +- .../glslang/MachineIndependent/ParseHelper.h | 2 +- .../glslang/glslang/MachineIndependent/Scan.h | 2 +- .../glslang/MachineIndependent/SymbolTable.h | 22 +- .../MachineIndependent/glslang_tab.cpp.h | 10 +- .../MachineIndependent/localintermediate.h | 10 +- .../preprocessor/PpContext.h | 18 +- .../preprocessor/PpTokens.h | 4 +- .../glslang/MachineIndependent/reflection.h | 6 +- .../glslang/glslang/Public/ShaderLang.h | 12 +- deps/glslang/glslang/gtests/TestFixture.h | 4 +- deps/glslang/glslang/hlsl/hlslGrammar.h | 2 +- deps/glslang/glslang/hlsl/hlslParseHelper.h | 2 +- deps/glslang/glslang/hlsl/hlslParseables.h | 2 +- deps/glslang/glslang/hlsl/hlslTokens.h | 2 +- deps/ibxm/ibxm.c | 3844 ++++++++--------- deps/libvita2d/source/vita2d_texture.c | 2 +- deps/mbedtls/ecjpake.c | 2 +- deps/mbedtls/mbedtls/ecp_internal.h | 2 +- deps/mbedtls/mbedtls/rsa.h | 8 +- deps/mbedtls/mbedtls/ssl_ciphersuites.h | 2 +- deps/mbedtls/ssl_cli.c | 4 +- deps/mbedtls/ssl_srv.c | 8 +- deps/mbedtls/x509_crt.c | 2 +- deps/stb/stb_image.h | 4 +- deps/stb/stb_rect_pack.h | 6 +- deps/stb/stb_truetype.h | 48 +- deps/stb/stb_vorbis.h | 160 +- dirs.c | 4 +- dirs.h | 2 +- driver.c | 24 +- driver.h | 6 +- dynamic.c | 54 +- dynamic.h | 6 +- file_path_str.c | 2 +- frontend/drivers/platform_ctr.c | 4 +- frontend/drivers/platform_gx.c | 2 +- frontend/drivers/platform_ps3.c | 6 +- frontend/drivers/platform_qnx.c | 2 +- frontend/drivers/platform_unix.c | 18 +- frontend/drivers/platform_unix.h | 4 +- frontend/drivers/platform_wii.c | 8 +- frontend/drivers/platform_win32.c | 36 +- frontend/drivers/platform_xdk.c | 20 +- frontend/frontend.c | 2 +- frontend/frontend.h | 4 +- frontend/frontend_salamander.c | 8 +- gfx/common/d3d_common.c | 14 +- gfx/common/d3d_common.h | 4 +- gfx/common/dbus_common.c | 4 +- gfx/common/dbus_common.h | 2 +- gfx/common/drm_common.c | 2 +- gfx/common/drm_common.h | 2 +- gfx/common/egl_common.c | 4 +- gfx/common/egl_common.h | 2 +- gfx/common/gl_common.c | 2 +- gfx/common/gl_common.h | 2 +- gfx/common/vita2d_common.h | 14 +- gfx/common/vksym.h | 2 +- gfx/common/vulkan_common.c | 60 +- gfx/common/vulkan_common.h | 2 +- gfx/common/wayland_common.h | 2 +- gfx/common/win32_common.c | 6 +- gfx/common/win32_common.h | 2 +- gfx/common/x11_common.c | 12 +- gfx/common/x11_common.h | 2 +- gfx/common/xinerama_common.c | 2 +- gfx/common/xinerama_common.h | 2 +- gfx/drivers/ctr_gfx.c | 4 +- gfx/drivers/d3d.c | 26 +- gfx/drivers/d3d.h | 2 +- gfx/drivers/dispmanx_gfx.c | 146 +- gfx/drivers/drm_gfx.c | 206 +- gfx/drivers/exynos_gfx.c | 8 +- gfx/drivers/gdi_gfx.c | 4 +- gfx/drivers/gl.c | 14 +- .../gl_shaders/pipeline_snowflake.glsl.frag.h | 24 +- .../pipeline_xmb_ribbon_simple.cg.h | 2 +- gfx/drivers/gx_gfx.c | 30 +- gfx/drivers/gx_gfx_vi_encoder.c | 826 ++-- gfx/drivers/nullgfx.c | 2 +- gfx/drivers/omap_gfx.c | 8 +- gfx/drivers/psp1_gfx.c | 34 +- gfx/drivers/psp1_gfx.h | 2 +- gfx/drivers/sdl2_gfx.c | 8 +- gfx/drivers/sdl_gfx.c | 6 +- gfx/drivers/sunxi_gfx.c | 58 +- gfx/drivers/vga_gfx.c | 2 +- gfx/drivers/vita2d_gfx.c | 44 +- gfx/drivers/vulkan.c | 86 +- gfx/drivers/xenon360_gfx.c | 4 +- gfx/drivers/xshm_gfx.c | 54 +- gfx/drivers/xvideo.c | 52 +- gfx/drivers_context/android_ctx.c | 8 +- gfx/drivers_context/cgl_ctx.c | 18 +- gfx/drivers_context/d3d_ctx.c | 4 +- gfx/drivers_context/drm_ctx.c | 36 +- gfx/drivers_context/gdi_ctx.c | 4 +- gfx/drivers_context/gfx_null_ctx.c | 4 +- gfx/drivers_context/khr_display_ctx.c | 4 +- gfx/drivers_context/mali_fbdev_ctx.c | 4 +- gfx/drivers_context/opendingux_fbdev_ctx.c | 4 +- gfx/drivers_context/ps3_ctx.c | 16 +- gfx/drivers_context/sdl_gl_ctx.c | 2 +- gfx/drivers_context/vc_egl_ctx.c | 24 +- gfx/drivers_context/vivante_fbdev_ctx.c | 2 +- gfx/drivers_context/wayland_ctx.c | 10 +- gfx/drivers_context/wgl_ctx.c | 12 +- gfx/drivers_context/x_ctx.c | 26 +- gfx/drivers_context/xegl_ctx.c | 22 +- gfx/drivers_font/caca_font.c | 2 +- gfx/drivers_font/ctr_font.c | 2 +- gfx/drivers_font/d3d_w32_font.c | 2 +- gfx/drivers_font/gdi_font.c | 2 +- gfx/drivers_font/gl_raster_font.c | 4 +- gfx/drivers_font/ps_libdbgfont.c | 4 +- gfx/drivers_font/vga_font.c | 2 +- gfx/drivers_font/vita2d_font.c | 12 +- gfx/drivers_font/vulkan_raster_font.c | 14 +- gfx/drivers_font/xdk1_xfonts.c | 4 +- gfx/drivers_font_renderer/bitmap.h | 2 +- gfx/drivers_font_renderer/bitmapfont.c | 12 +- gfx/drivers_font_renderer/coretext.c | 10 +- gfx/drivers_font_renderer/freetype.c | 4 +- gfx/drivers_font_renderer/stb_unicode.c | 2 +- gfx/drivers_renderchain/d3d8_renderchain.c | 20 +- .../d3d9_hlsl_renderchain.c | 26 +- gfx/drivers_renderchain/gl1_renderchain.c | 4 +- gfx/drivers_renderchain/gl2_renderchain.c | 66 +- gfx/drivers_renderchain/null_renderchain.c | 2 +- gfx/drivers_shader/shader_gl_cg.c | 26 +- gfx/drivers_shader/shader_glsl.c | 10 +- gfx/drivers_shader/shader_glsl.h | 2 +- gfx/drivers_shader/shader_hlsl.c | 8 +- gfx/drivers_shader/shader_hlsl.h | 2 +- gfx/drivers_shader/shader_null.c | 2 +- gfx/drivers_shader/shader_vulkan.h | 4 +- gfx/drivers_shader/slang_preprocess.h | 2 +- gfx/drivers_tracker/video_state_python.h | 4 +- gfx/font_driver.c | 10 +- gfx/font_driver.h | 14 +- gfx/include/GL/glext.h | 6 +- gfx/include/d3d8/d3d8.h | 2558 +++++------ gfx/include/d3d8/d3dx8.h | 88 +- gfx/include/d3d8/d3dx8core.h | 1126 ++--- gfx/include/d3d8/d3dx8effect.h | 452 +- gfx/include/d3d8/d3dx8math.h | 2426 +++++------ gfx/include/d3d8/d3dx8mesh.h | 1520 +++---- gfx/include/d3d8/d3dx8shape.h | 440 +- gfx/include/d3d8/d3dx8tex.h | 3184 +++++++------- gfx/include/d3d9/d3dx9anim.h | 170 +- gfx/include/d3d9/d3dx9core.h | 52 +- gfx/include/d3d9/d3dx9effect.h | 50 +- gfx/include/d3d9/d3dx9math.h | 72 +- gfx/include/d3d9/d3dx9mesh.h | 716 +-- gfx/include/d3d9/d3dx9shader.h | 28 +- gfx/include/d3d9/d3dx9shape.h | 32 +- gfx/include/d3d9/d3dx9tex.h | 14 +- gfx/include/d3d9/d3dx9xof.h | 20 +- gfx/include/d3d9caps.h | 16 +- gfx/include/d3d9types.h | 78 +- gfx/include/vulkan/vulkan.h | 4 +- gfx/video_coord_array.c | 2 +- gfx/video_coord_array.h | 2 +- gfx/video_driver.c | 82 +- gfx/video_driver.h | 64 +- gfx/video_filter.c | 8 +- gfx/video_filters/2xbr.c | 118 +- gfx/video_filters/2xsai.c | 14 +- gfx/video_filters/blargg_ntsc_snes.c | 8 +- gfx/video_filters/darken.c | 6 +- gfx/video_filters/epx.c | 6 +- gfx/video_filters/lq2x.c | 12 +- gfx/video_filters/phosphor2x.c | 72 +- gfx/video_filters/scale2x.c | 12 +- gfx/video_filters/snes_ntsc/snes_ntsc.c | 48 +- gfx/video_filters/snes_ntsc/snes_ntsc.h | 4 +- gfx/video_filters/snes_ntsc/snes_ntsc_impl.h | 42 +- gfx/video_filters/softfilter.h | 30 +- gfx/video_filters/super2xsai.c | 8 +- gfx/video_filters/supereagle.c | 4 +- gfx/video_shader_parse.c | 56 +- gfx/video_shader_parse.h | 20 +- gfx/video_state_tracker.c | 12 +- gfx/video_state_tracker.h | 2 +- gfx/video_thread_wrapper.c | 28 +- gfx/video_thread_wrapper.h | 6 +- input/common/input_x11_common.c | 2 +- input/common/input_x11_common.h | 2 +- input/common/linux_common.c | 8 +- input/common/linux_common.h | 2 +- input/connect/connect_ps4.c | 2 +- input/connect/connect_wiiupro.c | 2 +- input/drivers/android_input.c | 60 +- input/drivers/cocoa_input.h | 2 +- input/drivers/ctr_input.c | 2 +- input/drivers/gx_input.c | 2 +- input/drivers/linuxraw_input.c | 4 +- input/drivers/nullinput.c | 2 +- input/drivers/ps3_input.c | 8 +- input/drivers/rwebinput_input.c | 6 +- input/drivers/sdl_input.c | 8 +- input/drivers/wayland_input.c | 14 +- input/drivers/winraw_input.c | 1714 ++++---- input/drivers/x11_input.c | 16 +- input/drivers/xdk_xinput_input.c | 8 +- input/drivers/xenon360_input.c | 2 +- input/drivers_hid/libusb_hid.c | 14 +- input/drivers_joypad/dinput_joypad.c | 8 +- input/drivers_joypad/sdl_joypad.c | 2 +- input/drivers_joypad/xinput_joypad.c | 20 +- .../drivers_keyboard/keyboard_event_android.c | 4 +- .../drivers_keyboard/keyboard_event_android.h | 2 +- input/drivers_keyboard/keyboard_event_dos.c | 2 +- input/drivers_keyboard/keyboard_event_dos.h | 2 +- input/drivers_keyboard/keyboard_event_xkb.c | 2 +- input/include/GameController/GCController.h | 46 +- .../GameController/GCControllerAxisInput.h | 2 +- .../GameController/GCControllerButtonInput.h | 4 +- .../GameController/GCControllerDirectionPad.h | 2 +- .../GameController/GCExtendedGamepad.h | 14 +- .../GCExtendedGamepadSnapshot.h | 14 +- input/include/GameController/GCGamepad.h | 12 +- .../GameController/GCGamepadSnapshot.h | 16 +- input/input_driver.c | 76 +- input/input_keymaps.c | 6 +- input/input_keymaps.h | 4 +- input/input_mapper.c | 6 +- input/input_mapper.h | 2 +- input/input_overlay.c | 22 +- input/input_overlay.h | 10 +- input/input_remapping.c | 14 +- input/input_remote.c | 4 +- input/input_remote.h | 2 +- intl/msg_hash_pt_br.c | 12 +- lakka.h | 2 +- libretro-common/audio/audio_mix.c | 6 +- libretro-common/audio/audio_mixer.c | 84 +- .../audio/conversion/float_to_s16.c | 6 +- .../audio/conversion/s16_to_float.c | 6 +- libretro-common/audio/dsp_filter.c | 6 +- libretro-common/audio/dsp_filters/chorus.c | 2 +- libretro-common/audio/dsp_filters/eq.c | 6 +- libretro-common/audio/dsp_filters/iir.c | 10 +- libretro-common/audio/dsp_filters/panning.c | 2 +- .../audio/resampler/audio_resampler.c | 2 +- .../resampler/drivers/nearest_resampler.c | 20 +- .../audio/resampler/drivers/null_resampler.c | 10 +- .../audio/resampler/drivers/sinc_resampler.c | 34 +- libretro-common/compat/compat_fnmatch.c | 12 +- libretro-common/compat/compat_getopt.c | 6 +- libretro-common/compat/compat_ifaddrs.c | 10 +- libretro-common/compat/compat_snprintf.c | 20 +- libretro-common/encodings/encoding_utf.c | 6 +- libretro-common/features/features_cpu.c | 12 +- libretro-common/file/archive_file.c | 4 +- libretro-common/file/archive_file_zlib.c | 2 +- libretro-common/file/config_file.c | 4 +- libretro-common/file/config_file_userdata.c | 8 +- libretro-common/file/file_path.c | 12 +- libretro-common/file/nbio/nbio_intf.c | 170 +- libretro-common/file/nbio/nbio_linux.c | 8 +- libretro-common/file/nbio/nbio_stdio.c | 536 +-- libretro-common/file/nbio/nbio_unixmmap.c | 10 +- libretro-common/file/nbio/nbio_windowsmmap.c | 6 +- libretro-common/formats/bmp/rbmp.c | 8 +- libretro-common/formats/image_texture.c | 12 +- libretro-common/formats/image_transfer.c | 2 +- libretro-common/formats/jpeg/rjpeg.c | 18 +- libretro-common/formats/json/jsonsax_full.c | 22 +- libretro-common/formats/libchdr/bitstream.c | 2 +- libretro-common/formats/libchdr/cdrom.c | 848 ++-- libretro-common/formats/libchdr/chd.c | 22 +- libretro-common/formats/libchdr/flac.c | 668 +-- libretro-common/formats/libchdr/huffman.c | 1134 ++--- libretro-common/formats/png/rpng.c | 42 +- libretro-common/formats/png/rpng_encode.c | 4 +- libretro-common/formats/tga/rtga.c | 6 +- libretro-common/formats/wav/rwav.c | 6 +- libretro-common/formats/xml/rxml.c | 12 +- libretro-common/formats/xml/test/rxml_test.c | 2 +- libretro-common/gfx/gl_capabilities.c | 2 +- libretro-common/gfx/scaler/pixconv.c | 2 +- libretro-common/gfx/scaler/scaler.c | 4 +- libretro-common/gfx/scaler/scaler_filter.c | 6 +- libretro-common/gfx/scaler/scaler_int.c | 26 +- libretro-common/glsm/glsm.c | 154 +- libretro-common/hash/rhash.c | 30 +- .../include/audio/audio_resampler.h | 18 +- .../include/audio/conversion/float_to_s16.h | 2 +- libretro-common/include/compat/getopt.h | 6 +- libretro-common/include/compat/intrinsics.h | 2 +- libretro-common/include/compat/msvc.h | 62 +- libretro-common/include/compat/msvc/stdint.h | 14 +- libretro-common/include/compat/strcasestr.h | 2 +- libretro-common/include/compat/strl.h | 2 +- libretro-common/include/encodings/win32.h | 126 +- libretro-common/include/file/config_file.h | 6 +- libretro-common/include/file/file_path.h | 38 +- libretro-common/include/file/nbio.h | 2 +- libretro-common/include/formats/rwav.h | 8 +- libretro-common/include/formats/rxml.h | 12 +- libretro-common/include/gfx/math/matrix_4x4.h | 8 +- libretro-common/include/gfx/math/vector_2.h | 4 +- libretro-common/include/glsm/glsmsym.h | 2 +- libretro-common/include/libchdr/cdrom.h | 140 +- libretro-common/include/libchdr/chd.h | 4 +- libretro-common/include/libchdr/flac.h | 104 +- libretro-common/include/libchdr/huffman.h | 180 +- libretro-common/include/libchdr/minmax.h | 42 +- libretro-common/include/libretro.h | 570 +-- libretro-common/include/libretro_dspfilter.h | 42 +- libretro-common/include/libretro_vulkan.h | 106 +- libretro-common/include/lists/file_list.h | 8 +- libretro-common/include/net/net_http.h | 6 +- libretro-common/include/net/net_ifinfo.h | 2 +- libretro-common/include/queues/task_queue.h | 40 +- libretro-common/include/retro_common.h | 2 +- libretro-common/include/retro_common_api.h | 4 +- libretro-common/include/retro_endianness.h | 24 +- libretro-common/include/retro_miscellaneous.h | 10 +- libretro-common/include/rthreads/rthreads.h | 34 +- libretro-common/libco/armeabi.c | 2 +- libretro-common/libco/ppc.c | 32 +- libretro-common/lists/file_list.c | 8 +- libretro-common/memmap/memmap.c | 4 +- libretro-common/net/net_compat.c | 12 +- libretro-common/net/net_http.c | 6 +- libretro-common/net/net_ifinfo.c | 2 +- libretro-common/net/net_socket.c | 4 +- libretro-common/queues/message_queue.c | 6 +- libretro-common/queues/task_queue.c | 4 +- libretro-common/rthreads/rthreads.c | 94 +- .../samples/formats/png/rpng_test.c | 2 +- libretro-common/samples/net/net_http_test.c | 6 +- libretro-common/samples/net/udp-test.c | 116 +- libretro-common/streams/chd_stream.c | 4 +- .../streams/file_stream_transforms.c | 205 +- libretro-common/streams/memory_stream.c | 4 +- libretro-common/string/stdstring.c | 8 +- libretro-common/utils/crc32.c | 86 +- libretro-common/utils/sha1.c | 16 +- libretro-common/utils/sha1_main.c | 4 +- libretro-db/libretrodb_tool.c | 8 +- libretro-db/query.c | 12 +- libretro-db/rmsgpack_dom.c | 4 +- list_special.c | 2 +- list_special.h | 2 +- location/drivers/android.c | 4 +- location/drivers/nulllocation.c | 2 +- location/location_driver.c | 16 +- location/location_driver.h | 4 +- managers/cheat_manager.h | 2 +- managers/core_manager.c | 2 +- managers/core_manager.h | 2 +- managers/core_option_manager.c | 8 +- managers/core_option_manager.h | 6 +- managers/state_manager.c | 88 +- managers/state_manager.h | 2 +- memory/wii/mem2_manager.c | 14 +- memory/wii/mem2_manager.h | 2 +- menu/cbs/menu_cbs_deferred_push.c | 18 +- menu/cbs/menu_cbs_get_value.c | 4 +- menu/cbs/menu_cbs_info.c | 2 +- menu/cbs/menu_cbs_left.c | 22 +- menu/cbs/menu_cbs_ok.c | 8 +- menu/cbs/menu_cbs_right.c | 10 +- menu/cbs/menu_cbs_scan.c | 2 +- menu/cbs/menu_cbs_select.c | 10 +- menu/cbs/menu_cbs_start.c | 4 +- menu/cbs/menu_cbs_title.c | 46 +- menu/drivers/materialui.c | 158 +- menu/drivers/menu_generic.c | 2 +- menu/drivers/nuklear.c | 6 +- menu/drivers/nuklear/nk_common.c | 2 +- menu/drivers/nuklear/nk_menu.c | 68 +- menu/drivers/rgui.c | 6 +- menu/drivers/xmb.c | 2 +- menu/drivers/zarch.c | 34 +- menu/drivers_display/menu_display_caca.c | 2 +- menu/drivers_display/menu_display_ctr.c | 4 +- menu/drivers_display/menu_display_d3d.c | 6 +- menu/drivers_display/menu_display_vga.c | 2 +- menu/drivers_display/menu_display_vita2d.c | 36 +- menu/drivers_display/menu_display_vulkan.c | 6 +- menu/menu_animation.c | 6 +- menu/menu_cbs.c | 16 +- menu/menu_cbs.h | 4 +- menu/menu_content.c | 4 +- menu/menu_displaylist.h | 2 +- menu/menu_driver.c | 30 +- menu/menu_entries.c | 6 +- menu/menu_entries.h | 2 +- menu/menu_event.c | 10 +- menu/menu_event.h | 4 +- menu/menu_input.c | 12 +- menu/menu_setting.h | 2 +- menu/menu_shader.c | 28 +- menu/menu_shader.h | 6 +- menu/widgets/menu_entry.c | 8 +- menu/widgets/menu_filebrowser.c | 2 +- menu/widgets/menu_input_bind_dialog.c | 2 +- movie.c | 16 +- movie.h | 2 +- network/httpserver/httpserver.c | 2 +- network/net_http_special.h | 2 +- network/net_logger.c | 2 +- network/netplay/netplay.h | 2 +- network/netplay/netplay_buf.c | 2 +- network/netplay/netplay_discovery.c | 12 +- network/netplay/netplay_discovery.h | 2 +- network/netplay/netplay_frontend.c | 30 +- network/netplay/netplay_handshake.c | 8 +- network/netplay/netplay_init.c | 18 +- network/netplay/netplay_io.c | 4 +- network/netplay/netplay_private.h | 6 +- paths.c | 14 +- paths.h | 2 +- performance_counters.h | 6 +- playlist.c | 12 +- playlist.h | 10 +- record/drivers/record_ffmpeg.c | 34 +- record/record_driver.c | 10 +- record/record_driver.h | 2 +- retroarch.h | 10 +- setting_list.c | 48 +- setting_list.h | 10 +- tasks/task_audio_mixer.c | 8 +- tasks/task_content.c | 40 +- tasks/task_database.c | 10 +- tasks/task_http.c | 2 +- tasks/task_image.c | 12 +- tasks/task_netplay_find_content.c | 18 +- tasks/task_netplay_lan_scan.c | 2 +- tasks/task_overlay.c | 4 +- tasks/task_patch.c | 76 +- tasks/task_save.c | 8 +- tasks/task_screenshot.c | 8 +- tasks/task_wifi.c | 2 +- tasks/tasks_internal.h | 4 +- tools/ps3/ps3py/crypt.c | 10 +- ui/drivers/cocoa/cocoa_common.h | 4 +- ui/drivers/qt/wimp/wimp.h | 126 +- ui/drivers/qt/wimp/wimp_global.h | 56 +- ui/drivers/qt/wrapper/wrapper.h | 76 +- ui/drivers/ui_cocoa.h | 2 +- ui/drivers/ui_win32.c | 64 +- ui/drivers/ui_win32.h | 2 +- ui/drivers/ui_win32_resource.h | 64 +- ui/drivers/win32/ui_win32_browser_window.c | 2 +- ui/drivers/win32/ui_win32_window.c | 2 +- ui/ui_companion_driver.c | 2 +- ui/ui_companion_driver.h | 6 +- verbosity.c | 2 +- version.h | 2 +- version_git.c | 2 +- version_git.h | 4 +- wifi/drivers/connmanctl.c | 4 +- wifi/drivers/nullwifi.c | 2 +- wifi/wifi_driver.c | 14 +- wifi/wifi_driver.h | 2 +- wii/app_booter/main.c | 2 +- wii/libogc/include/bte/bd_addr.h | 28 +- wii/libogc/include/debug.h | 2 +- wii/libogc/include/gctypes.h | 6 +- wii/libogc/include/ipv4/lwip/icmp.h | 30 +- wii/libogc/include/ipv4/lwip/inet.h | 28 +- wii/libogc/include/ipv4/lwip/ip.h | 30 +- wii/libogc/include/ipv4/lwip/ip_frag.h | 28 +- wii/libogc/include/iso9660.h | 2 +- wii/libogc/include/lwip/api.h | 28 +- wii/libogc/include/lwip/api_msg.h | 28 +- wii/libogc/include/lwip/arch.h | 28 +- wii/libogc/include/lwip/debug.h | 40 +- wii/libogc/include/lwip/def.h | 28 +- wii/libogc/include/lwip/dhcp.h | 22 +- wii/libogc/include/lwip/err.h | 28 +- wii/libogc/include/lwip/lwipopts.h | 2 +- wii/libogc/include/lwip/mem.h | 28 +- wii/libogc/include/lwip/memp.h | 32 +- wii/libogc/include/lwip/netif.h | 28 +- wii/libogc/include/lwip/opt.h | 56 +- wii/libogc/include/lwip/pbuf.h | 42 +- wii/libogc/include/lwip/sio.h | 26 +- wii/libogc/include/lwip/snmp.h | 54 +- wii/libogc/include/lwip/sockets.h | 32 +- wii/libogc/include/lwip/stats.h | 32 +- wii/libogc/include/lwip/sys.h | 28 +- wii/libogc/include/lwip/tcp.h | 68 +- wii/libogc/include/lwip/tcpip.h | 28 +- wii/libogc/include/lwip/udp.h | 34 +- wii/libogc/include/netif/arch/cc.h | 48 +- wii/libogc/include/netif/arch/cpu.h | 48 +- wii/libogc/include/netif/arch/init.h | 48 +- wii/libogc/include/netif/arch/lib.h | 48 +- wii/libogc/include/netif/arch/perf.h | 48 +- wii/libogc/include/netif/arch/sys_arch.h | 48 +- wii/libogc/include/netif/etharp.h | 28 +- wii/libogc/include/netif/loopif.h | 28 +- wii/libogc/include/ogc/aram.h | 36 +- wii/libogc/include/ogc/arqmgr.h | 4 +- wii/libogc/include/ogc/arqueue.h | 4 +- wii/libogc/include/ogc/audio.h | 54 +- wii/libogc/include/ogc/card.h | 28 +- wii/libogc/include/ogc/cond.h | 6 +- wii/libogc/include/ogc/disc_io.h | 2 +- wii/libogc/include/ogc/dsp.h | 18 +- wii/libogc/include/ogc/dvd.h | 64 +- wii/libogc/include/ogc/exi.h | 4 +- wii/libogc/include/ogc/gu.h | 2 +- wii/libogc/include/ogc/gx.h | 14 +- wii/libogc/include/ogc/gx_struct.h | 4 +- wii/libogc/include/ogc/lwp.h | 4 +- wii/libogc/include/ogc/lwp_mutex.h | 2 +- wii/libogc/include/ogc/lwp_stack.h | 2 +- wii/libogc/include/ogc/lwp_states.h | 2 +- wii/libogc/include/ogc/lwp_threads.h | 2 +- wii/libogc/include/ogc/lwp_watchdog.h | 6 +- wii/libogc/include/ogc/machine/asm.h | 30 +- wii/libogc/include/ogc/machine/spinlock.h | 4 +- wii/libogc/include/ogc/message.h | 4 +- wii/libogc/include/ogc/mutex.h | 4 +- wii/libogc/include/ogc/semaphore.h | 4 +- wii/libogc/include/ogc/video.h | 34 +- wii/libogc/include/sdcard/gcsd.h | 2 +- wii/libogc/include/sdcard/wiisd_io.h | 2 +- wii/libogc/include/wiiuse/wiiuse.h | 2 +- wii/libogc/include/wiiuse/wpad.h | 8 +- wii/libogc/libdb/debug.c | 26 +- wii/libogc/libdb/debug_supp.c | 12 +- wii/libogc/libdb/geckousb.c | 2 +- wii/libogc/libdb/tcpip.c | 42 +- wii/libogc/libdb/uIP/bba.c | 48 +- wii/libogc/libdb/uIP/memb.c | 2 +- wii/libogc/libdb/uIP/memr.c | 10 +- wii/libogc/libdb/uIP/uip.h | 22 +- wii/libogc/libdb/uIP/uip_arch.c | 30 +- wii/libogc/libdb/uIP/uip_arch.h | 22 +- wii/libogc/libdb/uIP/uip_arp.c | 48 +- wii/libogc/libdb/uIP/uip_arp.h | 32 +- wii/libogc/libdb/uIP/uip_icmp.c | 10 +- wii/libogc/libdb/uIP/uip_ip.c | 42 +- wii/libogc/libdb/uIP/uip_ip.h | 6 +- wii/libogc/libdb/uIP/uip_netif.c | 14 +- wii/libogc/libdb/uIP/uip_netif.h | 8 +- wii/libogc/libdb/uIP/uip_pbuf.c | 16 +- wii/libogc/libdb/uIP/uip_tcp.c | 112 +- wii/libogc/libdb/uIP/uip_tcp.h | 26 +- wii/libogc/libdb/uIP/uipopt.h | 28 +- wii/libogc/libfat/bit_ops.h | 2 +- wii/libogc/libfat/directory.h | 10 +- wii/libogc/libfat/disc.c | 14 +- wii/libogc/libfat/disc.h | 12 +- wii/libogc/libfat/fatdir.h | 6 +- wii/libogc/libfat/fatfile.h | 6 +- wii/libogc/libfat/file_allocation_table.h | 6 +- wii/libogc/libfat/filetime.c | 20 +- wii/libogc/libfat/filetime.h | 2 +- wii/libogc/libfat/libfat.c | 8 +- wii/libogc/libfat/mem_allocate.h | 2 +- wii/libogc/libogc/argv.c | 6 +- wii/libogc/libogc/arqmgr.c | 8 +- wii/libogc/libogc/arqueue.c | 10 +- wii/libogc/libogc/card.c | 388 +- wii/libogc/libogc/cond.c | 8 +- wii/libogc/libogc/conf.c | 76 +- wii/libogc/libogc/console.c | 30 +- wii/libogc/libogc/depackrnc1.c | 2 +- wii/libogc/libogc/dvd.c | 2 +- wii/libogc/libogc/es.c | 10 +- wii/libogc/libogc/exception.c | 4 +- wii/libogc/libogc/gcsd.c | 2 +- wii/libogc/libogc/gu.c | 36 +- wii/libogc/libogc/ios.c | 8 +- wii/libogc/libogc/isfs.c | 66 +- wii/libogc/libogc/lock_supp.c | 10 +- wii/libogc/libogc/lwp.c | 20 +- wii/libogc/libogc/lwp_heap.c | 34 +- wii/libogc/libogc/lwp_messages.c | 18 +- wii/libogc/libogc/lwp_mutex.c | 8 +- wii/libogc/libogc/lwp_objmgr.c | 2 +- wii/libogc/libogc/lwp_priority.c | 4 +- wii/libogc/libogc/lwp_queue.c | 10 +- wii/libogc/libogc/lwp_sema.c | 6 +- wii/libogc/libogc/lwp_stack.c | 2 +- wii/libogc/libogc/lwp_threadq.c | 22 +- wii/libogc/libogc/lwp_threads.c | 60 +- wii/libogc/libogc/lwp_watchdog.c | 2 +- wii/libogc/libogc/malloc_lock.c | 6 +- wii/libogc/libogc/mutex.c | 4 +- wii/libogc/libogc/network_common.c | 4 +- wii/libogc/libogc/newlibc.c | 4 +- wii/libogc/libogc/pad.c | 2 +- wii/libogc/libogc/sbrk.c | 2 +- wii/libogc/libogc/sdgecko_buf.c | 6 +- wii/libogc/libogc/sdgecko_io.c | 92 +- wii/libogc/libogc/semaphore.c | 4 +- wii/libogc/libogc/stm.c | 26 +- wii/libogc/libogc/texconv.c | 2 +- wii/libogc/libogc/timesupp.c | 4 +- wii/libogc/libogc/timesupp.h | 2 +- wii/libogc/libogc/tpl.c | 6 +- wii/libogc/libogc/usbstorage.c | 28 +- wii/libogc/libogc/wiilaunch.c | 4 +- wii/libogc/libogc/wiisd.c | 154 +- wii/libogc/libwiikeyboard/ukbdmap.c | 2 +- wii/libogc/lwbt/bt.h | 22 +- wii/libogc/lwbt/btarch.h | 28 +- wii/libogc/lwbt/bte.c | 22 +- wii/libogc/lwbt/btmemb.c | 4 +- wii/libogc/lwbt/btmemr.c | 10 +- wii/libogc/lwbt/btopt.h | 50 +- wii/libogc/lwbt/btpbuf.c | 16 +- wii/libogc/lwbt/hci.c | 176 +- wii/libogc/lwbt/hci.h | 6 +- wii/libogc/lwbt/l2cap.c | 192 +- wii/libogc/lwbt/l2cap.h | 2 +- wii/libogc/lwbt/physbusif.h | 20 +- wii/libogc/lwip/core/dhcp.c | 16 +- wii/libogc/lwip/core/inet.c | 12 +- wii/libogc/lwip/core/inet6.c | 42 +- wii/libogc/lwip/core/ipv4/ip.c | 8 +- wii/libogc/lwip/core/ipv4/ip_addr.c | 32 +- wii/libogc/lwip/core/ipv4/ip_frag.c | 46 +- wii/libogc/lwip/core/mem.c | 74 +- wii/libogc/lwip/core/memp.c | 64 +- wii/libogc/lwip/core/netif.c | 16 +- wii/libogc/lwip/core/pbuf.c | 20 +- wii/libogc/lwip/core/raw.c | 14 +- wii/libogc/lwip/core/stats.c | 76 +- wii/libogc/lwip/core/tcp.c | 140 +- wii/libogc/lwip/core/tcp_in.c | 18 +- wii/libogc/lwip/core/tcp_out.c | 22 +- wii/libogc/lwip/core/udp.c | 16 +- wii/libogc/lwip/netif/etharp.c | 44 +- wii/libogc/lwip/netif/loopif.c | 40 +- wii/libogc/lwip/netif/skeleton/ethernetif.c | 72 +- wii/libogc/lwip/netif/skeleton/slipif.c | 84 +- wii/libogc/lwip/netio.c | 8 +- wii/libogc/lwip/network.c | 154 +- wii/libogc/wiiuse/classic.h | 2 +- wii/libogc/wiiuse/dynamics.c | 2 +- wii/libogc/wiiuse/dynamics.h | 2 +- wii/libogc/wiiuse/events.c | 10 +- wii/libogc/wiiuse/events.h | 2 +- wii/libogc/wiiuse/io.h | 2 +- wii/libogc/wiiuse/io_wii.c | 8 +- wii/libogc/wiiuse/ir.c | 4 +- wii/libogc/wiiuse/ir.h | 2 +- wii/libogc/wiiuse/motion_plus.c | 8 +- wii/libogc/wiiuse/motion_plus.h | 2 +- wii/libogc/wiiuse/nunchuk.c | 4 +- wii/libogc/wiiuse/nunchuk.h | 2 +- wii/libogc/wiiuse/os.h | 2 +- wii/libogc/wiiuse/speaker.c | 2 +- wii/libogc/wiiuse/speaker.h | 2 +- wii/libogc/wiiuse/wiiuse.c | 14 +- wii/libogc/wiiuse/wiiuse_internal.h | 2 +- wii/libogc/wiiuse/wpad.c | 6 +- wiiu/include/wiiu/nsyskbd.h | 4 +- wiiu/include/wiiu/syshid.h | 92 +- 765 files changed, 23365 insertions(+), 23366 deletions(-) diff --git a/audio/audio_driver.c b/audio/audio_driver.c index 6acb0b2ca7..6cd70cf681 100644 --- a/audio/audio_driver.c +++ b/audio/audio_driver.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -111,7 +111,7 @@ static const audio_driver_t *audio_drivers[] = { #endif #if defined(PSP) || defined(VITA) &audio_psp, -#endif +#endif #ifdef _3DS &audio_ctr_csnd, &audio_ctr_dsp, @@ -150,7 +150,7 @@ static uint64_t audio_driver_free_samples_count = 0; static size_t audio_driver_buffer_size = 0; static size_t audio_driver_data_ptr = 0; -static bool audio_driver_control = false; +static bool audio_driver_control = false; static bool audio_driver_mixer_mute_enable = false; static bool audio_driver_mute_enable = false; static bool audio_driver_use_float = false; @@ -212,12 +212,12 @@ static void compute_audio_buffer_statistics(void) accum_var += diff * diff; } -#if defined(_MSC_VER) && _MSC_VER <= 1200 +#if defined(_MSC_VER) && _MSC_VER <= 1200 /* FIXME: error C2520: conversion from unsigned __int64 to double not implemented, use signed __int64 */ -#else - stddev = (unsigned)sqrt((double)accum_var / (samples - 2)); - avg_filled = 1.0f - (float)avg / audio_driver_buffer_size; - deviation = (float)stddev / audio_driver_buffer_size; +#else + stddev = (unsigned)sqrt((double)accum_var / (samples - 2)); + avg_filled = 1.0f - (float)avg / audio_driver_buffer_size; + deviation = (float)stddev / audio_driver_buffer_size; #endif low_water_size = (unsigned)(audio_driver_buffer_size * 3 / 4); high_water_size = (unsigned)(audio_driver_buffer_size / 4); @@ -335,13 +335,13 @@ static bool audio_driver_init_internal(bool audio_cb_inited) size_t max_bufsamples = AUDIO_CHUNK_SIZE_NONBLOCKING * 2; settings_t *settings = config_get_ptr(); /* Accomodate rewind since at some point we might have two full buffers. */ - size_t outsamples_max = AUDIO_CHUNK_SIZE_NONBLOCKING * 2 * AUDIO_MAX_RATIO * + size_t outsamples_max = AUDIO_CHUNK_SIZE_NONBLOCKING * 2 * AUDIO_MAX_RATIO * settings->floats.slowmotion_ratio; convert_s16_to_float_init_simd(); convert_float_to_s16_init_simd(); - conv_buf = (int16_t*)malloc(outsamples_max + conv_buf = (int16_t*)malloc(outsamples_max * sizeof(int16_t)); /* Used for recording even if audio isn't enabled. */ retro_assert(conv_buf != NULL); @@ -379,9 +379,9 @@ static bool audio_driver_init_internal(bool audio_cb_inited) if (!audio_init_thread( ¤t_audio, &audio_driver_context_audio_data, - *settings->arrays.audio_device + *settings->arrays.audio_device ? settings->arrays.audio_device : NULL, - settings->uints.audio_out_rate, &new_rate, + settings->uints.audio_out_rate, &new_rate, settings->uints.audio_latency, settings->uints.audio_block_frames, current_audio)) @@ -393,7 +393,7 @@ static bool audio_driver_init_internal(bool audio_cb_inited) else #endif { - audio_driver_context_audio_data = + audio_driver_context_audio_data = current_audio->init(*settings->arrays.audio_device ? settings->arrays.audio_device : NULL, settings->uints.audio_out_rate, @@ -414,7 +414,7 @@ static bool audio_driver_init_internal(bool audio_cb_inited) } audio_driver_use_float = false; - if ( audio_driver_active + if ( audio_driver_active && current_audio->use_float(audio_driver_context_audio_data)) audio_driver_use_float = true; @@ -470,7 +470,7 @@ static bool audio_driver_init_internal(bool audio_cb_inited) if ( !audio_cb_inited - && audio_driver_active + && audio_driver_active && settings->bools.audio_rate_control ) { @@ -478,7 +478,7 @@ static bool audio_driver_init_internal(bool audio_cb_inited) * and buffer_size to be implemented. */ if (current_audio->buffer_size) { - audio_driver_buffer_size = + audio_driver_buffer_size = current_audio->buffer_size(audio_driver_context_audio_data); audio_driver_control = true; } @@ -516,8 +516,8 @@ void audio_driver_set_nonblocking_state(bool enable) audio_driver_context_audio_data, settings->bools.audio_sync ? enable : true); - audio_driver_chunk_size = enable ? - audio_driver_chunk_nonblock_size : + audio_driver_chunk_size = enable ? + audio_driver_chunk_nonblock_size : audio_driver_chunk_block_size; } @@ -541,7 +541,7 @@ static bool audio_driver_flush(const int16_t *data, size_t samples) bool is_slowmotion = false; const void *output_data = NULL; unsigned output_frames = 0; - float audio_volume_gain = !audio_driver_mute_enable ? + float audio_volume_gain = !audio_driver_mute_enable ? audio_driver_volume_gain : 0.0f; src_data.data_in = NULL; @@ -597,7 +597,7 @@ static bool audio_driver_flush(const int16_t *data, size_t samples) unsigned write_idx = audio_driver_free_samples_count++ & (AUDIO_BUFFER_FREE_SAMPLES_COUNT - 1); int half_size = (int)(audio_driver_buffer_size / 2); - int avail = + int avail = (int)current_audio->write_avail(audio_driver_context_audio_data); int delta_mid = avail - half_size; double direction = (double)delta_mid / half_size; @@ -610,7 +610,7 @@ static bool audio_driver_flush(const int16_t *data, size_t samples) audio_driver_free_samples_buf [write_idx] = avail; - audio_source_ratio_current = + audio_source_ratio_current = audio_source_ratio_original * adjust; #if 0 @@ -632,9 +632,9 @@ static bool audio_driver_flush(const int16_t *data, size_t samples) if (audio_mixer_active) { - bool override = audio_driver_mixer_mute_enable ? true : + bool override = audio_driver_mixer_mute_enable ? true : (audio_driver_mixer_volume_gain != 0.0f) ? true : false; - float mixer_gain = !audio_driver_mixer_mute_enable ? + float mixer_gain = !audio_driver_mixer_mute_enable ? audio_driver_mixer_volume_gain : 0.0f; audio_mixer_mix(audio_driver_output_samples_buf, src_data.output_frames, mixer_gain, override); @@ -679,7 +679,7 @@ void audio_driver_sample(int16_t left, int16_t right) if (audio_driver_data_ptr < audio_driver_chunk_size) return; - audio_driver_flush(audio_driver_output_samples_conv_buf, + audio_driver_flush(audio_driver_output_samples_conv_buf, audio_driver_data_ptr); audio_driver_data_ptr = 0; @@ -710,8 +710,8 @@ size_t audio_driver_sample_batch(const int16_t *data, size_t frames) * @left : value of the left audio channel. * @right : value of the right audio channel. * - * Audio sample render callback function (rewind version). - * This callback function will be used instead of + * Audio sample render callback function (rewind version). + * This callback function will be used instead of * audio_driver_sample when rewinding is activated. **/ void audio_driver_sample_rewind(int16_t left, int16_t right) @@ -725,9 +725,9 @@ void audio_driver_sample_rewind(int16_t left, int16_t right) * @data : pointer to audio buffer. * @frames : amount of audio frames to push. * - * Batched audio sample render callback function (rewind version). + * Batched audio sample render callback function (rewind version). * - * This callback function will be used instead of + * This callback function will be used instead of * audio_driver_sample_batch when rewinding is activated. * * Returns: amount of frames sampled. Will be equal to @frames @@ -800,9 +800,9 @@ void audio_driver_monitor_adjust_system_rates(void) struct retro_system_av_info *av_info = video_viewport_get_system_av_info(); float video_refresh_rate = settings->floats.video_refresh_rate; float max_timing_skew = settings->floats.audio_max_timing_skew; - const struct retro_system_timing *info = av_info ? + const struct retro_system_timing *info = av_info ? (const struct retro_system_timing*)&av_info->timing : NULL; - + if (!info || info->sample_rate <= 0.0) return; @@ -882,7 +882,7 @@ bool audio_driver_free_devices_list(void) if (!current_audio || !current_audio->device_list_free || !audio_driver_context_audio_data) return false; - current_audio->device_list_free(audio_driver_context_audio_data, + current_audio->device_list_free(audio_driver_context_audio_data, audio_driver_devices_list); audio_driver_devices_list = NULL; return true; @@ -1003,7 +1003,7 @@ bool audio_driver_mixer_add_stream(audio_mixer_stream_params_t *params) audio_mixer_stop_cb_t stop_cb = audio_mixer_play_stop_cb; bool looped = false; void *buf = NULL; - + if (audio_mixer_current_max_idx >= AUDIO_MIXER_MAX_STREAMS) return false; @@ -1132,7 +1132,7 @@ bool audio_driver_set_callback(const void *data) bool audio_driver_enable_callback(void) { if (!audio_callback.callback) - return false; + return false; if (audio_callback.set_state) audio_callback.set_state(true); return true; @@ -1152,7 +1152,7 @@ bool audio_driver_disable_callback(void) void audio_driver_monitor_set_rate(void) { settings_t *settings = config_get_ptr(); - double new_src_ratio = (double)settings->uints.audio_out_rate / + double new_src_ratio = (double)settings->uints.audio_out_rate / audio_driver_input; audio_source_ratio_original = new_src_ratio; @@ -1191,8 +1191,8 @@ bool audio_driver_mixer_toggle_mute(void) static INLINE bool audio_driver_alive(void) { - if ( current_audio - && current_audio->alive + if ( current_audio + && current_audio->alive && audio_driver_context_audio_data) return current_audio->alive(audio_driver_context_audio_data); return false; @@ -1200,7 +1200,7 @@ static INLINE bool audio_driver_alive(void) bool audio_driver_start(bool is_shutdown) { - if (!current_audio || !current_audio->start + if (!current_audio || !current_audio->start || !audio_driver_context_audio_data) goto error; if (!current_audio->start(audio_driver_context_audio_data, is_shutdown)) @@ -1218,7 +1218,7 @@ error: bool audio_driver_stop(void) { - if (!current_audio || !current_audio->stop + if (!current_audio || !current_audio->stop || !audio_driver_context_audio_data) return false; if (!audio_driver_alive()) diff --git a/audio/audio_driver.h b/audio/audio_driver.h index 3a62b95c29..27b6a4205c 100644 --- a/audio/audio_driver.h +++ b/audio/audio_driver.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -90,7 +90,7 @@ typedef struct audio_driver /* Is the audio driver currently running? */ bool (*alive)(void *data); - /* Should we care about blocking in audio thread? Fast forwarding. + /* Should we care about blocking in audio thread? Fast forwarding. * * If state is true, nonblocking operation is assumed. * This is typically used for fast-forwarding. If driver cannot @@ -103,7 +103,7 @@ typedef struct audio_driver void (*free)(void *data); /* Defines if driver will take standard floating point samples, - * or int16_t samples. + * or int16_t samples. * * If true is returned, the audio driver is capable of using * floating point data. This will likely increase performance as the diff --git a/audio/audio_thread_wrapper.c b/audio/audio_thread_wrapper.c index 196fd201c6..76e130fd44 100644 --- a/audio/audio_thread_wrapper.c +++ b/audio/audio_thread_wrapper.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -56,7 +56,7 @@ static void audio_thread_loop(void *data) return; RARCH_LOG("[Audio Thread]: Initializing audio driver.\n"); - thr->driver_data = thr->driver->init(thr->device, thr->out_rate, thr->latency, + thr->driver_data = thr->driver->init(thr->device, thr->out_rate, thr->latency, thr->block_frames, thr->new_rate); slock_lock(thr->lock); thr->inited = thr->driver_data ? 1 : -1; @@ -68,7 +68,7 @@ static void audio_thread_loop(void *data) if (thr->inited < 0) return; - /* Wait until we start to avoid calling + /* Wait until we start to avoid calling * stop immediately after initialization. */ slock_lock(thr->lock); while (thr->stopped) @@ -188,7 +188,7 @@ static bool audio_thread_stop(void *data) audio_thread_t *thr = (audio_thread_t*)data; if (!thr) - return false; + return false; audio_thread_block(thr); thr->is_paused = true; @@ -274,7 +274,7 @@ static const audio_driver_t audio_thread = { * * Starts a audio driver in a new thread. * Access to audio driver will be mediated through this driver. - * This driver interfaces with audio callback and is + * This driver interfaces with audio callback and is * only used in that case. * * Returns: true (1) if successful, otherwise false (0). diff --git a/audio/audio_thread_wrapper.h b/audio/audio_thread_wrapper.h index 298941d4ff..fcb2e0d028 100644 --- a/audio/audio_thread_wrapper.h +++ b/audio/audio_thread_wrapper.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/audio/drivers/alsa.c b/audio/drivers/alsa.c index 379b579658..c2f2a13f91 100644 --- a/audio/drivers/alsa.c +++ b/audio/drivers/alsa.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -121,7 +121,7 @@ static void *alsa_init(const char *device, unsigned rate, unsigned latency, if (snd_pcm_hw_params(alsa->pcm, params) < 0) goto error; - /* Shouldn't have to bother with this, + /* Shouldn't have to bother with this, * but some drivers are apparently broken. */ if (snd_pcm_hw_params_get_period_size(params, &buffer_size, NULL)) snd_pcm_hw_params_get_period_size_min(params, &buffer_size, NULL); diff --git a/audio/drivers/alsa_qsa.c b/audio/drivers/alsa_qsa.c index 6fe075cfd9..76d442db98 100644 --- a/audio/drivers/alsa_qsa.c +++ b/audio/drivers/alsa_qsa.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -231,7 +231,7 @@ static ssize_t alsa_qsa_write(void *data, const void *buf, size_t size) if (avail_write) { - memcpy(alsa->buffer[alsa->buffer_index] + + memcpy(alsa->buffer[alsa->buffer_index] + alsa->buffer_ptr, buf, avail_write); alsa->buffer_ptr += avail_write; @@ -355,8 +355,8 @@ static void alsa_qsa_free(void *data) static size_t alsa_qsa_write_avail(void *data) { alsa_t *alsa = (alsa_t*)data; - size_t avail = (alsa->buf_count - - (int)alsa->buffered_blocks - 1) * alsa->buf_size + + size_t avail = (alsa->buf_count - + (int)alsa->buffered_blocks - 1) * alsa->buf_size + (alsa->buf_size - (int)alsa->buffer_ptr); return avail; } @@ -364,7 +364,7 @@ static size_t alsa_qsa_write_avail(void *data) static size_t alsa_qsa_buffer_size(void *data) { alsa_t *alsa = (alsa_t*)data; - return alsa->buf_size * alsa->buf_count; + return alsa->buf_size * alsa->buf_count; } audio_driver_t audio_alsa = { diff --git a/audio/drivers/alsathread.c b/audio/drivers/alsathread.c index e6206eb65b..b01b6a424a 100644 --- a/audio/drivers/alsathread.c +++ b/audio/drivers/alsathread.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2012-2015 - Michael Lelli - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -77,7 +77,7 @@ static void alsa_worker_thread(void *data) frames = snd_pcm_writei(alsa->pcm, buf, alsa->period_frames); - if (frames == -EPIPE || frames == -EINTR || + if (frames == -EPIPE || frames == -EINTR || frames == -ESTRPIPE) { if (snd_pcm_recover(alsa->pcm, frames, 1) < 0) @@ -192,7 +192,7 @@ static void *alsa_thread_init(const char *device, TRY_ALSA(snd_pcm_hw_params(alsa->pcm, params)); - /* Shouldn't have to bother with this, + /* Shouldn't have to bother with this, * but some drivers are apparently broken. */ if (snd_pcm_hw_params_get_period_size(params, &alsa->period_frames, NULL)) snd_pcm_hw_params_get_period_size_min( diff --git a/audio/drivers/coreaudio.c b/audio/drivers/coreaudio.c index 02ff2c6b9a..6f255bbc5b 100644 --- a/audio/drivers/coreaudio.c +++ b/audio/drivers/coreaudio.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2014 - Chris Moeller - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -112,7 +112,7 @@ static OSStatus audio_write_cb(void *userdata, slock_unlock(dev->lock); /* Technically possible to deadlock without. */ - scond_signal(dev->cond); + scond_signal(dev->cond); return noErr; } @@ -169,10 +169,10 @@ static void choose_output_device(coreaudio_t *dev, const char* device) size = 1024; if (AudioObjectGetPropertyData(devices[i], - &propaddr, 0, 0, &size, device_name) == noErr + &propaddr, 0, 0, &size, device_name) == noErr && string_is_equal(device_name, device)) { - AudioUnitSetProperty(dev->dev, kAudioOutputUnitProperty_CurrentDevice, + AudioUnitSetProperty(dev->dev, kAudioOutputUnitProperty_CurrentDevice, kAudioUnitScope_Global, 0, &devices[i], sizeof(AudioDeviceID)); goto done; } @@ -244,7 +244,7 @@ static void *coreaudio_init(const char *device, #endif if (comp == NULL) goto error; - + #if (defined(__MACH__) && (defined(__ppc__) || defined(__ppc64__))) component_unavailable = (OpenAComponent(comp, &dev->dev) != noErr); #else @@ -269,17 +269,17 @@ static void *coreaudio_init(const char *device, stream_desc.mBytesPerFrame = 2 * sizeof(float); stream_desc.mFramesPerPacket = 1; stream_desc.mFormatID = kAudioFormatLinearPCM; - stream_desc.mFormatFlags = kAudioFormatFlagIsFloat | - kAudioFormatFlagIsPacked | (is_little_endian() ? + stream_desc.mFormatFlags = kAudioFormatFlagIsFloat | + kAudioFormatFlagIsPacked | (is_little_endian() ? 0 : kAudioFormatFlagIsBigEndian); - + if (AudioUnitSetProperty(dev->dev, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0, &stream_desc, sizeof(stream_desc)) != noErr) goto error; - + /* Check returned audio format. */ i_size = sizeof(real_desc); - if (AudioUnitGetProperty(dev->dev, kAudioUnitProperty_StreamFormat, + if (AudioUnitGetProperty(dev->dev, kAudioUnitProperty_StreamFormat, kAudioUnitScope_Input, 0, &real_desc, &i_size) != noErr) goto error; diff --git a/audio/drivers/ctr_csnd_audio.c b/audio/drivers/ctr_csnd_audio.c index 4765cd7f5c..8731706c32 100644 --- a/audio/drivers/ctr_csnd_audio.c +++ b/audio/drivers/ctr_csnd_audio.c @@ -49,7 +49,7 @@ typedef struct static void ctr_csnd_audio_update_playpos(ctr_csnd_audio_t* ctr) { uint64_t current_tick = svcGetSystemTick(); - uint32_t samples_played = (current_tick - ctr->cpu_ticks_last) + uint32_t samples_played = (current_tick - ctr->cpu_ticks_last) / CTR_CSND_CPU_TICKS_PER_SAMPLE; ctr->playpos = (ctr->playpos + samples_played) & CTR_CSND_AUDIO_COUNT_MASK; @@ -94,7 +94,7 @@ Result csndPlaySound_custom(int chn, u32 flags, float vol, float pan, if (loopMode == CSND_LOOPMODE_NORMAL && paddr1 > paddr0) { - /* Now that the first block is playing, + /* Now that the first block is playing, * configure the size of the subsequent blocks */ size -= paddr1 - paddr0; CSND_SetBlock(chn, 1, paddr1, size); @@ -209,7 +209,7 @@ static ssize_t ctr_csnd_audio_write(void *data, const void *buf, size_t size) } static bool ctr_csnd_audio_stop(void *data) -{ +{ ctr_csnd_audio_t* ctr = (ctr_csnd_audio_t*)data; /* using SetPlayState would make tracking the playback diff --git a/audio/drivers/dsound.c b/audio/drivers/dsound.c index 9514236f4a..09b8119f87 100644 --- a/audio/drivers/dsound.c +++ b/audio/drivers/dsound.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -93,7 +93,7 @@ static INLINE bool grab_region(dsound_t *ds, uint32_t write_ptr, struct audio_lock *region) { const char *err = NULL; - HRESULT res = IDirectSoundBuffer_Lock(ds->dsb, write_ptr, CHUNK_SIZE, + HRESULT res = IDirectSoundBuffer_Lock(ds->dsb, write_ptr, CHUNK_SIZE, ®ion->chunk1, ®ion->size1, ®ion->chunk2, ®ion->size2, 0); if (res == DSERR_BUFFERLOST) @@ -152,7 +152,7 @@ static void dsound_thread(void *data) struct audio_lock region; DWORD read_ptr, avail, fifo_avail; get_positions(ds, &read_ptr, NULL); - + avail = write_avail(read_ptr, write_ptr, ds->buffer_size); EnterCriticalSection(&ds->crit); @@ -161,12 +161,12 @@ static void dsound_thread(void *data) if (avail < CHUNK_SIZE || ((fifo_avail < CHUNK_SIZE) && (avail < ds->buffer_size / 2))) { - /* No space to write, or we don't have data in our fifo, + /* No space to write, or we don't have data in our fifo, * but we can wait some time before it underruns ... */ /* We could opt for using the notification interface, - * but it is not guaranteed to work, so use high + * but it is not guaranteed to work, so use high * priority sleeping patterns. */ retro_sleep(1); @@ -182,7 +182,7 @@ static void dsound_thread(void *data) if (fifo_avail < CHUNK_SIZE) { - /* Got space to write, but nothing in FIFO (underrun), + /* Got space to write, but nothing in FIFO (underrun), * fill block with silence. */ memset(region.chunk1, 0, region.size1); @@ -191,7 +191,7 @@ static void dsound_thread(void *data) release_region(ds, ®ion); write_ptr = (write_ptr + region.size1 + region.size2) % ds->buffer_size; } - else + else { /* All is good. Pull from it and notify FIFO. */ diff --git a/audio/drivers/gx_audio.c b/audio/drivers/gx_audio.c index 7453060881..5e840a933f 100644 --- a/audio/drivers/gx_audio.c +++ b/audio/drivers/gx_audio.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -129,9 +129,9 @@ static ssize_t gx_audio_write(void *data, const void *buf_, size_t size) if (frames < to_write) to_write = frames; - /* FIXME: Nonblocking audio should break out of loop + /* FIXME: Nonblocking audio should break out of loop * when it has nothing to write. */ - while ((wa->dma_write == wa->dma_next || + while ((wa->dma_write == wa->dma_next || wa->dma_write == wa->dma_busy) && !wa->nonblock) OSSleepThread(wa->cond); diff --git a/audio/drivers/jack.c b/audio/drivers/jack.c index 9b0758175f..40a116f292 100644 --- a/audio/drivers/jack.c +++ b/audio/drivers/jack.c @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -181,7 +181,7 @@ static void *ja_init(const char *device, unsigned rate, unsigned latency, RARCH_ERR("[JACK]: Failed to register ports.\n"); goto error; } - + jports = jack_get_ports(jd->client, NULL, NULL, JackPortIsPhysical | JackPortIsInput); if (jports == NULL) { @@ -222,7 +222,7 @@ static void *ja_init(const char *device, unsigned rate, unsigned latency, for (i = 0; i < parsed; i++) free(dest_ports[i]); - + jack_free(jports); return jd; diff --git a/audio/drivers/nullaudio.c b/audio/drivers/nullaudio.c index d0d9c0d36b..39be26d4d0 100644 --- a/audio/drivers/nullaudio.c +++ b/audio/drivers/nullaudio.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/audio/drivers/openal.c b/audio/drivers/openal.c index 69964f4225..6127ca9b4d 100644 --- a/audio/drivers/openal.c +++ b/audio/drivers/openal.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/audio/drivers/opensl.c b/audio/drivers/opensl.c index fef08db8f2..113bce3567 100644 --- a/audio/drivers/opensl.c +++ b/audio/drivers/opensl.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -200,7 +200,7 @@ error: static bool sl_stop(void *data) { sl_t *sl = (sl_t*)data; - sl->is_paused = (SLPlayItf_SetPlayState(sl->player, SL_PLAYSTATE_STOPPED) + sl->is_paused = (SLPlayItf_SetPlayState(sl->player, SL_PLAYSTATE_STOPPED) == SL_RESULT_SUCCESS) ? true : false; return sl->is_paused ? true : false; diff --git a/audio/drivers/oss.c b/audio/drivers/oss.c index d6d4d28ffa..1c6691187e 100644 --- a/audio/drivers/oss.c +++ b/audio/drivers/oss.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -51,7 +51,7 @@ static void *oss_init(const char *device, unsigned rate, unsigned latency, int frags, frag, channels, format, new_rate; int *fd = (int*)calloc(1, sizeof(int)); const char *oss_device = device ? device : DEFAULT_OSS_DEV; - + if (!fd) return NULL; diff --git a/audio/drivers/ps3_audio.c b/audio/drivers/ps3_audio.c index 0d4e56e467..1f5eba29b6 100644 --- a/audio/drivers/ps3_audio.c +++ b/audio/drivers/ps3_audio.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -110,11 +110,11 @@ static void *ps3_audio_init(const char *device, return NULL; } - data->buffer = fifo_new(CELL_AUDIO_BLOCK_SAMPLES * + data->buffer = fifo_new(CELL_AUDIO_BLOCK_SAMPLES * AUDIO_CHANNELS * AUDIO_BLOCKS * sizeof(float)); #ifdef __PSL1GHT__ - sys_lwmutex_attr_t lock_attr = + sys_lwmutex_attr_t lock_attr = {SYS_LWMUTEX_ATTR_PROTOCOL, SYS_LWMUTEX_ATTR_RECURSIVE, "\0"}; sys_lwmutex_attr_t cond_lock_attr = {SYS_LWMUTEX_ATTR_PROTOCOL, SYS_LWMUTEX_ATTR_RECURSIVE, "\0"}; diff --git a/audio/drivers/psp_audio.c b/audio/drivers/psp_audio.c index 808f21e3e5..48e0cdc823 100644 --- a/audio/drivers/psp_audio.c +++ b/audio/drivers/psp_audio.c @@ -244,9 +244,9 @@ static bool psp_audio_stop(void *data) SceUInt timeout = 100000; psp_audio_t* psp = (psp_audio_t*)data; - if(psp && !psp->running) + if(psp && !psp->running) return true; - + info.size = sizeof(SceKernelThreadInfo); if (sceKernelGetThreadInfo( @@ -269,8 +269,8 @@ static bool psp_audio_start(void *data, bool is_shutdown) { SceKernelThreadInfo info; psp_audio_t* psp = (psp_audio_t*)data; - - if(psp && psp->running) + + if(psp && psp->running) return true; info.size = sizeof(SceKernelThreadInfo); diff --git a/audio/drivers/pulse.c b/audio/drivers/pulse.c index 61e47fd08f..ce3e94bd5e 100644 --- a/audio/drivers/pulse.c +++ b/audio/drivers/pulse.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -88,7 +88,7 @@ static void context_state_cb(pa_context *c, void *data) } } -static void stream_state_cb(pa_stream *s, void *data) +static void stream_state_cb(pa_stream *s, void *data) { pa_t *pa = (pa_t*)data; @@ -104,7 +104,7 @@ static void stream_state_cb(pa_stream *s, void *data) } } -static void stream_request_cb(pa_stream *s, size_t length, void *data) +static void stream_request_cb(pa_stream *s, size_t length, void *data) { pa_t *pa = (pa_t*)data; @@ -114,7 +114,7 @@ static void stream_request_cb(pa_stream *s, size_t length, void *data) pa_threaded_mainloop_signal(pa->mainloop, 0); } -static void stream_latency_update_cb(pa_stream *s, void *data) +static void stream_latency_update_cb(pa_stream *s, void *data) { pa_t *pa = (pa_t*)data; @@ -149,7 +149,7 @@ static void buffer_attr_cb(pa_stream *s, void *data) } static void *pulse_init(const char *device, unsigned rate, - unsigned latency, + unsigned latency, unsigned block_frames, unsigned *new_rate) { @@ -232,7 +232,7 @@ static void *pulse_init(const char *device, unsigned rate, unlock_error: pa_threaded_mainloop_unlock(pa->mainloop); error: - pulse_free(pa); + pulse_free(pa); return NULL; } diff --git a/audio/drivers/roar.c b/audio/drivers/roar.c index 7e08f74749..815e5ade96 100644 --- a/audio/drivers/roar.c +++ b/audio/drivers/roar.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/audio/drivers/rsound.c b/audio/drivers/rsound.c index 258f42aa2a..c6241c51d5 100644 --- a/audio/drivers/rsound.c +++ b/audio/drivers/rsound.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/audio/drivers/rsound.h b/audio/drivers/rsound.h index 645eaa8316..236eeb16e6 100644 --- a/audio/drivers/rsound.h +++ b/audio/drivers/rsound.h @@ -1,6 +1,6 @@ /* RSound - A PCM audio client/server * Copyright (C) 2010-2014 - Hans-Kristian Arntzen - * + * * RSound 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -43,7 +43,7 @@ RETRO_BEGIN_DECLS #endif /* Feature tests */ -#define RSD_SAMPLERATE RSD_SAMPLERATE +#define RSD_SAMPLERATE RSD_SAMPLERATE #define RSD_CHANNELS RSD_CHANNELS #define RSD_HOST RSD_HOST #define RSD_PORT RSD_PORT @@ -125,7 +125,7 @@ enum rsd_settings /* Audio callback for rsd_set_callback. Return -1 to trigger an error in the stream. */ typedef ssize_t (*rsd_audio_callback_t)(void *data, size_t bytes, void *userdata); -/* Error callback. Signals caller that stream has been stopped, +/* Error callback. Signals caller that stream has been stopped, * either by audio callback returning -1 or stream was hung up. */ typedef void (*rsd_error_callback_t)(void *userdata); @@ -144,7 +144,7 @@ typedef struct rsound int conn_type; volatile int buffer_pointer; /* Obsolete, but kept for backwards header compatibility. */ - size_t buffer_size; + size_t buffer_size; fifo_buffer_t *fifo_buffer; volatile int thread_active; @@ -196,13 +196,13 @@ typedef struct rsound rsd_set_param(rd, RSD_HOST, "foohost"); *sets more params* rsd_start(rd); - rsd_write(rd, buf, size); + rsd_write(rd, buf, size); rsd_stop(rd); rsd_free(rd); */ int rsd_init (rsound_t **rd); -/* This is a simpler function that initializes an rsound struct, sets params as given, +/* This is a simpler function that initializes an rsound struct, sets params as given, and starts the stream. Should this function fail, the structure will stay uninitialized. Should NULL be passed in either host, port or ident, defaults will be used. */ @@ -211,29 +211,29 @@ int rsd_simple_start (rsound_t **rd, const char* host, const char* port, const c /* Sets params associated with an rsound_t. These options (int options) include: -RSD_HOST: Server to connect to. Expects (char *) in param. -If not set, will default to environmental variable RSD_SERVER or "localhost". +RSD_HOST: Server to connect to. Expects (char *) in param. +If not set, will default to environmental variable RSD_SERVER or "localhost". -RSD_PORT: Set port. Expects (char *) in param. +RSD_PORT: Set port. Expects (char *) in param. If not set, will default to environmental variable RSD_PORT or "12345". RSD_CHANNELS: Set number of audio channels. Expects (int *) in param. Mandatory. RSD_SAMPLERATE: Set samplerate of audio stream. Expects (int *) in param. Mandatory. -RSD_BUFSIZE: Sets internal buffersize for the stream. -Might be overridden if too small. +RSD_BUFSIZE: Sets internal buffersize for the stream. +Might be overridden if too small. Expects (int *) in param. Optional. -RSD_LATENCY: Sets maximum audio latency in milliseconds, -(must be used with rsd_delay_wait() or this will have no effect). -Most applications do not need this. -Might be overridden if too small. +RSD_LATENCY: Sets maximum audio latency in milliseconds, +(must be used with rsd_delay_wait() or this will have no effect). +Most applications do not need this. +Might be overridden if too small. Expects (int *) in param. Optional. -RSD_FORMAT: Sets sample format. -It defaults to S16_LE, so you probably will not use this. -Expects (int *) in param, with available values found in the format enum. +RSD_FORMAT: Sets sample format. +It defaults to S16_LE, so you probably will not use this. +Expects (int *) in param, with available values found in the format enum. If invalid format is given, param might be changed to reflect the sample format the library will use. RSD_IDENTITY: Sets an identity string associated with the client. @@ -244,14 +244,14 @@ Will be truncated if longer than 256 bytes. int rsd_set_param (rsound_t *rd, enum rsd_settings option, void* param); -/* Enables use of the callback interface. This must be set when stream is not active. - When callback is active, use of the blocking interface is disabled. - Only valid functions to call after rsd_start() is stopping the stream with either rsd_pause() or rsd_stop(). Calling any other function is undefined. - The callback is called at regular intervals and is asynchronous, so thread safety must be ensured by the caller. - If not enough data can be given to the callback, librsound will fill the rest of the callback data with silence. +/* Enables use of the callback interface. This must be set when stream is not active. + When callback is active, use of the blocking interface is disabled. + Only valid functions to call after rsd_start() is stopping the stream with either rsd_pause() or rsd_stop(). Calling any other function is undefined. + The callback is called at regular intervals and is asynchronous, so thread safety must be ensured by the caller. + If not enough data can be given to the callback, librsound will fill the rest of the callback data with silence. librsound will attempt to obey latency information given with RSD_LATENCY as given before calling rsd_start(). max_size signifies the maximum size that will ever be requested by librsound. Set this to 0 to let librsound decide the maximum size. - Should an error occur to the stream, err_callback will be called, and the stream will be stopped. The stream can be started again. + Should an error occur to the stream, err_callback will be called, and the stream will be stopped. The stream can be started again. Callbacks can be disabled by setting callbacks to NULL. */ @@ -260,37 +260,37 @@ void rsd_set_callback (rsound_t *rd, rsd_audio_callback_t callback, rsd_error_ca /* Lock and unlock the callback. When the callback lock is aquired, the callback is guaranteed to not be executing. The lock has to be unlocked afterwards. Attemping to call several rsd_callback_lock() in succession might cause a deadlock. - The lock should be held for as short period as possible. + The lock should be held for as short period as possible. Try to avoid calling code that may block when holding the lock. */ void rsd_callback_lock (rsound_t *rd); void rsd_callback_unlock (rsound_t *rd); -/* Establishes connection to server. Might fail if connection can't be established or that one of +/* Establishes connection to server. Might fail if connection can't be established or that one of the mandatory options isn't set in rsd_set_param(). This needs to be called after params have been set - with rsd_set_param(), and before rsd_write(). */ + with rsd_set_param(), and before rsd_write(). */ int rsd_start (rsound_t *rd); /* Shuts down the rsound data structures, but returns the file descriptor associated with the connection. - The control socket will be shut down. If this function returns a negative number, the exec failed, - but the data structures will not be teared down. + The control socket will be shut down. If this function returns a negative number, the exec failed, + but the data structures will not be teared down. Should a valid file descriptor be returned, it will always be blocking. This call will block until all internal buffers have been sent to the network. */ int rsd_exec (rsound_t *rd); -/* Disconnects from server. All audio data still in network buffer and other buffers will be dropped. +/* Disconnects from server. All audio data still in network buffer and other buffers will be dropped. To continue playing, you will need to rsd_start() again. */ int rsd_stop (rsound_t *rd); -/* Writes from buf to the internal buffer. Might fail if no connection is established, +/* Writes from buf to the internal buffer. Might fail if no connection is established, or there was an unexpected error. This function will block until all data has been written to the buffer. This function will return the number of bytes written to the buffer, or 0 should it fail (disconnection from server). You will have to restart the stream again should this occur. */ size_t rsd_write (rsound_t *rd, const void* buf, size_t size); -/* Gets the position of the buffer pointer. - Not really interesting for normal applications. - Might be useful for implementing rsound on top of other blocking APIs. +/* Gets the position of the buffer pointer. + Not really interesting for normal applications. + Might be useful for implementing rsound on top of other blocking APIs. *NOTE* This function is deprecated, it should not be used in new applications. */ size_t rsd_pointer (rsound_t *rd); @@ -306,12 +306,12 @@ size_t rsd_delay_ms (rsound_t *rd); /* Returns bytes per sample */ int rsd_samplesize(rsound_t *rd); -/* Will sleep until latency of stream reaches maximum allowed latency defined earlier by rsd_set_param - RSD_LATENCY +/* Will sleep until latency of stream reaches maximum allowed latency defined earlier by rsd_set_param - RSD_LATENCY Useful for hard headed blocking I/O design where user defined latency is needed. If rsd_set_param hasn't been set with RSD_LATENCY, this function will do nothing. */ void rsd_delay_wait(rsound_t *rd); -/* Pauses or unpauses a stream. pause -> enable = 1 +/* Pauses or unpauses a stream. pause -> enable = 1 This function essentially calls on start() and stop(). This behavior might be changed later. */ int rsd_pause (rsound_t *rd, int enable); diff --git a/audio/drivers/rwebaudio.c b/audio/drivers/rwebaudio.c index 5a90e69233..3e819b2049 100644 --- a/audio/drivers/rwebaudio.c +++ b/audio/drivers/rwebaudio.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2015 - Michael Lelli * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/audio/drivers/sdl_audio.c b/audio/drivers/sdl_audio.c index 49703948a2..31152a644b 100644 --- a/audio/drivers/sdl_audio.c +++ b/audio/drivers/sdl_audio.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -93,7 +93,7 @@ static void *sdl_audio_init(const char *device, if (!sdl) return NULL; - /* We have to buffer up some data ourselves, so we let SDL + /* We have to buffer up some data ourselves, so we let SDL * carry approximately half of the latency. * * SDL double buffers audio and we do as well. */ @@ -119,7 +119,7 @@ static void *sdl_audio_init(const char *device, sdl->cond = scond_new(); #endif - RARCH_LOG("[SDL audio]: Requested %u ms latency, got %d ms\n", + RARCH_LOG("[SDL audio]: Requested %u ms latency, got %d ms\n", latency, (int)(out.samples * 4 * 1000 / (*new_rate))); /* Create a buffer twice as big as needed and prefill the buffer. */ diff --git a/audio/drivers/tinyalsa.c b/audio/drivers/tinyalsa.c index 08e8ea4a1a..bb12d3a253 100644 --- a/audio/drivers/tinyalsa.c +++ b/audio/drivers/tinyalsa.c @@ -30,7 +30,7 @@ * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis * Copyright (C) 2017 - Charlton Head - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -508,7 +508,7 @@ struct snd_pcm_sw_params struct snd_pcm_hw_params { unsigned int flags; - struct snd_mask masks[SNDRV_PCM_HW_PARAM_LAST_MASK - + struct snd_mask masks[SNDRV_PCM_HW_PARAM_LAST_MASK - SNDRV_PCM_HW_PARAM_FIRST_MASK + 1]; struct snd_mask mres[5]; /* reserved masks */ struct snd_interval intervals[SNDRV_PCM_HW_PARAM_LAST_INTERVAL - @@ -2320,7 +2320,7 @@ tinyalsa_write(void *data, const void *buf_, size_t size_) } } - return written; + return written; } @@ -2366,7 +2366,7 @@ tinyalsa_start(void *data, bool is_shutdown) RARCH_ERR("[TINYALSA]: Failed to unpause.\n"); return false; } - + tinyalsa->is_paused = false; } @@ -2414,7 +2414,7 @@ static size_t tinyalsa_write_avail(void *data) static size_t tinyalsa_buffer_size(void *data) { tinyalsa_t *tinyalsa = (tinyalsa_t*)data; - + return tinyalsa->buffer_size; } diff --git a/audio/drivers/wasapi.c b/audio/drivers/wasapi.c index e11d8056e0..249ab3589d 100644 --- a/audio/drivers/wasapi.c +++ b/audio/drivers/wasapi.c @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -15,7 +15,7 @@ #include -#ifdef _WIN32_WINNT +#ifdef _WIN32_WINNT #undef _WIN32_WINNT #endif #define _WIN32_WINNT 0x0600 @@ -40,7 +40,7 @@ DEFINE_PROPERTYKEY(PKEY_Device_FriendlyName, 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0 #ifdef __cplusplus #define _IMMDeviceCollection_Item(This,nDevice,ppdevice) (This)->Item(nDevice,ppdevice) -#define _IAudioClient_Start(This) ( (This)->Start() ) +#define _IAudioClient_Start(This) ( (This)->Start() ) #define _IAudioClient_Stop(This) ( (This)->Stop() ) #define _IAudioClient_GetCurrentPadding(This,pNumPaddingFrames) \ ( (This)->GetCurrentPadding(pNumPaddingFrames) ) @@ -62,7 +62,7 @@ DEFINE_PROPERTYKEY(PKEY_Device_FriendlyName, 0xa45c254e, 0xdf1c, 0x4efd, 0x80, 0 #define _IMMDeviceCollection_GetCount(This,cProps) ( (This)->GetCount(cProps) ) #else #define _IMMDeviceCollection_Item(This,nDevice,ppdevice) (This)->lpVtbl->Item(This,nDevice,ppdevice) -#define _IAudioClient_Start(This) ( (This)->lpVtbl -> Start(This) ) +#define _IAudioClient_Start(This) ( (This)->lpVtbl -> Start(This) ) #define _IAudioClient_Stop(This) ( (This)->lpVtbl -> Stop(This) ) #define _IAudioClient_GetCurrentPadding(This,pNumPaddingFrames) \ ( (This)->lpVtbl -> GetCurrentPadding(This,pNumPaddingFrames) ) @@ -163,7 +163,7 @@ static bool wasapi_check_device_id(IMMDevice *device, const char *id) id_length = MultiByteToWideChar(CP_ACP, 0, id, -1, dev_cmp_id, id_length); WASAPI_SR_CHECK(id_length > 0, "MultiByteToWideChar", goto error); - + hr = _IMMDevice_GetId(device, &dev_id); WASAPI_HR_CHECK(hr, "IMMDevice::GetId", goto error); @@ -306,7 +306,7 @@ static IAudioClient *wasapi_init_client_sh(IMMDevice *device, bool float_fmt_res = *float_fmt; unsigned rate_res = *rate; HRESULT hr = _IMMDevice_Activate(device, - IID_IAudioClient, + IID_IAudioClient, CLSCTX_ALL, NULL, (void**)&client); WASAPI_HR_CHECK(hr, "IMMDevice::Activate", return NULL); @@ -339,7 +339,7 @@ static IAudioClient *wasapi_init_client_sh(IMMDevice *device, HRESULT hr; WASAPI_RELEASE(client); hr = _IMMDevice_Activate(device, - IID_IAudioClient, + IID_IAudioClient, CLSCTX_ALL, NULL, (void**)&client); WASAPI_HR_CHECK(hr, "IMMDevice::Activate", return NULL); @@ -391,7 +391,7 @@ static IAudioClient *wasapi_init_client_ex(IMMDevice *device, REFERENCE_TIME buffer_duration = 0; UINT32 buffer_length = 0; HRESULT hr = _IMMDevice_Activate(device, - IID_IAudioClient, + IID_IAudioClient, CLSCTX_ALL, NULL, (void**)&client); WASAPI_HR_CHECK(hr, "IMMDevice::Activate", return NULL); @@ -433,7 +433,7 @@ static IAudioClient *wasapi_init_client_ex(IMMDevice *device, WASAPI_RELEASE(client); hr = _IMMDevice_Activate(device, - IID_IAudioClient, + IID_IAudioClient, CLSCTX_ALL, NULL, (void**)&client); WASAPI_HR_CHECK(hr, "IMMDevice::Activate", return NULL); @@ -452,7 +452,7 @@ static IAudioClient *wasapi_init_client_ex(IMMDevice *device, { WASAPI_RELEASE(client); hr = _IMMDevice_Activate(device, - IID_IAudioClient, + IID_IAudioClient, CLSCTX_ALL, NULL, (void**)&client); WASAPI_HR_CHECK(hr, "IMMDevice::Activate", return NULL); @@ -669,7 +669,7 @@ static void *wasapi_init(const char *dev_id, unsigned rate, unsigned latency, error: WASAPI_RELEASE(w->renderer); - WASAPI_RELEASE(w->client); + WASAPI_RELEASE(w->client); WASAPI_RELEASE(w->device); if (w->write_event) CloseHandle(w->write_event); @@ -1045,7 +1045,7 @@ static size_t wasapi_write_avail(void *wh) hr = _IAudioClient_GetCurrentPadding(w->client, &padding); WASAPI_HR_CHECK(hr, "IAudioClient::GetCurrentPadding", return 0); - + return w->engine_buffer_size - padding * w->frame_size; } diff --git a/audio/drivers/xaudio.c b/audio/drivers/xaudio.c index cae0f8a289..f3c81a1741 100644 --- a/audio/drivers/xaudio.c +++ b/audio/drivers/xaudio.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -69,7 +69,7 @@ struct xaudio2 virtual ~xaudio2() {} STDMETHOD_(void, OnBufferStart) (void *) {} - STDMETHOD_(void, OnBufferEnd) (void *) + STDMETHOD_(void, OnBufferEnd) (void *) { InterlockedDecrement((LONG volatile*)&buffers); SetEvent(hEvent); @@ -96,27 +96,27 @@ struct xaudio2 }; #ifndef __cplusplus -static void WINAPI voice_on_buffer_end(void *handle_, void *data) -{ - xaudio2_t *handle = (xaudio2_t*)handle_; - (void)data; - InterlockedDecrement((LONG volatile*)&handle->buffers); - SetEvent(handle->hEvent); -} +static void WINAPI voice_on_buffer_end(void *handle_, void *data) +{ + xaudio2_t *handle = (xaudio2_t*)handle_; + (void)data; + InterlockedDecrement((LONG volatile*)&handle->buffers); + SetEvent(handle->hEvent); +} -static void WINAPI dummy_voidp(void *handle, void *data) { (void)handle; (void)data; } -static void WINAPI dummy_nil(void *handle) { (void)handle; } -static void WINAPI dummy_uint32(void *handle, UINT32 dummy) { (void)handle; (void)dummy; } -static void WINAPI dummy_voidp_hresult(void *handle, void *data, HRESULT dummy) { (void)handle; (void)data; (void)dummy; } +static void WINAPI dummy_voidp(void *handle, void *data) { (void)handle; (void)data; } +static void WINAPI dummy_nil(void *handle) { (void)handle; } +static void WINAPI dummy_uint32(void *handle, UINT32 dummy) { (void)handle; (void)dummy; } +static void WINAPI dummy_voidp_hresult(void *handle, void *data, HRESULT dummy) { (void)handle; (void)data; (void)dummy; } -const struct IXAudio2VoiceCallbackVtbl voice_vtable = { - dummy_uint32, - dummy_nil, - dummy_nil, - dummy_voidp, - voice_on_buffer_end, - dummy_voidp, - dummy_voidp_hresult, +const struct IXAudio2VoiceCallbackVtbl voice_vtable = { + dummy_uint32, + dummy_nil, + dummy_nil, + dummy_voidp, + voice_on_buffer_end, + dummy_voidp, + dummy_voidp_hresult, }; #endif @@ -225,9 +225,9 @@ static xaudio2_t *xaudio2_new(unsigned samplerate, unsigned channels, xaudio2_set_wavefmt(&wfx, channels, samplerate); - if (FAILED(IXAudio2_CreateSourceVoice(handle->pXAudio2, - &handle->pSourceVoice, &wfx, - XAUDIO2_VOICE_NOSRC, XAUDIO2_DEFAULT_FREQ_RATIO, + if (FAILED(IXAudio2_CreateSourceVoice(handle->pXAudio2, + &handle->pSourceVoice, &wfx, + XAUDIO2_VOICE_NOSRC, XAUDIO2_DEFAULT_FREQ_RATIO, (IXAudio2VoiceCallback*)handle, 0, 0))) goto error; @@ -240,7 +240,7 @@ static xaudio2_t *xaudio2_new(unsigned samplerate, unsigned channels, if (!handle->buf) goto error; - if (FAILED(IXAudio2SourceVoice_Start(handle->pSourceVoice, 0, + if (FAILED(IXAudio2SourceVoice_Start(handle->pSourceVoice, 0, XAUDIO2_COMMIT_NOW))) goto error; @@ -265,7 +265,7 @@ static size_t xaudio2_write(xaudio2_t *handle, const void *buf, size_t bytes_) { unsigned need = MIN(bytes, handle->bufsize - handle->bufptr); - memcpy(handle->buf + handle->write_buffer * + memcpy(handle->buf + handle->write_buffer * handle->bufsize + handle->bufptr, buffer, need); diff --git a/audio/drivers/xaudio.h b/audio/drivers/xaudio.h index 266f89a59c..4c03e60035 100644 --- a/audio/drivers/xaudio.h +++ b/audio/drivers/xaudio.h @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis * Copyright (C) 2010-2014 - OV2 - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -58,7 +58,7 @@ DEFINE_IID(IXAudio2, 8bcf1f58, 9fe7, 4583, 8a, c6, e2, ad, c4, 65, c8, bb); #include #ifndef __cplusplus -#undef OPAQUE +#undef OPAQUE #define OPAQUE struct #endif @@ -131,7 +131,7 @@ typedef enum XAUDIO2_WINDOWS_PROCESSOR_SPECIFIER typedef enum XAUDIO2_FILTER_TYPE { LowPassFilter, BandPassFilter, - HighPassFilter + HighPassFilter } XAUDIO2_FILTER_TYPE; typedef struct XAUDIO2_DEVICE_DETAILS @@ -294,27 +294,27 @@ DECLARE_INTERFACE_(IXAudio2, IUnknown) #ifdef __cplusplus /* C++ hooks */ -#define IXAudio2_Initialize(handle,a,b) handle->Initialize(a, b) -#define IXAudio2SourceVoice_SubmitSourceBuffer(handle, a, b) handle->SubmitSourceBuffer(a, b) -#define IXAudio2SourceVoice_Stop(handle, a, b) handle->Stop(a, b) -#define IXAudio2SourceVoice_DestroyVoice(handle) handle->DestroyVoice() -#define IXAudio2MasteringVoice_DestroyVoice(handle) handle->DestroyVoice() -#define IXAudio2_Release(handle) handle->Release() -#define IXAudio2_CreateSourceVoice(handle, a, b, c, d, e, f, g) handle->CreateSourceVoice(a, b, c, d, e, f, g) -#define IXAudio2_CreateMasteringVoice(handle, a, b, c, d, e, f) handle->CreateMasteringVoice(a, b, c, d, e, f) -#define IXAudio2SourceVoice_Start(handle, a, b) handle->Start(a, b) +#define IXAudio2_Initialize(handle,a,b) handle->Initialize(a, b) +#define IXAudio2SourceVoice_SubmitSourceBuffer(handle, a, b) handle->SubmitSourceBuffer(a, b) +#define IXAudio2SourceVoice_Stop(handle, a, b) handle->Stop(a, b) +#define IXAudio2SourceVoice_DestroyVoice(handle) handle->DestroyVoice() +#define IXAudio2MasteringVoice_DestroyVoice(handle) handle->DestroyVoice() +#define IXAudio2_Release(handle) handle->Release() +#define IXAudio2_CreateSourceVoice(handle, a, b, c, d, e, f, g) handle->CreateSourceVoice(a, b, c, d, e, f, g) +#define IXAudio2_CreateMasteringVoice(handle, a, b, c, d, e, f) handle->CreateMasteringVoice(a, b, c, d, e, f) +#define IXAudio2SourceVoice_Start(handle, a, b) handle->Start(a, b) #else /* C hooks */ -#define IXAudio2_Initialize(THIS,a,b) (THIS)->lpVtbl->Initialize(THIS, a, b) -#define IXAudio2_Release(THIS) (THIS)->lpVtbl->Release(THIS) -#define IXAudio2_CreateSourceVoice(THIS,ppSourceVoice,pSourceFormat,Flags,MaxFrequencyRatio,pCallback,pSendList,pEffectChain) (THIS)->lpVtbl->CreateSourceVoice(THIS, ppSourceVoice,pSourceFormat,Flags,MaxFrequencyRatio,pCallback,pSendList,pEffectChain) -#define IXAudio2_CreateMasteringVoice(THIS,ppMasteringVoice,InputChannels,InputSampleRate,Flags,DeviceIndex,pEffectChain) (THIS)->lpVtbl->CreateMasteringVoice(THIS, ppMasteringVoice,InputChannels,InputSampleRate,Flags,DeviceIndex,pEffectChain) -#define IXAudio2_GetDeviceCount(THIS, puCount) (THIS)->lpVtbl->GetDeviceCount(THIS, puCount) -#define IXAudio2_GetDeviceDetails(THIS, Index,pDeviceDetails) (THIS)->lpVtbl->GetDeviceDetails(THIS, Index, pDeviceDetails) -#define IXAudio2SourceVoice_Start(THIS, Flags, OperationSet) (THIS)->lpVtbl->Start(THIS, Flags, OperationSet) -#define IXAudio2SourceVoice_Stop(THIS, Flags, OperationSet) (THIS)->lpVtbl->Stop(THIS, Flags, OperationSet) -#define IXAudio2SourceVoice_SubmitSourceBuffer(THIS, pBuffer, pBufferWMA) (THIS)->lpVtbl->SubmitSourceBuffer(THIS, pBuffer, pBufferWMA) -#define IXAudio2SourceVoice_DestroyVoice(THIS) (THIS)->lpVtbl->DestroyVoice(THIS) +#define IXAudio2_Initialize(THIS,a,b) (THIS)->lpVtbl->Initialize(THIS, a, b) +#define IXAudio2_Release(THIS) (THIS)->lpVtbl->Release(THIS) +#define IXAudio2_CreateSourceVoice(THIS,ppSourceVoice,pSourceFormat,Flags,MaxFrequencyRatio,pCallback,pSendList,pEffectChain) (THIS)->lpVtbl->CreateSourceVoice(THIS, ppSourceVoice,pSourceFormat,Flags,MaxFrequencyRatio,pCallback,pSendList,pEffectChain) +#define IXAudio2_CreateMasteringVoice(THIS,ppMasteringVoice,InputChannels,InputSampleRate,Flags,DeviceIndex,pEffectChain) (THIS)->lpVtbl->CreateMasteringVoice(THIS, ppMasteringVoice,InputChannels,InputSampleRate,Flags,DeviceIndex,pEffectChain) +#define IXAudio2_GetDeviceCount(THIS, puCount) (THIS)->lpVtbl->GetDeviceCount(THIS, puCount) +#define IXAudio2_GetDeviceDetails(THIS, Index,pDeviceDetails) (THIS)->lpVtbl->GetDeviceDetails(THIS, Index, pDeviceDetails) +#define IXAudio2SourceVoice_Start(THIS, Flags, OperationSet) (THIS)->lpVtbl->Start(THIS, Flags, OperationSet) +#define IXAudio2SourceVoice_Stop(THIS, Flags, OperationSet) (THIS)->lpVtbl->Stop(THIS, Flags, OperationSet) +#define IXAudio2SourceVoice_SubmitSourceBuffer(THIS, pBuffer, pBufferWMA) (THIS)->lpVtbl->SubmitSourceBuffer(THIS, pBuffer, pBufferWMA) +#define IXAudio2SourceVoice_DestroyVoice(THIS) (THIS)->lpVtbl->DestroyVoice(THIS) #define IXAudio2MasteringVoice_DestroyVoice(THIS) (THIS)->lpVtbl->DestroyVoice(THIS) #endif diff --git a/audio/drivers/xenon360_audio.c b/audio/drivers/xenon360_audio.c index b72e01fc4d..fdcd585572 100644 --- a/audio/drivers/xenon360_audio.c +++ b/audio/drivers/xenon360_audio.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -70,7 +70,7 @@ static ssize_t xenon360_audio_write(void *data, const void *buf, size_t size) { while (xenon_sound_get_unplayed() >= MAX_BUFFER) { - /* libxenon doesn't have proper + /* libxenon doesn't have proper * synchronization primitives for this... */ udelay(50); } diff --git a/audio/drivers_resampler/cc_resampler.c b/audio/drivers_resampler/cc_resampler.c index b743338f10..5a3f920431 100644 --- a/audio/drivers_resampler/cc_resampler.c +++ b/audio/drivers_resampler/cc_resampler.c @@ -498,12 +498,12 @@ static void *resampler_CC_init(const struct resampler_config *config, rarch_CC_resampler_t *re = (rarch_CC_resampler_t*) memalign_alloc(32, sizeof(rarch_CC_resampler_t)); - /* TODO: lookup if NEON support can be detected at + /* TODO: lookup if NEON support can be detected at * runtime and a funcptr set at runtime for either * C codepath or NEON codepath. This will help out * Android. */ (void)mask; - (void)config; + (void)config; if (!re) return NULL; diff --git a/audio/librsound.c b/audio/librsound.c index 273fc13334..da2aaeaa86 100644 --- a/audio/librsound.c +++ b/audio/librsound.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -16,7 +16,7 @@ /* RSound - A PCM audio client/server * Copyright (C) 2010 - Hans-Kristian Arntzen - * + * * RSound 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -67,7 +67,7 @@ #include #include #include -#include +#include #include #include @@ -75,8 +75,8 @@ #include #include -/* - **************************************************************************** +/* + **************************************************************************** Naming convention. Functions for use in API are called rsd_*(), * internal function are called rsnd_*() * **************************************************************************** @@ -251,7 +251,7 @@ static int rsnd_connect_server( rsound_t *rd ) if ( rd->conn.ctl_socket < 0 ) goto error; - /* Uses non-blocking IO since it performed more deterministic with poll()/send() */ + /* Uses non-blocking IO since it performed more deterministic with poll()/send() */ #ifdef __CELLOS_LV2__ setsockopt(rd->conn.socket, SOL_SOCKET, SO_NBIO, &i, sizeof(int)); @@ -302,7 +302,7 @@ static int rsnd_send_header_info(rsound_t *rd) uint16_t temp16; uint32_t temp32; - /* These magic numbers represent the position of the elements in the wave header. + /* These magic numbers represent the position of the elements in the wave header. We can't simply send a wave struct over the network since the compiler is allowed to pad our structs as they like, so sizeof(waveheader) might not be similar on two different systems. */ @@ -353,7 +353,7 @@ static int rsnd_send_header_info(rsound_t *rd) } /* Since the values in the wave header we are interested in, are little endian (>_<), we need - to determine whether we're running it or not, so we can byte swap accordingly. + to determine whether we're running it or not, so we can byte swap accordingly. Could determine this compile time, but it was simpler to do it this way. */ // Fancy macros for embedding little endian values into the header. @@ -501,7 +501,7 @@ static int rsnd_get_backend_info ( rsound_t *rd ) // Can we read the last 8 bytes so we can use the protocol interface? // This is non-blocking. if ( rsnd_recv_chunk(rd->conn.socket, rsnd_header, RSND_HEADER_SIZE, 0) == RSND_HEADER_SIZE ) - rd->conn_type |= RSD_CONN_PROTO; + rd->conn_type |= RSD_CONN_PROTO; else { RSD_DEBUG("[RSound] Failed to get new proto.\n"); } @@ -515,7 +515,7 @@ static int rsnd_get_backend_info ( rsound_t *rd ) return 0; } -/* Makes sure that we're connected and done with wave header handshaking. Returns -1 on error, and 0 on success. +/* Makes sure that we're connected and done with wave header handshaking. Returns -1 on error, and 0 on success. This goes for all other functions in use. */ static int rsnd_create_connection(rsound_t *rd) { @@ -750,7 +750,7 @@ static int64_t rsnd_get_time_usec(void) /* Calculates how many bytes there are in total in the virtual buffer. This is calculated client side. It should be accurate enough unless we have big problems with buffer underruns. - This function is called by rsd_delay() to determine the latency. + This function is called by rsd_delay() to determine the latency. This function might be changed in the future to correctly determine latency from server. */ static void rsnd_drain(rsound_t *rd) { @@ -777,7 +777,7 @@ static void rsnd_drain(rsound_t *rd) } /* Tries to fill the buffer. Uses signals to determine when the buffer is ready to be filled. Should the thread not be active - it will treat this as an error. Crude implementation of a blocking FIFO. */ + it will treat this as an error. Crude implementation of a blocking FIFO. */ static size_t rsnd_fill_buffer(rsound_t *rd, const char *buf, size_t size) { @@ -851,7 +851,7 @@ static int rsnd_stop_thread(rsound_t *rd) sthread_join(rd->thread.thread); RSD_DEBUG("[RSound] Thread joined successfully.\n"); - + return 0; } else @@ -981,7 +981,7 @@ static int rsnd_close_ctl(rsound_t *rd) } -// Sends delay info request to server on the ctl socket. This code section isn't critical, and will work if it works. +// Sends delay info request to server on the ctl socket. This code section isn't critical, and will work if it works. // It will never block. static int rsnd_send_info_query(rsound_t *rd) { @@ -1111,7 +1111,7 @@ static void rsnd_thread ( void * thread_data ) // We only bother to check after 1 sec of audio has been played, as it might be quite inaccurate in the start of the stream. if ( (rd->conn_type & RSD_CONN_PROTO) && (rd->total_written > rd->channels * rd->rate * rd->samplesize) ) { - rsnd_send_info_query(rd); + rsnd_send_info_query(rd); rsnd_update_server_info(rd); } @@ -1263,7 +1263,7 @@ static void rsnd_cb_thread(void *thread_data) if ( (rd->conn_type & RSD_CONN_PROTO) && (rd->total_written > rd->channels * rd->rate * rd->samplesize) ) { - rsnd_send_info_query(rd); + rsnd_send_info_query(rd); rsnd_update_server_info(rd); } @@ -1304,7 +1304,7 @@ int rsd_stop(rsound_t *rd) const char buf[] = "RSD 5 STOP"; - // Do not really care about errors here. + // Do not really care about errors here. // The socket will be closed down in any case in rsnd_reset(). rsnd_send_chunk(rd->conn.ctl_socket, buf, strlen(buf), 0); @@ -1325,7 +1325,7 @@ size_t rsd_write( rsound_t *rsound, const void* buf, size_t size) while ( written < size ) { - size_t write_size = (size - written) > max_write ? max_write : (size - written); + size_t write_size = (size - written) > max_write ? max_write : (size - written); size_t result = rsnd_fill_buffer(rsound, (const char*)buf + written, write_size); if (result == 0) @@ -1454,7 +1454,7 @@ int rsd_set_param(rsound_t *rd, enum rsd_settings option, void* param) rd->max_latency = *((int*)param); break; - // Checks if format is valid. + // Checks if format is valid. case RSD_FORMAT: rd->format = (uint16_t)(*((int*)param)); rd->samplesize = rsnd_format_to_samplesize(rd->format); @@ -1509,7 +1509,7 @@ size_t rsd_pointer(rsound_t *rsound) retro_assert(rsound != NULL); int ptr; - ptr = rsnd_get_ptr(rsound); + ptr = rsnd_get_ptr(rsound); return ptr; } diff --git a/autosave.h b/autosave.h index 39cfe8a7a1..1421d60436 100644 --- a/autosave.h +++ b/autosave.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2016 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/bootstrap/psp1/kernel_functions_prx/main.c b/bootstrap/psp1/kernel_functions_prx/main.c index 335b156097..08ae0bf0ba 100644 --- a/bootstrap/psp1/kernel_functions_prx/main.c +++ b/bootstrap/psp1/kernel_functions_prx/main.c @@ -66,7 +66,7 @@ int module_start(SceSize args, void *argp) (void)argp; buttons = 0; - thread_active = 0; + thread_active = 0; main_thread_id = sceKernelCreateThread("main Thread", main_thread, 0x11, 0x200, 0, NULL); if (main_thread >= 0) diff --git a/bootstrap/vita/threading.c b/bootstrap/vita/threading.c index cceca6b30a..8b0d10aa2a 100644 --- a/bootstrap/vita/threading.c +++ b/bootstrap/vita/threading.c @@ -34,7 +34,7 @@ int __vita_delete_thread_reent(int thid) // We only need to cleanup if reent is allocated, i.e. if it's on our TLS // We also don't need to clean up the global reent struct _reent **on_tls = NULL; - + if (thid == 0) on_tls = TLS_REENT_PTR; else @@ -141,16 +141,16 @@ struct _reent *__getreent_for_thread(int thid) { // A pointer to our reent should be on the TLS struct _reent **on_tls = NULL; - + if (thid == 0) on_tls = TLS_REENT_PTR; else - on_tls = TLS_REENT_THID_PTR(thid); - + on_tls = TLS_REENT_THID_PTR(thid); + if (*on_tls) { return *on_tls; } - + sceKernelLockMutex(_newlib_reent_mutex, 1, 0); // If it's not on the TLS this means the thread doesn't have a reent allocated yet diff --git a/camera/camera_driver.c b/camera/camera_driver.c index 34a5a31d88..0ee9a7f878 100644 --- a/camera/camera_driver.c +++ b/camera/camera_driver.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -139,7 +139,7 @@ bool camera_driver_ctl(enum rarch_camera_ctl_state state, void *data) case RARCH_CAMERA_CTL_OWNS_DRIVER: return camera_driver_data_own; case RARCH_CAMERA_CTL_SET_ACTIVE: - camera_driver_active = true; + camera_driver_active = true; break; case RARCH_CAMERA_CTL_FIND_DRIVER: { @@ -174,10 +174,10 @@ bool camera_driver_ctl(enum rarch_camera_ctl_state state, void *data) } break; case RARCH_CAMERA_CTL_UNSET_ACTIVE: - camera_driver_active = false; + camera_driver_active = false; break; case RARCH_CAMERA_CTL_IS_ACTIVE: - return camera_driver_active; + return camera_driver_active; case RARCH_CAMERA_CTL_DEINIT: if (camera_data && camera_driver) { @@ -191,8 +191,8 @@ bool camera_driver_ctl(enum rarch_camera_ctl_state state, void *data) camera_data = NULL; break; case RARCH_CAMERA_CTL_STOP: - if ( camera_driver - && camera_driver->stop + if ( camera_driver + && camera_driver->stop && camera_data) camera_driver->stop(camera_data); break; @@ -243,6 +243,6 @@ bool camera_driver_ctl(enum rarch_camera_ctl_state state, void *data) default: break; } - + return true; } diff --git a/camera/camera_driver.h b/camera/camera_driver.h index a916165689..25bbc71d38 100644 --- a/camera/camera_driver.h +++ b/camera/camera_driver.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/camera/drivers/android.c b/camera/drivers/android.c index 2ee7541e33..ab17640155 100644 --- a/camera/drivers/android.c +++ b/camera/drivers/android.c @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis * Copyright (C) 2012-2015 - Michael Lelli - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -152,7 +152,7 @@ static void android_camera_stop(void *data) CALL_VOID_METHOD(env, android_app->activity->clazz, androidcamera->onCameraStop); - + if (androidcamera->tex) video_driver_texture_unload((uintptr_t*)&androidcamera->tex); } @@ -171,12 +171,12 @@ static bool android_camera_poll(void *data, (void)frame_raw_cb; - CALL_BOOLEAN_METHOD(env, newFrame, android_app->activity->clazz, + CALL_BOOLEAN_METHOD(env, newFrame, android_app->activity->clazz, androidcamera->onCameraPoll); if (newFrame) { - /* FIXME: Identity for now. Use proper texture matrix as + /* FIXME: Identity for now. Use proper texture matrix as * returned by Android Camera. */ static const float affine[] = { 1.0f, 0.0f, 0.0f, diff --git a/camera/drivers/nullcamera.c b/camera/drivers/nullcamera.c index bb0cc82c5c..332a671e34 100644 --- a/camera/drivers/nullcamera.c +++ b/camera/drivers/nullcamera.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2012-2015 - Michael Lelli * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/camera/drivers/rwebcam.c b/camera/drivers/rwebcam.c index c630f0f4c1..a7a39cab36 100644 --- a/camera/drivers/rwebcam.c +++ b/camera/drivers/rwebcam.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2012-2015 - Michael Lelli * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/camera/drivers/video4linux2.c b/camera/drivers/video4linux2.c index 2be990821e..1fa94fcfa6 100644 --- a/camera/drivers/video4linux2.c +++ b/camera/drivers/video4linux2.c @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis * Copyright (C) 2012-2015 - Michael Lelli - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/cheevos/badges.c b/cheevos/badges.c index 5ac1112222..b51ae3669f 100644 --- a/cheevos/badges.c +++ b/cheevos/badges.c @@ -1,55 +1,55 @@ -#include -#include -#include - -#include "../file_path_special.h" -#include "../configuration.h" -#include "../verbosity.h" -#include "../network/net_http_special.h" - -#include "badges.h" - -badges_ctx_t badges_ctx; - -bool badge_exists(const char* filepath) -{ - if(path_file_exists(filepath)) - return true; - else - return false; -} - -void set_badge_menu_texture(badges_ctx_t * badges, int i) -{ - char fullpath[PATH_MAX_LENGTH]; - const char * locked_suffix = (badges->badge_locked[i] == true) ? "_lock.png" : ".png"; - - unsigned int bufferSize = 16; - /* TODO/FIXME - variable length forbidden in C89 - rewrite this! */ - char badge_file[bufferSize]; - - snprintf(badge_file, bufferSize, "%s", badges->badge_id_list[i]); - strcat(badge_file, locked_suffix); - - fill_pathname_application_special(fullpath, - PATH_MAX_LENGTH * sizeof(char), - APPLICATION_SPECIAL_DIRECTORY_THUMBNAILS_CHEEVOS_BADGES); - - menu_display_reset_textures_list(badge_file, fullpath, &badges->menu_texture_list[i],TEXTURE_FILTER_MIPMAP_LINEAR); -} - -void set_badge_info (badges_ctx_t *badge_struct, int id, const char *badge_id, bool active) -{ - badge_struct->badge_id_list[id] = badge_id; - badge_struct->badge_locked[id] = active; - set_badge_menu_texture(badge_struct, id); -} - -menu_texture_item get_badge_texture (int id) -{ - settings_t *settings = config_get_ptr(); - if (!settings->bools.cheevos_badges_enable) - return (menu_texture_item)NULL; - - return badges_ctx.menu_texture_list[id]; -} +#include +#include +#include + +#include "../file_path_special.h" +#include "../configuration.h" +#include "../verbosity.h" +#include "../network/net_http_special.h" + +#include "badges.h" + +badges_ctx_t badges_ctx; + +bool badge_exists(const char* filepath) +{ + if(path_file_exists(filepath)) + return true; + else + return false; +} + +void set_badge_menu_texture(badges_ctx_t * badges, int i) +{ + char fullpath[PATH_MAX_LENGTH]; + const char * locked_suffix = (badges->badge_locked[i] == true) ? "_lock.png" : ".png"; + + unsigned int bufferSize = 16; + /* TODO/FIXME - variable length forbidden in C89 - rewrite this! */ + char badge_file[bufferSize]; + + snprintf(badge_file, bufferSize, "%s", badges->badge_id_list[i]); + strcat(badge_file, locked_suffix); + + fill_pathname_application_special(fullpath, + PATH_MAX_LENGTH * sizeof(char), + APPLICATION_SPECIAL_DIRECTORY_THUMBNAILS_CHEEVOS_BADGES); + + menu_display_reset_textures_list(badge_file, fullpath, &badges->menu_texture_list[i],TEXTURE_FILTER_MIPMAP_LINEAR); +} + +void set_badge_info (badges_ctx_t *badge_struct, int id, const char *badge_id, bool active) +{ + badge_struct->badge_id_list[id] = badge_id; + badge_struct->badge_locked[id] = active; + set_badge_menu_texture(badge_struct, id); +} + +menu_texture_item get_badge_texture (int id) +{ + settings_t *settings = config_get_ptr(); + if (!settings->bools.cheevos_badges_enable) + return (menu_texture_item)NULL; + + return badges_ctx.menu_texture_list[id]; +} diff --git a/cheevos/badges.h b/cheevos/badges.h index 57a8de6ed2..05fe875a2a 100644 --- a/cheevos/badges.h +++ b/cheevos/badges.h @@ -1,29 +1,29 @@ -#ifndef __RARCH_BADGE_H -#define __RARCH_BADGE_H - -#include "../menu/menu_driver.h" - -#include - -RETRO_BEGIN_DECLS - -#define CHEEVOS_BADGE_LIMIT 256 - -typedef struct -{ - bool badge_locked[CHEEVOS_BADGE_LIMIT]; - const char * badge_id_list[CHEEVOS_BADGE_LIMIT]; - menu_texture_item menu_texture_list[CHEEVOS_BADGE_LIMIT]; -} badges_ctx_t; - -bool badge_exists(const char* filepath); -void set_badge_menu_texture(badges_ctx_t * badges, int i); -extern void set_badge_info (badges_ctx_t *badge_struct, int id, const char *badge_id, bool active); -extern menu_texture_item get_badge_texture(int id); - -extern badges_ctx_t badges_ctx; -static badges_ctx_t new_badges_ctx; - -RETRO_END_DECLS - -#endif +#ifndef __RARCH_BADGE_H +#define __RARCH_BADGE_H + +#include "../menu/menu_driver.h" + +#include + +RETRO_BEGIN_DECLS + +#define CHEEVOS_BADGE_LIMIT 256 + +typedef struct +{ + bool badge_locked[CHEEVOS_BADGE_LIMIT]; + const char * badge_id_list[CHEEVOS_BADGE_LIMIT]; + menu_texture_item menu_texture_list[CHEEVOS_BADGE_LIMIT]; +} badges_ctx_t; + +bool badge_exists(const char* filepath); +void set_badge_menu_texture(badges_ctx_t * badges, int i); +extern void set_badge_info (badges_ctx_t *badge_struct, int id, const char *badge_id, bool active); +extern menu_texture_item get_badge_texture(int id); + +extern badges_ctx_t badges_ctx; +static badges_ctx_t new_badges_ctx; + +RETRO_END_DECLS + +#endif diff --git a/cheevos/cheevos.c b/cheevos/cheevos.c index 5d1c7515ac..827cd2290a 100644 --- a/cheevos/cheevos.c +++ b/cheevos/cheevos.c @@ -3163,7 +3163,7 @@ static int cheevos_iterate(coro_t* coro) { settings_t *settings = config_get_ptr(); - if (!string_is_equal(settings->arrays.menu_driver, "xmb") || + if (!string_is_equal(settings->arrays.menu_driver, "xmb") || !settings->bools.cheevos_badges_enable) CORO_RET(); } @@ -3182,7 +3182,7 @@ static int cheevos_iterate(coro_t* coro) if (!path_is_directory(CHEEVOS_VAR_BADGE_BASE_PATH)) path_mkdir(CHEEVOS_VAR_BADGE_BASE_PATH); CORO_YIELD(); - if (CHEEVOS_VAR_J == 0) + if (CHEEVOS_VAR_J == 0) snprintf(CHEEVOS_VAR_BADGE_NAME, sizeof(CHEEVOS_VAR_BADGE_NAME), "%s.png", CHEEVOS_VAR_CHEEVO_CURR->badge); else snprintf(CHEEVOS_VAR_BADGE_NAME, sizeof(CHEEVOS_VAR_BADGE_NAME), "%s_lock.png", CHEEVOS_VAR_CHEEVO_CURR->badge); diff --git a/cheevos/var.c b/cheevos/var.c index 45ae9ac866..e0e6d5c6d8 100644 --- a/cheevos/var.c +++ b/cheevos/var.c @@ -256,7 +256,7 @@ void cheevos_var_patch_addr(cheevos_var_t* var, cheevos_console_t console) else { unsigned i; - + for (i = 0; i < 4; i++) { retro_ctx_memory_info_t meminfo; @@ -352,7 +352,7 @@ unsigned cheevos_var_get_value(cheevos_var_t* var) case CHEEVOS_VAR_TYPE_VALUE_COMP: value = var->value; break; - + case CHEEVOS_VAR_TYPE_ADDRESS: case CHEEVOS_VAR_TYPE_DELTA_MEM: memory = cheevos_var_get_memory(var); diff --git a/command.c b/command.c index 67fa8014c5..7b01a2b0d9 100644 --- a/command.c +++ b/command.c @@ -610,7 +610,7 @@ static void command_stdin_poll(command_t *handle) handle->stdin_buf_ptr += ret; handle->stdin_buf[handle->stdin_buf_ptr] = '\0'; - last_newline = + last_newline = strrchr(handle->stdin_buf, '\n'); if (!last_newline) @@ -1028,7 +1028,7 @@ static void command_event_init_controllers(void) break; case RETRO_DEVICE_JOYPAD: /* Ideally these checks shouldn't be required but if we always - * call core_set_controller_port_device input won't work on + * call core_set_controller_port_device input won't work on * cores that don't set port information properly */ if (info && info->ports.size != 0 && i < info->ports.size) set_controller = true; @@ -1126,7 +1126,7 @@ static void command_event_load_auto_state(void) msg_hash_to_str(MSG_AUTOLOADING_SAVESTATE_FROM), savestate_name_auto, ret ? "succeeded" : "failed"); RARCH_LOG("%s\n", msg); - + free(savestate_name_auto); return; @@ -1338,7 +1338,7 @@ static bool command_event_save_auto_state(void) bool is_inited = false; char *savestate_name_auto = (char*) calloc(PATH_MAX_LENGTH, sizeof(*savestate_name_auto)); - size_t + size_t savestate_name_auto_size = PATH_MAX_LENGTH * sizeof(char); settings_t *settings = config_get_ptr(); global_t *global = global_get_ptr(); @@ -1383,7 +1383,7 @@ static bool command_event_save_config( char *s, size_t len) { bool path_exists = !string_is_empty(config_path); - const char *str = path_exists ? config_path : + const char *str = path_exists ? config_path : path_get(RARCH_PATH_CONFIG); if (path_exists && config_save_file(config_path)) @@ -1713,7 +1713,7 @@ void command_playlist_push_write( if (!playlist) return; - + if (playlist_push( playlist, path, diff --git a/command.h b/command.h index 286383fc83..858fcd820f 100644 --- a/command.h +++ b/command.h @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2016 - Daniel De Matteis * Copyright (C) 2016 - Brad Parker - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/configuration.h b/configuration.h index c94b215209..881e94afee 100644 --- a/configuration.h +++ b/configuration.h @@ -38,7 +38,7 @@ { \ settings->modified = true; \ var = newvar; \ -} +} #define configuration_set_uint(settings, var, newvar) \ { \ diff --git a/core.h b/core.h index 08ec2e1f08..35878206b4 100644 --- a/core.h +++ b/core.h @@ -30,14 +30,14 @@ RETRO_BEGIN_DECLS enum { - /* Polling is performed before + /* Polling is performed before * call to retro_run. */ POLL_TYPE_EARLY = 0, /* Polling is performed when requested. */ POLL_TYPE_NORMAL, - /* Polling is performed on first call to + /* Polling is performed on first call to * retro_input_state per frame. */ POLL_TYPE_LATE }; @@ -65,7 +65,7 @@ typedef struct rarch_system_info const char *input_desc_btn[MAX_USERS][RARCH_FIRST_META_KEY]; char valid_extensions[255]; - struct retro_disk_control_callback disk_control_cb; + struct retro_disk_control_callback disk_control_cb; struct retro_location_callback location_cb; struct @@ -79,7 +79,7 @@ typedef struct rarch_system_info struct retro_controller_info *data; unsigned size; } ports; - + rarch_memory_map_t mmaps; } rarch_system_info_t; diff --git a/core_info.c b/core_info.c index c2989d883b..2194e29648 100644 --- a/core_info.c +++ b/core_info.c @@ -214,7 +214,7 @@ static bool core_info_list_iterate( fill_pathname_join(s, (!string_is_empty(settings->paths.path_libretro_info)) ? - settings->paths.path_libretro_info : + settings->paths.path_libretro_info : settings->paths.directory_libretro, info_path_base, len); @@ -255,9 +255,9 @@ static core_info_list_t *core_info_list_new(const char *path) info_path[0] = '\0'; - if ( + if ( core_info_list_iterate(info_path, info_path_size, - contents, i) + contents, i) && path_is_valid(info_path)) { char *tmp = NULL; @@ -270,14 +270,14 @@ static core_info_list_t *core_info_list_new(const char *path) if (!conf) continue; - if (config_get_string(conf, "display_name", &tmp) + if (config_get_string(conf, "display_name", &tmp) && !string_is_empty(tmp)) { core_info[i].display_name = strdup(tmp); free(tmp); tmp = NULL; } - if (config_get_string(conf, "corename", &tmp) + if (config_get_string(conf, "corename", &tmp) && !string_is_empty(tmp)) { core_info[i].core_name = strdup(tmp); @@ -285,7 +285,7 @@ static core_info_list_t *core_info_list_new(const char *path) tmp = NULL; } - if (config_get_string(conf, "systemname", &tmp) + if (config_get_string(conf, "systemname", &tmp) && !string_is_empty(tmp)) { core_info[i].systemname = strdup(tmp); @@ -293,7 +293,7 @@ static core_info_list_t *core_info_list_new(const char *path) tmp = NULL; } - if (config_get_string(conf, "manufacturer", &tmp) + if (config_get_string(conf, "manufacturer", &tmp) && !string_is_empty(tmp)) { core_info[i].system_manufacturer = strdup(tmp); @@ -305,7 +305,7 @@ static core_info_list_t *core_info_list_new(const char *path) core_info[i].firmware_count = count; - if (config_get_string(conf, "supported_extensions", &tmp) + if (config_get_string(conf, "supported_extensions", &tmp) && !string_is_empty(tmp)) { core_info[i].supported_extensions = strdup(tmp); @@ -316,7 +316,7 @@ static core_info_list_t *core_info_list_new(const char *path) tmp = NULL; } - if (config_get_string(conf, "authors", &tmp) + if (config_get_string(conf, "authors", &tmp) && !string_is_empty(tmp)) { core_info[i].authors = strdup(tmp); @@ -327,7 +327,7 @@ static core_info_list_t *core_info_list_new(const char *path) tmp = NULL; } - if (config_get_string(conf, "permissions", &tmp) + if (config_get_string(conf, "permissions", &tmp) && !string_is_empty(tmp)) { core_info[i].permissions = strdup(tmp); @@ -338,7 +338,7 @@ static core_info_list_t *core_info_list_new(const char *path) tmp = NULL; } - if (config_get_string(conf, "license", &tmp) + if (config_get_string(conf, "license", &tmp) && !string_is_empty(tmp)) { core_info[i].licenses = strdup(tmp); @@ -349,7 +349,7 @@ static core_info_list_t *core_info_list_new(const char *path) tmp = NULL; } - if (config_get_string(conf, "categories", &tmp) + if (config_get_string(conf, "categories", &tmp) && !string_is_empty(tmp)) { core_info[i].categories = strdup(tmp); @@ -360,7 +360,7 @@ static core_info_list_t *core_info_list_new(const char *path) tmp = NULL; } - if (config_get_string(conf, "database", &tmp) + if (config_get_string(conf, "database", &tmp) && !string_is_empty(tmp)) { core_info[i].databases = strdup(tmp); @@ -371,7 +371,7 @@ static core_info_list_t *core_info_list_new(const char *path) tmp = NULL; } - if (config_get_string(conf, "notes", &tmp) + if (config_get_string(conf, "notes", &tmp) && !string_is_empty(tmp)) { core_info[i].notes = strdup(tmp); diff --git a/core_info.h b/core_info.h index a151091673..c058e8d937 100644 --- a/core_info.h +++ b/core_info.h @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis * Copyright (C) 2016-2017 - Brad Parker - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/core_type.h b/core_type.h index 532b4e4fa6..e4a66058e5 100644 --- a/core_type.h +++ b/core_type.h @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -16,7 +16,7 @@ #ifndef __CORE_TYPE_H #define __CORE_TYPE_H -enum rarch_core_type +enum rarch_core_type { CORE_TYPE_PLAIN = 0, CORE_TYPE_DUMMY, diff --git a/cores/dynamic_dummy.c b/cores/dynamic_dummy.c index e5b3397f48..ad61faff97 100644 --- a/cores/dynamic_dummy.c +++ b/cores/dynamic_dummy.c @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis * Copyright (C) 2012-2015 - Michael Lelli - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/cores/internal_cores.h b/cores/internal_cores.h index 69c698d3f2..aa756ed349 100644 --- a/cores/internal_cores.h +++ b/cores/internal_cores.h @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis * Copyright (C) 2012-2015 - Michael Lelli - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/cores/libretro-ffmpeg/ffmpeg_core.c b/cores/libretro-ffmpeg/ffmpeg_core.c index f6ba5e51dd..1842f59809 100644 --- a/cores/libretro-ffmpeg/ffmpeg_core.c +++ b/cores/libretro-ffmpeg/ffmpeg_core.c @@ -214,7 +214,7 @@ void CORE_PREFIX(retro_init)(void) av_register_all(); #if 0 - /* FIXME: Occasionally crashes inside libavdevice + /* FIXME: Occasionally crashes inside libavdevice * for some odd reason on reentrancy. Likely a libavdevice bug. */ avdevice_register_all(); #endif @@ -548,7 +548,7 @@ void CORE_PREFIX(retro_run)(void) frame_cnt++; - /* Have to decode audio before video + /* Have to decode audio before video * incase there are PTS fuckups due * to seeking. */ if (audio_streams_num > 0) @@ -679,20 +679,20 @@ void CORE_PREFIX(retro_run)(void) if (!temporal_interpolation) mix_factor = 1.0f; - + glBindFramebuffer(GL_FRAMEBUFFER, hw_render.get_current_framebuffer()); glClearColor(0, 0, 0, 1); glClear(GL_COLOR_BUFFER_BIT); glViewport(0, 0, media.width, media.height); glUseProgram(prog); - + glUniform1f(mix_loc, mix_factor); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, frames[1].tex); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, frames[0].tex); - - + + glBindBuffer(GL_ARRAY_BUFFER, vbo); glVertexAttribPointer(vertex_loc, 2, GL_FLOAT, GL_FALSE, 4 * sizeof(GLfloat), (const GLvoid*)(0 * sizeof(GLfloat))); @@ -701,17 +701,17 @@ void CORE_PREFIX(retro_run)(void) glEnableVertexAttribArray(vertex_loc); glEnableVertexAttribArray(tex_loc); glBindBuffer(GL_ARRAY_BUFFER, 0); - + glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); glDisableVertexAttribArray(vertex_loc); glDisableVertexAttribArray(tex_loc); - + glUseProgram(0); glActiveTexture(GL_TEXTURE1); glBindTexture(GL_TEXTURE_2D, 0); glActiveTexture(GL_TEXTURE0); glBindTexture(GL_TEXTURE_2D, 0); - + CORE_PREFIX(video_cb)(RETRO_HW_FRAME_BUFFER_VALID, media.width, media.height, media.width * sizeof(uint32_t)); } @@ -731,10 +731,10 @@ void CORE_PREFIX(retro_run)(void) while (frames) { unsigned to_read = frames; - + /* FFT size we use (1 << 11). Really shouldn't happen, * unless we use a crazy high sample rate. */ - if (to_read > (1 << 11)) + if (to_read > (1 << 11)) to_read = 1 << 11; fft_step_fft(fft, buffer, to_read); @@ -861,7 +861,7 @@ static bool open_codecs(void) break; case AVMEDIA_TYPE_VIDEO: - if ( !vctx + if ( !vctx && !codec_is_image(fctx->streams[i]->codec->codec_id)) { if (!open_codec(&vctx, i)) @@ -872,7 +872,7 @@ static bool open_codecs(void) case AVMEDIA_TYPE_SUBTITLE: #ifdef HAVE_SSA - if ( subtitle_streams_num < MAX_STREAMS + if ( subtitle_streams_num < MAX_STREAMS && codec_id_is_ass(fctx->streams[i]->codec->codec_id)) { int size; @@ -923,7 +923,7 @@ static bool init_media_info(void) { media.width = vctx->width; media.height = vctx->height; - media.aspect = (float)vctx->width * + media.aspect = (float)vctx->width * av_q2d(vctx->sample_aspect_ratio) / vctx->height; } @@ -1149,7 +1149,7 @@ static void render_ass_img(AVFrame *conv_frame, ASS_Image *img) dst_g = (g * src_alpha + dst_g * dst_alpha) >> 8; dst_b = (b * src_alpha + dst_b * dst_alpha) >> 8; - dst[x] = (0xffu << 24) | (dst_r << 16) | + dst[x] = (0xffu << 24) | (dst_r << 16) | (dst_g << 8) | (dst_b << 0); } } @@ -1171,7 +1171,7 @@ static void decode_thread(void *data) struct SwsContext *sws = NULL; (void)data; - + if (video_stream >= 0) sws = sws_getCachedContext(NULL, media.width, media.height, vctx->pix_fmt, @@ -1295,7 +1295,7 @@ static void decode_thread(void *data) int stride; unsigned y; const uint8_t *src = NULL; - + fifo_write(video_decode_fifo, &pts, sizeof(pts)); src = conv_frame->data[0]; stride = conv_frame->linesize[0]; @@ -1377,8 +1377,8 @@ static void context_destroy(void) #include "gl_shaders/ffmpeg.glsl.vert.h" -/* OpenGL ES note about main() - Get format as GL_RGBA/GL_UNSIGNED_BYTE. - * Assume little endian, so we get ARGB -> BGRA byte order, and +/* OpenGL ES note about main() - Get format as GL_RGBA/GL_UNSIGNED_BYTE. + * Assume little endian, so we get ARGB -> BGRA byte order, and * we have to swizzle to .BGR. */ #ifdef HAVE_OPENGLES #include "gl_shaders/ffmpeg_es.glsl.frag.h" @@ -1445,7 +1445,7 @@ static void context_reset(void) #if !defined(HAVE_OPENGLES) glGenBuffers(1, &frames[i].pbo); glBindBuffer(GL_PIXEL_UNPACK_BUFFER, frames[i].pbo); - glBufferData(GL_PIXEL_UNPACK_BUFFER, media.width + glBufferData(GL_PIXEL_UNPACK_BUFFER, media.width * media.height * sizeof(uint32_t), NULL, GL_STREAM_DRAW); glBindBuffer(GL_PIXEL_UNPACK_BUFFER, 0); #endif @@ -1611,7 +1611,7 @@ bool CORE_PREFIX(retro_load_game)(const struct retro_game_info *info) if (video_stream >= 0 || is_fft) { - video_decode_fifo = fifo_new(media.width + video_decode_fifo = fifo_new(media.width * media.height * sizeof(uint32_t) * 32); #if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) diff --git a/cores/libretro-ffmpeg/ffmpeg_fft.c b/cores/libretro-ffmpeg/ffmpeg_fft.c index 32405a0dea..8d8d22ba12 100644 --- a/cores/libretro-ffmpeg/ffmpeg_fft.c +++ b/cores/libretro-ffmpeg/ffmpeg_fft.c @@ -45,7 +45,7 @@ struct Pass GLuint parameter_tex; }; -struct GLFFT +struct GLFFT { GLuint ms_rb_color; GLuint ms_rb_ds; @@ -102,7 +102,7 @@ static GLuint fft_compile_shader(fft_t *fft, GLenum type, const char *source) glShaderSource(shader, 1, (const GLchar**)&source, NULL); glCompileShader(shader); - + glGetShaderiv(shader, GL_COMPILE_STATUS, &status); if (!status) @@ -153,7 +153,7 @@ typedef float stub_matrix4x4[4][4]; static INLINE unsigned log2i(unsigned x) { unsigned res; - + for (res = 0; x; x >>= 1) res++; return res - 1; @@ -297,7 +297,7 @@ static void fft_init(fft_t *fft) glUniform1i(glGetUniformLocation(fft->prog_complex, "sTexture"), 0); glUniform1i(glGetUniformLocation(fft->prog_complex, "sParameterTexture"), 1); glUniform4fv(glGetUniformLocation(fft->prog_complex, "uOffsetScale"), 1, unity); - + glUseProgram(fft->prog_resolve); glUniform1i(glGetUniformLocation(fft->prog_resolve, "sFFT"), 0); glUniform4fv(glGetUniformLocation(fft->prog_resolve, "uOffsetScale"), 1, unity); @@ -478,7 +478,7 @@ static bool fft_context_reset(fft_t *fft, unsigned fft_steps, return true; } -/* GLFFT requires either GLES3 or +/* GLFFT requires either GLES3 or * desktop GL with ES3_compat (supported by MESA on Linux) extension. */ fft_t *fft_new(unsigned fft_steps, rglgen_proc_address_t proc) { @@ -621,14 +621,14 @@ void fft_step_fft(fft_t *fft, const GLshort *audio_buffer, unsigned frames) if (i == fft->steps - 1) { glBindFramebuffer(GL_FRAMEBUFFER, fft->output.fbo); - glUniform1i(glGetUniformLocation(i == 0 + glUniform1i(glGetUniformLocation(i == 0 ? fft->prog_real : fft->prog_complex, "uViewportOffset"), fft->output_ptr); glViewport(0, fft->output_ptr, fft->size, 1); } else { - glUniform1i(glGetUniformLocation(i == 0 + glUniform1i(glGetUniformLocation(i == 0 ? fft->prog_real : fft->prog_complex, "uViewportOffset"), 0); glBindFramebuffer(GL_FRAMEBUFFER, fft->passes[i].target.fbo); glClear(GL_COLOR_BUFFER_BIT); diff --git a/cores/libretro-ffmpeg/gl_shaders/ffmpeg_es.glsl.frag.h b/cores/libretro-ffmpeg/gl_shaders/ffmpeg_es.glsl.frag.h index 49f4289a00..012a5c7ff0 100644 --- a/cores/libretro-ffmpeg/gl_shaders/ffmpeg_es.glsl.frag.h +++ b/cores/libretro-ffmpeg/gl_shaders/ffmpeg_es.glsl.frag.h @@ -7,7 +7,7 @@ static const char *fragment_source = GLSL( uniform float uMix; void main() { - gl_FragColor = vec4(pow(mix(pow(texture2D(sTex0, vTex).bgr, vec3(2.2)), pow(texture2D(sTex1, vTex).bgr, vec3(2.2)), uMix), vec3(1.0 / 2.2)), 1.0); + gl_FragColor = vec4(pow(mix(pow(texture2D(sTex0, vTex).bgr, vec3(2.2)), pow(texture2D(sTex1, vTex).bgr, vec3(2.2)), uMix), vec3(1.0 / 2.2)), 1.0); } ); diff --git a/cores/libretro-ffmpeg/gl_shaders/fft_heightmap.glsl.vert.h b/cores/libretro-ffmpeg/gl_shaders/fft_heightmap.glsl.vert.h index a5ea0adb2e..85fec8f668 100644 --- a/cores/libretro-ffmpeg/gl_shaders/fft_heightmap.glsl.vert.h +++ b/cores/libretro-ffmpeg/gl_shaders/fft_heightmap.glsl.vert.h @@ -21,7 +21,7 @@ static const char *fft_vertex_program_heightmap = GLSL_300( float lod = log2(world_pos.z + 1.0) - 6.0; vec4 heights = textureLod(sHeight, tex_coord, lod); - + float cangle = cos(angle); float sangle = sin(angle); diff --git a/cores/libretro-imageviewer/image_core.c b/cores/libretro-imageviewer/image_core.c index fdc28b9088..2c562b3e5f 100644 --- a/cores/libretro-imageviewer/image_core.c +++ b/cores/libretro-imageviewer/image_core.c @@ -274,7 +274,7 @@ bool IMAGE_CORE_PREFIX(retro_load_game)(const struct retro_game_info *info) dir_list_sort(file_list, false); free(dir); - + if (!IMAGE_CORE_PREFIX(environ_cb)(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt)) { if (IMAGE_CORE_PREFIX(log_cb)) @@ -437,7 +437,7 @@ void IMAGE_CORE_PREFIX(retro_run)(void) { uint32_t pixel = *buf; uint32_t a = pixel >> 24; - + if (a == 255) *buf = (pixel & 0x0000ff00) | ((pixel << 16) & 0x00ff0000) | ((pixel >> 16) & 0x000000ff); else @@ -446,11 +446,11 @@ void IMAGE_CORE_PREFIX(retro_run)(void) uint32_t g = (pixel & 0x00ff00) >> 8; uint32_t b = (pixel & 0xff0000) >> 16; uint32_t bg = ((x & 8) ^ (y & 8)) ? 0x66 : 0x99; - + r = a * r / 255 + (255 - a) * bg / 255; g = a * g / 255 + (255 - a) * bg / 255; b = a * b / 255 + (255 - a) * bg / 255; - + *buf = r << 16 | g << 8 | b; } } diff --git a/cores/libretro-video-processor/video_processor_v4l2.c b/cores/libretro-video-processor/video_processor_v4l2.c index d49d0900aa..d5f0813f19 100644 --- a/cores/libretro-video-processor/video_processor_v4l2.c +++ b/cores/libretro-video-processor/video_processor_v4l2.c @@ -219,7 +219,7 @@ enumerate_audio_devices(char *buf, size_t buflen) name = snd_device_name_get_hint(*n, "NAME"); ioid = snd_device_name_get_hint(*n, "IOID"); if ((ioid == NULL || string_is_equal(ioid, "Input")) && - (!strncmp(name, "hw:", strlen("hw:")) || + (!strncmp(name, "hw:", strlen("hw:")) || !strncmp(name, "default:", strlen("default:")))) { if (ndevs > 0) @@ -368,7 +368,7 @@ static bool open_devices(void) } error = snd_pcm_hw_params_set_format(audio_handle, hw_params, SND_PCM_FORMAT_S16_LE); if (error) - { + { printf("Couldn't set hw param format to SND_PCM_FORMAT_S16_LE: %s\n", snd_strerror(error)); return false; } @@ -460,12 +460,12 @@ RETRO_API void VIDEOPROC_CORE_PREFIX(retro_get_system_av_info)(struct retro_syst cc.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; error = v4l2_ioctl(video_fd, VIDIOC_CROPCAP, &cc); if (error == 0) - info->geometry.aspect_ratio = (double)cc.pixelaspect.denominator + info->geometry.aspect_ratio = (double)cc.pixelaspect.denominator / (double)cc.pixelaspect.numerator; info->geometry.base_width = info->geometry.max_width = video_format.fmt.pix.width; info->geometry.base_height = info->geometry.max_height = video_format.fmt.pix.height; - info->timing.fps = (double)video_standard.frameperiod.denominator / + info->timing.fps = (double)video_standard.frameperiod.denominator / (double)video_standard.frameperiod.numerator; info->timing.sample_rate = AUDIO_SAMPLE_RATE; @@ -655,7 +655,7 @@ RETRO_API bool VIDEOPROC_CORE_PREFIX(retro_load_game)(const struct retro_game_in buf.index = index; buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; buf.memory = V4L2_MEMORY_MMAP; - + error = v4l2_ioctl(video_fd, VIDIOC_QBUF, &buf); if (error != 0) { @@ -664,8 +664,8 @@ RETRO_API bool VIDEOPROC_CORE_PREFIX(retro_load_game)(const struct retro_game_in } } - conv_data = (uint16_t*)calloc(1, - video_format.fmt.pix.width * video_format.fmt.pix.height * 2); + conv_data = (uint16_t*)calloc(1, + video_format.fmt.pix.width * video_format.fmt.pix.height * 2); if (!conv_data) { printf("Cannot allocate conversion buffer\n"); @@ -707,7 +707,7 @@ RETRO_API void VIDEOPROC_CORE_PREFIX(retro_unload_game)(void) for (index = 0; index < video_nbuffers; index++) v4l2_munmap(video_buffer[index].start, video_buffer[index].len); } - + if (conv_data) free(conv_data); conv_data = NULL; diff --git a/defaults.h b/defaults.h index 66940f307e..2373d0bf00 100644 --- a/defaults.h +++ b/defaults.h @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -98,7 +98,7 @@ struct defaults float video_refresh_rate; bool video_threaded_enable; char menu[32]; - } settings; + } settings; #ifndef IS_SALAMANDER playlist_t *content_history; diff --git a/defines/d3d_defines.h b/defines/d3d_defines.h index 2e98aabfee..c4dccb2618 100644 --- a/defines/d3d_defines.h +++ b/defines/d3d_defines.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -65,7 +65,7 @@ #define ID3DSURFACE IDirect3DSurface8 #define D3DCREATE_CTX Direct3DCreate8 -#if !defined(D3DLOCK_NOSYSLOCK) && defined(_XBOX) +#if !defined(D3DLOCK_NOSYSLOCK) && defined(_XBOX) #define D3DLOCK_NOSYSLOCK (0) #endif #define D3DSAMP_ADDRESSU D3DTSS_ADDRESSU diff --git a/defines/gx_defines.h b/defines/gx_defines.h index e472b8231b..c9e7c28e7c 100644 --- a/defines/gx_defines.h +++ b/defines/gx_defines.h @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/defines/ps3_defines.h b/defines/ps3_defines.h index ac8e6f920c..2b4b0b3d75 100644 --- a/defines/ps3_defines.h +++ b/defines/ps3_defines.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/deps/7zip/7z.h b/deps/7zip/7z.h index 4f2ee95d88..84cd56c152 100644 --- a/deps/7zip/7z.h +++ b/deps/7zip/7z.h @@ -1,207 +1,207 @@ -/* 7z.h -- 7z interface -2010-03-11 : Igor Pavlov : Public domain */ - -#ifndef __7Z_H -#define __7Z_H - -#include "7zBuf.h" - -#ifdef __cplusplus -extern "C" { -#endif - -#define k7zStartHeaderSize 0x20 -#define k7zSignatureSize 6 -extern uint8_t k7zSignature[k7zSignatureSize]; -#define k7zMajorVersion 0 - -enum EIdEnum -{ - k7zIdEnd, - k7zIdHeader, - k7zIdArchiveProperties, - k7zIdAdditionalStreamsInfo, - k7zIdMainStreamsInfo, - k7zIdFilesInfo, - k7zIdPackInfo, - k7zIdUnpackInfo, - k7zIdSubStreamsInfo, - k7zIdSize, - k7zIdCRC, - k7zIdFolder, - k7zIdCodersUnpackSize, - k7zIdNumUnpackStream, - k7zIdEmptyStream, - k7zIdEmptyFile, - k7zIdAnti, - k7zIdName, - k7zIdCTime, - k7zIdATime, - k7zIdMTime, - k7zIdWinAttributes, - k7zIdComment, - k7zIdEncodedHeader, - k7zIdStartPos, - k7zIdDummy -}; - -typedef struct -{ - uint32_t NumInStreams; - uint32_t NumOutStreams; - uint64_t MethodID; - CBuf Props; -} CSzCoderInfo; - -void SzCoderInfo_Init(CSzCoderInfo *p); -void SzCoderInfo_Free(CSzCoderInfo *p, ISzAlloc *alloc); - -typedef struct -{ - uint32_t InIndex; - uint32_t OutIndex; -} CSzBindPair; - -typedef struct -{ - CSzCoderInfo *Coders; - CSzBindPair *BindPairs; - uint32_t *PackStreams; - uint64_t *UnpackSizes; - uint32_t NumCoders; - uint32_t NumBindPairs; - uint32_t NumPackStreams; - int UnpackCRCDefined; - uint32_t UnpackCRC; - - uint32_t NumUnpackStreams; -} CSzFolder; - -void SzFolder_Init(CSzFolder *p); -uint64_t SzFolder_GetUnpackSize(CSzFolder *p); -int SzFolder_FindBindPairForInStream(CSzFolder *p, uint32_t inStreamIndex); -uint32_t SzFolder_GetNumOutStreams(CSzFolder *p); -uint64_t SzFolder_GetUnpackSize(CSzFolder *p); - -SRes SzFolder_Decode(const CSzFolder *folder, const uint64_t *packSizes, - ILookInStream *stream, uint64_t startPos, - uint8_t *outBuffer, size_t outSize, ISzAlloc *allocMain); - -typedef struct -{ - uint32_t Low; - uint32_t High; -} CNtfsFileTime; - -typedef struct -{ - CNtfsFileTime MTime; - uint64_t Size; - uint32_t Crc; - uint32_t Attrib; - uint8_t HasStream; - uint8_t IsDir; - uint8_t IsAnti; - uint8_t CrcDefined; - uint8_t MTimeDefined; - uint8_t AttribDefined; -} CSzFileItem; - -void SzFile_Init(CSzFileItem *p); - -typedef struct -{ - uint64_t *PackSizes; - uint8_t *PackCRCsDefined; - uint32_t *PackCRCs; - CSzFolder *Folders; - CSzFileItem *Files; - uint32_t NumPackStreams; - uint32_t NumFolders; - uint32_t NumFiles; -} CSzAr; - -void SzAr_Init(CSzAr *p); -void SzAr_Free(CSzAr *p, ISzAlloc *alloc); - - -/* - SzExtract extracts file from archive - - *outBuffer must be 0 before first call for each new archive. - - Extracting cache: - If you need to decompress more than one file, you can send - these values from previous call: - *blockIndex, - *outBuffer, - *outBufferSize - You can consider "*outBuffer" as cache of solid block. If your archive is solid, - it will increase decompression speed. - - If you use external function, you can declare these 3 cache variables - (blockIndex, outBuffer, outBufferSize) as static in that external function. - - Free *outBuffer and set *outBuffer to 0, if you want to flush cache. -*/ - -typedef struct -{ - CSzAr db; - - uint64_t startPosAfterHeader; - uint64_t dataPos; - - uint32_t *FolderStartPackStreamIndex; - uint64_t *PackStreamStartPositions; - uint32_t *FolderStartFileIndex; - uint32_t *FileIndexToFolderIndexMap; - - size_t *FileNameOffsets; /* in 2-byte steps */ - CBuf FileNames; /* UTF-16-LE */ -} CSzArEx; - -void SzArEx_Init(CSzArEx *p); -void SzArEx_Free(CSzArEx *p, ISzAlloc *alloc); -uint64_t SzArEx_GetFolderStreamPos(const CSzArEx *p, uint32_t folderIndex, uint32_t indexInFolder); -int SzArEx_GetFolderFullPackSize(const CSzArEx *p, uint32_t folderIndex, uint64_t *resSize); - -/* -if dest == NULL, the return value specifies the required size of the buffer, - in 16-bit characters, including the null-terminating character. -if dest != NULL, the return value specifies the number of 16-bit characters that - are written to the dest, including the null-terminating character. */ - -size_t SzArEx_GetFileNameUtf16(const CSzArEx *p, size_t fileIndex, uint16_t *dest); - -SRes SzArEx_Extract( - const CSzArEx *db, - ILookInStream *inStream, - uint32_t fileIndex, /* index of file */ - uint32_t *blockIndex, /* index of solid block */ - uint8_t **outBuffer, /* pointer to pointer to output buffer (allocated with allocMain) */ - size_t *outBufferSize, /* buffer size for output buffer */ - size_t *offset, /* offset of stream for required file in *outBuffer */ - size_t *outSizeProcessed, /* size of file in *outBuffer */ - ISzAlloc *allocMain, - ISzAlloc *allocTemp); - - -/* -SzArEx_Open Errors: -SZ_ERROR_NO_ARCHIVE -SZ_ERROR_ARCHIVE -SZ_ERROR_UNSUPPORTED -SZ_ERROR_MEM -SZ_ERROR_CRC -SZ_ERROR_INPUT_EOF -SZ_ERROR_FAIL -*/ - -SRes SzArEx_Open(CSzArEx *p, ILookInStream *inStream, ISzAlloc *allocMain, ISzAlloc *allocTemp); - -#ifdef __cplusplus -} -#endif - -#endif +/* 7z.h -- 7z interface +2010-03-11 : Igor Pavlov : Public domain */ + +#ifndef __7Z_H +#define __7Z_H + +#include "7zBuf.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#define k7zStartHeaderSize 0x20 +#define k7zSignatureSize 6 +extern uint8_t k7zSignature[k7zSignatureSize]; +#define k7zMajorVersion 0 + +enum EIdEnum +{ + k7zIdEnd, + k7zIdHeader, + k7zIdArchiveProperties, + k7zIdAdditionalStreamsInfo, + k7zIdMainStreamsInfo, + k7zIdFilesInfo, + k7zIdPackInfo, + k7zIdUnpackInfo, + k7zIdSubStreamsInfo, + k7zIdSize, + k7zIdCRC, + k7zIdFolder, + k7zIdCodersUnpackSize, + k7zIdNumUnpackStream, + k7zIdEmptyStream, + k7zIdEmptyFile, + k7zIdAnti, + k7zIdName, + k7zIdCTime, + k7zIdATime, + k7zIdMTime, + k7zIdWinAttributes, + k7zIdComment, + k7zIdEncodedHeader, + k7zIdStartPos, + k7zIdDummy +}; + +typedef struct +{ + uint32_t NumInStreams; + uint32_t NumOutStreams; + uint64_t MethodID; + CBuf Props; +} CSzCoderInfo; + +void SzCoderInfo_Init(CSzCoderInfo *p); +void SzCoderInfo_Free(CSzCoderInfo *p, ISzAlloc *alloc); + +typedef struct +{ + uint32_t InIndex; + uint32_t OutIndex; +} CSzBindPair; + +typedef struct +{ + CSzCoderInfo *Coders; + CSzBindPair *BindPairs; + uint32_t *PackStreams; + uint64_t *UnpackSizes; + uint32_t NumCoders; + uint32_t NumBindPairs; + uint32_t NumPackStreams; + int UnpackCRCDefined; + uint32_t UnpackCRC; + + uint32_t NumUnpackStreams; +} CSzFolder; + +void SzFolder_Init(CSzFolder *p); +uint64_t SzFolder_GetUnpackSize(CSzFolder *p); +int SzFolder_FindBindPairForInStream(CSzFolder *p, uint32_t inStreamIndex); +uint32_t SzFolder_GetNumOutStreams(CSzFolder *p); +uint64_t SzFolder_GetUnpackSize(CSzFolder *p); + +SRes SzFolder_Decode(const CSzFolder *folder, const uint64_t *packSizes, + ILookInStream *stream, uint64_t startPos, + uint8_t *outBuffer, size_t outSize, ISzAlloc *allocMain); + +typedef struct +{ + uint32_t Low; + uint32_t High; +} CNtfsFileTime; + +typedef struct +{ + CNtfsFileTime MTime; + uint64_t Size; + uint32_t Crc; + uint32_t Attrib; + uint8_t HasStream; + uint8_t IsDir; + uint8_t IsAnti; + uint8_t CrcDefined; + uint8_t MTimeDefined; + uint8_t AttribDefined; +} CSzFileItem; + +void SzFile_Init(CSzFileItem *p); + +typedef struct +{ + uint64_t *PackSizes; + uint8_t *PackCRCsDefined; + uint32_t *PackCRCs; + CSzFolder *Folders; + CSzFileItem *Files; + uint32_t NumPackStreams; + uint32_t NumFolders; + uint32_t NumFiles; +} CSzAr; + +void SzAr_Init(CSzAr *p); +void SzAr_Free(CSzAr *p, ISzAlloc *alloc); + + +/* + SzExtract extracts file from archive + + *outBuffer must be 0 before first call for each new archive. + + Extracting cache: + If you need to decompress more than one file, you can send + these values from previous call: + *blockIndex, + *outBuffer, + *outBufferSize + You can consider "*outBuffer" as cache of solid block. If your archive is solid, + it will increase decompression speed. + + If you use external function, you can declare these 3 cache variables + (blockIndex, outBuffer, outBufferSize) as static in that external function. + + Free *outBuffer and set *outBuffer to 0, if you want to flush cache. +*/ + +typedef struct +{ + CSzAr db; + + uint64_t startPosAfterHeader; + uint64_t dataPos; + + uint32_t *FolderStartPackStreamIndex; + uint64_t *PackStreamStartPositions; + uint32_t *FolderStartFileIndex; + uint32_t *FileIndexToFolderIndexMap; + + size_t *FileNameOffsets; /* in 2-byte steps */ + CBuf FileNames; /* UTF-16-LE */ +} CSzArEx; + +void SzArEx_Init(CSzArEx *p); +void SzArEx_Free(CSzArEx *p, ISzAlloc *alloc); +uint64_t SzArEx_GetFolderStreamPos(const CSzArEx *p, uint32_t folderIndex, uint32_t indexInFolder); +int SzArEx_GetFolderFullPackSize(const CSzArEx *p, uint32_t folderIndex, uint64_t *resSize); + +/* +if dest == NULL, the return value specifies the required size of the buffer, + in 16-bit characters, including the null-terminating character. +if dest != NULL, the return value specifies the number of 16-bit characters that + are written to the dest, including the null-terminating character. */ + +size_t SzArEx_GetFileNameUtf16(const CSzArEx *p, size_t fileIndex, uint16_t *dest); + +SRes SzArEx_Extract( + const CSzArEx *db, + ILookInStream *inStream, + uint32_t fileIndex, /* index of file */ + uint32_t *blockIndex, /* index of solid block */ + uint8_t **outBuffer, /* pointer to pointer to output buffer (allocated with allocMain) */ + size_t *outBufferSize, /* buffer size for output buffer */ + size_t *offset, /* offset of stream for required file in *outBuffer */ + size_t *outSizeProcessed, /* size of file in *outBuffer */ + ISzAlloc *allocMain, + ISzAlloc *allocTemp); + + +/* +SzArEx_Open Errors: +SZ_ERROR_NO_ARCHIVE +SZ_ERROR_ARCHIVE +SZ_ERROR_UNSUPPORTED +SZ_ERROR_MEM +SZ_ERROR_CRC +SZ_ERROR_INPUT_EOF +SZ_ERROR_FAIL +*/ + +SRes SzArEx_Open(CSzArEx *p, ILookInStream *inStream, ISzAlloc *allocMain, ISzAlloc *allocTemp); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/deps/7zip/7zBuf.c b/deps/7zip/7zBuf.c index 3d30bfd270..832a7a9271 100644 --- a/deps/7zip/7zBuf.c +++ b/deps/7zip/7zBuf.c @@ -1,37 +1,37 @@ -/* 7zBuf.c -- Byte Buffer - 2008-03-28 - Igor Pavlov - Public domain */ - -#include -#include "7zBuf.h" - -void Buf_Init(CBuf *p) -{ - p->data = 0; - p->size = 0; -} - -int Buf_Create(CBuf *p, size_t size, ISzAlloc *alloc) -{ - p->size = 0; - if (size == 0) - { - p->data = 0; - return 1; - } - p->data = (uint8_t *)alloc->Alloc(alloc, size); - if (p->data != 0) - { - p->size = size; - return 1; - } - return 0; -} - -void Buf_Free(CBuf *p, ISzAlloc *alloc) -{ - alloc->Free(alloc, p->data); - p->data = 0; - p->size = 0; -} +/* 7zBuf.c -- Byte Buffer + 2008-03-28 + Igor Pavlov + Public domain */ + +#include +#include "7zBuf.h" + +void Buf_Init(CBuf *p) +{ + p->data = 0; + p->size = 0; +} + +int Buf_Create(CBuf *p, size_t size, ISzAlloc *alloc) +{ + p->size = 0; + if (size == 0) + { + p->data = 0; + return 1; + } + p->data = (uint8_t *)alloc->Alloc(alloc, size); + if (p->data != 0) + { + p->size = size; + return 1; + } + return 0; +} + +void Buf_Free(CBuf *p, ISzAlloc *alloc) +{ + alloc->Free(alloc, p->data); + p->data = 0; + p->size = 0; +} diff --git a/deps/7zip/7zBuf.h b/deps/7zip/7zBuf.h index 485ec12610..4ce09cb767 100644 --- a/deps/7zip/7zBuf.h +++ b/deps/7zip/7zBuf.h @@ -1,27 +1,27 @@ -/* 7zBuf.h -- Byte Buffer -2009-02-07 : Igor Pavlov : Public domain */ - -#ifndef __7Z_BUF_H -#define __7Z_BUF_H - -#include "7zTypes.h" - -#ifdef __cplusplus -extern "C" { -#endif - -typedef struct -{ - uint8_t *data; - size_t size; -} CBuf; - -void Buf_Init(CBuf *p); -int Buf_Create(CBuf *p, size_t size, ISzAlloc *alloc); -void Buf_Free(CBuf *p, ISzAlloc *alloc); - -#ifdef __cplusplus -} -#endif - -#endif +/* 7zBuf.h -- Byte Buffer +2009-02-07 : Igor Pavlov : Public domain */ + +#ifndef __7Z_BUF_H +#define __7Z_BUF_H + +#include "7zTypes.h" + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct +{ + uint8_t *data; + size_t size; +} CBuf; + +void Buf_Init(CBuf *p); +int Buf_Create(CBuf *p, size_t size, ISzAlloc *alloc); +void Buf_Free(CBuf *p, ISzAlloc *alloc); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/deps/7zip/7zCrc.c b/deps/7zip/7zCrc.c index 0e95f17a34..02728d23d6 100644 --- a/deps/7zip/7zCrc.c +++ b/deps/7zip/7zCrc.c @@ -1,76 +1,76 @@ -/* 7zCrc.c -- CRC32 calculation - 2009-11-23 : Igor Pavlov : Public domain */ - -#include -#include "7zCrc.h" -#include "CpuArch.h" - -#define kCrcPoly 0xEDB88320 - -#ifdef MSB_FIRST -#define CRC_NUM_TABLES 1 -#else -#define CRC_NUM_TABLES 8 -#endif - -typedef uint32_t (MY_FAST_CALL *CRC_FUNC)(uint32_t v, const void *data, size_t size, const uint32_t *table); - -static CRC_FUNC g_CrcUpdate; -uint32_t g_CrcTable[256 * CRC_NUM_TABLES]; - -#if CRC_NUM_TABLES == 1 - -#define CRC_UPDATE_BYTE_2(crc, b) (table[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8)) - -static uint32_t MY_FAST_CALL CrcUpdateT1(uint32_t v, const void *data, size_t size, const uint32_t *table) -{ - const uint8_t *p = (const uint8_t *)data; - for (; size > 0; size--, p++) - v = CRC_UPDATE_BYTE_2(v, *p); - return v; -} - -#else - -uint32_t MY_FAST_CALL CrcUpdateT4(uint32_t v, const void *data, size_t size, const uint32_t *table); -uint32_t MY_FAST_CALL CrcUpdateT8(uint32_t v, const void *data, size_t size, const uint32_t *table); - -#endif - -uint32_t MY_FAST_CALL CrcUpdate(uint32_t v, const void *data, size_t size) -{ - return g_CrcUpdate(v, data, size, g_CrcTable); -} - -uint32_t MY_FAST_CALL CrcCalc(const void *data, size_t size) -{ - return g_CrcUpdate(CRC_INIT_VAL, data, size, g_CrcTable) ^ CRC_INIT_VAL; -} - -void MY_FAST_CALL CrcGenerateTable(void) -{ - uint32_t i; - for (i = 0; i < 256; i++) - { - uint32_t r = i; - unsigned j; - for (j = 0; j < 8; j++) - r = (r >> 1) ^ (kCrcPoly & ~((r & 1) - 1)); - g_CrcTable[i] = r; - } -#if CRC_NUM_TABLES == 1 - g_CrcUpdate = CrcUpdateT1; -#else - for (; i < 256 * CRC_NUM_TABLES; i++) - { - uint32_t r = g_CrcTable[i - 256]; - g_CrcTable[i] = g_CrcTable[r & 0xFF] ^ (r >> 8); - } - -#ifdef MY_CPU_X86_OR_AMD64 - g_CrcUpdate = CrcUpdateT8; -#else - g_CrcUpdate = CrcUpdateT4; -#endif -#endif -} +/* 7zCrc.c -- CRC32 calculation + 2009-11-23 : Igor Pavlov : Public domain */ + +#include +#include "7zCrc.h" +#include "CpuArch.h" + +#define kCrcPoly 0xEDB88320 + +#ifdef MSB_FIRST +#define CRC_NUM_TABLES 1 +#else +#define CRC_NUM_TABLES 8 +#endif + +typedef uint32_t (MY_FAST_CALL *CRC_FUNC)(uint32_t v, const void *data, size_t size, const uint32_t *table); + +static CRC_FUNC g_CrcUpdate; +uint32_t g_CrcTable[256 * CRC_NUM_TABLES]; + +#if CRC_NUM_TABLES == 1 + +#define CRC_UPDATE_BYTE_2(crc, b) (table[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8)) + +static uint32_t MY_FAST_CALL CrcUpdateT1(uint32_t v, const void *data, size_t size, const uint32_t *table) +{ + const uint8_t *p = (const uint8_t *)data; + for (; size > 0; size--, p++) + v = CRC_UPDATE_BYTE_2(v, *p); + return v; +} + +#else + +uint32_t MY_FAST_CALL CrcUpdateT4(uint32_t v, const void *data, size_t size, const uint32_t *table); +uint32_t MY_FAST_CALL CrcUpdateT8(uint32_t v, const void *data, size_t size, const uint32_t *table); + +#endif + +uint32_t MY_FAST_CALL CrcUpdate(uint32_t v, const void *data, size_t size) +{ + return g_CrcUpdate(v, data, size, g_CrcTable); +} + +uint32_t MY_FAST_CALL CrcCalc(const void *data, size_t size) +{ + return g_CrcUpdate(CRC_INIT_VAL, data, size, g_CrcTable) ^ CRC_INIT_VAL; +} + +void MY_FAST_CALL CrcGenerateTable(void) +{ + uint32_t i; + for (i = 0; i < 256; i++) + { + uint32_t r = i; + unsigned j; + for (j = 0; j < 8; j++) + r = (r >> 1) ^ (kCrcPoly & ~((r & 1) - 1)); + g_CrcTable[i] = r; + } +#if CRC_NUM_TABLES == 1 + g_CrcUpdate = CrcUpdateT1; +#else + for (; i < 256 * CRC_NUM_TABLES; i++) + { + uint32_t r = g_CrcTable[i - 256]; + g_CrcTable[i] = g_CrcTable[r & 0xFF] ^ (r >> 8); + } + +#ifdef MY_CPU_X86_OR_AMD64 + g_CrcUpdate = CrcUpdateT8; +#else + g_CrcUpdate = CrcUpdateT4; +#endif +#endif +} diff --git a/deps/7zip/7zCrc.h b/deps/7zip/7zCrc.h index 4b56a1c506..30890b8035 100644 --- a/deps/7zip/7zCrc.h +++ b/deps/7zip/7zCrc.h @@ -1,29 +1,29 @@ -/* 7zCrc.h -- CRC32 calculation - 2009-11-21 : Igor Pavlov : Public domain */ - -#ifndef __7Z_CRC_H -#define __7Z_CRC_H - -#include "7zTypes.h" - -#ifdef __cplusplus -extern "C" { -#endif - -extern uint32_t g_CrcTable[]; - -/* Call CrcGenerateTable one time before other CRC functions */ -void MY_FAST_CALL CrcGenerateTable(void); - -#define CRC_INIT_VAL 0xFFFFFFFF -#define CRC_GET_DIGEST(crc) ((crc) ^ CRC_INIT_VAL) -#define CRC_UPDATE_BYTE(crc, b) (g_CrcTable[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8)) - -uint32_t MY_FAST_CALL CrcUpdate(uint32_t crc, const void *data, size_t size); -uint32_t MY_FAST_CALL CrcCalc(const void *data, size_t size); - -#ifdef __cplusplus -} -#endif - -#endif +/* 7zCrc.h -- CRC32 calculation + 2009-11-21 : Igor Pavlov : Public domain */ + +#ifndef __7Z_CRC_H +#define __7Z_CRC_H + +#include "7zTypes.h" + +#ifdef __cplusplus +extern "C" { +#endif + +extern uint32_t g_CrcTable[]; + +/* Call CrcGenerateTable one time before other CRC functions */ +void MY_FAST_CALL CrcGenerateTable(void); + +#define CRC_INIT_VAL 0xFFFFFFFF +#define CRC_GET_DIGEST(crc) ((crc) ^ CRC_INIT_VAL) +#define CRC_UPDATE_BYTE(crc, b) (g_CrcTable[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8)) + +uint32_t MY_FAST_CALL CrcUpdate(uint32_t crc, const void *data, size_t size); +uint32_t MY_FAST_CALL CrcCalc(const void *data, size_t size); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/deps/7zip/7zCrcOpt.c b/deps/7zip/7zCrcOpt.c index d2f18b372b..22bd4b1196 100644 --- a/deps/7zip/7zCrcOpt.c +++ b/deps/7zip/7zCrcOpt.c @@ -1,38 +1,38 @@ -/* 7zCrcOpt.c -- CRC32 calculation : optimized version - 2009-11-23 : Igor Pavlov : Public domain */ - -#include -#include "CpuArch.h" - -#ifndef MSB_FIRST - -#define CRC_UPDATE_BYTE_2(crc, b) (table[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8)) - -uint32_t MY_FAST_CALL CrcUpdateT4(uint32_t v, const void *data, size_t size, const uint32_t *table); -uint32_t MY_FAST_CALL CrcUpdateT8(uint32_t v, const void *data, size_t size, const uint32_t *table); - -uint32_t MY_FAST_CALL CrcUpdateT4(uint32_t v, const void *data, size_t size, const uint32_t *table) -{ - const uint8_t *p = (const uint8_t*)data; - for (; size > 0 && ((unsigned)(ptrdiff_t)p & 3) != 0; size--, p++) - v = CRC_UPDATE_BYTE_2(v, *p); - for (; size >= 4; size -= 4, p += 4) - { - v ^= *(const uint32_t *)p; - v = - table[0x300 + (v & 0xFF)] ^ - table[0x200 + ((v >> 8) & 0xFF)] ^ - table[0x100 + ((v >> 16) & 0xFF)] ^ - table[0x000 + ((v >> 24))]; - } - for (; size > 0; size--, p++) - v = CRC_UPDATE_BYTE_2(v, *p); - return v; -} - -uint32_t MY_FAST_CALL CrcUpdateT8(uint32_t v, const void *data, size_t size, const uint32_t *table) -{ - return CrcUpdateT4(v, data, size, table); -} - -#endif +/* 7zCrcOpt.c -- CRC32 calculation : optimized version + 2009-11-23 : Igor Pavlov : Public domain */ + +#include +#include "CpuArch.h" + +#ifndef MSB_FIRST + +#define CRC_UPDATE_BYTE_2(crc, b) (table[((crc) ^ (b)) & 0xFF] ^ ((crc) >> 8)) + +uint32_t MY_FAST_CALL CrcUpdateT4(uint32_t v, const void *data, size_t size, const uint32_t *table); +uint32_t MY_FAST_CALL CrcUpdateT8(uint32_t v, const void *data, size_t size, const uint32_t *table); + +uint32_t MY_FAST_CALL CrcUpdateT4(uint32_t v, const void *data, size_t size, const uint32_t *table) +{ + const uint8_t *p = (const uint8_t*)data; + for (; size > 0 && ((unsigned)(ptrdiff_t)p & 3) != 0; size--, p++) + v = CRC_UPDATE_BYTE_2(v, *p); + for (; size >= 4; size -= 4, p += 4) + { + v ^= *(const uint32_t *)p; + v = + table[0x300 + (v & 0xFF)] ^ + table[0x200 + ((v >> 8) & 0xFF)] ^ + table[0x100 + ((v >> 16) & 0xFF)] ^ + table[0x000 + ((v >> 24))]; + } + for (; size > 0; size--, p++) + v = CRC_UPDATE_BYTE_2(v, *p); + return v; +} + +uint32_t MY_FAST_CALL CrcUpdateT8(uint32_t v, const void *data, size_t size, const uint32_t *table) +{ + return CrcUpdateT4(v, data, size, table); +} + +#endif diff --git a/deps/7zip/7zDec.c b/deps/7zip/7zDec.c index 34eac2a832..4ed17b2340 100644 --- a/deps/7zip/7zDec.c +++ b/deps/7zip/7zDec.c @@ -1,360 +1,360 @@ -/* 7zDec.c -- Decoding from 7z folder -2010-11-02 : Igor Pavlov : Public domain */ - -#include -#include -#include - -#include "7z.h" - -#include "Bcj2.h" -#include "Bra.h" -#include "CpuArch.h" -#include "LzmaDec.h" -#include "Lzma2Dec.h" - -#define k_Copy 0 -#define k_LZMA2 0x21 -#define k_LZMA 0x30101 -#define k_BCJ 0x03030103 -#define k_PPC 0x03030205 -#define k_ARM 0x03030501 -#define k_ARMT 0x03030701 -#define k_SPARC 0x03030805 -#define k_BCJ2 0x0303011B - -static SRes SzDecodeLzma(CSzCoderInfo *coder, uint64_t inSize, ILookInStream *inStream, - uint8_t *outBuffer, size_t outSize, ISzAlloc *allocMain) -{ - CLzmaDec state; - SRes res = SZ_OK; - - LzmaDec_Construct(&state); - RINOK(LzmaDec_AllocateProbs(&state, coder->Props.data, (unsigned)coder->Props.size, allocMain)); - state.dic = outBuffer; - state.dicBufSize = outSize; - LzmaDec_Init(&state); - - for (;;) - { - uint8_t *inBuf = NULL; - size_t lookahead = (1 << 18); - if (lookahead > inSize) - lookahead = (size_t)inSize; - res = inStream->Look((void *)inStream, (const void **)&inBuf, &lookahead); - if (res != SZ_OK) - break; - - { - size_t inProcessed = (size_t)lookahead, dicPos = state.dicPos; - ELzmaStatus status; - res = LzmaDec_DecodeToDic(&state, outSize, inBuf, &inProcessed, LZMA_FINISH_END, &status); - lookahead -= inProcessed; - inSize -= inProcessed; - if (res != SZ_OK) - break; - if (state.dicPos == state.dicBufSize || (inProcessed == 0 && dicPos == state.dicPos)) - { - if (state.dicBufSize != outSize || lookahead != 0 || - (status != LZMA_STATUS_FINISHED_WITH_MARK && - status != LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK)) - res = SZ_ERROR_DATA; - break; - } - res = inStream->Skip((void *)inStream, inProcessed); - if (res != SZ_OK) - break; - } - } - - LzmaDec_FreeProbs(&state, allocMain); - return res; -} - -static SRes SzDecodeLzma2(CSzCoderInfo *coder, uint64_t inSize, ILookInStream *inStream, - uint8_t *outBuffer, size_t outSize, ISzAlloc *allocMain) -{ - CLzma2Dec state; - SRes res = SZ_OK; - - Lzma2Dec_Construct(&state); - if (coder->Props.size != 1) - return SZ_ERROR_DATA; - RINOK(Lzma2Dec_AllocateProbs(&state, coder->Props.data[0], allocMain)); - state.decoder.dic = outBuffer; - state.decoder.dicBufSize = outSize; - Lzma2Dec_Init(&state); - - for (;;) - { - uint8_t *inBuf = NULL; - size_t lookahead = (1 << 18); - if (lookahead > inSize) - lookahead = (size_t)inSize; - res = inStream->Look((void *)inStream, (const void **)&inBuf, &lookahead); - if (res != SZ_OK) - break; - - { - size_t inProcessed = (size_t)lookahead, dicPos = state.decoder.dicPos; - ELzmaStatus status; - res = Lzma2Dec_DecodeToDic(&state, outSize, inBuf, &inProcessed, LZMA_FINISH_END, &status); - lookahead -= inProcessed; - inSize -= inProcessed; - if (res != SZ_OK) - break; - if (state.decoder.dicPos == state.decoder.dicBufSize || (inProcessed == 0 && dicPos == state.decoder.dicPos)) - { - if (state.decoder.dicBufSize != outSize || lookahead != 0 || - (status != LZMA_STATUS_FINISHED_WITH_MARK)) - res = SZ_ERROR_DATA; - break; - } - res = inStream->Skip((void *)inStream, inProcessed); - if (res != SZ_OK) - break; - } - } - - Lzma2Dec_FreeProbs(&state, allocMain); - return res; -} - -static SRes SzDecodeCopy(uint64_t inSize, ILookInStream *inStream, uint8_t *outBuffer) -{ - while (inSize > 0) - { - void *inBuf; - size_t curSize = (1 << 18); - if (curSize > inSize) - curSize = (size_t)inSize; - RINOK(inStream->Look((void *)inStream, (const void **)&inBuf, &curSize)); - if (curSize == 0) - return SZ_ERROR_INPUT_EOF; - memcpy(outBuffer, inBuf, curSize); - outBuffer += curSize; - inSize -= curSize; - RINOK(inStream->Skip((void *)inStream, curSize)); - } - return SZ_OK; -} - -static bool IS_MAIN_METHOD(uint32_t m) -{ - switch(m) - { - case k_Copy: - case k_LZMA: - case k_LZMA2: - return true; - } - return false; -} - -static bool IS_SUPPORTED_CODER(const CSzCoderInfo *c) -{ - return - c->NumInStreams == 1 && - c->NumOutStreams == 1 && - c->MethodID <= (uint32_t)0xFFFFFFFF && - IS_MAIN_METHOD((uint32_t)c->MethodID); -} - -#define IS_BCJ2(c) ((c)->MethodID == k_BCJ2 && (c)->NumInStreams == 4 && (c)->NumOutStreams == 1) - -static SRes CheckSupportedFolder(const CSzFolder *f) -{ - if (f->NumCoders < 1 || f->NumCoders > 4) - return SZ_ERROR_UNSUPPORTED; - if (!IS_SUPPORTED_CODER(&f->Coders[0])) - return SZ_ERROR_UNSUPPORTED; - if (f->NumCoders == 1) - { - if (f->NumPackStreams != 1 || f->PackStreams[0] != 0 || f->NumBindPairs != 0) - return SZ_ERROR_UNSUPPORTED; - return SZ_OK; - } - if (f->NumCoders == 2) - { - CSzCoderInfo *c = &f->Coders[1]; - if (c->MethodID > (uint32_t)0xFFFFFFFF || - c->NumInStreams != 1 || - c->NumOutStreams != 1 || - f->NumPackStreams != 1 || - f->PackStreams[0] != 0 || - f->NumBindPairs != 1 || - f->BindPairs[0].InIndex != 1 || - f->BindPairs[0].OutIndex != 0) - return SZ_ERROR_UNSUPPORTED; - switch ((uint32_t)c->MethodID) - { - case k_BCJ: - case k_ARM: - break; - default: - return SZ_ERROR_UNSUPPORTED; - } - return SZ_OK; - } - if (f->NumCoders == 4) - { - if (!IS_SUPPORTED_CODER(&f->Coders[1]) || - !IS_SUPPORTED_CODER(&f->Coders[2]) || - !IS_BCJ2(&f->Coders[3])) - return SZ_ERROR_UNSUPPORTED; - if (f->NumPackStreams != 4 || - f->PackStreams[0] != 2 || - f->PackStreams[1] != 6 || - f->PackStreams[2] != 1 || - f->PackStreams[3] != 0 || - f->NumBindPairs != 3 || - f->BindPairs[0].InIndex != 5 || f->BindPairs[0].OutIndex != 0 || - f->BindPairs[1].InIndex != 4 || f->BindPairs[1].OutIndex != 1 || - f->BindPairs[2].InIndex != 3 || f->BindPairs[2].OutIndex != 2) - return SZ_ERROR_UNSUPPORTED; - return SZ_OK; - } - return SZ_ERROR_UNSUPPORTED; -} - -static uint64_t GetSum(const uint64_t *values, uint32_t idx) -{ - uint64_t sum = 0; - uint32_t i; - for (i = 0; i < idx; i++) - sum += values[i]; - return sum; -} - -#define CASE_BRA_CONV(isa) case k_ ## isa: isa ## _Convert(outBuffer, outSize, 0, 0); break; - -static SRes SzFolder_Decode2(const CSzFolder *folder, const uint64_t *packSizes, - ILookInStream *inStream, uint64_t startPos, - uint8_t *outBuffer, size_t outSize, ISzAlloc *allocMain, - uint8_t *tempBuf[]) -{ - uint32_t ci; - size_t tempSizes[3] = { 0, 0, 0}; - size_t tempSize3 = 0; - uint8_t *tempBuf3 = 0; - - RINOK(CheckSupportedFolder(folder)); - - for (ci = 0; ci < folder->NumCoders; ci++) - { - CSzCoderInfo *coder = &folder->Coders[ci]; - - if (IS_MAIN_METHOD((uint32_t)coder->MethodID)) - { - uint32_t si = 0; - uint64_t offset; - uint64_t inSize; - uint8_t *outBufCur = outBuffer; - size_t outSizeCur = outSize; - if (folder->NumCoders == 4) - { - uint32_t indices[] = { 3, 2, 0 }; - uint64_t unpackSize = folder->UnpackSizes[ci]; - si = indices[ci]; - if (ci < 2) - { - uint8_t *temp; - outSizeCur = (size_t)unpackSize; - if (outSizeCur != unpackSize) - return SZ_ERROR_MEM; - temp = (uint8_t *)IAlloc_Alloc(allocMain, outSizeCur); - if (temp == 0 && outSizeCur != 0) - return SZ_ERROR_MEM; - outBufCur = tempBuf[1 - ci] = temp; - tempSizes[1 - ci] = outSizeCur; - } - else if (ci == 2) - { - if (unpackSize > outSize) /* check it */ - return SZ_ERROR_PARAM; - tempBuf3 = outBufCur = outBuffer + (outSize - (size_t)unpackSize); - tempSize3 = outSizeCur = (size_t)unpackSize; - } - else - return SZ_ERROR_UNSUPPORTED; - } - offset = GetSum(packSizes, si); - inSize = packSizes[si]; - RINOK(LookInStream_SeekTo(inStream, startPos + offset)); - - if (coder->MethodID == k_Copy) - { - if (inSize != outSizeCur) /* check it */ - return SZ_ERROR_DATA; - RINOK(SzDecodeCopy(inSize, inStream, outBufCur)); - } - else if (coder->MethodID == k_LZMA) - { - RINOK(SzDecodeLzma(coder, inSize, inStream, outBufCur, outSizeCur, allocMain)); - } - else if (coder->MethodID == k_LZMA2) - { - RINOK(SzDecodeLzma2(coder, inSize, inStream, outBufCur, outSizeCur, allocMain)); - } - else - return SZ_ERROR_UNSUPPORTED; - } - else if (coder->MethodID == k_BCJ2) - { - uint64_t offset = GetSum(packSizes, 1); - uint64_t s3Size = packSizes[1]; - SRes res; - if (ci != 3) - return SZ_ERROR_UNSUPPORTED; - RINOK(LookInStream_SeekTo(inStream, startPos + offset)); - tempSizes[2] = (size_t)s3Size; - if (tempSizes[2] != s3Size) - return SZ_ERROR_MEM; - tempBuf[2] = (uint8_t *)IAlloc_Alloc(allocMain, tempSizes[2]); - if (tempBuf[2] == 0 && tempSizes[2] != 0) - return SZ_ERROR_MEM; - res = SzDecodeCopy(s3Size, inStream, tempBuf[2]); - RINOK(res) - - res = Bcj2_Decode( - tempBuf3, tempSize3, - tempBuf[0], tempSizes[0], - tempBuf[1], tempSizes[1], - tempBuf[2], tempSizes[2], - outBuffer, outSize); - RINOK(res) - } - else - { - if (ci != 1) - return SZ_ERROR_UNSUPPORTED; - switch(coder->MethodID) - { - case k_BCJ: - { - uint32_t state; - x86_Convert_Init(state); - x86_Convert(outBuffer, outSize, 0, &state, 0); - break; - } - CASE_BRA_CONV(ARM) - default: - return SZ_ERROR_UNSUPPORTED; - } - } - } - return SZ_OK; -} - -SRes SzFolder_Decode(const CSzFolder *folder, const uint64_t *packSizes, - ILookInStream *inStream, uint64_t startPos, - uint8_t *outBuffer, size_t outSize, ISzAlloc *allocMain) -{ - uint8_t *tempBuf[3] = { 0, 0, 0}; - int i; - SRes res = SzFolder_Decode2(folder, packSizes, inStream, startPos, - outBuffer, (size_t)outSize, allocMain, tempBuf); - for (i = 0; i < 3; i++) - IAlloc_Free(allocMain, tempBuf[i]); - return res; -} +/* 7zDec.c -- Decoding from 7z folder +2010-11-02 : Igor Pavlov : Public domain */ + +#include +#include +#include + +#include "7z.h" + +#include "Bcj2.h" +#include "Bra.h" +#include "CpuArch.h" +#include "LzmaDec.h" +#include "Lzma2Dec.h" + +#define k_Copy 0 +#define k_LZMA2 0x21 +#define k_LZMA 0x30101 +#define k_BCJ 0x03030103 +#define k_PPC 0x03030205 +#define k_ARM 0x03030501 +#define k_ARMT 0x03030701 +#define k_SPARC 0x03030805 +#define k_BCJ2 0x0303011B + +static SRes SzDecodeLzma(CSzCoderInfo *coder, uint64_t inSize, ILookInStream *inStream, + uint8_t *outBuffer, size_t outSize, ISzAlloc *allocMain) +{ + CLzmaDec state; + SRes res = SZ_OK; + + LzmaDec_Construct(&state); + RINOK(LzmaDec_AllocateProbs(&state, coder->Props.data, (unsigned)coder->Props.size, allocMain)); + state.dic = outBuffer; + state.dicBufSize = outSize; + LzmaDec_Init(&state); + + for (;;) + { + uint8_t *inBuf = NULL; + size_t lookahead = (1 << 18); + if (lookahead > inSize) + lookahead = (size_t)inSize; + res = inStream->Look((void *)inStream, (const void **)&inBuf, &lookahead); + if (res != SZ_OK) + break; + + { + size_t inProcessed = (size_t)lookahead, dicPos = state.dicPos; + ELzmaStatus status; + res = LzmaDec_DecodeToDic(&state, outSize, inBuf, &inProcessed, LZMA_FINISH_END, &status); + lookahead -= inProcessed; + inSize -= inProcessed; + if (res != SZ_OK) + break; + if (state.dicPos == state.dicBufSize || (inProcessed == 0 && dicPos == state.dicPos)) + { + if (state.dicBufSize != outSize || lookahead != 0 || + (status != LZMA_STATUS_FINISHED_WITH_MARK && + status != LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK)) + res = SZ_ERROR_DATA; + break; + } + res = inStream->Skip((void *)inStream, inProcessed); + if (res != SZ_OK) + break; + } + } + + LzmaDec_FreeProbs(&state, allocMain); + return res; +} + +static SRes SzDecodeLzma2(CSzCoderInfo *coder, uint64_t inSize, ILookInStream *inStream, + uint8_t *outBuffer, size_t outSize, ISzAlloc *allocMain) +{ + CLzma2Dec state; + SRes res = SZ_OK; + + Lzma2Dec_Construct(&state); + if (coder->Props.size != 1) + return SZ_ERROR_DATA; + RINOK(Lzma2Dec_AllocateProbs(&state, coder->Props.data[0], allocMain)); + state.decoder.dic = outBuffer; + state.decoder.dicBufSize = outSize; + Lzma2Dec_Init(&state); + + for (;;) + { + uint8_t *inBuf = NULL; + size_t lookahead = (1 << 18); + if (lookahead > inSize) + lookahead = (size_t)inSize; + res = inStream->Look((void *)inStream, (const void **)&inBuf, &lookahead); + if (res != SZ_OK) + break; + + { + size_t inProcessed = (size_t)lookahead, dicPos = state.decoder.dicPos; + ELzmaStatus status; + res = Lzma2Dec_DecodeToDic(&state, outSize, inBuf, &inProcessed, LZMA_FINISH_END, &status); + lookahead -= inProcessed; + inSize -= inProcessed; + if (res != SZ_OK) + break; + if (state.decoder.dicPos == state.decoder.dicBufSize || (inProcessed == 0 && dicPos == state.decoder.dicPos)) + { + if (state.decoder.dicBufSize != outSize || lookahead != 0 || + (status != LZMA_STATUS_FINISHED_WITH_MARK)) + res = SZ_ERROR_DATA; + break; + } + res = inStream->Skip((void *)inStream, inProcessed); + if (res != SZ_OK) + break; + } + } + + Lzma2Dec_FreeProbs(&state, allocMain); + return res; +} + +static SRes SzDecodeCopy(uint64_t inSize, ILookInStream *inStream, uint8_t *outBuffer) +{ + while (inSize > 0) + { + void *inBuf; + size_t curSize = (1 << 18); + if (curSize > inSize) + curSize = (size_t)inSize; + RINOK(inStream->Look((void *)inStream, (const void **)&inBuf, &curSize)); + if (curSize == 0) + return SZ_ERROR_INPUT_EOF; + memcpy(outBuffer, inBuf, curSize); + outBuffer += curSize; + inSize -= curSize; + RINOK(inStream->Skip((void *)inStream, curSize)); + } + return SZ_OK; +} + +static bool IS_MAIN_METHOD(uint32_t m) +{ + switch(m) + { + case k_Copy: + case k_LZMA: + case k_LZMA2: + return true; + } + return false; +} + +static bool IS_SUPPORTED_CODER(const CSzCoderInfo *c) +{ + return + c->NumInStreams == 1 && + c->NumOutStreams == 1 && + c->MethodID <= (uint32_t)0xFFFFFFFF && + IS_MAIN_METHOD((uint32_t)c->MethodID); +} + +#define IS_BCJ2(c) ((c)->MethodID == k_BCJ2 && (c)->NumInStreams == 4 && (c)->NumOutStreams == 1) + +static SRes CheckSupportedFolder(const CSzFolder *f) +{ + if (f->NumCoders < 1 || f->NumCoders > 4) + return SZ_ERROR_UNSUPPORTED; + if (!IS_SUPPORTED_CODER(&f->Coders[0])) + return SZ_ERROR_UNSUPPORTED; + if (f->NumCoders == 1) + { + if (f->NumPackStreams != 1 || f->PackStreams[0] != 0 || f->NumBindPairs != 0) + return SZ_ERROR_UNSUPPORTED; + return SZ_OK; + } + if (f->NumCoders == 2) + { + CSzCoderInfo *c = &f->Coders[1]; + if (c->MethodID > (uint32_t)0xFFFFFFFF || + c->NumInStreams != 1 || + c->NumOutStreams != 1 || + f->NumPackStreams != 1 || + f->PackStreams[0] != 0 || + f->NumBindPairs != 1 || + f->BindPairs[0].InIndex != 1 || + f->BindPairs[0].OutIndex != 0) + return SZ_ERROR_UNSUPPORTED; + switch ((uint32_t)c->MethodID) + { + case k_BCJ: + case k_ARM: + break; + default: + return SZ_ERROR_UNSUPPORTED; + } + return SZ_OK; + } + if (f->NumCoders == 4) + { + if (!IS_SUPPORTED_CODER(&f->Coders[1]) || + !IS_SUPPORTED_CODER(&f->Coders[2]) || + !IS_BCJ2(&f->Coders[3])) + return SZ_ERROR_UNSUPPORTED; + if (f->NumPackStreams != 4 || + f->PackStreams[0] != 2 || + f->PackStreams[1] != 6 || + f->PackStreams[2] != 1 || + f->PackStreams[3] != 0 || + f->NumBindPairs != 3 || + f->BindPairs[0].InIndex != 5 || f->BindPairs[0].OutIndex != 0 || + f->BindPairs[1].InIndex != 4 || f->BindPairs[1].OutIndex != 1 || + f->BindPairs[2].InIndex != 3 || f->BindPairs[2].OutIndex != 2) + return SZ_ERROR_UNSUPPORTED; + return SZ_OK; + } + return SZ_ERROR_UNSUPPORTED; +} + +static uint64_t GetSum(const uint64_t *values, uint32_t idx) +{ + uint64_t sum = 0; + uint32_t i; + for (i = 0; i < idx; i++) + sum += values[i]; + return sum; +} + +#define CASE_BRA_CONV(isa) case k_ ## isa: isa ## _Convert(outBuffer, outSize, 0, 0); break; + +static SRes SzFolder_Decode2(const CSzFolder *folder, const uint64_t *packSizes, + ILookInStream *inStream, uint64_t startPos, + uint8_t *outBuffer, size_t outSize, ISzAlloc *allocMain, + uint8_t *tempBuf[]) +{ + uint32_t ci; + size_t tempSizes[3] = { 0, 0, 0}; + size_t tempSize3 = 0; + uint8_t *tempBuf3 = 0; + + RINOK(CheckSupportedFolder(folder)); + + for (ci = 0; ci < folder->NumCoders; ci++) + { + CSzCoderInfo *coder = &folder->Coders[ci]; + + if (IS_MAIN_METHOD((uint32_t)coder->MethodID)) + { + uint32_t si = 0; + uint64_t offset; + uint64_t inSize; + uint8_t *outBufCur = outBuffer; + size_t outSizeCur = outSize; + if (folder->NumCoders == 4) + { + uint32_t indices[] = { 3, 2, 0 }; + uint64_t unpackSize = folder->UnpackSizes[ci]; + si = indices[ci]; + if (ci < 2) + { + uint8_t *temp; + outSizeCur = (size_t)unpackSize; + if (outSizeCur != unpackSize) + return SZ_ERROR_MEM; + temp = (uint8_t *)IAlloc_Alloc(allocMain, outSizeCur); + if (temp == 0 && outSizeCur != 0) + return SZ_ERROR_MEM; + outBufCur = tempBuf[1 - ci] = temp; + tempSizes[1 - ci] = outSizeCur; + } + else if (ci == 2) + { + if (unpackSize > outSize) /* check it */ + return SZ_ERROR_PARAM; + tempBuf3 = outBufCur = outBuffer + (outSize - (size_t)unpackSize); + tempSize3 = outSizeCur = (size_t)unpackSize; + } + else + return SZ_ERROR_UNSUPPORTED; + } + offset = GetSum(packSizes, si); + inSize = packSizes[si]; + RINOK(LookInStream_SeekTo(inStream, startPos + offset)); + + if (coder->MethodID == k_Copy) + { + if (inSize != outSizeCur) /* check it */ + return SZ_ERROR_DATA; + RINOK(SzDecodeCopy(inSize, inStream, outBufCur)); + } + else if (coder->MethodID == k_LZMA) + { + RINOK(SzDecodeLzma(coder, inSize, inStream, outBufCur, outSizeCur, allocMain)); + } + else if (coder->MethodID == k_LZMA2) + { + RINOK(SzDecodeLzma2(coder, inSize, inStream, outBufCur, outSizeCur, allocMain)); + } + else + return SZ_ERROR_UNSUPPORTED; + } + else if (coder->MethodID == k_BCJ2) + { + uint64_t offset = GetSum(packSizes, 1); + uint64_t s3Size = packSizes[1]; + SRes res; + if (ci != 3) + return SZ_ERROR_UNSUPPORTED; + RINOK(LookInStream_SeekTo(inStream, startPos + offset)); + tempSizes[2] = (size_t)s3Size; + if (tempSizes[2] != s3Size) + return SZ_ERROR_MEM; + tempBuf[2] = (uint8_t *)IAlloc_Alloc(allocMain, tempSizes[2]); + if (tempBuf[2] == 0 && tempSizes[2] != 0) + return SZ_ERROR_MEM; + res = SzDecodeCopy(s3Size, inStream, tempBuf[2]); + RINOK(res) + + res = Bcj2_Decode( + tempBuf3, tempSize3, + tempBuf[0], tempSizes[0], + tempBuf[1], tempSizes[1], + tempBuf[2], tempSizes[2], + outBuffer, outSize); + RINOK(res) + } + else + { + if (ci != 1) + return SZ_ERROR_UNSUPPORTED; + switch(coder->MethodID) + { + case k_BCJ: + { + uint32_t state; + x86_Convert_Init(state); + x86_Convert(outBuffer, outSize, 0, &state, 0); + break; + } + CASE_BRA_CONV(ARM) + default: + return SZ_ERROR_UNSUPPORTED; + } + } + } + return SZ_OK; +} + +SRes SzFolder_Decode(const CSzFolder *folder, const uint64_t *packSizes, + ILookInStream *inStream, uint64_t startPos, + uint8_t *outBuffer, size_t outSize, ISzAlloc *allocMain) +{ + uint8_t *tempBuf[3] = { 0, 0, 0}; + int i; + SRes res = SzFolder_Decode2(folder, packSizes, inStream, startPos, + outBuffer, (size_t)outSize, allocMain, tempBuf); + for (i = 0; i < 3; i++) + IAlloc_Free(allocMain, tempBuf[i]); + return res; +} diff --git a/deps/7zip/7zFile.c b/deps/7zip/7zFile.c index 8f0b628fff..6dc10da40c 100644 --- a/deps/7zip/7zFile.c +++ b/deps/7zip/7zFile.c @@ -1,285 +1,285 @@ -/* 7zFile.c -- File IO - 2009-11-24 : Igor Pavlov : Public domain */ - -#include -#include "7zFile.h" - -#ifndef USE_WINDOWS_FILE - -#ifndef UNDER_CE -#include -#endif - -#else - -/* - ReadFile and WriteFile functions in Windows have BUG: - If you Read or Write 64MB or more (probably min_failure_size = 64MB - 32KB + 1) - from/to Network file, it returns ERROR_NO_SYSTEM_RESOURCES - (Insufficient system resources exist to complete the requested service). - Probably in some version of Windows there are problems with other sizes: - for 32 MB (maybe also for 16 MB). - And message can be "Network connection was lost" - */ - -#define kChunkSizeMax (1 << 22) - -#endif - -void File_Construct(CSzFile *p) -{ -#ifdef USE_WINDOWS_FILE - p->handle = INVALID_HANDLE_VALUE; -#else - p->file = NULL; -#endif -} - -#if !defined(UNDER_CE) || !defined(USE_WINDOWS_FILE) -static WRes File_Open(CSzFile *p, const char *name, int writeMode) -{ -#ifdef USE_WINDOWS_FILE - p->handle = CreateFileA(name, - writeMode ? GENERIC_WRITE : GENERIC_READ, - FILE_SHARE_READ, NULL, - writeMode ? CREATE_ALWAYS : OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, NULL); - return (p->handle != INVALID_HANDLE_VALUE) ? 0 : GetLastError(); -#else - p->file = fopen(name, writeMode ? "wb+" : "rb"); - return (p->file != 0) ? 0 : -#ifdef UNDER_CE - 2; /* ENOENT */ -#else - errno; -#endif -#endif -} - -WRes InFile_Open(CSzFile *p, const char *name) { return File_Open(p, name, 0); } -WRes OutFile_Open(CSzFile *p, const char *name) { return File_Open(p, name, 1); } -#endif - -#ifdef USE_WINDOWS_FILE -static WRes File_OpenW(CSzFile *p, const WCHAR *name, int writeMode) -{ - p->handle = CreateFileW(name, - writeMode ? GENERIC_WRITE : GENERIC_READ, - FILE_SHARE_READ, NULL, - writeMode ? CREATE_ALWAYS : OPEN_EXISTING, - FILE_ATTRIBUTE_NORMAL, NULL); - return (p->handle != INVALID_HANDLE_VALUE) ? 0 : GetLastError(); -} -WRes InFile_OpenW(CSzFile *p, const WCHAR *name) { return File_OpenW(p, name, 0); } -WRes OutFile_OpenW(CSzFile *p, const WCHAR *name) { return File_OpenW(p, name, 1); } -#endif - -WRes File_Close(CSzFile *p) -{ -#ifdef USE_WINDOWS_FILE - if (p->handle != INVALID_HANDLE_VALUE) - { - if (!CloseHandle(p->handle)) - return GetLastError(); - p->handle = INVALID_HANDLE_VALUE; - } -#else - if (p->file != NULL) - { - int res = fclose(p->file); - if (res != 0) - return res; - p->file = NULL; - } -#endif - return 0; -} - -WRes File_Read(CSzFile *p, void *data, size_t *size) -{ - size_t originalSize = *size; - if (originalSize == 0) - return 0; - -#ifdef USE_WINDOWS_FILE - - *size = 0; - do - { - DWORD curSize = (originalSize > kChunkSizeMax) ? kChunkSizeMax : (DWORD)originalSize; - DWORD processed = 0; - BOOL res = ReadFile(p->handle, data, curSize, &processed, NULL); - data = (void *)((uint8_t*)data + processed); - originalSize -= processed; - *size += processed; - if (!res) - return GetLastError(); - if (processed == 0) - break; - } - while (originalSize > 0); - return 0; - -#else - - *size = fread(data, 1, originalSize, p->file); - if (*size == originalSize) - return 0; - return ferror(p->file); - -#endif -} - -WRes File_Write(CSzFile *p, const void *data, size_t *size) -{ - size_t originalSize = *size; - if (originalSize == 0) - return 0; - -#ifdef USE_WINDOWS_FILE - - *size = 0; - do - { - DWORD curSize = (originalSize > kChunkSizeMax) ? kChunkSizeMax : (DWORD)originalSize; - DWORD processed = 0; - BOOL res = WriteFile(p->handle, data, curSize, &processed, NULL); - data = (void *)((uint8_t*)data + processed); - originalSize -= processed; - *size += processed; - if (!res) - return GetLastError(); - if (processed == 0) - break; - } - while (originalSize > 0); - return 0; - -#else - - *size = fwrite(data, 1, originalSize, p->file); - if (*size == originalSize) - return 0; - return ferror(p->file); - -#endif -} - -WRes File_Seek(CSzFile *p, int64_t *pos, ESzSeek origin) -{ -#ifdef USE_WINDOWS_FILE - - LARGE_INTEGER value; - DWORD moveMethod; - value.LowPart = (DWORD)*pos; - value.HighPart = (LONG)((uint64_t)*pos >> 16 >> 16); /* for case when uint64_t is 32-bit only */ - switch (origin) - { - case SZ_SEEK_SET: moveMethod = FILE_BEGIN; break; - case SZ_SEEK_CUR: moveMethod = FILE_CURRENT; break; - case SZ_SEEK_END: moveMethod = FILE_END; break; - default: return ERROR_INVALID_PARAMETER; - } - value.LowPart = SetFilePointer(p->handle, value.LowPart, &value.HighPart, moveMethod); - if (value.LowPart == 0xFFFFFFFF) - { - WRes res = GetLastError(); - if (res != NO_ERROR) - return res; - } - *pos = ((int64_t)value.HighPart << 32) | value.LowPart; - return 0; - -#else - - int moveMethod; - int res; - switch (origin) - { - case SZ_SEEK_SET: moveMethod = SEEK_SET; break; - case SZ_SEEK_CUR: moveMethod = SEEK_CUR; break; - case SZ_SEEK_END: moveMethod = SEEK_END; break; - default: return 1; - } - res = fseek(p->file, (long)*pos, moveMethod); - *pos = ftell(p->file); - return res; - -#endif -} - -WRes File_GetLength(CSzFile *p, uint64_t *length) -{ -#ifdef USE_WINDOWS_FILE - - DWORD sizeHigh; - DWORD sizeLow = GetFileSize(p->handle, &sizeHigh); - if (sizeLow == 0xFFFFFFFF) - { - DWORD res = GetLastError(); - if (res != NO_ERROR) - return res; - } - *length = (((uint64_t)sizeHigh) << 32) + sizeLow; - return 0; - -#else - - long pos = ftell(p->file); - int res = fseek(p->file, 0, SEEK_END); - *length = ftell(p->file); - fseek(p->file, pos, SEEK_SET); - return res; - -#endif -} - - -/* ---------- FileSeqInStream ---------- */ - -static SRes FileSeqInStream_Read(void *pp, void *buf, size_t *size) -{ - CFileSeqInStream *p = (CFileSeqInStream *)pp; - return File_Read(&p->file, buf, size) == 0 ? SZ_OK : SZ_ERROR_READ; -} - -void FileSeqInStream_CreateVTable(CFileSeqInStream *p) -{ - p->s.Read = FileSeqInStream_Read; -} - - -/* ---------- FileInStream ---------- */ - -static SRes FileInStream_Read(void *pp, void *buf, size_t *size) -{ - CFileInStream *p = (CFileInStream *)pp; - return (File_Read(&p->file, buf, size) == 0) ? SZ_OK : SZ_ERROR_READ; -} - -static SRes FileInStream_Seek(void *pp, int64_t *pos, ESzSeek origin) -{ - CFileInStream *p = (CFileInStream *)pp; - return File_Seek(&p->file, pos, origin); -} - -void FileInStream_CreateVTable(CFileInStream *p) -{ - p->s.Read = FileInStream_Read; - p->s.Seek = FileInStream_Seek; -} - - -/* ---------- FileOutStream ---------- */ - -static size_t FileOutStream_Write(void *pp, const void *data, size_t size) -{ - CFileOutStream *p = (CFileOutStream *)pp; - File_Write(&p->file, data, &size); - return size; -} - -void FileOutStream_CreateVTable(CFileOutStream *p) -{ - p->s.Write = FileOutStream_Write; -} +/* 7zFile.c -- File IO + 2009-11-24 : Igor Pavlov : Public domain */ + +#include +#include "7zFile.h" + +#ifndef USE_WINDOWS_FILE + +#ifndef UNDER_CE +#include +#endif + +#else + +/* + ReadFile and WriteFile functions in Windows have BUG: + If you Read or Write 64MB or more (probably min_failure_size = 64MB - 32KB + 1) + from/to Network file, it returns ERROR_NO_SYSTEM_RESOURCES + (Insufficient system resources exist to complete the requested service). + Probably in some version of Windows there are problems with other sizes: + for 32 MB (maybe also for 16 MB). + And message can be "Network connection was lost" + */ + +#define kChunkSizeMax (1 << 22) + +#endif + +void File_Construct(CSzFile *p) +{ +#ifdef USE_WINDOWS_FILE + p->handle = INVALID_HANDLE_VALUE; +#else + p->file = NULL; +#endif +} + +#if !defined(UNDER_CE) || !defined(USE_WINDOWS_FILE) +static WRes File_Open(CSzFile *p, const char *name, int writeMode) +{ +#ifdef USE_WINDOWS_FILE + p->handle = CreateFileA(name, + writeMode ? GENERIC_WRITE : GENERIC_READ, + FILE_SHARE_READ, NULL, + writeMode ? CREATE_ALWAYS : OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, NULL); + return (p->handle != INVALID_HANDLE_VALUE) ? 0 : GetLastError(); +#else + p->file = fopen(name, writeMode ? "wb+" : "rb"); + return (p->file != 0) ? 0 : +#ifdef UNDER_CE + 2; /* ENOENT */ +#else + errno; +#endif +#endif +} + +WRes InFile_Open(CSzFile *p, const char *name) { return File_Open(p, name, 0); } +WRes OutFile_Open(CSzFile *p, const char *name) { return File_Open(p, name, 1); } +#endif + +#ifdef USE_WINDOWS_FILE +static WRes File_OpenW(CSzFile *p, const WCHAR *name, int writeMode) +{ + p->handle = CreateFileW(name, + writeMode ? GENERIC_WRITE : GENERIC_READ, + FILE_SHARE_READ, NULL, + writeMode ? CREATE_ALWAYS : OPEN_EXISTING, + FILE_ATTRIBUTE_NORMAL, NULL); + return (p->handle != INVALID_HANDLE_VALUE) ? 0 : GetLastError(); +} +WRes InFile_OpenW(CSzFile *p, const WCHAR *name) { return File_OpenW(p, name, 0); } +WRes OutFile_OpenW(CSzFile *p, const WCHAR *name) { return File_OpenW(p, name, 1); } +#endif + +WRes File_Close(CSzFile *p) +{ +#ifdef USE_WINDOWS_FILE + if (p->handle != INVALID_HANDLE_VALUE) + { + if (!CloseHandle(p->handle)) + return GetLastError(); + p->handle = INVALID_HANDLE_VALUE; + } +#else + if (p->file != NULL) + { + int res = fclose(p->file); + if (res != 0) + return res; + p->file = NULL; + } +#endif + return 0; +} + +WRes File_Read(CSzFile *p, void *data, size_t *size) +{ + size_t originalSize = *size; + if (originalSize == 0) + return 0; + +#ifdef USE_WINDOWS_FILE + + *size = 0; + do + { + DWORD curSize = (originalSize > kChunkSizeMax) ? kChunkSizeMax : (DWORD)originalSize; + DWORD processed = 0; + BOOL res = ReadFile(p->handle, data, curSize, &processed, NULL); + data = (void *)((uint8_t*)data + processed); + originalSize -= processed; + *size += processed; + if (!res) + return GetLastError(); + if (processed == 0) + break; + } + while (originalSize > 0); + return 0; + +#else + + *size = fread(data, 1, originalSize, p->file); + if (*size == originalSize) + return 0; + return ferror(p->file); + +#endif +} + +WRes File_Write(CSzFile *p, const void *data, size_t *size) +{ + size_t originalSize = *size; + if (originalSize == 0) + return 0; + +#ifdef USE_WINDOWS_FILE + + *size = 0; + do + { + DWORD curSize = (originalSize > kChunkSizeMax) ? kChunkSizeMax : (DWORD)originalSize; + DWORD processed = 0; + BOOL res = WriteFile(p->handle, data, curSize, &processed, NULL); + data = (void *)((uint8_t*)data + processed); + originalSize -= processed; + *size += processed; + if (!res) + return GetLastError(); + if (processed == 0) + break; + } + while (originalSize > 0); + return 0; + +#else + + *size = fwrite(data, 1, originalSize, p->file); + if (*size == originalSize) + return 0; + return ferror(p->file); + +#endif +} + +WRes File_Seek(CSzFile *p, int64_t *pos, ESzSeek origin) +{ +#ifdef USE_WINDOWS_FILE + + LARGE_INTEGER value; + DWORD moveMethod; + value.LowPart = (DWORD)*pos; + value.HighPart = (LONG)((uint64_t)*pos >> 16 >> 16); /* for case when uint64_t is 32-bit only */ + switch (origin) + { + case SZ_SEEK_SET: moveMethod = FILE_BEGIN; break; + case SZ_SEEK_CUR: moveMethod = FILE_CURRENT; break; + case SZ_SEEK_END: moveMethod = FILE_END; break; + default: return ERROR_INVALID_PARAMETER; + } + value.LowPart = SetFilePointer(p->handle, value.LowPart, &value.HighPart, moveMethod); + if (value.LowPart == 0xFFFFFFFF) + { + WRes res = GetLastError(); + if (res != NO_ERROR) + return res; + } + *pos = ((int64_t)value.HighPart << 32) | value.LowPart; + return 0; + +#else + + int moveMethod; + int res; + switch (origin) + { + case SZ_SEEK_SET: moveMethod = SEEK_SET; break; + case SZ_SEEK_CUR: moveMethod = SEEK_CUR; break; + case SZ_SEEK_END: moveMethod = SEEK_END; break; + default: return 1; + } + res = fseek(p->file, (long)*pos, moveMethod); + *pos = ftell(p->file); + return res; + +#endif +} + +WRes File_GetLength(CSzFile *p, uint64_t *length) +{ +#ifdef USE_WINDOWS_FILE + + DWORD sizeHigh; + DWORD sizeLow = GetFileSize(p->handle, &sizeHigh); + if (sizeLow == 0xFFFFFFFF) + { + DWORD res = GetLastError(); + if (res != NO_ERROR) + return res; + } + *length = (((uint64_t)sizeHigh) << 32) + sizeLow; + return 0; + +#else + + long pos = ftell(p->file); + int res = fseek(p->file, 0, SEEK_END); + *length = ftell(p->file); + fseek(p->file, pos, SEEK_SET); + return res; + +#endif +} + + +/* ---------- FileSeqInStream ---------- */ + +static SRes FileSeqInStream_Read(void *pp, void *buf, size_t *size) +{ + CFileSeqInStream *p = (CFileSeqInStream *)pp; + return File_Read(&p->file, buf, size) == 0 ? SZ_OK : SZ_ERROR_READ; +} + +void FileSeqInStream_CreateVTable(CFileSeqInStream *p) +{ + p->s.Read = FileSeqInStream_Read; +} + + +/* ---------- FileInStream ---------- */ + +static SRes FileInStream_Read(void *pp, void *buf, size_t *size) +{ + CFileInStream *p = (CFileInStream *)pp; + return (File_Read(&p->file, buf, size) == 0) ? SZ_OK : SZ_ERROR_READ; +} + +static SRes FileInStream_Seek(void *pp, int64_t *pos, ESzSeek origin) +{ + CFileInStream *p = (CFileInStream *)pp; + return File_Seek(&p->file, pos, origin); +} + +void FileInStream_CreateVTable(CFileInStream *p) +{ + p->s.Read = FileInStream_Read; + p->s.Seek = FileInStream_Seek; +} + + +/* ---------- FileOutStream ---------- */ + +static size_t FileOutStream_Write(void *pp, const void *data, size_t size) +{ + CFileOutStream *p = (CFileOutStream *)pp; + File_Write(&p->file, data, &size); + return size; +} + +void FileOutStream_CreateVTable(CFileOutStream *p) +{ + p->s.Write = FileOutStream_Write; +} diff --git a/deps/7zip/7zFile.h b/deps/7zip/7zFile.h index 86c3ed1060..33910ec420 100644 --- a/deps/7zip/7zFile.h +++ b/deps/7zip/7zFile.h @@ -1,87 +1,87 @@ -/* 7zFile.h -- File IO -2009-11-24 : Igor Pavlov : Public domain */ - -#ifndef __7Z_FILE_H -#define __7Z_FILE_H - -#ifdef _WIN32 -#define USE_WINDOWS_FILE -#endif - -#ifdef USE_WINDOWS_FILE -#include -#else -#include -#endif - -#include "7zTypes.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* ---------- File ---------- */ - -typedef struct -{ - #ifdef USE_WINDOWS_FILE - HANDLE handle; - #else - FILE *file; - #endif -} CSzFile; - -void File_Construct(CSzFile *p); -#if !defined(UNDER_CE) || !defined(USE_WINDOWS_FILE) -WRes InFile_Open(CSzFile *p, const char *name); -WRes OutFile_Open(CSzFile *p, const char *name); -#endif -#ifdef USE_WINDOWS_FILE -WRes InFile_OpenW(CSzFile *p, const WCHAR *name); -WRes OutFile_OpenW(CSzFile *p, const WCHAR *name); -#endif -WRes File_Close(CSzFile *p); - -/* reads max(*size, remain file's size) bytes */ -WRes File_Read(CSzFile *p, void *data, size_t *size); - -/* writes *size bytes */ -WRes File_Write(CSzFile *p, const void *data, size_t *size); - -WRes File_Seek(CSzFile *p, int64_t *pos, ESzSeek origin); -WRes File_GetLength(CSzFile *p, uint64_t *length); - - -/* ---------- FileInStream ---------- */ - -typedef struct -{ - ISeqInStream s; - CSzFile file; -} CFileSeqInStream; - -void FileSeqInStream_CreateVTable(CFileSeqInStream *p); - - -typedef struct -{ - ISeekInStream s; - CSzFile file; -} CFileInStream; - -void FileInStream_CreateVTable(CFileInStream *p); - - -typedef struct -{ - ISeqOutStream s; - CSzFile file; -} CFileOutStream; - -void FileOutStream_CreateVTable(CFileOutStream *p); - -#ifdef __cplusplus -} -#endif - -#endif +/* 7zFile.h -- File IO +2009-11-24 : Igor Pavlov : Public domain */ + +#ifndef __7Z_FILE_H +#define __7Z_FILE_H + +#ifdef _WIN32 +#define USE_WINDOWS_FILE +#endif + +#ifdef USE_WINDOWS_FILE +#include +#else +#include +#endif + +#include "7zTypes.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* ---------- File ---------- */ + +typedef struct +{ + #ifdef USE_WINDOWS_FILE + HANDLE handle; + #else + FILE *file; + #endif +} CSzFile; + +void File_Construct(CSzFile *p); +#if !defined(UNDER_CE) || !defined(USE_WINDOWS_FILE) +WRes InFile_Open(CSzFile *p, const char *name); +WRes OutFile_Open(CSzFile *p, const char *name); +#endif +#ifdef USE_WINDOWS_FILE +WRes InFile_OpenW(CSzFile *p, const WCHAR *name); +WRes OutFile_OpenW(CSzFile *p, const WCHAR *name); +#endif +WRes File_Close(CSzFile *p); + +/* reads max(*size, remain file's size) bytes */ +WRes File_Read(CSzFile *p, void *data, size_t *size); + +/* writes *size bytes */ +WRes File_Write(CSzFile *p, const void *data, size_t *size); + +WRes File_Seek(CSzFile *p, int64_t *pos, ESzSeek origin); +WRes File_GetLength(CSzFile *p, uint64_t *length); + + +/* ---------- FileInStream ---------- */ + +typedef struct +{ + ISeqInStream s; + CSzFile file; +} CFileSeqInStream; + +void FileSeqInStream_CreateVTable(CFileSeqInStream *p); + + +typedef struct +{ + ISeekInStream s; + CSzFile file; +} CFileInStream; + +void FileInStream_CreateVTable(CFileInStream *p); + + +typedef struct +{ + ISeqOutStream s; + CSzFile file; +} CFileOutStream; + +void FileOutStream_CreateVTable(CFileOutStream *p); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/deps/7zip/7zIn.c b/deps/7zip/7zIn.c index b2b67b063b..62c1d5eb82 100644 --- a/deps/7zip/7zIn.c +++ b/deps/7zip/7zIn.c @@ -1,1371 +1,1371 @@ -/* 7zIn.c -- 7z Input functions - 2010-10-29 : Igor Pavlov : Public domain */ - -#include -#include - -#include "7z.h" -#include "7zCrc.h" -#include "CpuArch.h" - -uint8_t k7zSignature[k7zSignatureSize] = {'7', 'z', 0xBC, 0xAF, 0x27, 0x1C}; - -#define RINOM(x) { if ((x) == 0) return SZ_ERROR_MEM; } - -#define NUM_FOLDER_CODERS_MAX 32 -#define NUM_CODER_STREAMS_MAX 32 - -void SzFolder_Free(CSzFolder *p, ISzAlloc *alloc); -int SzFolder_FindBindPairForOutStream(CSzFolder *p, uint32_t outStreamIndex); - -void SzCoderInfo_Init(CSzCoderInfo *p) -{ - Buf_Init(&p->Props); -} - -void SzCoderInfo_Free(CSzCoderInfo *p, ISzAlloc *alloc) -{ - Buf_Free(&p->Props, alloc); - SzCoderInfo_Init(p); -} - -void SzFolder_Init(CSzFolder *p) -{ - p->Coders = 0; - p->BindPairs = 0; - p->PackStreams = 0; - p->UnpackSizes = 0; - p->NumCoders = 0; - p->NumBindPairs = 0; - p->NumPackStreams = 0; - p->UnpackCRCDefined = 0; - p->UnpackCRC = 0; - p->NumUnpackStreams = 0; -} - -void SzFolder_Free(CSzFolder *p, ISzAlloc *alloc) -{ - uint32_t i; - if (p->Coders) - for (i = 0; i < p->NumCoders; i++) - SzCoderInfo_Free(&p->Coders[i], alloc); - IAlloc_Free(alloc, p->Coders); - IAlloc_Free(alloc, p->BindPairs); - IAlloc_Free(alloc, p->PackStreams); - IAlloc_Free(alloc, p->UnpackSizes); - SzFolder_Init(p); -} - -uint32_t SzFolder_GetNumOutStreams(CSzFolder *p) -{ - uint32_t result = 0; - uint32_t i; - for (i = 0; i < p->NumCoders; i++) - result += p->Coders[i].NumOutStreams; - return result; -} - -int SzFolder_FindBindPairForInStream(CSzFolder *p, uint32_t inStreamIndex) -{ - uint32_t i; - for (i = 0; i < p->NumBindPairs; i++) - if (p->BindPairs[i].InIndex == inStreamIndex) - return i; - return -1; -} - - -int SzFolder_FindBindPairForOutStream(CSzFolder *p, uint32_t outStreamIndex) -{ - uint32_t i; - for (i = 0; i < p->NumBindPairs; i++) - if (p->BindPairs[i].OutIndex == outStreamIndex) - return i; - return -1; -} - -uint64_t SzFolder_GetUnpackSize(CSzFolder *p) -{ - int i = (int)SzFolder_GetNumOutStreams(p); - if (i == 0) - return 0; - for (i--; i >= 0; i--) - if (SzFolder_FindBindPairForOutStream(p, i) < 0) - return p->UnpackSizes[i]; - /* throw 1; */ - return 0; -} - -void SzFile_Init(CSzFileItem *p) -{ - p->HasStream = 1; - p->IsDir = 0; - p->IsAnti = 0; - p->CrcDefined = 0; - p->MTimeDefined = 0; -} - -void SzAr_Init(CSzAr *p) -{ - p->PackSizes = 0; - p->PackCRCsDefined = 0; - p->PackCRCs = 0; - p->Folders = 0; - p->Files = 0; - p->NumPackStreams = 0; - p->NumFolders = 0; - p->NumFiles = 0; -} - -void SzAr_Free(CSzAr *p, ISzAlloc *alloc) -{ - uint32_t i; - if (p->Folders) - for (i = 0; i < p->NumFolders; i++) - SzFolder_Free(&p->Folders[i], alloc); - - IAlloc_Free(alloc, p->PackSizes); - IAlloc_Free(alloc, p->PackCRCsDefined); - IAlloc_Free(alloc, p->PackCRCs); - IAlloc_Free(alloc, p->Folders); - IAlloc_Free(alloc, p->Files); - SzAr_Init(p); -} - - -void SzArEx_Init(CSzArEx *p) -{ - SzAr_Init(&p->db); - p->FolderStartPackStreamIndex = 0; - p->PackStreamStartPositions = 0; - p->FolderStartFileIndex = 0; - p->FileIndexToFolderIndexMap = 0; - p->FileNameOffsets = 0; - Buf_Init(&p->FileNames); -} - -void SzArEx_Free(CSzArEx *p, ISzAlloc *alloc) -{ - IAlloc_Free(alloc, p->FolderStartPackStreamIndex); - IAlloc_Free(alloc, p->PackStreamStartPositions); - IAlloc_Free(alloc, p->FolderStartFileIndex); - IAlloc_Free(alloc, p->FileIndexToFolderIndexMap); - - IAlloc_Free(alloc, p->FileNameOffsets); - Buf_Free(&p->FileNames, alloc); - - SzAr_Free(&p->db, alloc); - SzArEx_Init(p); -} - -/* - uint64_t GetFolderPackStreamSize(int folderIndex, int streamIndex) const - { - return PackSizes[FolderStartPackStreamIndex[folderIndex] + streamIndex]; - } - - uint64_t GetFilePackSize(int fileIndex) const - { - int folderIndex = FileIndexToFolderIndexMap[fileIndex]; - if (folderIndex >= 0) - { - const CSzFolder &folderInfo = Folders[folderIndex]; - if (FolderStartFileIndex[folderIndex] == fileIndex) - return GetFolderFullPackSize(folderIndex); - } - return 0; - } - */ - -#define MY_ALLOC(T, p, size, alloc) { if ((size) == 0) p = 0; else \ - if ((p = (T *)IAlloc_Alloc(alloc, (size) * sizeof(T))) == 0) return SZ_ERROR_MEM; } - -static SRes SzArEx_Fill(CSzArEx *p, ISzAlloc *alloc) -{ - uint32_t startPos = 0; - uint64_t startPosSize = 0; - uint32_t i; - uint32_t folderIndex = 0; - uint32_t indexInFolder = 0; - MY_ALLOC(uint32_t, p->FolderStartPackStreamIndex, p->db.NumFolders, alloc); - for (i = 0; i < p->db.NumFolders; i++) - { - p->FolderStartPackStreamIndex[i] = startPos; - startPos += p->db.Folders[i].NumPackStreams; - } - - MY_ALLOC(uint64_t, p->PackStreamStartPositions, p->db.NumPackStreams, alloc); - - for (i = 0; i < p->db.NumPackStreams; i++) - { - p->PackStreamStartPositions[i] = startPosSize; - startPosSize += p->db.PackSizes[i]; - } - - MY_ALLOC(uint32_t, p->FolderStartFileIndex, p->db.NumFolders, alloc); - MY_ALLOC(uint32_t, p->FileIndexToFolderIndexMap, p->db.NumFiles, alloc); - - for (i = 0; i < p->db.NumFiles; i++) - { - CSzFileItem *file = p->db.Files + i; - int emptyStream = !file->HasStream; - if (emptyStream && indexInFolder == 0) - { - p->FileIndexToFolderIndexMap[i] = (uint32_t)-1; - continue; - } - if (indexInFolder == 0) - { - /* - v3.13 incorrectly worked with empty folders - v4.07: Loop for skipping empty folders - */ - for (;;) - { - if (folderIndex >= p->db.NumFolders) - return SZ_ERROR_ARCHIVE; - p->FolderStartFileIndex[folderIndex] = i; - if (p->db.Folders[folderIndex].NumUnpackStreams != 0) - break; - folderIndex++; - } - } - p->FileIndexToFolderIndexMap[i] = folderIndex; - if (emptyStream) - continue; - indexInFolder++; - if (indexInFolder >= p->db.Folders[folderIndex].NumUnpackStreams) - { - folderIndex++; - indexInFolder = 0; - } - } - return SZ_OK; -} - - -uint64_t SzArEx_GetFolderStreamPos(const CSzArEx *p, uint32_t folderIndex, uint32_t indexInFolder) -{ - return p->dataPos + - p->PackStreamStartPositions[p->FolderStartPackStreamIndex[folderIndex] + indexInFolder]; -} - -int SzArEx_GetFolderFullPackSize(const CSzArEx *p, uint32_t folderIndex, uint64_t *resSize) -{ - uint32_t packStreamIndex = p->FolderStartPackStreamIndex[folderIndex]; - CSzFolder *folder = p->db.Folders + folderIndex; - uint64_t size = 0; - uint32_t i; - for (i = 0; i < folder->NumPackStreams; i++) - { - uint64_t t = size + p->db.PackSizes[packStreamIndex + i]; - if (t < size) /* check it */ - return SZ_ERROR_FAIL; - size = t; - } - *resSize = size; - return SZ_OK; -} - - -static int TestSignatureCandidate(uint8_t *testuint8_ts) -{ - size_t i; - for (i = 0; i < k7zSignatureSize; i++) - if (testuint8_ts[i] != k7zSignature[i]) - return 0; - return 1; -} - -typedef struct _CSzState -{ - uint8_t *Data; - size_t Size; -}CSzData; - -static SRes SzReaduint8_t(CSzData *sd, uint8_t *b) -{ - if (sd->Size == 0) - return SZ_ERROR_ARCHIVE; - sd->Size--; - *b = *sd->Data++; - return SZ_OK; -} - -static SRes SzReaduint8_ts(CSzData *sd, uint8_t *data, size_t size) -{ - size_t i; - for (i = 0; i < size; i++) - { - RINOK(SzReaduint8_t(sd, data + i)); - } - return SZ_OK; -} - -static SRes SzReaduint32_t(CSzData *sd, uint32_t *value) -{ - int i; - *value = 0; - for (i = 0; i < 4; i++) - { - uint8_t b; - RINOK(SzReaduint8_t(sd, &b)); - *value |= ((uint32_t)(b) << (8 * i)); - } - return SZ_OK; -} - -static SRes SzReadNumber(CSzData *sd, uint64_t *value) -{ - uint8_t firstuint8_t; - uint8_t mask = 0x80; - int i; - RINOK(SzReaduint8_t(sd, &firstuint8_t)); - *value = 0; - for (i = 0; i < 8; i++) - { - uint8_t b; - if ((firstuint8_t & mask) == 0) - { - uint64_t highPart = firstuint8_t & (mask - 1); - *value += (highPart << (8 * i)); - return SZ_OK; - } - RINOK(SzReaduint8_t(sd, &b)); - *value |= ((uint64_t)b << (8 * i)); - mask >>= 1; - } - return SZ_OK; -} - -static SRes SzReadNumber32(CSzData *sd, uint32_t *value) -{ - uint64_t value64; - RINOK(SzReadNumber(sd, &value64)); - if (value64 >= 0x80000000) - return SZ_ERROR_UNSUPPORTED; - if (value64 >= ((uint64_t)(1) << ((sizeof(size_t) - 1) * 8 + 2))) - return SZ_ERROR_UNSUPPORTED; - *value = (uint32_t)value64; - return SZ_OK; -} - -static SRes SzReadID(CSzData *sd, uint64_t *value) -{ - return SzReadNumber(sd, value); -} - -static SRes SzSkeepDataSize(CSzData *sd, uint64_t size) -{ - if (size > sd->Size) - return SZ_ERROR_ARCHIVE; - sd->Size -= (size_t)size; - sd->Data += (size_t)size; - return SZ_OK; -} - -static SRes SzSkeepData(CSzData *sd) -{ - uint64_t size; - RINOK(SzReadNumber(sd, &size)); - return SzSkeepDataSize(sd, size); -} - -static SRes SzReadArchiveProperties(CSzData *sd) -{ - for (;;) - { - uint64_t type; - RINOK(SzReadID(sd, &type)); - if (type == k7zIdEnd) - break; - SzSkeepData(sd); - } - return SZ_OK; -} - -static SRes SzWaitAttribute(CSzData *sd, uint64_t attribute) -{ - for (;;) - { - uint64_t type; - RINOK(SzReadID(sd, &type)); - if (type == attribute) - return SZ_OK; - if (type == k7zIdEnd) - return SZ_ERROR_ARCHIVE; - RINOK(SzSkeepData(sd)); - } -} - -static SRes SzReadBoolVector(CSzData *sd, size_t numItems, uint8_t **v, ISzAlloc *alloc) -{ - uint8_t b = 0; - uint8_t mask = 0; - size_t i; - MY_ALLOC(uint8_t, *v, numItems, alloc); - for (i = 0; i < numItems; i++) - { - if (mask == 0) - { - RINOK(SzReaduint8_t(sd, &b)); - mask = 0x80; - } - (*v)[i] = (uint8_t)(((b & mask) != 0) ? 1 : 0); - mask >>= 1; - } - return SZ_OK; -} - -static SRes SzReadBoolVector2(CSzData *sd, size_t numItems, uint8_t **v, ISzAlloc *alloc) -{ - uint8_t allAreDefined; - size_t i; - RINOK(SzReaduint8_t(sd, &allAreDefined)); - if (allAreDefined == 0) - return SzReadBoolVector(sd, numItems, v, alloc); - MY_ALLOC(uint8_t, *v, numItems, alloc); - for (i = 0; i < numItems; i++) - (*v)[i] = 1; - return SZ_OK; -} - -static SRes SzReadHashDigests( - CSzData *sd, - size_t numItems, - uint8_t **digestsDefined, - uint32_t **digests, - ISzAlloc *alloc) -{ - size_t i; - RINOK(SzReadBoolVector2(sd, numItems, digestsDefined, alloc)); - MY_ALLOC(uint32_t, *digests, numItems, alloc); - for (i = 0; i < numItems; i++) - if ((*digestsDefined)[i]) - { - RINOK(SzReaduint32_t(sd, (*digests) + i)); - } - return SZ_OK; -} - -static SRes SzReadPackInfo( - CSzData *sd, - uint64_t *dataOffset, - uint32_t *numPackStreams, - uint64_t **packSizes, - uint8_t **packCRCsDefined, - uint32_t **packCRCs, - ISzAlloc *alloc) -{ - uint32_t i; - RINOK(SzReadNumber(sd, dataOffset)); - RINOK(SzReadNumber32(sd, numPackStreams)); - - RINOK(SzWaitAttribute(sd, k7zIdSize)); - - MY_ALLOC(uint64_t, *packSizes, (size_t)*numPackStreams, alloc); - - for (i = 0; i < *numPackStreams; i++) - { - RINOK(SzReadNumber(sd, (*packSizes) + i)); - } - - for (;;) - { - uint64_t type; - RINOK(SzReadID(sd, &type)); - if (type == k7zIdEnd) - break; - if (type == k7zIdCRC) - { - RINOK(SzReadHashDigests(sd, (size_t)*numPackStreams, packCRCsDefined, packCRCs, alloc)); - continue; - } - RINOK(SzSkeepData(sd)); - } - if (*packCRCsDefined == 0) - { - MY_ALLOC(uint8_t, *packCRCsDefined, (size_t)*numPackStreams, alloc); - MY_ALLOC(uint32_t, *packCRCs, (size_t)*numPackStreams, alloc); - for (i = 0; i < *numPackStreams; i++) - { - (*packCRCsDefined)[i] = 0; - (*packCRCs)[i] = 0; - } - } - return SZ_OK; -} - -static SRes SzReadSwitch(CSzData *sd) -{ - uint8_t external; - RINOK(SzReaduint8_t(sd, &external)); - return (external == 0) ? SZ_OK: SZ_ERROR_UNSUPPORTED; -} - -static SRes SzGetNextFolderItem(CSzData *sd, CSzFolder *folder, ISzAlloc *alloc) -{ - uint32_t numCoders, numBindPairs, numPackStreams, i; - uint32_t numInStreams = 0, numOutStreams = 0; - - RINOK(SzReadNumber32(sd, &numCoders)); - if (numCoders > NUM_FOLDER_CODERS_MAX) - return SZ_ERROR_UNSUPPORTED; - folder->NumCoders = numCoders; - - MY_ALLOC(CSzCoderInfo, folder->Coders, (size_t)numCoders, alloc); - - for (i = 0; i < numCoders; i++) - SzCoderInfo_Init(folder->Coders + i); - - for (i = 0; i < numCoders; i++) - { - uint8_t mainuint8_t; - CSzCoderInfo *coder = folder->Coders + i; - { - unsigned idSize, j; - uint8_t longID[15]; - RINOK(SzReaduint8_t(sd, &mainuint8_t)); - idSize = (unsigned)(mainuint8_t & 0xF); - RINOK(SzReaduint8_ts(sd, longID, idSize)); - if (idSize > sizeof(coder->MethodID)) - return SZ_ERROR_UNSUPPORTED; - coder->MethodID = 0; - for (j = 0; j < idSize; j++) - coder->MethodID |= (uint64_t)longID[idSize - 1 - j] << (8 * j); - - if ((mainuint8_t & 0x10) != 0) - { - RINOK(SzReadNumber32(sd, &coder->NumInStreams)); - RINOK(SzReadNumber32(sd, &coder->NumOutStreams)); - if (coder->NumInStreams > NUM_CODER_STREAMS_MAX || - coder->NumOutStreams > NUM_CODER_STREAMS_MAX) - return SZ_ERROR_UNSUPPORTED; - } - else - { - coder->NumInStreams = 1; - coder->NumOutStreams = 1; - } - if ((mainuint8_t & 0x20) != 0) - { - uint64_t propertiesSize = 0; - RINOK(SzReadNumber(sd, &propertiesSize)); - if (!Buf_Create(&coder->Props, (size_t)propertiesSize, alloc)) - return SZ_ERROR_MEM; - RINOK(SzReaduint8_ts(sd, coder->Props.data, (size_t)propertiesSize)); - } - } - while ((mainuint8_t & 0x80) != 0) - { - RINOK(SzReaduint8_t(sd, &mainuint8_t)); - RINOK(SzSkeepDataSize(sd, (mainuint8_t & 0xF))); - if ((mainuint8_t & 0x10) != 0) - { - uint32_t n; - RINOK(SzReadNumber32(sd, &n)); - RINOK(SzReadNumber32(sd, &n)); - } - if ((mainuint8_t & 0x20) != 0) - { - uint64_t propertiesSize = 0; - RINOK(SzReadNumber(sd, &propertiesSize)); - RINOK(SzSkeepDataSize(sd, propertiesSize)); - } - } - numInStreams += coder->NumInStreams; - numOutStreams += coder->NumOutStreams; - } - - if (numOutStreams == 0) - return SZ_ERROR_UNSUPPORTED; - - folder->NumBindPairs = numBindPairs = numOutStreams - 1; - MY_ALLOC(CSzBindPair, folder->BindPairs, (size_t)numBindPairs, alloc); - - for (i = 0; i < numBindPairs; i++) - { - CSzBindPair *bp = folder->BindPairs + i; - RINOK(SzReadNumber32(sd, &bp->InIndex)); - RINOK(SzReadNumber32(sd, &bp->OutIndex)); - } - - if (numInStreams < numBindPairs) - return SZ_ERROR_UNSUPPORTED; - - folder->NumPackStreams = numPackStreams = numInStreams - numBindPairs; - MY_ALLOC(uint32_t, folder->PackStreams, (size_t)numPackStreams, alloc); - - if (numPackStreams == 1) - { - for (i = 0; i < numInStreams ; i++) - if (SzFolder_FindBindPairForInStream(folder, i) < 0) - break; - if (i == numInStreams) - return SZ_ERROR_UNSUPPORTED; - folder->PackStreams[0] = i; - } - else - for (i = 0; i < numPackStreams; i++) - { - RINOK(SzReadNumber32(sd, folder->PackStreams + i)); - } - return SZ_OK; -} - -static SRes SzReadUnpackInfo( - CSzData *sd, - uint32_t *numFolders, - CSzFolder **folders, /* for alloc */ - ISzAlloc *alloc, - ISzAlloc *allocTemp) -{ - uint32_t i; - RINOK(SzWaitAttribute(sd, k7zIdFolder)); - RINOK(SzReadNumber32(sd, numFolders)); - { - RINOK(SzReadSwitch(sd)); - - MY_ALLOC(CSzFolder, *folders, (size_t)*numFolders, alloc); - - for (i = 0; i < *numFolders; i++) - SzFolder_Init((*folders) + i); - - for (i = 0; i < *numFolders; i++) - { - RINOK(SzGetNextFolderItem(sd, (*folders) + i, alloc)); - } - } - - RINOK(SzWaitAttribute(sd, k7zIdCodersUnpackSize)); - - for (i = 0; i < *numFolders; i++) - { - uint32_t j; - CSzFolder *folder = (*folders) + i; - uint32_t numOutStreams = SzFolder_GetNumOutStreams(folder); - - MY_ALLOC(uint64_t, folder->UnpackSizes, (size_t)numOutStreams, alloc); - - for (j = 0; j < numOutStreams; j++) - { - RINOK(SzReadNumber(sd, folder->UnpackSizes + j)); - } - } - - for (;;) - { - uint64_t type; - RINOK(SzReadID(sd, &type)); - if (type == k7zIdEnd) - return SZ_OK; - if (type == k7zIdCRC) - { - SRes res; - uint8_t *crcsDefined = 0; - uint32_t *crcs = 0; - res = SzReadHashDigests(sd, *numFolders, &crcsDefined, &crcs, allocTemp); - if (res == SZ_OK) - { - for (i = 0; i < *numFolders; i++) - { - CSzFolder *folder = (*folders) + i; - folder->UnpackCRCDefined = crcsDefined[i]; - folder->UnpackCRC = crcs[i]; - } - } - IAlloc_Free(allocTemp, crcs); - IAlloc_Free(allocTemp, crcsDefined); - RINOK(res); - continue; - } - RINOK(SzSkeepData(sd)); - } -} - -static SRes SzReadSubStreamsInfo( - CSzData *sd, - uint32_t numFolders, - CSzFolder *folders, - uint32_t *numUnpackStreams, - uint64_t **unpackSizes, - uint8_t **digestsDefined, - uint32_t **digests, - ISzAlloc *allocTemp) -{ - uint64_t type = 0; - uint32_t i; - uint32_t si = 0; - uint32_t numDigests = 0; - - for (i = 0; i < numFolders; i++) - folders[i].NumUnpackStreams = 1; - *numUnpackStreams = numFolders; - - for (;;) - { - RINOK(SzReadID(sd, &type)); - if (type == k7zIdNumUnpackStream) - { - *numUnpackStreams = 0; - for (i = 0; i < numFolders; i++) - { - uint32_t numStreams; - RINOK(SzReadNumber32(sd, &numStreams)); - folders[i].NumUnpackStreams = numStreams; - *numUnpackStreams += numStreams; - } - continue; - } - if (type == k7zIdCRC || type == k7zIdSize) - break; - if (type == k7zIdEnd) - break; - RINOK(SzSkeepData(sd)); - } - - if (*numUnpackStreams == 0) - { - *unpackSizes = 0; - *digestsDefined = 0; - *digests = 0; - } - else - { - *unpackSizes = (uint64_t *)IAlloc_Alloc(allocTemp, (size_t)*numUnpackStreams * sizeof(uint64_t)); - RINOM(*unpackSizes); - *digestsDefined = (uint8_t *)IAlloc_Alloc(allocTemp, (size_t)*numUnpackStreams * sizeof(uint8_t)); - RINOM(*digestsDefined); - *digests = (uint32_t *)IAlloc_Alloc(allocTemp, (size_t)*numUnpackStreams * sizeof(uint32_t)); - RINOM(*digests); - } - - for (i = 0; i < numFolders; i++) - { - /* - v3.13 incorrectly worked with empty folders - v4.07: we check that folder is empty - */ - uint64_t sum = 0; - uint32_t j; - uint32_t numSubstreams = folders[i].NumUnpackStreams; - if (numSubstreams == 0) - continue; - if (type == k7zIdSize) - for (j = 1; j < numSubstreams; j++) - { - uint64_t size; - RINOK(SzReadNumber(sd, &size)); - (*unpackSizes)[si++] = size; - sum += size; - } - (*unpackSizes)[si++] = SzFolder_GetUnpackSize(folders + i) - sum; - } - if (type == k7zIdSize) - { - RINOK(SzReadID(sd, &type)); - } - - for (i = 0; i < *numUnpackStreams; i++) - { - (*digestsDefined)[i] = 0; - (*digests)[i] = 0; - } - - - for (i = 0; i < numFolders; i++) - { - uint32_t numSubstreams = folders[i].NumUnpackStreams; - if (numSubstreams != 1 || !folders[i].UnpackCRCDefined) - numDigests += numSubstreams; - } - - - si = 0; - for (;;) - { - if (type == k7zIdCRC) - { - int digestIndex = 0; - uint8_t *digestsDefined2 = 0; - uint32_t *digests2 = 0; - SRes res = SzReadHashDigests(sd, numDigests, &digestsDefined2, &digests2, allocTemp); - if (res == SZ_OK) - { - for (i = 0; i < numFolders; i++) - { - CSzFolder *folder = folders + i; - uint32_t numSubstreams = folder->NumUnpackStreams; - if (numSubstreams == 1 && folder->UnpackCRCDefined) - { - (*digestsDefined)[si] = 1; - (*digests)[si] = folder->UnpackCRC; - si++; - } - else - { - uint32_t j; - for (j = 0; j < numSubstreams; j++, digestIndex++) - { - (*digestsDefined)[si] = digestsDefined2[digestIndex]; - (*digests)[si] = digests2[digestIndex]; - si++; - } - } - } - } - IAlloc_Free(allocTemp, digestsDefined2); - IAlloc_Free(allocTemp, digests2); - RINOK(res); - } - else if (type == k7zIdEnd) - return SZ_OK; - else - { - RINOK(SzSkeepData(sd)); - } - RINOK(SzReadID(sd, &type)); - } -} - - -static SRes SzReadStreamsInfo( - CSzData *sd, - uint64_t *dataOffset, - CSzAr *p, - uint32_t *numUnpackStreams, - uint64_t **unpackSizes, /* allocTemp */ - uint8_t **digestsDefined, /* allocTemp */ - uint32_t **digests, /* allocTemp */ - ISzAlloc *alloc, - ISzAlloc *allocTemp) -{ - for (;;) - { - uint64_t type; - RINOK(SzReadID(sd, &type)); - if ((uint64_t)(int)type != type) - return SZ_ERROR_UNSUPPORTED; - switch((int)type) - { - case k7zIdEnd: - return SZ_OK; - case k7zIdPackInfo: - { - RINOK(SzReadPackInfo(sd, dataOffset, &p->NumPackStreams, - &p->PackSizes, &p->PackCRCsDefined, &p->PackCRCs, alloc)); - break; - } - case k7zIdUnpackInfo: - { - RINOK(SzReadUnpackInfo(sd, &p->NumFolders, &p->Folders, alloc, allocTemp)); - break; - } - case k7zIdSubStreamsInfo: - { - RINOK(SzReadSubStreamsInfo(sd, p->NumFolders, p->Folders, - numUnpackStreams, unpackSizes, digestsDefined, digests, allocTemp)); - break; - } - default: - return SZ_ERROR_UNSUPPORTED; - } - } -} - -size_t SzArEx_GetFileNameUtf16(const CSzArEx *p, size_t fileIndex, uint16_t *dest) -{ - size_t len = p->FileNameOffsets[fileIndex + 1] - p->FileNameOffsets[fileIndex]; - if (dest != 0) - { - size_t i; - const uint8_t *src = p->FileNames.data + (p->FileNameOffsets[fileIndex] * 2); - for (i = 0; i < len; i++) - dest[i] = GetUi16(src + i * 2); - } - return len; -} - -static SRes SzReadFileNames(const uint8_t *p, size_t size, uint32_t numFiles, size_t *sizes) -{ - uint32_t i; - size_t pos = 0; - for (i = 0; i < numFiles; i++) - { - sizes[i] = pos; - for (;;) - { - if (pos >= size) - return SZ_ERROR_ARCHIVE; - if (p[pos * 2] == 0 && p[pos * 2 + 1] == 0) - break; - pos++; - } - pos++; - } - sizes[i] = pos; - return (pos == size) ? SZ_OK : SZ_ERROR_ARCHIVE; -} - -static SRes SzReadHeader2( - CSzArEx *p, /* allocMain */ - CSzData *sd, - uint64_t **unpackSizes, /* allocTemp */ - uint8_t **digestsDefined, /* allocTemp */ - uint32_t **digests, /* allocTemp */ - uint8_t **emptyStreamVector, /* allocTemp */ - uint8_t **emptyFileVector, /* allocTemp */ - uint8_t **lwtVector, /* allocTemp */ - ISzAlloc *allocMain, - ISzAlloc *allocTemp) -{ - uint64_t type; - uint32_t numUnpackStreams = 0; - uint32_t numFiles = 0; - CSzFileItem *files = 0; - uint32_t numEmptyStreams = 0; - uint32_t i; - - RINOK(SzReadID(sd, &type)); - - if (type == k7zIdArchiveProperties) - { - RINOK(SzReadArchiveProperties(sd)); - RINOK(SzReadID(sd, &type)); - } - - - if (type == k7zIdMainStreamsInfo) - { - RINOK(SzReadStreamsInfo(sd, - &p->dataPos, - &p->db, - &numUnpackStreams, - unpackSizes, - digestsDefined, - digests, allocMain, allocTemp)); - p->dataPos += p->startPosAfterHeader; - RINOK(SzReadID(sd, &type)); - } - - if (type == k7zIdEnd) - return SZ_OK; - if (type != k7zIdFilesInfo) - return SZ_ERROR_ARCHIVE; - - RINOK(SzReadNumber32(sd, &numFiles)); - p->db.NumFiles = numFiles; - - MY_ALLOC(CSzFileItem, files, (size_t)numFiles, allocMain); - - p->db.Files = files; - for (i = 0; i < numFiles; i++) - SzFile_Init(files + i); - - for (;;) - { - uint64_t size; - RINOK(SzReadID(sd, &type)); - if (type == k7zIdEnd) - break; - RINOK(SzReadNumber(sd, &size)); - if (size > sd->Size) - return SZ_ERROR_ARCHIVE; - if ((uint64_t)(int)type != type) - { - RINOK(SzSkeepDataSize(sd, size)); - } - else - switch((int)type) - { - case k7zIdName: - { - size_t namesSize; - RINOK(SzReadSwitch(sd)); - namesSize = (size_t)size - 1; - if ((namesSize & 1) != 0) - return SZ_ERROR_ARCHIVE; - if (!Buf_Create(&p->FileNames, namesSize, allocMain)) - return SZ_ERROR_MEM; - MY_ALLOC(size_t, p->FileNameOffsets, numFiles + 1, allocMain); - memcpy(p->FileNames.data, sd->Data, namesSize); - RINOK(SzReadFileNames(sd->Data, namesSize >> 1, numFiles, p->FileNameOffsets)) - RINOK(SzSkeepDataSize(sd, namesSize)); - break; - } - case k7zIdEmptyStream: - { - RINOK(SzReadBoolVector(sd, numFiles, emptyStreamVector, allocTemp)); - numEmptyStreams = 0; - for (i = 0; i < numFiles; i++) - if ((*emptyStreamVector)[i]) - numEmptyStreams++; - break; - } - case k7zIdEmptyFile: - { - RINOK(SzReadBoolVector(sd, numEmptyStreams, emptyFileVector, allocTemp)); - break; - } - case k7zIdWinAttributes: - { - RINOK(SzReadBoolVector2(sd, numFiles, lwtVector, allocTemp)); - RINOK(SzReadSwitch(sd)); - for (i = 0; i < numFiles; i++) - { - CSzFileItem *f = &files[i]; - uint8_t defined = (*lwtVector)[i]; - f->AttribDefined = defined; - f->Attrib = 0; - if (defined) - { - RINOK(SzReaduint32_t(sd, &f->Attrib)); - } - } - IAlloc_Free(allocTemp, *lwtVector); - *lwtVector = NULL; - break; - } - case k7zIdMTime: - { - RINOK(SzReadBoolVector2(sd, numFiles, lwtVector, allocTemp)); - RINOK(SzReadSwitch(sd)); - for (i = 0; i < numFiles; i++) - { - CSzFileItem *f = &files[i]; - uint8_t defined = (*lwtVector)[i]; - f->MTimeDefined = defined; - f->MTime.Low = f->MTime.High = 0; - if (defined) - { - RINOK(SzReaduint32_t(sd, &f->MTime.Low)); - RINOK(SzReaduint32_t(sd, &f->MTime.High)); - } - } - IAlloc_Free(allocTemp, *lwtVector); - *lwtVector = NULL; - break; - } - default: - { - RINOK(SzSkeepDataSize(sd, size)); - } - } - } - - { - uint32_t emptyFileIndex = 0; - uint32_t sizeIndex = 0; - for (i = 0; i < numFiles; i++) - { - CSzFileItem *file = files + i; - file->IsAnti = 0; - if (*emptyStreamVector == 0) - file->HasStream = 1; - else - file->HasStream = (uint8_t)((*emptyStreamVector)[i] ? 0 : 1); - if (file->HasStream) - { - file->IsDir = 0; - file->Size = (*unpackSizes)[sizeIndex]; - file->Crc = (*digests)[sizeIndex]; - file->CrcDefined = (uint8_t)(*digestsDefined)[sizeIndex]; - sizeIndex++; - } - else - { - if (*emptyFileVector == 0) - file->IsDir = 1; - else - file->IsDir = (uint8_t)((*emptyFileVector)[emptyFileIndex] ? 0 : 1); - emptyFileIndex++; - file->Size = 0; - file->Crc = 0; - file->CrcDefined = 0; - } - } - } - return SzArEx_Fill(p, allocMain); -} - -static SRes SzReadHeader( - CSzArEx *p, - CSzData *sd, - ISzAlloc *allocMain, - ISzAlloc *allocTemp) -{ - uint64_t *unpackSizes = 0; - uint8_t *digestsDefined = 0; - uint32_t *digests = 0; - uint8_t *emptyStreamVector = 0; - uint8_t *emptyFileVector = 0; - uint8_t *lwtVector = 0; - SRes res = SzReadHeader2(p, sd, - &unpackSizes, &digestsDefined, &digests, - &emptyStreamVector, &emptyFileVector, &lwtVector, - allocMain, allocTemp); - IAlloc_Free(allocTemp, unpackSizes); - IAlloc_Free(allocTemp, digestsDefined); - IAlloc_Free(allocTemp, digests); - IAlloc_Free(allocTemp, emptyStreamVector); - IAlloc_Free(allocTemp, emptyFileVector); - IAlloc_Free(allocTemp, lwtVector); - return res; -} - -static SRes SzReadAndDecodePackedStreams2( - ILookInStream *inStream, - CSzData *sd, - CBuf *outBuffer, - uint64_t baseOffset, - CSzAr *p, - uint64_t **unpackSizes, - uint8_t **digestsDefined, - uint32_t **digests, - ISzAlloc *allocTemp) -{ - - uint32_t numUnpackStreams = 0; - uint64_t dataStartPos; - CSzFolder *folder; - uint64_t unpackSize; - SRes res; - - RINOK(SzReadStreamsInfo(sd, &dataStartPos, p, - &numUnpackStreams, unpackSizes, digestsDefined, digests, - allocTemp, allocTemp)); - - dataStartPos += baseOffset; - if (p->NumFolders != 1) - return SZ_ERROR_ARCHIVE; - - folder = p->Folders; - unpackSize = SzFolder_GetUnpackSize(folder); - - RINOK(LookInStream_SeekTo(inStream, dataStartPos)); - - if (!Buf_Create(outBuffer, (size_t)unpackSize, allocTemp)) - return SZ_ERROR_MEM; - - res = SzFolder_Decode(folder, p->PackSizes, - inStream, dataStartPos, - outBuffer->data, (size_t)unpackSize, allocTemp); - RINOK(res); - if (folder->UnpackCRCDefined) - if (CrcCalc(outBuffer->data, (size_t)unpackSize) != folder->UnpackCRC) - return SZ_ERROR_CRC; - return SZ_OK; -} - -static SRes SzReadAndDecodePackedStreams( - ILookInStream *inStream, - CSzData *sd, - CBuf *outBuffer, - uint64_t baseOffset, - ISzAlloc *allocTemp) -{ - CSzAr p; - uint64_t *unpackSizes = 0; - uint8_t *digestsDefined = 0; - uint32_t *digests = 0; - SRes res; - SzAr_Init(&p); - res = SzReadAndDecodePackedStreams2(inStream, sd, outBuffer, baseOffset, - &p, &unpackSizes, &digestsDefined, &digests, - allocTemp); - SzAr_Free(&p, allocTemp); - IAlloc_Free(allocTemp, unpackSizes); - IAlloc_Free(allocTemp, digestsDefined); - IAlloc_Free(allocTemp, digests); - return res; -} - -static SRes SzArEx_Open2( - CSzArEx *p, - ILookInStream *inStream, - ISzAlloc *allocMain, - ISzAlloc *allocTemp) -{ - uint8_t header[k7zStartHeaderSize]; - int64_t startArcPos; - uint64_t nextHeaderOffset, nextHeaderSize; - size_t nextHeaderSizeT; - uint32_t nextHeaderCRC; - CBuf buffer; - SRes res; - - startArcPos = 0; - RINOK(inStream->Seek(inStream, &startArcPos, SZ_SEEK_CUR)); - - RINOK(LookInStream_Read2(inStream, header, k7zStartHeaderSize, SZ_ERROR_NO_ARCHIVE)); - - if (!TestSignatureCandidate(header)) - return SZ_ERROR_NO_ARCHIVE; - if (header[6] != k7zMajorVersion) - return SZ_ERROR_UNSUPPORTED; - - nextHeaderOffset = GetUi64(header + 12); - nextHeaderSize = GetUi64(header + 20); - nextHeaderCRC = GetUi32(header + 28); - - p->startPosAfterHeader = startArcPos + k7zStartHeaderSize; - - if (CrcCalc(header + 12, 20) != GetUi32(header + 8)) - return SZ_ERROR_CRC; - - nextHeaderSizeT = (size_t)nextHeaderSize; - if (nextHeaderSizeT != nextHeaderSize) - return SZ_ERROR_MEM; - if (nextHeaderSizeT == 0) - return SZ_OK; - if (nextHeaderOffset > nextHeaderOffset + nextHeaderSize || - nextHeaderOffset > nextHeaderOffset + nextHeaderSize + k7zStartHeaderSize) - return SZ_ERROR_NO_ARCHIVE; - - { - int64_t pos = 0; - RINOK(inStream->Seek(inStream, &pos, SZ_SEEK_END)); - if ((uint64_t)pos < startArcPos + nextHeaderOffset || - (uint64_t)pos < startArcPos + k7zStartHeaderSize + nextHeaderOffset || - (uint64_t)pos < startArcPos + k7zStartHeaderSize + nextHeaderOffset + nextHeaderSize) - return SZ_ERROR_INPUT_EOF; - } - - RINOK(LookInStream_SeekTo(inStream, startArcPos + k7zStartHeaderSize + nextHeaderOffset)); - - if (!Buf_Create(&buffer, nextHeaderSizeT, allocTemp)) - return SZ_ERROR_MEM; - - res = LookInStream_Read(inStream, buffer.data, nextHeaderSizeT); - if (res == SZ_OK) - { - res = SZ_ERROR_ARCHIVE; - if (CrcCalc(buffer.data, nextHeaderSizeT) == nextHeaderCRC) - { - CSzData sd; - uint64_t type; - sd.Data = buffer.data; - sd.Size = buffer.size; - res = SzReadID(&sd, &type); - if (res == SZ_OK) - { - if (type == k7zIdEncodedHeader) - { - CBuf outBuffer; - Buf_Init(&outBuffer); - res = SzReadAndDecodePackedStreams(inStream, &sd, &outBuffer, p->startPosAfterHeader, allocTemp); - if (res != SZ_OK) - Buf_Free(&outBuffer, allocTemp); - else - { - Buf_Free(&buffer, allocTemp); - buffer.data = outBuffer.data; - buffer.size = outBuffer.size; - sd.Data = buffer.data; - sd.Size = buffer.size; - res = SzReadID(&sd, &type); - } - } - } - if (res == SZ_OK) - { - if (type == k7zIdHeader) - res = SzReadHeader(p, &sd, allocMain, allocTemp); - else - res = SZ_ERROR_UNSUPPORTED; - } - } - } - Buf_Free(&buffer, allocTemp); - return res; -} - -SRes SzArEx_Open(CSzArEx *p, ILookInStream *inStream, ISzAlloc *allocMain, ISzAlloc *allocTemp) -{ - SRes res = SzArEx_Open2(p, inStream, allocMain, allocTemp); - if (res != SZ_OK) - SzArEx_Free(p, allocMain); - return res; -} - -SRes SzArEx_Extract( - const CSzArEx *p, - ILookInStream *inStream, - uint32_t fileIndex, - uint32_t *blockIndex, - uint8_t **outBuffer, - size_t *outBufferSize, - size_t *offset, - size_t *outSizeProcessed, - ISzAlloc *allocMain, - ISzAlloc *allocTemp) -{ - uint32_t folderIndex = p->FileIndexToFolderIndexMap[fileIndex]; - SRes res = SZ_OK; - *offset = 0; - *outSizeProcessed = 0; - if (folderIndex == (uint32_t)-1) - { - IAlloc_Free(allocMain, *outBuffer); - *blockIndex = folderIndex; - *outBuffer = 0; - *outBufferSize = 0; - return SZ_OK; - } - - if (*outBuffer == 0 || *blockIndex != folderIndex) - { - CSzFolder *folder = p->db.Folders + folderIndex; - uint64_t unpackSizeSpec = SzFolder_GetUnpackSize(folder); - size_t unpackSize = (size_t)unpackSizeSpec; - uint64_t startOffset = SzArEx_GetFolderStreamPos(p, folderIndex, 0); - - if (unpackSize != unpackSizeSpec) - return SZ_ERROR_MEM; - *blockIndex = folderIndex; - IAlloc_Free(allocMain, *outBuffer); - *outBuffer = 0; - - RINOK(LookInStream_SeekTo(inStream, startOffset)); - - if (res == SZ_OK) - { - *outBufferSize = unpackSize; - if (unpackSize != 0) - { - *outBuffer = (uint8_t *)IAlloc_Alloc(allocMain, unpackSize); - if (*outBuffer == 0) - res = SZ_ERROR_MEM; - } - if (res == SZ_OK) - { - res = SzFolder_Decode(folder, - p->db.PackSizes + p->FolderStartPackStreamIndex[folderIndex], - inStream, startOffset, - *outBuffer, unpackSize, allocTemp); - if (res == SZ_OK) - { - if (folder->UnpackCRCDefined) - { - if (CrcCalc(*outBuffer, unpackSize) != folder->UnpackCRC) - res = SZ_ERROR_CRC; - } - } - } - } - } - if (res == SZ_OK) - { - uint32_t i; - CSzFileItem *fileItem = p->db.Files + fileIndex; - *offset = 0; - for (i = p->FolderStartFileIndex[folderIndex]; i < fileIndex; i++) - *offset += (uint32_t)p->db.Files[i].Size; - *outSizeProcessed = (size_t)fileItem->Size; - if (*offset + *outSizeProcessed > *outBufferSize) - return SZ_ERROR_FAIL; - if (fileItem->CrcDefined && CrcCalc(*outBuffer + *offset, *outSizeProcessed) != fileItem->Crc) - res = SZ_ERROR_CRC; - } - return res; -} +/* 7zIn.c -- 7z Input functions + 2010-10-29 : Igor Pavlov : Public domain */ + +#include +#include + +#include "7z.h" +#include "7zCrc.h" +#include "CpuArch.h" + +uint8_t k7zSignature[k7zSignatureSize] = {'7', 'z', 0xBC, 0xAF, 0x27, 0x1C}; + +#define RINOM(x) { if ((x) == 0) return SZ_ERROR_MEM; } + +#define NUM_FOLDER_CODERS_MAX 32 +#define NUM_CODER_STREAMS_MAX 32 + +void SzFolder_Free(CSzFolder *p, ISzAlloc *alloc); +int SzFolder_FindBindPairForOutStream(CSzFolder *p, uint32_t outStreamIndex); + +void SzCoderInfo_Init(CSzCoderInfo *p) +{ + Buf_Init(&p->Props); +} + +void SzCoderInfo_Free(CSzCoderInfo *p, ISzAlloc *alloc) +{ + Buf_Free(&p->Props, alloc); + SzCoderInfo_Init(p); +} + +void SzFolder_Init(CSzFolder *p) +{ + p->Coders = 0; + p->BindPairs = 0; + p->PackStreams = 0; + p->UnpackSizes = 0; + p->NumCoders = 0; + p->NumBindPairs = 0; + p->NumPackStreams = 0; + p->UnpackCRCDefined = 0; + p->UnpackCRC = 0; + p->NumUnpackStreams = 0; +} + +void SzFolder_Free(CSzFolder *p, ISzAlloc *alloc) +{ + uint32_t i; + if (p->Coders) + for (i = 0; i < p->NumCoders; i++) + SzCoderInfo_Free(&p->Coders[i], alloc); + IAlloc_Free(alloc, p->Coders); + IAlloc_Free(alloc, p->BindPairs); + IAlloc_Free(alloc, p->PackStreams); + IAlloc_Free(alloc, p->UnpackSizes); + SzFolder_Init(p); +} + +uint32_t SzFolder_GetNumOutStreams(CSzFolder *p) +{ + uint32_t result = 0; + uint32_t i; + for (i = 0; i < p->NumCoders; i++) + result += p->Coders[i].NumOutStreams; + return result; +} + +int SzFolder_FindBindPairForInStream(CSzFolder *p, uint32_t inStreamIndex) +{ + uint32_t i; + for (i = 0; i < p->NumBindPairs; i++) + if (p->BindPairs[i].InIndex == inStreamIndex) + return i; + return -1; +} + + +int SzFolder_FindBindPairForOutStream(CSzFolder *p, uint32_t outStreamIndex) +{ + uint32_t i; + for (i = 0; i < p->NumBindPairs; i++) + if (p->BindPairs[i].OutIndex == outStreamIndex) + return i; + return -1; +} + +uint64_t SzFolder_GetUnpackSize(CSzFolder *p) +{ + int i = (int)SzFolder_GetNumOutStreams(p); + if (i == 0) + return 0; + for (i--; i >= 0; i--) + if (SzFolder_FindBindPairForOutStream(p, i) < 0) + return p->UnpackSizes[i]; + /* throw 1; */ + return 0; +} + +void SzFile_Init(CSzFileItem *p) +{ + p->HasStream = 1; + p->IsDir = 0; + p->IsAnti = 0; + p->CrcDefined = 0; + p->MTimeDefined = 0; +} + +void SzAr_Init(CSzAr *p) +{ + p->PackSizes = 0; + p->PackCRCsDefined = 0; + p->PackCRCs = 0; + p->Folders = 0; + p->Files = 0; + p->NumPackStreams = 0; + p->NumFolders = 0; + p->NumFiles = 0; +} + +void SzAr_Free(CSzAr *p, ISzAlloc *alloc) +{ + uint32_t i; + if (p->Folders) + for (i = 0; i < p->NumFolders; i++) + SzFolder_Free(&p->Folders[i], alloc); + + IAlloc_Free(alloc, p->PackSizes); + IAlloc_Free(alloc, p->PackCRCsDefined); + IAlloc_Free(alloc, p->PackCRCs); + IAlloc_Free(alloc, p->Folders); + IAlloc_Free(alloc, p->Files); + SzAr_Init(p); +} + + +void SzArEx_Init(CSzArEx *p) +{ + SzAr_Init(&p->db); + p->FolderStartPackStreamIndex = 0; + p->PackStreamStartPositions = 0; + p->FolderStartFileIndex = 0; + p->FileIndexToFolderIndexMap = 0; + p->FileNameOffsets = 0; + Buf_Init(&p->FileNames); +} + +void SzArEx_Free(CSzArEx *p, ISzAlloc *alloc) +{ + IAlloc_Free(alloc, p->FolderStartPackStreamIndex); + IAlloc_Free(alloc, p->PackStreamStartPositions); + IAlloc_Free(alloc, p->FolderStartFileIndex); + IAlloc_Free(alloc, p->FileIndexToFolderIndexMap); + + IAlloc_Free(alloc, p->FileNameOffsets); + Buf_Free(&p->FileNames, alloc); + + SzAr_Free(&p->db, alloc); + SzArEx_Init(p); +} + +/* + uint64_t GetFolderPackStreamSize(int folderIndex, int streamIndex) const + { + return PackSizes[FolderStartPackStreamIndex[folderIndex] + streamIndex]; + } + + uint64_t GetFilePackSize(int fileIndex) const + { + int folderIndex = FileIndexToFolderIndexMap[fileIndex]; + if (folderIndex >= 0) + { + const CSzFolder &folderInfo = Folders[folderIndex]; + if (FolderStartFileIndex[folderIndex] == fileIndex) + return GetFolderFullPackSize(folderIndex); + } + return 0; + } + */ + +#define MY_ALLOC(T, p, size, alloc) { if ((size) == 0) p = 0; else \ + if ((p = (T *)IAlloc_Alloc(alloc, (size) * sizeof(T))) == 0) return SZ_ERROR_MEM; } + +static SRes SzArEx_Fill(CSzArEx *p, ISzAlloc *alloc) +{ + uint32_t startPos = 0; + uint64_t startPosSize = 0; + uint32_t i; + uint32_t folderIndex = 0; + uint32_t indexInFolder = 0; + MY_ALLOC(uint32_t, p->FolderStartPackStreamIndex, p->db.NumFolders, alloc); + for (i = 0; i < p->db.NumFolders; i++) + { + p->FolderStartPackStreamIndex[i] = startPos; + startPos += p->db.Folders[i].NumPackStreams; + } + + MY_ALLOC(uint64_t, p->PackStreamStartPositions, p->db.NumPackStreams, alloc); + + for (i = 0; i < p->db.NumPackStreams; i++) + { + p->PackStreamStartPositions[i] = startPosSize; + startPosSize += p->db.PackSizes[i]; + } + + MY_ALLOC(uint32_t, p->FolderStartFileIndex, p->db.NumFolders, alloc); + MY_ALLOC(uint32_t, p->FileIndexToFolderIndexMap, p->db.NumFiles, alloc); + + for (i = 0; i < p->db.NumFiles; i++) + { + CSzFileItem *file = p->db.Files + i; + int emptyStream = !file->HasStream; + if (emptyStream && indexInFolder == 0) + { + p->FileIndexToFolderIndexMap[i] = (uint32_t)-1; + continue; + } + if (indexInFolder == 0) + { + /* + v3.13 incorrectly worked with empty folders + v4.07: Loop for skipping empty folders + */ + for (;;) + { + if (folderIndex >= p->db.NumFolders) + return SZ_ERROR_ARCHIVE; + p->FolderStartFileIndex[folderIndex] = i; + if (p->db.Folders[folderIndex].NumUnpackStreams != 0) + break; + folderIndex++; + } + } + p->FileIndexToFolderIndexMap[i] = folderIndex; + if (emptyStream) + continue; + indexInFolder++; + if (indexInFolder >= p->db.Folders[folderIndex].NumUnpackStreams) + { + folderIndex++; + indexInFolder = 0; + } + } + return SZ_OK; +} + + +uint64_t SzArEx_GetFolderStreamPos(const CSzArEx *p, uint32_t folderIndex, uint32_t indexInFolder) +{ + return p->dataPos + + p->PackStreamStartPositions[p->FolderStartPackStreamIndex[folderIndex] + indexInFolder]; +} + +int SzArEx_GetFolderFullPackSize(const CSzArEx *p, uint32_t folderIndex, uint64_t *resSize) +{ + uint32_t packStreamIndex = p->FolderStartPackStreamIndex[folderIndex]; + CSzFolder *folder = p->db.Folders + folderIndex; + uint64_t size = 0; + uint32_t i; + for (i = 0; i < folder->NumPackStreams; i++) + { + uint64_t t = size + p->db.PackSizes[packStreamIndex + i]; + if (t < size) /* check it */ + return SZ_ERROR_FAIL; + size = t; + } + *resSize = size; + return SZ_OK; +} + + +static int TestSignatureCandidate(uint8_t *testuint8_ts) +{ + size_t i; + for (i = 0; i < k7zSignatureSize; i++) + if (testuint8_ts[i] != k7zSignature[i]) + return 0; + return 1; +} + +typedef struct _CSzState +{ + uint8_t *Data; + size_t Size; +}CSzData; + +static SRes SzReaduint8_t(CSzData *sd, uint8_t *b) +{ + if (sd->Size == 0) + return SZ_ERROR_ARCHIVE; + sd->Size--; + *b = *sd->Data++; + return SZ_OK; +} + +static SRes SzReaduint8_ts(CSzData *sd, uint8_t *data, size_t size) +{ + size_t i; + for (i = 0; i < size; i++) + { + RINOK(SzReaduint8_t(sd, data + i)); + } + return SZ_OK; +} + +static SRes SzReaduint32_t(CSzData *sd, uint32_t *value) +{ + int i; + *value = 0; + for (i = 0; i < 4; i++) + { + uint8_t b; + RINOK(SzReaduint8_t(sd, &b)); + *value |= ((uint32_t)(b) << (8 * i)); + } + return SZ_OK; +} + +static SRes SzReadNumber(CSzData *sd, uint64_t *value) +{ + uint8_t firstuint8_t; + uint8_t mask = 0x80; + int i; + RINOK(SzReaduint8_t(sd, &firstuint8_t)); + *value = 0; + for (i = 0; i < 8; i++) + { + uint8_t b; + if ((firstuint8_t & mask) == 0) + { + uint64_t highPart = firstuint8_t & (mask - 1); + *value += (highPart << (8 * i)); + return SZ_OK; + } + RINOK(SzReaduint8_t(sd, &b)); + *value |= ((uint64_t)b << (8 * i)); + mask >>= 1; + } + return SZ_OK; +} + +static SRes SzReadNumber32(CSzData *sd, uint32_t *value) +{ + uint64_t value64; + RINOK(SzReadNumber(sd, &value64)); + if (value64 >= 0x80000000) + return SZ_ERROR_UNSUPPORTED; + if (value64 >= ((uint64_t)(1) << ((sizeof(size_t) - 1) * 8 + 2))) + return SZ_ERROR_UNSUPPORTED; + *value = (uint32_t)value64; + return SZ_OK; +} + +static SRes SzReadID(CSzData *sd, uint64_t *value) +{ + return SzReadNumber(sd, value); +} + +static SRes SzSkeepDataSize(CSzData *sd, uint64_t size) +{ + if (size > sd->Size) + return SZ_ERROR_ARCHIVE; + sd->Size -= (size_t)size; + sd->Data += (size_t)size; + return SZ_OK; +} + +static SRes SzSkeepData(CSzData *sd) +{ + uint64_t size; + RINOK(SzReadNumber(sd, &size)); + return SzSkeepDataSize(sd, size); +} + +static SRes SzReadArchiveProperties(CSzData *sd) +{ + for (;;) + { + uint64_t type; + RINOK(SzReadID(sd, &type)); + if (type == k7zIdEnd) + break; + SzSkeepData(sd); + } + return SZ_OK; +} + +static SRes SzWaitAttribute(CSzData *sd, uint64_t attribute) +{ + for (;;) + { + uint64_t type; + RINOK(SzReadID(sd, &type)); + if (type == attribute) + return SZ_OK; + if (type == k7zIdEnd) + return SZ_ERROR_ARCHIVE; + RINOK(SzSkeepData(sd)); + } +} + +static SRes SzReadBoolVector(CSzData *sd, size_t numItems, uint8_t **v, ISzAlloc *alloc) +{ + uint8_t b = 0; + uint8_t mask = 0; + size_t i; + MY_ALLOC(uint8_t, *v, numItems, alloc); + for (i = 0; i < numItems; i++) + { + if (mask == 0) + { + RINOK(SzReaduint8_t(sd, &b)); + mask = 0x80; + } + (*v)[i] = (uint8_t)(((b & mask) != 0) ? 1 : 0); + mask >>= 1; + } + return SZ_OK; +} + +static SRes SzReadBoolVector2(CSzData *sd, size_t numItems, uint8_t **v, ISzAlloc *alloc) +{ + uint8_t allAreDefined; + size_t i; + RINOK(SzReaduint8_t(sd, &allAreDefined)); + if (allAreDefined == 0) + return SzReadBoolVector(sd, numItems, v, alloc); + MY_ALLOC(uint8_t, *v, numItems, alloc); + for (i = 0; i < numItems; i++) + (*v)[i] = 1; + return SZ_OK; +} + +static SRes SzReadHashDigests( + CSzData *sd, + size_t numItems, + uint8_t **digestsDefined, + uint32_t **digests, + ISzAlloc *alloc) +{ + size_t i; + RINOK(SzReadBoolVector2(sd, numItems, digestsDefined, alloc)); + MY_ALLOC(uint32_t, *digests, numItems, alloc); + for (i = 0; i < numItems; i++) + if ((*digestsDefined)[i]) + { + RINOK(SzReaduint32_t(sd, (*digests) + i)); + } + return SZ_OK; +} + +static SRes SzReadPackInfo( + CSzData *sd, + uint64_t *dataOffset, + uint32_t *numPackStreams, + uint64_t **packSizes, + uint8_t **packCRCsDefined, + uint32_t **packCRCs, + ISzAlloc *alloc) +{ + uint32_t i; + RINOK(SzReadNumber(sd, dataOffset)); + RINOK(SzReadNumber32(sd, numPackStreams)); + + RINOK(SzWaitAttribute(sd, k7zIdSize)); + + MY_ALLOC(uint64_t, *packSizes, (size_t)*numPackStreams, alloc); + + for (i = 0; i < *numPackStreams; i++) + { + RINOK(SzReadNumber(sd, (*packSizes) + i)); + } + + for (;;) + { + uint64_t type; + RINOK(SzReadID(sd, &type)); + if (type == k7zIdEnd) + break; + if (type == k7zIdCRC) + { + RINOK(SzReadHashDigests(sd, (size_t)*numPackStreams, packCRCsDefined, packCRCs, alloc)); + continue; + } + RINOK(SzSkeepData(sd)); + } + if (*packCRCsDefined == 0) + { + MY_ALLOC(uint8_t, *packCRCsDefined, (size_t)*numPackStreams, alloc); + MY_ALLOC(uint32_t, *packCRCs, (size_t)*numPackStreams, alloc); + for (i = 0; i < *numPackStreams; i++) + { + (*packCRCsDefined)[i] = 0; + (*packCRCs)[i] = 0; + } + } + return SZ_OK; +} + +static SRes SzReadSwitch(CSzData *sd) +{ + uint8_t external; + RINOK(SzReaduint8_t(sd, &external)); + return (external == 0) ? SZ_OK: SZ_ERROR_UNSUPPORTED; +} + +static SRes SzGetNextFolderItem(CSzData *sd, CSzFolder *folder, ISzAlloc *alloc) +{ + uint32_t numCoders, numBindPairs, numPackStreams, i; + uint32_t numInStreams = 0, numOutStreams = 0; + + RINOK(SzReadNumber32(sd, &numCoders)); + if (numCoders > NUM_FOLDER_CODERS_MAX) + return SZ_ERROR_UNSUPPORTED; + folder->NumCoders = numCoders; + + MY_ALLOC(CSzCoderInfo, folder->Coders, (size_t)numCoders, alloc); + + for (i = 0; i < numCoders; i++) + SzCoderInfo_Init(folder->Coders + i); + + for (i = 0; i < numCoders; i++) + { + uint8_t mainuint8_t; + CSzCoderInfo *coder = folder->Coders + i; + { + unsigned idSize, j; + uint8_t longID[15]; + RINOK(SzReaduint8_t(sd, &mainuint8_t)); + idSize = (unsigned)(mainuint8_t & 0xF); + RINOK(SzReaduint8_ts(sd, longID, idSize)); + if (idSize > sizeof(coder->MethodID)) + return SZ_ERROR_UNSUPPORTED; + coder->MethodID = 0; + for (j = 0; j < idSize; j++) + coder->MethodID |= (uint64_t)longID[idSize - 1 - j] << (8 * j); + + if ((mainuint8_t & 0x10) != 0) + { + RINOK(SzReadNumber32(sd, &coder->NumInStreams)); + RINOK(SzReadNumber32(sd, &coder->NumOutStreams)); + if (coder->NumInStreams > NUM_CODER_STREAMS_MAX || + coder->NumOutStreams > NUM_CODER_STREAMS_MAX) + return SZ_ERROR_UNSUPPORTED; + } + else + { + coder->NumInStreams = 1; + coder->NumOutStreams = 1; + } + if ((mainuint8_t & 0x20) != 0) + { + uint64_t propertiesSize = 0; + RINOK(SzReadNumber(sd, &propertiesSize)); + if (!Buf_Create(&coder->Props, (size_t)propertiesSize, alloc)) + return SZ_ERROR_MEM; + RINOK(SzReaduint8_ts(sd, coder->Props.data, (size_t)propertiesSize)); + } + } + while ((mainuint8_t & 0x80) != 0) + { + RINOK(SzReaduint8_t(sd, &mainuint8_t)); + RINOK(SzSkeepDataSize(sd, (mainuint8_t & 0xF))); + if ((mainuint8_t & 0x10) != 0) + { + uint32_t n; + RINOK(SzReadNumber32(sd, &n)); + RINOK(SzReadNumber32(sd, &n)); + } + if ((mainuint8_t & 0x20) != 0) + { + uint64_t propertiesSize = 0; + RINOK(SzReadNumber(sd, &propertiesSize)); + RINOK(SzSkeepDataSize(sd, propertiesSize)); + } + } + numInStreams += coder->NumInStreams; + numOutStreams += coder->NumOutStreams; + } + + if (numOutStreams == 0) + return SZ_ERROR_UNSUPPORTED; + + folder->NumBindPairs = numBindPairs = numOutStreams - 1; + MY_ALLOC(CSzBindPair, folder->BindPairs, (size_t)numBindPairs, alloc); + + for (i = 0; i < numBindPairs; i++) + { + CSzBindPair *bp = folder->BindPairs + i; + RINOK(SzReadNumber32(sd, &bp->InIndex)); + RINOK(SzReadNumber32(sd, &bp->OutIndex)); + } + + if (numInStreams < numBindPairs) + return SZ_ERROR_UNSUPPORTED; + + folder->NumPackStreams = numPackStreams = numInStreams - numBindPairs; + MY_ALLOC(uint32_t, folder->PackStreams, (size_t)numPackStreams, alloc); + + if (numPackStreams == 1) + { + for (i = 0; i < numInStreams ; i++) + if (SzFolder_FindBindPairForInStream(folder, i) < 0) + break; + if (i == numInStreams) + return SZ_ERROR_UNSUPPORTED; + folder->PackStreams[0] = i; + } + else + for (i = 0; i < numPackStreams; i++) + { + RINOK(SzReadNumber32(sd, folder->PackStreams + i)); + } + return SZ_OK; +} + +static SRes SzReadUnpackInfo( + CSzData *sd, + uint32_t *numFolders, + CSzFolder **folders, /* for alloc */ + ISzAlloc *alloc, + ISzAlloc *allocTemp) +{ + uint32_t i; + RINOK(SzWaitAttribute(sd, k7zIdFolder)); + RINOK(SzReadNumber32(sd, numFolders)); + { + RINOK(SzReadSwitch(sd)); + + MY_ALLOC(CSzFolder, *folders, (size_t)*numFolders, alloc); + + for (i = 0; i < *numFolders; i++) + SzFolder_Init((*folders) + i); + + for (i = 0; i < *numFolders; i++) + { + RINOK(SzGetNextFolderItem(sd, (*folders) + i, alloc)); + } + } + + RINOK(SzWaitAttribute(sd, k7zIdCodersUnpackSize)); + + for (i = 0; i < *numFolders; i++) + { + uint32_t j; + CSzFolder *folder = (*folders) + i; + uint32_t numOutStreams = SzFolder_GetNumOutStreams(folder); + + MY_ALLOC(uint64_t, folder->UnpackSizes, (size_t)numOutStreams, alloc); + + for (j = 0; j < numOutStreams; j++) + { + RINOK(SzReadNumber(sd, folder->UnpackSizes + j)); + } + } + + for (;;) + { + uint64_t type; + RINOK(SzReadID(sd, &type)); + if (type == k7zIdEnd) + return SZ_OK; + if (type == k7zIdCRC) + { + SRes res; + uint8_t *crcsDefined = 0; + uint32_t *crcs = 0; + res = SzReadHashDigests(sd, *numFolders, &crcsDefined, &crcs, allocTemp); + if (res == SZ_OK) + { + for (i = 0; i < *numFolders; i++) + { + CSzFolder *folder = (*folders) + i; + folder->UnpackCRCDefined = crcsDefined[i]; + folder->UnpackCRC = crcs[i]; + } + } + IAlloc_Free(allocTemp, crcs); + IAlloc_Free(allocTemp, crcsDefined); + RINOK(res); + continue; + } + RINOK(SzSkeepData(sd)); + } +} + +static SRes SzReadSubStreamsInfo( + CSzData *sd, + uint32_t numFolders, + CSzFolder *folders, + uint32_t *numUnpackStreams, + uint64_t **unpackSizes, + uint8_t **digestsDefined, + uint32_t **digests, + ISzAlloc *allocTemp) +{ + uint64_t type = 0; + uint32_t i; + uint32_t si = 0; + uint32_t numDigests = 0; + + for (i = 0; i < numFolders; i++) + folders[i].NumUnpackStreams = 1; + *numUnpackStreams = numFolders; + + for (;;) + { + RINOK(SzReadID(sd, &type)); + if (type == k7zIdNumUnpackStream) + { + *numUnpackStreams = 0; + for (i = 0; i < numFolders; i++) + { + uint32_t numStreams; + RINOK(SzReadNumber32(sd, &numStreams)); + folders[i].NumUnpackStreams = numStreams; + *numUnpackStreams += numStreams; + } + continue; + } + if (type == k7zIdCRC || type == k7zIdSize) + break; + if (type == k7zIdEnd) + break; + RINOK(SzSkeepData(sd)); + } + + if (*numUnpackStreams == 0) + { + *unpackSizes = 0; + *digestsDefined = 0; + *digests = 0; + } + else + { + *unpackSizes = (uint64_t *)IAlloc_Alloc(allocTemp, (size_t)*numUnpackStreams * sizeof(uint64_t)); + RINOM(*unpackSizes); + *digestsDefined = (uint8_t *)IAlloc_Alloc(allocTemp, (size_t)*numUnpackStreams * sizeof(uint8_t)); + RINOM(*digestsDefined); + *digests = (uint32_t *)IAlloc_Alloc(allocTemp, (size_t)*numUnpackStreams * sizeof(uint32_t)); + RINOM(*digests); + } + + for (i = 0; i < numFolders; i++) + { + /* + v3.13 incorrectly worked with empty folders + v4.07: we check that folder is empty + */ + uint64_t sum = 0; + uint32_t j; + uint32_t numSubstreams = folders[i].NumUnpackStreams; + if (numSubstreams == 0) + continue; + if (type == k7zIdSize) + for (j = 1; j < numSubstreams; j++) + { + uint64_t size; + RINOK(SzReadNumber(sd, &size)); + (*unpackSizes)[si++] = size; + sum += size; + } + (*unpackSizes)[si++] = SzFolder_GetUnpackSize(folders + i) - sum; + } + if (type == k7zIdSize) + { + RINOK(SzReadID(sd, &type)); + } + + for (i = 0; i < *numUnpackStreams; i++) + { + (*digestsDefined)[i] = 0; + (*digests)[i] = 0; + } + + + for (i = 0; i < numFolders; i++) + { + uint32_t numSubstreams = folders[i].NumUnpackStreams; + if (numSubstreams != 1 || !folders[i].UnpackCRCDefined) + numDigests += numSubstreams; + } + + + si = 0; + for (;;) + { + if (type == k7zIdCRC) + { + int digestIndex = 0; + uint8_t *digestsDefined2 = 0; + uint32_t *digests2 = 0; + SRes res = SzReadHashDigests(sd, numDigests, &digestsDefined2, &digests2, allocTemp); + if (res == SZ_OK) + { + for (i = 0; i < numFolders; i++) + { + CSzFolder *folder = folders + i; + uint32_t numSubstreams = folder->NumUnpackStreams; + if (numSubstreams == 1 && folder->UnpackCRCDefined) + { + (*digestsDefined)[si] = 1; + (*digests)[si] = folder->UnpackCRC; + si++; + } + else + { + uint32_t j; + for (j = 0; j < numSubstreams; j++, digestIndex++) + { + (*digestsDefined)[si] = digestsDefined2[digestIndex]; + (*digests)[si] = digests2[digestIndex]; + si++; + } + } + } + } + IAlloc_Free(allocTemp, digestsDefined2); + IAlloc_Free(allocTemp, digests2); + RINOK(res); + } + else if (type == k7zIdEnd) + return SZ_OK; + else + { + RINOK(SzSkeepData(sd)); + } + RINOK(SzReadID(sd, &type)); + } +} + + +static SRes SzReadStreamsInfo( + CSzData *sd, + uint64_t *dataOffset, + CSzAr *p, + uint32_t *numUnpackStreams, + uint64_t **unpackSizes, /* allocTemp */ + uint8_t **digestsDefined, /* allocTemp */ + uint32_t **digests, /* allocTemp */ + ISzAlloc *alloc, + ISzAlloc *allocTemp) +{ + for (;;) + { + uint64_t type; + RINOK(SzReadID(sd, &type)); + if ((uint64_t)(int)type != type) + return SZ_ERROR_UNSUPPORTED; + switch((int)type) + { + case k7zIdEnd: + return SZ_OK; + case k7zIdPackInfo: + { + RINOK(SzReadPackInfo(sd, dataOffset, &p->NumPackStreams, + &p->PackSizes, &p->PackCRCsDefined, &p->PackCRCs, alloc)); + break; + } + case k7zIdUnpackInfo: + { + RINOK(SzReadUnpackInfo(sd, &p->NumFolders, &p->Folders, alloc, allocTemp)); + break; + } + case k7zIdSubStreamsInfo: + { + RINOK(SzReadSubStreamsInfo(sd, p->NumFolders, p->Folders, + numUnpackStreams, unpackSizes, digestsDefined, digests, allocTemp)); + break; + } + default: + return SZ_ERROR_UNSUPPORTED; + } + } +} + +size_t SzArEx_GetFileNameUtf16(const CSzArEx *p, size_t fileIndex, uint16_t *dest) +{ + size_t len = p->FileNameOffsets[fileIndex + 1] - p->FileNameOffsets[fileIndex]; + if (dest != 0) + { + size_t i; + const uint8_t *src = p->FileNames.data + (p->FileNameOffsets[fileIndex] * 2); + for (i = 0; i < len; i++) + dest[i] = GetUi16(src + i * 2); + } + return len; +} + +static SRes SzReadFileNames(const uint8_t *p, size_t size, uint32_t numFiles, size_t *sizes) +{ + uint32_t i; + size_t pos = 0; + for (i = 0; i < numFiles; i++) + { + sizes[i] = pos; + for (;;) + { + if (pos >= size) + return SZ_ERROR_ARCHIVE; + if (p[pos * 2] == 0 && p[pos * 2 + 1] == 0) + break; + pos++; + } + pos++; + } + sizes[i] = pos; + return (pos == size) ? SZ_OK : SZ_ERROR_ARCHIVE; +} + +static SRes SzReadHeader2( + CSzArEx *p, /* allocMain */ + CSzData *sd, + uint64_t **unpackSizes, /* allocTemp */ + uint8_t **digestsDefined, /* allocTemp */ + uint32_t **digests, /* allocTemp */ + uint8_t **emptyStreamVector, /* allocTemp */ + uint8_t **emptyFileVector, /* allocTemp */ + uint8_t **lwtVector, /* allocTemp */ + ISzAlloc *allocMain, + ISzAlloc *allocTemp) +{ + uint64_t type; + uint32_t numUnpackStreams = 0; + uint32_t numFiles = 0; + CSzFileItem *files = 0; + uint32_t numEmptyStreams = 0; + uint32_t i; + + RINOK(SzReadID(sd, &type)); + + if (type == k7zIdArchiveProperties) + { + RINOK(SzReadArchiveProperties(sd)); + RINOK(SzReadID(sd, &type)); + } + + + if (type == k7zIdMainStreamsInfo) + { + RINOK(SzReadStreamsInfo(sd, + &p->dataPos, + &p->db, + &numUnpackStreams, + unpackSizes, + digestsDefined, + digests, allocMain, allocTemp)); + p->dataPos += p->startPosAfterHeader; + RINOK(SzReadID(sd, &type)); + } + + if (type == k7zIdEnd) + return SZ_OK; + if (type != k7zIdFilesInfo) + return SZ_ERROR_ARCHIVE; + + RINOK(SzReadNumber32(sd, &numFiles)); + p->db.NumFiles = numFiles; + + MY_ALLOC(CSzFileItem, files, (size_t)numFiles, allocMain); + + p->db.Files = files; + for (i = 0; i < numFiles; i++) + SzFile_Init(files + i); + + for (;;) + { + uint64_t size; + RINOK(SzReadID(sd, &type)); + if (type == k7zIdEnd) + break; + RINOK(SzReadNumber(sd, &size)); + if (size > sd->Size) + return SZ_ERROR_ARCHIVE; + if ((uint64_t)(int)type != type) + { + RINOK(SzSkeepDataSize(sd, size)); + } + else + switch((int)type) + { + case k7zIdName: + { + size_t namesSize; + RINOK(SzReadSwitch(sd)); + namesSize = (size_t)size - 1; + if ((namesSize & 1) != 0) + return SZ_ERROR_ARCHIVE; + if (!Buf_Create(&p->FileNames, namesSize, allocMain)) + return SZ_ERROR_MEM; + MY_ALLOC(size_t, p->FileNameOffsets, numFiles + 1, allocMain); + memcpy(p->FileNames.data, sd->Data, namesSize); + RINOK(SzReadFileNames(sd->Data, namesSize >> 1, numFiles, p->FileNameOffsets)) + RINOK(SzSkeepDataSize(sd, namesSize)); + break; + } + case k7zIdEmptyStream: + { + RINOK(SzReadBoolVector(sd, numFiles, emptyStreamVector, allocTemp)); + numEmptyStreams = 0; + for (i = 0; i < numFiles; i++) + if ((*emptyStreamVector)[i]) + numEmptyStreams++; + break; + } + case k7zIdEmptyFile: + { + RINOK(SzReadBoolVector(sd, numEmptyStreams, emptyFileVector, allocTemp)); + break; + } + case k7zIdWinAttributes: + { + RINOK(SzReadBoolVector2(sd, numFiles, lwtVector, allocTemp)); + RINOK(SzReadSwitch(sd)); + for (i = 0; i < numFiles; i++) + { + CSzFileItem *f = &files[i]; + uint8_t defined = (*lwtVector)[i]; + f->AttribDefined = defined; + f->Attrib = 0; + if (defined) + { + RINOK(SzReaduint32_t(sd, &f->Attrib)); + } + } + IAlloc_Free(allocTemp, *lwtVector); + *lwtVector = NULL; + break; + } + case k7zIdMTime: + { + RINOK(SzReadBoolVector2(sd, numFiles, lwtVector, allocTemp)); + RINOK(SzReadSwitch(sd)); + for (i = 0; i < numFiles; i++) + { + CSzFileItem *f = &files[i]; + uint8_t defined = (*lwtVector)[i]; + f->MTimeDefined = defined; + f->MTime.Low = f->MTime.High = 0; + if (defined) + { + RINOK(SzReaduint32_t(sd, &f->MTime.Low)); + RINOK(SzReaduint32_t(sd, &f->MTime.High)); + } + } + IAlloc_Free(allocTemp, *lwtVector); + *lwtVector = NULL; + break; + } + default: + { + RINOK(SzSkeepDataSize(sd, size)); + } + } + } + + { + uint32_t emptyFileIndex = 0; + uint32_t sizeIndex = 0; + for (i = 0; i < numFiles; i++) + { + CSzFileItem *file = files + i; + file->IsAnti = 0; + if (*emptyStreamVector == 0) + file->HasStream = 1; + else + file->HasStream = (uint8_t)((*emptyStreamVector)[i] ? 0 : 1); + if (file->HasStream) + { + file->IsDir = 0; + file->Size = (*unpackSizes)[sizeIndex]; + file->Crc = (*digests)[sizeIndex]; + file->CrcDefined = (uint8_t)(*digestsDefined)[sizeIndex]; + sizeIndex++; + } + else + { + if (*emptyFileVector == 0) + file->IsDir = 1; + else + file->IsDir = (uint8_t)((*emptyFileVector)[emptyFileIndex] ? 0 : 1); + emptyFileIndex++; + file->Size = 0; + file->Crc = 0; + file->CrcDefined = 0; + } + } + } + return SzArEx_Fill(p, allocMain); +} + +static SRes SzReadHeader( + CSzArEx *p, + CSzData *sd, + ISzAlloc *allocMain, + ISzAlloc *allocTemp) +{ + uint64_t *unpackSizes = 0; + uint8_t *digestsDefined = 0; + uint32_t *digests = 0; + uint8_t *emptyStreamVector = 0; + uint8_t *emptyFileVector = 0; + uint8_t *lwtVector = 0; + SRes res = SzReadHeader2(p, sd, + &unpackSizes, &digestsDefined, &digests, + &emptyStreamVector, &emptyFileVector, &lwtVector, + allocMain, allocTemp); + IAlloc_Free(allocTemp, unpackSizes); + IAlloc_Free(allocTemp, digestsDefined); + IAlloc_Free(allocTemp, digests); + IAlloc_Free(allocTemp, emptyStreamVector); + IAlloc_Free(allocTemp, emptyFileVector); + IAlloc_Free(allocTemp, lwtVector); + return res; +} + +static SRes SzReadAndDecodePackedStreams2( + ILookInStream *inStream, + CSzData *sd, + CBuf *outBuffer, + uint64_t baseOffset, + CSzAr *p, + uint64_t **unpackSizes, + uint8_t **digestsDefined, + uint32_t **digests, + ISzAlloc *allocTemp) +{ + + uint32_t numUnpackStreams = 0; + uint64_t dataStartPos; + CSzFolder *folder; + uint64_t unpackSize; + SRes res; + + RINOK(SzReadStreamsInfo(sd, &dataStartPos, p, + &numUnpackStreams, unpackSizes, digestsDefined, digests, + allocTemp, allocTemp)); + + dataStartPos += baseOffset; + if (p->NumFolders != 1) + return SZ_ERROR_ARCHIVE; + + folder = p->Folders; + unpackSize = SzFolder_GetUnpackSize(folder); + + RINOK(LookInStream_SeekTo(inStream, dataStartPos)); + + if (!Buf_Create(outBuffer, (size_t)unpackSize, allocTemp)) + return SZ_ERROR_MEM; + + res = SzFolder_Decode(folder, p->PackSizes, + inStream, dataStartPos, + outBuffer->data, (size_t)unpackSize, allocTemp); + RINOK(res); + if (folder->UnpackCRCDefined) + if (CrcCalc(outBuffer->data, (size_t)unpackSize) != folder->UnpackCRC) + return SZ_ERROR_CRC; + return SZ_OK; +} + +static SRes SzReadAndDecodePackedStreams( + ILookInStream *inStream, + CSzData *sd, + CBuf *outBuffer, + uint64_t baseOffset, + ISzAlloc *allocTemp) +{ + CSzAr p; + uint64_t *unpackSizes = 0; + uint8_t *digestsDefined = 0; + uint32_t *digests = 0; + SRes res; + SzAr_Init(&p); + res = SzReadAndDecodePackedStreams2(inStream, sd, outBuffer, baseOffset, + &p, &unpackSizes, &digestsDefined, &digests, + allocTemp); + SzAr_Free(&p, allocTemp); + IAlloc_Free(allocTemp, unpackSizes); + IAlloc_Free(allocTemp, digestsDefined); + IAlloc_Free(allocTemp, digests); + return res; +} + +static SRes SzArEx_Open2( + CSzArEx *p, + ILookInStream *inStream, + ISzAlloc *allocMain, + ISzAlloc *allocTemp) +{ + uint8_t header[k7zStartHeaderSize]; + int64_t startArcPos; + uint64_t nextHeaderOffset, nextHeaderSize; + size_t nextHeaderSizeT; + uint32_t nextHeaderCRC; + CBuf buffer; + SRes res; + + startArcPos = 0; + RINOK(inStream->Seek(inStream, &startArcPos, SZ_SEEK_CUR)); + + RINOK(LookInStream_Read2(inStream, header, k7zStartHeaderSize, SZ_ERROR_NO_ARCHIVE)); + + if (!TestSignatureCandidate(header)) + return SZ_ERROR_NO_ARCHIVE; + if (header[6] != k7zMajorVersion) + return SZ_ERROR_UNSUPPORTED; + + nextHeaderOffset = GetUi64(header + 12); + nextHeaderSize = GetUi64(header + 20); + nextHeaderCRC = GetUi32(header + 28); + + p->startPosAfterHeader = startArcPos + k7zStartHeaderSize; + + if (CrcCalc(header + 12, 20) != GetUi32(header + 8)) + return SZ_ERROR_CRC; + + nextHeaderSizeT = (size_t)nextHeaderSize; + if (nextHeaderSizeT != nextHeaderSize) + return SZ_ERROR_MEM; + if (nextHeaderSizeT == 0) + return SZ_OK; + if (nextHeaderOffset > nextHeaderOffset + nextHeaderSize || + nextHeaderOffset > nextHeaderOffset + nextHeaderSize + k7zStartHeaderSize) + return SZ_ERROR_NO_ARCHIVE; + + { + int64_t pos = 0; + RINOK(inStream->Seek(inStream, &pos, SZ_SEEK_END)); + if ((uint64_t)pos < startArcPos + nextHeaderOffset || + (uint64_t)pos < startArcPos + k7zStartHeaderSize + nextHeaderOffset || + (uint64_t)pos < startArcPos + k7zStartHeaderSize + nextHeaderOffset + nextHeaderSize) + return SZ_ERROR_INPUT_EOF; + } + + RINOK(LookInStream_SeekTo(inStream, startArcPos + k7zStartHeaderSize + nextHeaderOffset)); + + if (!Buf_Create(&buffer, nextHeaderSizeT, allocTemp)) + return SZ_ERROR_MEM; + + res = LookInStream_Read(inStream, buffer.data, nextHeaderSizeT); + if (res == SZ_OK) + { + res = SZ_ERROR_ARCHIVE; + if (CrcCalc(buffer.data, nextHeaderSizeT) == nextHeaderCRC) + { + CSzData sd; + uint64_t type; + sd.Data = buffer.data; + sd.Size = buffer.size; + res = SzReadID(&sd, &type); + if (res == SZ_OK) + { + if (type == k7zIdEncodedHeader) + { + CBuf outBuffer; + Buf_Init(&outBuffer); + res = SzReadAndDecodePackedStreams(inStream, &sd, &outBuffer, p->startPosAfterHeader, allocTemp); + if (res != SZ_OK) + Buf_Free(&outBuffer, allocTemp); + else + { + Buf_Free(&buffer, allocTemp); + buffer.data = outBuffer.data; + buffer.size = outBuffer.size; + sd.Data = buffer.data; + sd.Size = buffer.size; + res = SzReadID(&sd, &type); + } + } + } + if (res == SZ_OK) + { + if (type == k7zIdHeader) + res = SzReadHeader(p, &sd, allocMain, allocTemp); + else + res = SZ_ERROR_UNSUPPORTED; + } + } + } + Buf_Free(&buffer, allocTemp); + return res; +} + +SRes SzArEx_Open(CSzArEx *p, ILookInStream *inStream, ISzAlloc *allocMain, ISzAlloc *allocTemp) +{ + SRes res = SzArEx_Open2(p, inStream, allocMain, allocTemp); + if (res != SZ_OK) + SzArEx_Free(p, allocMain); + return res; +} + +SRes SzArEx_Extract( + const CSzArEx *p, + ILookInStream *inStream, + uint32_t fileIndex, + uint32_t *blockIndex, + uint8_t **outBuffer, + size_t *outBufferSize, + size_t *offset, + size_t *outSizeProcessed, + ISzAlloc *allocMain, + ISzAlloc *allocTemp) +{ + uint32_t folderIndex = p->FileIndexToFolderIndexMap[fileIndex]; + SRes res = SZ_OK; + *offset = 0; + *outSizeProcessed = 0; + if (folderIndex == (uint32_t)-1) + { + IAlloc_Free(allocMain, *outBuffer); + *blockIndex = folderIndex; + *outBuffer = 0; + *outBufferSize = 0; + return SZ_OK; + } + + if (*outBuffer == 0 || *blockIndex != folderIndex) + { + CSzFolder *folder = p->db.Folders + folderIndex; + uint64_t unpackSizeSpec = SzFolder_GetUnpackSize(folder); + size_t unpackSize = (size_t)unpackSizeSpec; + uint64_t startOffset = SzArEx_GetFolderStreamPos(p, folderIndex, 0); + + if (unpackSize != unpackSizeSpec) + return SZ_ERROR_MEM; + *blockIndex = folderIndex; + IAlloc_Free(allocMain, *outBuffer); + *outBuffer = 0; + + RINOK(LookInStream_SeekTo(inStream, startOffset)); + + if (res == SZ_OK) + { + *outBufferSize = unpackSize; + if (unpackSize != 0) + { + *outBuffer = (uint8_t *)IAlloc_Alloc(allocMain, unpackSize); + if (*outBuffer == 0) + res = SZ_ERROR_MEM; + } + if (res == SZ_OK) + { + res = SzFolder_Decode(folder, + p->db.PackSizes + p->FolderStartPackStreamIndex[folderIndex], + inStream, startOffset, + *outBuffer, unpackSize, allocTemp); + if (res == SZ_OK) + { + if (folder->UnpackCRCDefined) + { + if (CrcCalc(*outBuffer, unpackSize) != folder->UnpackCRC) + res = SZ_ERROR_CRC; + } + } + } + } + } + if (res == SZ_OK) + { + uint32_t i; + CSzFileItem *fileItem = p->db.Files + fileIndex; + *offset = 0; + for (i = p->FolderStartFileIndex[folderIndex]; i < fileIndex; i++) + *offset += (uint32_t)p->db.Files[i].Size; + *outSizeProcessed = (size_t)fileItem->Size; + if (*offset + *outSizeProcessed > *outBufferSize) + return SZ_ERROR_FAIL; + if (fileItem->CrcDefined && CrcCalc(*outBuffer + *offset, *outSizeProcessed) != fileItem->Crc) + res = SZ_ERROR_CRC; + } + return res; +} diff --git a/deps/7zip/7zStream.c b/deps/7zip/7zStream.c index c205fbe200..1fc86d064c 100644 --- a/deps/7zip/7zStream.c +++ b/deps/7zip/7zStream.c @@ -1,173 +1,173 @@ -/* 7zStream.c -- 7z Stream functions - 2010-03-11 : Igor Pavlov : Public domain */ - -#include -#include -#include - -#include "7zTypes.h" - -SRes SeqInStream_Readuint8_t(ISeqInStream *stream, uint8_t *buf); - -SRes SeqInStream_Read2(ISeqInStream *stream, void *buf, size_t size, SRes errorType) -{ - while (size != 0) - { - size_t processed = size; - RINOK(stream->Read(stream, buf, &processed)); - if (processed == 0) - return errorType; - buf = (void *)((uint8_t *)buf + processed); - size -= processed; - } - return SZ_OK; -} - -SRes SeqInStream_Read(ISeqInStream *stream, void *buf, size_t size) -{ - return SeqInStream_Read2(stream, buf, size, SZ_ERROR_INPUT_EOF); -} - -SRes SeqInStream_Readuint8_t(ISeqInStream *stream, uint8_t *buf) -{ - size_t processed = 1; - RINOK(stream->Read(stream, buf, &processed)); - return (processed == 1) ? SZ_OK : SZ_ERROR_INPUT_EOF; -} - -SRes LookInStream_SeekTo(ILookInStream *stream, uint64_t offset) -{ - int64_t t = offset; - return stream->Seek(stream, &t, SZ_SEEK_SET); -} - -SRes LookInStream_LookRead(ILookInStream *stream, void *buf, size_t *size) -{ - const void *lookBuf; - if (*size == 0) - return SZ_OK; - RINOK(stream->Look(stream, &lookBuf, size)); - memcpy(buf, lookBuf, *size); - return stream->Skip(stream, *size); -} - -SRes LookInStream_Read2(ILookInStream *stream, void *buf, size_t size, SRes errorType) -{ - while (size != 0) - { - size_t processed = size; - RINOK(stream->Read(stream, buf, &processed)); - if (processed == 0) - return errorType; - buf = (void *)((uint8_t *)buf + processed); - size -= processed; - } - return SZ_OK; -} - -SRes LookInStream_Read(ILookInStream *stream, void *buf, size_t size) -{ - return LookInStream_Read2(stream, buf, size, SZ_ERROR_INPUT_EOF); -} - -static SRes LookToRead_Look_Lookahead(void *pp, const void **buf, size_t *size) -{ - SRes res = SZ_OK; - CLookToRead *p = (CLookToRead *)pp; - size_t size2 = p->size - p->pos; - if (size2 == 0 && *size > 0) - { - p->pos = 0; - size2 = LookToRead_BUF_SIZE; - res = p->realStream->Read(p->realStream, p->buf, &size2); - p->size = size2; - } - if (size2 < *size) - *size = size2; - *buf = p->buf + p->pos; - return res; -} - -static SRes LookToRead_Look_Exact(void *pp, const void **buf, size_t *size) -{ - SRes res = SZ_OK; - CLookToRead *p = (CLookToRead *)pp; - size_t size2 = p->size - p->pos; - if (size2 == 0 && *size > 0) - { - p->pos = 0; - if (*size > LookToRead_BUF_SIZE) - *size = LookToRead_BUF_SIZE; - res = p->realStream->Read(p->realStream, p->buf, size); - size2 = p->size = *size; - } - if (size2 < *size) - *size = size2; - *buf = p->buf + p->pos; - return res; -} - -static SRes LookToRead_Skip(void *pp, size_t offset) -{ - CLookToRead *p = (CLookToRead *)pp; - p->pos += offset; - return SZ_OK; -} - -static SRes LookToRead_Read(void *pp, void *buf, size_t *size) -{ - CLookToRead *p = (CLookToRead *)pp; - size_t rem = p->size - p->pos; - if (rem == 0) - return p->realStream->Read(p->realStream, buf, size); - if (rem > *size) - rem = *size; - memcpy(buf, p->buf + p->pos, rem); - p->pos += rem; - *size = rem; - return SZ_OK; -} - -static SRes LookToRead_Seek(void *pp, int64_t *pos, ESzSeek origin) -{ - CLookToRead *p = (CLookToRead *)pp; - p->pos = p->size = 0; - return p->realStream->Seek(p->realStream, pos, origin); -} - -void LookToRead_CreateVTable(CLookToRead *p, int lookahead) -{ - p->s.Look = lookahead ? - LookToRead_Look_Lookahead : - LookToRead_Look_Exact; - p->s.Skip = LookToRead_Skip; - p->s.Read = LookToRead_Read; - p->s.Seek = LookToRead_Seek; -} - -void LookToRead_Init(CLookToRead *p) -{ - p->pos = p->size = 0; -} - -static SRes SecToLook_Read(void *pp, void *buf, size_t *size) -{ - CSecToLook *p = (CSecToLook *)pp; - return LookInStream_LookRead(p->realStream, buf, size); -} - -void SecToLook_CreateVTable(CSecToLook *p) -{ - p->s.Read = SecToLook_Read; -} - -static SRes SecToRead_Read(void *pp, void *buf, size_t *size) -{ - CSecToRead *p = (CSecToRead *)pp; - return p->realStream->Read(p->realStream, buf, size); -} - -void SecToRead_CreateVTable(CSecToRead *p) -{ - p->s.Read = SecToRead_Read; -} +/* 7zStream.c -- 7z Stream functions + 2010-03-11 : Igor Pavlov : Public domain */ + +#include +#include +#include + +#include "7zTypes.h" + +SRes SeqInStream_Readuint8_t(ISeqInStream *stream, uint8_t *buf); + +SRes SeqInStream_Read2(ISeqInStream *stream, void *buf, size_t size, SRes errorType) +{ + while (size != 0) + { + size_t processed = size; + RINOK(stream->Read(stream, buf, &processed)); + if (processed == 0) + return errorType; + buf = (void *)((uint8_t *)buf + processed); + size -= processed; + } + return SZ_OK; +} + +SRes SeqInStream_Read(ISeqInStream *stream, void *buf, size_t size) +{ + return SeqInStream_Read2(stream, buf, size, SZ_ERROR_INPUT_EOF); +} + +SRes SeqInStream_Readuint8_t(ISeqInStream *stream, uint8_t *buf) +{ + size_t processed = 1; + RINOK(stream->Read(stream, buf, &processed)); + return (processed == 1) ? SZ_OK : SZ_ERROR_INPUT_EOF; +} + +SRes LookInStream_SeekTo(ILookInStream *stream, uint64_t offset) +{ + int64_t t = offset; + return stream->Seek(stream, &t, SZ_SEEK_SET); +} + +SRes LookInStream_LookRead(ILookInStream *stream, void *buf, size_t *size) +{ + const void *lookBuf; + if (*size == 0) + return SZ_OK; + RINOK(stream->Look(stream, &lookBuf, size)); + memcpy(buf, lookBuf, *size); + return stream->Skip(stream, *size); +} + +SRes LookInStream_Read2(ILookInStream *stream, void *buf, size_t size, SRes errorType) +{ + while (size != 0) + { + size_t processed = size; + RINOK(stream->Read(stream, buf, &processed)); + if (processed == 0) + return errorType; + buf = (void *)((uint8_t *)buf + processed); + size -= processed; + } + return SZ_OK; +} + +SRes LookInStream_Read(ILookInStream *stream, void *buf, size_t size) +{ + return LookInStream_Read2(stream, buf, size, SZ_ERROR_INPUT_EOF); +} + +static SRes LookToRead_Look_Lookahead(void *pp, const void **buf, size_t *size) +{ + SRes res = SZ_OK; + CLookToRead *p = (CLookToRead *)pp; + size_t size2 = p->size - p->pos; + if (size2 == 0 && *size > 0) + { + p->pos = 0; + size2 = LookToRead_BUF_SIZE; + res = p->realStream->Read(p->realStream, p->buf, &size2); + p->size = size2; + } + if (size2 < *size) + *size = size2; + *buf = p->buf + p->pos; + return res; +} + +static SRes LookToRead_Look_Exact(void *pp, const void **buf, size_t *size) +{ + SRes res = SZ_OK; + CLookToRead *p = (CLookToRead *)pp; + size_t size2 = p->size - p->pos; + if (size2 == 0 && *size > 0) + { + p->pos = 0; + if (*size > LookToRead_BUF_SIZE) + *size = LookToRead_BUF_SIZE; + res = p->realStream->Read(p->realStream, p->buf, size); + size2 = p->size = *size; + } + if (size2 < *size) + *size = size2; + *buf = p->buf + p->pos; + return res; +} + +static SRes LookToRead_Skip(void *pp, size_t offset) +{ + CLookToRead *p = (CLookToRead *)pp; + p->pos += offset; + return SZ_OK; +} + +static SRes LookToRead_Read(void *pp, void *buf, size_t *size) +{ + CLookToRead *p = (CLookToRead *)pp; + size_t rem = p->size - p->pos; + if (rem == 0) + return p->realStream->Read(p->realStream, buf, size); + if (rem > *size) + rem = *size; + memcpy(buf, p->buf + p->pos, rem); + p->pos += rem; + *size = rem; + return SZ_OK; +} + +static SRes LookToRead_Seek(void *pp, int64_t *pos, ESzSeek origin) +{ + CLookToRead *p = (CLookToRead *)pp; + p->pos = p->size = 0; + return p->realStream->Seek(p->realStream, pos, origin); +} + +void LookToRead_CreateVTable(CLookToRead *p, int lookahead) +{ + p->s.Look = lookahead ? + LookToRead_Look_Lookahead : + LookToRead_Look_Exact; + p->s.Skip = LookToRead_Skip; + p->s.Read = LookToRead_Read; + p->s.Seek = LookToRead_Seek; +} + +void LookToRead_Init(CLookToRead *p) +{ + p->pos = p->size = 0; +} + +static SRes SecToLook_Read(void *pp, void *buf, size_t *size) +{ + CSecToLook *p = (CSecToLook *)pp; + return LookInStream_LookRead(p->realStream, buf, size); +} + +void SecToLook_CreateVTable(CSecToLook *p) +{ + p->s.Read = SecToLook_Read; +} + +static SRes SecToRead_Read(void *pp, void *buf, size_t *size) +{ + CSecToRead *p = (CSecToRead *)pp; + return p->realStream->Read(p->realStream, buf, size); +} + +void SecToRead_CreateVTable(CSecToRead *p) +{ + p->s.Read = SecToRead_Read; +} diff --git a/deps/7zip/7zVersion.h b/deps/7zip/7zVersion.h index d4ac470e23..9d99c5dff2 100644 --- a/deps/7zip/7zVersion.h +++ b/deps/7zip/7zVersion.h @@ -1,7 +1,7 @@ -#define MY_VER_MAJOR 9 -#define MY_VER_MINOR 20 -#define MY_VER_BUILD 0 -#define MY_VERSION "9.20" -#define MY_DATE "2010-11-18" -#define MY_COPYRIGHT ": Igor Pavlov : Public domain" -#define MY_VERSION_COPYRIGHT_DATE MY_VERSION " " MY_COPYRIGHT " : " MY_DATE +#define MY_VER_MAJOR 9 +#define MY_VER_MINOR 20 +#define MY_VER_BUILD 0 +#define MY_VERSION "9.20" +#define MY_DATE "2010-11-18" +#define MY_COPYRIGHT ": Igor Pavlov : Public domain" +#define MY_VERSION_COPYRIGHT_DATE MY_VERSION " " MY_COPYRIGHT " : " MY_DATE diff --git a/deps/7zip/Bcj2.c b/deps/7zip/Bcj2.c index 7c55cae3d1..13991b7698 100644 --- a/deps/7zip/Bcj2.c +++ b/deps/7zip/Bcj2.c @@ -1,149 +1,149 @@ -/* Bcj2.c -- Converter for x86 code (BCJ2) - 2008-10-04 : Igor Pavlov : Public domain */ - -#include -#include "Bcj2.h" - -#define IsJcc(b0, b1) ((b0) == 0x0F && ((b1) & 0xF0) == 0x80) -#define IsJ(b0, b1) ((b1 & 0xFE) == 0xE8 || IsJcc(b0, b1)) - -#define kNumTopBits 24 -#define kTopValue ((uint32_t)1 << kNumTopBits) - -#define kNumBitModelTotalBits 11 -#define kBitModelTotal (1 << kNumBitModelTotalBits) -#define kNumMoveBits 5 - -#define RC_READ_BYTE (*buffer++) - -int Bcj2_Decode( - const uint8_t *buf0, size_t size0, - const uint8_t *buf1, size_t size1, - const uint8_t *buf2, size_t size2, - const uint8_t *buf3, size_t size3, - uint8_t *outBuf, size_t outSize) -{ - uint16_t p[256 + 2]; - size_t inPos = 0, outPos = 0; - - const uint8_t *buffer, *bufferLim; - uint32_t range, codes = 0; - uint8_t prevuint8_t = 0; - - unsigned int i; - for (i = 0; i < sizeof(p) / sizeof(p[0]); i++) - p[i] = kBitModelTotal >> 1; - - buffer = buf3; - bufferLim = buffer + size3; - range = 0xFFFFFFFF; - - for (i = 0; i < 5; i++) - { - if (buffer == bufferLim) - return SZ_ERROR_DATA; - codes = (codes << 8) | RC_READ_BYTE; - } - - if (outSize == 0) - return SZ_OK; - - for (;;) - { - uint8_t b; - uint16_t *prob; - uint32_t bound; - uint32_t ttt; - - size_t limit = size0 - inPos; - if (outSize - outPos < limit) - limit = outSize - outPos; - while (limit != 0) - { - b = buf0[inPos]; - outBuf[outPos++] = b; - if (IsJ(prevuint8_t, b)) - break; - inPos++; - prevuint8_t = b; - limit--; - } - - if (limit == 0 || outPos == outSize) - break; - - b = buf0[inPos++]; - - if (b == 0xE8) - prob = p + prevuint8_t; - else if (b == 0xE9) - prob = p + 256; - else - prob = p + 257; - - ttt = *(prob); - bound = (range >> kNumBitModelTotalBits) * ttt; - - if (codes < bound) - { - range = bound; - *(prob) = (uint16_t)(ttt + ((kBitModelTotal - ttt) >> kNumMoveBits)); - - if (range < kTopValue) - { - if (buffer == bufferLim) - return SZ_ERROR_DATA; - range <<= 8; - codes = (codes << 8) | RC_READ_BYTE; - } - prevuint8_t = b; - } - else - { - uint32_t dest; - const uint8_t *v; - - range -= bound; - codes -= bound; - *(prob) = (uint16_t)(ttt - (ttt >> kNumMoveBits)); - - if (range < kTopValue) - { - if (buffer == bufferLim) - return SZ_ERROR_DATA; - range <<= 8; - codes = (codes << 8) | RC_READ_BYTE; - } - - if (b == 0xE8) - { - v = buf1; - if (size1 < 4) - return SZ_ERROR_DATA; - buf1 += 4; - size1 -= 4; - } - else - { - v = buf2; - if (size2 < 4) - return SZ_ERROR_DATA; - buf2 += 4; - size2 -= 4; - } - dest = (((uint32_t)v[0] << 24) | ((uint32_t)v[1] << 16) | - ((uint32_t)v[2] << 8) | ((uint32_t)v[3])) - ((uint32_t)outPos + 4); - outBuf[outPos++] = (uint8_t)dest; - if (outPos == outSize) - break; - outBuf[outPos++] = (uint8_t)(dest >> 8); - if (outPos == outSize) - break; - outBuf[outPos++] = (uint8_t)(dest >> 16); - if (outPos == outSize) - break; - outBuf[outPos++] = prevuint8_t = (uint8_t)(dest >> 24); - } - } - return (outPos == outSize) ? SZ_OK : SZ_ERROR_DATA; -} +/* Bcj2.c -- Converter for x86 code (BCJ2) + 2008-10-04 : Igor Pavlov : Public domain */ + +#include +#include "Bcj2.h" + +#define IsJcc(b0, b1) ((b0) == 0x0F && ((b1) & 0xF0) == 0x80) +#define IsJ(b0, b1) ((b1 & 0xFE) == 0xE8 || IsJcc(b0, b1)) + +#define kNumTopBits 24 +#define kTopValue ((uint32_t)1 << kNumTopBits) + +#define kNumBitModelTotalBits 11 +#define kBitModelTotal (1 << kNumBitModelTotalBits) +#define kNumMoveBits 5 + +#define RC_READ_BYTE (*buffer++) + +int Bcj2_Decode( + const uint8_t *buf0, size_t size0, + const uint8_t *buf1, size_t size1, + const uint8_t *buf2, size_t size2, + const uint8_t *buf3, size_t size3, + uint8_t *outBuf, size_t outSize) +{ + uint16_t p[256 + 2]; + size_t inPos = 0, outPos = 0; + + const uint8_t *buffer, *bufferLim; + uint32_t range, codes = 0; + uint8_t prevuint8_t = 0; + + unsigned int i; + for (i = 0; i < sizeof(p) / sizeof(p[0]); i++) + p[i] = kBitModelTotal >> 1; + + buffer = buf3; + bufferLim = buffer + size3; + range = 0xFFFFFFFF; + + for (i = 0; i < 5; i++) + { + if (buffer == bufferLim) + return SZ_ERROR_DATA; + codes = (codes << 8) | RC_READ_BYTE; + } + + if (outSize == 0) + return SZ_OK; + + for (;;) + { + uint8_t b; + uint16_t *prob; + uint32_t bound; + uint32_t ttt; + + size_t limit = size0 - inPos; + if (outSize - outPos < limit) + limit = outSize - outPos; + while (limit != 0) + { + b = buf0[inPos]; + outBuf[outPos++] = b; + if (IsJ(prevuint8_t, b)) + break; + inPos++; + prevuint8_t = b; + limit--; + } + + if (limit == 0 || outPos == outSize) + break; + + b = buf0[inPos++]; + + if (b == 0xE8) + prob = p + prevuint8_t; + else if (b == 0xE9) + prob = p + 256; + else + prob = p + 257; + + ttt = *(prob); + bound = (range >> kNumBitModelTotalBits) * ttt; + + if (codes < bound) + { + range = bound; + *(prob) = (uint16_t)(ttt + ((kBitModelTotal - ttt) >> kNumMoveBits)); + + if (range < kTopValue) + { + if (buffer == bufferLim) + return SZ_ERROR_DATA; + range <<= 8; + codes = (codes << 8) | RC_READ_BYTE; + } + prevuint8_t = b; + } + else + { + uint32_t dest; + const uint8_t *v; + + range -= bound; + codes -= bound; + *(prob) = (uint16_t)(ttt - (ttt >> kNumMoveBits)); + + if (range < kTopValue) + { + if (buffer == bufferLim) + return SZ_ERROR_DATA; + range <<= 8; + codes = (codes << 8) | RC_READ_BYTE; + } + + if (b == 0xE8) + { + v = buf1; + if (size1 < 4) + return SZ_ERROR_DATA; + buf1 += 4; + size1 -= 4; + } + else + { + v = buf2; + if (size2 < 4) + return SZ_ERROR_DATA; + buf2 += 4; + size2 -= 4; + } + dest = (((uint32_t)v[0] << 24) | ((uint32_t)v[1] << 16) | + ((uint32_t)v[2] << 8) | ((uint32_t)v[3])) - ((uint32_t)outPos + 4); + outBuf[outPos++] = (uint8_t)dest; + if (outPos == outSize) + break; + outBuf[outPos++] = (uint8_t)(dest >> 8); + if (outPos == outSize) + break; + outBuf[outPos++] = (uint8_t)(dest >> 16); + if (outPos == outSize) + break; + outBuf[outPos++] = prevuint8_t = (uint8_t)(dest >> 24); + } + } + return (outPos == outSize) ? SZ_OK : SZ_ERROR_DATA; +} diff --git a/deps/7zip/Bcj2.h b/deps/7zip/Bcj2.h index a7651499f7..edca41e0a9 100644 --- a/deps/7zip/Bcj2.h +++ b/deps/7zip/Bcj2.h @@ -1,38 +1,38 @@ -/* Bcj2.h -- Converter for x86 code (BCJ2) -2009-02-07 : Igor Pavlov : Public domain */ - -#ifndef __BCJ2_H -#define __BCJ2_H - -#include "7zTypes.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* -Conditions: - outSize <= FullOutputSize, - where FullOutputSize is full size of output stream of x86_2 filter. - -If buf0 overlaps outBuf, there are two required conditions: - 1) (buf0 >= outBuf) - 2) (buf0 + size0 >= outBuf + FullOutputSize). - -Returns: - SZ_OK - SZ_ERROR_DATA - Data error -*/ - -int Bcj2_Decode( - const uint8_t *buf0, size_t size0, - const uint8_t *buf1, size_t size1, - const uint8_t *buf2, size_t size2, - const uint8_t *buf3, size_t size3, - uint8_t *outBuf, size_t outSize); - -#ifdef __cplusplus -} -#endif - -#endif +/* Bcj2.h -- Converter for x86 code (BCJ2) +2009-02-07 : Igor Pavlov : Public domain */ + +#ifndef __BCJ2_H +#define __BCJ2_H + +#include "7zTypes.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* +Conditions: + outSize <= FullOutputSize, + where FullOutputSize is full size of output stream of x86_2 filter. + +If buf0 overlaps outBuf, there are two required conditions: + 1) (buf0 >= outBuf) + 2) (buf0 + size0 >= outBuf + FullOutputSize). + +Returns: + SZ_OK + SZ_ERROR_DATA - Data error +*/ + +int Bcj2_Decode( + const uint8_t *buf0, size_t size0, + const uint8_t *buf1, size_t size1, + const uint8_t *buf2, size_t size2, + const uint8_t *buf3, size_t size3, + uint8_t *outBuf, size_t outSize); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/deps/7zip/Bra.c b/deps/7zip/Bra.c index 40a0e5f9ed..49df0831b3 100644 --- a/deps/7zip/Bra.c +++ b/deps/7zip/Bra.c @@ -1,134 +1,134 @@ -/* Bra.c -- Converters for RISC code - 2010-04-16 : Igor Pavlov : Public domain */ - -#include -#include "Bra.h" - -size_t ARM_Convert(uint8_t *data, size_t size, uint32_t ip, int encoding) -{ - size_t i; - if (size < 4) - return 0; - size -= 4; - ip += 8; - for (i = 0; i <= size; i += 4) - { - if (data[i + 3] == 0xEB) - { - uint32_t dest; - uint32_t src = ((uint32_t)data[i + 2] << 16) | ((uint32_t)data[i + 1] << 8) | (data[i + 0]); - src <<= 2; - if (encoding) - dest = ip + (uint32_t)i + src; - else - dest = src - (ip + (uint32_t)i); - dest >>= 2; - data[i + 2] = (uint8_t)(dest >> 16); - data[i + 1] = (uint8_t)(dest >> 8); - data[i + 0] = (uint8_t)dest; - } - } - return i; -} - -size_t ARMT_Convert(uint8_t *data, size_t size, uint32_t ip, int encoding) -{ - size_t i; - if (size < 4) - return 0; - size -= 4; - ip += 4; - for (i = 0; i <= size; i += 2) - { - if ((data[i + 1] & 0xF8) == 0xF0 && - (data[i + 3] & 0xF8) == 0xF8) - { - uint32_t dest; - uint32_t src = - (((uint32_t)data[i + 1] & 0x7) << 19) | - ((uint32_t)data[i + 0] << 11) | - (((uint32_t)data[i + 3] & 0x7) << 8) | - (data[i + 2]); - - src <<= 1; - if (encoding) - dest = ip + (uint32_t)i + src; - else - dest = src - (ip + (uint32_t)i); - dest >>= 1; - - data[i + 1] = (uint8_t)(0xF0 | ((dest >> 19) & 0x7)); - data[i + 0] = (uint8_t)(dest >> 11); - data[i + 3] = (uint8_t)(0xF8 | ((dest >> 8) & 0x7)); - data[i + 2] = (uint8_t)dest; - i += 2; - } - } - return i; -} - -size_t PPC_Convert(uint8_t *data, size_t size, uint32_t ip, int encoding) -{ - size_t i; - if (size < 4) - return 0; - size -= 4; - for (i = 0; i <= size; i += 4) - { - if ((data[i] >> 2) == 0x12 && (data[i + 3] & 3) == 1) - { - uint32_t src = ((uint32_t)(data[i + 0] & 3) << 24) | - ((uint32_t)data[i + 1] << 16) | - ((uint32_t)data[i + 2] << 8) | - ((uint32_t)data[i + 3] & (~3)); - - uint32_t dest; - if (encoding) - dest = ip + (uint32_t)i + src; - else - dest = src - (ip + (uint32_t)i); - data[i + 0] = (uint8_t)(0x48 | ((dest >> 24) & 0x3)); - data[i + 1] = (uint8_t)(dest >> 16); - data[i + 2] = (uint8_t)(dest >> 8); - data[i + 3] &= 0x3; - data[i + 3] |= dest; - } - } - return i; -} - -size_t SPARC_Convert(uint8_t *data, size_t size, uint32_t ip, int encoding) -{ - uint32_t i; - if (size < 4) - return 0; - size -= 4; - for (i = 0; i <= size; i += 4) - { - if ((data[i] == 0x40 && (data[i + 1] & 0xC0) == 0x00) || - (data[i] == 0x7F && (data[i + 1] & 0xC0) == 0xC0)) - { - uint32_t src = - ((uint32_t)data[i + 0] << 24) | - ((uint32_t)data[i + 1] << 16) | - ((uint32_t)data[i + 2] << 8) | - ((uint32_t)data[i + 3]); - uint32_t dest; - - src <<= 2; - if (encoding) - dest = ip + i + src; - else - dest = src - (ip + i); - dest >>= 2; - - dest = (((0 - ((dest >> 22) & 1)) << 22) & 0x3FFFFFFF) | (dest & 0x3FFFFF) | 0x40000000; - - data[i + 0] = (uint8_t)(dest >> 24); - data[i + 1] = (uint8_t)(dest >> 16); - data[i + 2] = (uint8_t)(dest >> 8); - data[i + 3] = (uint8_t)dest; - } - } - return i; -} +/* Bra.c -- Converters for RISC code + 2010-04-16 : Igor Pavlov : Public domain */ + +#include +#include "Bra.h" + +size_t ARM_Convert(uint8_t *data, size_t size, uint32_t ip, int encoding) +{ + size_t i; + if (size < 4) + return 0; + size -= 4; + ip += 8; + for (i = 0; i <= size; i += 4) + { + if (data[i + 3] == 0xEB) + { + uint32_t dest; + uint32_t src = ((uint32_t)data[i + 2] << 16) | ((uint32_t)data[i + 1] << 8) | (data[i + 0]); + src <<= 2; + if (encoding) + dest = ip + (uint32_t)i + src; + else + dest = src - (ip + (uint32_t)i); + dest >>= 2; + data[i + 2] = (uint8_t)(dest >> 16); + data[i + 1] = (uint8_t)(dest >> 8); + data[i + 0] = (uint8_t)dest; + } + } + return i; +} + +size_t ARMT_Convert(uint8_t *data, size_t size, uint32_t ip, int encoding) +{ + size_t i; + if (size < 4) + return 0; + size -= 4; + ip += 4; + for (i = 0; i <= size; i += 2) + { + if ((data[i + 1] & 0xF8) == 0xF0 && + (data[i + 3] & 0xF8) == 0xF8) + { + uint32_t dest; + uint32_t src = + (((uint32_t)data[i + 1] & 0x7) << 19) | + ((uint32_t)data[i + 0] << 11) | + (((uint32_t)data[i + 3] & 0x7) << 8) | + (data[i + 2]); + + src <<= 1; + if (encoding) + dest = ip + (uint32_t)i + src; + else + dest = src - (ip + (uint32_t)i); + dest >>= 1; + + data[i + 1] = (uint8_t)(0xF0 | ((dest >> 19) & 0x7)); + data[i + 0] = (uint8_t)(dest >> 11); + data[i + 3] = (uint8_t)(0xF8 | ((dest >> 8) & 0x7)); + data[i + 2] = (uint8_t)dest; + i += 2; + } + } + return i; +} + +size_t PPC_Convert(uint8_t *data, size_t size, uint32_t ip, int encoding) +{ + size_t i; + if (size < 4) + return 0; + size -= 4; + for (i = 0; i <= size; i += 4) + { + if ((data[i] >> 2) == 0x12 && (data[i + 3] & 3) == 1) + { + uint32_t src = ((uint32_t)(data[i + 0] & 3) << 24) | + ((uint32_t)data[i + 1] << 16) | + ((uint32_t)data[i + 2] << 8) | + ((uint32_t)data[i + 3] & (~3)); + + uint32_t dest; + if (encoding) + dest = ip + (uint32_t)i + src; + else + dest = src - (ip + (uint32_t)i); + data[i + 0] = (uint8_t)(0x48 | ((dest >> 24) & 0x3)); + data[i + 1] = (uint8_t)(dest >> 16); + data[i + 2] = (uint8_t)(dest >> 8); + data[i + 3] &= 0x3; + data[i + 3] |= dest; + } + } + return i; +} + +size_t SPARC_Convert(uint8_t *data, size_t size, uint32_t ip, int encoding) +{ + uint32_t i; + if (size < 4) + return 0; + size -= 4; + for (i = 0; i <= size; i += 4) + { + if ((data[i] == 0x40 && (data[i + 1] & 0xC0) == 0x00) || + (data[i] == 0x7F && (data[i + 1] & 0xC0) == 0xC0)) + { + uint32_t src = + ((uint32_t)data[i + 0] << 24) | + ((uint32_t)data[i + 1] << 16) | + ((uint32_t)data[i + 2] << 8) | + ((uint32_t)data[i + 3]); + uint32_t dest; + + src <<= 2; + if (encoding) + dest = ip + i + src; + else + dest = src - (ip + i); + dest >>= 2; + + dest = (((0 - ((dest >> 22) & 1)) << 22) & 0x3FFFFFFF) | (dest & 0x3FFFFF) | 0x40000000; + + data[i + 0] = (uint8_t)(dest >> 24); + data[i + 1] = (uint8_t)(dest >> 16); + data[i + 2] = (uint8_t)(dest >> 8); + data[i + 3] = (uint8_t)dest; + } + } + return i; +} diff --git a/deps/7zip/Bra.h b/deps/7zip/Bra.h index 3e9d9d9a30..52fa0b30b1 100644 --- a/deps/7zip/Bra.h +++ b/deps/7zip/Bra.h @@ -1,68 +1,68 @@ -/* Bra.h -- Branch converters for executables - 2009-02-07 : Igor Pavlov : Public domain */ - -#ifndef __BRA_H -#define __BRA_H - -#include "7zTypes.h" - -#ifdef __cplusplus -extern "C" { -#endif - - /* - These functions convert relative addresses to absolute addresses - in CALL instructions to increase the compression ratio. - -In: -data - data buffer -size - size of data -ip - current virtual Instruction Pinter (IP) value -state - state variable for x86 converter -encoding - 0 (for decoding), 1 (for encoding) - -Out: -state - state variable for x86 converter - -Returns: -The number of processed bytes. If you call these functions with multiple calls, -you must start next call with first byte after block of processed bytes. - -Type Endian Alignment LookAhead - -x86 little 1 4 -ARMT little 2 2 -ARM little 4 0 -PPC big 4 0 -SPARC big 4 0 -IA64 little 16 0 - -size must be >= Alignment + LookAhead, if it's not last block. -If (size < Alignment + LookAhead), converter returns 0. - -Example: - -uint32_t ip = 0; -for () -{ -; size must be >= Alignment + LookAhead, if it's not last block -size_t processed = Convert(data, size, ip, 1); -data += processed; -size -= processed; -ip += processed; -} -*/ - -#define x86_Convert_Init(state) { state = 0; } -size_t x86_Convert(uint8_t *data, size_t size, uint32_t ip, uint32_t *state, int encoding); -size_t ARM_Convert(uint8_t *data, size_t size, uint32_t ip, int encoding); -size_t ARMT_Convert(uint8_t *data, size_t size, uint32_t ip, int encoding); -size_t PPC_Convert(uint8_t *data, size_t size, uint32_t ip, int encoding); -size_t SPARC_Convert(uint8_t *data, size_t size, uint32_t ip, int encoding); -size_t IA64_Convert(uint8_t *data, size_t size, uint32_t ip, int encoding); - -#ifdef __cplusplus -} -#endif - -#endif +/* Bra.h -- Branch converters for executables + 2009-02-07 : Igor Pavlov : Public domain */ + +#ifndef __BRA_H +#define __BRA_H + +#include "7zTypes.h" + +#ifdef __cplusplus +extern "C" { +#endif + + /* + These functions convert relative addresses to absolute addresses + in CALL instructions to increase the compression ratio. + +In: +data - data buffer +size - size of data +ip - current virtual Instruction Pinter (IP) value +state - state variable for x86 converter +encoding - 0 (for decoding), 1 (for encoding) + +Out: +state - state variable for x86 converter + +Returns: +The number of processed bytes. If you call these functions with multiple calls, +you must start next call with first byte after block of processed bytes. + +Type Endian Alignment LookAhead + +x86 little 1 4 +ARMT little 2 2 +ARM little 4 0 +PPC big 4 0 +SPARC big 4 0 +IA64 little 16 0 + +size must be >= Alignment + LookAhead, if it's not last block. +If (size < Alignment + LookAhead), converter returns 0. + +Example: + +uint32_t ip = 0; +for () +{ +; size must be >= Alignment + LookAhead, if it's not last block +size_t processed = Convert(data, size, ip, 1); +data += processed; +size -= processed; +ip += processed; +} +*/ + +#define x86_Convert_Init(state) { state = 0; } +size_t x86_Convert(uint8_t *data, size_t size, uint32_t ip, uint32_t *state, int encoding); +size_t ARM_Convert(uint8_t *data, size_t size, uint32_t ip, int encoding); +size_t ARMT_Convert(uint8_t *data, size_t size, uint32_t ip, int encoding); +size_t PPC_Convert(uint8_t *data, size_t size, uint32_t ip, int encoding); +size_t SPARC_Convert(uint8_t *data, size_t size, uint32_t ip, int encoding); +size_t IA64_Convert(uint8_t *data, size_t size, uint32_t ip, int encoding); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/deps/7zip/Bra86.c b/deps/7zip/Bra86.c index 6cb7bb17f5..d404527199 100644 --- a/deps/7zip/Bra86.c +++ b/deps/7zip/Bra86.c @@ -1,86 +1,86 @@ -/* Bra86.c -- Converter for x86 code (BCJ) - 2008-10-04 : Igor Pavlov : Public domain */ - -#include -#include "Bra.h" - -#define Test86MSuint8_t(b) ((b) == 0 || (b) == 0xFF) - -const uint8_t kMaskToAllowedStatus[8] = {1, 1, 1, 0, 1, 0, 0, 0}; -const uint8_t kMaskToBitNumber[8] = {0, 1, 2, 2, 3, 3, 3, 3}; - -size_t x86_Convert(uint8_t *data, size_t size, uint32_t ip, uint32_t *state, int encoding) -{ - size_t bufferPos = 0, prevPosT; - uint32_t prevMask = *state & 0x7; - if (size < 5) - return 0; - ip += 5; - prevPosT = (size_t)0 - 1; - - for (;;) - { - uint8_t *p = data + bufferPos; - uint8_t *limit = data + size - 4; - for (; p < limit; p++) - if ((*p & 0xFE) == 0xE8) - break; - bufferPos = (size_t)(p - data); - if (p >= limit) - break; - prevPosT = bufferPos - prevPosT; - if (prevPosT > 3) - prevMask = 0; - else - { - prevMask = (prevMask << ((int)prevPosT - 1)) & 0x7; - if (prevMask != 0) - { - uint8_t b = p[4 - kMaskToBitNumber[prevMask]]; - if (!kMaskToAllowedStatus[prevMask] || Test86MSuint8_t(b)) - { - prevPosT = bufferPos; - prevMask = ((prevMask << 1) & 0x7) | 1; - bufferPos++; - continue; - } - } - } - prevPosT = bufferPos; - - if (Test86MSuint8_t(p[4])) - { - uint32_t src = ((uint32_t)p[4] << 24) | ((uint32_t)p[3] << 16) | ((uint32_t)p[2] << 8) | ((uint32_t)p[1]); - uint32_t dest; - for (;;) - { - uint8_t b; - int idx; - if (encoding) - dest = (ip + (uint32_t)bufferPos) + src; - else - dest = src - (ip + (uint32_t)bufferPos); - if (prevMask == 0) - break; - idx = kMaskToBitNumber[prevMask] * 8; - b = (uint8_t)(dest >> (24 - idx)); - if (!Test86MSuint8_t(b)) - break; - src = dest ^ ((1 << (32 - idx)) - 1); - } - p[4] = (uint8_t)(~(((dest >> 24) & 1) - 1)); - p[3] = (uint8_t)(dest >> 16); - p[2] = (uint8_t)(dest >> 8); - p[1] = (uint8_t)dest; - bufferPos += 5; - } - else - { - prevMask = ((prevMask << 1) & 0x7) | 1; - bufferPos++; - } - } - prevPosT = bufferPos - prevPosT; - *state = ((prevPosT > 3) ? 0 : ((prevMask << ((int)prevPosT - 1)) & 0x7)); - return bufferPos; -} +/* Bra86.c -- Converter for x86 code (BCJ) + 2008-10-04 : Igor Pavlov : Public domain */ + +#include +#include "Bra.h" + +#define Test86MSuint8_t(b) ((b) == 0 || (b) == 0xFF) + +const uint8_t kMaskToAllowedStatus[8] = {1, 1, 1, 0, 1, 0, 0, 0}; +const uint8_t kMaskToBitNumber[8] = {0, 1, 2, 2, 3, 3, 3, 3}; + +size_t x86_Convert(uint8_t *data, size_t size, uint32_t ip, uint32_t *state, int encoding) +{ + size_t bufferPos = 0, prevPosT; + uint32_t prevMask = *state & 0x7; + if (size < 5) + return 0; + ip += 5; + prevPosT = (size_t)0 - 1; + + for (;;) + { + uint8_t *p = data + bufferPos; + uint8_t *limit = data + size - 4; + for (; p < limit; p++) + if ((*p & 0xFE) == 0xE8) + break; + bufferPos = (size_t)(p - data); + if (p >= limit) + break; + prevPosT = bufferPos - prevPosT; + if (prevPosT > 3) + prevMask = 0; + else + { + prevMask = (prevMask << ((int)prevPosT - 1)) & 0x7; + if (prevMask != 0) + { + uint8_t b = p[4 - kMaskToBitNumber[prevMask]]; + if (!kMaskToAllowedStatus[prevMask] || Test86MSuint8_t(b)) + { + prevPosT = bufferPos; + prevMask = ((prevMask << 1) & 0x7) | 1; + bufferPos++; + continue; + } + } + } + prevPosT = bufferPos; + + if (Test86MSuint8_t(p[4])) + { + uint32_t src = ((uint32_t)p[4] << 24) | ((uint32_t)p[3] << 16) | ((uint32_t)p[2] << 8) | ((uint32_t)p[1]); + uint32_t dest; + for (;;) + { + uint8_t b; + int idx; + if (encoding) + dest = (ip + (uint32_t)bufferPos) + src; + else + dest = src - (ip + (uint32_t)bufferPos); + if (prevMask == 0) + break; + idx = kMaskToBitNumber[prevMask] * 8; + b = (uint8_t)(dest >> (24 - idx)); + if (!Test86MSuint8_t(b)) + break; + src = dest ^ ((1 << (32 - idx)) - 1); + } + p[4] = (uint8_t)(~(((dest >> 24) & 1) - 1)); + p[3] = (uint8_t)(dest >> 16); + p[2] = (uint8_t)(dest >> 8); + p[1] = (uint8_t)dest; + bufferPos += 5; + } + else + { + prevMask = ((prevMask << 1) & 0x7) | 1; + bufferPos++; + } + } + prevPosT = bufferPos - prevPosT; + *state = ((prevPosT > 3) ? 0 : ((prevMask << ((int)prevPosT - 1)) & 0x7)); + return bufferPos; +} diff --git a/deps/7zip/CpuArch.h b/deps/7zip/CpuArch.h index 700945f617..b223f1a7cb 100644 --- a/deps/7zip/CpuArch.h +++ b/deps/7zip/CpuArch.h @@ -1,71 +1,71 @@ -/* CpuArch.h -- CPU specific code -2010-10-26: Igor Pavlov : Public domain */ - -#ifndef __CPU_ARCH_H -#define __CPU_ARCH_H - -#include "7zTypes.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* -MY_CPU_LE_UNALIGN means that CPU is LITTLE ENDIAN and CPU supports unaligned memory accesses. -If MY_CPU_LE_UNALIGN is not defined, we don't know about these properties of platform. -*/ - -#if defined(_M_X64) || defined(_M_AMD64) || defined(__x86_64__) -#define MY_CPU_AMD64 -#endif - -#if defined(MY_CPU_AMD64) || defined(_M_IA64) -#define MY_CPU_64BIT -#endif - -#if defined(_M_IX86) || defined(__i386__) -#define MY_CPU_X86 -#endif - -#if defined(MY_CPU_X86) || defined(MY_CPU_AMD64) -#define MY_CPU_X86_OR_AMD64 -#endif - -#if defined(MY_CPU_X86) || defined(_M_ARM) -#define MY_CPU_32BIT -#endif - -#if defined(_WIN32) && defined(_M_ARM) -#define MY_CPU_ARM_LE -#endif - -#if defined(_WIN32) && defined(_M_IA64) -#define MY_CPU_IA64_LE -#endif - -#if defined(MY_CPU_X86_OR_AMD64) -#define MY_CPU_LE_UNALIGN -#endif - -#ifdef MY_CPU_LE_UNALIGN - -#define GetUi16(p) (*(const uint16_t *)(p)) -#define GetUi32(p) (*(const uint32_t *)(p)) -#define GetUi64(p) (*(const uint64_t *)(p)) -#else -#define GetUi16(p) (((const uint8_t *)(p))[0] | ((uint16_t)((const uint8_t *)(p))[1] << 8)) - -#define GetUi32(p) ( \ - ((const uint8_t *)(p))[0] | \ - ((uint32_t)((const uint8_t *)(p))[1] << 8) | \ - ((uint32_t)((const uint8_t *)(p))[2] << 16) | \ - ((uint32_t)((const uint8_t *)(p))[3] << 24)) - -#define GetUi64(p) (GetUi32(p) | ((uint64_t)GetUi32(((const uint8_t *)(p)) + 4) << 32)) -#endif - -#ifdef __cplusplus -} -#endif - -#endif +/* CpuArch.h -- CPU specific code +2010-10-26: Igor Pavlov : Public domain */ + +#ifndef __CPU_ARCH_H +#define __CPU_ARCH_H + +#include "7zTypes.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* +MY_CPU_LE_UNALIGN means that CPU is LITTLE ENDIAN and CPU supports unaligned memory accesses. +If MY_CPU_LE_UNALIGN is not defined, we don't know about these properties of platform. +*/ + +#if defined(_M_X64) || defined(_M_AMD64) || defined(__x86_64__) +#define MY_CPU_AMD64 +#endif + +#if defined(MY_CPU_AMD64) || defined(_M_IA64) +#define MY_CPU_64BIT +#endif + +#if defined(_M_IX86) || defined(__i386__) +#define MY_CPU_X86 +#endif + +#if defined(MY_CPU_X86) || defined(MY_CPU_AMD64) +#define MY_CPU_X86_OR_AMD64 +#endif + +#if defined(MY_CPU_X86) || defined(_M_ARM) +#define MY_CPU_32BIT +#endif + +#if defined(_WIN32) && defined(_M_ARM) +#define MY_CPU_ARM_LE +#endif + +#if defined(_WIN32) && defined(_M_IA64) +#define MY_CPU_IA64_LE +#endif + +#if defined(MY_CPU_X86_OR_AMD64) +#define MY_CPU_LE_UNALIGN +#endif + +#ifdef MY_CPU_LE_UNALIGN + +#define GetUi16(p) (*(const uint16_t *)(p)) +#define GetUi32(p) (*(const uint32_t *)(p)) +#define GetUi64(p) (*(const uint64_t *)(p)) +#else +#define GetUi16(p) (((const uint8_t *)(p))[0] | ((uint16_t)((const uint8_t *)(p))[1] << 8)) + +#define GetUi32(p) ( \ + ((const uint8_t *)(p))[0] | \ + ((uint32_t)((const uint8_t *)(p))[1] << 8) | \ + ((uint32_t)((const uint8_t *)(p))[2] << 16) | \ + ((uint32_t)((const uint8_t *)(p))[3] << 24)) + +#define GetUi64(p) (GetUi32(p) | ((uint64_t)GetUi32(((const uint8_t *)(p)) + 4) << 32)) +#endif + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/deps/7zip/LzFind.c b/deps/7zip/LzFind.c index e41014e65f..0ad8c2c733 100644 --- a/deps/7zip/LzFind.c +++ b/deps/7zip/LzFind.c @@ -73,7 +73,7 @@ static void MatchFinder_ReadBlock(CMatchFinder *p) p->streamEndWasReached = 1; return; } - + for (;;) { unsigned char *dest = p->buffer + (p->streamPos - p->pos); @@ -179,24 +179,24 @@ int MatchFinder_Create(CMatchFinder *p, uint32_t historySize, ISzAlloc *alloc) { uint32_t sizeReserv; - + if (historySize > LzFindkMaxHistorySize) { MatchFinder_Free(p, alloc); return 0; } - + sizeReserv = historySize >> 1; if (historySize >= ((uint32_t)3 << 30)) sizeReserv = historySize >> 3; else if (historySize >= ((uint32_t)2 << 30)) sizeReserv = historySize >> 2; - + sizeReserv += (keepAddBufferBefore + matchMaxLen + keepAddBufferAfter) / 2 + (1 << 19); p->keepSizeBefore = historySize + keepAddBufferBefore + 1; p->keepSizeAfter = matchMaxLen + keepAddBufferAfter; - + /* we need one additional byte, since we use MoveBlock after pos++ and before dictionary using */ - + if (LzInWindow_Create(p, sizeReserv, alloc)) { uint32_t newCyclicBufferSize = historySize + 1; @@ -238,7 +238,7 @@ int MatchFinder_Create(CMatchFinder *p, uint32_t historySize, p->historySize = historySize; p->hashSizeSum = hs; p->cyclicBufferSize = newCyclicBufferSize; - + numSons = newCyclicBufferSize; if (p->btMode) numSons <<= 1; @@ -246,11 +246,11 @@ int MatchFinder_Create(CMatchFinder *p, uint32_t historySize, if (p->hash && p->numRefs == newSize) return 1; - + MatchFinder_FreeThisClassMemory(p, alloc); p->numRefs = newSize; p->hash = AllocRefs(newSize, alloc); - + if (p->hash) { p->son = p->hash + p->hashSizeSum; @@ -267,11 +267,11 @@ static void MatchFinder_SetLimits(CMatchFinder *p) { uint32_t limit = kMaxValForNormalize - p->pos; uint32_t limit2 = p->cyclicBufferSize - p->cyclicBufferPos; - + if (limit2 < limit) limit = limit2; limit2 = p->streamPos - p->pos; - + if (limit2 <= p->keepSizeAfter) { if (limit2 > 0) @@ -279,10 +279,10 @@ static void MatchFinder_SetLimits(CMatchFinder *p) } else limit2 -= p->keepSizeAfter; - + if (limit2 < limit) limit = limit2; - + { uint32_t lenLimit = p->streamPos - p->pos; if (lenLimit > p->matchMaxLen) @@ -299,16 +299,16 @@ void MatchFinder_Init_2(CMatchFinder *p, int readData) uint32_t num = p->hashSizeSum; for (i = 0; i < num; i++) hash[i] = kEmptyHashValue; - + p->cyclicBufferPos = 0; p->buffer = p->bufferBase; p->pos = p->streamPos = p->cyclicBufferSize; p->result = SZ_OK; p->streamEndWasReached = 0; - + if (readData) MatchFinder_ReadBlock(p); - + MatchFinder_SetLimits(p); } @@ -316,7 +316,7 @@ void MatchFinder_Init(CMatchFinder *p) { MatchFinder_Init_2(p, true); } - + static uint32_t MatchFinder_GetSubValue(CMatchFinder *p) { return (p->pos - p->historySize - 1) & kNormalizeMask; @@ -559,7 +559,7 @@ static uint32_t Bt3_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances) d2 = pos - hash[h2]; curMatch = hash[kFix3HashSize + hv]; - + hash[h2] = pos; hash[kFix3HashSize + hv] = pos; @@ -578,7 +578,7 @@ static uint32_t Bt3_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances) MOVE_POS_RET; } } - + GET_MATCHES_FOOTER(offset, maxLen) } @@ -604,14 +604,14 @@ static uint32_t Bt4_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances) maxLen = 0; offset = 0; - + if (d2 < p->cyclicBufferSize && *(cur - d2) == *cur) { distances[0] = maxLen = 2; distances[1] = d2 - 1; offset = 2; } - + if (d2 != d3 && d3 < p->cyclicBufferSize && *(cur - d3) == *cur) { maxLen = 3; @@ -619,7 +619,7 @@ static uint32_t Bt4_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances) offset += 2; d2 = d3; } - + if (offset != 0) { UPDATE_maxLen @@ -630,10 +630,10 @@ static uint32_t Bt4_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances) MOVE_POS_RET; } } - + if (maxLen < 3) maxLen = 3; - + GET_MATCHES_FOOTER(offset, maxLen) } @@ -647,10 +647,10 @@ static uint32_t Hc4_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances) hash = p->hash; pos = p->pos; - + d2 = pos - hash[ h2]; d3 = pos - hash[kFix3HashSize + h3]; - + curMatch = hash[kFix4HashSize + hv]; hash[ h2] = pos; @@ -666,7 +666,7 @@ static uint32_t Hc4_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances) distances[1] = d2 - 1; offset = 2; } - + if (d2 != d3 && d3 < p->cyclicBufferSize && *(cur - d3) == *cur) { maxLen = 3; @@ -674,7 +674,7 @@ static uint32_t Hc4_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances) offset += 2; d2 = d3; } - + if (offset != 0) { UPDATE_maxLen @@ -685,7 +685,7 @@ static uint32_t Hc4_MatchFinder_GetMatches(CMatchFinder *p, uint32_t *distances) MOVE_POS_RET; } } - + if (maxLen < 3) maxLen = 3; diff --git a/deps/7zip/LzFind.h b/deps/7zip/LzFind.h index a7fc117536..063eceb5e4 100644 --- a/deps/7zip/LzFind.h +++ b/deps/7zip/LzFind.h @@ -34,7 +34,7 @@ typedef struct _CMatchFinder unsigned char *bufferBase; ISeqInStream *stream; - + uint32_t blockSize; uint32_t keepSizeBefore; uint32_t keepSizeAfter; @@ -57,7 +57,7 @@ typedef struct _CMatchFinder ((p)->streamEndWasReached \ && (p)->streamPos == (p)->pos \ && (!(p)->directInput || (p)->directInputRem == 0)) - + int MatchFinder_NeedMove(CMatchFinder *p); unsigned char *MatchFinder_GetPointerToCurrentPos(CMatchFinder *p); void MatchFinder_MoveBlock(CMatchFinder *p); diff --git a/deps/7zip/Lzma2Dec.c b/deps/7zip/Lzma2Dec.c index a99b1f91b3..5b8a61c7d5 100644 --- a/deps/7zip/Lzma2Dec.c +++ b/deps/7zip/Lzma2Dec.c @@ -1,347 +1,347 @@ -/* Lzma2Dec.c -- LZMA2 Decoder - 2009-05-03 : Igor Pavlov : Public domain */ - -#include -#include - -#include "Lzma2Dec.h" - -/* - 00000000 - EOS - 00000001 U U - Uncompressed Reset Dic - 00000010 U U - Uncompressed No Reset - 100uuuuu U U P P - LZMA no reset - 101uuuuu U U P P - LZMA reset state - 110uuuuu U U P P S - LZMA reset state + new prop - 111uuuuu U U P P S - LZMA reset state + new prop + reset dic - - u, U - Unpack Size - P - Pack Size - S - Props - */ - -#define LZMA2_CONTROL_LZMA (1 << 7) -#define LZMA2_CONTROL_COPY_NO_RESET 2 -#define LZMA2_CONTROL_COPY_RESET_DIC 1 -#define LZMA2_CONTROL_EOF 0 - -#define LZMA2_IS_UNCOMPRESSED_STATE(p) (((p)->control & LZMA2_CONTROL_LZMA) == 0) - -#define LZMA2_GET_LZMA_MODE(p) (((p)->control >> 5) & 3) -#define LZMA2_IS_THERE_PROP(mode) ((mode) >= 2) - -#define LZMA2_LCLP_MAX 4 -#define LZMA2_DIC_SIZE_FROM_PROP(p) (((uint32_t)2 | ((p) & 1)) << ((p) / 2 + 11)) - -#define PRF(x) - -typedef enum -{ - LZMA2_STATE_CONTROL, - LZMA2_STATE_UNPACK0, - LZMA2_STATE_UNPACK1, - LZMA2_STATE_PACK0, - LZMA2_STATE_PACK1, - LZMA2_STATE_PROP, - LZMA2_STATE_DATA, - LZMA2_STATE_DATA_CONT, - LZMA2_STATE_FINISHED, - LZMA2_STATE_ERROR -} ELzma2State; - -static SRes Lzma2Dec_GetOldProps(uint8_t prop, uint8_t *props) -{ - uint32_t dicSize; - if (prop > 40) - return SZ_ERROR_UNSUPPORTED; - dicSize = (prop == 40) ? 0xFFFFFFFF : LZMA2_DIC_SIZE_FROM_PROP(prop); - props[0] = (uint8_t)LZMA2_LCLP_MAX; - props[1] = (uint8_t)(dicSize); - props[2] = (uint8_t)(dicSize >> 8); - props[3] = (uint8_t)(dicSize >> 16); - props[4] = (uint8_t)(dicSize >> 24); - return SZ_OK; -} - -SRes Lzma2Dec_AllocateProbs(CLzma2Dec *p, uint8_t prop, ISzAlloc *alloc) -{ - uint8_t props[LZMA_PROPS_SIZE]; - RINOK(Lzma2Dec_GetOldProps(prop, props)); - return LzmaDec_AllocateProbs(&p->decoder, props, LZMA_PROPS_SIZE, alloc); -} - -SRes Lzma2Dec_Allocate(CLzma2Dec *p, uint8_t prop, ISzAlloc *alloc) -{ - uint8_t props[LZMA_PROPS_SIZE]; - RINOK(Lzma2Dec_GetOldProps(prop, props)); - return LzmaDec_Allocate(&p->decoder, props, LZMA_PROPS_SIZE, alloc); -} - -void Lzma2Dec_Init(CLzma2Dec *p) -{ - p->state = LZMA2_STATE_CONTROL; - p->needInitDic = true; - p->needInitState = true; - p->needInitProp = true; - LzmaDec_Init(&p->decoder); -} - -static ELzma2State Lzma2Dec_UpdateState(CLzma2Dec *p, uint8_t b) -{ - switch(p->state) - { - case LZMA2_STATE_CONTROL: - p->control = b; - PRF(printf("\n %4X ", p->decoder.dicPos)); - PRF(printf(" %2X", b)); - if (p->control == 0) - return LZMA2_STATE_FINISHED; - if (LZMA2_IS_UNCOMPRESSED_STATE(p)) - { - if ((p->control & 0x7F) > 2) - return LZMA2_STATE_ERROR; - p->unpackSize = 0; - } - else - p->unpackSize = (uint32_t)(p->control & 0x1F) << 16; - return LZMA2_STATE_UNPACK0; - - case LZMA2_STATE_UNPACK0: - p->unpackSize |= (uint32_t)b << 8; - return LZMA2_STATE_UNPACK1; - - case LZMA2_STATE_UNPACK1: - p->unpackSize |= (uint32_t)b; - p->unpackSize++; - PRF(printf(" %8d", p->unpackSize)); - return (LZMA2_IS_UNCOMPRESSED_STATE(p)) ? LZMA2_STATE_DATA : LZMA2_STATE_PACK0; - - case LZMA2_STATE_PACK0: - p->packSize = (uint32_t)b << 8; - return LZMA2_STATE_PACK1; - - case LZMA2_STATE_PACK1: - p->packSize |= (uint32_t)b; - p->packSize++; - PRF(printf(" %8d", p->packSize)); - return LZMA2_IS_THERE_PROP(LZMA2_GET_LZMA_MODE(p)) ? LZMA2_STATE_PROP: - (p->needInitProp ? LZMA2_STATE_ERROR : LZMA2_STATE_DATA); - - case LZMA2_STATE_PROP: - { - int lc, lp; - if (b >= (9 * 5 * 5)) - return LZMA2_STATE_ERROR; - lc = b % 9; - b /= 9; - p->decoder.prop.pb = b / 5; - lp = b % 5; - if (lc + lp > LZMA2_LCLP_MAX) - return LZMA2_STATE_ERROR; - p->decoder.prop.lc = lc; - p->decoder.prop.lp = lp; - p->needInitProp = false; - return LZMA2_STATE_DATA; - } - } - return LZMA2_STATE_ERROR; -} - -static void LzmaDec_UpdateWithUncompressed(CLzmaDec *p, const uint8_t *src, size_t size) -{ - memcpy(p->dic + p->dicPos, src, size); - p->dicPos += size; - if (p->checkDicSize == 0 && p->prop.dicSize - p->processedPos <= size) - p->checkDicSize = p->prop.dicSize; - p->processedPos += (uint32_t)size; -} - -void LzmaDec_InitDicAndState(CLzmaDec *p, bool initDic, bool initState); - -SRes Lzma2Dec_DecodeToDic(CLzma2Dec *p, size_t dicLimit, - const uint8_t *src, size_t *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status) -{ - size_t inSize = *srcLen; - *srcLen = 0; - *status = LZMA_STATUS_NOT_SPECIFIED; - - while (p->state != LZMA2_STATE_FINISHED) - { - size_t dicPos = p->decoder.dicPos; - if (p->state == LZMA2_STATE_ERROR) - return SZ_ERROR_DATA; - if (dicPos == dicLimit && finishMode == LZMA_FINISH_ANY) - { - *status = LZMA_STATUS_NOT_FINISHED; - return SZ_OK; - } - if (p->state != LZMA2_STATE_DATA && p->state != LZMA2_STATE_DATA_CONT) - { - if (*srcLen == inSize) - { - *status = LZMA_STATUS_NEEDS_MORE_INPUT; - return SZ_OK; - } - (*srcLen)++; - p->state = Lzma2Dec_UpdateState(p, *src++); - continue; - } - { - size_t destSizeCur = dicLimit - dicPos; - size_t srcSizeCur = inSize - *srcLen; - ELzmaFinishMode curFinishMode = LZMA_FINISH_ANY; - - if (p->unpackSize <= destSizeCur) - { - destSizeCur = (size_t)p->unpackSize; - curFinishMode = LZMA_FINISH_END; - } - - if (LZMA2_IS_UNCOMPRESSED_STATE(p)) - { - if (*srcLen == inSize) - { - *status = LZMA_STATUS_NEEDS_MORE_INPUT; - return SZ_OK; - } - - if (p->state == LZMA2_STATE_DATA) - { - bool initDic = (p->control == LZMA2_CONTROL_COPY_RESET_DIC); - if (initDic) - p->needInitProp = p->needInitState = true; - else if (p->needInitDic) - return SZ_ERROR_DATA; - p->needInitDic = false; - LzmaDec_InitDicAndState(&p->decoder, initDic, false); - } - - if (srcSizeCur > destSizeCur) - srcSizeCur = destSizeCur; - - if (srcSizeCur == 0) - return SZ_ERROR_DATA; - - LzmaDec_UpdateWithUncompressed(&p->decoder, src, srcSizeCur); - - src += srcSizeCur; - *srcLen += srcSizeCur; - p->unpackSize -= (uint32_t)srcSizeCur; - p->state = (p->unpackSize == 0) ? LZMA2_STATE_CONTROL : LZMA2_STATE_DATA_CONT; - } - else - { - size_t outSizeProcessed; - SRes res; - - if (p->state == LZMA2_STATE_DATA) - { - int mode = LZMA2_GET_LZMA_MODE(p); - bool initDic = (mode == 3); - bool initState = (mode > 0); - if ((!initDic && p->needInitDic) || (!initState && p->needInitState)) - return SZ_ERROR_DATA; - - LzmaDec_InitDicAndState(&p->decoder, initDic, initState); - p->needInitDic = false; - p->needInitState = false; - p->state = LZMA2_STATE_DATA_CONT; - } - if (srcSizeCur > p->packSize) - srcSizeCur = (size_t)p->packSize; - - res = LzmaDec_DecodeToDic(&p->decoder, dicPos + destSizeCur, src, &srcSizeCur, curFinishMode, status); - - src += srcSizeCur; - *srcLen += srcSizeCur; - p->packSize -= (uint32_t)srcSizeCur; - - outSizeProcessed = p->decoder.dicPos - dicPos; - p->unpackSize -= (uint32_t)outSizeProcessed; - - RINOK(res); - if (*status == LZMA_STATUS_NEEDS_MORE_INPUT) - return res; - - if (srcSizeCur == 0 && outSizeProcessed == 0) - { - if (*status != LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK || - p->unpackSize != 0 || p->packSize != 0) - return SZ_ERROR_DATA; - p->state = LZMA2_STATE_CONTROL; - } - if (*status == LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK) - *status = LZMA_STATUS_NOT_FINISHED; - } - } - } - *status = LZMA_STATUS_FINISHED_WITH_MARK; - return SZ_OK; -} - -SRes Lzma2Dec_DecodeToBuf(CLzma2Dec *p, uint8_t *dest, size_t *destLen, const uint8_t *src, size_t *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status) -{ - size_t outSize = *destLen, inSize = *srcLen; - *srcLen = *destLen = 0; - for (;;) - { - size_t srcSizeCur = inSize, outSizeCur, dicPos; - ELzmaFinishMode curFinishMode; - SRes res; - if (p->decoder.dicPos == p->decoder.dicBufSize) - p->decoder.dicPos = 0; - dicPos = p->decoder.dicPos; - if (outSize > p->decoder.dicBufSize - dicPos) - { - outSizeCur = p->decoder.dicBufSize; - curFinishMode = LZMA_FINISH_ANY; - } - else - { - outSizeCur = dicPos + outSize; - curFinishMode = finishMode; - } - - res = Lzma2Dec_DecodeToDic(p, outSizeCur, src, &srcSizeCur, curFinishMode, status); - src += srcSizeCur; - inSize -= srcSizeCur; - *srcLen += srcSizeCur; - outSizeCur = p->decoder.dicPos - dicPos; - memcpy(dest, p->decoder.dic + dicPos, outSizeCur); - dest += outSizeCur; - outSize -= outSizeCur; - *destLen += outSizeCur; - if (res != 0) - return res; - if (outSizeCur == 0 || outSize == 0) - return SZ_OK; - } -} - -SRes Lzma2Decode(uint8_t *dest, size_t *destLen, const uint8_t *src, size_t *srcLen, - uint8_t prop, ELzmaFinishMode finishMode, ELzmaStatus *status, ISzAlloc *alloc) -{ - CLzma2Dec decoder; - SRes res; - size_t outSize = *destLen, inSize = *srcLen; - uint8_t props[LZMA_PROPS_SIZE]; - - Lzma2Dec_Construct(&decoder); - - *destLen = *srcLen = 0; - *status = LZMA_STATUS_NOT_SPECIFIED; - decoder.decoder.dic = dest; - decoder.decoder.dicBufSize = outSize; - - RINOK(Lzma2Dec_GetOldProps(prop, props)); - RINOK(LzmaDec_AllocateProbs(&decoder.decoder, props, LZMA_PROPS_SIZE, alloc)); - - *srcLen = inSize; - res = Lzma2Dec_DecodeToDic(&decoder, outSize, src, srcLen, finishMode, status); - *destLen = decoder.decoder.dicPos; - if (res == SZ_OK && *status == LZMA_STATUS_NEEDS_MORE_INPUT) - res = SZ_ERROR_INPUT_EOF; - - LzmaDec_FreeProbs(&decoder.decoder, alloc); - return res; -} +/* Lzma2Dec.c -- LZMA2 Decoder + 2009-05-03 : Igor Pavlov : Public domain */ + +#include +#include + +#include "Lzma2Dec.h" + +/* + 00000000 - EOS + 00000001 U U - Uncompressed Reset Dic + 00000010 U U - Uncompressed No Reset + 100uuuuu U U P P - LZMA no reset + 101uuuuu U U P P - LZMA reset state + 110uuuuu U U P P S - LZMA reset state + new prop + 111uuuuu U U P P S - LZMA reset state + new prop + reset dic + + u, U - Unpack Size + P - Pack Size + S - Props + */ + +#define LZMA2_CONTROL_LZMA (1 << 7) +#define LZMA2_CONTROL_COPY_NO_RESET 2 +#define LZMA2_CONTROL_COPY_RESET_DIC 1 +#define LZMA2_CONTROL_EOF 0 + +#define LZMA2_IS_UNCOMPRESSED_STATE(p) (((p)->control & LZMA2_CONTROL_LZMA) == 0) + +#define LZMA2_GET_LZMA_MODE(p) (((p)->control >> 5) & 3) +#define LZMA2_IS_THERE_PROP(mode) ((mode) >= 2) + +#define LZMA2_LCLP_MAX 4 +#define LZMA2_DIC_SIZE_FROM_PROP(p) (((uint32_t)2 | ((p) & 1)) << ((p) / 2 + 11)) + +#define PRF(x) + +typedef enum +{ + LZMA2_STATE_CONTROL, + LZMA2_STATE_UNPACK0, + LZMA2_STATE_UNPACK1, + LZMA2_STATE_PACK0, + LZMA2_STATE_PACK1, + LZMA2_STATE_PROP, + LZMA2_STATE_DATA, + LZMA2_STATE_DATA_CONT, + LZMA2_STATE_FINISHED, + LZMA2_STATE_ERROR +} ELzma2State; + +static SRes Lzma2Dec_GetOldProps(uint8_t prop, uint8_t *props) +{ + uint32_t dicSize; + if (prop > 40) + return SZ_ERROR_UNSUPPORTED; + dicSize = (prop == 40) ? 0xFFFFFFFF : LZMA2_DIC_SIZE_FROM_PROP(prop); + props[0] = (uint8_t)LZMA2_LCLP_MAX; + props[1] = (uint8_t)(dicSize); + props[2] = (uint8_t)(dicSize >> 8); + props[3] = (uint8_t)(dicSize >> 16); + props[4] = (uint8_t)(dicSize >> 24); + return SZ_OK; +} + +SRes Lzma2Dec_AllocateProbs(CLzma2Dec *p, uint8_t prop, ISzAlloc *alloc) +{ + uint8_t props[LZMA_PROPS_SIZE]; + RINOK(Lzma2Dec_GetOldProps(prop, props)); + return LzmaDec_AllocateProbs(&p->decoder, props, LZMA_PROPS_SIZE, alloc); +} + +SRes Lzma2Dec_Allocate(CLzma2Dec *p, uint8_t prop, ISzAlloc *alloc) +{ + uint8_t props[LZMA_PROPS_SIZE]; + RINOK(Lzma2Dec_GetOldProps(prop, props)); + return LzmaDec_Allocate(&p->decoder, props, LZMA_PROPS_SIZE, alloc); +} + +void Lzma2Dec_Init(CLzma2Dec *p) +{ + p->state = LZMA2_STATE_CONTROL; + p->needInitDic = true; + p->needInitState = true; + p->needInitProp = true; + LzmaDec_Init(&p->decoder); +} + +static ELzma2State Lzma2Dec_UpdateState(CLzma2Dec *p, uint8_t b) +{ + switch(p->state) + { + case LZMA2_STATE_CONTROL: + p->control = b; + PRF(printf("\n %4X ", p->decoder.dicPos)); + PRF(printf(" %2X", b)); + if (p->control == 0) + return LZMA2_STATE_FINISHED; + if (LZMA2_IS_UNCOMPRESSED_STATE(p)) + { + if ((p->control & 0x7F) > 2) + return LZMA2_STATE_ERROR; + p->unpackSize = 0; + } + else + p->unpackSize = (uint32_t)(p->control & 0x1F) << 16; + return LZMA2_STATE_UNPACK0; + + case LZMA2_STATE_UNPACK0: + p->unpackSize |= (uint32_t)b << 8; + return LZMA2_STATE_UNPACK1; + + case LZMA2_STATE_UNPACK1: + p->unpackSize |= (uint32_t)b; + p->unpackSize++; + PRF(printf(" %8d", p->unpackSize)); + return (LZMA2_IS_UNCOMPRESSED_STATE(p)) ? LZMA2_STATE_DATA : LZMA2_STATE_PACK0; + + case LZMA2_STATE_PACK0: + p->packSize = (uint32_t)b << 8; + return LZMA2_STATE_PACK1; + + case LZMA2_STATE_PACK1: + p->packSize |= (uint32_t)b; + p->packSize++; + PRF(printf(" %8d", p->packSize)); + return LZMA2_IS_THERE_PROP(LZMA2_GET_LZMA_MODE(p)) ? LZMA2_STATE_PROP: + (p->needInitProp ? LZMA2_STATE_ERROR : LZMA2_STATE_DATA); + + case LZMA2_STATE_PROP: + { + int lc, lp; + if (b >= (9 * 5 * 5)) + return LZMA2_STATE_ERROR; + lc = b % 9; + b /= 9; + p->decoder.prop.pb = b / 5; + lp = b % 5; + if (lc + lp > LZMA2_LCLP_MAX) + return LZMA2_STATE_ERROR; + p->decoder.prop.lc = lc; + p->decoder.prop.lp = lp; + p->needInitProp = false; + return LZMA2_STATE_DATA; + } + } + return LZMA2_STATE_ERROR; +} + +static void LzmaDec_UpdateWithUncompressed(CLzmaDec *p, const uint8_t *src, size_t size) +{ + memcpy(p->dic + p->dicPos, src, size); + p->dicPos += size; + if (p->checkDicSize == 0 && p->prop.dicSize - p->processedPos <= size) + p->checkDicSize = p->prop.dicSize; + p->processedPos += (uint32_t)size; +} + +void LzmaDec_InitDicAndState(CLzmaDec *p, bool initDic, bool initState); + +SRes Lzma2Dec_DecodeToDic(CLzma2Dec *p, size_t dicLimit, + const uint8_t *src, size_t *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status) +{ + size_t inSize = *srcLen; + *srcLen = 0; + *status = LZMA_STATUS_NOT_SPECIFIED; + + while (p->state != LZMA2_STATE_FINISHED) + { + size_t dicPos = p->decoder.dicPos; + if (p->state == LZMA2_STATE_ERROR) + return SZ_ERROR_DATA; + if (dicPos == dicLimit && finishMode == LZMA_FINISH_ANY) + { + *status = LZMA_STATUS_NOT_FINISHED; + return SZ_OK; + } + if (p->state != LZMA2_STATE_DATA && p->state != LZMA2_STATE_DATA_CONT) + { + if (*srcLen == inSize) + { + *status = LZMA_STATUS_NEEDS_MORE_INPUT; + return SZ_OK; + } + (*srcLen)++; + p->state = Lzma2Dec_UpdateState(p, *src++); + continue; + } + { + size_t destSizeCur = dicLimit - dicPos; + size_t srcSizeCur = inSize - *srcLen; + ELzmaFinishMode curFinishMode = LZMA_FINISH_ANY; + + if (p->unpackSize <= destSizeCur) + { + destSizeCur = (size_t)p->unpackSize; + curFinishMode = LZMA_FINISH_END; + } + + if (LZMA2_IS_UNCOMPRESSED_STATE(p)) + { + if (*srcLen == inSize) + { + *status = LZMA_STATUS_NEEDS_MORE_INPUT; + return SZ_OK; + } + + if (p->state == LZMA2_STATE_DATA) + { + bool initDic = (p->control == LZMA2_CONTROL_COPY_RESET_DIC); + if (initDic) + p->needInitProp = p->needInitState = true; + else if (p->needInitDic) + return SZ_ERROR_DATA; + p->needInitDic = false; + LzmaDec_InitDicAndState(&p->decoder, initDic, false); + } + + if (srcSizeCur > destSizeCur) + srcSizeCur = destSizeCur; + + if (srcSizeCur == 0) + return SZ_ERROR_DATA; + + LzmaDec_UpdateWithUncompressed(&p->decoder, src, srcSizeCur); + + src += srcSizeCur; + *srcLen += srcSizeCur; + p->unpackSize -= (uint32_t)srcSizeCur; + p->state = (p->unpackSize == 0) ? LZMA2_STATE_CONTROL : LZMA2_STATE_DATA_CONT; + } + else + { + size_t outSizeProcessed; + SRes res; + + if (p->state == LZMA2_STATE_DATA) + { + int mode = LZMA2_GET_LZMA_MODE(p); + bool initDic = (mode == 3); + bool initState = (mode > 0); + if ((!initDic && p->needInitDic) || (!initState && p->needInitState)) + return SZ_ERROR_DATA; + + LzmaDec_InitDicAndState(&p->decoder, initDic, initState); + p->needInitDic = false; + p->needInitState = false; + p->state = LZMA2_STATE_DATA_CONT; + } + if (srcSizeCur > p->packSize) + srcSizeCur = (size_t)p->packSize; + + res = LzmaDec_DecodeToDic(&p->decoder, dicPos + destSizeCur, src, &srcSizeCur, curFinishMode, status); + + src += srcSizeCur; + *srcLen += srcSizeCur; + p->packSize -= (uint32_t)srcSizeCur; + + outSizeProcessed = p->decoder.dicPos - dicPos; + p->unpackSize -= (uint32_t)outSizeProcessed; + + RINOK(res); + if (*status == LZMA_STATUS_NEEDS_MORE_INPUT) + return res; + + if (srcSizeCur == 0 && outSizeProcessed == 0) + { + if (*status != LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK || + p->unpackSize != 0 || p->packSize != 0) + return SZ_ERROR_DATA; + p->state = LZMA2_STATE_CONTROL; + } + if (*status == LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK) + *status = LZMA_STATUS_NOT_FINISHED; + } + } + } + *status = LZMA_STATUS_FINISHED_WITH_MARK; + return SZ_OK; +} + +SRes Lzma2Dec_DecodeToBuf(CLzma2Dec *p, uint8_t *dest, size_t *destLen, const uint8_t *src, size_t *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status) +{ + size_t outSize = *destLen, inSize = *srcLen; + *srcLen = *destLen = 0; + for (;;) + { + size_t srcSizeCur = inSize, outSizeCur, dicPos; + ELzmaFinishMode curFinishMode; + SRes res; + if (p->decoder.dicPos == p->decoder.dicBufSize) + p->decoder.dicPos = 0; + dicPos = p->decoder.dicPos; + if (outSize > p->decoder.dicBufSize - dicPos) + { + outSizeCur = p->decoder.dicBufSize; + curFinishMode = LZMA_FINISH_ANY; + } + else + { + outSizeCur = dicPos + outSize; + curFinishMode = finishMode; + } + + res = Lzma2Dec_DecodeToDic(p, outSizeCur, src, &srcSizeCur, curFinishMode, status); + src += srcSizeCur; + inSize -= srcSizeCur; + *srcLen += srcSizeCur; + outSizeCur = p->decoder.dicPos - dicPos; + memcpy(dest, p->decoder.dic + dicPos, outSizeCur); + dest += outSizeCur; + outSize -= outSizeCur; + *destLen += outSizeCur; + if (res != 0) + return res; + if (outSizeCur == 0 || outSize == 0) + return SZ_OK; + } +} + +SRes Lzma2Decode(uint8_t *dest, size_t *destLen, const uint8_t *src, size_t *srcLen, + uint8_t prop, ELzmaFinishMode finishMode, ELzmaStatus *status, ISzAlloc *alloc) +{ + CLzma2Dec decoder; + SRes res; + size_t outSize = *destLen, inSize = *srcLen; + uint8_t props[LZMA_PROPS_SIZE]; + + Lzma2Dec_Construct(&decoder); + + *destLen = *srcLen = 0; + *status = LZMA_STATUS_NOT_SPECIFIED; + decoder.decoder.dic = dest; + decoder.decoder.dicBufSize = outSize; + + RINOK(Lzma2Dec_GetOldProps(prop, props)); + RINOK(LzmaDec_AllocateProbs(&decoder.decoder, props, LZMA_PROPS_SIZE, alloc)); + + *srcLen = inSize; + res = Lzma2Dec_DecodeToDic(&decoder, outSize, src, srcLen, finishMode, status); + *destLen = decoder.decoder.dicPos; + if (res == SZ_OK && *status == LZMA_STATUS_NEEDS_MORE_INPUT) + res = SZ_ERROR_INPUT_EOF; + + LzmaDec_FreeProbs(&decoder.decoder, alloc); + return res; +} diff --git a/deps/7zip/Lzma2Dec.h b/deps/7zip/Lzma2Dec.h index 53797ae049..5ab3706b49 100644 --- a/deps/7zip/Lzma2Dec.h +++ b/deps/7zip/Lzma2Dec.h @@ -1,85 +1,85 @@ -/* Lzma2Dec.h -- LZMA2 Decoder -2009-05-03 : Igor Pavlov : Public domain */ - -#ifndef __LZMA2_DEC_H -#define __LZMA2_DEC_H - -#include -#include "LzmaDec.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* ---------- State Interface ---------- */ - -typedef struct -{ - CLzmaDec decoder; - uint32_t packSize; - uint32_t unpackSize; - int state; - uint8_t control; - bool needInitDic; - bool needInitState; - bool needInitProp; -} CLzma2Dec; - -#define Lzma2Dec_Construct(p) LzmaDec_Construct(&(p)->decoder) -#define Lzma2Dec_FreeProbs(p, alloc) LzmaDec_FreeProbs(&(p)->decoder, alloc); -#define Lzma2Dec_Free(p, alloc) LzmaDec_Free(&(p)->decoder, alloc); - -SRes Lzma2Dec_AllocateProbs(CLzma2Dec *p, uint8_t prop, ISzAlloc *alloc); -SRes Lzma2Dec_Allocate(CLzma2Dec *p, uint8_t prop, ISzAlloc *alloc); -void Lzma2Dec_Init(CLzma2Dec *p); - - -/* -finishMode: - It has meaning only if the decoding reaches output limit (*destLen or dicLimit). - LZMA_FINISH_ANY - use smallest number of input bytes - LZMA_FINISH_END - read EndOfStream marker after decoding - -Returns: - SZ_OK - status: - LZMA_STATUS_FINISHED_WITH_MARK - LZMA_STATUS_NOT_FINISHED - LZMA_STATUS_NEEDS_MORE_INPUT - SZ_ERROR_DATA - Data error -*/ - -SRes Lzma2Dec_DecodeToDic(CLzma2Dec *p, size_t dicLimit, - const uint8_t *src, size_t *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status); - -SRes Lzma2Dec_DecodeToBuf(CLzma2Dec *p, uint8_t *dest, size_t *destLen, - const uint8_t *src, size_t *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status); - - -/* ---------- One Call Interface ---------- */ - -/* -finishMode: - It has meaning only if the decoding reaches output limit (*destLen). - LZMA_FINISH_ANY - use smallest number of input bytes - LZMA_FINISH_END - read EndOfStream marker after decoding - -Returns: - SZ_OK - status: - LZMA_STATUS_FINISHED_WITH_MARK - LZMA_STATUS_NOT_FINISHED - SZ_ERROR_DATA - Data error - SZ_ERROR_MEM - Memory allocation error - SZ_ERROR_UNSUPPORTED - Unsupported properties - SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src). -*/ - -SRes Lzma2Decode(uint8_t *dest, size_t *destLen, const uint8_t *src, size_t *srcLen, - uint8_t prop, ELzmaFinishMode finishMode, ELzmaStatus *status, ISzAlloc *alloc); - -#ifdef __cplusplus -} -#endif - -#endif +/* Lzma2Dec.h -- LZMA2 Decoder +2009-05-03 : Igor Pavlov : Public domain */ + +#ifndef __LZMA2_DEC_H +#define __LZMA2_DEC_H + +#include +#include "LzmaDec.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* ---------- State Interface ---------- */ + +typedef struct +{ + CLzmaDec decoder; + uint32_t packSize; + uint32_t unpackSize; + int state; + uint8_t control; + bool needInitDic; + bool needInitState; + bool needInitProp; +} CLzma2Dec; + +#define Lzma2Dec_Construct(p) LzmaDec_Construct(&(p)->decoder) +#define Lzma2Dec_FreeProbs(p, alloc) LzmaDec_FreeProbs(&(p)->decoder, alloc); +#define Lzma2Dec_Free(p, alloc) LzmaDec_Free(&(p)->decoder, alloc); + +SRes Lzma2Dec_AllocateProbs(CLzma2Dec *p, uint8_t prop, ISzAlloc *alloc); +SRes Lzma2Dec_Allocate(CLzma2Dec *p, uint8_t prop, ISzAlloc *alloc); +void Lzma2Dec_Init(CLzma2Dec *p); + + +/* +finishMode: + It has meaning only if the decoding reaches output limit (*destLen or dicLimit). + LZMA_FINISH_ANY - use smallest number of input bytes + LZMA_FINISH_END - read EndOfStream marker after decoding + +Returns: + SZ_OK + status: + LZMA_STATUS_FINISHED_WITH_MARK + LZMA_STATUS_NOT_FINISHED + LZMA_STATUS_NEEDS_MORE_INPUT + SZ_ERROR_DATA - Data error +*/ + +SRes Lzma2Dec_DecodeToDic(CLzma2Dec *p, size_t dicLimit, + const uint8_t *src, size_t *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status); + +SRes Lzma2Dec_DecodeToBuf(CLzma2Dec *p, uint8_t *dest, size_t *destLen, + const uint8_t *src, size_t *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status); + + +/* ---------- One Call Interface ---------- */ + +/* +finishMode: + It has meaning only if the decoding reaches output limit (*destLen). + LZMA_FINISH_ANY - use smallest number of input bytes + LZMA_FINISH_END - read EndOfStream marker after decoding + +Returns: + SZ_OK + status: + LZMA_STATUS_FINISHED_WITH_MARK + LZMA_STATUS_NOT_FINISHED + SZ_ERROR_DATA - Data error + SZ_ERROR_MEM - Memory allocation error + SZ_ERROR_UNSUPPORTED - Unsupported properties + SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src). +*/ + +SRes Lzma2Decode(uint8_t *dest, size_t *destLen, const uint8_t *src, size_t *srcLen, + uint8_t prop, ELzmaFinishMode finishMode, ELzmaStatus *status, ISzAlloc *alloc); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/deps/7zip/LzmaDec.c b/deps/7zip/LzmaDec.c index 4a0a5a5faf..5325053939 100644 --- a/deps/7zip/LzmaDec.c +++ b/deps/7zip/LzmaDec.c @@ -1,1040 +1,1040 @@ -/* LzmaDec.c -- LZMA Decoder - 2009-09-20 : Igor Pavlov : Public domain */ -#include -#include -#include - -#include "LzmaDec.h" - -#define kNumTopBits 24 -#define kTopValue ((uint32_t)1 << kNumTopBits) - -#define kNumBitModelTotalBits 11 -#define kBitModelTotal (1 << kNumBitModelTotalBits) -#define kNumMoveBits 5 - -#define RC_INIT_SIZE 5 - -#define LZMADEC_NORMALIZE if (range < kTopValue) { range <<= 8; codes = (codes << 8) | (*buf++); } - -#define LZMADEC_IF_BIT_0(prob) ttt = *(prob); LZMADEC_NORMALIZE; bound = (range >> kNumBitModelTotalBits) * ttt; if (codes < bound) -#define UPDATE_0(p) range = bound; *(p) = (uint16_t)(ttt + ((kBitModelTotal - ttt) >> kNumMoveBits)); -#define LZMADEC_UPDATE_1(p) range -= bound; codes -= bound; *(p) = (uint16_t)(ttt - (ttt >> kNumMoveBits)); -#define GET_BIT2(p, i, A0, A1) LZMADEC_IF_BIT_0(p) \ -{ UPDATE_0(p); i = (i + i); A0; } else \ -{ LZMADEC_UPDATE_1(p); i = (i + i) + 1; A1; } -#define GET_BIT(p, i) GET_BIT2(p, i, ; , ;) - -#define TREE_GET_BIT(probs, i) { GET_BIT((probs + i), i); } -#define TREE_DECODE(probs, limit, i) \ -{ i = 1; do { TREE_GET_BIT(probs, i); } while (i < limit); i -= limit; } - -/* #define _LZMA_SIZE_OPT */ - -#ifdef _LZMA_SIZE_OPT -#define TREE_6_DECODE(probs, i) TREE_DECODE(probs, (1 << 6), i) -#else -#define TREE_6_DECODE(probs, i) \ -{ i = 1; \ - TREE_GET_BIT(probs, i); \ - TREE_GET_BIT(probs, i); \ - TREE_GET_BIT(probs, i); \ - TREE_GET_BIT(probs, i); \ - TREE_GET_BIT(probs, i); \ - TREE_GET_BIT(probs, i); \ - i -= 0x40; } -#endif - -#define NORMALIZE_CHECK if (range < kTopValue) { if (buf >= bufLimit) return DUMMY_ERROR; range <<= 8; codes = (codes << 8) | (*buf++); } - -#define IF_BIT_0_CHECK(p) ttt = *(p); NORMALIZE_CHECK; bound = (range >> kNumBitModelTotalBits) * ttt; if (codes < bound) -#define UPDATE_0_CHECK range = bound; -#define UPDATE_1_CHECK range -= bound; codes -= bound; -#define GET_BIT2_CHECK(p, i, A0, A1) IF_BIT_0_CHECK(p) \ -{ UPDATE_0_CHECK; i = (i + i); A0; } else \ -{ UPDATE_1_CHECK; i = (i + i) + 1; A1; } -#define GET_BIT_CHECK(p, i) GET_BIT2_CHECK(p, i, ; , ;) -#define TREE_DECODE_CHECK(probs, limit, i) \ -{ i = 1; do { GET_BIT_CHECK(probs + i, i) } while (i < limit); i -= limit; } - - -#define kNumPosBitsMax 4 -#define kNumPosStatesMax (1 << kNumPosBitsMax) - -#define kLenNumLowBits 3 -#define kLenNumLowSymbols (1 << kLenNumLowBits) -#define kLenNumMidBits 3 -#define kLenNumMidSymbols (1 << kLenNumMidBits) -#define kLenNumHighBits 8 -#define kLenNumHighSymbols (1 << kLenNumHighBits) - -#define LenChoice 0 -#define LenChoice2 (LenChoice + 1) -#define LenLow (LenChoice2 + 1) -#define LenMid (LenLow + (kNumPosStatesMax << kLenNumLowBits)) -#define LenHigh (LenMid + (kNumPosStatesMax << kLenNumMidBits)) -#define kNumLenProbs (LenHigh + kLenNumHighSymbols) - - -#define kNumStates 12 -#define kNumLitStates 7 - -#define kStartPosModelIndex 4 -#define kEndPosModelIndex 14 -#define kNumFullDistances (1 << (kEndPosModelIndex >> 1)) - -#define kNumPosSlotBits 6 -#define kNumLenToPosStates 4 - -#define kNumAlignBits 4 -#define kAlignTableSize (1 << kNumAlignBits) - -#define kMatchMinLen 2 -#define kMatchSpecLenStart (kMatchMinLen + kLenNumLowSymbols + kLenNumMidSymbols + kLenNumHighSymbols) - -#define IsMatch 0 -#define IsRep (IsMatch + (kNumStates << kNumPosBitsMax)) -#define IsRepG0 (IsRep + kNumStates) -#define IsRepG1 (IsRepG0 + kNumStates) -#define IsRepG2 (IsRepG1 + kNumStates) -#define IsRep0Long (IsRepG2 + kNumStates) -#define PosSlot (IsRep0Long + (kNumStates << kNumPosBitsMax)) -#define SpecPos (PosSlot + (kNumLenToPosStates << kNumPosSlotBits)) -#define Align (SpecPos + kNumFullDistances - kEndPosModelIndex) -#define LenCoder (Align + kAlignTableSize) -#define RepLenCoder (LenCoder + kNumLenProbs) -#define Literal (RepLenCoder + kNumLenProbs) - -#define LZMA_BASE_SIZE 1846 -#define LZMA_LIT_SIZE 768 - -#define LzmaProps_GetNumProbs(p) ((uint32_t)LZMA_BASE_SIZE + (LZMA_LIT_SIZE << ((p)->lc + (p)->lp))) - -#if Literal != LZMA_BASE_SIZE -StopCompilingDueBUG -#endif - -#define LZMA_DIC_MIN (1 << 12) - -/* First LZMA-symbol is always decoded. - And it decodes new LZMA-symbols while (buf < bufLimit), but "buf" is without last normalization - Out: - Result: - SZ_OK - OK - SZ_ERROR_DATA - Error - p->remainLen: - < kMatchSpecLenStart : normal remain - = kMatchSpecLenStart : finished - = kMatchSpecLenStart + 1 : Flush marker - = kMatchSpecLenStart + 2 : State Init Marker - */ - -static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, size_t limit, const uint8_t *bufLimit) -{ - uint16_t *probs = p->probs; - - unsigned state = p->state; - uint32_t rep0 = p->reps[0], rep1 = p->reps[1], rep2 = p->reps[2], rep3 = p->reps[3]; - unsigned pbMask = ((unsigned)1 << (p->prop.pb)) - 1; - unsigned lpMask = ((unsigned)1 << (p->prop.lp)) - 1; - unsigned lc = p->prop.lc; - - uint8_t *dic = p->dic; - size_t dicBufSize = p->dicBufSize; - size_t dicPos = p->dicPos; - - uint32_t processedPos = p->processedPos; - uint32_t checkDicSize = p->checkDicSize; - unsigned len = 0; - - const uint8_t *buf = p->buf; - uint32_t range = p->range; - uint32_t codes = p->code; - - do - { - uint16_t *prob; - uint32_t bound; - unsigned ttt; - unsigned posState = processedPos & pbMask; - - prob = probs + IsMatch + (state << kNumPosBitsMax) + posState; - ttt = *(prob); - LZMADEC_NORMALIZE; - bound = (range >> kNumBitModelTotalBits) * ttt; - - if (codes < bound) - { - unsigned symbol; - UPDATE_0(prob); - prob = probs + Literal; - if (checkDicSize != 0 || processedPos != 0) - prob += (LZMA_LIT_SIZE * (((processedPos & lpMask) << lc) + - (dic[(dicPos == 0 ? dicBufSize : dicPos) - 1] >> (8 - lc)))); - - if (state < kNumLitStates) - { - state -= (state < 4) ? state : 3; - symbol = 1; - do { GET_BIT(prob + symbol, symbol) } while (symbol < 0x100); - } - else - { - unsigned matchuint8_t = p->dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)]; - unsigned offs = 0x100; - state -= (state < 10) ? 3 : 6; - symbol = 1; - do - { - unsigned bit; - uint16_t *probLit; - matchuint8_t <<= 1; - bit = (matchuint8_t & offs); - probLit = prob + offs + bit + symbol; - GET_BIT2(probLit, symbol, offs &= ~bit, offs &= bit) - } - while (symbol < 0x100); - } - dic[dicPos++] = (uint8_t)symbol; - processedPos++; - continue; - } - else - { - LZMADEC_UPDATE_1(prob); - prob = probs + IsRep + state; - - ttt = *(prob); - LZMADEC_NORMALIZE; - bound = (range >> kNumBitModelTotalBits) * ttt; - - if (codes < bound) - { - UPDATE_0(prob); - state += kNumStates; - prob = probs + LenCoder; - } - else - { - LZMADEC_UPDATE_1(prob); - if (checkDicSize == 0 && processedPos == 0) - return SZ_ERROR_DATA; - prob = probs + IsRepG0 + state; - - ttt = *(prob); - LZMADEC_NORMALIZE; - bound = (range >> kNumBitModelTotalBits) * ttt; - - if (codes < bound) - { - UPDATE_0(prob); - prob = probs + IsRep0Long + (state << kNumPosBitsMax) + posState; - - ttt = *(prob); - LZMADEC_NORMALIZE; - bound = (range >> kNumBitModelTotalBits) * ttt; - - if (codes < bound) - { - UPDATE_0(prob); - dic[dicPos] = dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)]; - dicPos++; - processedPos++; - state = state < kNumLitStates ? 9 : 11; - continue; - } - LZMADEC_UPDATE_1(prob); - } - else - { - uint32_t distance; - LZMADEC_UPDATE_1(prob); - prob = probs + IsRepG1 + state; - - ttt = *(prob); - LZMADEC_NORMALIZE; - bound = (range >> kNumBitModelTotalBits) * ttt; - - if (codes < bound) - { - UPDATE_0(prob); - distance = rep1; - } - else - { - LZMADEC_UPDATE_1(prob); - prob = probs + IsRepG2 + state; - - ttt = *(prob); - LZMADEC_NORMALIZE; - bound = (range >> kNumBitModelTotalBits) * ttt; - - if (codes < bound) - { - UPDATE_0(prob); - distance = rep2; - } - else - { - LZMADEC_UPDATE_1(prob); - distance = rep3; - rep3 = rep2; - } - rep2 = rep1; - } - rep1 = rep0; - rep0 = distance; - } - state = state < kNumLitStates ? 8 : 11; - prob = probs + RepLenCoder; - } - { - unsigned _limit, offset; - uint16_t *probLen = prob + LenChoice; - - ttt = *(probLen); - LZMADEC_NORMALIZE; - bound = (range >> kNumBitModelTotalBits) * ttt; - if (codes < bound) - { - UPDATE_0(probLen); - probLen = prob + LenLow + (posState << kLenNumLowBits); - offset = 0; - _limit = (1 << kLenNumLowBits); - } - else - { - LZMADEC_UPDATE_1(probLen); - probLen = prob + LenChoice2; - - ttt = *(probLen); - LZMADEC_NORMALIZE; - bound = (range >> kNumBitModelTotalBits) * ttt; - if (codes < bound) - { - UPDATE_0(probLen); - probLen = prob + LenMid + (posState << kLenNumMidBits); - offset = kLenNumLowSymbols; - _limit = (1 << kLenNumMidBits); - } - else - { - LZMADEC_UPDATE_1(probLen); - probLen = prob + LenHigh; - offset = kLenNumLowSymbols + kLenNumMidSymbols; - _limit = (1 << kLenNumHighBits); - } - } - TREE_DECODE(probLen, _limit, len); - len += offset; - } - - if (state >= kNumStates) - { - uint32_t distance; - prob = probs + PosSlot + - ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) << kNumPosSlotBits); - TREE_6_DECODE(prob, distance); - if (distance >= kStartPosModelIndex) - { - unsigned posSlot = (unsigned)distance; - int numDirectBits = (int)(((distance >> 1) - 1)); - distance = (2 | (distance & 1)); - if (posSlot < kEndPosModelIndex) - { - distance <<= numDirectBits; - prob = probs + SpecPos + distance - posSlot - 1; - { - uint32_t mask = 1; - unsigned i = 1; - do - { - GET_BIT2(prob + i, i, ; , distance |= mask); - mask <<= 1; - } - while (--numDirectBits != 0); - } - } - else - { - numDirectBits -= kNumAlignBits; - do - { - LZMADEC_NORMALIZE - range >>= 1; - - { - uint32_t t; - codes -= range; - t = (0 - ((uint32_t)codes >> 31)); /* (uint32_t)((Int32)codes >> 31) */ - distance = (distance << 1) + (t + 1); - codes += range & t; - } - /* - distance <<= 1; - if (codes >= range) - { - codes -= range; - distance |= 1; - } - */ - } - while (--numDirectBits != 0); - prob = probs + Align; - distance <<= kNumAlignBits; - { - unsigned i = 1; - GET_BIT2(prob + i, i, ; , distance |= 1); - GET_BIT2(prob + i, i, ; , distance |= 2); - GET_BIT2(prob + i, i, ; , distance |= 4); - GET_BIT2(prob + i, i, ; , distance |= 8); - } - if (distance == (uint32_t)0xFFFFFFFF) - { - len += kMatchSpecLenStart; - state -= kNumStates; - break; - } - } - } - rep3 = rep2; - rep2 = rep1; - rep1 = rep0; - rep0 = distance + 1; - if (checkDicSize == 0) - { - if (distance >= processedPos) - return SZ_ERROR_DATA; - } - else if (distance >= checkDicSize) - return SZ_ERROR_DATA; - state = (state < kNumStates + kNumLitStates) ? kNumLitStates : kNumLitStates + 3; - } - - len += kMatchMinLen; - - if (limit == dicPos) - return SZ_ERROR_DATA; - { - size_t rem = limit - dicPos; - unsigned curLen = ((rem < len) ? (unsigned)rem : len); - size_t pos = (dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0); - - processedPos += curLen; - - len -= curLen; - if (pos + curLen <= dicBufSize) - { - uint8_t *dest = dic + dicPos; - ptrdiff_t src = (ptrdiff_t)pos - (ptrdiff_t)dicPos; - const uint8_t *lim = dest + curLen; - dicPos += curLen; - do - *(dest) = (uint8_t)*(dest + src); - while (++dest != lim); - } - else - { - do - { - dic[dicPos++] = dic[pos]; - if (++pos == dicBufSize) - pos = 0; - } - while (--curLen != 0); - } - } - } - }while (dicPos < limit && buf < bufLimit); - - LZMADEC_NORMALIZE; - - p->buf = buf; - p->range = range; - p->code = codes; - p->remainLen = len; - p->dicPos = dicPos; - p->processedPos = processedPos; - p->reps[0] = rep0; - p->reps[1] = rep1; - p->reps[2] = rep2; - p->reps[3] = rep3; - p->state = state; - - return SZ_OK; -} - -static void MY_FAST_CALL LzmaDec_WriteRem(CLzmaDec *p, size_t limit) -{ - if (p->remainLen != 0 && p->remainLen < kMatchSpecLenStart) - { - uint8_t *dic = p->dic; - size_t dicPos = p->dicPos; - size_t dicBufSize = p->dicBufSize; - unsigned len = p->remainLen; - uint32_t rep0 = p->reps[0]; - if (limit - dicPos < len) - len = (unsigned)(limit - dicPos); - - if (p->checkDicSize == 0 && p->prop.dicSize - p->processedPos <= len) - p->checkDicSize = p->prop.dicSize; - - p->processedPos += len; - p->remainLen -= len; - while (len-- != 0) - { - dic[dicPos] = dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)]; - dicPos++; - } - p->dicPos = dicPos; - } -} - -static int MY_FAST_CALL LzmaDec_DecodeReal2(CLzmaDec *p, size_t limit, const uint8_t *bufLimit) -{ - do - { - size_t limit2 = limit; - if (p->checkDicSize == 0) - { - uint32_t rem = p->prop.dicSize - p->processedPos; - if (limit - p->dicPos > rem) - limit2 = p->dicPos + rem; - } - RINOK(LzmaDec_DecodeReal(p, limit2, bufLimit)); - if (p->processedPos >= p->prop.dicSize) - p->checkDicSize = p->prop.dicSize; - LzmaDec_WriteRem(p, limit); - } - while (p->dicPos < limit && p->buf < bufLimit && p->remainLen < kMatchSpecLenStart); - - if (p->remainLen > kMatchSpecLenStart) - { - p->remainLen = kMatchSpecLenStart; - } - return 0; -} - -typedef enum -{ - DUMMY_ERROR, /* unexpected end of input stream */ - DUMMY_LIT, - DUMMY_MATCH, - DUMMY_REP -} ELzmaDummy; - -static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const uint8_t *buf, size_t inSize) -{ - uint32_t range = p->range; - uint32_t codes = p->code; - const uint8_t *bufLimit = buf + inSize; - uint16_t *probs = p->probs; - unsigned state = p->state; - ELzmaDummy res; - - { - uint16_t *prob; - uint32_t bound; - unsigned ttt; - unsigned posState = (p->processedPos) & ((1 << p->prop.pb) - 1); - - prob = probs + IsMatch + (state << kNumPosBitsMax) + posState; - IF_BIT_0_CHECK(prob) - { - UPDATE_0_CHECK - - /* if (bufLimit - buf >= 7) return DUMMY_LIT; */ - - prob = probs + Literal; - if (p->checkDicSize != 0 || p->processedPos != 0) - prob += (LZMA_LIT_SIZE * - ((((p->processedPos) & ((1 << (p->prop.lp)) - 1)) << p->prop.lc) + - (p->dic[(p->dicPos == 0 ? p->dicBufSize : p->dicPos) - 1] >> (8 - p->prop.lc)))); - - if (state < kNumLitStates) - { - unsigned symbol = 1; - do { GET_BIT_CHECK(prob + symbol, symbol) } while (symbol < 0x100); - } - else - { - unsigned matchuint8_t = p->dic[p->dicPos - p->reps[0] + - ((p->dicPos < p->reps[0]) ? p->dicBufSize : 0)]; - unsigned offs = 0x100; - unsigned symbol = 1; - do - { - unsigned bit; - uint16_t *probLit; - matchuint8_t <<= 1; - bit = (matchuint8_t & offs); - probLit = prob + offs + bit + symbol; - GET_BIT2_CHECK(probLit, symbol, offs &= ~bit, offs &= bit) - } - while (symbol < 0x100); - } - res = DUMMY_LIT; - } - else - { - unsigned len; - UPDATE_1_CHECK; - - prob = probs + IsRep + state; - IF_BIT_0_CHECK(prob) - { - UPDATE_0_CHECK; - state = 0; - prob = probs + LenCoder; - res = DUMMY_MATCH; - } - else - { - UPDATE_1_CHECK; - res = DUMMY_REP; - prob = probs + IsRepG0 + state; - IF_BIT_0_CHECK(prob) - { - UPDATE_0_CHECK; - prob = probs + IsRep0Long + (state << kNumPosBitsMax) + posState; - IF_BIT_0_CHECK(prob) - { - UPDATE_0_CHECK; - NORMALIZE_CHECK; - return DUMMY_REP; - } - else - { - UPDATE_1_CHECK; - } - } - else - { - UPDATE_1_CHECK; - prob = probs + IsRepG1 + state; - IF_BIT_0_CHECK(prob) - { - UPDATE_0_CHECK; - } - else - { - UPDATE_1_CHECK; - prob = probs + IsRepG2 + state; - IF_BIT_0_CHECK(prob) - { - UPDATE_0_CHECK; - } - else - { - UPDATE_1_CHECK; - } - } - } - state = kNumStates; - prob = probs + RepLenCoder; - } - { - unsigned limit, offset; - uint16_t *probLen = prob + LenChoice; - IF_BIT_0_CHECK(probLen) - { - UPDATE_0_CHECK; - probLen = prob + LenLow + (posState << kLenNumLowBits); - offset = 0; - limit = 1 << kLenNumLowBits; - } - else - { - UPDATE_1_CHECK; - probLen = prob + LenChoice2; - IF_BIT_0_CHECK(probLen) - { - UPDATE_0_CHECK; - probLen = prob + LenMid + (posState << kLenNumMidBits); - offset = kLenNumLowSymbols; - limit = 1 << kLenNumMidBits; - } - else - { - UPDATE_1_CHECK; - probLen = prob + LenHigh; - offset = kLenNumLowSymbols + kLenNumMidSymbols; - limit = 1 << kLenNumHighBits; - } - } - TREE_DECODE_CHECK(probLen, limit, len); - len += offset; - } - - if (state < 4) - { - unsigned posSlot; - prob = probs + PosSlot + - ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) << - kNumPosSlotBits); - TREE_DECODE_CHECK(prob, 1 << kNumPosSlotBits, posSlot); - if (posSlot >= kStartPosModelIndex) - { - int numDirectBits = ((posSlot >> 1) - 1); - - /* if (bufLimit - buf >= 8) return DUMMY_MATCH; */ - - if (posSlot < kEndPosModelIndex) - { - prob = probs + SpecPos + ((2 | (posSlot & 1)) << numDirectBits) - posSlot - 1; - } - else - { - numDirectBits -= kNumAlignBits; - do - { - NORMALIZE_CHECK - range >>= 1; - codes -= range & (((codes - range) >> 31) - 1); - /* if (codes >= range) codes -= range; */ - } - while (--numDirectBits != 0); - prob = probs + Align; - numDirectBits = kNumAlignBits; - } - { - unsigned i = 1; - do - { - GET_BIT_CHECK(prob + i, i); - } - while (--numDirectBits != 0); - } - } - } - } - } - NORMALIZE_CHECK; - return res; -} - - -static void LzmaDec_InitRc(CLzmaDec *p, const uint8_t *data) -{ - p->code = ((uint32_t)data[1] << 24) | ((uint32_t)data[2] << 16) | ((uint32_t)data[3] << 8) | ((uint32_t)data[4]); - p->range = 0xFFFFFFFF; - p->needFlush = 0; -} - -void LzmaDec_InitDicAndState(CLzmaDec *p, bool initDic, bool initState); - -void LzmaDec_InitDicAndState(CLzmaDec *p, bool initDic, bool initState) -{ - p->needFlush = 1; - p->remainLen = 0; - p->tempBufSize = 0; - - if (initDic) - { - p->processedPos = 0; - p->checkDicSize = 0; - p->needInitState = 1; - } - if (initState) - p->needInitState = 1; -} - -void LzmaDec_Init(CLzmaDec *p) -{ - p->dicPos = 0; - LzmaDec_InitDicAndState(p, true, true); -} - -static void LzmaDec_InitStateReal(CLzmaDec *p) -{ - uint32_t numProbs = Literal + ((uint32_t)LZMA_LIT_SIZE << (p->prop.lc + p->prop.lp)); - uint32_t i; - uint16_t *probs = p->probs; - for (i = 0; i < numProbs; i++) - probs[i] = kBitModelTotal >> 1; - p->reps[0] = p->reps[1] = p->reps[2] = p->reps[3] = 1; - p->state = 0; - p->needInitState = 0; -} - -SRes LzmaDec_DecodeToDic(CLzmaDec *p, size_t dicLimit, const uint8_t *src, size_t *srcLen, - ELzmaFinishMode finishMode, ELzmaStatus *status) -{ - size_t inSize = *srcLen; - (*srcLen) = 0; - LzmaDec_WriteRem(p, dicLimit); - - *status = LZMA_STATUS_NOT_SPECIFIED; - - while (p->remainLen != kMatchSpecLenStart) - { - int checkEndMarkNow; - - if (p->needFlush != 0) - { - for (; inSize > 0 && p->tempBufSize < RC_INIT_SIZE; (*srcLen)++, inSize--) - p->tempBuf[p->tempBufSize++] = *src++; - if (p->tempBufSize < RC_INIT_SIZE) - { - *status = LZMA_STATUS_NEEDS_MORE_INPUT; - return SZ_OK; - } - if (p->tempBuf[0] != 0) - return SZ_ERROR_DATA; - - LzmaDec_InitRc(p, p->tempBuf); - p->tempBufSize = 0; - } - - checkEndMarkNow = 0; - if (p->dicPos >= dicLimit) - { - if (p->remainLen == 0 && p->code == 0) - { - *status = LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK; - return SZ_OK; - } - if (finishMode == LZMA_FINISH_ANY) - { - *status = LZMA_STATUS_NOT_FINISHED; - return SZ_OK; - } - if (p->remainLen != 0) - { - *status = LZMA_STATUS_NOT_FINISHED; - return SZ_ERROR_DATA; - } - checkEndMarkNow = 1; - } - - if (p->needInitState) - LzmaDec_InitStateReal(p); - - if (p->tempBufSize == 0) - { - size_t processed; - const uint8_t *bufLimit; - if (inSize < LZMA_REQUIRED_INPUT_MAX || checkEndMarkNow) - { - int dummyRes = LzmaDec_TryDummy(p, src, inSize); - if (dummyRes == DUMMY_ERROR) - { - memcpy(p->tempBuf, src, inSize); - p->tempBufSize = (unsigned)inSize; - (*srcLen) += inSize; - *status = LZMA_STATUS_NEEDS_MORE_INPUT; - return SZ_OK; - } - if (checkEndMarkNow && dummyRes != DUMMY_MATCH) - { - *status = LZMA_STATUS_NOT_FINISHED; - return SZ_ERROR_DATA; - } - bufLimit = src; - } - else - bufLimit = src + inSize - LZMA_REQUIRED_INPUT_MAX; - p->buf = src; - if (LzmaDec_DecodeReal2(p, dicLimit, bufLimit) != 0) - return SZ_ERROR_DATA; - processed = (size_t)(p->buf - src); - (*srcLen) += processed; - src += processed; - inSize -= processed; - } - else - { - unsigned rem = p->tempBufSize, lookAhead = 0; - while (rem < LZMA_REQUIRED_INPUT_MAX && lookAhead < inSize) - p->tempBuf[rem++] = src[lookAhead++]; - p->tempBufSize = rem; - if (rem < LZMA_REQUIRED_INPUT_MAX || checkEndMarkNow) - { - int dummyRes = LzmaDec_TryDummy(p, p->tempBuf, rem); - if (dummyRes == DUMMY_ERROR) - { - (*srcLen) += lookAhead; - *status = LZMA_STATUS_NEEDS_MORE_INPUT; - return SZ_OK; - } - if (checkEndMarkNow && dummyRes != DUMMY_MATCH) - { - *status = LZMA_STATUS_NOT_FINISHED; - return SZ_ERROR_DATA; - } - } - p->buf = p->tempBuf; - if (LzmaDec_DecodeReal2(p, dicLimit, p->buf) != 0) - return SZ_ERROR_DATA; - lookAhead -= (rem - (unsigned)(p->buf - p->tempBuf)); - (*srcLen) += lookAhead; - src += lookAhead; - inSize -= lookAhead; - p->tempBufSize = 0; - } - } - if (p->code == 0) - *status = LZMA_STATUS_FINISHED_WITH_MARK; - return (p->code == 0) ? SZ_OK : SZ_ERROR_DATA; -} - -SRes LzmaDec_DecodeToBuf(CLzmaDec *p, uint8_t *dest, size_t *destLen, const uint8_t *src, size_t *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status) -{ - size_t outSize = *destLen; - size_t inSize = *srcLen; - *srcLen = *destLen = 0; - for (;;) - { - size_t inSizeCur = inSize, outSizeCur, dicPos; - ELzmaFinishMode curFinishMode; - SRes res; - if (p->dicPos == p->dicBufSize) - p->dicPos = 0; - dicPos = p->dicPos; - if (outSize > p->dicBufSize - dicPos) - { - outSizeCur = p->dicBufSize; - curFinishMode = LZMA_FINISH_ANY; - } - else - { - outSizeCur = dicPos + outSize; - curFinishMode = finishMode; - } - - res = LzmaDec_DecodeToDic(p, outSizeCur, src, &inSizeCur, curFinishMode, status); - src += inSizeCur; - inSize -= inSizeCur; - *srcLen += inSizeCur; - outSizeCur = p->dicPos - dicPos; - memcpy(dest, p->dic + dicPos, outSizeCur); - dest += outSizeCur; - outSize -= outSizeCur; - *destLen += outSizeCur; - if (res != 0) - return res; - if (outSizeCur == 0 || outSize == 0) - return SZ_OK; - } -} - -void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc) -{ - alloc->Free(alloc, p->probs); - p->probs = 0; -} - -static void LzmaDec_FreeDict(CLzmaDec *p, ISzAlloc *alloc) -{ - alloc->Free(alloc, p->dic); - p->dic = 0; -} - -void LzmaDec_Free(CLzmaDec *p, ISzAlloc *alloc) -{ - LzmaDec_FreeProbs(p, alloc); - LzmaDec_FreeDict(p, alloc); -} - -SRes LzmaProps_Decode(CLzmaProps *p, const uint8_t *data, unsigned size) -{ - uint32_t dicSize; - uint8_t d; - - if (size < LZMA_PROPS_SIZE) - return SZ_ERROR_UNSUPPORTED; - else - dicSize = data[1] | ((uint32_t)data[2] << 8) | ((uint32_t)data[3] << 16) | ((uint32_t)data[4] << 24); - - if (dicSize < LZMA_DIC_MIN) - dicSize = LZMA_DIC_MIN; - p->dicSize = dicSize; - - d = data[0]; - if (d >= (9 * 5 * 5)) - return SZ_ERROR_UNSUPPORTED; - - p->lc = d % 9; - d /= 9; - p->pb = d / 5; - p->lp = d % 5; - - return SZ_OK; -} - -static SRes LzmaDec_AllocateProbs2(CLzmaDec *p, const CLzmaProps *propNew, ISzAlloc *alloc) -{ - uint32_t numProbs = LzmaProps_GetNumProbs(propNew); - if (p->probs == 0 || numProbs != p->numProbs) - { - LzmaDec_FreeProbs(p, alloc); - p->probs = (uint16_t *)alloc->Alloc(alloc, numProbs * sizeof(uint16_t)); - p->numProbs = numProbs; - if (p->probs == 0) - return SZ_ERROR_MEM; - } - return SZ_OK; -} - -SRes LzmaDec_AllocateProbs(CLzmaDec *p, const uint8_t *props, unsigned propsSize, ISzAlloc *alloc) -{ - CLzmaProps propNew; - RINOK(LzmaProps_Decode(&propNew, props, propsSize)); - RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc)); - p->prop = propNew; - return SZ_OK; -} - -SRes LzmaDec_Allocate(CLzmaDec *p, const uint8_t *props, unsigned propsSize, ISzAlloc *alloc) -{ - CLzmaProps propNew; - size_t dicBufSize; - RINOK(LzmaProps_Decode(&propNew, props, propsSize)); - RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc)); - dicBufSize = propNew.dicSize; - if (p->dic == 0 || dicBufSize != p->dicBufSize) - { - LzmaDec_FreeDict(p, alloc); - p->dic = (uint8_t *)alloc->Alloc(alloc, dicBufSize); - if (p->dic == 0) - { - LzmaDec_FreeProbs(p, alloc); - return SZ_ERROR_MEM; - } - } - p->dicBufSize = dicBufSize; - p->prop = propNew; - return SZ_OK; -} - -SRes LzmaDecode(uint8_t *dest, size_t *destLen, const uint8_t *src, size_t *srcLen, - const uint8_t *propData, unsigned propSize, ELzmaFinishMode finishMode, - ELzmaStatus *status, ISzAlloc *alloc) -{ - CLzmaDec p; - SRes res; - size_t inSize = *srcLen; - size_t outSize = *destLen; - *srcLen = *destLen = 0; - if (inSize < RC_INIT_SIZE) - return SZ_ERROR_INPUT_EOF; - - LzmaDec_Construct(&p); - res = LzmaDec_AllocateProbs(&p, propData, propSize, alloc); - if (res != 0) - return res; - p.dic = dest; - p.dicBufSize = outSize; - - LzmaDec_Init(&p); - - *srcLen = inSize; - res = LzmaDec_DecodeToDic(&p, outSize, src, srcLen, finishMode, status); - - if (res == SZ_OK && *status == LZMA_STATUS_NEEDS_MORE_INPUT) - res = SZ_ERROR_INPUT_EOF; - - (*destLen) = p.dicPos; - LzmaDec_FreeProbs(&p, alloc); - return res; -} +/* LzmaDec.c -- LZMA Decoder + 2009-09-20 : Igor Pavlov : Public domain */ +#include +#include +#include + +#include "LzmaDec.h" + +#define kNumTopBits 24 +#define kTopValue ((uint32_t)1 << kNumTopBits) + +#define kNumBitModelTotalBits 11 +#define kBitModelTotal (1 << kNumBitModelTotalBits) +#define kNumMoveBits 5 + +#define RC_INIT_SIZE 5 + +#define LZMADEC_NORMALIZE if (range < kTopValue) { range <<= 8; codes = (codes << 8) | (*buf++); } + +#define LZMADEC_IF_BIT_0(prob) ttt = *(prob); LZMADEC_NORMALIZE; bound = (range >> kNumBitModelTotalBits) * ttt; if (codes < bound) +#define UPDATE_0(p) range = bound; *(p) = (uint16_t)(ttt + ((kBitModelTotal - ttt) >> kNumMoveBits)); +#define LZMADEC_UPDATE_1(p) range -= bound; codes -= bound; *(p) = (uint16_t)(ttt - (ttt >> kNumMoveBits)); +#define GET_BIT2(p, i, A0, A1) LZMADEC_IF_BIT_0(p) \ +{ UPDATE_0(p); i = (i + i); A0; } else \ +{ LZMADEC_UPDATE_1(p); i = (i + i) + 1; A1; } +#define GET_BIT(p, i) GET_BIT2(p, i, ; , ;) + +#define TREE_GET_BIT(probs, i) { GET_BIT((probs + i), i); } +#define TREE_DECODE(probs, limit, i) \ +{ i = 1; do { TREE_GET_BIT(probs, i); } while (i < limit); i -= limit; } + +/* #define _LZMA_SIZE_OPT */ + +#ifdef _LZMA_SIZE_OPT +#define TREE_6_DECODE(probs, i) TREE_DECODE(probs, (1 << 6), i) +#else +#define TREE_6_DECODE(probs, i) \ +{ i = 1; \ + TREE_GET_BIT(probs, i); \ + TREE_GET_BIT(probs, i); \ + TREE_GET_BIT(probs, i); \ + TREE_GET_BIT(probs, i); \ + TREE_GET_BIT(probs, i); \ + TREE_GET_BIT(probs, i); \ + i -= 0x40; } +#endif + +#define NORMALIZE_CHECK if (range < kTopValue) { if (buf >= bufLimit) return DUMMY_ERROR; range <<= 8; codes = (codes << 8) | (*buf++); } + +#define IF_BIT_0_CHECK(p) ttt = *(p); NORMALIZE_CHECK; bound = (range >> kNumBitModelTotalBits) * ttt; if (codes < bound) +#define UPDATE_0_CHECK range = bound; +#define UPDATE_1_CHECK range -= bound; codes -= bound; +#define GET_BIT2_CHECK(p, i, A0, A1) IF_BIT_0_CHECK(p) \ +{ UPDATE_0_CHECK; i = (i + i); A0; } else \ +{ UPDATE_1_CHECK; i = (i + i) + 1; A1; } +#define GET_BIT_CHECK(p, i) GET_BIT2_CHECK(p, i, ; , ;) +#define TREE_DECODE_CHECK(probs, limit, i) \ +{ i = 1; do { GET_BIT_CHECK(probs + i, i) } while (i < limit); i -= limit; } + + +#define kNumPosBitsMax 4 +#define kNumPosStatesMax (1 << kNumPosBitsMax) + +#define kLenNumLowBits 3 +#define kLenNumLowSymbols (1 << kLenNumLowBits) +#define kLenNumMidBits 3 +#define kLenNumMidSymbols (1 << kLenNumMidBits) +#define kLenNumHighBits 8 +#define kLenNumHighSymbols (1 << kLenNumHighBits) + +#define LenChoice 0 +#define LenChoice2 (LenChoice + 1) +#define LenLow (LenChoice2 + 1) +#define LenMid (LenLow + (kNumPosStatesMax << kLenNumLowBits)) +#define LenHigh (LenMid + (kNumPosStatesMax << kLenNumMidBits)) +#define kNumLenProbs (LenHigh + kLenNumHighSymbols) + + +#define kNumStates 12 +#define kNumLitStates 7 + +#define kStartPosModelIndex 4 +#define kEndPosModelIndex 14 +#define kNumFullDistances (1 << (kEndPosModelIndex >> 1)) + +#define kNumPosSlotBits 6 +#define kNumLenToPosStates 4 + +#define kNumAlignBits 4 +#define kAlignTableSize (1 << kNumAlignBits) + +#define kMatchMinLen 2 +#define kMatchSpecLenStart (kMatchMinLen + kLenNumLowSymbols + kLenNumMidSymbols + kLenNumHighSymbols) + +#define IsMatch 0 +#define IsRep (IsMatch + (kNumStates << kNumPosBitsMax)) +#define IsRepG0 (IsRep + kNumStates) +#define IsRepG1 (IsRepG0 + kNumStates) +#define IsRepG2 (IsRepG1 + kNumStates) +#define IsRep0Long (IsRepG2 + kNumStates) +#define PosSlot (IsRep0Long + (kNumStates << kNumPosBitsMax)) +#define SpecPos (PosSlot + (kNumLenToPosStates << kNumPosSlotBits)) +#define Align (SpecPos + kNumFullDistances - kEndPosModelIndex) +#define LenCoder (Align + kAlignTableSize) +#define RepLenCoder (LenCoder + kNumLenProbs) +#define Literal (RepLenCoder + kNumLenProbs) + +#define LZMA_BASE_SIZE 1846 +#define LZMA_LIT_SIZE 768 + +#define LzmaProps_GetNumProbs(p) ((uint32_t)LZMA_BASE_SIZE + (LZMA_LIT_SIZE << ((p)->lc + (p)->lp))) + +#if Literal != LZMA_BASE_SIZE +StopCompilingDueBUG +#endif + +#define LZMA_DIC_MIN (1 << 12) + +/* First LZMA-symbol is always decoded. + And it decodes new LZMA-symbols while (buf < bufLimit), but "buf" is without last normalization + Out: + Result: + SZ_OK - OK + SZ_ERROR_DATA - Error + p->remainLen: + < kMatchSpecLenStart : normal remain + = kMatchSpecLenStart : finished + = kMatchSpecLenStart + 1 : Flush marker + = kMatchSpecLenStart + 2 : State Init Marker + */ + +static int MY_FAST_CALL LzmaDec_DecodeReal(CLzmaDec *p, size_t limit, const uint8_t *bufLimit) +{ + uint16_t *probs = p->probs; + + unsigned state = p->state; + uint32_t rep0 = p->reps[0], rep1 = p->reps[1], rep2 = p->reps[2], rep3 = p->reps[3]; + unsigned pbMask = ((unsigned)1 << (p->prop.pb)) - 1; + unsigned lpMask = ((unsigned)1 << (p->prop.lp)) - 1; + unsigned lc = p->prop.lc; + + uint8_t *dic = p->dic; + size_t dicBufSize = p->dicBufSize; + size_t dicPos = p->dicPos; + + uint32_t processedPos = p->processedPos; + uint32_t checkDicSize = p->checkDicSize; + unsigned len = 0; + + const uint8_t *buf = p->buf; + uint32_t range = p->range; + uint32_t codes = p->code; + + do + { + uint16_t *prob; + uint32_t bound; + unsigned ttt; + unsigned posState = processedPos & pbMask; + + prob = probs + IsMatch + (state << kNumPosBitsMax) + posState; + ttt = *(prob); + LZMADEC_NORMALIZE; + bound = (range >> kNumBitModelTotalBits) * ttt; + + if (codes < bound) + { + unsigned symbol; + UPDATE_0(prob); + prob = probs + Literal; + if (checkDicSize != 0 || processedPos != 0) + prob += (LZMA_LIT_SIZE * (((processedPos & lpMask) << lc) + + (dic[(dicPos == 0 ? dicBufSize : dicPos) - 1] >> (8 - lc)))); + + if (state < kNumLitStates) + { + state -= (state < 4) ? state : 3; + symbol = 1; + do { GET_BIT(prob + symbol, symbol) } while (symbol < 0x100); + } + else + { + unsigned matchuint8_t = p->dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)]; + unsigned offs = 0x100; + state -= (state < 10) ? 3 : 6; + symbol = 1; + do + { + unsigned bit; + uint16_t *probLit; + matchuint8_t <<= 1; + bit = (matchuint8_t & offs); + probLit = prob + offs + bit + symbol; + GET_BIT2(probLit, symbol, offs &= ~bit, offs &= bit) + } + while (symbol < 0x100); + } + dic[dicPos++] = (uint8_t)symbol; + processedPos++; + continue; + } + else + { + LZMADEC_UPDATE_1(prob); + prob = probs + IsRep + state; + + ttt = *(prob); + LZMADEC_NORMALIZE; + bound = (range >> kNumBitModelTotalBits) * ttt; + + if (codes < bound) + { + UPDATE_0(prob); + state += kNumStates; + prob = probs + LenCoder; + } + else + { + LZMADEC_UPDATE_1(prob); + if (checkDicSize == 0 && processedPos == 0) + return SZ_ERROR_DATA; + prob = probs + IsRepG0 + state; + + ttt = *(prob); + LZMADEC_NORMALIZE; + bound = (range >> kNumBitModelTotalBits) * ttt; + + if (codes < bound) + { + UPDATE_0(prob); + prob = probs + IsRep0Long + (state << kNumPosBitsMax) + posState; + + ttt = *(prob); + LZMADEC_NORMALIZE; + bound = (range >> kNumBitModelTotalBits) * ttt; + + if (codes < bound) + { + UPDATE_0(prob); + dic[dicPos] = dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)]; + dicPos++; + processedPos++; + state = state < kNumLitStates ? 9 : 11; + continue; + } + LZMADEC_UPDATE_1(prob); + } + else + { + uint32_t distance; + LZMADEC_UPDATE_1(prob); + prob = probs + IsRepG1 + state; + + ttt = *(prob); + LZMADEC_NORMALIZE; + bound = (range >> kNumBitModelTotalBits) * ttt; + + if (codes < bound) + { + UPDATE_0(prob); + distance = rep1; + } + else + { + LZMADEC_UPDATE_1(prob); + prob = probs + IsRepG2 + state; + + ttt = *(prob); + LZMADEC_NORMALIZE; + bound = (range >> kNumBitModelTotalBits) * ttt; + + if (codes < bound) + { + UPDATE_0(prob); + distance = rep2; + } + else + { + LZMADEC_UPDATE_1(prob); + distance = rep3; + rep3 = rep2; + } + rep2 = rep1; + } + rep1 = rep0; + rep0 = distance; + } + state = state < kNumLitStates ? 8 : 11; + prob = probs + RepLenCoder; + } + { + unsigned _limit, offset; + uint16_t *probLen = prob + LenChoice; + + ttt = *(probLen); + LZMADEC_NORMALIZE; + bound = (range >> kNumBitModelTotalBits) * ttt; + if (codes < bound) + { + UPDATE_0(probLen); + probLen = prob + LenLow + (posState << kLenNumLowBits); + offset = 0; + _limit = (1 << kLenNumLowBits); + } + else + { + LZMADEC_UPDATE_1(probLen); + probLen = prob + LenChoice2; + + ttt = *(probLen); + LZMADEC_NORMALIZE; + bound = (range >> kNumBitModelTotalBits) * ttt; + if (codes < bound) + { + UPDATE_0(probLen); + probLen = prob + LenMid + (posState << kLenNumMidBits); + offset = kLenNumLowSymbols; + _limit = (1 << kLenNumMidBits); + } + else + { + LZMADEC_UPDATE_1(probLen); + probLen = prob + LenHigh; + offset = kLenNumLowSymbols + kLenNumMidSymbols; + _limit = (1 << kLenNumHighBits); + } + } + TREE_DECODE(probLen, _limit, len); + len += offset; + } + + if (state >= kNumStates) + { + uint32_t distance; + prob = probs + PosSlot + + ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) << kNumPosSlotBits); + TREE_6_DECODE(prob, distance); + if (distance >= kStartPosModelIndex) + { + unsigned posSlot = (unsigned)distance; + int numDirectBits = (int)(((distance >> 1) - 1)); + distance = (2 | (distance & 1)); + if (posSlot < kEndPosModelIndex) + { + distance <<= numDirectBits; + prob = probs + SpecPos + distance - posSlot - 1; + { + uint32_t mask = 1; + unsigned i = 1; + do + { + GET_BIT2(prob + i, i, ; , distance |= mask); + mask <<= 1; + } + while (--numDirectBits != 0); + } + } + else + { + numDirectBits -= kNumAlignBits; + do + { + LZMADEC_NORMALIZE + range >>= 1; + + { + uint32_t t; + codes -= range; + t = (0 - ((uint32_t)codes >> 31)); /* (uint32_t)((Int32)codes >> 31) */ + distance = (distance << 1) + (t + 1); + codes += range & t; + } + /* + distance <<= 1; + if (codes >= range) + { + codes -= range; + distance |= 1; + } + */ + } + while (--numDirectBits != 0); + prob = probs + Align; + distance <<= kNumAlignBits; + { + unsigned i = 1; + GET_BIT2(prob + i, i, ; , distance |= 1); + GET_BIT2(prob + i, i, ; , distance |= 2); + GET_BIT2(prob + i, i, ; , distance |= 4); + GET_BIT2(prob + i, i, ; , distance |= 8); + } + if (distance == (uint32_t)0xFFFFFFFF) + { + len += kMatchSpecLenStart; + state -= kNumStates; + break; + } + } + } + rep3 = rep2; + rep2 = rep1; + rep1 = rep0; + rep0 = distance + 1; + if (checkDicSize == 0) + { + if (distance >= processedPos) + return SZ_ERROR_DATA; + } + else if (distance >= checkDicSize) + return SZ_ERROR_DATA; + state = (state < kNumStates + kNumLitStates) ? kNumLitStates : kNumLitStates + 3; + } + + len += kMatchMinLen; + + if (limit == dicPos) + return SZ_ERROR_DATA; + { + size_t rem = limit - dicPos; + unsigned curLen = ((rem < len) ? (unsigned)rem : len); + size_t pos = (dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0); + + processedPos += curLen; + + len -= curLen; + if (pos + curLen <= dicBufSize) + { + uint8_t *dest = dic + dicPos; + ptrdiff_t src = (ptrdiff_t)pos - (ptrdiff_t)dicPos; + const uint8_t *lim = dest + curLen; + dicPos += curLen; + do + *(dest) = (uint8_t)*(dest + src); + while (++dest != lim); + } + else + { + do + { + dic[dicPos++] = dic[pos]; + if (++pos == dicBufSize) + pos = 0; + } + while (--curLen != 0); + } + } + } + }while (dicPos < limit && buf < bufLimit); + + LZMADEC_NORMALIZE; + + p->buf = buf; + p->range = range; + p->code = codes; + p->remainLen = len; + p->dicPos = dicPos; + p->processedPos = processedPos; + p->reps[0] = rep0; + p->reps[1] = rep1; + p->reps[2] = rep2; + p->reps[3] = rep3; + p->state = state; + + return SZ_OK; +} + +static void MY_FAST_CALL LzmaDec_WriteRem(CLzmaDec *p, size_t limit) +{ + if (p->remainLen != 0 && p->remainLen < kMatchSpecLenStart) + { + uint8_t *dic = p->dic; + size_t dicPos = p->dicPos; + size_t dicBufSize = p->dicBufSize; + unsigned len = p->remainLen; + uint32_t rep0 = p->reps[0]; + if (limit - dicPos < len) + len = (unsigned)(limit - dicPos); + + if (p->checkDicSize == 0 && p->prop.dicSize - p->processedPos <= len) + p->checkDicSize = p->prop.dicSize; + + p->processedPos += len; + p->remainLen -= len; + while (len-- != 0) + { + dic[dicPos] = dic[(dicPos - rep0) + ((dicPos < rep0) ? dicBufSize : 0)]; + dicPos++; + } + p->dicPos = dicPos; + } +} + +static int MY_FAST_CALL LzmaDec_DecodeReal2(CLzmaDec *p, size_t limit, const uint8_t *bufLimit) +{ + do + { + size_t limit2 = limit; + if (p->checkDicSize == 0) + { + uint32_t rem = p->prop.dicSize - p->processedPos; + if (limit - p->dicPos > rem) + limit2 = p->dicPos + rem; + } + RINOK(LzmaDec_DecodeReal(p, limit2, bufLimit)); + if (p->processedPos >= p->prop.dicSize) + p->checkDicSize = p->prop.dicSize; + LzmaDec_WriteRem(p, limit); + } + while (p->dicPos < limit && p->buf < bufLimit && p->remainLen < kMatchSpecLenStart); + + if (p->remainLen > kMatchSpecLenStart) + { + p->remainLen = kMatchSpecLenStart; + } + return 0; +} + +typedef enum +{ + DUMMY_ERROR, /* unexpected end of input stream */ + DUMMY_LIT, + DUMMY_MATCH, + DUMMY_REP +} ELzmaDummy; + +static ELzmaDummy LzmaDec_TryDummy(const CLzmaDec *p, const uint8_t *buf, size_t inSize) +{ + uint32_t range = p->range; + uint32_t codes = p->code; + const uint8_t *bufLimit = buf + inSize; + uint16_t *probs = p->probs; + unsigned state = p->state; + ELzmaDummy res; + + { + uint16_t *prob; + uint32_t bound; + unsigned ttt; + unsigned posState = (p->processedPos) & ((1 << p->prop.pb) - 1); + + prob = probs + IsMatch + (state << kNumPosBitsMax) + posState; + IF_BIT_0_CHECK(prob) + { + UPDATE_0_CHECK + + /* if (bufLimit - buf >= 7) return DUMMY_LIT; */ + + prob = probs + Literal; + if (p->checkDicSize != 0 || p->processedPos != 0) + prob += (LZMA_LIT_SIZE * + ((((p->processedPos) & ((1 << (p->prop.lp)) - 1)) << p->prop.lc) + + (p->dic[(p->dicPos == 0 ? p->dicBufSize : p->dicPos) - 1] >> (8 - p->prop.lc)))); + + if (state < kNumLitStates) + { + unsigned symbol = 1; + do { GET_BIT_CHECK(prob + symbol, symbol) } while (symbol < 0x100); + } + else + { + unsigned matchuint8_t = p->dic[p->dicPos - p->reps[0] + + ((p->dicPos < p->reps[0]) ? p->dicBufSize : 0)]; + unsigned offs = 0x100; + unsigned symbol = 1; + do + { + unsigned bit; + uint16_t *probLit; + matchuint8_t <<= 1; + bit = (matchuint8_t & offs); + probLit = prob + offs + bit + symbol; + GET_BIT2_CHECK(probLit, symbol, offs &= ~bit, offs &= bit) + } + while (symbol < 0x100); + } + res = DUMMY_LIT; + } + else + { + unsigned len; + UPDATE_1_CHECK; + + prob = probs + IsRep + state; + IF_BIT_0_CHECK(prob) + { + UPDATE_0_CHECK; + state = 0; + prob = probs + LenCoder; + res = DUMMY_MATCH; + } + else + { + UPDATE_1_CHECK; + res = DUMMY_REP; + prob = probs + IsRepG0 + state; + IF_BIT_0_CHECK(prob) + { + UPDATE_0_CHECK; + prob = probs + IsRep0Long + (state << kNumPosBitsMax) + posState; + IF_BIT_0_CHECK(prob) + { + UPDATE_0_CHECK; + NORMALIZE_CHECK; + return DUMMY_REP; + } + else + { + UPDATE_1_CHECK; + } + } + else + { + UPDATE_1_CHECK; + prob = probs + IsRepG1 + state; + IF_BIT_0_CHECK(prob) + { + UPDATE_0_CHECK; + } + else + { + UPDATE_1_CHECK; + prob = probs + IsRepG2 + state; + IF_BIT_0_CHECK(prob) + { + UPDATE_0_CHECK; + } + else + { + UPDATE_1_CHECK; + } + } + } + state = kNumStates; + prob = probs + RepLenCoder; + } + { + unsigned limit, offset; + uint16_t *probLen = prob + LenChoice; + IF_BIT_0_CHECK(probLen) + { + UPDATE_0_CHECK; + probLen = prob + LenLow + (posState << kLenNumLowBits); + offset = 0; + limit = 1 << kLenNumLowBits; + } + else + { + UPDATE_1_CHECK; + probLen = prob + LenChoice2; + IF_BIT_0_CHECK(probLen) + { + UPDATE_0_CHECK; + probLen = prob + LenMid + (posState << kLenNumMidBits); + offset = kLenNumLowSymbols; + limit = 1 << kLenNumMidBits; + } + else + { + UPDATE_1_CHECK; + probLen = prob + LenHigh; + offset = kLenNumLowSymbols + kLenNumMidSymbols; + limit = 1 << kLenNumHighBits; + } + } + TREE_DECODE_CHECK(probLen, limit, len); + len += offset; + } + + if (state < 4) + { + unsigned posSlot; + prob = probs + PosSlot + + ((len < kNumLenToPosStates ? len : kNumLenToPosStates - 1) << + kNumPosSlotBits); + TREE_DECODE_CHECK(prob, 1 << kNumPosSlotBits, posSlot); + if (posSlot >= kStartPosModelIndex) + { + int numDirectBits = ((posSlot >> 1) - 1); + + /* if (bufLimit - buf >= 8) return DUMMY_MATCH; */ + + if (posSlot < kEndPosModelIndex) + { + prob = probs + SpecPos + ((2 | (posSlot & 1)) << numDirectBits) - posSlot - 1; + } + else + { + numDirectBits -= kNumAlignBits; + do + { + NORMALIZE_CHECK + range >>= 1; + codes -= range & (((codes - range) >> 31) - 1); + /* if (codes >= range) codes -= range; */ + } + while (--numDirectBits != 0); + prob = probs + Align; + numDirectBits = kNumAlignBits; + } + { + unsigned i = 1; + do + { + GET_BIT_CHECK(prob + i, i); + } + while (--numDirectBits != 0); + } + } + } + } + } + NORMALIZE_CHECK; + return res; +} + + +static void LzmaDec_InitRc(CLzmaDec *p, const uint8_t *data) +{ + p->code = ((uint32_t)data[1] << 24) | ((uint32_t)data[2] << 16) | ((uint32_t)data[3] << 8) | ((uint32_t)data[4]); + p->range = 0xFFFFFFFF; + p->needFlush = 0; +} + +void LzmaDec_InitDicAndState(CLzmaDec *p, bool initDic, bool initState); + +void LzmaDec_InitDicAndState(CLzmaDec *p, bool initDic, bool initState) +{ + p->needFlush = 1; + p->remainLen = 0; + p->tempBufSize = 0; + + if (initDic) + { + p->processedPos = 0; + p->checkDicSize = 0; + p->needInitState = 1; + } + if (initState) + p->needInitState = 1; +} + +void LzmaDec_Init(CLzmaDec *p) +{ + p->dicPos = 0; + LzmaDec_InitDicAndState(p, true, true); +} + +static void LzmaDec_InitStateReal(CLzmaDec *p) +{ + uint32_t numProbs = Literal + ((uint32_t)LZMA_LIT_SIZE << (p->prop.lc + p->prop.lp)); + uint32_t i; + uint16_t *probs = p->probs; + for (i = 0; i < numProbs; i++) + probs[i] = kBitModelTotal >> 1; + p->reps[0] = p->reps[1] = p->reps[2] = p->reps[3] = 1; + p->state = 0; + p->needInitState = 0; +} + +SRes LzmaDec_DecodeToDic(CLzmaDec *p, size_t dicLimit, const uint8_t *src, size_t *srcLen, + ELzmaFinishMode finishMode, ELzmaStatus *status) +{ + size_t inSize = *srcLen; + (*srcLen) = 0; + LzmaDec_WriteRem(p, dicLimit); + + *status = LZMA_STATUS_NOT_SPECIFIED; + + while (p->remainLen != kMatchSpecLenStart) + { + int checkEndMarkNow; + + if (p->needFlush != 0) + { + for (; inSize > 0 && p->tempBufSize < RC_INIT_SIZE; (*srcLen)++, inSize--) + p->tempBuf[p->tempBufSize++] = *src++; + if (p->tempBufSize < RC_INIT_SIZE) + { + *status = LZMA_STATUS_NEEDS_MORE_INPUT; + return SZ_OK; + } + if (p->tempBuf[0] != 0) + return SZ_ERROR_DATA; + + LzmaDec_InitRc(p, p->tempBuf); + p->tempBufSize = 0; + } + + checkEndMarkNow = 0; + if (p->dicPos >= dicLimit) + { + if (p->remainLen == 0 && p->code == 0) + { + *status = LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK; + return SZ_OK; + } + if (finishMode == LZMA_FINISH_ANY) + { + *status = LZMA_STATUS_NOT_FINISHED; + return SZ_OK; + } + if (p->remainLen != 0) + { + *status = LZMA_STATUS_NOT_FINISHED; + return SZ_ERROR_DATA; + } + checkEndMarkNow = 1; + } + + if (p->needInitState) + LzmaDec_InitStateReal(p); + + if (p->tempBufSize == 0) + { + size_t processed; + const uint8_t *bufLimit; + if (inSize < LZMA_REQUIRED_INPUT_MAX || checkEndMarkNow) + { + int dummyRes = LzmaDec_TryDummy(p, src, inSize); + if (dummyRes == DUMMY_ERROR) + { + memcpy(p->tempBuf, src, inSize); + p->tempBufSize = (unsigned)inSize; + (*srcLen) += inSize; + *status = LZMA_STATUS_NEEDS_MORE_INPUT; + return SZ_OK; + } + if (checkEndMarkNow && dummyRes != DUMMY_MATCH) + { + *status = LZMA_STATUS_NOT_FINISHED; + return SZ_ERROR_DATA; + } + bufLimit = src; + } + else + bufLimit = src + inSize - LZMA_REQUIRED_INPUT_MAX; + p->buf = src; + if (LzmaDec_DecodeReal2(p, dicLimit, bufLimit) != 0) + return SZ_ERROR_DATA; + processed = (size_t)(p->buf - src); + (*srcLen) += processed; + src += processed; + inSize -= processed; + } + else + { + unsigned rem = p->tempBufSize, lookAhead = 0; + while (rem < LZMA_REQUIRED_INPUT_MAX && lookAhead < inSize) + p->tempBuf[rem++] = src[lookAhead++]; + p->tempBufSize = rem; + if (rem < LZMA_REQUIRED_INPUT_MAX || checkEndMarkNow) + { + int dummyRes = LzmaDec_TryDummy(p, p->tempBuf, rem); + if (dummyRes == DUMMY_ERROR) + { + (*srcLen) += lookAhead; + *status = LZMA_STATUS_NEEDS_MORE_INPUT; + return SZ_OK; + } + if (checkEndMarkNow && dummyRes != DUMMY_MATCH) + { + *status = LZMA_STATUS_NOT_FINISHED; + return SZ_ERROR_DATA; + } + } + p->buf = p->tempBuf; + if (LzmaDec_DecodeReal2(p, dicLimit, p->buf) != 0) + return SZ_ERROR_DATA; + lookAhead -= (rem - (unsigned)(p->buf - p->tempBuf)); + (*srcLen) += lookAhead; + src += lookAhead; + inSize -= lookAhead; + p->tempBufSize = 0; + } + } + if (p->code == 0) + *status = LZMA_STATUS_FINISHED_WITH_MARK; + return (p->code == 0) ? SZ_OK : SZ_ERROR_DATA; +} + +SRes LzmaDec_DecodeToBuf(CLzmaDec *p, uint8_t *dest, size_t *destLen, const uint8_t *src, size_t *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status) +{ + size_t outSize = *destLen; + size_t inSize = *srcLen; + *srcLen = *destLen = 0; + for (;;) + { + size_t inSizeCur = inSize, outSizeCur, dicPos; + ELzmaFinishMode curFinishMode; + SRes res; + if (p->dicPos == p->dicBufSize) + p->dicPos = 0; + dicPos = p->dicPos; + if (outSize > p->dicBufSize - dicPos) + { + outSizeCur = p->dicBufSize; + curFinishMode = LZMA_FINISH_ANY; + } + else + { + outSizeCur = dicPos + outSize; + curFinishMode = finishMode; + } + + res = LzmaDec_DecodeToDic(p, outSizeCur, src, &inSizeCur, curFinishMode, status); + src += inSizeCur; + inSize -= inSizeCur; + *srcLen += inSizeCur; + outSizeCur = p->dicPos - dicPos; + memcpy(dest, p->dic + dicPos, outSizeCur); + dest += outSizeCur; + outSize -= outSizeCur; + *destLen += outSizeCur; + if (res != 0) + return res; + if (outSizeCur == 0 || outSize == 0) + return SZ_OK; + } +} + +void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc) +{ + alloc->Free(alloc, p->probs); + p->probs = 0; +} + +static void LzmaDec_FreeDict(CLzmaDec *p, ISzAlloc *alloc) +{ + alloc->Free(alloc, p->dic); + p->dic = 0; +} + +void LzmaDec_Free(CLzmaDec *p, ISzAlloc *alloc) +{ + LzmaDec_FreeProbs(p, alloc); + LzmaDec_FreeDict(p, alloc); +} + +SRes LzmaProps_Decode(CLzmaProps *p, const uint8_t *data, unsigned size) +{ + uint32_t dicSize; + uint8_t d; + + if (size < LZMA_PROPS_SIZE) + return SZ_ERROR_UNSUPPORTED; + else + dicSize = data[1] | ((uint32_t)data[2] << 8) | ((uint32_t)data[3] << 16) | ((uint32_t)data[4] << 24); + + if (dicSize < LZMA_DIC_MIN) + dicSize = LZMA_DIC_MIN; + p->dicSize = dicSize; + + d = data[0]; + if (d >= (9 * 5 * 5)) + return SZ_ERROR_UNSUPPORTED; + + p->lc = d % 9; + d /= 9; + p->pb = d / 5; + p->lp = d % 5; + + return SZ_OK; +} + +static SRes LzmaDec_AllocateProbs2(CLzmaDec *p, const CLzmaProps *propNew, ISzAlloc *alloc) +{ + uint32_t numProbs = LzmaProps_GetNumProbs(propNew); + if (p->probs == 0 || numProbs != p->numProbs) + { + LzmaDec_FreeProbs(p, alloc); + p->probs = (uint16_t *)alloc->Alloc(alloc, numProbs * sizeof(uint16_t)); + p->numProbs = numProbs; + if (p->probs == 0) + return SZ_ERROR_MEM; + } + return SZ_OK; +} + +SRes LzmaDec_AllocateProbs(CLzmaDec *p, const uint8_t *props, unsigned propsSize, ISzAlloc *alloc) +{ + CLzmaProps propNew; + RINOK(LzmaProps_Decode(&propNew, props, propsSize)); + RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc)); + p->prop = propNew; + return SZ_OK; +} + +SRes LzmaDec_Allocate(CLzmaDec *p, const uint8_t *props, unsigned propsSize, ISzAlloc *alloc) +{ + CLzmaProps propNew; + size_t dicBufSize; + RINOK(LzmaProps_Decode(&propNew, props, propsSize)); + RINOK(LzmaDec_AllocateProbs2(p, &propNew, alloc)); + dicBufSize = propNew.dicSize; + if (p->dic == 0 || dicBufSize != p->dicBufSize) + { + LzmaDec_FreeDict(p, alloc); + p->dic = (uint8_t *)alloc->Alloc(alloc, dicBufSize); + if (p->dic == 0) + { + LzmaDec_FreeProbs(p, alloc); + return SZ_ERROR_MEM; + } + } + p->dicBufSize = dicBufSize; + p->prop = propNew; + return SZ_OK; +} + +SRes LzmaDecode(uint8_t *dest, size_t *destLen, const uint8_t *src, size_t *srcLen, + const uint8_t *propData, unsigned propSize, ELzmaFinishMode finishMode, + ELzmaStatus *status, ISzAlloc *alloc) +{ + CLzmaDec p; + SRes res; + size_t inSize = *srcLen; + size_t outSize = *destLen; + *srcLen = *destLen = 0; + if (inSize < RC_INIT_SIZE) + return SZ_ERROR_INPUT_EOF; + + LzmaDec_Construct(&p); + res = LzmaDec_AllocateProbs(&p, propData, propSize, alloc); + if (res != 0) + return res; + p.dic = dest; + p.dicBufSize = outSize; + + LzmaDec_Init(&p); + + *srcLen = inSize; + res = LzmaDec_DecodeToDic(&p, outSize, src, srcLen, finishMode, status); + + if (res == SZ_OK && *status == LZMA_STATUS_NEEDS_MORE_INPUT) + res = SZ_ERROR_INPUT_EOF; + + (*destLen) = p.dicPos; + LzmaDec_FreeProbs(&p, alloc); + return res; +} diff --git a/deps/7zip/LzmaDec.h b/deps/7zip/LzmaDec.h index b10837ce99..a7cf98d971 100644 --- a/deps/7zip/LzmaDec.h +++ b/deps/7zip/LzmaDec.h @@ -1,220 +1,220 @@ -/* LzmaDec.h -- LZMA Decoder - 2009-02-07 : Igor Pavlov : Public domain */ - -#ifndef __LZMA_DEC_H -#define __LZMA_DEC_H - -#include "7zTypes.h" - -#ifdef __cplusplus -extern "C" { -#endif - -/* ---------- LZMA Properties ---------- */ - -#define LZMA_PROPS_SIZE 5 - - typedef struct _CLzmaProps - { - unsigned lc, lp, pb; - uint32_t dicSize; - } CLzmaProps; - - /* LzmaProps_Decode - decodes properties -Returns: -SZ_OK -SZ_ERROR_UNSUPPORTED - Unsupported properties -*/ - - SRes LzmaProps_Decode(CLzmaProps *p, const uint8_t *data, unsigned size); - - - /* ---------- LZMA Decoder state ---------- */ - - /* LZMA_REQUIRED_INPUT_MAX = number of required input bytes for worst case. - Num bits = log2((2^11 / 31) ^ 22) + 26 < 134 + 26 = 160; */ - -#define LZMA_REQUIRED_INPUT_MAX 20 - - typedef struct - { - CLzmaProps prop; - uint16_t *probs; - uint8_t *dic; - const uint8_t *buf; - uint32_t range, code; - size_t dicPos; - size_t dicBufSize; - uint32_t processedPos; - uint32_t checkDicSize; - unsigned state; - uint32_t reps[4]; - unsigned remainLen; - int needFlush; - int needInitState; - uint32_t numProbs; - unsigned tempBufSize; - uint8_t tempBuf[LZMA_REQUIRED_INPUT_MAX]; - } CLzmaDec; - -#define LzmaDec_Construct(p) { (p)->dic = 0; (p)->probs = 0; } - - void LzmaDec_Init(CLzmaDec *p); - - /* There are two types of LZMA streams: - 0) Stream with end mark. That end mark adds about 6 bytes to compressed size. - 1) Stream without end mark. You must know exact uncompressed size to decompress such stream. */ - - typedef enum - { - LZMA_FINISH_ANY, /* finish at any point */ - LZMA_FINISH_END /* block must be finished at the end */ - } ELzmaFinishMode; - - /* ELzmaFinishMode has meaning only if the decoding reaches output limit !!! - - You must use LZMA_FINISH_END, when you know that current output buffer - covers last bytes of block. In other cases you must use LZMA_FINISH_ANY. - - If LZMA decoder sees end marker before reaching output limit, it returns SZ_OK, - and output value of destLen will be less than output buffer size limit. - You can check status result also. - - You can use multiple checks to test data integrity after full decompression: - 1) Check Result and "status" variable. - 2) Check that output(destLen) = uncompressedSize, if you know real uncompressedSize. - 3) Check that output(srcLen) = compressedSize, if you know real compressedSize. - You must use correct finish mode in that case. */ - - typedef enum - { - LZMA_STATUS_NOT_SPECIFIED, /* use main error code instead */ - LZMA_STATUS_FINISHED_WITH_MARK, /* stream was finished with end mark. */ - LZMA_STATUS_NOT_FINISHED, /* stream was not finished */ - LZMA_STATUS_NEEDS_MORE_INPUT, /* you must provide more input bytes */ - LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK /* there is probability that stream was finished without end mark */ - } ELzmaStatus; - - /* ELzmaStatus is used only as output value for function call */ - - - /* ---------- Interfaces ---------- */ - - /* There are 3 levels of interfaces: - 1) Dictionary Interface - 2) Buffer Interface - 3) One Call Interface - You can select any of these interfaces, but don't mix functions from different - groups for same object. */ - - - /* There are two variants to allocate state for Dictionary Interface: - 1) LzmaDec_Allocate / LzmaDec_Free - 2) LzmaDec_AllocateProbs / LzmaDec_FreeProbs - You can use variant 2, if you set dictionary buffer manually. - For Buffer Interface you must always use variant 1. - - LzmaDec_Allocate* can return: - SZ_OK - SZ_ERROR_MEM - Memory allocation error - SZ_ERROR_UNSUPPORTED - Unsupported properties - */ - - SRes LzmaDec_AllocateProbs(CLzmaDec *p, const uint8_t *props, unsigned propsSize, ISzAlloc *alloc); - void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc); - - SRes LzmaDec_Allocate(CLzmaDec *state, const uint8_t *prop, unsigned propsSize, ISzAlloc *alloc); - void LzmaDec_Free(CLzmaDec *state, ISzAlloc *alloc); - - /* ---------- Dictionary Interface ---------- */ - - /* You can use it, if you want to eliminate the overhead for data copying from - dictionary to some other external buffer. - You must work with CLzmaDec variables directly in this interface. - -STEPS: -LzmaDec_Constr() -LzmaDec_Allocate() -for (each new stream) -{ -LzmaDec_Init() -while (it needs more decompression) -{ -LzmaDec_DecodeToDic() -use data from CLzmaDec::dic and update CLzmaDec::dicPos -} -} -LzmaDec_Free() -*/ - - /* LzmaDec_DecodeToDic - - The decoding to internal dictionary buffer (CLzmaDec::dic). - You must manually update CLzmaDec::dicPos, if it reaches CLzmaDec::dicBufSize !!! - -finishMode: -It has meaning only if the decoding reaches output limit (dicLimit). -LZMA_FINISH_ANY - Decode just dicLimit bytes. -LZMA_FINISH_END - Stream must be finished after dicLimit. - -Returns: -SZ_OK -status: -LZMA_STATUS_FINISHED_WITH_MARK -LZMA_STATUS_NOT_FINISHED -LZMA_STATUS_NEEDS_MORE_INPUT -LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK -SZ_ERROR_DATA - Data error -*/ - - SRes LzmaDec_DecodeToDic(CLzmaDec *p, size_t dicLimit, - const uint8_t *src, size_t *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status); - - -/* ---------- Buffer Interface ---------- */ - -/* It's zlib-like interface. - See LzmaDec_DecodeToDic description for information about STEPS and return results, - but you must use LzmaDec_DecodeToBuf instead of LzmaDec_DecodeToDic and you don't need - to work with CLzmaDec variables manually. - -finishMode: -It has meaning only if the decoding reaches output limit (*destLen). -LZMA_FINISH_ANY - Decode just destLen bytes. -LZMA_FINISH_END - Stream must be finished after (*destLen). -*/ - -SRes LzmaDec_DecodeToBuf(CLzmaDec *p, uint8_t *dest, size_t *destLen, - const uint8_t *src, size_t *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status); - - -/* ---------- One Call Interface ---------- */ - -/* LzmaDecode - -finishMode: -It has meaning only if the decoding reaches output limit (*destLen). -LZMA_FINISH_ANY - Decode just destLen bytes. -LZMA_FINISH_END - Stream must be finished after (*destLen). - -Returns: -SZ_OK -status: -LZMA_STATUS_FINISHED_WITH_MARK -LZMA_STATUS_NOT_FINISHED -LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK -SZ_ERROR_DATA - Data error -SZ_ERROR_MEM - Memory allocation error -SZ_ERROR_UNSUPPORTED - Unsupported properties -SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src). -*/ - -SRes LzmaDecode(uint8_t *dest, size_t *destLen, const uint8_t *src, size_t *srcLen, - const uint8_t *propData, unsigned propSize, ELzmaFinishMode finishMode, - ELzmaStatus *status, ISzAlloc *alloc); - -#ifdef __cplusplus -} -#endif - -#endif +/* LzmaDec.h -- LZMA Decoder + 2009-02-07 : Igor Pavlov : Public domain */ + +#ifndef __LZMA_DEC_H +#define __LZMA_DEC_H + +#include "7zTypes.h" + +#ifdef __cplusplus +extern "C" { +#endif + +/* ---------- LZMA Properties ---------- */ + +#define LZMA_PROPS_SIZE 5 + + typedef struct _CLzmaProps + { + unsigned lc, lp, pb; + uint32_t dicSize; + } CLzmaProps; + + /* LzmaProps_Decode - decodes properties +Returns: +SZ_OK +SZ_ERROR_UNSUPPORTED - Unsupported properties +*/ + + SRes LzmaProps_Decode(CLzmaProps *p, const uint8_t *data, unsigned size); + + + /* ---------- LZMA Decoder state ---------- */ + + /* LZMA_REQUIRED_INPUT_MAX = number of required input bytes for worst case. + Num bits = log2((2^11 / 31) ^ 22) + 26 < 134 + 26 = 160; */ + +#define LZMA_REQUIRED_INPUT_MAX 20 + + typedef struct + { + CLzmaProps prop; + uint16_t *probs; + uint8_t *dic; + const uint8_t *buf; + uint32_t range, code; + size_t dicPos; + size_t dicBufSize; + uint32_t processedPos; + uint32_t checkDicSize; + unsigned state; + uint32_t reps[4]; + unsigned remainLen; + int needFlush; + int needInitState; + uint32_t numProbs; + unsigned tempBufSize; + uint8_t tempBuf[LZMA_REQUIRED_INPUT_MAX]; + } CLzmaDec; + +#define LzmaDec_Construct(p) { (p)->dic = 0; (p)->probs = 0; } + + void LzmaDec_Init(CLzmaDec *p); + + /* There are two types of LZMA streams: + 0) Stream with end mark. That end mark adds about 6 bytes to compressed size. + 1) Stream without end mark. You must know exact uncompressed size to decompress such stream. */ + + typedef enum + { + LZMA_FINISH_ANY, /* finish at any point */ + LZMA_FINISH_END /* block must be finished at the end */ + } ELzmaFinishMode; + + /* ELzmaFinishMode has meaning only if the decoding reaches output limit !!! + + You must use LZMA_FINISH_END, when you know that current output buffer + covers last bytes of block. In other cases you must use LZMA_FINISH_ANY. + + If LZMA decoder sees end marker before reaching output limit, it returns SZ_OK, + and output value of destLen will be less than output buffer size limit. + You can check status result also. + + You can use multiple checks to test data integrity after full decompression: + 1) Check Result and "status" variable. + 2) Check that output(destLen) = uncompressedSize, if you know real uncompressedSize. + 3) Check that output(srcLen) = compressedSize, if you know real compressedSize. + You must use correct finish mode in that case. */ + + typedef enum + { + LZMA_STATUS_NOT_SPECIFIED, /* use main error code instead */ + LZMA_STATUS_FINISHED_WITH_MARK, /* stream was finished with end mark. */ + LZMA_STATUS_NOT_FINISHED, /* stream was not finished */ + LZMA_STATUS_NEEDS_MORE_INPUT, /* you must provide more input bytes */ + LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK /* there is probability that stream was finished without end mark */ + } ELzmaStatus; + + /* ELzmaStatus is used only as output value for function call */ + + + /* ---------- Interfaces ---------- */ + + /* There are 3 levels of interfaces: + 1) Dictionary Interface + 2) Buffer Interface + 3) One Call Interface + You can select any of these interfaces, but don't mix functions from different + groups for same object. */ + + + /* There are two variants to allocate state for Dictionary Interface: + 1) LzmaDec_Allocate / LzmaDec_Free + 2) LzmaDec_AllocateProbs / LzmaDec_FreeProbs + You can use variant 2, if you set dictionary buffer manually. + For Buffer Interface you must always use variant 1. + + LzmaDec_Allocate* can return: + SZ_OK + SZ_ERROR_MEM - Memory allocation error + SZ_ERROR_UNSUPPORTED - Unsupported properties + */ + + SRes LzmaDec_AllocateProbs(CLzmaDec *p, const uint8_t *props, unsigned propsSize, ISzAlloc *alloc); + void LzmaDec_FreeProbs(CLzmaDec *p, ISzAlloc *alloc); + + SRes LzmaDec_Allocate(CLzmaDec *state, const uint8_t *prop, unsigned propsSize, ISzAlloc *alloc); + void LzmaDec_Free(CLzmaDec *state, ISzAlloc *alloc); + + /* ---------- Dictionary Interface ---------- */ + + /* You can use it, if you want to eliminate the overhead for data copying from + dictionary to some other external buffer. + You must work with CLzmaDec variables directly in this interface. + +STEPS: +LzmaDec_Constr() +LzmaDec_Allocate() +for (each new stream) +{ +LzmaDec_Init() +while (it needs more decompression) +{ +LzmaDec_DecodeToDic() +use data from CLzmaDec::dic and update CLzmaDec::dicPos +} +} +LzmaDec_Free() +*/ + + /* LzmaDec_DecodeToDic + + The decoding to internal dictionary buffer (CLzmaDec::dic). + You must manually update CLzmaDec::dicPos, if it reaches CLzmaDec::dicBufSize !!! + +finishMode: +It has meaning only if the decoding reaches output limit (dicLimit). +LZMA_FINISH_ANY - Decode just dicLimit bytes. +LZMA_FINISH_END - Stream must be finished after dicLimit. + +Returns: +SZ_OK +status: +LZMA_STATUS_FINISHED_WITH_MARK +LZMA_STATUS_NOT_FINISHED +LZMA_STATUS_NEEDS_MORE_INPUT +LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK +SZ_ERROR_DATA - Data error +*/ + + SRes LzmaDec_DecodeToDic(CLzmaDec *p, size_t dicLimit, + const uint8_t *src, size_t *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status); + + +/* ---------- Buffer Interface ---------- */ + +/* It's zlib-like interface. + See LzmaDec_DecodeToDic description for information about STEPS and return results, + but you must use LzmaDec_DecodeToBuf instead of LzmaDec_DecodeToDic and you don't need + to work with CLzmaDec variables manually. + +finishMode: +It has meaning only if the decoding reaches output limit (*destLen). +LZMA_FINISH_ANY - Decode just destLen bytes. +LZMA_FINISH_END - Stream must be finished after (*destLen). +*/ + +SRes LzmaDec_DecodeToBuf(CLzmaDec *p, uint8_t *dest, size_t *destLen, + const uint8_t *src, size_t *srcLen, ELzmaFinishMode finishMode, ELzmaStatus *status); + + +/* ---------- One Call Interface ---------- */ + +/* LzmaDecode + +finishMode: +It has meaning only if the decoding reaches output limit (*destLen). +LZMA_FINISH_ANY - Decode just destLen bytes. +LZMA_FINISH_END - Stream must be finished after (*destLen). + +Returns: +SZ_OK +status: +LZMA_STATUS_FINISHED_WITH_MARK +LZMA_STATUS_NOT_FINISHED +LZMA_STATUS_MAYBE_FINISHED_WITHOUT_MARK +SZ_ERROR_DATA - Data error +SZ_ERROR_MEM - Memory allocation error +SZ_ERROR_UNSUPPORTED - Unsupported properties +SZ_ERROR_INPUT_EOF - It needs more bytes in input buffer (src). +*/ + +SRes LzmaDecode(uint8_t *dest, size_t *destLen, const uint8_t *src, size_t *srcLen, + const uint8_t *propData, unsigned propSize, ELzmaFinishMode finishMode, + ELzmaStatus *status, ISzAlloc *alloc); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/deps/7zip/LzmaEnc.c b/deps/7zip/LzmaEnc.c index 6ea4395a3b..d66c0acb08 100644 --- a/deps/7zip/LzmaEnc.c +++ b/deps/7zip/LzmaEnc.c @@ -50,7 +50,7 @@ void LzmaEncProps_Normalize(CLzmaEncProps *p) int level = p->level; if (level < 0) level = 5; p->level = level; - + if (p->dictSize == 0) p->dictSize = (level <= 5 ? (1 << (level * 2 + 14)) : (level == 6 ? (1 << 25) : (1 << 26))); if (p->dictSize > p->reduceSize) { @@ -71,7 +71,7 @@ void LzmaEncProps_Normalize(CLzmaEncProps *p) if (p->btMode < 0) p->btMode = (p->algo == 0 ? 0 : 1); if (p->numHashBytes < 0) p->numHashBytes = 4; if (p->mc == 0) p->mc = (16 + (p->fb >> 1)) >> (p->btMode ? 0 : 1); - + if (p->numThreads < 0) p->numThreads = #ifndef _7ZIP_ST @@ -99,7 +99,7 @@ static void LzmaEnc_FastPosInit(unsigned char *g_FastPos) g_FastPos[0] = 0; g_FastPos[1] = 1; g_FastPos += 2; - + for (slot = 2; slot < kNumLogBits * 2; slot++) { size_t k = ((size_t)1 << ((slot >> 1) - 1)); @@ -236,7 +236,7 @@ typedef struct CLzmaProb posSlotEncoder[kNumLenToPosStates][1 << kNumPosSlotBits]; CLzmaProb posEncoders[kNumFullDistances - kEndPosModelIndex]; CLzmaProb posAlignEncoder[1 << kNumAlignBits]; - + CLenPriceEnc lenEnc; CLenPriceEnc repLenEnc; } CSaveState; @@ -272,7 +272,7 @@ typedef struct bool needInit; uint64_t nowPos64; - + uint32_t matchPriceCount; uint32_t alignPriceCount; @@ -293,9 +293,9 @@ typedef struct #ifndef _7ZIP_ST unsigned char pad[128]; #endif - + COptimal opt[kNumOpts]; - + unsigned char g_FastPos[1 << kNumLogBits]; uint32_t ProbPrices[kBitModelTotal >> kNumMoveReducingBits]; @@ -315,7 +315,7 @@ typedef struct CLzmaProb posSlotEncoder[kNumLenToPosStates][1 << kNumPosSlotBits]; CLzmaProb posEncoders[kNumFullDistances - kEndPosModelIndex]; CLzmaProb posAlignEncoder[1 << kNumAlignBits]; - + CLenPriceEnc lenEnc; CLenPriceEnc repLenEnc; @@ -808,7 +808,7 @@ static uint32_t ReadMatchDistances(CLzmaEnc *p, uint32_t *numDistancePairsRes) uint32_t lenRes = 0, numPairs; p->numAvail = p->matchFinder.GetNumAvailableBytes(p->matchFinderObj); numPairs = p->matchFinder.GetMatches(p->matchFinderObj, p->matches); - + if (numPairs > 0) { lenRes = p->matches[numPairs - 2]; @@ -893,10 +893,10 @@ static uint32_t Backward(CLzmaEnc *p, uint32_t *backRes, uint32_t cur) { uint32_t posPrev = posMem; uint32_t backCur = backMem; - + backMem = p->opt[posPrev].backPrev; posMem = p->opt[posPrev].posPrev; - + p->opt[posPrev].backPrev = backCur; p->opt[posPrev].posPrev = cur; cur = posPrev; @@ -932,7 +932,7 @@ static uint32_t GetOptimum(CLzmaEnc *p, uint32_t position, uint32_t *backRes) return lenRes; } p->optimumCurrentIndex = p->optimumEndIndex = 0; - + if (p->additionalOffset == 0) mainLen = ReadMatchDistances(p, &numPairs); else @@ -1223,7 +1223,7 @@ static uint32_t GetOptimum(CLzmaEnc *p, uint32_t position, uint32_t *backRes) matchPrice = curPrice + GET_PRICE_1(p->isMatch[state][posState]); repMatchPrice = matchPrice + GET_PRICE_1(p->isRep[state]); - + if (matchByte == curByte && !(nextOpt->posPrev < cur && nextOpt->backPrev == 0)) { uint32_t shortRepPrice = repMatchPrice + GetRepLen1Price(p, state, posState); @@ -1285,7 +1285,7 @@ static uint32_t GetOptimum(CLzmaEnc *p, uint32_t position, uint32_t *backRes) } } } - + startLen = 2; /* speed optimization */ { uint32_t repIndex; @@ -1316,10 +1316,10 @@ static uint32_t GetOptimum(CLzmaEnc *p, uint32_t position, uint32_t *backRes) } while (--lenTest >= 2); lenTest = lenTestTemp; - + if (repIndex == 0) startLen = lenTest + 1; - + /* if (_maxMode) */ { uint32_t lenTest2 = lenTest + 1; @@ -1343,7 +1343,7 @@ static uint32_t GetOptimum(CLzmaEnc *p, uint32_t position, uint32_t *backRes) nextRepMatchPrice = curAndLenCharPrice + GET_PRICE_1(p->isMatch[state2][posStateNext]) + GET_PRICE_1(p->isRep[state2]); - + /* for (; lenTest2 >= 2; lenTest2--) */ { uint32_t curAndLenPrice; @@ -1399,7 +1399,7 @@ static uint32_t GetOptimum(CLzmaEnc *p, uint32_t position, uint32_t *backRes) curAndLenPrice += p->distancesPrices[lenToPosState][curBack]; else curAndLenPrice += p->posSlotPrices[lenToPosState][posSlot] + p->alignPrices[curBack & kAlignMask]; - + opt = &p->opt[cur + lenTest]; if (curAndLenPrice < opt->price) { @@ -1434,7 +1434,7 @@ static uint32_t GetOptimum(CLzmaEnc *p, uint32_t position, uint32_t *backRes) nextRepMatchPrice = curAndLenCharPrice + GET_PRICE_1(p->isMatch[state2][posStateNext]) + GET_PRICE_1(p->isRep[state2]); - + /* for (; lenTest2 >= 2; lenTest2--) */ { uint32_t offset = cur + lenTest + 1 + lenTest2; @@ -1546,7 +1546,7 @@ static uint32_t GetOptimumFast(CLzmaEnc *p, uint32_t *backRes) MovePos(p, repLen - 1); return repLen; } - + if (mainLen < 2 || numAvail <= 2) return 1; @@ -1560,7 +1560,7 @@ static uint32_t GetOptimumFast(CLzmaEnc *p, uint32_t *backRes) (p->longestMatchLength + 1 >= mainLen && mainLen >= 3 && ChangePair(newDistance, mainDist))) return 1; } - + data = p->matchFinder.GetPointerToCurrentPos(p->matchFinderObj) - 1; for (i = 0; i < LZMA_NUM_REPS; i++) { @@ -1660,7 +1660,7 @@ void LzmaEnc_Construct(CLzmaEnc *p) { RangeEnc_Construct(&p->rc); MatchFinder_Construct(&p->matchFinderBase); - + #ifndef _7ZIP_ST MatchFinderMt_Construct(&p->matchFinderMt); p->matchFinderMt.MatchFinder = &p->matchFinderBase; @@ -1701,7 +1701,7 @@ void LzmaEnc_Destruct(CLzmaEnc *p, ISzAlloc *alloc, ISzAlloc *allocBig) #ifndef _7ZIP_ST MatchFinderMt_Destruct(&p->matchFinderMt, allocBig); #endif - + MatchFinder_Free(&p->matchFinderBase, allocBig); LzmaEnc_FreeLits(p, alloc); RangeEnc_Free(&p->rc, alloc); @@ -1816,7 +1816,7 @@ static SRes LzmaEnc_CodeOneBlock(CLzmaEnc *p, bool useLimits, uint32_t maxPackSi pos -= LZMA_NUM_REPS; GetPosSlot(pos, posSlot); RcTree_Encode(&p->rc, p->posSlotEncoder[GetLenToPosState(len)], kNumPosSlotBits, posSlot); - + if (posSlot >= kStartPosModelIndex) { uint32_t footerBits = ((posSlot >> 1) - 1); @@ -1919,7 +1919,7 @@ static SRes LzmaEnc_Alloc(CLzmaEnc *p, uint32_t keepWindowSize, ISzAlloc *alloc, p->matchFinderObj = &p->matchFinderBase; MatchFinder_CreateVTable(&p->matchFinderBase, &p->matchFinder); } - + return SZ_OK; } @@ -2123,7 +2123,7 @@ SRes LzmaEnc_CodeOneMemBlock(CLzmaEncHandle pp, bool reInit, p->rc.outStream = &outStream.funcTable; res = LzmaEnc_CodeOneBlock(p, true, desiredPackSize, *unpackSize); - + *unpackSize = (uint32_t)(p->nowPos64 - nowPos64); *destLen -= outStream.rem; if (outStream.overflow) @@ -2158,7 +2158,7 @@ static SRes LzmaEnc_Encode2(CLzmaEnc *p, ICompressProgress *progress) } } } - + LzmaEnc_Finish(p); return res; @@ -2218,7 +2218,7 @@ SRes LzmaEnc_MemEncode(CLzmaEncHandle pp, unsigned char *dest, size_t *destLen, p->rc.outStream = &outStream.funcTable; res = LzmaEnc_MemPrepare(pp, src, srcLen, 0, alloc, allocBig); - + if (res == SZ_OK) { res = LzmaEnc_Encode2(p, progress); diff --git a/deps/SPIRV-Cross/GLSL.std.450.h b/deps/SPIRV-Cross/GLSL.std.450.h index 54cc00e9a8..943fd8650f 100644 --- a/deps/SPIRV-Cross/GLSL.std.450.h +++ b/deps/SPIRV-Cross/GLSL.std.450.h @@ -13,7 +13,7 @@ ** ** MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS ** STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND -** HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/ +** HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/ ** ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ** OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, diff --git a/deps/glslang/glslang/SPIRV/GLSL.std.450.h b/deps/glslang/glslang/SPIRV/GLSL.std.450.h index df31092bec..86d3da8065 100755 --- a/deps/glslang/glslang/SPIRV/GLSL.std.450.h +++ b/deps/glslang/glslang/SPIRV/GLSL.std.450.h @@ -13,7 +13,7 @@ ** ** MODIFICATIONS TO THIS FILE MAY MEAN IT NO LONGER ACCURATELY REFLECTS KHRONOS ** STANDARDS. THE UNMODIFIED, NORMATIVE VERSIONS OF KHRONOS SPECIFICATIONS AND -** HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/ +** HEADER INFORMATION ARE LOCATED AT https://www.khronos.org/registry/ ** ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ** OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, diff --git a/deps/glslang/glslang/SPIRV/SPVRemapper.h b/deps/glslang/glslang/SPIRV/SPVRemapper.h index b3c686aae5..ee5f63c653 100755 --- a/deps/glslang/glslang/SPIRV/SPVRemapper.h +++ b/deps/glslang/glslang/SPIRV/SPVRemapper.h @@ -112,7 +112,7 @@ class spirvbin_t : public spirvbin_base_t { public: spirvbin_t(int verbose = 0) : entryPoint(spv::NoResult), largestNewId(0), verbose(verbose) { } - + // remap on an existing binary in memory void remap(std::vector& spv, std::uint32_t opts = DO_EVERYTHING); @@ -175,7 +175,7 @@ private: range_t constRange(spv::Op opCode) const; unsigned typeSizeInWords(spv::Id id) const; unsigned idTypeSizeInWords(spv::Id id) const; - + spv::Id& asId(unsigned word) { return spv[word]; } const spv::Id& asId(unsigned word) const { return spv[word]; } spv::Op asOpCode(unsigned word) const { return opOpCode(spv[word]); } @@ -241,7 +241,7 @@ private: void mapRemainder(); // map any IDs we haven't touched yet void stripDebug(); // strip debug info void strip(); // remove debug symbols - + std::vector spv; // SPIR words namemap_t nameMap; // ID names from OpName @@ -268,11 +268,11 @@ private: // Which functions are called, anywhere in the module, with a call count std::unordered_map fnCalls; - + posmap_t typeConstPos; // word positions that define types & consts (ordered) posmap_rev_t idPosR; // reverse map from IDs to positions typesize_map_t idTypeSizeMap; // maps each ID to its type size, if known. - + std::vector idMapL; // ID {M}ap from {L}ocal to {G}lobal IDs spv::Id entryPoint; // module entry point diff --git a/deps/glslang/glslang/SPIRV/SpvBuilder.h b/deps/glslang/glslang/SPIRV/SpvBuilder.h index e8524b2b1b..ad5da5ffde 100755 --- a/deps/glslang/glslang/SPIRV/SpvBuilder.h +++ b/deps/glslang/glslang/SPIRV/SpvBuilder.h @@ -301,7 +301,7 @@ public: // Generally, the type of 'scalar' does not need to be the same type as the components in 'vector'. // The type of the created vector is a vector of components of the same type as the scalar. // - // Note: One of the arguments will change, with the result coming back that way rather than + // Note: One of the arguments will change, with the result coming back that way rather than // through the return value. void promoteScalar(Decoration precision, Id& left, Id& right); diff --git a/deps/glslang/glslang/SPIRV/doc.h b/deps/glslang/glslang/SPIRV/doc.h index 743896ff4a..dfc5662667 100644 --- a/deps/glslang/glslang/SPIRV/doc.h +++ b/deps/glslang/glslang/SPIRV/doc.h @@ -195,7 +195,7 @@ public: // Parameterize a set of enumerants that form an enum class EnumDefinition : public EnumParameters { public: - EnumDefinition() : + EnumDefinition() : ceiling(0), bitmask(false), getName(0), enumParams(0), operandParams(0) { } void set(int ceil, const char* (*name)(int), EnumParameters* ep, bool mask = false) { diff --git a/deps/glslang/glslang/SPIRV/spvIR.h b/deps/glslang/glslang/SPIRV/spvIR.h index c584c9dcb4..88630f899c 100755 --- a/deps/glslang/glslang/SPIRV/spvIR.h +++ b/deps/glslang/glslang/SPIRV/spvIR.h @@ -36,9 +36,9 @@ // // Simple in-memory representation (IR) of SPIRV. Just for holding // Each function's CFG of blocks. Has this hierarchy: -// - Module, which is a list of -// - Function, which is a list of -// - Block, which is a list of +// - Module, which is a list of +// - Function, which is a list of +// - Block, which is a list of // - Instruction // @@ -65,7 +65,7 @@ const Id NoResult = 0; const Id NoType = 0; const Decoration NoPrecision = DecorationMax; -const MemorySemanticsMask MemorySemanticsAllMemory = +const MemorySemanticsMask MemorySemanticsAllMemory = (MemorySemanticsMask)(MemorySemanticsSequentiallyConsistentMask | MemorySemanticsUniformMemoryMask | MemorySemanticsSubgroupMemoryMask | @@ -229,7 +229,7 @@ protected: std::vector > localVariables; Function& parent; - // track whether this block is known to be uncreachable (not necessarily + // track whether this block is known to be uncreachable (not necessarily // true for all unreachable blocks, but should be set at least // for the extraneous ones introduced by the builder). bool unreachable; diff --git a/deps/glslang/glslang/StandAlone/Worklist.h b/deps/glslang/glslang/StandAlone/Worklist.h index 57dc0db7b2..cfa80a8321 100644 --- a/deps/glslang/glslang/StandAlone/Worklist.h +++ b/deps/glslang/glslang/StandAlone/Worklist.h @@ -59,21 +59,21 @@ namespace glslang { void add(TWorkItem* item) { GetGlobalLock(); - + worklist.push_back(item); - + ReleaseGlobalLock(); } - + bool remove(TWorkItem*& item) { GetGlobalLock(); - + if (worklist.empty()) return false; item = worklist.front(); worklist.pop_front(); - + ReleaseGlobalLock(); return true; diff --git a/deps/glslang/glslang/glslang/Include/BaseTypes.h b/deps/glslang/glslang/glslang/Include/BaseTypes.h index f707440672..38719306d0 100644 --- a/deps/glslang/glslang/glslang/Include/BaseTypes.h +++ b/deps/glslang/glslang/glslang/Include/BaseTypes.h @@ -84,7 +84,7 @@ enum TStorageQualifier { EvqUniform, // read only, shared with app EvqBuffer, // read/write, shared with app EvqShared, // compute shader's read/write 'shared' qualifier - + // parameters EvqIn, // also, for 'in' in the grammar before we know if it's a pipeline input or an 'in' parameter EvqOut, // also, for 'out' in the grammar before we know if it's a pipeline output or an 'out' parameter @@ -212,7 +212,7 @@ enum TBuiltInVariable { }; // These will show up in error messages -__inline const char* GetStorageQualifierString(TStorageQualifier q) +__inline const char* GetStorageQualifierString(TStorageQualifier q) { switch (q) { case EvqTemporary: return "temp"; break; diff --git a/deps/glslang/glslang/glslang/Include/Common.h b/deps/glslang/glslang/glslang/Include/Common.h index a779c83e6a..e0af6b1ff1 100644 --- a/deps/glslang/glslang/glslang/Include/Common.h +++ b/deps/glslang/glslang/glslang/Include/Common.h @@ -56,7 +56,7 @@ std::string to_string(const T& val) { #if defined(_MSC_VER) && _MSC_VER < 1700 inline long long int strtoll (const char* str, char** endptr, int base) { - return _strtoi64(str, endptr, base); + return _strtoi64(str, endptr, base); } inline unsigned long long int strtoull (const char* str, char** endptr, int base) { @@ -168,7 +168,7 @@ public: template class TList : public std::list > { }; -template > +template > class TMap : public std::map > > { }; @@ -194,13 +194,13 @@ template T Max(const T a, const T b) { return a > b ? a : b; } inline const TString String(const int i, const int /*base*/ = 10) { char text[16]; // 32 bit ints are at most 10 digits in base 10 - + // we assume base 10 for all cases snprintf(text, sizeof(text), "%d", i); return text; } - + struct TSourceLoc { void init() { name = nullptr; string = 0; line = 0; column = 0; } // Returns the name if it exists. Otherwise, returns the string number. diff --git a/deps/glslang/glslang/glslang/Include/ConstantUnion.h b/deps/glslang/glslang/glslang/Include/ConstantUnion.h index ec6aff1171..18756f5ce0 100644 --- a/deps/glslang/glslang/glslang/Include/ConstantUnion.h +++ b/deps/glslang/glslang/glslang/Include/ConstantUnion.h @@ -46,14 +46,14 @@ public: TConstUnion() : iConst(0), type(EbtInt) { } void setIConst(int i) - { - iConst = i; + { + iConst = i; type = EbtInt; } void setUConst(unsigned int u) { - uConst = u; + uConst = u; type = EbtUint; } @@ -71,13 +71,13 @@ public: void setDConst(double d) { - dConst = d; + dConst = d; type = EbtDouble; } void setBConst(bool b) { - bConst = b; + bConst = b; type = EbtBool; } @@ -215,7 +215,7 @@ public: } bool operator>(const TConstUnion& constant) const - { + { assert(type == constant.type); switch (type) { case EbtInt: @@ -250,7 +250,7 @@ public: } bool operator<(const TConstUnion& constant) const - { + { assert(type == constant.type); switch (type) { case EbtInt: @@ -285,7 +285,7 @@ public: } TConstUnion operator+(const TConstUnion& constant) const - { + { TConstUnion returnValue; assert(type == constant.type); switch (type) { @@ -301,7 +301,7 @@ public: } TConstUnion operator-(const TConstUnion& constant) const - { + { TConstUnion returnValue; assert(type == constant.type); switch (type) { @@ -317,7 +317,7 @@ public: } TConstUnion operator*(const TConstUnion& constant) const - { + { TConstUnion returnValue; assert(type == constant.type); switch (type) { @@ -325,7 +325,7 @@ public: case EbtInt64: returnValue.setI64Const(i64Const * constant.i64Const); break; case EbtUint: returnValue.setUConst(uConst * constant.uConst); break; case EbtUint64: returnValue.setU64Const(u64Const * constant.u64Const); break; - case EbtDouble: returnValue.setDConst(dConst * constant.dConst); break; + case EbtDouble: returnValue.setDConst(dConst * constant.dConst); break; default: assert(false && "Default missing"); } @@ -333,7 +333,7 @@ public: } TConstUnion operator%(const TConstUnion& constant) const - { + { TConstUnion returnValue; assert(type == constant.type); switch (type) { @@ -348,7 +348,7 @@ public: } TConstUnion operator>>(const TConstUnion& constant) const - { + { TConstUnion returnValue; switch (type) { case EbtInt: @@ -394,7 +394,7 @@ public: } TConstUnion operator<<(const TConstUnion& constant) const - { + { TConstUnion returnValue; switch (type) { case EbtInt: @@ -440,7 +440,7 @@ public: } TConstUnion operator&(const TConstUnion& constant) const - { + { TConstUnion returnValue; assert(type == constant.type); switch (type) { @@ -455,7 +455,7 @@ public: } TConstUnion operator|(const TConstUnion& constant) const - { + { TConstUnion returnValue; assert(type == constant.type); switch (type) { @@ -470,7 +470,7 @@ public: } TConstUnion operator^(const TConstUnion& constant) const - { + { TConstUnion returnValue; assert(type == constant.type); switch (type) { @@ -485,7 +485,7 @@ public: } TConstUnion operator~() const - { + { TConstUnion returnValue; switch (type) { case EbtInt: returnValue.setIConst(~iConst); break; @@ -499,7 +499,7 @@ public: } TConstUnion operator&&(const TConstUnion& constant) const - { + { TConstUnion returnValue; assert(type == constant.type); switch (type) { @@ -511,7 +511,7 @@ public: } TConstUnion operator||(const TConstUnion& constant) const - { + { TConstUnion returnValue; assert(type == constant.type); switch (type) { @@ -544,7 +544,7 @@ private: // One convenience is being able to use [] to go inside the array, instead // of C++ assuming it as an array of pointers to vectors. // -// General usage is that the size is known up front, and it is +// General usage is that the size is known up front, and it is // created once with the proper size. // class TConstUnionArray { diff --git a/deps/glslang/glslang/glslang/Include/InfoSink.h b/deps/glslang/glslang/glslang/Include/InfoSink.h index 0cbd99bdaa..54f1f3393c 100644 --- a/deps/glslang/glslang/glslang/Include/InfoSink.h +++ b/deps/glslang/glslang/glslang/Include/InfoSink.h @@ -74,9 +74,9 @@ public: TInfoSinkBase& operator<<(const char* s) { append(s); return *this; } TInfoSinkBase& operator<<(int n) { append(String(n)); return *this; } TInfoSinkBase& operator<<(unsigned int n) { append(String(n)); return *this; } - TInfoSinkBase& operator<<(float n) { const int size = 40; char buf[size]; + TInfoSinkBase& operator<<(float n) { const int size = 40; char buf[size]; snprintf(buf, size, (fabs(n) > 1e-8 && fabs(n) < 1e8) || n == 0.0f ? "%f" : "%g", n); - append(buf); + append(buf); return *this; } TInfoSinkBase& operator+(const TPersistString& t) { append(t); return *this; } TInfoSinkBase& operator+(const TString& t) { append(t); return *this; } @@ -113,20 +113,20 @@ public: append(s); append("\n"); } - + void setOutputStream(int output = 4) { outputStream = output; } protected: - void append(const char* s); + void append(const char* s); void append(int count, char c); void append(const TPersistString& t); void append(const TString& t); - void checkMem(size_t growth) { if (sink.capacity() < sink.size() + growth + 2) + void checkMem(size_t growth) { if (sink.capacity() < sink.size() + growth + 2) sink.reserve(sink.capacity() + sink.capacity() / 2); } void appendToStream(const char* s); TPersistString sink; diff --git a/deps/glslang/glslang/glslang/Include/PoolAlloc.h b/deps/glslang/glslang/glslang/Include/PoolAlloc.h index 635be79ef9..0aa2ab2c11 100644 --- a/deps/glslang/glslang/glslang/Include/PoolAlloc.h +++ b/deps/glslang/glslang/glslang/Include/PoolAlloc.h @@ -43,8 +43,8 @@ // // This header defines an allocator that can be used to efficiently -// allocate a large number of small requests for heap memory, with the -// intention that they are not individually deallocated, but rather +// allocate a large number of small requests for heap memory, with the +// intention that they are not individually deallocated, but rather // collectively deallocated at one time. // // This simultaneously @@ -70,7 +70,7 @@ namespace glslang { // If we are using guard blocks, we must track each individual // allocation. If we aren't using guard blocks, these // never get instantiated, so won't have any impact. -// +// class TAllocation { public: @@ -87,7 +87,7 @@ public: memset(postGuard(), guardBlockEndVal, guardBlockSize); # endif } - + void check() const { checkGuardBlock(preGuard(), guardBlockBeginVal, "before"); checkGuardBlock(postGuard(), guardBlockEndVal, "after"); @@ -100,7 +100,7 @@ public: inline static size_t allocationSize(size_t size) { return size + 2 * guardBlockSize + headerSize(); } - + // Offset from surrounding buffer to get to user data buffer. inline static unsigned char* offsetAllocation(unsigned char* m) { return m + guardBlockSize + headerSize(); @@ -123,16 +123,16 @@ private: const static unsigned char userDataFill; const static size_t guardBlockSize; -# ifdef GUARD_BLOCKS +# ifdef GUARD_BLOCKS inline static size_t headerSize() { return sizeof(TAllocation); } # else inline static size_t headerSize() { return 0; } # endif }; - + // // There are several stacks. One is to track the pushing and popping -// of the user, and not yet implemented. The others are simply a +// of the user, and not yet implemented. The others are simply a // repositories of free pages or used pages. // // Page stacks are linked together with a simple header at the beginning @@ -141,7 +141,7 @@ private: // re-use. // // The "page size" used is not, nor must it match, the underlying OS -// page size. But, having it be about that size or equal to a set of +// page size. But, having it be about that size or equal to a set of // pages is likely most optimal. // class TPoolAllocator { @@ -185,7 +185,7 @@ public: protected: friend struct tHeader; - + struct tHeader { tHeader(tHeader* nextPage, size_t pageCount) : #ifdef GUARD_BLOCKS @@ -227,7 +227,7 @@ protected: } size_t pageSize; // granularity of allocation from the OS - size_t alignment; // all returned allocations will be aligned at + size_t alignment; // all returned allocations will be aligned at // this granularity, which will be a power of 2 size_t alignmentMask; size_t headerSkip; // amount of memory to skip to make room for the @@ -278,7 +278,7 @@ public: typedef T& reference; typedef const T& const_reference; typedef T value_type; - template + template struct rebind { typedef pool_allocator other; }; @@ -292,9 +292,9 @@ public: template pool_allocator(const pool_allocator& p) : allocator(p.getAllocator()) { } - pointer allocate(size_type n) { + pointer allocate(size_type n) { return reinterpret_cast(getAllocator().allocate(n * sizeof(T))); } - pointer allocate(size_type n, const void*) { + pointer allocate(size_type n, const void*) { return reinterpret_cast(getAllocator().allocate(n * sizeof(T))); } void deallocate(void*, size_type) { } diff --git a/deps/glslang/glslang/glslang/Include/ResourceLimits.h b/deps/glslang/glslang/glslang/Include/ResourceLimits.h index e8c743d6b7..b9cadb9faf 100644 --- a/deps/glslang/glslang/glslang/Include/ResourceLimits.h +++ b/deps/glslang/glslang/glslang/Include/ResourceLimits.h @@ -81,7 +81,7 @@ struct TBuiltInResource { int maxComputeImageUniforms; int maxComputeAtomicCounters; int maxComputeAtomicCounterBuffers; - int maxVaryingComponents; + int maxVaryingComponents; int maxVertexOutputComponents; int maxGeometryInputComponents; int maxGeometryOutputComponents; diff --git a/deps/glslang/glslang/glslang/Include/ShHandle.h b/deps/glslang/glslang/glslang/Include/ShHandle.h index bfc97db8b2..1e24fdd933 100644 --- a/deps/glslang/glslang/glslang/Include/ShHandle.h +++ b/deps/glslang/glslang/glslang/Include/ShHandle.h @@ -43,7 +43,7 @@ // -#define SH_EXPORTING +#define SH_EXPORTING #include "../Public/ShaderLang.h" #include "../MachineIndependent/Versions.h" #include "InfoSink.h" @@ -73,7 +73,7 @@ public: TUniformMap() { } virtual ~TUniformMap() { } virtual TUniformMap* getAsUniformMap() { return this; } - virtual int getLocation(const char* name) = 0; + virtual int getLocation(const char* name) = 0; virtual TInfoSink& getInfoSink() { return infoSink; } TInfoSink infoSink; }; @@ -95,7 +95,7 @@ public: virtual TCompiler* getAsCompiler() { return this; } virtual bool linkable() { return haveValidObjectCode; } - + TInfoSink& infoSink; protected: TCompiler& operator=(TCompiler&); @@ -117,9 +117,9 @@ typedef glslang::TVector THandleList; class TLinker : public TShHandleBase { public: - TLinker(EShExecutable e, TInfoSink& iSink) : + TLinker(EShExecutable e, TInfoSink& iSink) : infoSink(iSink), - executable(e), + executable(e), haveReturnableObjectCode(false), appAttributeBindings(0), fixedAttributeBindings(0), @@ -147,7 +147,7 @@ protected: const ShBindingTable* fixedAttributeBindings; const int* excludedAttributes; int excludedCount; - ShBindingTable* uniformBindings; // created by the linker + ShBindingTable* uniformBindings; // created by the linker }; // @@ -155,7 +155,7 @@ protected: // and the machine dependent code. // // The machine dependent code should derive from the classes -// above. Then Construct*() and Delete*() will create and +// above. Then Construct*() and Delete*() will create and // destroy the machine dependent objects, which contain the // above machine independent information. // @@ -165,7 +165,7 @@ TShHandleBase* ConstructLinker(EShExecutable, int); TShHandleBase* ConstructBindings(); void DeleteLinker(TShHandleBase*); void DeleteBindingList(TShHandleBase* bindingList); - + TUniformMap* ConstructUniformMap(); void DeleteCompiler(TCompiler*); diff --git a/deps/glslang/glslang/glslang/Include/Types.h b/deps/glslang/glslang/glslang/Include/Types.h index 8745c7a942..7642df9be1 100644 --- a/deps/glslang/glslang/glslang/Include/Types.h +++ b/deps/glslang/glslang/glslang/Include/Types.h @@ -421,7 +421,7 @@ public: clearLayout(); } - // Drop just the storage qualification, which perhaps should + // Drop just the storage qualification, which perhaps should // never be done, as it is fundamentally inconsistent, but need to // explore what downstream consumers need. // E.g., in a deference, it is an inconsistency between: @@ -1067,7 +1067,7 @@ public: qualifier.storage = q; } // for explicit precision qualifier - TType(TBasicType t, TStorageQualifier q, TPrecisionQualifier p, int vs = 1, int mc = 0, int mr = 0, + TType(TBasicType t, TStorageQualifier q, TPrecisionQualifier p, int vs = 1, int mc = 0, int mr = 0, bool isVector = false) : basicType(t), vectorSize(vs), matrixCols(mc), matrixRows(mr), vector1(isVector && vs == 1), arraySizes(nullptr), structure(nullptr), fieldName(nullptr), typeName(nullptr) diff --git a/deps/glslang/glslang/glslang/Include/intermediate.h b/deps/glslang/glslang/glslang/Include/intermediate.h index 8f7ffcc0da..ffdc82b003 100644 --- a/deps/glslang/glslang/glslang/Include/intermediate.h +++ b/deps/glslang/glslang/glslang/Include/intermediate.h @@ -38,7 +38,7 @@ // Definition of the in-memory high-level intermediate representation // of shaders. This is a tree that parser creates. // -// Nodes in the tree are defined as a hierarchy of classes derived from +// Nodes in the tree are defined as a hierarchy of classes derived from // TIntermNode. Each is a node in a tree. There is no preset branching factor; // each node can have it's own type of list of children. // @@ -66,14 +66,14 @@ enum TOperator { EOpNull, // if in a node, should only mean a node is still being built EOpSequence, // denotes a list of statements, or parameters, etc. EOpLinkerObjects, // for aggregate node of objects the linker may need, if not reference by the rest of the AST - EOpFunctionCall, + EOpFunctionCall, EOpFunction, // For function definition EOpParameters, // an aggregate listing the parameters to a function // // Unary operators // - + EOpNegative, EOpLogicalNot, EOpVectorLogicalNot, @@ -445,7 +445,7 @@ enum TOperator { // // moves // - + EOpAssign, EOpAddAssign, EOpSubAssign, @@ -708,7 +708,7 @@ public: virtual void setType(const TType& t) { type.shallowCopy(t); } virtual const TType& getType() const { return type; } virtual TType& getWritableType() { return type; } - + virtual TBasicType getBasicType() const { return type.getBasicType(); } virtual TQualifier& getQualifier() { return type.getQualifier(); } virtual const TQualifier& getQualifier() const { return type.getQualifier(); } @@ -733,7 +733,7 @@ protected: // class TIntermLoop : public TIntermNode { public: - TIntermLoop(TIntermNode* aBody, TIntermTyped* aTest, TIntermTyped* aTerminal, bool testFirst) : + TIntermLoop(TIntermNode* aBody, TIntermTyped* aTest, TIntermTyped* aTerminal, bool testFirst) : body(aBody), test(aTest), terminal(aTerminal), @@ -1147,7 +1147,7 @@ enum TVisit }; // -// For traversing the tree. User should derive from this, +// For traversing the tree. User should derive from this, // put their traversal specific data in it, and then pass // it to a Traverse method. // @@ -1159,10 +1159,10 @@ enum TVisit // the subtree). Similarly for inVisit for in-order visiting of nodes with // multiple children. // -// If you only want post-visits, explicitly turn off preVisit (and inVisit) +// If you only want post-visits, explicitly turn off preVisit (and inVisit) // and turn on postVisit. // -// In general, for the visit*() methods, return true from interior nodes +// In general, for the visit*() methods, return true from interior nodes // to have the traversal continue on to children. // // If you process children yourself, or don't want them processed, return false. diff --git a/deps/glslang/glslang/glslang/MachineIndependent/Initialize.h b/deps/glslang/glslang/glslang/MachineIndependent/Initialize.h index 23f57acc17..a61c6b408a 100644 --- a/deps/glslang/glslang/glslang/MachineIndependent/Initialize.h +++ b/deps/glslang/glslang/glslang/MachineIndependent/Initialize.h @@ -67,7 +67,7 @@ public: virtual const TString& getStageString(EShLanguage language) const { return stageBuiltins[language]; } virtual void identifyBuiltIns(int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language, TSymbolTable& symbolTable) = 0; - + virtual void identifyBuiltIns(int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language, TSymbolTable& symbolTable, const TBuiltInResource &resources) = 0; protected: @@ -89,7 +89,7 @@ public: void initialize(const TBuiltInResource& resources, int version, EProfile, const SpvVersion& spvVersion, EShLanguage); void identifyBuiltIns(int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language, TSymbolTable& symbolTable); - + void identifyBuiltIns(int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language, TSymbolTable& symbolTable, const TBuiltInResource &resources); protected: diff --git a/deps/glslang/glslang/glslang/MachineIndependent/ParseHelper.h b/deps/glslang/glslang/glslang/MachineIndependent/ParseHelper.h index 6234db6095..30f2d9a822 100644 --- a/deps/glslang/glslang/glslang/MachineIndependent/ParseHelper.h +++ b/deps/glslang/glslang/glslang/MachineIndependent/ParseHelper.h @@ -449,7 +449,7 @@ protected: // * note, that appropriately gives an error if redeclaring a block that // was already used and hence already copied-up // - // - on seeing a layout declaration that sizes the array, fix everything in the + // - on seeing a layout declaration that sizes the array, fix everything in the // resize-list, giving errors for mismatch // // - on seeing an array size declaration, give errors on mismatch between it and previous diff --git a/deps/glslang/glslang/glslang/MachineIndependent/Scan.h b/deps/glslang/glslang/glslang/MachineIndependent/Scan.h index 67c86d2efe..fe747ef431 100644 --- a/deps/glslang/glslang/glslang/MachineIndependent/Scan.h +++ b/deps/glslang/glslang/glslang/MachineIndependent/Scan.h @@ -254,7 +254,7 @@ protected: size_t currentChar; // This is for reporting what string/line an error occurred on, and can be overridden by #line. - // It remembers the last state of each source string as it is left for the next one, so unget() + // It remembers the last state of each source string as it is left for the next one, so unget() // can restore that state. TSourceLoc* loc; // an array diff --git a/deps/glslang/glslang/glslang/MachineIndependent/SymbolTable.h b/deps/glslang/glslang/glslang/MachineIndependent/SymbolTable.h index aeec34fc02..9f5a2e69f5 100644 --- a/deps/glslang/glslang/glslang/MachineIndependent/SymbolTable.h +++ b/deps/glslang/glslang/glslang/MachineIndependent/SymbolTable.h @@ -120,7 +120,7 @@ protected: const TString *name; unsigned int uniqueId; // For cross-scope comparing during code generation - // For tracking what extensions must be present + // For tracking what extensions must be present // (don't use if correct version/profile is present). int numExtensions; const char** extensions; // an array of pointers to existing constant char strings @@ -145,7 +145,7 @@ protected: class TVariable : public TSymbol { public: TVariable(const TString *name, const TType& t, bool uT = false ) - : TSymbol(name), + : TSymbol(name), userType(uT), constSubtree(nullptr), anonId(-1) { type.shallowCopy(t); } @@ -191,7 +191,7 @@ protected: struct TParameter { TString *name; TType* type; - void copyParam(const TParameter& param) + void copyParam(const TParameter& param) { if (param.name) name = NewPoolTString(param.name->c_str()); @@ -272,7 +272,7 @@ public: virtual const TAnonMember* getAsAnonMember() const { return this; } virtual const TVariable& getAnonContainer() const { return anonContainer; } virtual unsigned int getMemberNumber() const { return memberNumber; } - + virtual const TType& getType() const { const TTypeList& types = *anonContainer.getType().getStruct(); @@ -285,7 +285,7 @@ public: const TTypeList& types = *anonContainer.getType().getStruct(); return *types[memberNumber].type; } - + virtual int getAnonId() const { return anonId; } virtual void dump(TInfoSink &infoSink) const; @@ -365,7 +365,7 @@ public: TSymbol* find(const TString& name) const { tLevel::const_iterator it = level.find(name); - if (it == level.end()) + if (it == level.end()) return 0; else return (*it).second; @@ -488,7 +488,7 @@ public: while (table.size() > adoptedLevels) pop(0); } - + void adoptLevels(TSymbolTable& symTable) { for (unsigned int level = 0; level < symTable.table.size(); ++level) { @@ -520,7 +520,7 @@ public: void setNoBuiltInRedeclarations() { noBuiltInRedeclarations = true; } void setSeparateNameSpaces() { separateNameSpaces = true; } - + void push() { table.push_back(new TSymbolTableLevel); @@ -546,7 +546,7 @@ public: // make sure there isn't a function of this variable name if (! separateNameSpaces && ! symbol.getAsFunction() && table[currentLevel()]->hasFunctionName(symbol.getName())) return false; - + // check for not overloading or redefining a built-in function if (noBuiltInRedeclarations) { if (atGlobalLevel() && currentLevel() > 0) { @@ -570,7 +570,7 @@ public: // // To allocate an internal temporary, which will need to be uniquely - // identified by the consumer of the AST, but never need to + // identified by the consumer of the AST, but never need to // found by doing a symbol table search by name, hence allowed an // arbitrary name in the symbol with no worry of collision. // @@ -672,7 +672,7 @@ public: for (unsigned int level = 0; level < table.size(); ++level) table[level]->relateToOperator(name, op); } - + void setFunctionExtensions(const char* name, int num, const char* const extensions[]) { for (unsigned int level = 0; level < table.size(); ++level) diff --git a/deps/glslang/glslang/glslang/MachineIndependent/glslang_tab.cpp.h b/deps/glslang/glslang/glslang/MachineIndependent/glslang_tab.cpp.h index b6d27993c9..a3a458bb77 100644 --- a/deps/glslang/glslang/glslang/MachineIndependent/glslang_tab.cpp.h +++ b/deps/glslang/glslang/glslang/MachineIndependent/glslang_tab.cpp.h @@ -1,19 +1,19 @@ /* A Bison parser, made by GNU Bison 2.7. */ /* Bison interface for Yacc-like parsers in C - + Copyright (C) 1984, 1989-1990, 2000-2012 Free Software Foundation, Inc. - + 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 3 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, see . */ @@ -26,7 +26,7 @@ special exception, which will cause the skeleton and the resulting Bison output files to be licensed under the GNU General Public License without this special exception. - + This special exception was added by the Free Software Foundation in version 2.2 of Bison. */ diff --git a/deps/glslang/glslang/glslang/MachineIndependent/localintermediate.h b/deps/glslang/glslang/glslang/MachineIndependent/localintermediate.h index 6f6db92d5f..57a2a70353 100644 --- a/deps/glslang/glslang/glslang/MachineIndependent/localintermediate.h +++ b/deps/glslang/glslang/glslang/MachineIndependent/localintermediate.h @@ -83,7 +83,7 @@ struct TCall { // A generic 1-D range. struct TRange { TRange(int start, int last) : start(start), last(last) { } - bool overlap(const TRange& rhs) const + bool overlap(const TRange& rhs) const { return last >= rhs.start && start <= rhs.last; } @@ -188,7 +188,7 @@ public: bool getFlattenUniformArrays() const { return flattenUniformArrays; } void setNoStorageFormat(bool b) { useUnknownFormat = b; } bool getNoStorageFormat() const { return useUnknownFormat; } - + void setVersion(int v) { version = v; } int getVersion() const { return version; } void setProfile(EProfile p) { profile = p; } @@ -269,7 +269,7 @@ public: void addSymbolLinkageNodes(TIntermAggregate*& linkage, EShLanguage, TSymbolTable&); void addSymbolLinkageNode(TIntermAggregate*& linkage, const TSymbol&); - bool setInvocations(int i) + bool setInvocations(int i) { if (invocations != TQualifier::layoutNotSet) return invocations == i; @@ -311,7 +311,7 @@ public: TVertexOrder getVertexOrder() const { return vertexOrder; } void setPointMode() { pointMode = true; } bool getPointMode() const { return pointMode; } - + bool setLocalSize(int dim, int size) { if (localSize[dim] > 1) @@ -406,7 +406,7 @@ protected: bool promoteBinary(TIntermBinary&); void addSymbolLinkageNode(TIntermAggregate*& linkage, TSymbolTable&, const TString&); bool promoteAggregate(TIntermAggregate&); - + const EShLanguage language; // stage, known at construction time EShSource source; // source language, known a bit later std::string entryPointName; diff --git a/deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpContext.h b/deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpContext.h index 013c90e567..f1c2f31108 100644 --- a/deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpContext.h +++ b/deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpContext.h @@ -56,7 +56,7 @@ Except as expressly stated in this notice, no other rights or licenses express or implied, are granted by NVIDIA herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the NVIDIA Software may be -incorporated. No hardware is licensed hereunder. +incorporated. No hardware is licensed hereunder. THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, @@ -94,7 +94,7 @@ class TPpToken { public: TPpToken() : token(0), space(false), ival(0), dval(0.0), atom(0) { - loc.init(); + loc.init(); name[0] = 0; } @@ -239,7 +239,7 @@ protected: static const int maxMacroArgs = 64; static const int maxIfNesting = 64; - int ifdepth; // current #if-#else-#endif nesting in the cpp.c file (pre-processor) + int ifdepth; // current #if-#else-#endif nesting in the cpp.c file (pre-processor) bool elseSeen[maxIfNesting]; // Keep a track of whether an else has been seen at a particular depth int elsetracker; // #if-#else and #endif constructs...Counter. @@ -301,11 +301,11 @@ protected: int extraTokenCheck(int atom, TPpToken* ppToken, int token); int eval(int token, int precedence, bool shortCircuit, int& res, bool& err, TPpToken * ppToken); int evalToToken(int token, bool shortCircuit, int& res, bool& err, TPpToken * ppToken); - int CPPif (TPpToken * ppToken); + int CPPif (TPpToken * ppToken); int CPPifdef(int defined, TPpToken * ppToken); int CPPinclude(TPpToken * ppToken); - int CPPline(TPpToken * ppToken); - int CPPerror(TPpToken * ppToken); + int CPPline(TPpToken * ppToken); + int CPPerror(TPpToken * ppToken); int CPPpragma(TPpToken * ppToken); int CPPversion(TPpToken * ppToken); int CPPextension(TPpToken * ppToken); @@ -331,7 +331,7 @@ protected: int ReadToken(TokenStream* pTok, TPpToken* ppToken); void pushTokenStreamInput(TokenStream *ts); void UngetToken(int token, TPpToken* ppToken); - + class tTokenInput : public tInput { public: tTokenInput(TPpContext* pp, TokenStream* t) : tInput(pp), tokens(t) { } @@ -387,7 +387,7 @@ protected: return '\\'; } while (ch == '\\'); } - + // handle any non-escaped newline if (ch == '\r' || ch == '\n') { if (ch == '\r' && input->peek() == '\n') @@ -432,7 +432,7 @@ protected: TInputScanner* input; }; - // Holds a reference to included file data, as well as a + // Holds a reference to included file data, as well as a // prologue and an epilogue string. This can be scanned using the tInput // interface and acts as a single source string. class TokenizableIncludeFile : public tInput { diff --git a/deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpTokens.h b/deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpTokens.h index c84431d368..2d231e1d2d 100644 --- a/deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpTokens.h +++ b/deps/glslang/glslang/glslang/MachineIndependent/preprocessor/PpTokens.h @@ -56,7 +56,7 @@ Except as expressly stated in this notice, no other rights or licenses express or implied, are granted by NVIDIA herein, including but not limited to any patent rights that may be infringed by your derivative works or by other works in which the NVIDIA Software may be -incorporated. No hardware is licensed hereunder. +incorporated. No hardware is licensed hereunder. THE NVIDIA SOFTWARE IS BEING PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS OR IMPLIED, @@ -128,7 +128,7 @@ enum EFixedAtoms { #endif PpAtomConstString, - // Identifiers + // Identifiers PpAtomIdentifier, // preprocessor "keywords" diff --git a/deps/glslang/glslang/glslang/MachineIndependent/reflection.h b/deps/glslang/glslang/glslang/MachineIndependent/reflection.h index 13f5177c0f..b6bf4a9b02 100644 --- a/deps/glslang/glslang/glslang/MachineIndependent/reflection.h +++ b/deps/glslang/glslang/glslang/MachineIndependent/reflection.h @@ -55,7 +55,7 @@ class TReflectionTraverser; // Data needed for just a single object at the granularity exchanged by the reflection API class TObjectReflection { public: - TObjectReflection(const TString& pName, const TType& pType, int pOffset, int pGLDefineType, int pSize, int pIndex) : + TObjectReflection(const TString& pName, const TType& pType, int pOffset, int pGLDefineType, int pSize, int pIndex) : name(pName), type(pType.clone()), offset(pOffset), glDefineType(pGLDefineType), size(pSize), index(pIndex) { } @@ -107,7 +107,7 @@ public: // for mapping a block index to the block's description int getNumUniformBlocks() const { return (int)indexToUniformBlock.size(); } - const TObjectReflection& getUniformBlock(int i) const + const TObjectReflection& getUniformBlock(int i) const { if (i >= 0 && i < (int)indexToUniformBlock.size()) return indexToUniformBlock[i]; @@ -126,7 +126,7 @@ public: } // for mapping any name to its index (block names, uniform names and attribute names) - int getIndex(const char* name) const + int getIndex(const char* name) const { TNameToIndex::const_iterator it = nameToIndex.find(name); if (it == nameToIndex.end()) diff --git a/deps/glslang/glslang/glslang/Public/ShaderLang.h b/deps/glslang/glslang/glslang/Public/ShaderLang.h index afdc7d1eb2..4e4d695c69 100644 --- a/deps/glslang/glslang/glslang/Public/ShaderLang.h +++ b/deps/glslang/glslang/glslang/Public/ShaderLang.h @@ -165,9 +165,9 @@ typedef struct { // // ShHandle held by but opaque to the driver. It is allocated, -// managed, and de-allocated by the compiler/linker. It's contents +// managed, and de-allocated by the compiler/linker. It's contents // are defined by and used by the compiler and linker. For example, -// symbol table information and object code passed from the compiler +// symbol table information and object code passed from the compiler // to the linker can be stored where ShHandle points. // // If handle creation fails, 0 will be returned. @@ -187,7 +187,7 @@ SH_IMPORT_EXPORT void ShDestruct(ShHandle); // The return value of ShCompile is boolean, non-zero indicating // success. // -// The info-log should be written by ShCompile into +// The info-log should be written by ShCompile into // ShHandle, so it can answer future queries. // SH_IMPORT_EXPORT int ShCompile( @@ -251,8 +251,8 @@ SH_IMPORT_EXPORT int ShGetUniformLocation(const ShHandle uniformMap, const char* // ----------------------------------- // // Below is a new alternate C++ interface that might potentially replace the above -// opaque handle-based interface. -// +// opaque handle-based interface. +// // The below is further designed to handle multiple compilation units per stage, where // the intermediate results, including the parse tree, are preserved until link time, // rather than the above interface which is designed to have each compilation unit @@ -513,7 +513,7 @@ public: const char *getAttributeName(int index) const; // can be used for glGetActiveAttrib() int getAttributeType(int index) const; // can be used for glGetActiveAttrib() const TType* getUniformTType(int index) const; // returns a TType* - const TType* getUniformBlockTType(int index) const; // returns a TType* + const TType* getUniformBlockTType(int index) const; // returns a TType* const TType* getAttributeTType(int index) const; // returns a TType* void dumpReflection(); diff --git a/deps/glslang/glslang/gtests/TestFixture.h b/deps/glslang/glslang/gtests/TestFixture.h index e795e8dc90..8aee0cf88e 100644 --- a/deps/glslang/glslang/gtests/TestFixture.h +++ b/deps/glslang/glslang/gtests/TestFixture.h @@ -258,7 +258,7 @@ public: glslang::TProgram program; program.addShader(&shader); - + success &= program.link(controls); success &= program.mapIO(); @@ -330,7 +330,7 @@ public: std::vector spirv_binary(code); // scratch copy spv::spirvbin_t(0 /*verbosity*/).remap(spirv_binary, remapOptions); - + std::ostringstream disassembly_stream; spv::Parameterize(); spv::Disassemble(disassembly_stream, spirv_binary); diff --git a/deps/glslang/glslang/hlsl/hlslGrammar.h b/deps/glslang/glslang/hlsl/hlslGrammar.h index 8804b217ec..ad124cb755 100755 --- a/deps/glslang/glslang/hlsl/hlslGrammar.h +++ b/deps/glslang/glslang/hlsl/hlslGrammar.h @@ -44,7 +44,7 @@ namespace glslang { class TAttributeMap; // forward declare - + // Should just be the grammar aspect of HLSL. // Described in more detail in hlslGrammar.cpp. diff --git a/deps/glslang/glslang/hlsl/hlslParseHelper.h b/deps/glslang/glslang/hlsl/hlslParseHelper.h index 206df9b887..1de4f36d03 100755 --- a/deps/glslang/glslang/hlsl/hlslParseHelper.h +++ b/deps/glslang/glslang/hlsl/hlslParseHelper.h @@ -263,7 +263,7 @@ protected: // * note, that appropriately gives an error if redeclaring a block that // was already used and hence already copied-up // - // - on seeing a layout declaration that sizes the array, fix everything in the + // - on seeing a layout declaration that sizes the array, fix everything in the // resize-list, giving errors for mismatch // // - on seeing an array size declaration, give errors on mismatch between it and previous diff --git a/deps/glslang/glslang/hlsl/hlslParseables.h b/deps/glslang/glslang/hlsl/hlslParseables.h index c837590030..3c93b178e6 100755 --- a/deps/glslang/glslang/hlsl/hlslParseables.h +++ b/deps/glslang/glslang/hlsl/hlslParseables.h @@ -52,7 +52,7 @@ public: void initialize(const TBuiltInResource& resources, int version, EProfile, const SpvVersion& spvVersion, EShLanguage); void identifyBuiltIns(int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language, TSymbolTable& symbolTable); - + void identifyBuiltIns(int version, EProfile profile, const SpvVersion& spvVersion, EShLanguage language, TSymbolTable& symbolTable, const TBuiltInResource &resources); private: diff --git a/deps/glslang/glslang/hlsl/hlslTokens.h b/deps/glslang/glslang/hlsl/hlslTokens.h index 6902070cbe..cfa63b7cfe 100755 --- a/deps/glslang/glslang/hlsl/hlslTokens.h +++ b/deps/glslang/glslang/hlsl/hlslTokens.h @@ -247,7 +247,7 @@ enum EHlslTokenClass { EHTokRWTexture2darray, EHTokRWTexture3d, EHTokRWBuffer, - + // variable, user type, ... EHTokIdentifier, diff --git a/deps/ibxm/ibxm.c b/deps/ibxm/ibxm.c index 526cfd6875..2097cedc12 100644 --- a/deps/ibxm/ibxm.c +++ b/deps/ibxm/ibxm.c @@ -1,1922 +1,1922 @@ - -#include "stdlib.h" -#include "string.h" - -#include "ibxm.h" - -const char *IBXM_VERSION = "ibxm/ac mod/xm/s3m replay 20170901 (c)mumart@gmail.com"; - -static const int FP_SHIFT = 15, FP_ONE = 32768, FP_MASK = 32767; - -static const int exp2_table[] = { - 32768, 32946, 33125, 33305, 33486, 33667, 33850, 34034, - 34219, 34405, 34591, 34779, 34968, 35158, 35349, 35541, - 35734, 35928, 36123, 36319, 36516, 36715, 36914, 37114, - 37316, 37518, 37722, 37927, 38133, 38340, 38548, 38757, - 38968, 39180, 39392, 39606, 39821, 40037, 40255, 40473, - 40693, 40914, 41136, 41360, 41584, 41810, 42037, 42265, - 42495, 42726, 42958, 43191, 43425, 43661, 43898, 44137, - 44376, 44617, 44859, 45103, 45348, 45594, 45842, 46091, - 46341, 46593, 46846, 47100, 47356, 47613, 47871, 48131, - 48393, 48655, 48920, 49185, 49452, 49721, 49991, 50262, - 50535, 50810, 51085, 51363, 51642, 51922, 52204, 52488, - 52773, 53059, 53347, 53637, 53928, 54221, 54515, 54811, - 55109, 55408, 55709, 56012, 56316, 56622, 56929, 57238, - 57549, 57861, 58176, 58491, 58809, 59128, 59449, 59772, - 60097, 60423, 60751, 61081, 61413, 61746, 62081, 62419, - 62757, 63098, 63441, 63785, 64132, 64480, 64830, 65182, - 65536 -}; - -static const short sine_table[] = { - 0, 24, 49, 74, 97, 120, 141, 161, 180, 197, 212, 224, 235, 244, 250, 253, - 255, 253, 250, 244, 235, 224, 212, 197, 180, 161, 141, 120, 97, 74, 49, 24 -}; - -struct note { - unsigned char key, instrument, volume, effect, param; -}; - -struct channel { - struct replay *replay; - struct instrument *instrument; - struct sample *sample; - struct note note; - int id, key_on, random_seed, pl_row; - int sample_off, sample_idx, sample_fra, freq, ampl, pann; - int volume, panning, fadeout_vol, vol_env_tick, pan_env_tick; - int period, porta_period, retrig_count, fx_count, av_count; - int porta_up_param, porta_down_param, tone_porta_param, offset_param; - int fine_porta_up_param, fine_porta_down_param, xfine_porta_param; - int arpeggio_param, vol_slide_param, gvol_slide_param, pan_slide_param; - int fine_vslide_up_param, fine_vslide_down_param; - int retrig_volume, retrig_ticks, tremor_on_ticks, tremor_off_ticks; - int vibrato_type, vibrato_phase, vibrato_speed, vibrato_depth; - int tremolo_type, tremolo_phase, tremolo_speed, tremolo_depth; - int tremolo_add, vibrato_add, arpeggio_add; -}; - -struct replay { - int sample_rate, interpolation, global_vol; - int seq_pos, break_pos, row, next_row, tick; - int speed, tempo, pl_count, pl_chan; - int *ramp_buf; - char **play_count; - struct channel *channels; - struct module *module; -}; - -static int exp_2( int x ) { - int c, m, y; - int x0 = ( x & FP_MASK ) >> ( FP_SHIFT - 7 ); - c = exp2_table[ x0 ]; - m = exp2_table[ x0 + 1 ] - c; - y = ( m * ( x & ( FP_MASK >> 7 ) ) >> 8 ) + c; - return ( y << FP_SHIFT ) >> ( FP_SHIFT - ( x >> FP_SHIFT ) ); -} - -static int log_2( int x ) { - int step; - int y = 16 << FP_SHIFT; - for( step = y; step > 0; step >>= 1 ) { - if( exp_2( y - step ) >= x ) { - y -= step; - } - } - return y; -} - -static char* data_ascii( struct data *data, int offset, int length, char *dest ) { - int idx, chr; - memset( dest, 32, length ); - if( offset > data->length ) { - offset = data->length; - } - if( ( unsigned int ) offset + length > ( unsigned int ) data->length ) { - length = data->length - offset; - } - for( idx = 0; idx < length; idx++ ) { - chr = data->buffer[ offset + idx ] & 0xFF; - if( chr > 32 ) { - dest[ idx ] = chr; - } - } - return dest; -} - -static int data_s8( struct data *data, int offset ) { - int value = 0; - if( offset < data->length ) { - value = data->buffer[ offset ]; - value = ( value & 0x7F ) - ( value & 0x80 ); - } - return value; -} - -static int data_u8( struct data *data, int offset ) { - int value = 0; - if( offset < data->length ) { - value = data->buffer[ offset ] & 0xFF; - } - return value; -} - -static int data_u16be( struct data *data, int offset ) { - int value = 0; - if( offset + 1 < data->length ) { - value = ( ( data->buffer[ offset ] & 0xFF ) << 8 ) - | ( data->buffer[ offset + 1 ] & 0xFF ); - } - return value; -} - -static int data_u16le( struct data *data, int offset ) { - int value = 0; - if( offset + 1 < data->length ) { - value = ( data->buffer[ offset ] & 0xFF ) - | ( ( data->buffer[ offset + 1 ] & 0xFF ) << 8 ); - } - return value; -} - -static unsigned int data_u32le( struct data *data, int offset ) { - unsigned int value = 0; - if( offset + 3 < data->length ) { - value = ( data->buffer[ offset ] & 0xFF ) - | ( ( data->buffer[ offset + 1 ] & 0xFF ) << 8 ) - | ( ( data->buffer[ offset + 2 ] & 0xFF ) << 16 ) - | ( ( data->buffer[ offset + 3 ] & 0xFF ) << 24 ); - } - return value; -} - -static void data_sam_s8( struct data *data, int offset, int count, short *dest ) { - int idx, amp, length = data->length; - char *buffer = data->buffer; - if( offset > length ) { - offset = length; - } - if( offset + count > length ) { - count = length - offset; - } - for( idx = 0; idx < count; idx++ ) { - amp = ( buffer[ offset + idx ] & 0xFF ) << 8; - dest[ idx ] = ( amp & 0x7FFF ) - ( amp & 0x8000 ); - } -} - -static void data_sam_s16le( struct data *data, int offset, int count, short *dest ) { - int idx, amp, length = data->length; - char *buffer = data->buffer; - if( offset > length ) { - offset = length; - } - if( offset + count * 2 > length ) { - count = ( length - offset ) / 2; - } - for( idx = 0; idx < count; idx++ ) { - amp = ( buffer[ offset + idx * 2 ] & 0xFF ) | ( buffer[ offset + idx * 2 + 1 ] << 8 ); - dest[ idx ] = ( amp & 0x7FFF ) - ( amp & 0x8000 ); - } -} - -static int envelope_next_tick( struct envelope *envelope, int tick, int key_on ) { - tick++; - if( envelope->looped && tick >= envelope->loop_end_tick ) { - tick = envelope->loop_start_tick; - } - if( envelope->sustain && key_on && tick >= envelope->sustain_tick ) { - tick = envelope->sustain_tick; - } - return tick; -} - -static int envelope_calculate_ampl( struct envelope *envelope, int tick ) { - int idx, point, dt, da; - int ampl = envelope->points_ampl[ envelope->num_points - 1 ]; - if( tick < envelope->points_tick[ envelope->num_points - 1 ] ) { - point = 0; - for( idx = 1; idx < envelope->num_points; idx++ ) { - if( envelope->points_tick[ idx ] <= tick ) { - point = idx; - } - } - dt = envelope->points_tick[ point + 1 ] - envelope->points_tick[ point ]; - da = envelope->points_ampl[ point + 1 ] - envelope->points_ampl[ point ]; - ampl = envelope->points_ampl[ point ]; - ampl += ( ( da << 24 ) / dt ) * ( tick - envelope->points_tick[ point ] ) >> 24; - } - return ampl; -} - -static void sample_ping_pong( struct sample *sample ) { - int idx; - int loop_start = sample->loop_start; - int loop_length = sample->loop_length; - int loop_end = loop_start + loop_length; - short *sample_data = sample->data; - short *new_data = (short*)calloc( loop_end + loop_length + 1, sizeof( short ) ); - if( new_data ) { - memcpy( new_data, sample_data, loop_end * sizeof( short ) ); - for( idx = 0; idx < loop_length; idx++ ) { - new_data[ loop_end + idx ] = sample_data[ loop_end - idx - 1 ]; - } - free( sample->data ); - sample->data = new_data; - sample->loop_length *= 2; - sample->data[ loop_start + sample->loop_length ] = sample->data[ loop_start ]; - } -} - -/* Deallocate the specified module. */ -void dispose_module( struct module *module ) { - int idx, sam; - struct instrument *instrument; - free( module->default_panning ); - free( module->sequence ); - if( module->patterns ) { - for( idx = 0; idx < module->num_patterns; idx++ ) { - free( module->patterns[ idx ].data ); - } - free( module->patterns ); - } - if( module->instruments ) { - for( idx = 0; idx <= module->num_instruments; idx++ ) { - instrument = &module->instruments[ idx ]; - if( instrument->samples ) { - for( sam = 0; sam < instrument->num_samples; sam++ ) { - free( instrument->samples[ sam ].data ); - } - free( instrument->samples ); - } - } - free( module->instruments ); - } - free( module ); -} - -static struct module* module_load_xm( struct data *data, char *message ) { - int delta_env, offset, next_offset, idx, entry; - int num_rows, num_notes, pat_data_len, pat_data_offset; - int sam, sam_head_offset, sam_data_bytes, sam_data_samples; - int num_samples, sam_loop_start, sam_loop_length, amp; - int note, flags, key, ins, vol, fxc, fxp; - int point, point_tick, point_offset; - int looped, ping_pong, sixteen_bit; - char ascii[ 16 ], *pattern_data; - struct instrument *instrument; - struct sample *sample; - struct module *module = (struct module*)calloc( 1, sizeof( struct module ) ); - if( module ) { - if( data_u16le( data, 58 ) != 0x0104 ) { - strcpy( message, "XM format version must be 0x0104!" ); - dispose_module( module ); - return NULL; - } - data_ascii( data, 17, 20, module->name ); - delta_env = !memcmp( data_ascii( data, 38, 15, ascii ), "DigiBooster Pro", 15 ); - offset = 60 + data_u32le( data, 60 ); - module->sequence_len = data_u16le( data, 64 ); - module->restart_pos = data_u16le( data, 66 ); - module->num_channels = data_u16le( data, 68 ); - module->num_patterns = data_u16le( data, 70 ); - module->num_instruments = data_u16le( data, 72 ); - module->linear_periods = data_u16le( data, 74 ) & 0x1; - module->default_gvol = 64; - module->default_speed = data_u16le( data, 76 ); - module->default_tempo = data_u16le( data, 78 ); - module->c2_rate = 8363; - module->gain = 64; - module->default_panning = (unsigned char*)calloc( module->num_channels, sizeof( unsigned char ) ); - if( !module->default_panning ) { - dispose_module( module ); - return NULL; - } - for( idx = 0; idx < module->num_channels; idx++ ) { - module->default_panning[ idx ] = 128; - } - module->sequence = (unsigned char*)calloc( module->sequence_len, sizeof( unsigned char ) ); - if( !module->sequence ) { - dispose_module( module ); - return NULL; - } - for( idx = 0; idx < module->sequence_len; idx++ ) { - entry = data_u8( data, 80 + idx ); - module->sequence[ idx ] = entry < module->num_patterns ? entry : 0; - } - module->patterns = (struct pattern*)calloc( module->num_patterns, sizeof( struct pattern ) ); - if( !module->patterns ) { - dispose_module( module ); - return NULL; - } - for( idx = 0; idx < module->num_patterns; idx++ ) { - if( data_u8( data, offset + 4 ) ) { - strcpy( message, "Unknown pattern packing type!" ); - dispose_module( module ); - return NULL; - } - num_rows = data_u16le( data, offset + 5 ); - if( num_rows < 1 ) { - num_rows = 1; - } - pat_data_len = data_u16le( data, offset + 7 ); - offset += data_u32le( data, offset ); - next_offset = offset + pat_data_len; - num_notes = num_rows * module->num_channels; - pattern_data = (char*)calloc( num_notes, 5 ); - if( !pattern_data ) { - dispose_module( module ); - return NULL; - } - module->patterns[ idx ].num_channels = module->num_channels; - module->patterns[ idx ].num_rows = num_rows; - module->patterns[ idx ].data = pattern_data; - if( pat_data_len > 0 ) { - pat_data_offset = 0; - for( note = 0; note < num_notes; note++ ) { - flags = data_u8( data, offset ); - if( ( flags & 0x80 ) == 0 ) { - flags = 0x1F; - } else { - offset++; - } - key = ( flags & 0x01 ) > 0 ? data_u8( data, offset++ ) : 0; - pattern_data[ pat_data_offset++ ] = key; - ins = ( flags & 0x02 ) > 0 ? data_u8( data, offset++ ) : 0; - pattern_data[ pat_data_offset++ ] = ins; - vol = ( flags & 0x04 ) > 0 ? data_u8( data, offset++ ) : 0; - pattern_data[ pat_data_offset++ ] = vol; - fxc = ( flags & 0x08 ) > 0 ? data_u8( data, offset++ ) : 0; - fxp = ( flags & 0x10 ) > 0 ? data_u8( data, offset++ ) : 0; - if( fxc >= 0x40 ) { - fxc = fxp = 0; - } - pattern_data[ pat_data_offset++ ] = fxc; - pattern_data[ pat_data_offset++ ] = fxp; - } - } - offset = next_offset; - } - module->instruments = (struct instrument*)calloc( module->num_instruments + 1, sizeof( struct instrument ) ); - if( !module->instruments ) { - dispose_module( module ); - return NULL; - } - instrument = &module->instruments[ 0 ]; - instrument->samples = (struct sample*)calloc( 1, sizeof( struct sample ) ); - if( !instrument->samples ) { - dispose_module( module ); - return NULL; - } - for( ins = 1; ins <= module->num_instruments; ins++ ) { - instrument = &module->instruments[ ins ]; - data_ascii( data, offset + 4, 22, instrument->name ); - num_samples = data_u16le( data, offset + 27 ); - instrument->num_samples = ( num_samples > 0 ) ? num_samples : 1; - instrument->samples = (struct sample*)calloc( instrument->num_samples, sizeof( struct sample ) ); - if( !instrument->samples ) { - dispose_module( module ); - return NULL; - } - if( num_samples > 0 ) { - for( key = 0; key < 96; key++ ) { - instrument->key_to_sample[ key + 1 ] = data_u8( data, offset + 33 + key ); - } - point_tick = 0; - for( point = 0; point < 12; point++ ) { - point_offset = offset + 129 + ( point * 4 ); - point_tick = ( delta_env ? point_tick : 0 ) + data_u16le( data, point_offset ); - instrument->vol_env.points_tick[ point ] = point_tick; - instrument->vol_env.points_ampl[ point ] = data_u16le( data, point_offset + 2 ); - } - point_tick = 0; - for( point = 0; point < 12; point++ ) { - point_offset = offset + 177 + ( point * 4 ); - point_tick = ( delta_env ? point_tick : 0 ) + data_u16le( data, point_offset ); - instrument->pan_env.points_tick[ point ] = point_tick; - instrument->pan_env.points_ampl[ point ] = data_u16le( data, point_offset + 2 ); - } - instrument->vol_env.num_points = data_u8( data, offset + 225 ); - if( instrument->vol_env.num_points > 12 ) { - instrument->vol_env.num_points = 0; - } - instrument->pan_env.num_points = data_u8( data, offset + 226 ); - if( instrument->pan_env.num_points > 12 ) { - instrument->pan_env.num_points = 0; - } - instrument->vol_env.sustain_tick = instrument->vol_env.points_tick[ data_u8( data, offset + 227 ) & 0xF ]; - instrument->vol_env.loop_start_tick = instrument->vol_env.points_tick[ data_u8( data, offset + 228 ) & 0xF ]; - instrument->vol_env.loop_end_tick = instrument->vol_env.points_tick[ data_u8( data, offset + 229 ) & 0xF ]; - instrument->pan_env.sustain_tick = instrument->pan_env.points_tick[ data_u8( data, offset + 230 ) & 0xF ]; - instrument->pan_env.loop_start_tick = instrument->pan_env.points_tick[ data_u8( data, offset + 231 ) & 0xF ]; - instrument->pan_env.loop_end_tick = instrument->pan_env.points_tick[ data_u8( data, offset + 232 ) & 0xF ]; - instrument->vol_env.enabled = instrument->vol_env.num_points > 0 && ( data_u8( data, offset + 233 ) & 0x1 ); - instrument->vol_env.sustain = ( data_u8( data, offset + 233 ) & 0x2 ) > 0; - instrument->vol_env.looped = ( data_u8( data, offset + 233 ) & 0x4 ) > 0; - instrument->pan_env.enabled = instrument->pan_env.num_points > 0 && ( data_u8( data, offset + 234 ) & 0x1 ); - instrument->pan_env.sustain = ( data_u8( data, offset + 234 ) & 0x2 ) > 0; - instrument->pan_env.looped = ( data_u8( data, offset + 234 ) & 0x4 ) > 0; - instrument->vib_type = data_u8( data, offset + 235 ); - instrument->vib_sweep = data_u8( data, offset + 236 ); - instrument->vib_depth = data_u8( data, offset + 237 ); - instrument->vib_rate = data_u8( data, offset + 238 ); - instrument->vol_fadeout = data_u16le( data, offset + 239 ); - } - offset += data_u32le( data, offset ); - sam_head_offset = offset; - offset += num_samples * 40; - for( sam = 0; sam < num_samples; sam++ ) { - sample = &instrument->samples[ sam ]; - sam_data_bytes = data_u32le( data, sam_head_offset ); - sam_loop_start = data_u32le( data, sam_head_offset + 4 ); - sam_loop_length = data_u32le( data, sam_head_offset + 8 ); - sample->volume = data_u8( data, sam_head_offset + 12 ); - sample->fine_tune = data_s8( data, sam_head_offset + 13 ); - looped = ( data_u8( data, sam_head_offset + 14 ) & 0x3 ) > 0; - ping_pong = ( data_u8( data, sam_head_offset + 14 ) & 0x2 ) > 0; - sixteen_bit = ( data_u8( data, sam_head_offset + 14 ) & 0x10 ) > 0; - sample->panning = data_u8( data, sam_head_offset + 15 ) + 1; - sample->rel_note = data_s8( data, sam_head_offset + 16 ); - data_ascii( data, sam_head_offset + 18, 22, sample->name ); - sam_head_offset += 40; - sam_data_samples = sam_data_bytes; - if( sixteen_bit ) { - sam_data_samples = sam_data_samples >> 1; - sam_loop_start = sam_loop_start >> 1; - sam_loop_length = sam_loop_length >> 1; - } - if( !looped || ( sam_loop_start + sam_loop_length ) > sam_data_samples ) { - sam_loop_start = sam_data_samples; - sam_loop_length = 0; - } - sample->loop_start = sam_loop_start; - sample->loop_length = sam_loop_length; - sample->data = (short*)calloc( sam_data_samples + 1, sizeof( short ) ); - if( sample->data ) { - if( sixteen_bit ) { - data_sam_s16le( data, offset, sam_data_samples, sample->data ); - } else { - data_sam_s8( data, offset, sam_data_samples, sample->data ); - } - amp = 0; - for( idx = 0; idx < sam_data_samples; idx++ ) { - amp = amp + sample->data[ idx ]; - amp = ( amp & 0x7FFF ) - ( amp & 0x8000 ); - sample->data[ idx ] = amp; - } - sample->data[ sam_loop_start + sam_loop_length ] = sample->data[ sam_loop_start ]; - if( ping_pong ) { - sample_ping_pong( sample ); - } - } else { - dispose_module( module ); - return NULL; - } - offset += sam_data_bytes; - } - } - } - return module; -} - -static struct module* module_load_s3m( struct data *data, char *message ) { - int idx, module_data_idx, inst_offset, flags; - int version, sixteen_bit, tune, signed_samples; - int stereo_mode, default_pan, channel_map[ 32 ]; - int sample_offset, sample_length, loop_start, loop_length; - int pat_offset, note_offset, row, chan, token; - int key, ins, volume, effect, param, panning; - char *pattern_data; - struct instrument *instrument; - struct sample *sample; - struct module *module = (struct module*)calloc( 1, sizeof( struct module ) ); - if( module ) { - data_ascii( data, 0, 28, module->name ); - module->sequence_len = data_u16le( data, 32 ); - module->num_instruments = data_u16le( data, 34 ); - module->num_patterns = data_u16le( data, 36 ); - flags = data_u16le( data, 38 ); - version = data_u16le( data, 40 ); - module->fast_vol_slides = ( ( flags & 0x40 ) == 0x40 ) || version == 0x1300; - signed_samples = data_u16le( data, 42 ) == 1; - if( data_u32le( data, 44 ) != 0x4d524353 ) { - strcpy( message, "Not an S3M file!" ); - dispose_module( module ); - return NULL; - } - module->default_gvol = data_u8( data, 48 ); - module->default_speed = data_u8( data, 49 ); - module->default_tempo = data_u8( data, 50 ); - module->c2_rate = 8363; - module->gain = data_u8( data, 51 ) & 0x7F; - stereo_mode = ( data_u8( data, 51 ) & 0x80 ) == 0x80; - default_pan = data_u8( data, 53 ) == 0xFC; - for( idx = 0; idx < 32; idx++ ) { - channel_map[ idx ] = -1; - if( data_u8( data, 64 + idx ) < 16 ) { - channel_map[ idx ] = module->num_channels++; - } - } - module->sequence = (unsigned char*)calloc( module->sequence_len, sizeof( unsigned char ) ); - if( !module->sequence ){ - dispose_module( module ); - return NULL; - } - for( idx = 0; idx < module->sequence_len; idx++ ) { - module->sequence[ idx ] = data_u8( data, 96 + idx ); - } - module_data_idx = 96 + module->sequence_len; - module->instruments = (struct instrument*)calloc( module->num_instruments + 1, sizeof( struct instrument ) ); - if( !module->instruments ) { - dispose_module( module ); - return NULL; - } - instrument = &module->instruments[ 0 ]; - instrument->num_samples = 1; - instrument->samples = (struct sample*)calloc( 1, sizeof( struct sample ) ); - if( !instrument->samples ) { - dispose_module( module ); - return NULL; - } - for( ins = 1; ins <= module->num_instruments; ins++ ) { - instrument = &module->instruments[ ins ]; - instrument->num_samples = 1; - instrument->samples = (struct sample*)calloc( 1, sizeof( struct sample ) ); - if( !instrument->samples ) { - dispose_module( module ); - return NULL; - } - sample = &instrument->samples[ 0 ]; - inst_offset = data_u16le( data, module_data_idx ) << 4; - module_data_idx += 2; - data_ascii( data, inst_offset + 48, 28, instrument->name ); - if( data_u8( data, inst_offset ) == 1 && data_u16le( data, inst_offset + 76 ) == 0x4353 ) { - sample_offset = ( data_u8( data, inst_offset + 13 ) << 20 ) - + ( data_u16le( data, inst_offset + 14 ) << 4 ); - sample_length = data_u32le( data, inst_offset + 16 ); - loop_start = data_u32le( data, inst_offset + 20 ); - loop_length = data_u32le( data, inst_offset + 24 ) - loop_start; - sample->volume = data_u8( data, inst_offset + 28 ); - if( data_u8( data, inst_offset + 30 ) != 0 ) { - strcpy( message, "Packed samples not supported!" ); - dispose_module( module ); - return NULL; - } - if( loop_start + loop_length > sample_length ) { - loop_length = sample_length - loop_start; - } - if( loop_length < 1 || !( data_u8( data, inst_offset + 31 ) & 0x1 ) ) { - loop_start = sample_length; - loop_length = 0; - } - sample->loop_start = loop_start; - sample->loop_length = loop_length; - /* stereo = data_u8( data, inst_offset + 31 ) & 0x2; */ - sixteen_bit = data_u8( data, inst_offset + 31 ) & 0x4; - tune = ( log_2( data_u32le( data, inst_offset + 32 ) ) - log_2( module->c2_rate ) ) * 12; - sample->rel_note = tune >> FP_SHIFT; - sample->fine_tune = ( tune & FP_MASK ) >> ( FP_SHIFT - 7 ); - sample->data = (short*)calloc( sample_length + 1, sizeof( short ) ); - if( sample->data ) { - if( sixteen_bit ) { - data_sam_s16le( data, sample_offset, sample_length, sample->data ); - } else { - data_sam_s8( data, sample_offset, sample_length, sample->data ); - } - if( !signed_samples ) { - for( idx = 0; idx < sample_length; idx++ ) { - sample->data[ idx ] = ( sample->data[ idx ] & 0xFFFF ) - 32768; - } - } - sample->data[ loop_start + loop_length ] = sample->data[ loop_start ]; - } else { - dispose_module( module ); - return NULL; - } - } - } - module->patterns = (struct pattern*)calloc( module->num_patterns, sizeof( struct pattern ) ); - if( !module->patterns ) { - dispose_module( module ); - return NULL; - } - for( idx = 0; idx < module->num_patterns; idx++ ) { - module->patterns[ idx ].num_channels = module->num_channels; - module->patterns[ idx ].num_rows = 64; - pattern_data = (char*)calloc( module->num_channels * 64, 5 ); - if( !pattern_data ) { - dispose_module( module ); - return NULL; - } - module->patterns[ idx ].data = pattern_data; - pat_offset = ( data_u16le( data, module_data_idx ) << 4 ) + 2; - row = 0; - while( row < 64 ) { - token = data_u8( data, pat_offset++ ); - if( token ) { - key = ins = 0; - if( ( token & 0x20 ) == 0x20 ) { - /* Key + Instrument.*/ - key = data_u8( data, pat_offset++ ); - ins = data_u8( data, pat_offset++ ); - if( key < 0xFE ) { - key = ( key >> 4 ) * 12 + ( key & 0xF ) + 1; - } else if( key == 0xFF ) { - key = 0; - } - } - volume = 0; - if( ( token & 0x40 ) == 0x40 ) { - /* Volume Column.*/ - volume = ( data_u8( data, pat_offset++ ) & 0x7F ) + 0x10; - if( volume > 0x50 ) { - volume = 0; - } - } - effect = param = 0; - if( ( token & 0x80 ) == 0x80 ) { - /* Effect + Param.*/ - effect = data_u8( data, pat_offset++ ); - param = data_u8( data, pat_offset++ ); - if( effect < 1 || effect >= 0x40 ) { - effect = param = 0; - } else if( effect > 0 ) { - effect += 0x80; - } - } - chan = channel_map[ token & 0x1F ]; - if( chan >= 0 ) { - note_offset = ( row * module->num_channels + chan ) * 5; - pattern_data[ note_offset ] = key; - pattern_data[ note_offset + 1 ] = ins; - pattern_data[ note_offset + 2 ] = volume; - pattern_data[ note_offset + 3 ] = effect; - pattern_data[ note_offset + 4 ] = param; - } - } else { - row++; - } - } - module_data_idx += 2; - } - module->default_panning = (unsigned char*)calloc( module->num_channels, sizeof( unsigned char ) ); - if( module->default_panning ) { - for( chan = 0; chan < 32; chan++ ) { - if( channel_map[ chan ] >= 0 ) { - panning = 7; - if( stereo_mode ) { - panning = 12; - if( data_u8( data, 64 + chan ) < 8 ) { - panning = 3; - } - } - if( default_pan ) { - flags = data_u8( data, module_data_idx + chan ); - if( ( flags & 0x20 ) == 0x20 ) { - panning = flags & 0xF; - } - } - module->default_panning[ channel_map[ chan ] ] = panning * 17; - } - } - } else { - dispose_module( module ); - return NULL; - } - } - return module; -} - -static struct module* module_load_mod( struct data *data, char *message ) { - int idx, pat, module_data_idx, pat_data_len, pat_data_idx; - int period, key, ins, effect, param, fine_tune; - int sample_length, loop_start, loop_length; - char *pattern_data; - struct instrument *instrument; - struct sample *sample; - struct module *module = (struct module*)calloc( 1, sizeof( struct module ) ); - if( module ) { - data_ascii( data, 0, 20, module->name ); - module->sequence_len = data_u8( data, 950 ) & 0x7F; - module->restart_pos = data_u8( data, 951 ) & 0x7F; - if( module->restart_pos >= module->sequence_len ) { - module->restart_pos = 0; - } - module->sequence = (unsigned char*)calloc( 128, sizeof( unsigned char ) ); - if( !module->sequence ){ - dispose_module( module ); - return NULL; - } - for( idx = 0; idx < 128; idx++ ) { - pat = data_u8( data, 952 + idx ) & 0x7F; - module->sequence[ idx ] = pat; - if( pat >= module->num_patterns ) { - module->num_patterns = pat + 1; - } - } - switch( data_u16be( data, 1082 ) ) { - case 0x4b2e: /* M.K. */ - case 0x4b21: /* M!K! */ - case 0x5434: /* FLT4 */ - module->num_channels = 4; - module->c2_rate = 8287; - module->gain = 64; - break; - case 0x484e: /* xCHN */ - module->num_channels = data_u8( data, 1080 ) - 48; - module->c2_rate = 8363; - module->gain = 32; - break; - case 0x4348: /* xxCH */ - module->num_channels = ( data_u8( data, 1080 ) - 48 ) * 10; - module->num_channels += data_u8( data, 1081 ) - 48; - module->c2_rate = 8363; - module->gain = 32; - break; - default: - strcpy( message, "MOD Format not recognised!" ); - dispose_module( module ); - return NULL; - } - module->default_gvol = 64; - module->default_speed = 6; - module->default_tempo = 125; - module->default_panning = (unsigned char*)calloc( module->num_channels, sizeof( unsigned char ) ); - if( !module->default_panning ) { - dispose_module( module ); - return NULL; - } - for( idx = 0; idx < module->num_channels; idx++ ) { - module->default_panning[ idx ] = 51; - if( ( idx & 3 ) == 1 || ( idx & 3 ) == 2 ) { - module->default_panning[ idx ] = 204; - } - } - module_data_idx = 1084; - module->patterns = (struct pattern*)calloc( module->num_patterns, sizeof( struct pattern ) ); - if( !module->patterns ) { - dispose_module( module ); - return NULL; - } - pat_data_len = module->num_channels * 64 * 5; - for( pat = 0; pat < module->num_patterns; pat++ ) { - module->patterns[ pat ].num_channels = module->num_channels; - module->patterns[ pat ].num_rows = 64; - pattern_data = (char*)calloc( 1, pat_data_len ); - if( !pattern_data ) { - dispose_module( module ); - return NULL; - } - module->patterns[ pat ].data = pattern_data; - for( pat_data_idx = 0; pat_data_idx < pat_data_len; pat_data_idx += 5 ) { - period = ( data_u8( data, module_data_idx ) & 0xF ) << 8; - period = ( period | data_u8( data, module_data_idx + 1 ) ) * 4; - if( period >= 112 && period <= 6848 ) { - key = -12 * log_2( ( period << FP_SHIFT ) / 29021 ); - key = ( key + ( key & ( FP_ONE >> 1 ) ) ) >> FP_SHIFT; - pattern_data[ pat_data_idx ] = key; - } - ins = ( data_u8( data, module_data_idx + 2 ) & 0xF0 ) >> 4; - ins = ins | ( data_u8( data, module_data_idx ) & 0x10 ); - pattern_data[ pat_data_idx + 1 ] = ins; - effect = data_u8( data, module_data_idx + 2 ) & 0x0F; - param = data_u8( data, module_data_idx + 3 ); - if( param == 0 && ( effect < 3 || effect == 0xA ) ) { - effect = 0; - } - if( param == 0 && ( effect == 5 || effect == 6 ) ) { - effect -= 2; - } - if( effect == 8 && module->num_channels == 4 ) { - effect = param = 0; - } - pattern_data[ pat_data_idx + 3 ] = effect; - pattern_data[ pat_data_idx + 4 ] = param; - module_data_idx += 4; - } - } - module->num_instruments = 31; - module->instruments = (struct instrument*)calloc( module->num_instruments + 1, sizeof( struct instrument ) ); - if( !module->instruments ) { - dispose_module( module ); - return NULL; - } - instrument = &module->instruments[ 0 ]; - instrument->num_samples = 1; - instrument->samples = (struct sample*)calloc( 1, sizeof( struct sample ) ); - if( !instrument->samples ) { - dispose_module( module ); - return NULL; - } - for( ins = 1; ins <= module->num_instruments; ins++ ) { - instrument = &module->instruments[ ins ]; - instrument->num_samples = 1; - instrument->samples = (struct sample*)calloc( 1, sizeof( struct sample ) ); - if( !instrument->samples ) { - dispose_module( module ); - return NULL; - } - sample = &instrument->samples[ 0 ]; - data_ascii( data, ins * 30 - 10, 22, instrument->name ); - sample_length = data_u16be( data, ins * 30 + 12 ) * 2; - fine_tune = ( data_u8( data, ins * 30 + 14 ) & 0xF ) << 4; - sample->fine_tune = ( fine_tune & 0x7F ) - ( fine_tune & 0x80 ); - sample->volume = data_u8( data, ins * 30 + 15 ) & 0x7F; - if( sample->volume > 64 ) { - sample->volume = 64; - } - loop_start = data_u16be( data, ins * 30 + 16 ) * 2; - loop_length = data_u16be( data, ins * 30 + 18 ) * 2; - if( loop_start + loop_length > sample_length ) { - loop_length = sample_length - loop_start; - } - if( loop_length < 4 ) { - loop_start = sample_length; - loop_length = 0; - } - sample->loop_start = loop_start; - sample->loop_length = loop_length; - sample->data = (short*)calloc( sample_length + 1, sizeof( short ) ); - if( sample->data ) { - data_sam_s8( data, module_data_idx, sample_length, sample->data ); - sample->data[ loop_start + loop_length ] = sample->data[ loop_start ]; - } else { - dispose_module( module ); - return NULL; - } - module_data_idx += sample_length; - } - } - return module; -} - -/* Allocate and initialize a module from the specified data, returns NULL on error. - Message should point to a 64-character buffer to receive error messages. */ -struct module* module_load( struct data *data, char *message ) { - char ascii[ 16 ]; - struct module* module; - if( !memcmp( data_ascii( data, 0, 16, ascii ), "Extended Module:", 16 ) ) { - module = module_load_xm( data, message ); - } else if( !memcmp( data_ascii( data, 44, 4, ascii ), "SCRM", 4 ) ) { - module = module_load_s3m( data, message ); - } else { - module = module_load_mod( data, message ); - } - return module; -} - -static void pattern_get_note( struct pattern *pattern, int row, int chan, struct note *dest ) { - int offset = ( row * pattern->num_channels + chan ) * 5; - if( offset >= 0 && row < pattern->num_rows && chan < pattern->num_channels ) { - dest->key = pattern->data[ offset ]; - dest->instrument = pattern->data[ offset + 1 ]; - dest->volume = pattern->data[ offset + 2 ]; - dest->effect = pattern->data[ offset + 3 ]; - dest->param = pattern->data[ offset + 4 ]; - } else { - memset( dest, 0, sizeof( struct note ) ); - } -} - -static void channel_init( struct channel *channel, struct replay *replay, int idx ) { - memset( channel, 0, sizeof( struct channel ) ); - channel->replay = replay; - channel->id = idx; - channel->panning = replay->module->default_panning[ idx ]; - channel->instrument = &replay->module->instruments[ 0 ]; - channel->sample = &channel->instrument->samples[ 0 ]; - channel->random_seed = ( idx + 1 ) * 0xABCDEF; -} - -static void channel_volume_slide( struct channel *channel ) { - int up = channel->vol_slide_param >> 4; - int down = channel->vol_slide_param & 0xF; - if( down == 0xF && up > 0 ) { - /* Fine slide up.*/ - if( channel->fx_count == 0 ) { - channel->volume += up; - } - } else if( up == 0xF && down > 0 ) { - /* Fine slide down.*/ - if( channel->fx_count == 0 ) { - channel->volume -= down; - } - } else if( channel->fx_count > 0 || channel->replay->module->fast_vol_slides ) { - /* Normal.*/ - channel->volume += up - down; - } - if( channel->volume > 64 ) { - channel->volume = 64; - } - if( channel->volume < 0 ) { - channel->volume = 0; - } -} - -static void channel_porta_up( struct channel *channel, int param ) { - switch( param & 0xF0 ) { - case 0xE0: /* Extra-fine porta.*/ - if( channel->fx_count == 0 ) { - channel->period -= param & 0xF; - } - break; - case 0xF0: /* Fine porta.*/ - if( channel->fx_count == 0 ) { - channel->period -= ( param & 0xF ) << 2; - } - break; - default:/* Normal porta.*/ - if( channel->fx_count > 0 ) { - channel->period -= param << 2; - } - break; - } - if( channel->period < 0 ) { - channel->period = 0; - } -} - -static void channel_porta_down( struct channel *channel, int param ) { - if( channel->period > 0 ) { - switch( param & 0xF0 ) { - case 0xE0: /* Extra-fine porta.*/ - if( channel->fx_count == 0 ) { - channel->period += param & 0xF; - } - break; - case 0xF0: /* Fine porta.*/ - if( channel->fx_count == 0 ) { - channel->period += ( param & 0xF ) << 2; - } - break; - default:/* Normal porta.*/ - if( channel->fx_count > 0 ) { - channel->period += param << 2; - } - break; - } - if( channel->period > 65535 ) { - channel->period = 65535; - } - } -} - -static void channel_tone_porta( struct channel *channel ) { - if( channel->period > 0 ) { - if( channel->period < channel->porta_period ) { - channel->period += channel->tone_porta_param << 2; - if( channel->period > channel->porta_period ) { - channel->period = channel->porta_period; - } - } else { - channel->period -= channel->tone_porta_param << 2; - if( channel->period < channel->porta_period ) { - channel->period = channel->porta_period; - } - } - } -} - -static int channel_waveform( struct channel *channel, int phase, int type ) { - int amplitude = 0; - switch( type ) { - default: /* Sine. */ - amplitude = sine_table[ phase & 0x1F ]; - if( ( phase & 0x20 ) > 0 ) { - amplitude = -amplitude; - } - break; - case 6: /* Saw Up.*/ - amplitude = ( ( ( phase + 0x20 ) & 0x3F ) << 3 ) - 255; - break; - case 1: case 7: /* Saw Down. */ - amplitude = 255 - ( ( ( phase + 0x20 ) & 0x3F ) << 3 ); - break; - case 2: case 5: /* Square. */ - amplitude = ( phase & 0x20 ) > 0 ? 255 : -255; - break; - case 3: case 8: /* Random. */ - amplitude = ( channel->random_seed >> 20 ) - 255; - channel->random_seed = ( channel->random_seed * 65 + 17 ) & 0x1FFFFFFF; - break; - } - return amplitude; -} - -static void channel_vibrato( struct channel *channel, int fine ) { - int wave = channel_waveform( channel, channel->vibrato_phase, channel->vibrato_type & 0x3 ); - channel->vibrato_add = wave * channel->vibrato_depth >> ( fine ? 7 : 5 ); -} - -static void channel_tremolo( struct channel *channel ) { - int wave = channel_waveform( channel, channel->tremolo_phase, channel->tremolo_type & 0x3 ); - channel->tremolo_add = wave * channel->tremolo_depth >> 6; -} - -static void channel_tremor( struct channel *channel ) { - if( channel->retrig_count >= channel->tremor_on_ticks ) { - channel->tremolo_add = -64; - } - if( channel->retrig_count >= ( channel->tremor_on_ticks + channel->tremor_off_ticks ) ) { - channel->tremolo_add = channel->retrig_count = 0; - } -} - -static void channel_retrig_vol_slide( struct channel *channel ) { - if( channel->retrig_count >= channel->retrig_ticks ) { - channel->retrig_count = channel->sample_idx = channel->sample_fra = 0; - switch( channel->retrig_volume ) { - case 0x1: channel->volume = channel->volume - 1; break; - case 0x2: channel->volume = channel->volume - 2; break; - case 0x3: channel->volume = channel->volume - 4; break; - case 0x4: channel->volume = channel->volume - 8; break; - case 0x5: channel->volume = channel->volume - 16; break; - case 0x6: channel->volume = channel->volume * 2 / 3; break; - case 0x7: channel->volume = channel->volume >> 1; break; - case 0x8: /* ? */ break; - case 0x9: channel->volume = channel->volume + 1; break; - case 0xA: channel->volume = channel->volume + 2; break; - case 0xB: channel->volume = channel->volume + 4; break; - case 0xC: channel->volume = channel->volume + 8; break; - case 0xD: channel->volume = channel->volume + 16; break; - case 0xE: channel->volume = channel->volume * 3 / 2; break; - case 0xF: channel->volume = channel->volume << 1; break; - } - if( channel->volume < 0 ) { - channel->volume = 0; - } - if( channel->volume > 64 ) { - channel->volume = 64; - } - } -} - -static void channel_trigger( struct channel *channel ) { - int key, sam, porta, period, fine_tune, ins = channel->note.instrument; - struct sample *sample; - if( ins > 0 && ins <= channel->replay->module->num_instruments ) { - channel->instrument = &channel->replay->module->instruments[ ins ]; - key = channel->note.key < 97 ? channel->note.key : 0; - sam = channel->instrument->key_to_sample[ key ]; - sample = &channel->instrument->samples[ sam ]; - channel->volume = sample->volume >= 64 ? 64 : sample->volume & 0x3F; - if( sample->panning > 0 ) { - channel->panning = ( sample->panning - 1 ) & 0xFF; - } - if( channel->period > 0 && sample->loop_length > 1 ) { - /* Amiga trigger.*/ - channel->sample = sample; - } - channel->sample_off = 0; - channel->vol_env_tick = channel->pan_env_tick = 0; - channel->fadeout_vol = 32768; - channel->key_on = 1; - } - if( channel->note.effect == 0x09 || channel->note.effect == 0x8F ) { - /* Set Sample Offset. */ - if( channel->note.param > 0 ) { - channel->offset_param = channel->note.param; - } - channel->sample_off = channel->offset_param << 8; - } - if( channel->note.volume >= 0x10 && channel->note.volume < 0x60 ) { - channel->volume = channel->note.volume < 0x50 ? channel->note.volume - 0x10 : 64; - } - switch( channel->note.volume & 0xF0 ) { - case 0x80: /* Fine Vol Down.*/ - channel->volume -= channel->note.volume & 0xF; - if( channel->volume < 0 ) { - channel->volume = 0; - } - break; - case 0x90: /* Fine Vol Up.*/ - channel->volume += channel->note.volume & 0xF; - if( channel->volume > 64 ) { - channel->volume = 64; - } - break; - case 0xA0: /* Set Vibrato Speed.*/ - if( ( channel->note.volume & 0xF ) > 0 ) { - channel->vibrato_speed = channel->note.volume & 0xF; - } - break; - case 0xB0: /* Vibrato.*/ - if( ( channel->note.volume & 0xF ) > 0 ) { - channel->vibrato_depth = channel->note.volume & 0xF; - } - channel_vibrato( channel, 0 ); - break; - case 0xC0: /* Set Panning.*/ - channel->panning = ( channel->note.volume & 0xF ) * 17; - break; - case 0xF0: /* Tone Porta.*/ - if( ( channel->note.volume & 0xF ) > 0 ) { - channel->tone_porta_param = channel->note.volume & 0xF; - } - break; - } - if( channel->note.key > 0 ) { - if( channel->note.key > 96 ) { - channel->key_on = 0; - } else { - porta = ( channel->note.volume & 0xF0 ) == 0xF0 || - channel->note.effect == 0x03 || channel->note.effect == 0x05 || - channel->note.effect == 0x87 || channel->note.effect == 0x8C; - if( !porta ) { - ins = channel->instrument->key_to_sample[ channel->note.key ]; - channel->sample = &channel->instrument->samples[ ins ]; - } - fine_tune = channel->sample->fine_tune; - if( channel->note.effect == 0x75 || channel->note.effect == 0xF2 ) { - /* Set Fine Tune. */ - fine_tune = ( ( channel->note.param & 0xF ) << 4 ) - 128; - } - key = channel->note.key + channel->sample->rel_note; - if( key < 1 ) { - key = 1; - } - if( key > 120 ) { - key = 120; - } - period = ( key << 6 ) + ( fine_tune >> 1 ); - if( channel->replay->module->linear_periods ) { - channel->porta_period = 7744 - period; - } else { - channel->porta_period = 29021 * exp_2( ( period << FP_SHIFT ) / -768 ) >> FP_SHIFT; - } - if( !porta ) { - channel->period = channel->porta_period; - channel->sample_idx = channel->sample_off; - channel->sample_fra = 0; - if( channel->vibrato_type < 4 ) { - channel->vibrato_phase = 0; - } - if( channel->tremolo_type < 4 ) { - channel->tremolo_phase = 0; - } - channel->retrig_count = channel->av_count = 0; - } - } - } -} - -static void channel_update_envelopes( struct channel *channel ) { - if( channel->instrument->vol_env.enabled ) { - if( !channel->key_on ) { - channel->fadeout_vol -= channel->instrument->vol_fadeout; - if( channel->fadeout_vol < 0 ) { - channel->fadeout_vol = 0; - } - } - channel->vol_env_tick = envelope_next_tick( &channel->instrument->vol_env, - channel->vol_env_tick, channel->key_on ); - } - if( channel->instrument->pan_env.enabled ) { - channel->pan_env_tick = envelope_next_tick( &channel->instrument->pan_env, - channel->pan_env_tick, channel->key_on ); - } -} - -static void channel_auto_vibrato( struct channel *channel ) { - int sweep, rate, type, wave; - int depth = channel->instrument->vib_depth & 0x7F; - if( depth > 0 ) { - sweep = channel->instrument->vib_sweep & 0x7F; - rate = channel->instrument->vib_rate & 0x7F; - type = channel->instrument->vib_type; - if( channel->av_count < sweep ) { - depth = depth * channel->av_count / sweep; - } - wave = channel_waveform( channel, channel->av_count * rate >> 2, type + 4 ); - channel->vibrato_add += wave * depth >> 8; - channel->av_count++; - } -} - -static void channel_calculate_freq( struct channel *channel ) { - int per = channel->period + channel->vibrato_add; - if( channel->replay->module->linear_periods ) { - per = per - ( channel->arpeggio_add << 6 ); - if( per < 28 || per > 7680 ) { - per = 7680; - } - channel->freq = ( ( channel->replay->module->c2_rate >> 4 ) - * exp_2( ( ( 4608 - per ) << FP_SHIFT ) / 768 ) ) >> ( FP_SHIFT - 4 ); - } else { - if( per > 29021 ) { - per = 29021; - } - per = ( per << FP_SHIFT ) / exp_2( ( channel->arpeggio_add << FP_SHIFT ) / 12 ); - if( per < 28 ) { - per = 29021; - } - channel->freq = channel->replay->module->c2_rate * 1712 / per; - } -} - -static void channel_calculate_ampl( struct channel *channel ) { - int vol, range, env_pan = 32, env_vol = channel->key_on ? 64 : 0; - if( channel->instrument->vol_env.enabled ) { - env_vol = envelope_calculate_ampl( &channel->instrument->vol_env, channel->vol_env_tick ); - } - vol = channel->volume + channel->tremolo_add; - if( vol > 64 ) { - vol = 64; - } - if( vol < 0 ) { - vol = 0; - } - vol = ( vol * channel->replay->module->gain * FP_ONE ) >> 13; - vol = ( vol * channel->fadeout_vol ) >> 15; - channel->ampl = ( vol * channel->replay->global_vol * env_vol ) >> 12; - if( channel->instrument->pan_env.enabled ) { - env_pan = envelope_calculate_ampl( &channel->instrument->pan_env, channel->pan_env_tick ); - } - range = ( channel->panning < 128 ) ? channel->panning : ( 255 - channel->panning ); - channel->pann = channel->panning + ( range * ( env_pan - 32 ) >> 5 ); -} - -static void channel_tick( struct channel *channel ) { - channel->vibrato_add = 0; - channel->fx_count++; - channel->retrig_count++; - if( !( channel->note.effect == 0x7D && channel->fx_count <= channel->note.param ) ) { - switch( channel->note.volume & 0xF0 ) { - case 0x60: /* Vol Slide Down.*/ - channel->volume -= channel->note.volume & 0xF; - if( channel->volume < 0 ) { - channel->volume = 0; - } - break; - case 0x70: /* Vol Slide Up.*/ - channel->volume += channel->note.volume & 0xF; - if( channel->volume > 64 ) { - channel->volume = 64; - } - break; - case 0xB0: /* Vibrato.*/ - channel->vibrato_phase += channel->vibrato_speed; - channel_vibrato( channel, 0 ); - break; - case 0xD0: /* Pan Slide Left.*/ - channel->panning -= channel->note.volume & 0xF; - if( channel->panning < 0 ) { - channel->panning = 0; - } - break; - case 0xE0: /* Pan Slide Right.*/ - channel->panning += channel->note.volume & 0xF; - if( channel->panning > 255 ) { - channel->panning = 255; - } - break; - case 0xF0: /* Tone Porta.*/ - channel_tone_porta( channel ); - break; - } - } - switch( channel->note.effect ) { - case 0x01: case 0x86: /* Porta Up. */ - channel_porta_up( channel, channel->porta_up_param ); - break; - case 0x02: case 0x85: /* Porta Down. */ - channel_porta_down( channel, channel->porta_down_param ); - break; - case 0x03: case 0x87: /* Tone Porta. */ - channel_tone_porta( channel ); - break; - case 0x04: case 0x88: /* Vibrato. */ - channel->vibrato_phase += channel->vibrato_speed; - channel_vibrato( channel, 0 ); - break; - case 0x05: case 0x8C: /* Tone Porta + Vol Slide. */ - channel_tone_porta( channel ); - channel_volume_slide( channel ); - break; - case 0x06: case 0x8B: /* Vibrato + Vol Slide. */ - channel->vibrato_phase += channel->vibrato_speed; - channel_vibrato( channel, 0 ); - channel_volume_slide( channel ); - break; - case 0x07: case 0x92: /* Tremolo. */ - channel->tremolo_phase += channel->tremolo_speed; - channel_tremolo( channel ); - break; - case 0x0A: case 0x84: /* Vol Slide. */ - channel_volume_slide( channel ); - break; - case 0x11: /* Global Volume Slide. */ - channel->replay->global_vol = channel->replay->global_vol - + ( channel->gvol_slide_param >> 4 ) - - ( channel->gvol_slide_param & 0xF ); - if( channel->replay->global_vol < 0 ) { - channel->replay->global_vol = 0; - } - if( channel->replay->global_vol > 64 ) { - channel->replay->global_vol = 64; - } - break; - case 0x19: /* Panning Slide. */ - channel->panning = channel->panning - + ( channel->pan_slide_param >> 4 ) - - ( channel->pan_slide_param & 0xF ); - if( channel->panning < 0 ) { - channel->panning = 0; - } - if( channel->panning > 255 ) { - channel->panning = 255; - } - break; - case 0x1B: case 0x91: /* Retrig + Vol Slide. */ - channel_retrig_vol_slide( channel ); - break; - case 0x1D: case 0x89: /* Tremor. */ - channel_tremor( channel ); - break; - case 0x79: /* Retrig. */ - if( channel->fx_count >= channel->note.param ) { - channel->fx_count = 0; - channel->sample_idx = channel->sample_fra = 0; - } - break; - case 0x7C: case 0xFC: /* Note Cut. */ - if( channel->note.param == channel->fx_count ) { - channel->volume = 0; - } - break; - case 0x7D: case 0xFD: /* Note Delay. */ - if( channel->note.param == channel->fx_count ) { - channel_trigger( channel ); - } - break; - case 0x8A: /* Arpeggio. */ - if( channel->fx_count == 1 ) { - channel->arpeggio_add = channel->arpeggio_param >> 4; - } else if( channel->fx_count == 2 ) { - channel->arpeggio_add = channel->arpeggio_param & 0xF; - } else { - channel->arpeggio_add = channel->fx_count = 0; - } - break; - case 0x95: /* Fine Vibrato. */ - channel->vibrato_phase += channel->vibrato_speed; - channel_vibrato( channel, 1 ); - break; - } - channel_auto_vibrato( channel ); - channel_calculate_freq( channel ); - channel_calculate_ampl( channel ); - channel_update_envelopes( channel ); -} - -static void channel_row( struct channel *channel, struct note *note ) { - channel->note = *note; - channel->retrig_count++; - channel->vibrato_add = channel->tremolo_add = channel->arpeggio_add = channel->fx_count = 0; - if( !( ( note->effect == 0x7D || note->effect == 0xFD ) && note->param > 0 ) ) { - /* Not note delay.*/ - channel_trigger( channel ); - } - switch( channel->note.effect ) { - case 0x01: case 0x86: /* Porta Up. */ - if( channel->note.param > 0 ) { - channel->porta_up_param = channel->note.param; - } - channel_porta_up( channel, channel->porta_up_param ); - break; - case 0x02: case 0x85: /* Porta Down. */ - if( channel->note.param > 0 ) { - channel->porta_down_param = channel->note.param; - } - channel_porta_down( channel, channel->porta_down_param ); - break; - case 0x03: case 0x87: /* Tone Porta. */ - if( channel->note.param > 0 ) { - channel->tone_porta_param = channel->note.param; - } - break; - case 0x04: case 0x88: /* Vibrato. */ - if( ( channel->note.param >> 4 ) > 0 ) { - channel->vibrato_speed = channel->note.param >> 4; - } - if( ( channel->note.param & 0xF ) > 0 ) { - channel->vibrato_depth = channel->note.param & 0xF; - } - channel_vibrato( channel, 0 ); - break; - case 0x05: case 0x8C: /* Tone Porta + Vol Slide. */ - if( channel->note.param > 0 ) { - channel->vol_slide_param = channel->note.param; - } - channel_volume_slide( channel ); - break; - case 0x06: case 0x8B: /* Vibrato + Vol Slide. */ - if( channel->note.param > 0 ) { - channel->vol_slide_param = channel->note.param; - } - channel_vibrato( channel, 0 ); - channel_volume_slide( channel ); - break; - case 0x07: case 0x92: /* Tremolo. */ - if( ( channel->note.param >> 4 ) > 0 ) { - channel->tremolo_speed = channel->note.param >> 4; - } - if( ( channel->note.param & 0xF ) > 0 ) { - channel->tremolo_depth = channel->note.param & 0xF; - } - channel_tremolo( channel ); - break; - case 0x08: /* Set Panning.*/ - channel->panning = ( channel->note.param < 128 ) ? ( channel->note.param << 1 ) : 255; - break; - case 0x0A: case 0x84: /* Vol Slide. */ - if( channel->note.param > 0 ) { - channel->vol_slide_param = channel->note.param; - } - channel_volume_slide( channel ); - break; - case 0x0C: /* Set Volume. */ - channel->volume = channel->note.param >= 64 ? 64 : channel->note.param & 0x3F; - break; - case 0x10: case 0x96: /* Set Global Volume. */ - channel->replay->global_vol = channel->note.param >= 64 ? 64 : channel->note.param & 0x3F; - break; - case 0x11: /* Global Volume Slide. */ - if( channel->note.param > 0 ) { - channel->gvol_slide_param = channel->note.param; - } - break; - case 0x14: /* Key Off. */ - channel->key_on = 0; - break; - case 0x15: /* Set Envelope Tick. */ - channel->vol_env_tick = channel->pan_env_tick = channel->note.param & 0xFF; - break; - case 0x19: /* Panning Slide. */ - if( channel->note.param > 0 ) { - channel->pan_slide_param = channel->note.param; - } - break; - case 0x1B: case 0x91: /* Retrig + Vol Slide. */ - if( ( channel->note.param >> 4 ) > 0 ) { - channel->retrig_volume = channel->note.param >> 4; - } - if( ( channel->note.param & 0xF ) > 0 ) { - channel->retrig_ticks = channel->note.param & 0xF; - } - channel_retrig_vol_slide( channel ); - break; - case 0x1D: case 0x89: /* Tremor. */ - if( ( channel->note.param >> 4 ) > 0 ) { - channel->tremor_on_ticks = channel->note.param >> 4; - } - if( ( channel->note.param & 0xF ) > 0 ) { - channel->tremor_off_ticks = channel->note.param & 0xF; - } - channel_tremor( channel ); - break; - case 0x21: /* Extra Fine Porta. */ - if( channel->note.param > 0 ) { - channel->xfine_porta_param = channel->note.param; - } - switch( channel->xfine_porta_param & 0xF0 ) { - case 0x10: - channel_porta_up( channel, 0xE0 | ( channel->xfine_porta_param & 0xF ) ); - break; - case 0x20: - channel_porta_down( channel, 0xE0 | ( channel->xfine_porta_param & 0xF ) ); - break; - } - break; - case 0x71: /* Fine Porta Up. */ - if( channel->note.param > 0 ) { - channel->fine_porta_up_param = channel->note.param; - } - channel_porta_up( channel, 0xF0 | ( channel->fine_porta_up_param & 0xF ) ); - break; - case 0x72: /* Fine Porta Down. */ - if( channel->note.param > 0 ) { - channel->fine_porta_down_param = channel->note.param; - } - channel_porta_down( channel, 0xF0 | ( channel->fine_porta_down_param & 0xF ) ); - break; - case 0x74: case 0xF3: /* Set Vibrato Waveform. */ - if( channel->note.param < 8 ) { - channel->vibrato_type = channel->note.param; - } - break; - case 0x77: case 0xF4: /* Set Tremolo Waveform. */ - if( channel->note.param < 8 ) { - channel->tremolo_type = channel->note.param; - } - break; - case 0x7A: /* Fine Vol Slide Up. */ - if( channel->note.param > 0 ) { - channel->fine_vslide_up_param = channel->note.param; - } - channel->volume += channel->fine_vslide_up_param; - if( channel->volume > 64 ) { - channel->volume = 64; - } - break; - case 0x7B: /* Fine Vol Slide Down. */ - if( channel->note.param > 0 ) { - channel->fine_vslide_down_param = channel->note.param; - } - channel->volume -= channel->fine_vslide_down_param; - if( channel->volume < 0 ) { - channel->volume = 0; - } - break; - case 0x7C: case 0xFC: /* Note Cut. */ - if( channel->note.param <= 0 ) { - channel->volume = 0; - } - break; - case 0x8A: /* Arpeggio. */ - if( channel->note.param > 0 ) { - channel->arpeggio_param = channel->note.param; - } - break; - case 0x95: /* Fine Vibrato.*/ - if( ( channel->note.param >> 4 ) > 0 ) { - channel->vibrato_speed = channel->note.param >> 4; - } - if( ( channel->note.param & 0xF ) > 0 ) { - channel->vibrato_depth = channel->note.param & 0xF; - } - channel_vibrato( channel, 1 ); - break; - case 0xF8: /* Set Panning. */ - channel->panning = channel->note.param * 17; - break; - } - channel_auto_vibrato( channel ); - channel_calculate_freq( channel ); - channel_calculate_ampl( channel ); - channel_update_envelopes( channel ); -} - -static void channel_resample( struct channel *channel, int *mix_buf, - int offset, int count, int sample_rate, int interpolate ) { - struct sample *sample = channel->sample; - int l_gain, r_gain, sam_idx, sam_fra, step; - int loop_len, loop_end, out_idx, out_end, y, m, c; - short *sample_data = channel->sample->data; - if( channel->ampl > 0 ) { - l_gain = channel->ampl * ( 255 - channel->pann ) >> 8; - r_gain = channel->ampl * channel->pann >> 8; - sam_idx = channel->sample_idx; - sam_fra = channel->sample_fra; - step = ( channel->freq << ( FP_SHIFT - 3 ) ) / ( sample_rate >> 3 ); - loop_len = sample->loop_length; - loop_end = sample->loop_start + loop_len; - out_idx = offset * 2; - out_end = ( offset + count ) * 2; - if( interpolate ) { - while( out_idx < out_end ) { - if( sam_idx >= loop_end ) { - if( loop_len > 1 ) { - while( sam_idx >= loop_end ) { - sam_idx -= loop_len; - } - } else { - break; - } - } - c = sample_data[ sam_idx ]; - m = sample_data[ sam_idx + 1 ] - c; - y = ( ( m * sam_fra ) >> FP_SHIFT ) + c; - mix_buf[ out_idx++ ] += ( y * l_gain ) >> FP_SHIFT; - mix_buf[ out_idx++ ] += ( y * r_gain ) >> FP_SHIFT; - sam_fra += step; - sam_idx += sam_fra >> FP_SHIFT; - sam_fra &= FP_MASK; - } - } else { - while( out_idx < out_end ) { - if( sam_idx >= loop_end ) { - if( loop_len > 1 ) { - while( sam_idx >= loop_end ) { - sam_idx -= loop_len; - } - } else { - break; - } - } - y = sample_data[ sam_idx ]; - mix_buf[ out_idx++ ] += ( y * l_gain ) >> FP_SHIFT; - mix_buf[ out_idx++ ] += ( y * r_gain ) >> FP_SHIFT; - sam_fra += step; - sam_idx += sam_fra >> FP_SHIFT; - sam_fra &= FP_MASK; - } - } - } -} - -static void channel_update_sample_idx( struct channel *channel, int count, int sample_rate ) { - struct sample *sample = channel->sample; - int step = ( channel->freq << ( FP_SHIFT - 3 ) ) / ( sample_rate >> 3 ); - channel->sample_fra += step * count; - channel->sample_idx += channel->sample_fra >> FP_SHIFT; - if( channel->sample_idx > sample->loop_start ) { - if( sample->loop_length > 1 ) { - channel->sample_idx = sample->loop_start - + ( channel->sample_idx - sample->loop_start ) % sample->loop_length; - } else { - channel->sample_idx = sample->loop_start; - } - } - channel->sample_fra &= FP_MASK; -} - -static void replay_row( struct replay *replay ) { - int idx, count; - struct note note; - struct pattern *pattern; - struct channel *channel; - struct module *module = replay->module; - if( replay->next_row < 0 ) { - replay->break_pos = replay->seq_pos + 1; - replay->next_row = 0; - } - if( replay->break_pos >= 0 ) { - if( replay->break_pos >= module->sequence_len ) { - replay->break_pos = replay->next_row = 0; - } - while( module->sequence[ replay->break_pos ] >= module->num_patterns ) { - replay->break_pos++; - if( replay->break_pos >= module->sequence_len ) { - replay->break_pos = replay->next_row = 0; - } - } - replay->seq_pos = replay->break_pos; - for( idx = 0; idx < module->num_channels; idx++ ) { - replay->channels[ idx ].pl_row = 0; - } - replay->break_pos = -1; - } - pattern = &module->patterns[ module->sequence[ replay->seq_pos ] ]; - replay->row = replay->next_row; - if( replay->row >= pattern->num_rows ) { - replay->row = 0; - } - if( replay->play_count && replay->play_count[ 0 ] ) { - count = replay->play_count[ replay->seq_pos ][ replay->row ]; - if( replay->pl_count < 0 && count < 127 ) { - replay->play_count[ replay->seq_pos ][ replay->row ] = count + 1; - } - } - replay->next_row = replay->row + 1; - if( replay->next_row >= pattern->num_rows ) { - replay->next_row = -1; - } - for( idx = 0; idx < module->num_channels; idx++ ) { - channel = &replay->channels[ idx ]; - pattern_get_note( pattern, replay->row, idx, ¬e ); - if( note.effect == 0xE ) { - note.effect = 0x70 | ( note.param >> 4 ); - note.param &= 0xF; - } - if( note.effect == 0x93 ) { - note.effect = 0xF0 | ( note.param >> 4 ); - note.param &= 0xF; - } - if( note.effect == 0 && note.param > 0 ) { - note.effect = 0x8A; - } - channel_row( channel, ¬e ); - switch( note.effect ) { - case 0x81: /* Set Speed. */ - if( note.param > 0 ) { - replay->tick = replay->speed = note.param; - } - break; - case 0xB: case 0x82: /* Pattern Jump.*/ - if( replay->pl_count < 0 ) { - replay->break_pos = note.param; - replay->next_row = 0; - } - break; - case 0xD: case 0x83: /* Pattern Break.*/ - if( replay->pl_count < 0 ) { - if( replay->break_pos < 0 ) { - replay->break_pos = replay->seq_pos + 1; - } - replay->next_row = ( note.param >> 4 ) * 10 + ( note.param & 0xF ); - } - break; - case 0xF: /* Set Speed/Tempo.*/ - if( note.param > 0 ) { - if( note.param < 32 ) { - replay->tick = replay->speed = note.param; - } else { - replay->tempo = note.param; - } - } - break; - case 0x94: /* Set Tempo.*/ - if( note.param > 32 ) { - replay->tempo = note.param; - } - break; - case 0x76: case 0xFB : /* Pattern Loop.*/ - if( note.param == 0 ) { - /* Set loop marker on this channel. */ - channel->pl_row = replay->row; - } - if( channel->pl_row < replay->row && replay->break_pos < 0 ) { - /* Marker valid. */ - if( replay->pl_count < 0 ) { - /* Not already looping, begin. */ - replay->pl_count = note.param; - replay->pl_chan = idx; - } - if( replay->pl_chan == idx ) { - /* Next Loop.*/ - if( replay->pl_count == 0 ) { - /* Loop finished. Invalidate current marker. */ - channel->pl_row = replay->row + 1; - } else { - /* Loop. */ - replay->next_row = channel->pl_row; - } - replay->pl_count--; - } - } - break; - case 0x7E: case 0xFE: /* Pattern Delay.*/ - replay->tick = replay->speed + replay->speed * note.param; - break; - } - } -} - -static int replay_tick( struct replay *replay ) { - int idx, num_channels, count = 1; - if( --replay->tick <= 0 ) { - replay->tick = replay->speed; - replay_row( replay ); - } else { - num_channels = replay->module->num_channels; - for( idx = 0; idx < num_channels; idx++ ) { - channel_tick( &replay->channels[ idx ] ); - } - } - if( replay->play_count && replay->play_count[ 0 ] ) { - count = replay->play_count[ replay->seq_pos ][ replay->row ] - 1; - } - return count; -} - -static int module_init_play_count( struct module *module, char **play_count ) { - int idx, pat, rows, len = 0; - for( idx = 0; idx < module->sequence_len; idx++ ) { - pat = module->sequence[ idx ]; - rows = ( pat < module->num_patterns ) ? module->patterns[ pat ].num_rows : 0; - if( play_count ) { - play_count[ idx ] = play_count[ 0 ] ? &play_count[ 0 ][ len ] : NULL; - } - len += rows; - } - return len; -} - -/* Set the pattern in the sequence to play. The tempo is reset to the default. */ -void replay_set_sequence_pos( struct replay *replay, int pos ) { - int idx; - struct module *module = replay->module; - if( pos >= module->sequence_len ) { - pos = 0; - } - replay->break_pos = pos; - replay->next_row = 0; - replay->tick = 1; - replay->global_vol = module->default_gvol; - replay->speed = module->default_speed > 0 ? module->default_speed : 6; - replay->tempo = module->default_tempo > 0 ? module->default_tempo : 125; - replay->pl_count = replay->pl_chan = -1; - if( replay->play_count ) { - free( replay->play_count[ 0 ] ); - free( replay->play_count ); - } - replay->play_count = (char**)calloc( module->sequence_len, sizeof( char * ) ); - if( replay->play_count ) { - replay->play_count[ 0 ] = (char*)calloc( module_init_play_count( module, NULL ), sizeof( char ) ); - module_init_play_count( module, replay->play_count ); - } - for( idx = 0; idx < module->num_channels; idx++ ) { - channel_init( &replay->channels[ idx ], replay, idx ); - } - memset( replay->ramp_buf, 0, 128 * sizeof( int ) ); - replay_tick( replay ); -} - -/* Deallocate the specified replay. */ -void dispose_replay( struct replay *replay ) { - if( replay->play_count ) { - free( replay->play_count[ 0 ] ); - free( replay->play_count ); - } - free( replay->ramp_buf ); - free( replay->channels ); - free( replay ); -} - -/* Allocate and initialize a replay with the specified sampling rate and interpolation. */ -struct replay* new_replay( struct module *module, int sample_rate, int interpolation ) { - struct replay *replay = (struct replay*)calloc( 1, sizeof( struct replay ) ); - if( replay ) { - replay->module = module; - replay->sample_rate = sample_rate; - replay->interpolation = interpolation; - replay->ramp_buf = (int*)calloc( 128, sizeof( int ) ); - replay->channels = (struct channel*)calloc( module->num_channels, sizeof( struct channel ) ); - if( replay->ramp_buf && replay->channels ) { - replay_set_sequence_pos( replay, 0 ); - } else { - dispose_replay( replay ); - replay = NULL; - } - } - return replay; -} - -static int calculate_tick_len( int tempo, int sample_rate ) { - return ( sample_rate * 5 ) / ( tempo * 2 ); -} - -/* Returns the length of the output buffer required by replay_get_audio(). */ -int calculate_mix_buf_len( int sample_rate ) { - return ( calculate_tick_len( 32, sample_rate ) + 65 ) * 4; -} - -/* Returns the song duration in samples at the current sampling rate. */ -int replay_calculate_duration( struct replay *replay ) { - int count = 0, duration = 0; - replay_set_sequence_pos( replay, 0 ); - while( count < 1 ) { - duration += calculate_tick_len( replay->tempo, replay->sample_rate ); - count = replay_tick( replay ); - } - replay_set_sequence_pos( replay, 0 ); - return duration; -} - -/* Seek to approximately the specified sample position. - The actual sample position reached is returned. */ -int replay_seek( struct replay *replay, int sample_pos ) { - int idx, tick_len, current_pos = 0; - replay_set_sequence_pos( replay, 0 ); - tick_len = calculate_tick_len( replay->tempo, replay->sample_rate ); - while( ( sample_pos - current_pos ) >= tick_len ) { - for( idx = 0; idx < replay->module->num_channels; idx++ ) { - channel_update_sample_idx( &replay->channels[ idx ], - tick_len * 2, replay->sample_rate * 2 ); - } - current_pos += tick_len; - replay_tick( replay ); - tick_len = calculate_tick_len( replay->tempo, replay->sample_rate ); - } - return current_pos; -} - -static void replay_volume_ramp( struct replay *replay, int *mix_buf, int tick_len ) { - int idx, a1, a2, ramp_rate = 256 * 2048 / replay->sample_rate; - for( idx = 0, a1 = 0; a1 < 256; idx += 2, a1 += ramp_rate ) { - a2 = 256 - a1; - mix_buf[ idx ] = ( mix_buf[ idx ] * a1 + replay->ramp_buf[ idx ] * a2 ) >> 8; - mix_buf[ idx + 1 ] = ( mix_buf[ idx + 1 ] * a1 + replay->ramp_buf[ idx + 1 ] * a2 ) >> 8; - } - memcpy( replay->ramp_buf, &mix_buf[ tick_len * 2 ], 128 * sizeof( int ) ); -} - -/* 2:1 downsampling with simple but effective anti-aliasing. Buf must contain count * 2 + 1 stereo samples. */ -static void downsample( int *buf, int count ) { - int idx, out_idx, out_len = count * 2; - for( idx = 0, out_idx = 0; out_idx < out_len; idx += 4, out_idx += 2 ) { - buf[ out_idx ] = ( buf[ idx ] >> 2 ) + ( buf[ idx + 2 ] >> 1 ) + ( buf[ idx + 4 ] >> 2 ); - buf[ out_idx + 1 ] = ( buf[ idx + 1 ] >> 2 ) + ( buf[ idx + 3 ] >> 1 ) + ( buf[ idx + 5 ] >> 2 ); - } -} - -/* Generates audio and returns the number of stereo samples written into mix_buf. */ -int replay_get_audio( struct replay *replay, int *mix_buf ) { - struct channel *channel; - int idx, num_channels, tick_len = calculate_tick_len( replay->tempo, replay->sample_rate ); - /* Clear output buffer. */ - memset( mix_buf, 0, ( tick_len + 65 ) * 4 * sizeof( int ) ); - /* Resample. */ - num_channels = replay->module->num_channels; - for( idx = 0; idx < num_channels; idx++ ) { - channel = &replay->channels[ idx ]; - channel_resample( channel, mix_buf, 0, ( tick_len + 65 ) * 2, - replay->sample_rate * 2, replay->interpolation ); - channel_update_sample_idx( channel, tick_len * 2, replay->sample_rate * 2 ); - } - downsample( mix_buf, tick_len + 64 ); - replay_volume_ramp( replay, mix_buf, tick_len ); - replay_tick( replay ); - return tick_len; -} + +#include "stdlib.h" +#include "string.h" + +#include "ibxm.h" + +const char *IBXM_VERSION = "ibxm/ac mod/xm/s3m replay 20170901 (c)mumart@gmail.com"; + +static const int FP_SHIFT = 15, FP_ONE = 32768, FP_MASK = 32767; + +static const int exp2_table[] = { + 32768, 32946, 33125, 33305, 33486, 33667, 33850, 34034, + 34219, 34405, 34591, 34779, 34968, 35158, 35349, 35541, + 35734, 35928, 36123, 36319, 36516, 36715, 36914, 37114, + 37316, 37518, 37722, 37927, 38133, 38340, 38548, 38757, + 38968, 39180, 39392, 39606, 39821, 40037, 40255, 40473, + 40693, 40914, 41136, 41360, 41584, 41810, 42037, 42265, + 42495, 42726, 42958, 43191, 43425, 43661, 43898, 44137, + 44376, 44617, 44859, 45103, 45348, 45594, 45842, 46091, + 46341, 46593, 46846, 47100, 47356, 47613, 47871, 48131, + 48393, 48655, 48920, 49185, 49452, 49721, 49991, 50262, + 50535, 50810, 51085, 51363, 51642, 51922, 52204, 52488, + 52773, 53059, 53347, 53637, 53928, 54221, 54515, 54811, + 55109, 55408, 55709, 56012, 56316, 56622, 56929, 57238, + 57549, 57861, 58176, 58491, 58809, 59128, 59449, 59772, + 60097, 60423, 60751, 61081, 61413, 61746, 62081, 62419, + 62757, 63098, 63441, 63785, 64132, 64480, 64830, 65182, + 65536 +}; + +static const short sine_table[] = { + 0, 24, 49, 74, 97, 120, 141, 161, 180, 197, 212, 224, 235, 244, 250, 253, + 255, 253, 250, 244, 235, 224, 212, 197, 180, 161, 141, 120, 97, 74, 49, 24 +}; + +struct note { + unsigned char key, instrument, volume, effect, param; +}; + +struct channel { + struct replay *replay; + struct instrument *instrument; + struct sample *sample; + struct note note; + int id, key_on, random_seed, pl_row; + int sample_off, sample_idx, sample_fra, freq, ampl, pann; + int volume, panning, fadeout_vol, vol_env_tick, pan_env_tick; + int period, porta_period, retrig_count, fx_count, av_count; + int porta_up_param, porta_down_param, tone_porta_param, offset_param; + int fine_porta_up_param, fine_porta_down_param, xfine_porta_param; + int arpeggio_param, vol_slide_param, gvol_slide_param, pan_slide_param; + int fine_vslide_up_param, fine_vslide_down_param; + int retrig_volume, retrig_ticks, tremor_on_ticks, tremor_off_ticks; + int vibrato_type, vibrato_phase, vibrato_speed, vibrato_depth; + int tremolo_type, tremolo_phase, tremolo_speed, tremolo_depth; + int tremolo_add, vibrato_add, arpeggio_add; +}; + +struct replay { + int sample_rate, interpolation, global_vol; + int seq_pos, break_pos, row, next_row, tick; + int speed, tempo, pl_count, pl_chan; + int *ramp_buf; + char **play_count; + struct channel *channels; + struct module *module; +}; + +static int exp_2( int x ) { + int c, m, y; + int x0 = ( x & FP_MASK ) >> ( FP_SHIFT - 7 ); + c = exp2_table[ x0 ]; + m = exp2_table[ x0 + 1 ] - c; + y = ( m * ( x & ( FP_MASK >> 7 ) ) >> 8 ) + c; + return ( y << FP_SHIFT ) >> ( FP_SHIFT - ( x >> FP_SHIFT ) ); +} + +static int log_2( int x ) { + int step; + int y = 16 << FP_SHIFT; + for( step = y; step > 0; step >>= 1 ) { + if( exp_2( y - step ) >= x ) { + y -= step; + } + } + return y; +} + +static char* data_ascii( struct data *data, int offset, int length, char *dest ) { + int idx, chr; + memset( dest, 32, length ); + if( offset > data->length ) { + offset = data->length; + } + if( ( unsigned int ) offset + length > ( unsigned int ) data->length ) { + length = data->length - offset; + } + for( idx = 0; idx < length; idx++ ) { + chr = data->buffer[ offset + idx ] & 0xFF; + if( chr > 32 ) { + dest[ idx ] = chr; + } + } + return dest; +} + +static int data_s8( struct data *data, int offset ) { + int value = 0; + if( offset < data->length ) { + value = data->buffer[ offset ]; + value = ( value & 0x7F ) - ( value & 0x80 ); + } + return value; +} + +static int data_u8( struct data *data, int offset ) { + int value = 0; + if( offset < data->length ) { + value = data->buffer[ offset ] & 0xFF; + } + return value; +} + +static int data_u16be( struct data *data, int offset ) { + int value = 0; + if( offset + 1 < data->length ) { + value = ( ( data->buffer[ offset ] & 0xFF ) << 8 ) + | ( data->buffer[ offset + 1 ] & 0xFF ); + } + return value; +} + +static int data_u16le( struct data *data, int offset ) { + int value = 0; + if( offset + 1 < data->length ) { + value = ( data->buffer[ offset ] & 0xFF ) + | ( ( data->buffer[ offset + 1 ] & 0xFF ) << 8 ); + } + return value; +} + +static unsigned int data_u32le( struct data *data, int offset ) { + unsigned int value = 0; + if( offset + 3 < data->length ) { + value = ( data->buffer[ offset ] & 0xFF ) + | ( ( data->buffer[ offset + 1 ] & 0xFF ) << 8 ) + | ( ( data->buffer[ offset + 2 ] & 0xFF ) << 16 ) + | ( ( data->buffer[ offset + 3 ] & 0xFF ) << 24 ); + } + return value; +} + +static void data_sam_s8( struct data *data, int offset, int count, short *dest ) { + int idx, amp, length = data->length; + char *buffer = data->buffer; + if( offset > length ) { + offset = length; + } + if( offset + count > length ) { + count = length - offset; + } + for( idx = 0; idx < count; idx++ ) { + amp = ( buffer[ offset + idx ] & 0xFF ) << 8; + dest[ idx ] = ( amp & 0x7FFF ) - ( amp & 0x8000 ); + } +} + +static void data_sam_s16le( struct data *data, int offset, int count, short *dest ) { + int idx, amp, length = data->length; + char *buffer = data->buffer; + if( offset > length ) { + offset = length; + } + if( offset + count * 2 > length ) { + count = ( length - offset ) / 2; + } + for( idx = 0; idx < count; idx++ ) { + amp = ( buffer[ offset + idx * 2 ] & 0xFF ) | ( buffer[ offset + idx * 2 + 1 ] << 8 ); + dest[ idx ] = ( amp & 0x7FFF ) - ( amp & 0x8000 ); + } +} + +static int envelope_next_tick( struct envelope *envelope, int tick, int key_on ) { + tick++; + if( envelope->looped && tick >= envelope->loop_end_tick ) { + tick = envelope->loop_start_tick; + } + if( envelope->sustain && key_on && tick >= envelope->sustain_tick ) { + tick = envelope->sustain_tick; + } + return tick; +} + +static int envelope_calculate_ampl( struct envelope *envelope, int tick ) { + int idx, point, dt, da; + int ampl = envelope->points_ampl[ envelope->num_points - 1 ]; + if( tick < envelope->points_tick[ envelope->num_points - 1 ] ) { + point = 0; + for( idx = 1; idx < envelope->num_points; idx++ ) { + if( envelope->points_tick[ idx ] <= tick ) { + point = idx; + } + } + dt = envelope->points_tick[ point + 1 ] - envelope->points_tick[ point ]; + da = envelope->points_ampl[ point + 1 ] - envelope->points_ampl[ point ]; + ampl = envelope->points_ampl[ point ]; + ampl += ( ( da << 24 ) / dt ) * ( tick - envelope->points_tick[ point ] ) >> 24; + } + return ampl; +} + +static void sample_ping_pong( struct sample *sample ) { + int idx; + int loop_start = sample->loop_start; + int loop_length = sample->loop_length; + int loop_end = loop_start + loop_length; + short *sample_data = sample->data; + short *new_data = (short*)calloc( loop_end + loop_length + 1, sizeof( short ) ); + if( new_data ) { + memcpy( new_data, sample_data, loop_end * sizeof( short ) ); + for( idx = 0; idx < loop_length; idx++ ) { + new_data[ loop_end + idx ] = sample_data[ loop_end - idx - 1 ]; + } + free( sample->data ); + sample->data = new_data; + sample->loop_length *= 2; + sample->data[ loop_start + sample->loop_length ] = sample->data[ loop_start ]; + } +} + +/* Deallocate the specified module. */ +void dispose_module( struct module *module ) { + int idx, sam; + struct instrument *instrument; + free( module->default_panning ); + free( module->sequence ); + if( module->patterns ) { + for( idx = 0; idx < module->num_patterns; idx++ ) { + free( module->patterns[ idx ].data ); + } + free( module->patterns ); + } + if( module->instruments ) { + for( idx = 0; idx <= module->num_instruments; idx++ ) { + instrument = &module->instruments[ idx ]; + if( instrument->samples ) { + for( sam = 0; sam < instrument->num_samples; sam++ ) { + free( instrument->samples[ sam ].data ); + } + free( instrument->samples ); + } + } + free( module->instruments ); + } + free( module ); +} + +static struct module* module_load_xm( struct data *data, char *message ) { + int delta_env, offset, next_offset, idx, entry; + int num_rows, num_notes, pat_data_len, pat_data_offset; + int sam, sam_head_offset, sam_data_bytes, sam_data_samples; + int num_samples, sam_loop_start, sam_loop_length, amp; + int note, flags, key, ins, vol, fxc, fxp; + int point, point_tick, point_offset; + int looped, ping_pong, sixteen_bit; + char ascii[ 16 ], *pattern_data; + struct instrument *instrument; + struct sample *sample; + struct module *module = (struct module*)calloc( 1, sizeof( struct module ) ); + if( module ) { + if( data_u16le( data, 58 ) != 0x0104 ) { + strcpy( message, "XM format version must be 0x0104!" ); + dispose_module( module ); + return NULL; + } + data_ascii( data, 17, 20, module->name ); + delta_env = !memcmp( data_ascii( data, 38, 15, ascii ), "DigiBooster Pro", 15 ); + offset = 60 + data_u32le( data, 60 ); + module->sequence_len = data_u16le( data, 64 ); + module->restart_pos = data_u16le( data, 66 ); + module->num_channels = data_u16le( data, 68 ); + module->num_patterns = data_u16le( data, 70 ); + module->num_instruments = data_u16le( data, 72 ); + module->linear_periods = data_u16le( data, 74 ) & 0x1; + module->default_gvol = 64; + module->default_speed = data_u16le( data, 76 ); + module->default_tempo = data_u16le( data, 78 ); + module->c2_rate = 8363; + module->gain = 64; + module->default_panning = (unsigned char*)calloc( module->num_channels, sizeof( unsigned char ) ); + if( !module->default_panning ) { + dispose_module( module ); + return NULL; + } + for( idx = 0; idx < module->num_channels; idx++ ) { + module->default_panning[ idx ] = 128; + } + module->sequence = (unsigned char*)calloc( module->sequence_len, sizeof( unsigned char ) ); + if( !module->sequence ) { + dispose_module( module ); + return NULL; + } + for( idx = 0; idx < module->sequence_len; idx++ ) { + entry = data_u8( data, 80 + idx ); + module->sequence[ idx ] = entry < module->num_patterns ? entry : 0; + } + module->patterns = (struct pattern*)calloc( module->num_patterns, sizeof( struct pattern ) ); + if( !module->patterns ) { + dispose_module( module ); + return NULL; + } + for( idx = 0; idx < module->num_patterns; idx++ ) { + if( data_u8( data, offset + 4 ) ) { + strcpy( message, "Unknown pattern packing type!" ); + dispose_module( module ); + return NULL; + } + num_rows = data_u16le( data, offset + 5 ); + if( num_rows < 1 ) { + num_rows = 1; + } + pat_data_len = data_u16le( data, offset + 7 ); + offset += data_u32le( data, offset ); + next_offset = offset + pat_data_len; + num_notes = num_rows * module->num_channels; + pattern_data = (char*)calloc( num_notes, 5 ); + if( !pattern_data ) { + dispose_module( module ); + return NULL; + } + module->patterns[ idx ].num_channels = module->num_channels; + module->patterns[ idx ].num_rows = num_rows; + module->patterns[ idx ].data = pattern_data; + if( pat_data_len > 0 ) { + pat_data_offset = 0; + for( note = 0; note < num_notes; note++ ) { + flags = data_u8( data, offset ); + if( ( flags & 0x80 ) == 0 ) { + flags = 0x1F; + } else { + offset++; + } + key = ( flags & 0x01 ) > 0 ? data_u8( data, offset++ ) : 0; + pattern_data[ pat_data_offset++ ] = key; + ins = ( flags & 0x02 ) > 0 ? data_u8( data, offset++ ) : 0; + pattern_data[ pat_data_offset++ ] = ins; + vol = ( flags & 0x04 ) > 0 ? data_u8( data, offset++ ) : 0; + pattern_data[ pat_data_offset++ ] = vol; + fxc = ( flags & 0x08 ) > 0 ? data_u8( data, offset++ ) : 0; + fxp = ( flags & 0x10 ) > 0 ? data_u8( data, offset++ ) : 0; + if( fxc >= 0x40 ) { + fxc = fxp = 0; + } + pattern_data[ pat_data_offset++ ] = fxc; + pattern_data[ pat_data_offset++ ] = fxp; + } + } + offset = next_offset; + } + module->instruments = (struct instrument*)calloc( module->num_instruments + 1, sizeof( struct instrument ) ); + if( !module->instruments ) { + dispose_module( module ); + return NULL; + } + instrument = &module->instruments[ 0 ]; + instrument->samples = (struct sample*)calloc( 1, sizeof( struct sample ) ); + if( !instrument->samples ) { + dispose_module( module ); + return NULL; + } + for( ins = 1; ins <= module->num_instruments; ins++ ) { + instrument = &module->instruments[ ins ]; + data_ascii( data, offset + 4, 22, instrument->name ); + num_samples = data_u16le( data, offset + 27 ); + instrument->num_samples = ( num_samples > 0 ) ? num_samples : 1; + instrument->samples = (struct sample*)calloc( instrument->num_samples, sizeof( struct sample ) ); + if( !instrument->samples ) { + dispose_module( module ); + return NULL; + } + if( num_samples > 0 ) { + for( key = 0; key < 96; key++ ) { + instrument->key_to_sample[ key + 1 ] = data_u8( data, offset + 33 + key ); + } + point_tick = 0; + for( point = 0; point < 12; point++ ) { + point_offset = offset + 129 + ( point * 4 ); + point_tick = ( delta_env ? point_tick : 0 ) + data_u16le( data, point_offset ); + instrument->vol_env.points_tick[ point ] = point_tick; + instrument->vol_env.points_ampl[ point ] = data_u16le( data, point_offset + 2 ); + } + point_tick = 0; + for( point = 0; point < 12; point++ ) { + point_offset = offset + 177 + ( point * 4 ); + point_tick = ( delta_env ? point_tick : 0 ) + data_u16le( data, point_offset ); + instrument->pan_env.points_tick[ point ] = point_tick; + instrument->pan_env.points_ampl[ point ] = data_u16le( data, point_offset + 2 ); + } + instrument->vol_env.num_points = data_u8( data, offset + 225 ); + if( instrument->vol_env.num_points > 12 ) { + instrument->vol_env.num_points = 0; + } + instrument->pan_env.num_points = data_u8( data, offset + 226 ); + if( instrument->pan_env.num_points > 12 ) { + instrument->pan_env.num_points = 0; + } + instrument->vol_env.sustain_tick = instrument->vol_env.points_tick[ data_u8( data, offset + 227 ) & 0xF ]; + instrument->vol_env.loop_start_tick = instrument->vol_env.points_tick[ data_u8( data, offset + 228 ) & 0xF ]; + instrument->vol_env.loop_end_tick = instrument->vol_env.points_tick[ data_u8( data, offset + 229 ) & 0xF ]; + instrument->pan_env.sustain_tick = instrument->pan_env.points_tick[ data_u8( data, offset + 230 ) & 0xF ]; + instrument->pan_env.loop_start_tick = instrument->pan_env.points_tick[ data_u8( data, offset + 231 ) & 0xF ]; + instrument->pan_env.loop_end_tick = instrument->pan_env.points_tick[ data_u8( data, offset + 232 ) & 0xF ]; + instrument->vol_env.enabled = instrument->vol_env.num_points > 0 && ( data_u8( data, offset + 233 ) & 0x1 ); + instrument->vol_env.sustain = ( data_u8( data, offset + 233 ) & 0x2 ) > 0; + instrument->vol_env.looped = ( data_u8( data, offset + 233 ) & 0x4 ) > 0; + instrument->pan_env.enabled = instrument->pan_env.num_points > 0 && ( data_u8( data, offset + 234 ) & 0x1 ); + instrument->pan_env.sustain = ( data_u8( data, offset + 234 ) & 0x2 ) > 0; + instrument->pan_env.looped = ( data_u8( data, offset + 234 ) & 0x4 ) > 0; + instrument->vib_type = data_u8( data, offset + 235 ); + instrument->vib_sweep = data_u8( data, offset + 236 ); + instrument->vib_depth = data_u8( data, offset + 237 ); + instrument->vib_rate = data_u8( data, offset + 238 ); + instrument->vol_fadeout = data_u16le( data, offset + 239 ); + } + offset += data_u32le( data, offset ); + sam_head_offset = offset; + offset += num_samples * 40; + for( sam = 0; sam < num_samples; sam++ ) { + sample = &instrument->samples[ sam ]; + sam_data_bytes = data_u32le( data, sam_head_offset ); + sam_loop_start = data_u32le( data, sam_head_offset + 4 ); + sam_loop_length = data_u32le( data, sam_head_offset + 8 ); + sample->volume = data_u8( data, sam_head_offset + 12 ); + sample->fine_tune = data_s8( data, sam_head_offset + 13 ); + looped = ( data_u8( data, sam_head_offset + 14 ) & 0x3 ) > 0; + ping_pong = ( data_u8( data, sam_head_offset + 14 ) & 0x2 ) > 0; + sixteen_bit = ( data_u8( data, sam_head_offset + 14 ) & 0x10 ) > 0; + sample->panning = data_u8( data, sam_head_offset + 15 ) + 1; + sample->rel_note = data_s8( data, sam_head_offset + 16 ); + data_ascii( data, sam_head_offset + 18, 22, sample->name ); + sam_head_offset += 40; + sam_data_samples = sam_data_bytes; + if( sixteen_bit ) { + sam_data_samples = sam_data_samples >> 1; + sam_loop_start = sam_loop_start >> 1; + sam_loop_length = sam_loop_length >> 1; + } + if( !looped || ( sam_loop_start + sam_loop_length ) > sam_data_samples ) { + sam_loop_start = sam_data_samples; + sam_loop_length = 0; + } + sample->loop_start = sam_loop_start; + sample->loop_length = sam_loop_length; + sample->data = (short*)calloc( sam_data_samples + 1, sizeof( short ) ); + if( sample->data ) { + if( sixteen_bit ) { + data_sam_s16le( data, offset, sam_data_samples, sample->data ); + } else { + data_sam_s8( data, offset, sam_data_samples, sample->data ); + } + amp = 0; + for( idx = 0; idx < sam_data_samples; idx++ ) { + amp = amp + sample->data[ idx ]; + amp = ( amp & 0x7FFF ) - ( amp & 0x8000 ); + sample->data[ idx ] = amp; + } + sample->data[ sam_loop_start + sam_loop_length ] = sample->data[ sam_loop_start ]; + if( ping_pong ) { + sample_ping_pong( sample ); + } + } else { + dispose_module( module ); + return NULL; + } + offset += sam_data_bytes; + } + } + } + return module; +} + +static struct module* module_load_s3m( struct data *data, char *message ) { + int idx, module_data_idx, inst_offset, flags; + int version, sixteen_bit, tune, signed_samples; + int stereo_mode, default_pan, channel_map[ 32 ]; + int sample_offset, sample_length, loop_start, loop_length; + int pat_offset, note_offset, row, chan, token; + int key, ins, volume, effect, param, panning; + char *pattern_data; + struct instrument *instrument; + struct sample *sample; + struct module *module = (struct module*)calloc( 1, sizeof( struct module ) ); + if( module ) { + data_ascii( data, 0, 28, module->name ); + module->sequence_len = data_u16le( data, 32 ); + module->num_instruments = data_u16le( data, 34 ); + module->num_patterns = data_u16le( data, 36 ); + flags = data_u16le( data, 38 ); + version = data_u16le( data, 40 ); + module->fast_vol_slides = ( ( flags & 0x40 ) == 0x40 ) || version == 0x1300; + signed_samples = data_u16le( data, 42 ) == 1; + if( data_u32le( data, 44 ) != 0x4d524353 ) { + strcpy( message, "Not an S3M file!" ); + dispose_module( module ); + return NULL; + } + module->default_gvol = data_u8( data, 48 ); + module->default_speed = data_u8( data, 49 ); + module->default_tempo = data_u8( data, 50 ); + module->c2_rate = 8363; + module->gain = data_u8( data, 51 ) & 0x7F; + stereo_mode = ( data_u8( data, 51 ) & 0x80 ) == 0x80; + default_pan = data_u8( data, 53 ) == 0xFC; + for( idx = 0; idx < 32; idx++ ) { + channel_map[ idx ] = -1; + if( data_u8( data, 64 + idx ) < 16 ) { + channel_map[ idx ] = module->num_channels++; + } + } + module->sequence = (unsigned char*)calloc( module->sequence_len, sizeof( unsigned char ) ); + if( !module->sequence ){ + dispose_module( module ); + return NULL; + } + for( idx = 0; idx < module->sequence_len; idx++ ) { + module->sequence[ idx ] = data_u8( data, 96 + idx ); + } + module_data_idx = 96 + module->sequence_len; + module->instruments = (struct instrument*)calloc( module->num_instruments + 1, sizeof( struct instrument ) ); + if( !module->instruments ) { + dispose_module( module ); + return NULL; + } + instrument = &module->instruments[ 0 ]; + instrument->num_samples = 1; + instrument->samples = (struct sample*)calloc( 1, sizeof( struct sample ) ); + if( !instrument->samples ) { + dispose_module( module ); + return NULL; + } + for( ins = 1; ins <= module->num_instruments; ins++ ) { + instrument = &module->instruments[ ins ]; + instrument->num_samples = 1; + instrument->samples = (struct sample*)calloc( 1, sizeof( struct sample ) ); + if( !instrument->samples ) { + dispose_module( module ); + return NULL; + } + sample = &instrument->samples[ 0 ]; + inst_offset = data_u16le( data, module_data_idx ) << 4; + module_data_idx += 2; + data_ascii( data, inst_offset + 48, 28, instrument->name ); + if( data_u8( data, inst_offset ) == 1 && data_u16le( data, inst_offset + 76 ) == 0x4353 ) { + sample_offset = ( data_u8( data, inst_offset + 13 ) << 20 ) + + ( data_u16le( data, inst_offset + 14 ) << 4 ); + sample_length = data_u32le( data, inst_offset + 16 ); + loop_start = data_u32le( data, inst_offset + 20 ); + loop_length = data_u32le( data, inst_offset + 24 ) - loop_start; + sample->volume = data_u8( data, inst_offset + 28 ); + if( data_u8( data, inst_offset + 30 ) != 0 ) { + strcpy( message, "Packed samples not supported!" ); + dispose_module( module ); + return NULL; + } + if( loop_start + loop_length > sample_length ) { + loop_length = sample_length - loop_start; + } + if( loop_length < 1 || !( data_u8( data, inst_offset + 31 ) & 0x1 ) ) { + loop_start = sample_length; + loop_length = 0; + } + sample->loop_start = loop_start; + sample->loop_length = loop_length; + /* stereo = data_u8( data, inst_offset + 31 ) & 0x2; */ + sixteen_bit = data_u8( data, inst_offset + 31 ) & 0x4; + tune = ( log_2( data_u32le( data, inst_offset + 32 ) ) - log_2( module->c2_rate ) ) * 12; + sample->rel_note = tune >> FP_SHIFT; + sample->fine_tune = ( tune & FP_MASK ) >> ( FP_SHIFT - 7 ); + sample->data = (short*)calloc( sample_length + 1, sizeof( short ) ); + if( sample->data ) { + if( sixteen_bit ) { + data_sam_s16le( data, sample_offset, sample_length, sample->data ); + } else { + data_sam_s8( data, sample_offset, sample_length, sample->data ); + } + if( !signed_samples ) { + for( idx = 0; idx < sample_length; idx++ ) { + sample->data[ idx ] = ( sample->data[ idx ] & 0xFFFF ) - 32768; + } + } + sample->data[ loop_start + loop_length ] = sample->data[ loop_start ]; + } else { + dispose_module( module ); + return NULL; + } + } + } + module->patterns = (struct pattern*)calloc( module->num_patterns, sizeof( struct pattern ) ); + if( !module->patterns ) { + dispose_module( module ); + return NULL; + } + for( idx = 0; idx < module->num_patterns; idx++ ) { + module->patterns[ idx ].num_channels = module->num_channels; + module->patterns[ idx ].num_rows = 64; + pattern_data = (char*)calloc( module->num_channels * 64, 5 ); + if( !pattern_data ) { + dispose_module( module ); + return NULL; + } + module->patterns[ idx ].data = pattern_data; + pat_offset = ( data_u16le( data, module_data_idx ) << 4 ) + 2; + row = 0; + while( row < 64 ) { + token = data_u8( data, pat_offset++ ); + if( token ) { + key = ins = 0; + if( ( token & 0x20 ) == 0x20 ) { + /* Key + Instrument.*/ + key = data_u8( data, pat_offset++ ); + ins = data_u8( data, pat_offset++ ); + if( key < 0xFE ) { + key = ( key >> 4 ) * 12 + ( key & 0xF ) + 1; + } else if( key == 0xFF ) { + key = 0; + } + } + volume = 0; + if( ( token & 0x40 ) == 0x40 ) { + /* Volume Column.*/ + volume = ( data_u8( data, pat_offset++ ) & 0x7F ) + 0x10; + if( volume > 0x50 ) { + volume = 0; + } + } + effect = param = 0; + if( ( token & 0x80 ) == 0x80 ) { + /* Effect + Param.*/ + effect = data_u8( data, pat_offset++ ); + param = data_u8( data, pat_offset++ ); + if( effect < 1 || effect >= 0x40 ) { + effect = param = 0; + } else if( effect > 0 ) { + effect += 0x80; + } + } + chan = channel_map[ token & 0x1F ]; + if( chan >= 0 ) { + note_offset = ( row * module->num_channels + chan ) * 5; + pattern_data[ note_offset ] = key; + pattern_data[ note_offset + 1 ] = ins; + pattern_data[ note_offset + 2 ] = volume; + pattern_data[ note_offset + 3 ] = effect; + pattern_data[ note_offset + 4 ] = param; + } + } else { + row++; + } + } + module_data_idx += 2; + } + module->default_panning = (unsigned char*)calloc( module->num_channels, sizeof( unsigned char ) ); + if( module->default_panning ) { + for( chan = 0; chan < 32; chan++ ) { + if( channel_map[ chan ] >= 0 ) { + panning = 7; + if( stereo_mode ) { + panning = 12; + if( data_u8( data, 64 + chan ) < 8 ) { + panning = 3; + } + } + if( default_pan ) { + flags = data_u8( data, module_data_idx + chan ); + if( ( flags & 0x20 ) == 0x20 ) { + panning = flags & 0xF; + } + } + module->default_panning[ channel_map[ chan ] ] = panning * 17; + } + } + } else { + dispose_module( module ); + return NULL; + } + } + return module; +} + +static struct module* module_load_mod( struct data *data, char *message ) { + int idx, pat, module_data_idx, pat_data_len, pat_data_idx; + int period, key, ins, effect, param, fine_tune; + int sample_length, loop_start, loop_length; + char *pattern_data; + struct instrument *instrument; + struct sample *sample; + struct module *module = (struct module*)calloc( 1, sizeof( struct module ) ); + if( module ) { + data_ascii( data, 0, 20, module->name ); + module->sequence_len = data_u8( data, 950 ) & 0x7F; + module->restart_pos = data_u8( data, 951 ) & 0x7F; + if( module->restart_pos >= module->sequence_len ) { + module->restart_pos = 0; + } + module->sequence = (unsigned char*)calloc( 128, sizeof( unsigned char ) ); + if( !module->sequence ){ + dispose_module( module ); + return NULL; + } + for( idx = 0; idx < 128; idx++ ) { + pat = data_u8( data, 952 + idx ) & 0x7F; + module->sequence[ idx ] = pat; + if( pat >= module->num_patterns ) { + module->num_patterns = pat + 1; + } + } + switch( data_u16be( data, 1082 ) ) { + case 0x4b2e: /* M.K. */ + case 0x4b21: /* M!K! */ + case 0x5434: /* FLT4 */ + module->num_channels = 4; + module->c2_rate = 8287; + module->gain = 64; + break; + case 0x484e: /* xCHN */ + module->num_channels = data_u8( data, 1080 ) - 48; + module->c2_rate = 8363; + module->gain = 32; + break; + case 0x4348: /* xxCH */ + module->num_channels = ( data_u8( data, 1080 ) - 48 ) * 10; + module->num_channels += data_u8( data, 1081 ) - 48; + module->c2_rate = 8363; + module->gain = 32; + break; + default: + strcpy( message, "MOD Format not recognised!" ); + dispose_module( module ); + return NULL; + } + module->default_gvol = 64; + module->default_speed = 6; + module->default_tempo = 125; + module->default_panning = (unsigned char*)calloc( module->num_channels, sizeof( unsigned char ) ); + if( !module->default_panning ) { + dispose_module( module ); + return NULL; + } + for( idx = 0; idx < module->num_channels; idx++ ) { + module->default_panning[ idx ] = 51; + if( ( idx & 3 ) == 1 || ( idx & 3 ) == 2 ) { + module->default_panning[ idx ] = 204; + } + } + module_data_idx = 1084; + module->patterns = (struct pattern*)calloc( module->num_patterns, sizeof( struct pattern ) ); + if( !module->patterns ) { + dispose_module( module ); + return NULL; + } + pat_data_len = module->num_channels * 64 * 5; + for( pat = 0; pat < module->num_patterns; pat++ ) { + module->patterns[ pat ].num_channels = module->num_channels; + module->patterns[ pat ].num_rows = 64; + pattern_data = (char*)calloc( 1, pat_data_len ); + if( !pattern_data ) { + dispose_module( module ); + return NULL; + } + module->patterns[ pat ].data = pattern_data; + for( pat_data_idx = 0; pat_data_idx < pat_data_len; pat_data_idx += 5 ) { + period = ( data_u8( data, module_data_idx ) & 0xF ) << 8; + period = ( period | data_u8( data, module_data_idx + 1 ) ) * 4; + if( period >= 112 && period <= 6848 ) { + key = -12 * log_2( ( period << FP_SHIFT ) / 29021 ); + key = ( key + ( key & ( FP_ONE >> 1 ) ) ) >> FP_SHIFT; + pattern_data[ pat_data_idx ] = key; + } + ins = ( data_u8( data, module_data_idx + 2 ) & 0xF0 ) >> 4; + ins = ins | ( data_u8( data, module_data_idx ) & 0x10 ); + pattern_data[ pat_data_idx + 1 ] = ins; + effect = data_u8( data, module_data_idx + 2 ) & 0x0F; + param = data_u8( data, module_data_idx + 3 ); + if( param == 0 && ( effect < 3 || effect == 0xA ) ) { + effect = 0; + } + if( param == 0 && ( effect == 5 || effect == 6 ) ) { + effect -= 2; + } + if( effect == 8 && module->num_channels == 4 ) { + effect = param = 0; + } + pattern_data[ pat_data_idx + 3 ] = effect; + pattern_data[ pat_data_idx + 4 ] = param; + module_data_idx += 4; + } + } + module->num_instruments = 31; + module->instruments = (struct instrument*)calloc( module->num_instruments + 1, sizeof( struct instrument ) ); + if( !module->instruments ) { + dispose_module( module ); + return NULL; + } + instrument = &module->instruments[ 0 ]; + instrument->num_samples = 1; + instrument->samples = (struct sample*)calloc( 1, sizeof( struct sample ) ); + if( !instrument->samples ) { + dispose_module( module ); + return NULL; + } + for( ins = 1; ins <= module->num_instruments; ins++ ) { + instrument = &module->instruments[ ins ]; + instrument->num_samples = 1; + instrument->samples = (struct sample*)calloc( 1, sizeof( struct sample ) ); + if( !instrument->samples ) { + dispose_module( module ); + return NULL; + } + sample = &instrument->samples[ 0 ]; + data_ascii( data, ins * 30 - 10, 22, instrument->name ); + sample_length = data_u16be( data, ins * 30 + 12 ) * 2; + fine_tune = ( data_u8( data, ins * 30 + 14 ) & 0xF ) << 4; + sample->fine_tune = ( fine_tune & 0x7F ) - ( fine_tune & 0x80 ); + sample->volume = data_u8( data, ins * 30 + 15 ) & 0x7F; + if( sample->volume > 64 ) { + sample->volume = 64; + } + loop_start = data_u16be( data, ins * 30 + 16 ) * 2; + loop_length = data_u16be( data, ins * 30 + 18 ) * 2; + if( loop_start + loop_length > sample_length ) { + loop_length = sample_length - loop_start; + } + if( loop_length < 4 ) { + loop_start = sample_length; + loop_length = 0; + } + sample->loop_start = loop_start; + sample->loop_length = loop_length; + sample->data = (short*)calloc( sample_length + 1, sizeof( short ) ); + if( sample->data ) { + data_sam_s8( data, module_data_idx, sample_length, sample->data ); + sample->data[ loop_start + loop_length ] = sample->data[ loop_start ]; + } else { + dispose_module( module ); + return NULL; + } + module_data_idx += sample_length; + } + } + return module; +} + +/* Allocate and initialize a module from the specified data, returns NULL on error. + Message should point to a 64-character buffer to receive error messages. */ +struct module* module_load( struct data *data, char *message ) { + char ascii[ 16 ]; + struct module* module; + if( !memcmp( data_ascii( data, 0, 16, ascii ), "Extended Module:", 16 ) ) { + module = module_load_xm( data, message ); + } else if( !memcmp( data_ascii( data, 44, 4, ascii ), "SCRM", 4 ) ) { + module = module_load_s3m( data, message ); + } else { + module = module_load_mod( data, message ); + } + return module; +} + +static void pattern_get_note( struct pattern *pattern, int row, int chan, struct note *dest ) { + int offset = ( row * pattern->num_channels + chan ) * 5; + if( offset >= 0 && row < pattern->num_rows && chan < pattern->num_channels ) { + dest->key = pattern->data[ offset ]; + dest->instrument = pattern->data[ offset + 1 ]; + dest->volume = pattern->data[ offset + 2 ]; + dest->effect = pattern->data[ offset + 3 ]; + dest->param = pattern->data[ offset + 4 ]; + } else { + memset( dest, 0, sizeof( struct note ) ); + } +} + +static void channel_init( struct channel *channel, struct replay *replay, int idx ) { + memset( channel, 0, sizeof( struct channel ) ); + channel->replay = replay; + channel->id = idx; + channel->panning = replay->module->default_panning[ idx ]; + channel->instrument = &replay->module->instruments[ 0 ]; + channel->sample = &channel->instrument->samples[ 0 ]; + channel->random_seed = ( idx + 1 ) * 0xABCDEF; +} + +static void channel_volume_slide( struct channel *channel ) { + int up = channel->vol_slide_param >> 4; + int down = channel->vol_slide_param & 0xF; + if( down == 0xF && up > 0 ) { + /* Fine slide up.*/ + if( channel->fx_count == 0 ) { + channel->volume += up; + } + } else if( up == 0xF && down > 0 ) { + /* Fine slide down.*/ + if( channel->fx_count == 0 ) { + channel->volume -= down; + } + } else if( channel->fx_count > 0 || channel->replay->module->fast_vol_slides ) { + /* Normal.*/ + channel->volume += up - down; + } + if( channel->volume > 64 ) { + channel->volume = 64; + } + if( channel->volume < 0 ) { + channel->volume = 0; + } +} + +static void channel_porta_up( struct channel *channel, int param ) { + switch( param & 0xF0 ) { + case 0xE0: /* Extra-fine porta.*/ + if( channel->fx_count == 0 ) { + channel->period -= param & 0xF; + } + break; + case 0xF0: /* Fine porta.*/ + if( channel->fx_count == 0 ) { + channel->period -= ( param & 0xF ) << 2; + } + break; + default:/* Normal porta.*/ + if( channel->fx_count > 0 ) { + channel->period -= param << 2; + } + break; + } + if( channel->period < 0 ) { + channel->period = 0; + } +} + +static void channel_porta_down( struct channel *channel, int param ) { + if( channel->period > 0 ) { + switch( param & 0xF0 ) { + case 0xE0: /* Extra-fine porta.*/ + if( channel->fx_count == 0 ) { + channel->period += param & 0xF; + } + break; + case 0xF0: /* Fine porta.*/ + if( channel->fx_count == 0 ) { + channel->period += ( param & 0xF ) << 2; + } + break; + default:/* Normal porta.*/ + if( channel->fx_count > 0 ) { + channel->period += param << 2; + } + break; + } + if( channel->period > 65535 ) { + channel->period = 65535; + } + } +} + +static void channel_tone_porta( struct channel *channel ) { + if( channel->period > 0 ) { + if( channel->period < channel->porta_period ) { + channel->period += channel->tone_porta_param << 2; + if( channel->period > channel->porta_period ) { + channel->period = channel->porta_period; + } + } else { + channel->period -= channel->tone_porta_param << 2; + if( channel->period < channel->porta_period ) { + channel->period = channel->porta_period; + } + } + } +} + +static int channel_waveform( struct channel *channel, int phase, int type ) { + int amplitude = 0; + switch( type ) { + default: /* Sine. */ + amplitude = sine_table[ phase & 0x1F ]; + if( ( phase & 0x20 ) > 0 ) { + amplitude = -amplitude; + } + break; + case 6: /* Saw Up.*/ + amplitude = ( ( ( phase + 0x20 ) & 0x3F ) << 3 ) - 255; + break; + case 1: case 7: /* Saw Down. */ + amplitude = 255 - ( ( ( phase + 0x20 ) & 0x3F ) << 3 ); + break; + case 2: case 5: /* Square. */ + amplitude = ( phase & 0x20 ) > 0 ? 255 : -255; + break; + case 3: case 8: /* Random. */ + amplitude = ( channel->random_seed >> 20 ) - 255; + channel->random_seed = ( channel->random_seed * 65 + 17 ) & 0x1FFFFFFF; + break; + } + return amplitude; +} + +static void channel_vibrato( struct channel *channel, int fine ) { + int wave = channel_waveform( channel, channel->vibrato_phase, channel->vibrato_type & 0x3 ); + channel->vibrato_add = wave * channel->vibrato_depth >> ( fine ? 7 : 5 ); +} + +static void channel_tremolo( struct channel *channel ) { + int wave = channel_waveform( channel, channel->tremolo_phase, channel->tremolo_type & 0x3 ); + channel->tremolo_add = wave * channel->tremolo_depth >> 6; +} + +static void channel_tremor( struct channel *channel ) { + if( channel->retrig_count >= channel->tremor_on_ticks ) { + channel->tremolo_add = -64; + } + if( channel->retrig_count >= ( channel->tremor_on_ticks + channel->tremor_off_ticks ) ) { + channel->tremolo_add = channel->retrig_count = 0; + } +} + +static void channel_retrig_vol_slide( struct channel *channel ) { + if( channel->retrig_count >= channel->retrig_ticks ) { + channel->retrig_count = channel->sample_idx = channel->sample_fra = 0; + switch( channel->retrig_volume ) { + case 0x1: channel->volume = channel->volume - 1; break; + case 0x2: channel->volume = channel->volume - 2; break; + case 0x3: channel->volume = channel->volume - 4; break; + case 0x4: channel->volume = channel->volume - 8; break; + case 0x5: channel->volume = channel->volume - 16; break; + case 0x6: channel->volume = channel->volume * 2 / 3; break; + case 0x7: channel->volume = channel->volume >> 1; break; + case 0x8: /* ? */ break; + case 0x9: channel->volume = channel->volume + 1; break; + case 0xA: channel->volume = channel->volume + 2; break; + case 0xB: channel->volume = channel->volume + 4; break; + case 0xC: channel->volume = channel->volume + 8; break; + case 0xD: channel->volume = channel->volume + 16; break; + case 0xE: channel->volume = channel->volume * 3 / 2; break; + case 0xF: channel->volume = channel->volume << 1; break; + } + if( channel->volume < 0 ) { + channel->volume = 0; + } + if( channel->volume > 64 ) { + channel->volume = 64; + } + } +} + +static void channel_trigger( struct channel *channel ) { + int key, sam, porta, period, fine_tune, ins = channel->note.instrument; + struct sample *sample; + if( ins > 0 && ins <= channel->replay->module->num_instruments ) { + channel->instrument = &channel->replay->module->instruments[ ins ]; + key = channel->note.key < 97 ? channel->note.key : 0; + sam = channel->instrument->key_to_sample[ key ]; + sample = &channel->instrument->samples[ sam ]; + channel->volume = sample->volume >= 64 ? 64 : sample->volume & 0x3F; + if( sample->panning > 0 ) { + channel->panning = ( sample->panning - 1 ) & 0xFF; + } + if( channel->period > 0 && sample->loop_length > 1 ) { + /* Amiga trigger.*/ + channel->sample = sample; + } + channel->sample_off = 0; + channel->vol_env_tick = channel->pan_env_tick = 0; + channel->fadeout_vol = 32768; + channel->key_on = 1; + } + if( channel->note.effect == 0x09 || channel->note.effect == 0x8F ) { + /* Set Sample Offset. */ + if( channel->note.param > 0 ) { + channel->offset_param = channel->note.param; + } + channel->sample_off = channel->offset_param << 8; + } + if( channel->note.volume >= 0x10 && channel->note.volume < 0x60 ) { + channel->volume = channel->note.volume < 0x50 ? channel->note.volume - 0x10 : 64; + } + switch( channel->note.volume & 0xF0 ) { + case 0x80: /* Fine Vol Down.*/ + channel->volume -= channel->note.volume & 0xF; + if( channel->volume < 0 ) { + channel->volume = 0; + } + break; + case 0x90: /* Fine Vol Up.*/ + channel->volume += channel->note.volume & 0xF; + if( channel->volume > 64 ) { + channel->volume = 64; + } + break; + case 0xA0: /* Set Vibrato Speed.*/ + if( ( channel->note.volume & 0xF ) > 0 ) { + channel->vibrato_speed = channel->note.volume & 0xF; + } + break; + case 0xB0: /* Vibrato.*/ + if( ( channel->note.volume & 0xF ) > 0 ) { + channel->vibrato_depth = channel->note.volume & 0xF; + } + channel_vibrato( channel, 0 ); + break; + case 0xC0: /* Set Panning.*/ + channel->panning = ( channel->note.volume & 0xF ) * 17; + break; + case 0xF0: /* Tone Porta.*/ + if( ( channel->note.volume & 0xF ) > 0 ) { + channel->tone_porta_param = channel->note.volume & 0xF; + } + break; + } + if( channel->note.key > 0 ) { + if( channel->note.key > 96 ) { + channel->key_on = 0; + } else { + porta = ( channel->note.volume & 0xF0 ) == 0xF0 || + channel->note.effect == 0x03 || channel->note.effect == 0x05 || + channel->note.effect == 0x87 || channel->note.effect == 0x8C; + if( !porta ) { + ins = channel->instrument->key_to_sample[ channel->note.key ]; + channel->sample = &channel->instrument->samples[ ins ]; + } + fine_tune = channel->sample->fine_tune; + if( channel->note.effect == 0x75 || channel->note.effect == 0xF2 ) { + /* Set Fine Tune. */ + fine_tune = ( ( channel->note.param & 0xF ) << 4 ) - 128; + } + key = channel->note.key + channel->sample->rel_note; + if( key < 1 ) { + key = 1; + } + if( key > 120 ) { + key = 120; + } + period = ( key << 6 ) + ( fine_tune >> 1 ); + if( channel->replay->module->linear_periods ) { + channel->porta_period = 7744 - period; + } else { + channel->porta_period = 29021 * exp_2( ( period << FP_SHIFT ) / -768 ) >> FP_SHIFT; + } + if( !porta ) { + channel->period = channel->porta_period; + channel->sample_idx = channel->sample_off; + channel->sample_fra = 0; + if( channel->vibrato_type < 4 ) { + channel->vibrato_phase = 0; + } + if( channel->tremolo_type < 4 ) { + channel->tremolo_phase = 0; + } + channel->retrig_count = channel->av_count = 0; + } + } + } +} + +static void channel_update_envelopes( struct channel *channel ) { + if( channel->instrument->vol_env.enabled ) { + if( !channel->key_on ) { + channel->fadeout_vol -= channel->instrument->vol_fadeout; + if( channel->fadeout_vol < 0 ) { + channel->fadeout_vol = 0; + } + } + channel->vol_env_tick = envelope_next_tick( &channel->instrument->vol_env, + channel->vol_env_tick, channel->key_on ); + } + if( channel->instrument->pan_env.enabled ) { + channel->pan_env_tick = envelope_next_tick( &channel->instrument->pan_env, + channel->pan_env_tick, channel->key_on ); + } +} + +static void channel_auto_vibrato( struct channel *channel ) { + int sweep, rate, type, wave; + int depth = channel->instrument->vib_depth & 0x7F; + if( depth > 0 ) { + sweep = channel->instrument->vib_sweep & 0x7F; + rate = channel->instrument->vib_rate & 0x7F; + type = channel->instrument->vib_type; + if( channel->av_count < sweep ) { + depth = depth * channel->av_count / sweep; + } + wave = channel_waveform( channel, channel->av_count * rate >> 2, type + 4 ); + channel->vibrato_add += wave * depth >> 8; + channel->av_count++; + } +} + +static void channel_calculate_freq( struct channel *channel ) { + int per = channel->period + channel->vibrato_add; + if( channel->replay->module->linear_periods ) { + per = per - ( channel->arpeggio_add << 6 ); + if( per < 28 || per > 7680 ) { + per = 7680; + } + channel->freq = ( ( channel->replay->module->c2_rate >> 4 ) + * exp_2( ( ( 4608 - per ) << FP_SHIFT ) / 768 ) ) >> ( FP_SHIFT - 4 ); + } else { + if( per > 29021 ) { + per = 29021; + } + per = ( per << FP_SHIFT ) / exp_2( ( channel->arpeggio_add << FP_SHIFT ) / 12 ); + if( per < 28 ) { + per = 29021; + } + channel->freq = channel->replay->module->c2_rate * 1712 / per; + } +} + +static void channel_calculate_ampl( struct channel *channel ) { + int vol, range, env_pan = 32, env_vol = channel->key_on ? 64 : 0; + if( channel->instrument->vol_env.enabled ) { + env_vol = envelope_calculate_ampl( &channel->instrument->vol_env, channel->vol_env_tick ); + } + vol = channel->volume + channel->tremolo_add; + if( vol > 64 ) { + vol = 64; + } + if( vol < 0 ) { + vol = 0; + } + vol = ( vol * channel->replay->module->gain * FP_ONE ) >> 13; + vol = ( vol * channel->fadeout_vol ) >> 15; + channel->ampl = ( vol * channel->replay->global_vol * env_vol ) >> 12; + if( channel->instrument->pan_env.enabled ) { + env_pan = envelope_calculate_ampl( &channel->instrument->pan_env, channel->pan_env_tick ); + } + range = ( channel->panning < 128 ) ? channel->panning : ( 255 - channel->panning ); + channel->pann = channel->panning + ( range * ( env_pan - 32 ) >> 5 ); +} + +static void channel_tick( struct channel *channel ) { + channel->vibrato_add = 0; + channel->fx_count++; + channel->retrig_count++; + if( !( channel->note.effect == 0x7D && channel->fx_count <= channel->note.param ) ) { + switch( channel->note.volume & 0xF0 ) { + case 0x60: /* Vol Slide Down.*/ + channel->volume -= channel->note.volume & 0xF; + if( channel->volume < 0 ) { + channel->volume = 0; + } + break; + case 0x70: /* Vol Slide Up.*/ + channel->volume += channel->note.volume & 0xF; + if( channel->volume > 64 ) { + channel->volume = 64; + } + break; + case 0xB0: /* Vibrato.*/ + channel->vibrato_phase += channel->vibrato_speed; + channel_vibrato( channel, 0 ); + break; + case 0xD0: /* Pan Slide Left.*/ + channel->panning -= channel->note.volume & 0xF; + if( channel->panning < 0 ) { + channel->panning = 0; + } + break; + case 0xE0: /* Pan Slide Right.*/ + channel->panning += channel->note.volume & 0xF; + if( channel->panning > 255 ) { + channel->panning = 255; + } + break; + case 0xF0: /* Tone Porta.*/ + channel_tone_porta( channel ); + break; + } + } + switch( channel->note.effect ) { + case 0x01: case 0x86: /* Porta Up. */ + channel_porta_up( channel, channel->porta_up_param ); + break; + case 0x02: case 0x85: /* Porta Down. */ + channel_porta_down( channel, channel->porta_down_param ); + break; + case 0x03: case 0x87: /* Tone Porta. */ + channel_tone_porta( channel ); + break; + case 0x04: case 0x88: /* Vibrato. */ + channel->vibrato_phase += channel->vibrato_speed; + channel_vibrato( channel, 0 ); + break; + case 0x05: case 0x8C: /* Tone Porta + Vol Slide. */ + channel_tone_porta( channel ); + channel_volume_slide( channel ); + break; + case 0x06: case 0x8B: /* Vibrato + Vol Slide. */ + channel->vibrato_phase += channel->vibrato_speed; + channel_vibrato( channel, 0 ); + channel_volume_slide( channel ); + break; + case 0x07: case 0x92: /* Tremolo. */ + channel->tremolo_phase += channel->tremolo_speed; + channel_tremolo( channel ); + break; + case 0x0A: case 0x84: /* Vol Slide. */ + channel_volume_slide( channel ); + break; + case 0x11: /* Global Volume Slide. */ + channel->replay->global_vol = channel->replay->global_vol + + ( channel->gvol_slide_param >> 4 ) + - ( channel->gvol_slide_param & 0xF ); + if( channel->replay->global_vol < 0 ) { + channel->replay->global_vol = 0; + } + if( channel->replay->global_vol > 64 ) { + channel->replay->global_vol = 64; + } + break; + case 0x19: /* Panning Slide. */ + channel->panning = channel->panning + + ( channel->pan_slide_param >> 4 ) + - ( channel->pan_slide_param & 0xF ); + if( channel->panning < 0 ) { + channel->panning = 0; + } + if( channel->panning > 255 ) { + channel->panning = 255; + } + break; + case 0x1B: case 0x91: /* Retrig + Vol Slide. */ + channel_retrig_vol_slide( channel ); + break; + case 0x1D: case 0x89: /* Tremor. */ + channel_tremor( channel ); + break; + case 0x79: /* Retrig. */ + if( channel->fx_count >= channel->note.param ) { + channel->fx_count = 0; + channel->sample_idx = channel->sample_fra = 0; + } + break; + case 0x7C: case 0xFC: /* Note Cut. */ + if( channel->note.param == channel->fx_count ) { + channel->volume = 0; + } + break; + case 0x7D: case 0xFD: /* Note Delay. */ + if( channel->note.param == channel->fx_count ) { + channel_trigger( channel ); + } + break; + case 0x8A: /* Arpeggio. */ + if( channel->fx_count == 1 ) { + channel->arpeggio_add = channel->arpeggio_param >> 4; + } else if( channel->fx_count == 2 ) { + channel->arpeggio_add = channel->arpeggio_param & 0xF; + } else { + channel->arpeggio_add = channel->fx_count = 0; + } + break; + case 0x95: /* Fine Vibrato. */ + channel->vibrato_phase += channel->vibrato_speed; + channel_vibrato( channel, 1 ); + break; + } + channel_auto_vibrato( channel ); + channel_calculate_freq( channel ); + channel_calculate_ampl( channel ); + channel_update_envelopes( channel ); +} + +static void channel_row( struct channel *channel, struct note *note ) { + channel->note = *note; + channel->retrig_count++; + channel->vibrato_add = channel->tremolo_add = channel->arpeggio_add = channel->fx_count = 0; + if( !( ( note->effect == 0x7D || note->effect == 0xFD ) && note->param > 0 ) ) { + /* Not note delay.*/ + channel_trigger( channel ); + } + switch( channel->note.effect ) { + case 0x01: case 0x86: /* Porta Up. */ + if( channel->note.param > 0 ) { + channel->porta_up_param = channel->note.param; + } + channel_porta_up( channel, channel->porta_up_param ); + break; + case 0x02: case 0x85: /* Porta Down. */ + if( channel->note.param > 0 ) { + channel->porta_down_param = channel->note.param; + } + channel_porta_down( channel, channel->porta_down_param ); + break; + case 0x03: case 0x87: /* Tone Porta. */ + if( channel->note.param > 0 ) { + channel->tone_porta_param = channel->note.param; + } + break; + case 0x04: case 0x88: /* Vibrato. */ + if( ( channel->note.param >> 4 ) > 0 ) { + channel->vibrato_speed = channel->note.param >> 4; + } + if( ( channel->note.param & 0xF ) > 0 ) { + channel->vibrato_depth = channel->note.param & 0xF; + } + channel_vibrato( channel, 0 ); + break; + case 0x05: case 0x8C: /* Tone Porta + Vol Slide. */ + if( channel->note.param > 0 ) { + channel->vol_slide_param = channel->note.param; + } + channel_volume_slide( channel ); + break; + case 0x06: case 0x8B: /* Vibrato + Vol Slide. */ + if( channel->note.param > 0 ) { + channel->vol_slide_param = channel->note.param; + } + channel_vibrato( channel, 0 ); + channel_volume_slide( channel ); + break; + case 0x07: case 0x92: /* Tremolo. */ + if( ( channel->note.param >> 4 ) > 0 ) { + channel->tremolo_speed = channel->note.param >> 4; + } + if( ( channel->note.param & 0xF ) > 0 ) { + channel->tremolo_depth = channel->note.param & 0xF; + } + channel_tremolo( channel ); + break; + case 0x08: /* Set Panning.*/ + channel->panning = ( channel->note.param < 128 ) ? ( channel->note.param << 1 ) : 255; + break; + case 0x0A: case 0x84: /* Vol Slide. */ + if( channel->note.param > 0 ) { + channel->vol_slide_param = channel->note.param; + } + channel_volume_slide( channel ); + break; + case 0x0C: /* Set Volume. */ + channel->volume = channel->note.param >= 64 ? 64 : channel->note.param & 0x3F; + break; + case 0x10: case 0x96: /* Set Global Volume. */ + channel->replay->global_vol = channel->note.param >= 64 ? 64 : channel->note.param & 0x3F; + break; + case 0x11: /* Global Volume Slide. */ + if( channel->note.param > 0 ) { + channel->gvol_slide_param = channel->note.param; + } + break; + case 0x14: /* Key Off. */ + channel->key_on = 0; + break; + case 0x15: /* Set Envelope Tick. */ + channel->vol_env_tick = channel->pan_env_tick = channel->note.param & 0xFF; + break; + case 0x19: /* Panning Slide. */ + if( channel->note.param > 0 ) { + channel->pan_slide_param = channel->note.param; + } + break; + case 0x1B: case 0x91: /* Retrig + Vol Slide. */ + if( ( channel->note.param >> 4 ) > 0 ) { + channel->retrig_volume = channel->note.param >> 4; + } + if( ( channel->note.param & 0xF ) > 0 ) { + channel->retrig_ticks = channel->note.param & 0xF; + } + channel_retrig_vol_slide( channel ); + break; + case 0x1D: case 0x89: /* Tremor. */ + if( ( channel->note.param >> 4 ) > 0 ) { + channel->tremor_on_ticks = channel->note.param >> 4; + } + if( ( channel->note.param & 0xF ) > 0 ) { + channel->tremor_off_ticks = channel->note.param & 0xF; + } + channel_tremor( channel ); + break; + case 0x21: /* Extra Fine Porta. */ + if( channel->note.param > 0 ) { + channel->xfine_porta_param = channel->note.param; + } + switch( channel->xfine_porta_param & 0xF0 ) { + case 0x10: + channel_porta_up( channel, 0xE0 | ( channel->xfine_porta_param & 0xF ) ); + break; + case 0x20: + channel_porta_down( channel, 0xE0 | ( channel->xfine_porta_param & 0xF ) ); + break; + } + break; + case 0x71: /* Fine Porta Up. */ + if( channel->note.param > 0 ) { + channel->fine_porta_up_param = channel->note.param; + } + channel_porta_up( channel, 0xF0 | ( channel->fine_porta_up_param & 0xF ) ); + break; + case 0x72: /* Fine Porta Down. */ + if( channel->note.param > 0 ) { + channel->fine_porta_down_param = channel->note.param; + } + channel_porta_down( channel, 0xF0 | ( channel->fine_porta_down_param & 0xF ) ); + break; + case 0x74: case 0xF3: /* Set Vibrato Waveform. */ + if( channel->note.param < 8 ) { + channel->vibrato_type = channel->note.param; + } + break; + case 0x77: case 0xF4: /* Set Tremolo Waveform. */ + if( channel->note.param < 8 ) { + channel->tremolo_type = channel->note.param; + } + break; + case 0x7A: /* Fine Vol Slide Up. */ + if( channel->note.param > 0 ) { + channel->fine_vslide_up_param = channel->note.param; + } + channel->volume += channel->fine_vslide_up_param; + if( channel->volume > 64 ) { + channel->volume = 64; + } + break; + case 0x7B: /* Fine Vol Slide Down. */ + if( channel->note.param > 0 ) { + channel->fine_vslide_down_param = channel->note.param; + } + channel->volume -= channel->fine_vslide_down_param; + if( channel->volume < 0 ) { + channel->volume = 0; + } + break; + case 0x7C: case 0xFC: /* Note Cut. */ + if( channel->note.param <= 0 ) { + channel->volume = 0; + } + break; + case 0x8A: /* Arpeggio. */ + if( channel->note.param > 0 ) { + channel->arpeggio_param = channel->note.param; + } + break; + case 0x95: /* Fine Vibrato.*/ + if( ( channel->note.param >> 4 ) > 0 ) { + channel->vibrato_speed = channel->note.param >> 4; + } + if( ( channel->note.param & 0xF ) > 0 ) { + channel->vibrato_depth = channel->note.param & 0xF; + } + channel_vibrato( channel, 1 ); + break; + case 0xF8: /* Set Panning. */ + channel->panning = channel->note.param * 17; + break; + } + channel_auto_vibrato( channel ); + channel_calculate_freq( channel ); + channel_calculate_ampl( channel ); + channel_update_envelopes( channel ); +} + +static void channel_resample( struct channel *channel, int *mix_buf, + int offset, int count, int sample_rate, int interpolate ) { + struct sample *sample = channel->sample; + int l_gain, r_gain, sam_idx, sam_fra, step; + int loop_len, loop_end, out_idx, out_end, y, m, c; + short *sample_data = channel->sample->data; + if( channel->ampl > 0 ) { + l_gain = channel->ampl * ( 255 - channel->pann ) >> 8; + r_gain = channel->ampl * channel->pann >> 8; + sam_idx = channel->sample_idx; + sam_fra = channel->sample_fra; + step = ( channel->freq << ( FP_SHIFT - 3 ) ) / ( sample_rate >> 3 ); + loop_len = sample->loop_length; + loop_end = sample->loop_start + loop_len; + out_idx = offset * 2; + out_end = ( offset + count ) * 2; + if( interpolate ) { + while( out_idx < out_end ) { + if( sam_idx >= loop_end ) { + if( loop_len > 1 ) { + while( sam_idx >= loop_end ) { + sam_idx -= loop_len; + } + } else { + break; + } + } + c = sample_data[ sam_idx ]; + m = sample_data[ sam_idx + 1 ] - c; + y = ( ( m * sam_fra ) >> FP_SHIFT ) + c; + mix_buf[ out_idx++ ] += ( y * l_gain ) >> FP_SHIFT; + mix_buf[ out_idx++ ] += ( y * r_gain ) >> FP_SHIFT; + sam_fra += step; + sam_idx += sam_fra >> FP_SHIFT; + sam_fra &= FP_MASK; + } + } else { + while( out_idx < out_end ) { + if( sam_idx >= loop_end ) { + if( loop_len > 1 ) { + while( sam_idx >= loop_end ) { + sam_idx -= loop_len; + } + } else { + break; + } + } + y = sample_data[ sam_idx ]; + mix_buf[ out_idx++ ] += ( y * l_gain ) >> FP_SHIFT; + mix_buf[ out_idx++ ] += ( y * r_gain ) >> FP_SHIFT; + sam_fra += step; + sam_idx += sam_fra >> FP_SHIFT; + sam_fra &= FP_MASK; + } + } + } +} + +static void channel_update_sample_idx( struct channel *channel, int count, int sample_rate ) { + struct sample *sample = channel->sample; + int step = ( channel->freq << ( FP_SHIFT - 3 ) ) / ( sample_rate >> 3 ); + channel->sample_fra += step * count; + channel->sample_idx += channel->sample_fra >> FP_SHIFT; + if( channel->sample_idx > sample->loop_start ) { + if( sample->loop_length > 1 ) { + channel->sample_idx = sample->loop_start + + ( channel->sample_idx - sample->loop_start ) % sample->loop_length; + } else { + channel->sample_idx = sample->loop_start; + } + } + channel->sample_fra &= FP_MASK; +} + +static void replay_row( struct replay *replay ) { + int idx, count; + struct note note; + struct pattern *pattern; + struct channel *channel; + struct module *module = replay->module; + if( replay->next_row < 0 ) { + replay->break_pos = replay->seq_pos + 1; + replay->next_row = 0; + } + if( replay->break_pos >= 0 ) { + if( replay->break_pos >= module->sequence_len ) { + replay->break_pos = replay->next_row = 0; + } + while( module->sequence[ replay->break_pos ] >= module->num_patterns ) { + replay->break_pos++; + if( replay->break_pos >= module->sequence_len ) { + replay->break_pos = replay->next_row = 0; + } + } + replay->seq_pos = replay->break_pos; + for( idx = 0; idx < module->num_channels; idx++ ) { + replay->channels[ idx ].pl_row = 0; + } + replay->break_pos = -1; + } + pattern = &module->patterns[ module->sequence[ replay->seq_pos ] ]; + replay->row = replay->next_row; + if( replay->row >= pattern->num_rows ) { + replay->row = 0; + } + if( replay->play_count && replay->play_count[ 0 ] ) { + count = replay->play_count[ replay->seq_pos ][ replay->row ]; + if( replay->pl_count < 0 && count < 127 ) { + replay->play_count[ replay->seq_pos ][ replay->row ] = count + 1; + } + } + replay->next_row = replay->row + 1; + if( replay->next_row >= pattern->num_rows ) { + replay->next_row = -1; + } + for( idx = 0; idx < module->num_channels; idx++ ) { + channel = &replay->channels[ idx ]; + pattern_get_note( pattern, replay->row, idx, ¬e ); + if( note.effect == 0xE ) { + note.effect = 0x70 | ( note.param >> 4 ); + note.param &= 0xF; + } + if( note.effect == 0x93 ) { + note.effect = 0xF0 | ( note.param >> 4 ); + note.param &= 0xF; + } + if( note.effect == 0 && note.param > 0 ) { + note.effect = 0x8A; + } + channel_row( channel, ¬e ); + switch( note.effect ) { + case 0x81: /* Set Speed. */ + if( note.param > 0 ) { + replay->tick = replay->speed = note.param; + } + break; + case 0xB: case 0x82: /* Pattern Jump.*/ + if( replay->pl_count < 0 ) { + replay->break_pos = note.param; + replay->next_row = 0; + } + break; + case 0xD: case 0x83: /* Pattern Break.*/ + if( replay->pl_count < 0 ) { + if( replay->break_pos < 0 ) { + replay->break_pos = replay->seq_pos + 1; + } + replay->next_row = ( note.param >> 4 ) * 10 + ( note.param & 0xF ); + } + break; + case 0xF: /* Set Speed/Tempo.*/ + if( note.param > 0 ) { + if( note.param < 32 ) { + replay->tick = replay->speed = note.param; + } else { + replay->tempo = note.param; + } + } + break; + case 0x94: /* Set Tempo.*/ + if( note.param > 32 ) { + replay->tempo = note.param; + } + break; + case 0x76: case 0xFB : /* Pattern Loop.*/ + if( note.param == 0 ) { + /* Set loop marker on this channel. */ + channel->pl_row = replay->row; + } + if( channel->pl_row < replay->row && replay->break_pos < 0 ) { + /* Marker valid. */ + if( replay->pl_count < 0 ) { + /* Not already looping, begin. */ + replay->pl_count = note.param; + replay->pl_chan = idx; + } + if( replay->pl_chan == idx ) { + /* Next Loop.*/ + if( replay->pl_count == 0 ) { + /* Loop finished. Invalidate current marker. */ + channel->pl_row = replay->row + 1; + } else { + /* Loop. */ + replay->next_row = channel->pl_row; + } + replay->pl_count--; + } + } + break; + case 0x7E: case 0xFE: /* Pattern Delay.*/ + replay->tick = replay->speed + replay->speed * note.param; + break; + } + } +} + +static int replay_tick( struct replay *replay ) { + int idx, num_channels, count = 1; + if( --replay->tick <= 0 ) { + replay->tick = replay->speed; + replay_row( replay ); + } else { + num_channels = replay->module->num_channels; + for( idx = 0; idx < num_channels; idx++ ) { + channel_tick( &replay->channels[ idx ] ); + } + } + if( replay->play_count && replay->play_count[ 0 ] ) { + count = replay->play_count[ replay->seq_pos ][ replay->row ] - 1; + } + return count; +} + +static int module_init_play_count( struct module *module, char **play_count ) { + int idx, pat, rows, len = 0; + for( idx = 0; idx < module->sequence_len; idx++ ) { + pat = module->sequence[ idx ]; + rows = ( pat < module->num_patterns ) ? module->patterns[ pat ].num_rows : 0; + if( play_count ) { + play_count[ idx ] = play_count[ 0 ] ? &play_count[ 0 ][ len ] : NULL; + } + len += rows; + } + return len; +} + +/* Set the pattern in the sequence to play. The tempo is reset to the default. */ +void replay_set_sequence_pos( struct replay *replay, int pos ) { + int idx; + struct module *module = replay->module; + if( pos >= module->sequence_len ) { + pos = 0; + } + replay->break_pos = pos; + replay->next_row = 0; + replay->tick = 1; + replay->global_vol = module->default_gvol; + replay->speed = module->default_speed > 0 ? module->default_speed : 6; + replay->tempo = module->default_tempo > 0 ? module->default_tempo : 125; + replay->pl_count = replay->pl_chan = -1; + if( replay->play_count ) { + free( replay->play_count[ 0 ] ); + free( replay->play_count ); + } + replay->play_count = (char**)calloc( module->sequence_len, sizeof( char * ) ); + if( replay->play_count ) { + replay->play_count[ 0 ] = (char*)calloc( module_init_play_count( module, NULL ), sizeof( char ) ); + module_init_play_count( module, replay->play_count ); + } + for( idx = 0; idx < module->num_channels; idx++ ) { + channel_init( &replay->channels[ idx ], replay, idx ); + } + memset( replay->ramp_buf, 0, 128 * sizeof( int ) ); + replay_tick( replay ); +} + +/* Deallocate the specified replay. */ +void dispose_replay( struct replay *replay ) { + if( replay->play_count ) { + free( replay->play_count[ 0 ] ); + free( replay->play_count ); + } + free( replay->ramp_buf ); + free( replay->channels ); + free( replay ); +} + +/* Allocate and initialize a replay with the specified sampling rate and interpolation. */ +struct replay* new_replay( struct module *module, int sample_rate, int interpolation ) { + struct replay *replay = (struct replay*)calloc( 1, sizeof( struct replay ) ); + if( replay ) { + replay->module = module; + replay->sample_rate = sample_rate; + replay->interpolation = interpolation; + replay->ramp_buf = (int*)calloc( 128, sizeof( int ) ); + replay->channels = (struct channel*)calloc( module->num_channels, sizeof( struct channel ) ); + if( replay->ramp_buf && replay->channels ) { + replay_set_sequence_pos( replay, 0 ); + } else { + dispose_replay( replay ); + replay = NULL; + } + } + return replay; +} + +static int calculate_tick_len( int tempo, int sample_rate ) { + return ( sample_rate * 5 ) / ( tempo * 2 ); +} + +/* Returns the length of the output buffer required by replay_get_audio(). */ +int calculate_mix_buf_len( int sample_rate ) { + return ( calculate_tick_len( 32, sample_rate ) + 65 ) * 4; +} + +/* Returns the song duration in samples at the current sampling rate. */ +int replay_calculate_duration( struct replay *replay ) { + int count = 0, duration = 0; + replay_set_sequence_pos( replay, 0 ); + while( count < 1 ) { + duration += calculate_tick_len( replay->tempo, replay->sample_rate ); + count = replay_tick( replay ); + } + replay_set_sequence_pos( replay, 0 ); + return duration; +} + +/* Seek to approximately the specified sample position. + The actual sample position reached is returned. */ +int replay_seek( struct replay *replay, int sample_pos ) { + int idx, tick_len, current_pos = 0; + replay_set_sequence_pos( replay, 0 ); + tick_len = calculate_tick_len( replay->tempo, replay->sample_rate ); + while( ( sample_pos - current_pos ) >= tick_len ) { + for( idx = 0; idx < replay->module->num_channels; idx++ ) { + channel_update_sample_idx( &replay->channels[ idx ], + tick_len * 2, replay->sample_rate * 2 ); + } + current_pos += tick_len; + replay_tick( replay ); + tick_len = calculate_tick_len( replay->tempo, replay->sample_rate ); + } + return current_pos; +} + +static void replay_volume_ramp( struct replay *replay, int *mix_buf, int tick_len ) { + int idx, a1, a2, ramp_rate = 256 * 2048 / replay->sample_rate; + for( idx = 0, a1 = 0; a1 < 256; idx += 2, a1 += ramp_rate ) { + a2 = 256 - a1; + mix_buf[ idx ] = ( mix_buf[ idx ] * a1 + replay->ramp_buf[ idx ] * a2 ) >> 8; + mix_buf[ idx + 1 ] = ( mix_buf[ idx + 1 ] * a1 + replay->ramp_buf[ idx + 1 ] * a2 ) >> 8; + } + memcpy( replay->ramp_buf, &mix_buf[ tick_len * 2 ], 128 * sizeof( int ) ); +} + +/* 2:1 downsampling with simple but effective anti-aliasing. Buf must contain count * 2 + 1 stereo samples. */ +static void downsample( int *buf, int count ) { + int idx, out_idx, out_len = count * 2; + for( idx = 0, out_idx = 0; out_idx < out_len; idx += 4, out_idx += 2 ) { + buf[ out_idx ] = ( buf[ idx ] >> 2 ) + ( buf[ idx + 2 ] >> 1 ) + ( buf[ idx + 4 ] >> 2 ); + buf[ out_idx + 1 ] = ( buf[ idx + 1 ] >> 2 ) + ( buf[ idx + 3 ] >> 1 ) + ( buf[ idx + 5 ] >> 2 ); + } +} + +/* Generates audio and returns the number of stereo samples written into mix_buf. */ +int replay_get_audio( struct replay *replay, int *mix_buf ) { + struct channel *channel; + int idx, num_channels, tick_len = calculate_tick_len( replay->tempo, replay->sample_rate ); + /* Clear output buffer. */ + memset( mix_buf, 0, ( tick_len + 65 ) * 4 * sizeof( int ) ); + /* Resample. */ + num_channels = replay->module->num_channels; + for( idx = 0; idx < num_channels; idx++ ) { + channel = &replay->channels[ idx ]; + channel_resample( channel, mix_buf, 0, ( tick_len + 65 ) * 2, + replay->sample_rate * 2, replay->interpolation ); + channel_update_sample_idx( channel, tick_len * 2, replay->sample_rate * 2 ); + } + downsample( mix_buf, tick_len + 64 ); + replay_volume_ramp( replay, mix_buf, tick_len ); + replay_tick( replay ); + return tick_len; +} diff --git a/deps/libvita2d/source/vita2d_texture.c b/deps/libvita2d/source/vita2d_texture.c index 9d43071fb2..452bd4e51e 100644 --- a/deps/libvita2d/source/vita2d_texture.c +++ b/deps/libvita2d/source/vita2d_texture.c @@ -673,7 +673,7 @@ void vita2d_texture_set_tint_color_uniform(unsigned int color){ void vita2d_draw_texture_part_generic(const vita2d_texture *texture, SceGxmPrimitiveType type, vita2d_texture_vertex *vertices, unsigned int num_vertices) { - + uint16_t *indices = (uint16_t *)vita2d_pool_memalign( num_vertices * sizeof(uint16_t), // 4 indices sizeof(uint16_t)); diff --git a/deps/mbedtls/ecjpake.c b/deps/mbedtls/ecjpake.c index 1fa1c2d801..9218c5d172 100644 --- a/deps/mbedtls/ecjpake.c +++ b/deps/mbedtls/ecjpake.c @@ -299,7 +299,7 @@ cleanup: */ static int ecjpake_zkp_write( const mbedtls_md_info_t *md_info, const mbedtls_ecp_group *grp, - const int pf, + const int pf, const mbedtls_ecp_point *G, const mbedtls_mpi *x, const mbedtls_ecp_point *X, diff --git a/deps/mbedtls/mbedtls/ecp_internal.h b/deps/mbedtls/mbedtls/ecp_internal.h index 2991e26dd9..1a0fcd688c 100644 --- a/deps/mbedtls/mbedtls/ecp_internal.h +++ b/deps/mbedtls/mbedtls/ecp_internal.h @@ -47,7 +47,7 @@ * [6] Digital Signature Standard (DSS), FIPS 186-4. * * - * [7] Elliptic Curve Cryptography (ECC) Cipher Suites for Transport Layer + * [7] Elliptic Curve Cryptography (ECC) Cipher Suites for Transport Layer * Security (TLS), RFC 4492. * * diff --git a/deps/mbedtls/mbedtls/rsa.h b/deps/mbedtls/mbedtls/rsa.h index 7d7469d509..a1a804be4c 100644 --- a/deps/mbedtls/mbedtls/rsa.h +++ b/deps/mbedtls/mbedtls/rsa.h @@ -333,7 +333,7 @@ int mbedtls_rsa_rsaes_oaep_encrypt( mbedtls_rsa_context *ctx, * as large as the size ctx->len of ctx->N (eg. 128 bytes * if RSA-1024 is used) to be able to hold an arbitrary * decrypted message. If it is not large enough to hold - * the decryption of the particular ciphertext provided, + * the decryption of the particular ciphertext provided, * the function will return MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE. * * \note The input buffer must be as large as the size @@ -365,7 +365,7 @@ int mbedtls_rsa_pkcs1_decrypt( mbedtls_rsa_context *ctx, * as large as the size ctx->len of ctx->N (eg. 128 bytes * if RSA-1024 is used) to be able to hold an arbitrary * decrypted message. If it is not large enough to hold - * the decryption of the particular ciphertext provided, + * the decryption of the particular ciphertext provided, * the function will return MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE. * * \note The input buffer must be as large as the size @@ -399,10 +399,10 @@ int mbedtls_rsa_rsaes_pkcs1_v15_decrypt( mbedtls_rsa_context *ctx, * as large as the size ctx->len of ctx->N (eg. 128 bytes * if RSA-1024 is used) to be able to hold an arbitrary * decrypted message. If it is not large enough to hold - * the decryption of the particular ciphertext provided, + * the decryption of the particular ciphertext provided, * the function will return MBEDTLS_ERR_RSA_OUTPUT_TOO_LARGE. * - * \note The input buffer must be as large as the size + * \note The input buffer must be as large as the size * of ctx->N (eg. 128 bytes if RSA-1024 is used). */ int mbedtls_rsa_rsaes_oaep_decrypt( mbedtls_rsa_context *ctx, diff --git a/deps/mbedtls/mbedtls/ssl_ciphersuites.h b/deps/mbedtls/mbedtls/ssl_ciphersuites.h index 9101d9cc7c..8ef79fdad3 100644 --- a/deps/mbedtls/mbedtls/ssl_ciphersuites.h +++ b/deps/mbedtls/mbedtls/ssl_ciphersuites.h @@ -266,7 +266,7 @@ typedef enum { defined(MBEDTLS_KEY_EXCHANGE_ECDH_RSA_ENABLED) || \ defined(MBEDTLS_KEY_EXCHANGE_ECDHE_RSA_ENABLED) || \ defined(MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA_ENABLED) || \ - defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) + defined(MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA_ENABLED) #define MBEDTLS_KEY_EXCHANGE__CERT_REQ_ALLOWED__ENABLED #endif diff --git a/deps/mbedtls/ssl_cli.c b/deps/mbedtls/ssl_cli.c index a2b9f8cfe1..b73e416458 100644 --- a/deps/mbedtls/ssl_cli.c +++ b/deps/mbedtls/ssl_cli.c @@ -344,7 +344,7 @@ static void ssl_write_supported_point_formats_ext( mbedtls_ssl_context *ssl, *olen = 6; } -#endif /* MBEDTLS_ECDH_C || MBEDTLS_ECDSA_C || +#endif /* MBEDTLS_ECDH_C || MBEDTLS_ECDSA_C || MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */ #if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) @@ -1247,7 +1247,7 @@ static int ssl_parse_supported_point_formats_ext( mbedtls_ssl_context *ssl, MBEDTLS_SSL_ALERT_MSG_HANDSHAKE_FAILURE ); return( MBEDTLS_ERR_SSL_BAD_HS_SERVER_HELLO ); } -#endif /* MBEDTLS_ECDH_C || MBEDTLS_ECDSA_C || +#endif /* MBEDTLS_ECDH_C || MBEDTLS_ECDSA_C || MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED */ #if defined(MBEDTLS_KEY_EXCHANGE_ECJPAKE_ENABLED) diff --git a/deps/mbedtls/ssl_srv.c b/deps/mbedtls/ssl_srv.c index f137c3dce6..be961af710 100644 --- a/deps/mbedtls/ssl_srv.c +++ b/deps/mbedtls/ssl_srv.c @@ -785,7 +785,7 @@ static int ssl_ciphersuite_match( mbedtls_ssl_context *ssl, int suite_id, const mbedtls_ssl_ciphersuite_t *suite_info; #if defined(MBEDTLS_SSL_PROTO_TLS1_2) && \ - defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED) + defined(MBEDTLS_KEY_EXCHANGE__WITH_CERT__ENABLED) mbedtls_pk_type_t sig_type; #endif @@ -2955,7 +2955,7 @@ static int ssl_write_server_key_exchange( mbedtls_ssl_context *ssl ) return( ret ); } -#if defined(MBEDTLS_KEY_EXCHANGE__WITH_SERVER_SIGNATURE__ENABLED) +#if defined(MBEDTLS_KEY_EXCHANGE__WITH_SERVER_SIGNATURE__ENABLED) dig_signed = p; dig_signed_len = len; #endif @@ -3044,7 +3044,7 @@ curve_matching_done: /* * 3.1: Choose hash algorithm: - * A: For TLS 1.2, obey signature-hash-algorithm extension + * A: For TLS 1.2, obey signature-hash-algorithm extension * to choose appropriate hash. * B: For SSL3, TLS1.0, TLS1.1 and ECDHE_ECDSA, use SHA1 * (RFC 4492, Sec. 5.4) @@ -3065,7 +3065,7 @@ curve_matching_done: sig_alg ) ) == MBEDTLS_MD_NONE ) { MBEDTLS_SSL_DEBUG_MSG( 1, ( "should never happen" ) ); - /* (... because we choose a cipher suite + /* (... because we choose a cipher suite * only if there is a matching hash.) */ return( MBEDTLS_ERR_SSL_INTERNAL_ERROR ); } diff --git a/deps/mbedtls/x509_crt.c b/deps/mbedtls/x509_crt.c index a6dce95ba2..a2305beb2e 100644 --- a/deps/mbedtls/x509_crt.c +++ b/deps/mbedtls/x509_crt.c @@ -713,7 +713,7 @@ static int x509_crt_parse_der_core( mbedtls_x509_crt *crt, const unsigned char * memcpy( p, buf, crt->raw.len ); - // Direct pointers to the new buffer + // Direct pointers to the new buffer p += crt->raw.len - len; end = crt_end = p + len; diff --git a/deps/stb/stb_image.h b/deps/stb/stb_image.h index 3349700b81..323ce6df12 100644 --- a/deps/stb/stb_image.h +++ b/deps/stb/stb_image.h @@ -5158,7 +5158,7 @@ static stbi_uc *stbi__psd_load(stbi__context *s, int *x, int *y, int *comp, int // Else if n is 128, noop. // Endloop - /* The RLE-compressed data is preceeded by a 2-byte data count + /* The RLE-compressed data is preceeded by a 2-byte data count * for each row in the data, which we're going to just skip. */ stbi__skip(s, h * channelCount * 2 ); @@ -5948,7 +5948,7 @@ static float *stbi__hdr_load(stbi__context *s, int *x, int *y, int *comp, int re c2 = stbi__get8(s); len = stbi__get8(s); if (c1 != 2 || c2 != 2 || (len & 0x80)) { - /* not run-length encoded, so we have to + /* not run-length encoded, so we have to * actually use THIS data as a decoded * pixel (note this can't be a valid pixel * --one of RGB must be >= 128) */ diff --git a/deps/stb/stb_rect_pack.h b/deps/stb/stb_rect_pack.h index f31258adb9..6c658de33e 100644 --- a/deps/stb/stb_rect_pack.h +++ b/deps/stb/stb_rect_pack.h @@ -245,7 +245,7 @@ STBRP_DEF void stbrp_init_target(stbrp_context *context, int width, int height, context->num_nodes = num_nodes; stbrp_setup_allow_out_of_mem(context, 0); - /* node 0 is the full width, + /* node 0 is the full width, * node 1 is the sentinel (lets us not store width explicitly) */ context->extra[0].x = 0; context->extra[0].y = 0; @@ -268,7 +268,7 @@ static int stbrp__skyline_find_min_y(stbrp_context *c, int x1 = x0 + width; STBRP_ASSERT(first->x <= x0); - STBRP_ASSERT(node->next->x > x0); + STBRP_ASSERT(node->next->x > x0); STBRP_ASSERT(node->x <= x0); min_y = 0; @@ -417,7 +417,7 @@ static stbrp__findresult stbrp__skyline_find_best_pos(stbrp_context *c, int widt } } tail = tail->next; - } + } } fr.prev_link = best; diff --git a/deps/stb/stb_truetype.h b/deps/stb/stb_truetype.h index ba3dd5acc0..4e1b8a97e7 100644 --- a/deps/stb/stb_truetype.h +++ b/deps/stb/stb_truetype.h @@ -26,7 +26,7 @@ * "Zer" on mollyrocket (with fix) * Cass Everitt * stoiko (Haemimont Games) - * Brian Hook + * Brian Hook * Walter van Niftrik * David Gow * David Given @@ -230,7 +230,7 @@ * Curve tesselation 120 LOC \__ 550 LOC Bitmap creation * Bitmap management 100 LOC / * Baked bitmap interface 70 LOC / - * Font name matching & access 150 LOC ---- 150 + * Font name matching & access 150 LOC ---- 150 * C runtime library abstraction 60 LOC ---- 60 * * @@ -566,10 +566,10 @@ enum }; #endif -#ifndef stbtt_vertex +#ifndef stbtt_vertex /* can't use stbtt_int16 because that's not visible in the header file */ -#define stbtt_vertex_type short +#define stbtt_vertex_type short typedef struct { @@ -944,7 +944,7 @@ STBTT_DEF int stbtt_InitFont(stbtt_fontinfo *info, const unsigned char *data2, i stbtt_uint32 encoding_record = cmap + 4 + 8 * i; /* find an encoding we understand: */ - + switch(ttUSHORT(data+encoding_record)) { case STBTT_PLATFORM_ID_MICROSOFT: @@ -1273,7 +1273,7 @@ STBTT_DEF int stbtt_GetGlyphShape(const stbtt_fontinfo *info, int glyph_index, s if (start_off) { - /* if we start off with an off-curve point, + /* if we start off with an off-curve point, * then when we need to find a point on the curve * where we can start, and we need to save some state for when we wraparound. */ scx = x; @@ -1555,7 +1555,7 @@ STBTT_DEF void stbtt_GetGlyphBitmapBoxSubpixel(const stbtt_fontinfo *font, } else { - /* move to integral bboxes + /* move to integral bboxes * (treating pixels as little squares, what pixels get touched)? */ if (ix0) *ix0 = STBTT_ifloor( x0 * scale_x + shift_x); if (iy0) *iy0 = STBTT_ifloor(-y1 * scale_y + shift_y); @@ -1667,7 +1667,7 @@ static stbtt__active_edge *stbtt__new_active(stbtt__hheap *hh, stbtt__edge *e, i stbtt__active_edge *z = (stbtt__active_edge *) stbtt__hheap_alloc(hh, sizeof(*z), userdata); float dxdy = (e->x1 - e->x0) / (e->y1 - e->y0); if (!z) return z; - + /* round dx down to avoid overshooting */ if (dxdy < 0) z->dx = -STBTT_ifloor(STBTT_FIX * -dxdy); @@ -1750,7 +1750,7 @@ static void stbtt__fill_active_edges(unsigned char *scanline, int len, stbtt__ac } } } - + e = e->next; } } @@ -2092,7 +2092,7 @@ static void stbtt__rasterize_sorted_edges(stbtt__bitmap *result, stbtt__edge *e, memset(scanline2, 0, (result->w+1)*sizeof(scanline[0])); /* update all active edges, - * remove all active edges that terminate + * remove all active edges that terminate * before the top of this scanline */ while (*step) { stbtt__active_edge * z = *step; @@ -2306,7 +2306,7 @@ static void stbtt__rasterize(stbtt__bitmap *result, stbtt__point *pts, int *wcou /* now sort the edges by their highest point (should snap to integer, and then by x) */ stbtt__sort_edges(e, n); - /* now, traverse the scanlines and find the + /* now, traverse the scanlines and find the * intersections on each scanline, use XOR winding rule */ stbtt__rasterize_sorted_edges(result, e, n, vsubsample, off_x, off_y, userdata); @@ -2449,7 +2449,7 @@ STBTT_DEF unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info { int ix0,iy0,ix1,iy1; stbtt__bitmap gbm; - stbtt_vertex *vertices; + stbtt_vertex *vertices; int num_verts = stbtt_GetGlyphShape(info, glyph, &vertices); if (scale_x == 0) scale_x = scale_y; @@ -2471,7 +2471,7 @@ STBTT_DEF unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info if (height) *height = gbm.h; if (xoff ) *xoff = ix0; if (yoff ) *yoff = iy0; - + if (gbm.w && gbm.h) { gbm.pixels = (unsigned char *)malloc(gbm.w * gbm.h); @@ -2485,7 +2485,7 @@ STBTT_DEF unsigned char *stbtt_GetGlyphBitmapSubpixel(const stbtt_fontinfo *info free(vertices); return gbm.pixels; -} +} STBTT_DEF unsigned char *stbtt_GetGlyphBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int glyph, int *width, int *height, int *xoff, int *yoff) @@ -2500,7 +2500,7 @@ STBTT_DEF void stbtt_MakeGlyphBitmapSubpixel(const stbtt_fontinfo *info, unsigne int ix0,iy0; stbtt_vertex *vertices; int num_verts = stbtt_GetGlyphShape(info, glyph, &vertices); - stbtt__bitmap gbm; + stbtt__bitmap gbm; stbtt_GetGlyphBitmapBoxSubpixel(info, glyph, scale_x, scale_y, shift_x, shift_y, &ix0,&iy0,0,0); gbm.pixels = output; @@ -2526,7 +2526,7 @@ STBTT_DEF unsigned char *stbtt_GetCodepointBitmapSubpixel(const stbtt_fontinfo * { return stbtt_GetGlyphBitmapSubpixel(info, scale_x, scale_y,shift_x,shift_y, stbtt_FindGlyphIndex(info,codepoint), width,height,xoff,yoff); -} +} STBTT_DEF void stbtt_MakeCodepointBitmapSubpixel(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, int out_stride, float scale_x, float scale_y, @@ -2539,7 +2539,7 @@ STBTT_DEF void stbtt_MakeCodepointBitmapSubpixel(const stbtt_fontinfo *info, uns STBTT_DEF unsigned char *stbtt_GetCodepointBitmap(const stbtt_fontinfo *info, float scale_x, float scale_y, int codepoint, int *width, int *height, int *xoff, int *yoff) { return stbtt_GetCodepointBitmapSubpixel(info, scale_x, scale_y, 0.0f,0.0f, codepoint, width,height,xoff,yoff); -} +} STBTT_DEF void stbtt_MakeCodepointBitmap(const stbtt_fontinfo *info, unsigned char *output, int out_w, int out_h, @@ -2667,7 +2667,7 @@ static void stbrp_init_target(stbrp_context *con, int pw, int ph, con->y = 0; con->bottom_y = 0; STBTT__NOTUSED(nodes); - STBTT__NOTUSED(num_nodes); + STBTT__NOTUSED(num_nodes); } static void stbrp_pack_rects(stbrp_context *con, @@ -2772,7 +2772,7 @@ static void stbtt__h_prefilter(unsigned char *pixels, int w, int h, total = 0; - /* make kernel_width a constant in common cases + /* make kernel_width a constant in common cases * so compiler can optimize out the divide */ switch (kernel_width) { case 2: @@ -2912,7 +2912,7 @@ STBTT_DEF int stbtt_PackFontRanges(stbtt_pack_context *spc, unsigned char *fontd n = 0; for (i=0; i < num_ranges; ++i) n += ranges[i].num_chars_in_range; - + rects = (stbrp_rect *)malloc(sizeof(*rects) * n); if (rects == NULL) return 0; @@ -3045,7 +3045,7 @@ STBTT_DEF void stbtt_GetPackedQuad(stbtt_packedchar *chardata, int pw, /* font name matching -- recommended not to use this */ /* check if a UTF8 string contains a prefix which is the UTF16 string; if so return length of matching UTF8 string */ -static stbtt_int32 stbtt__CompareUTF8toUTF16_bigendian_prefix(const stbtt_uint8 *s1, stbtt_int32 len1, const stbtt_uint8 *s2, stbtt_int32 len2) +static stbtt_int32 stbtt__CompareUTF8toUTF16_bigendian_prefix(const stbtt_uint8 *s1, stbtt_int32 len1, const stbtt_uint8 *s2, stbtt_int32 len2) { stbtt_int32 i=0; @@ -3091,7 +3091,7 @@ static stbtt_int32 stbtt__CompareUTF8toUTF16_bigendian_prefix(const stbtt_uint8 return i; } -STBTT_DEF int stbtt_CompareUTF8toUTF16_bigendian(const char *s1, int len1, const char *s2, int len2) +STBTT_DEF int stbtt_CompareUTF8toUTF16_bigendian(const char *s1, int len1, const char *s2, int len2) { return len1 == stbtt__CompareUTF8toUTF16_bigendian_prefix((const stbtt_uint8*) s1, len1, (const stbtt_uint8*) s2, len2); } @@ -3150,8 +3150,8 @@ static int stbtt__matchpair(stbtt_uint8 *fc, stbtt_uint32 nm, stbtt_uint8 *name, if (matchlen >= 0) { /* check for target_id+1 immediately following, with same encoding & language */ - if (i+1 < count && ttUSHORT(fc+loc+12+6) == next_id - && ttUSHORT(fc+loc+12) == platform && ttUSHORT(fc+loc+12+2) == encoding + if (i+1 < count && ttUSHORT(fc+loc+12+6) == next_id + && ttUSHORT(fc+loc+12) == platform && ttUSHORT(fc+loc+12+2) == encoding && ttUSHORT(fc+loc+12+4) == language) { slen = ttUSHORT(fc+loc+12+8); diff --git a/deps/stb/stb_vorbis.h b/deps/stb/stb_vorbis.h index f662695711..6adaff4940 100644 --- a/deps/stb/stb_vorbis.h +++ b/deps/stb/stb_vorbis.h @@ -426,7 +426,7 @@ struct stb_vorbis int current_loc_valid; /* per-blocksize precomputed data */ - + /* twiddle factors */ float *A[2],*B[2],*C[2]; float *window[2]; @@ -737,7 +737,7 @@ static void compute_sorted_huffman(Codebook *c, uint8_t *lengths, uint32_t *valu if (!c->sparse) { int k = 0; for (i=0; i < c->entries; ++i) - if (include_in_sort(c, lengths[i])) + if (include_in_sort(c, lengths[i])) c->sorted_codewords[k++] = bit_reverse(c->codewords[i]); assert(k == c->sorted_entries); } else { @@ -943,7 +943,7 @@ static int start_page_no_capturepattern(vorb *f) /* header flag */ f->page_flag = get8(f); /* absolute granule position */ - loc0 = get32(f); + loc0 = get32(f); loc1 = get32(f); /* @TODO: validate loc0,loc1 as valid positions? * stream serial number -- vorbis doesn't interleave, so discard */ @@ -1437,69 +1437,69 @@ static int predict_point(int x, int x0, int x1, int y0, int y1) /* the following table is block-copied from the specification */ static float inverse_db_table[256] = { - 1.0649863e-07f, 1.1341951e-07f, 1.2079015e-07f, 1.2863978e-07f, - 1.3699951e-07f, 1.4590251e-07f, 1.5538408e-07f, 1.6548181e-07f, - 1.7623575e-07f, 1.8768855e-07f, 1.9988561e-07f, 2.1287530e-07f, - 2.2670913e-07f, 2.4144197e-07f, 2.5713223e-07f, 2.7384213e-07f, - 2.9163793e-07f, 3.1059021e-07f, 3.3077411e-07f, 3.5226968e-07f, - 3.7516214e-07f, 3.9954229e-07f, 4.2550680e-07f, 4.5315863e-07f, - 4.8260743e-07f, 5.1396998e-07f, 5.4737065e-07f, 5.8294187e-07f, - 6.2082472e-07f, 6.6116941e-07f, 7.0413592e-07f, 7.4989464e-07f, - 7.9862701e-07f, 8.5052630e-07f, 9.0579828e-07f, 9.6466216e-07f, - 1.0273513e-06f, 1.0941144e-06f, 1.1652161e-06f, 1.2409384e-06f, - 1.3215816e-06f, 1.4074654e-06f, 1.4989305e-06f, 1.5963394e-06f, - 1.7000785e-06f, 1.8105592e-06f, 1.9282195e-06f, 2.0535261e-06f, - 2.1869758e-06f, 2.3290978e-06f, 2.4804557e-06f, 2.6416497e-06f, - 2.8133190e-06f, 2.9961443e-06f, 3.1908506e-06f, 3.3982101e-06f, - 3.6190449e-06f, 3.8542308e-06f, 4.1047004e-06f, 4.3714470e-06f, - 4.6555282e-06f, 4.9580707e-06f, 5.2802740e-06f, 5.6234160e-06f, - 5.9888572e-06f, 6.3780469e-06f, 6.7925283e-06f, 7.2339451e-06f, - 7.7040476e-06f, 8.2047000e-06f, 8.7378876e-06f, 9.3057248e-06f, - 9.9104632e-06f, 1.0554501e-05f, 1.1240392e-05f, 1.1970856e-05f, - 1.2748789e-05f, 1.3577278e-05f, 1.4459606e-05f, 1.5399272e-05f, - 1.6400004e-05f, 1.7465768e-05f, 1.8600792e-05f, 1.9809576e-05f, - 2.1096914e-05f, 2.2467911e-05f, 2.3928002e-05f, 2.5482978e-05f, - 2.7139006e-05f, 2.8902651e-05f, 3.0780908e-05f, 3.2781225e-05f, - 3.4911534e-05f, 3.7180282e-05f, 3.9596466e-05f, 4.2169667e-05f, - 4.4910090e-05f, 4.7828601e-05f, 5.0936773e-05f, 5.4246931e-05f, - 5.7772202e-05f, 6.1526565e-05f, 6.5524908e-05f, 6.9783085e-05f, - 7.4317983e-05f, 7.9147585e-05f, 8.4291040e-05f, 8.9768747e-05f, - 9.5602426e-05f, 0.00010181521f, 0.00010843174f, 0.00011547824f, - 0.00012298267f, 0.00013097477f, 0.00013948625f, 0.00014855085f, - 0.00015820453f, 0.00016848555f, 0.00017943469f, 0.00019109536f, - 0.00020351382f, 0.00021673929f, 0.00023082423f, 0.00024582449f, - 0.00026179955f, 0.00027881276f, 0.00029693158f, 0.00031622787f, - 0.00033677814f, 0.00035866388f, 0.00038197188f, 0.00040679456f, - 0.00043323036f, 0.00046138411f, 0.00049136745f, 0.00052329927f, - 0.00055730621f, 0.00059352311f, 0.00063209358f, 0.00067317058f, - 0.00071691700f, 0.00076350630f, 0.00081312324f, 0.00086596457f, - 0.00092223983f, 0.00098217216f, 0.0010459992f, 0.0011139742f, - 0.0011863665f, 0.0012634633f, 0.0013455702f, 0.0014330129f, - 0.0015261382f, 0.0016253153f, 0.0017309374f, 0.0018434235f, - 0.0019632195f, 0.0020908006f, 0.0022266726f, 0.0023713743f, - 0.0025254795f, 0.0026895994f, 0.0028643847f, 0.0030505286f, - 0.0032487691f, 0.0034598925f, 0.0036847358f, 0.0039241906f, - 0.0041792066f, 0.0044507950f, 0.0047400328f, 0.0050480668f, - 0.0053761186f, 0.0057254891f, 0.0060975636f, 0.0064938176f, - 0.0069158225f, 0.0073652516f, 0.0078438871f, 0.0083536271f, - 0.0088964928f, 0.009474637f, 0.010090352f, 0.010746080f, - 0.011444421f, 0.012188144f, 0.012980198f, 0.013823725f, - 0.014722068f, 0.015678791f, 0.016697687f, 0.017782797f, - 0.018938423f, 0.020169149f, 0.021479854f, 0.022875735f, - 0.024362330f, 0.025945531f, 0.027631618f, 0.029427276f, - 0.031339626f, 0.033376252f, 0.035545228f, 0.037855157f, - 0.040315199f, 0.042935108f, 0.045725273f, 0.048696758f, - 0.051861348f, 0.055231591f, 0.058820850f, 0.062643361f, - 0.066714279f, 0.071049749f, 0.075666962f, 0.080584227f, - 0.085821044f, 0.091398179f, 0.097337747f, 0.10366330f, - 0.11039993f, 0.11757434f, 0.12521498f, 0.13335215f, - 0.14201813f, 0.15124727f, 0.16107617f, 0.17154380f, - 0.18269168f, 0.19456402f, 0.20720788f, 0.22067342f, - 0.23501402f, 0.25028656f, 0.26655159f, 0.28387361f, - 0.30232132f, 0.32196786f, 0.34289114f, 0.36517414f, - 0.38890521f, 0.41417847f, 0.44109412f, 0.46975890f, - 0.50028648f, 0.53279791f, 0.56742212f, 0.60429640f, - 0.64356699f, 0.68538959f, 0.72993007f, 0.77736504f, + 1.0649863e-07f, 1.1341951e-07f, 1.2079015e-07f, 1.2863978e-07f, + 1.3699951e-07f, 1.4590251e-07f, 1.5538408e-07f, 1.6548181e-07f, + 1.7623575e-07f, 1.8768855e-07f, 1.9988561e-07f, 2.1287530e-07f, + 2.2670913e-07f, 2.4144197e-07f, 2.5713223e-07f, 2.7384213e-07f, + 2.9163793e-07f, 3.1059021e-07f, 3.3077411e-07f, 3.5226968e-07f, + 3.7516214e-07f, 3.9954229e-07f, 4.2550680e-07f, 4.5315863e-07f, + 4.8260743e-07f, 5.1396998e-07f, 5.4737065e-07f, 5.8294187e-07f, + 6.2082472e-07f, 6.6116941e-07f, 7.0413592e-07f, 7.4989464e-07f, + 7.9862701e-07f, 8.5052630e-07f, 9.0579828e-07f, 9.6466216e-07f, + 1.0273513e-06f, 1.0941144e-06f, 1.1652161e-06f, 1.2409384e-06f, + 1.3215816e-06f, 1.4074654e-06f, 1.4989305e-06f, 1.5963394e-06f, + 1.7000785e-06f, 1.8105592e-06f, 1.9282195e-06f, 2.0535261e-06f, + 2.1869758e-06f, 2.3290978e-06f, 2.4804557e-06f, 2.6416497e-06f, + 2.8133190e-06f, 2.9961443e-06f, 3.1908506e-06f, 3.3982101e-06f, + 3.6190449e-06f, 3.8542308e-06f, 4.1047004e-06f, 4.3714470e-06f, + 4.6555282e-06f, 4.9580707e-06f, 5.2802740e-06f, 5.6234160e-06f, + 5.9888572e-06f, 6.3780469e-06f, 6.7925283e-06f, 7.2339451e-06f, + 7.7040476e-06f, 8.2047000e-06f, 8.7378876e-06f, 9.3057248e-06f, + 9.9104632e-06f, 1.0554501e-05f, 1.1240392e-05f, 1.1970856e-05f, + 1.2748789e-05f, 1.3577278e-05f, 1.4459606e-05f, 1.5399272e-05f, + 1.6400004e-05f, 1.7465768e-05f, 1.8600792e-05f, 1.9809576e-05f, + 2.1096914e-05f, 2.2467911e-05f, 2.3928002e-05f, 2.5482978e-05f, + 2.7139006e-05f, 2.8902651e-05f, 3.0780908e-05f, 3.2781225e-05f, + 3.4911534e-05f, 3.7180282e-05f, 3.9596466e-05f, 4.2169667e-05f, + 4.4910090e-05f, 4.7828601e-05f, 5.0936773e-05f, 5.4246931e-05f, + 5.7772202e-05f, 6.1526565e-05f, 6.5524908e-05f, 6.9783085e-05f, + 7.4317983e-05f, 7.9147585e-05f, 8.4291040e-05f, 8.9768747e-05f, + 9.5602426e-05f, 0.00010181521f, 0.00010843174f, 0.00011547824f, + 0.00012298267f, 0.00013097477f, 0.00013948625f, 0.00014855085f, + 0.00015820453f, 0.00016848555f, 0.00017943469f, 0.00019109536f, + 0.00020351382f, 0.00021673929f, 0.00023082423f, 0.00024582449f, + 0.00026179955f, 0.00027881276f, 0.00029693158f, 0.00031622787f, + 0.00033677814f, 0.00035866388f, 0.00038197188f, 0.00040679456f, + 0.00043323036f, 0.00046138411f, 0.00049136745f, 0.00052329927f, + 0.00055730621f, 0.00059352311f, 0.00063209358f, 0.00067317058f, + 0.00071691700f, 0.00076350630f, 0.00081312324f, 0.00086596457f, + 0.00092223983f, 0.00098217216f, 0.0010459992f, 0.0011139742f, + 0.0011863665f, 0.0012634633f, 0.0013455702f, 0.0014330129f, + 0.0015261382f, 0.0016253153f, 0.0017309374f, 0.0018434235f, + 0.0019632195f, 0.0020908006f, 0.0022266726f, 0.0023713743f, + 0.0025254795f, 0.0026895994f, 0.0028643847f, 0.0030505286f, + 0.0032487691f, 0.0034598925f, 0.0036847358f, 0.0039241906f, + 0.0041792066f, 0.0044507950f, 0.0047400328f, 0.0050480668f, + 0.0053761186f, 0.0057254891f, 0.0060975636f, 0.0064938176f, + 0.0069158225f, 0.0073652516f, 0.0078438871f, 0.0083536271f, + 0.0088964928f, 0.009474637f, 0.010090352f, 0.010746080f, + 0.011444421f, 0.012188144f, 0.012980198f, 0.013823725f, + 0.014722068f, 0.015678791f, 0.016697687f, 0.017782797f, + 0.018938423f, 0.020169149f, 0.021479854f, 0.022875735f, + 0.024362330f, 0.025945531f, 0.027631618f, 0.029427276f, + 0.031339626f, 0.033376252f, 0.035545228f, 0.037855157f, + 0.040315199f, 0.042935108f, 0.045725273f, 0.048696758f, + 0.051861348f, 0.055231591f, 0.058820850f, 0.062643361f, + 0.066714279f, 0.071049749f, 0.075666962f, 0.080584227f, + 0.085821044f, 0.091398179f, 0.097337747f, 0.10366330f, + 0.11039993f, 0.11757434f, 0.12521498f, 0.13335215f, + 0.14201813f, 0.15124727f, 0.16107617f, 0.17154380f, + 0.18269168f, 0.19456402f, 0.20720788f, 0.22067342f, + 0.23501402f, 0.25028656f, 0.26655159f, 0.28387361f, + 0.30232132f, 0.32196786f, 0.34289114f, 0.36517414f, + 0.38890521f, 0.41417847f, 0.44109412f, 0.46975890f, + 0.50028648f, 0.53279791f, 0.56742212f, 0.60429640f, + 0.64356699f, 0.68538959f, 0.72993007f, 0.77736504f, 0.82788260f, 0.88168307f, 0.9389798f, 1.0f }; @@ -1719,11 +1719,11 @@ static void decode_residue(vorb *f, float *residue_buffers[], int ch, int n, int #if LIBVORBIS_MDCT /* directly call the vorbis MDCT using an interface documented * by Jeff Roberts... useful for performance comparison */ -typedef struct +typedef struct { int n; int log2n; - + float *trig; int *bitrev; @@ -1742,7 +1742,7 @@ void inverse_mdct(float *buffer, int n, vorb *f, int blocktype) if (M1.n == n) M = &M1; else if (M2.n == n) M = &M2; else if (M1.n == 0) { mdct_init(&M1, n); M = &M1; } - else { + else { if (M2.n) __asm int 3; mdct_init(&M2, n); M = &M2; @@ -2157,7 +2157,7 @@ static void inverse_mdct(float *buffer, int n, vorb *f, int blocktype) d1[0] = u[k4+1]; d0[1] = u[k4+2]; d0[0] = u[k4+3]; - + d0 -= 4; d1 -= 4; bitrev += 2; @@ -2239,7 +2239,7 @@ static void inverse_mdct(float *buffer, int n, vorb *f, int blocktype) float p0,p1,p2,p3; p3 = e[6]*B[7] - e[7]*B[6]; - p2 = -e[6]*B[6] - e[7]*B[7]; + p2 = -e[6]*B[6] - e[7]*B[7]; d0[0] = p3; d1[3] = - p3; @@ -2247,7 +2247,7 @@ static void inverse_mdct(float *buffer, int n, vorb *f, int blocktype) d3[3] = p2; p1 = e[4]*B[5] - e[5]*B[4]; - p0 = -e[4]*B[4] - e[5]*B[5]; + p0 = -e[4]*B[4] - e[5]*B[5]; d0[1] = p1; d1[2] = - p1; @@ -2255,7 +2255,7 @@ static void inverse_mdct(float *buffer, int n, vorb *f, int blocktype) d3[2] = p0; p3 = e[2]*B[3] - e[3]*B[2]; - p2 = -e[2]*B[2] - e[3]*B[3]; + p2 = -e[2]*B[2] - e[3]*B[3]; d0[2] = p3; d1[1] = - p3; @@ -2263,7 +2263,7 @@ static void inverse_mdct(float *buffer, int n, vorb *f, int blocktype) d3[1] = p2; p1 = e[0]*B[1] - e[1]*B[0]; - p0 = -e[0]*B[0] - e[1]*B[1]; + p0 = -e[0]*B[0] - e[1]*B[1]; d0[3] = p1; d1[0] = - p1; @@ -2968,7 +2968,7 @@ static int start_decoder(vorb *f) } else { STBV_Point p[31*8+2]; Floor1 *g = &f->floor_config[i].floor1; - int max_class = -1; + int max_class = -1; g->partitions = get_bits(f, 5); for (j=0; j < g->partitions; ++j) { g->partition_class_list[j] = get_bits(f, 4); @@ -3072,7 +3072,7 @@ static int start_decoder(vorb *f) f->mapping_count = get_bits(f,6)+1; f->mapping = (Mapping *) setup_malloc(f, f->mapping_count * sizeof(*f->mapping)); for (i=0; i < f->mapping_count; ++i) { - Mapping *m = f->mapping + i; + Mapping *m = f->mapping + i; int mapping_type = get_bits(f,16); if (mapping_type != 0) return error(f, VORBIS_invalid_setup); m->chan = (MappingChannel *) setup_malloc(f, f->channels * sizeof(*m->chan)); @@ -3473,7 +3473,7 @@ static int vorbis_analyze_page(stb_vorbis *f, ProbedPage *z) * will then require us to NOT discard all of the first frame we * decode, in some cases, which means an even weirder frame size * and extra code. what a fucking pain. - + * we're going to discard the first packet if we * start the seek here, so we don't care about it. (we could actually * do better; if the first packet is long, and the previous packet @@ -3567,7 +3567,7 @@ static int vorbis_seek_frame_from_page(stb_vorbis *f, uint32_t page_start, uint3 * then leave frame pending */ frames_to_skip = frame - 1; assert(frames_to_skip >= 0); - data_to_skip = -1; + data_to_skip = -1; } set_file_offset(f, page_start); @@ -3645,7 +3645,7 @@ static int vorbis_seek_base(stb_vorbis *f, unsigned int sample_number, int fine) return error(f, VORBIS_seek_failed); /* now we want to lerp between these for the target samples... */ - + /* step 1: we need to bias towards the page start... */ if (start_offset + 4000 < end_offset) end_offset -= 4000; @@ -3725,7 +3725,7 @@ unsigned int stb_vorbis_stream_length_in_samples(stb_vorbis *f) /* first, store the current decode position so we can restore it */ restore_offset = stb_vorbis_get_file_offset(f); - /* now we want to seek back 64K from the end (the last page must + /* now we want to seek back 64K from the end (the last page must * be at most a little less than 64K, but let's allow a little slop) */ if (f->stream_len >= 65536 && f->stream_len-65536 >= f->first_audio_page_offset) previous_safe = f->stream_len - 65536; diff --git a/dirs.c b/dirs.c index 486e9dcc2c..35b7ad5413 100644 --- a/dirs.c +++ b/dirs.c @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -82,7 +82,7 @@ bool dir_init_shader(void) bool dir_free_shader(void) { - struct rarch_dir_list *dir_list = + struct rarch_dir_list *dir_list = (struct rarch_dir_list*)&dir_shader_list; dir_list_free(dir_list->list); diff --git a/dirs.h b/dirs.h index f69bb06715..e9bc186c69 100644 --- a/dirs.h +++ b/dirs.h @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/driver.c b/driver.c index fbee1c29f1..7cadd24508 100644 --- a/driver.c +++ b/driver.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -145,7 +145,7 @@ static int driver_find_index(const char * label, const char *drv) str[0] = '\0'; - for (i = 0; + for (i = 0; find_driver_nonempty(label, i, str, sizeof(str)) != NULL; i++) { if (string_is_empty(str)) @@ -253,7 +253,7 @@ static void driver_adjust_system_rates(void) * * Sets audio and video drivers to nonblock state (if enabled). * - * If nonblock state is false, sets + * If nonblock state is false, sets * blocking state for both audio and video drivers instead. **/ void driver_set_nonblock_state(void) @@ -266,7 +266,7 @@ void driver_set_nonblock_state(void) settings_t *settings = config_get_ptr(); bool video_nonblock = enable; - if ( !settings->bools.video_vsync + if ( !settings->bools.video_vsync || rarch_ctl(RARCH_CTL_IS_NONBLOCK_FORCED, NULL)) video_nonblock = true; video_driver_set_nonblock_state(video_nonblock); @@ -279,7 +279,7 @@ void driver_set_nonblock_state(void) * driver_update_system_av_info: * @data : pointer to new A/V info * - * Update the system Audio/Video information. + * Update the system Audio/Video information. * Will reinitialize audio/video drivers. * Used by RETRO_ENVIRONMENT_SET_SYSTEM_AV_INFO. * @@ -397,17 +397,17 @@ void drivers_init(int flags) **/ /** - * Driver ownership - set this to true if the platform in question needs to 'own' - * the respective handle and therefore skip regular RetroArch + * Driver ownership - set this to true if the platform in question needs to 'own' + * the respective handle and therefore skip regular RetroArch * driver teardown/reiniting procedure. * - * If to true, the 'free' function will get skipped. It is - * then up to the driver implementation to properly handle - * 'reiniting' inside the 'init' function and make sure it - * returns the existing handle instead of allocating and + * If to true, the 'free' function will get skipped. It is + * then up to the driver implementation to properly handle + * 'reiniting' inside the 'init' function and make sure it + * returns the existing handle instead of allocating and * returning a pointer to a new handle. * - * Typically, if a driver intends to make use of this, it should + * Typically, if a driver intends to make use of this, it should * set this to true at the end of its 'init' function. **/ void driver_uninit(int flags) diff --git a/driver.h b/driver.h index 1120253e65..49d61bbf07 100644 --- a/driver.h +++ b/driver.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -74,7 +74,7 @@ enum driver_ctl_state RARCH_DRIVER_CTL_NONE = 0, RARCH_DRIVER_CTL_DEINIT, - /* Attempts to find a default driver for + /* Attempts to find a default driver for * all driver types. * * Should be run before RARCH_DRIVER_CTL_INIT. @@ -86,7 +86,7 @@ enum driver_ctl_state * calls audio_monitor_set_refresh_rate(). */ RARCH_DRIVER_CTL_SET_REFRESH_RATE, - /* Update the system Audio/Video information. + /* Update the system Audio/Video information. * Will reinitialize audio/video drivers. * Used by RETRO_ENVIRONMENT_SET_SYSTEM_AV_INFO. */ RARCH_DRIVER_CTL_UPDATE_SYSTEM_AV_INFO, diff --git a/dynamic.c b/dynamic.c index 7661316f22..5e9bce61cb 100644 --- a/dynamic.c +++ b/dynamic.c @@ -199,11 +199,11 @@ static void libretro_get_environment_info(void (*func)(retro_environment_t), /* load_no_content gets set in this callback. */ func(environ_cb_get_system_info); - /* It's possible that we just set get_system_info callback + /* It's possible that we just set get_system_info callback * to the currently running core. * * Make sure we reset it to the actual environment callback. - * Ignore any environment callbacks here in case we're running + * Ignore any environment callbacks here in case we're running * on the non-current core. */ ignore_environment_cb = true; func(rarch_environment_cb); @@ -339,11 +339,11 @@ bool libretro_get_system_info(const char *path, /* load_no_content gets set in this callback. */ retro_set_environment(environ_cb_get_system_info); - /* It's possible that we just set get_system_info callback + /* It's possible that we just set get_system_info callback * to the currently running core. * * Make sure we reset it to the actual environment callback. - * Ignore any environment callbacks here in case we're running + * Ignore any environment callbacks here in case we're running * on the non-current core. */ ignore_environment_cb = true; retro_set_environment(rarch_environment_cb); @@ -712,11 +712,11 @@ static size_t mmap_add_bits_down(size_t n) n |= n >> 4; n |= n >> 8; n |= n >> 16; - + /* double shift to avoid warnings on 32bit (it's dead code, but compilers suck) */ if (sizeof(size_t) > 4) n |= n >> 16 >> 16; - + return n; } @@ -730,7 +730,7 @@ static size_t mmap_inflate(size_t addr, size_t mask) addr = ((addr & ~tmp) << 1) | (addr & tmp); mask = mask & (mask - 1); } - + return addr; } @@ -742,7 +742,7 @@ static size_t mmap_reduce(size_t addr, size_t mask) addr = (addr & tmp) | ((addr >> 1) & ~tmp); mask = (mask & (mask - 1)) >> 1; } - + return addr; } @@ -757,7 +757,7 @@ static bool mmap_preprocess_descriptors(rarch_memory_descriptor_t *first, unsign size_t top_addr = 1; rarch_memory_descriptor_t *desc = NULL; const rarch_memory_descriptor_t *end = first + count; - + for (desc = first; desc < end; desc++) { if (desc->core.select != 0) @@ -765,43 +765,43 @@ static bool mmap_preprocess_descriptors(rarch_memory_descriptor_t *first, unsign else top_addr |= desc->core.start + desc->core.len - 1; } - + top_addr = mmap_add_bits_down(top_addr); - + for (desc = first; desc < end; desc++) { if (desc->core.select == 0) { if (desc->core.len == 0) return false; - + if ((desc->core.len & (desc->core.len - 1)) != 0) return false; - + desc->core.select = top_addr & ~mmap_inflate(mmap_add_bits_down(desc->core.len - 1), desc->core.disconnect); } - + if (desc->core.len == 0) desc->core.len = mmap_add_bits_down(mmap_reduce(top_addr & ~desc->core.select, desc->core.disconnect)) + 1; - + if (desc->core.start & ~desc->core.select) return false; - + while (mmap_reduce(top_addr & ~desc->core.select, desc->core.disconnect) >> 1 > desc->core.len - 1) desc->core.disconnect |= mmap_highest_bit(top_addr & ~desc->core.select & ~desc->core.disconnect); - + desc->disconnect_mask = mmap_add_bits_down(desc->core.len - 1); desc->core.disconnect &= desc->disconnect_mask; - + while ((~desc->disconnect_mask) >> 1 & desc->core.disconnect) { desc->disconnect_mask >>= 1; desc->core.disconnect &= desc->disconnect_mask; } } - + return true; } @@ -942,7 +942,7 @@ bool rarch_environment_cb(unsigned cmd, void *data) unsigned p; settings_t *settings = config_get_ptr(); rarch_system_info_t *system = runloop_get_system_info(); - + if (ignore_environment_cb) return false; @@ -1238,7 +1238,7 @@ bool rarch_environment_cb(unsigned cmd, void *data) { struct retro_hw_render_callback *cb = (struct retro_hw_render_callback*)data; - struct retro_hw_render_callback *hwr = + struct retro_hw_render_callback *hwr = video_driver_get_hw_context(); RARCH_LOG("Environ SET_HW_RENDER.\n"); @@ -1253,7 +1253,7 @@ bool rarch_environment_cb(unsigned cmd, void *data) cb->get_proc_address = video_driver_get_proc_address; /* Old ABI. Don't copy garbage. */ - if (cmd & RETRO_ENVIRONMENT_EXPERIMENTAL) + if (cmd & RETRO_ENVIRONMENT_EXPERIMENTAL) memcpy(hwr, cb, offsetof(struct retro_hw_render_callback, stencil)); else @@ -1392,7 +1392,7 @@ bool rarch_environment_cb(unsigned cmd, void *data) cb->get_cpu_features = cpu_features_get; cb->get_perf_counter = cpu_features_get_perf_counter; - cb->perf_register = performance_counter_register; + cb->perf_register = performance_counter_register; cb->perf_start = core_performance_counter_start; cb->perf_stop = core_performance_counter_stop; cb->perf_log = retro_perf_log; @@ -1494,7 +1494,7 @@ bool rarch_environment_cb(unsigned cmd, void *data) } break; } - + case RETRO_ENVIRONMENT_SET_MEMORY_MAPS: { if (system) @@ -1575,9 +1575,9 @@ bool rarch_environment_cb(unsigned cmd, void *data) { const struct retro_game_geometry *in_geom = NULL; struct retro_game_geometry *geom = NULL; - struct retro_system_av_info *av_info = + struct retro_system_av_info *av_info = video_viewport_get_system_av_info(); - + if (av_info) geom = (struct retro_game_geometry*)&av_info->geometry; @@ -1617,7 +1617,7 @@ bool rarch_environment_cb(unsigned cmd, void *data) case RETRO_ENVIRONMENT_GET_HW_RENDER_INTERFACE: return video_driver_get_hw_render_interface( (const struct retro_hw_render_interface**)data); - + case RETRO_ENVIRONMENT_SET_SUPPORT_ACHIEVEMENTS: #ifdef HAVE_CHEEVOS { diff --git a/dynamic.h b/dynamic.h index d2b529520b..2432704e48 100644 --- a/dynamic.h +++ b/dynamic.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -93,7 +93,7 @@ struct retro_core_t void (*retro_set_input_poll)(retro_input_poll_t); void (*retro_set_input_state)(retro_input_state_t); void (*retro_set_controller_port_device)(unsigned, unsigned); - void (*retro_reset)(void); + void (*retro_reset)(void); void (*retro_run)(void); size_t (*retro_serialize_size)(void); bool (*retro_serialize)(void*, size_t); @@ -122,7 +122,7 @@ bool libretro_get_shared_context(void); /** * init_libretro_sym: * @type : Type of core to be loaded. - * If CORE_TYPE_DUMMY, will + * If CORE_TYPE_DUMMY, will * load dummy symbols. * * Initializes libretro symbols and diff --git a/file_path_str.c b/file_path_str.c index ce976bf261..219c719720 100644 --- a/file_path_str.c +++ b/file_path_str.c @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/frontend/drivers/platform_ctr.c b/frontend/drivers/platform_ctr.c index 7d3b7b6b28..015d7e0ae4 100644 --- a/frontend/drivers/platform_ctr.c +++ b/frontend/drivers/platform_ctr.c @@ -129,7 +129,7 @@ static void frontend_ctr_deinit(void *data) cfguExit(); ndspExit(); - csndExit(); + csndExit(); gfxTopRightFramebuffers[0] = NULL; gfxTopRightFramebuffers[1] = NULL; gfxExit(); @@ -322,7 +322,7 @@ static void frontend_ctr_init(void *data) verbosity_enable(); - gfxInit(GSP_BGR8_OES,GSP_RGB565_OES,false); + gfxInit(GSP_BGR8_OES,GSP_RGB565_OES,false); u32 topSize = 400 * 240 * 3; u32 bottomSize = 320 * 240 * 2; diff --git a/frontend/drivers/platform_gx.c b/frontend/drivers/platform_gx.c index 8443348c63..541e1363bf 100644 --- a/frontend/drivers/platform_gx.c +++ b/frontend/drivers/platform_gx.c @@ -405,7 +405,7 @@ static void frontend_gx_exitspawn(char *s, size_t len) sizeof(salamander_basename)); /* FIXME/TODO - hack - * direct loading failed (out of memory), + * direct loading failed (out of memory), * try to jump to Salamander, * then load the correct core */ fill_pathname_join(s, g_defaults.dirs[DEFAULT_DIR_CORE], diff --git a/frontend/drivers/platform_ps3.c b/frontend/drivers/platform_ps3.c index 9360feef2d..e6d49fcf43 100644 --- a/frontend/drivers/platform_ps3.c +++ b/frontend/drivers/platform_ps3.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -56,7 +56,7 @@ SYS_PROCESS_PARAM(1001, 0x100000) #else SYS_PROCESS_PARAM(1001, 0x200000) #endif - + #ifdef HAVE_MULTIMAN #define MULTIMAN_SELF_FILE "/dev_hdd0/game/BLES80608/USRDIR/RELOAD.SELF" static bool multiman_detected = false; @@ -189,7 +189,7 @@ static void frontend_ps3_get_environment_settings(int *argc, char *argv[], break; } - if((get_attributes & CELL_GAME_ATTRIBUTE_APP_HOME) + if((get_attributes & CELL_GAME_ATTRIBUTE_APP_HOME) == CELL_GAME_ATTRIBUTE_APP_HOME) RARCH_LOG("RetroArch was launched from host machine (APP_HOME).\n"); diff --git a/frontend/drivers/platform_qnx.c b/frontend/drivers/platform_qnx.c index b115e22520..d9ec683b24 100644 --- a/frontend/drivers/platform_qnx.c +++ b/frontend/drivers/platform_qnx.c @@ -45,7 +45,7 @@ static void frontend_qnx_shutdown(bool unused) static int frontend_qnx_get_rating(void) { - /* TODO/FIXME - look at unique identifier per device and + /* TODO/FIXME - look at unique identifier per device and * determine rating for some */ return -1; } diff --git a/frontend/drivers/platform_unix.c b/frontend/drivers/platform_unix.c index 80bd183322..43847effee 100644 --- a/frontend/drivers/platform_unix.c +++ b/frontend/drivers/platform_unix.c @@ -1502,7 +1502,7 @@ static void frontend_unix_get_env(int *argc, __android_log_print(ANDROID_LOG_INFO, "RetroArch", "[ENV]: app dir: [%s]\n", app_dir); - /* set paths depending on the ability to write + /* set paths depending on the ability to write * to internal_storage_path */ if(!string_is_empty(internal_storage_path)) @@ -1592,7 +1592,7 @@ static void frontend_unix_get_env(int *argc, internal_storage_app_path, "cheats", sizeof(g_defaults.dirs[DEFAULT_DIR_CHEATS])); - if(!string_is_empty(screenshot_dir) + if(!string_is_empty(screenshot_dir) && test_permissions(screenshot_dir)) { fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SCREENSHOT], @@ -1606,7 +1606,7 @@ static void frontend_unix_get_env(int *argc, sizeof(g_defaults.dirs[DEFAULT_DIR_SCREENSHOT])); } - if(!string_is_empty(downloads_dir) + if(!string_is_empty(downloads_dir) && test_permissions(downloads_dir)) { fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_ASSETS], @@ -1621,7 +1621,7 @@ static void frontend_unix_get_env(int *argc, } break; - + /* only the internal app dir is writable, this should never happen*/ case INTERNAL_STORAGE_NOT_WRITABLE: fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SRAM], @@ -1650,7 +1650,7 @@ static void frontend_unix_get_env(int *argc, app_dir, "cheats", sizeof(g_defaults.dirs[DEFAULT_DIR_CHEATS])); - if( !string_is_empty(screenshot_dir) + if( !string_is_empty(screenshot_dir) && test_permissions(screenshot_dir)) { fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_SCREENSHOT], @@ -1664,7 +1664,7 @@ static void frontend_unix_get_env(int *argc, sizeof(g_defaults.dirs[DEFAULT_DIR_SCREENSHOT])); } - if(!string_is_empty(downloads_dir) + if(!string_is_empty(downloads_dir) && test_permissions(downloads_dir)) { fill_pathname_join(g_defaults.dirs[DEFAULT_DIR_CORE_ASSETS], @@ -1768,7 +1768,7 @@ static void frontend_unix_get_env(int *argc, #endif #if 0 - /* Set the OK/cancel menu buttons to the default + /* Set the OK/cancel menu buttons to the default * ones used for Shield */ g_defaults.menu.controls.set = true; g_defaults.menu.controls.menu_btn_ok = RETRO_DEVICE_ID_JOYPAD_B; @@ -2035,7 +2035,7 @@ static int frontend_unix_parse_drive_list(void *data, bool load_content) menu_entries_append_enum(list, "/storage", msg_hash_to_str(MSG_REMOVABLE_STORAGE), - enum_idx, + enum_idx, FILE_TYPE_DIRECTORY, 0, 0); #endif @@ -2175,7 +2175,7 @@ VALGRIND_PRINTF_BACKTRACE("SIGINT"); if (unix_sighandler_quit == 1) {} if (unix_sighandler_quit == 2) exit(1); /* in case there's a second deadlock in a C++ destructor or something */ - if (unix_sighandler_quit >= 3) abort(); + if (unix_sighandler_quit >= 3) abort(); } static void frontend_unix_install_signal_handlers(void) diff --git a/frontend/drivers/platform_unix.h b/frontend/drivers/platform_unix.h index db5eacceb3..c5a028ccc8 100644 --- a/frontend/drivers/platform_unix.h +++ b/frontend/drivers/platform_unix.h @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis * Copyright (C) 2012-2015 - Michael Lelli - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -244,7 +244,7 @@ enum /** * Command from main thread: the app should generate a new saved state - * for itself, to restore from later if needed. + * for itself, to restore from later if needed. */ APP_CMD_SAVE_STATE, diff --git a/frontend/drivers/platform_wii.c b/frontend/drivers/platform_wii.c index ac5ebfaea3..51b0d9c148 100644 --- a/frontend/drivers/platform_wii.c +++ b/frontend/drivers/platform_wii.c @@ -74,9 +74,9 @@ static void dol_copy_argv_path(const char *dolpath, const char *argpath) } /* a relative path */ else if ( - (strstr(dolpath, "sd:/") != dolpath) && + (strstr(dolpath, "sd:/") != dolpath) && (strstr(dolpath, "usb:/") != dolpath) && - (strstr(dolpath, "carda:/") != dolpath) && + (strstr(dolpath, "carda:/") != dolpath) && (strstr(dolpath, "cardb:/") != dolpath) ) { @@ -119,7 +119,7 @@ static void dol_copy_argv_path(const char *dolpath, const char *argpath) DCFlushRange(ARGS_ADDR, sizeof(struct __argv) + argv->length); } -/* WARNING: after we move any data +/* WARNING: after we move any data * into EXECUTE_ADDR, we can no longer use any * heap memory and are restricted to the stack only. */ void system_exec_wii(const char *_path, bool should_load_game) @@ -133,7 +133,7 @@ void system_exec_wii(const char *_path, bool should_load_game) bool original_verbose = verbosity_is_enabled(); #endif - /* copy heap info into stack so it survives + /* copy heap info into stack so it survives * us moving the .dol into MEM2. */ strlcpy(path, _path, sizeof(path)); if (should_load_game) diff --git a/frontend/drivers/platform_win32.c b/frontend/drivers/platform_win32.c index 64703e4dcb..31b238c814 100644 --- a/frontend/drivers/platform_win32.c +++ b/frontend/drivers/platform_win32.c @@ -42,8 +42,8 @@ #include "../../retroarch.h" #include "../../verbosity.h" -/* We only load this library once, so we let it be - * unloaded at application shutdown, since unloading +/* We only load this library once, so we let it be + * unloaded at application shutdown, since unloading * it early seems to cause issues on some systems. */ @@ -89,10 +89,10 @@ static bool gfx_init_dwm(void) return false; } - DragAcceptFiles_func = + DragAcceptFiles_func = (VOID (WINAPI*)(HWND, BOOL))dylib_proc(shell32lib, "DragAcceptFiles"); - mmcss = + mmcss = (HRESULT (WINAPI*)(BOOL))dylib_proc(dwmlib, "DwmEnableMMCSS"); if (mmcss) { @@ -116,7 +116,7 @@ static void gfx_set_dwm(void) if (settings->bools.video_disable_composition == dwm_composition_disabled) return; - composition_enable = + composition_enable = (HRESULT (WINAPI*)(UINT))dylib_proc(dwmlib, "DwmEnableComposition"); if (!composition_enable) { @@ -292,11 +292,11 @@ static void frontend_win32_init(void *data) { typedef BOOL (WINAPI *isProcessDPIAwareProc)(); typedef BOOL (WINAPI *setProcessDPIAwareProc)(); - HMODULE handle = + HMODULE handle = GetModuleHandle("User32.dll"); - isProcessDPIAwareProc isDPIAwareProc = + isProcessDPIAwareProc isDPIAwareProc = (isProcessDPIAwareProc)dylib_proc(handle, "IsProcessDPIAware"); - setProcessDPIAwareProc setDPIAwareProc = + setProcessDPIAwareProc setDPIAwareProc = (setProcessDPIAwareProc)dylib_proc(handle, "SetProcessDPIAware"); if (isDPIAwareProc) @@ -307,7 +307,7 @@ static void frontend_win32_init(void *data) setDPIAwareProc(); } } - + } enum frontend_powerstate frontend_win32_get_powerstate(int *seconds, int *percent) @@ -471,7 +471,7 @@ static uint64_t frontend_win32_get_mem_total(void) static uint64_t frontend_win32_get_mem_used(void) { - /* OSes below 2000 don't have the Ex version, + /* OSes below 2000 don't have the Ex version, * and non-Ex cannot work with >4GB RAM */ #if _WIN32_WINNT >= 0x0500 MEMORYSTATUSEX mem_info; @@ -492,24 +492,24 @@ static void frontend_win32_attach_console(void) #ifdef _WIN32_WINNT_WINXP /* msys will start the process with FILE_TYPE_PIPE connected. - * cmd will start the process with FILE_TYPE_UNKNOWN connected + * cmd will start the process with FILE_TYPE_UNKNOWN connected * (since this is subsystem windows application - * ... UNLESS stdout/stderr were redirected (then FILE_TYPE_DISK + * ... UNLESS stdout/stderr were redirected (then FILE_TYPE_DISK * will be connected most likely) * explorer will start the process with NOTHING connected. * * Now, let's not reconnect anything that's already connected. * If any are disconnected, open a console, and connect to them. - * In case we're launched from msys or cmd, try attaching to the + * In case we're launched from msys or cmd, try attaching to the * parent process console first. * - * Take care to leave a record of what we did, so we can + * Take care to leave a record of what we did, so we can * undo it precisely. */ - bool need_stdout = (GetFileType(GetStdHandle(STD_OUTPUT_HANDLE)) + bool need_stdout = (GetFileType(GetStdHandle(STD_OUTPUT_HANDLE)) == FILE_TYPE_UNKNOWN); - bool need_stderr = (GetFileType(GetStdHandle(STD_ERROR_HANDLE)) + bool need_stderr = (GetFileType(GetStdHandle(STD_ERROR_HANDLE)) == FILE_TYPE_UNKNOWN); if(need_stdout || need_stderr) @@ -534,8 +534,8 @@ static void frontend_win32_detach_console(void) if(console_needs_free) { - /* we don't reconnect stdout/stderr to anything here, - * because by definition, they weren't connected to + /* we don't reconnect stdout/stderr to anything here, + * because by definition, they weren't connected to * anything in the first place. */ FreeConsole(); console_needs_free = false; diff --git a/frontend/drivers/platform_xdk.c b/frontend/drivers/platform_xdk.c index 3c626285d8..e67d5935ba 100644 --- a/frontend/drivers/platform_xdk.c +++ b/frontend/drivers/platform_xdk.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -240,10 +240,10 @@ typedef struct _FILE_FS_SIZE_INFORMATION { #define DEVICE_TYPE ULONG // Structure of FileFsDeviceInformation -typedef struct _FILE_FS_DEVICE_INFORMATION { - DEVICE_TYPE DeviceType; - ULONG Characteristics; -} FILE_FS_DEVICE_INFORMATION, *PFILE_FS_DEVICE_INFORMATION; +typedef struct _FILE_FS_DEVICE_INFORMATION { + DEVICE_TYPE DeviceType; + ULONG Characteristics; +} FILE_FS_DEVICE_INFORMATION, *PFILE_FS_DEVICE_INFORMATION; // DEVICE_TYPEs (I took a guess as to which the XBOX might have.) #define FILE_DEVICE_CD_ROM 0x00000002 @@ -993,12 +993,12 @@ extern "C" // Thanks and credit go to Team Evox extern VOID WINAPI HalReturnToFirmware(DWORD); - extern INT WINAPI XNetLoadConfigParams(LPBYTE); - extern INT WINAPI XNetSaveConfigParams(LPBYTE); + extern INT WINAPI XNetLoadConfigParams(LPBYTE); + extern INT WINAPI XNetSaveConfigParams(LPBYTE); extern INT WINAPI XWriteTitleInfoNoReboot(LPVOID,LPVOID,DWORD,DWORD,LPVOID); - extern DWORD* LaunchDataPage; + extern DWORD* LaunchDataPage; } #endif @@ -1006,7 +1006,7 @@ extern "C" static enum frontend_fork xdk_fork_mode = FRONTEND_FORK_NONE; #ifdef _XBOX360 -typedef struct _STRING +typedef struct _STRING { USHORT Length; USHORT MaximumLength; @@ -1016,7 +1016,7 @@ typedef struct _STRING #ifdef __cplusplus extern "C" { #endif -VOID RtlInitAnsiString(PSTRING DestinationString, PCHAR SourceString); +VOID RtlInitAnsiString(PSTRING DestinationString, PCHAR SourceString); HRESULT ObDeleteSymbolicLink(PSTRING SymbolicLinkName); HRESULT ObCreateSymbolicLink(PSTRING SymbolicLinkName, PSTRING DeviceName); #ifdef __cplusplus diff --git a/frontend/frontend.c b/frontend/frontend.c index b6dcca2cd2..137d9fa0bf 100644 --- a/frontend/frontend.c +++ b/frontend/frontend.c @@ -102,7 +102,7 @@ int rarch_main(int argc, char *argv[], void *data) rarch_ctl(RARCH_CTL_PREINIT, NULL); frontend_driver_init_first(args); rarch_ctl(RARCH_CTL_INIT, NULL); - + if (frontend_driver_is_inited()) { content_ctx_info_t info; diff --git a/frontend/frontend.h b/frontend/frontend.h index fed99639ce..ef821097c4 100644 --- a/frontend/frontend.h +++ b/frontend/frontend.h @@ -34,14 +34,14 @@ RETRO_BEGIN_DECLS * and (optionally) autosave state. **/ void main_exit(void *args); - + /** * main_entry: * * Main function of RetroArch. * * If HAVE_MAIN is not defined, will contain main loop and will not - * be exited from until we exit the program. Otherwise, will + * be exited from until we exit the program. Otherwise, will * just do initialization. * * Returns: varies per platform. diff --git a/frontend/frontend_salamander.c b/frontend/frontend_salamander.c index e8c2441e29..52868ec0c8 100644 --- a/frontend/frontend_salamander.c +++ b/frontend/frontend_salamander.c @@ -56,7 +56,7 @@ static void find_first_libretro_core(char *first_file, RARCH_LOG("Searching for valid libretro implementation in: \"%s\".\n", dir); - + for (i = 0; i < list->size && !ret; i++) { char fname[PATH_MAX_LENGTH] = {0}; @@ -94,7 +94,7 @@ static void find_first_libretro_core(char *first_file, dir_list_free(list); } -/* Last fallback - we'll need to start the first executable file +/* Last fallback - we'll need to start the first executable file * we can find in the RetroArch cores directory. */ static void find_and_set_first_file(char *s, size_t len, @@ -135,9 +135,9 @@ static void salamander_init(char *s, size_t len) strlcpy(s, tmp_str, len); } #ifdef GEKKO - /* stupid libfat bug or something; sometimes it says + /* stupid libfat bug or something; sometimes it says * the file is there when it doesn't. */ - else + else { config_exists = false; } diff --git a/gfx/common/d3d_common.c b/gfx/common/d3d_common.c index 07976b7393..5de2e746c9 100644 --- a/gfx/common/d3d_common.c +++ b/gfx/common/d3d_common.c @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -111,7 +111,7 @@ LPDIRECT3DTEXTURE d3d_texture_new(LPDIRECT3DDEVICE dev, const char *path, unsigned width, unsigned height, unsigned miplevels, unsigned usage, D3DFORMAT format, D3DPOOL pool, unsigned filter, unsigned mipfilter, - D3DCOLOR color_key, void *src_info_data, + D3DCOLOR color_key, void *src_info_data, PALETTEENTRY *palette) { HRESULT hr; @@ -535,7 +535,7 @@ void d3d_clear(LPDIRECT3DDEVICE dev, #if defined(_XBOX1) D3DDevice_Clear(count, rects, flags, color, z, stencil); #elif defined(_XBOX360) - D3DDevice_Clear(dev, count, rects, flags, color, z, + D3DDevice_Clear(dev, count, rects, flags, color, z, stencil, false); #elif defined(HAVE_D3D9) && !defined(__cplusplus) IDirect3DDevice9_Clear(dev, count, rects, flags, @@ -646,10 +646,10 @@ void d3d_set_texture(LPDIRECT3DDEVICE dev, unsigned sampler, #if defined(_XBOX1) D3DDevice_SetTexture(sampler, tex); #elif defined(_XBOX360) - unsigned fetchConstant = + unsigned fetchConstant = GPU_CONVERT_D3D_TO_HARDWARE_TEXTUREFETCHCONSTANT(sampler); - uint64_t pendingMask3 = - D3DTAG_MASKENCODE(D3DTAG_START(D3DTAG_FETCHCONSTANTS) + uint64_t pendingMask3 = + D3DTAG_MASKENCODE(D3DTAG_START(D3DTAG_FETCHCONSTANTS) + fetchConstant, D3DTAG_START(D3DTAG_FETCHCONSTANTS) + fetchConstant); #if defined(__cplusplus) @@ -976,7 +976,7 @@ D3DTEXTUREFILTERTYPE d3d_translate_filter(unsigned type) return D3DTEXF_POINT; } - + void *d3d_matrix_transpose(void *_pout, const void *_pm) { unsigned i,j; diff --git a/gfx/common/d3d_common.h b/gfx/common/d3d_common.h index 8fd61d2aad..fa88fb2e55 100644 --- a/gfx/common/d3d_common.h +++ b/gfx/common/d3d_common.h @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -45,7 +45,7 @@ LPDIRECT3DTEXTURE d3d_texture_new(LPDIRECT3DDEVICE dev, const char *path, unsigned width, unsigned height, unsigned miplevels, unsigned usage, D3DFORMAT format, D3DPOOL pool, unsigned filter, unsigned mipfilter, - D3DCOLOR color_key, void *src_info, + D3DCOLOR color_key, void *src_info, PALETTEENTRY *palette); void d3d_set_stream_source(LPDIRECT3DDEVICE dev, unsigned stream_no, diff --git a/gfx/common/dbus_common.c b/gfx/common/dbus_common.c index 4fd335a8f6..7270510337 100644 --- a/gfx/common/dbus_common.c +++ b/gfx/common/dbus_common.c @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -30,7 +30,7 @@ void dbus_ensure_connection(void) #ifdef HAVE_DBUS DBusError err; int ret; - + dbus_error_init(&err); dbus_connection = dbus_bus_get_private(DBUS_BUS_SESSION, &err); diff --git a/gfx/common/dbus_common.h b/gfx/common/dbus_common.h index c8a4e5f3e4..97f6b2a97c 100644 --- a/gfx/common/dbus_common.h +++ b/gfx/common/dbus_common.h @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/gfx/common/drm_common.c b/gfx/common/drm_common.c index b1d11ec999..33052c83e1 100644 --- a/gfx/common/drm_common.c +++ b/gfx/common/drm_common.c @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (c) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/gfx/common/drm_common.h b/gfx/common/drm_common.h index e66e1c1704..87458dac9a 100644 --- a/gfx/common/drm_common.h +++ b/gfx/common/drm_common.h @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (c) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/gfx/common/egl_common.c b/gfx/common/egl_common.c index 691213f7b6..a0dd747c24 100644 --- a/gfx/common/egl_common.c +++ b/gfx/common/egl_common.c @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (c) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -174,7 +174,7 @@ void egl_swap_buffers(void *data) void egl_set_swap_interval(egl_ctx_data_t *egl, unsigned interval) { /* Can be called before initialization. - * Some contexts require that swap interval + * Some contexts require that swap interval * is known at startup time. */ egl->interval = interval; diff --git a/gfx/common/egl_common.h b/gfx/common/egl_common.h index 70f48b666d..e82f889567 100644 --- a/gfx/common/egl_common.h +++ b/gfx/common/egl_common.h @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (c) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/gfx/common/gl_common.c b/gfx/common/gl_common.c index 10c139bef0..98a4c41c58 100644 --- a/gfx/common/gl_common.c +++ b/gfx/common/gl_common.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/gfx/common/gl_common.h b/gfx/common/gl_common.h index 7fb5527dcf..46b1c0b621 100644 --- a/gfx/common/gl_common.h +++ b/gfx/common/gl_common.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * copyright (c) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/gfx/common/vita2d_common.h b/gfx/common/vita2d_common.h index 010f3fca10..39006586a8 100644 --- a/gfx/common/vita2d_common.h +++ b/gfx/common/vita2d_common.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -41,12 +41,12 @@ struct vita_overlay_data { vita2d_texture *tex; float x; - float y; - float w; + float y; + float w; float h; float tex_x; - float tex_y; - float tex_w; + float tex_y; + float tex_w; float tex_h; float alpha_mod; float width; @@ -76,14 +76,14 @@ typedef struct vita_video bool should_resize; vita_menu_t menu; - + #ifdef HAVE_OVERLAY struct vita_overlay_data *overlay; unsigned overlays; bool overlay_enable; bool overlay_full_screen; #endif - + } vita_video_t; #endif diff --git a/gfx/common/vksym.h b/gfx/common/vksym.h index 02717d7d3f..257952d93a 100644 --- a/gfx/common/vksym.h +++ b/gfx/common/vksym.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2016-2017 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/gfx/common/vulkan_common.c b/gfx/common/vulkan_common.c index cab3af0bd3..91990eadb4 100644 --- a/gfx/common/vulkan_common.c +++ b/gfx/common/vulkan_common.c @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2016-2017 - Hans-Kristian Arntzen - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -162,14 +162,14 @@ void vulkan_copy_staging_to_dynamic(vk_t *vk, VkCommandBuffer cmd, vulkan_sync_texture_to_gpu(vk, staging); vulkan_transition_texture(vk, cmd, staging); - /* We don't have to sync against previous TRANSFER, - * since we observed the completion by fences. + /* We don't have to sync against previous TRANSFER, + * since we observed the completion by fences. * * If we have a single texture_optimal, we would need to sync against * previous transfers to avoid races. * - * We would also need to optionally maintain extra textures due to - * changes in resolution, so this seems like the sanest and + * We would also need to optionally maintain extra textures due to + * changes in resolution, so this seems like the sanest and * simplest solution. */ vulkan_image_layout_transition(vk, cmd, dynamic->image, VK_IMAGE_LAYOUT_UNDEFINED, VK_IMAGE_LAYOUT_TRANSFER_DST_OPTIMAL, @@ -413,7 +413,7 @@ struct vk_texture vulkan_create_texture(vk_t *vk, /* If the texture is STREAMED and it's not DEVICE_LOCAL, we expect to hit a slower path, * so fallback to copy path. */ - if (type == VULKAN_TEXTURE_STREAMED && + if (type == VULKAN_TEXTURE_STREAMED && (vk->context->memory_properties.memoryTypes[alloc.memoryTypeIndex].propertyFlags & VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT) == 0) { @@ -657,8 +657,8 @@ struct vk_texture vulkan_create_texture(vk_t *vk, vkQueueSubmit(vk->context->queue, 1, &submit_info, VK_NULL_HANDLE); - /* TODO: Very crude, but texture uploads only happen - * during init, so waiting for GPU to complete transfer + /* TODO: Very crude, but texture uploads only happen + * during init, so waiting for GPU to complete transfer * and blocking isn't a big deal. */ vkQueueWaitIdle(vk->context->queue); #ifdef HAVE_THREADS @@ -733,7 +733,7 @@ static void vulkan_write_quad_descriptors( void vulkan_transition_texture(vk_t *vk, VkCommandBuffer cmd, struct vk_texture *texture) { /* Transition to GENERAL layout for linear streamed textures. - * We're using linear textures here, so only + * We're using linear textures here, so only * GENERAL layout is supported. * If we're already in GENERAL, add a host -> shader read memory barrier * to invalidate texture caches. @@ -774,7 +774,7 @@ static void vulkan_check_dynamic_state( if (vk->tracker.dirty & VULKAN_DIRTY_DYNAMIC_BIT) { VkRect2D sci; - + sci.offset.x = vk->vp.x; sci.offset.y = vk->vp.y; sci.extent.width = vk->vp.width; @@ -873,7 +873,7 @@ void vulkan_draw_quad(vk_t *vk, const struct vk_draw_quad *quad) if ( string_is_equal_fast(quad->mvp, - &vk->tracker.mvp, sizeof(*quad->mvp)) + &vk->tracker.mvp, sizeof(*quad->mvp)) || quad->texture->view != vk->tracker.view || quad->sampler != vk->tracker.sampler) { @@ -939,7 +939,7 @@ void vulkan_image_layout_transition( VkPipelineStageFlags srcStages, VkPipelineStageFlags dstStages) { - VkImageMemoryBarrier barrier = + VkImageMemoryBarrier barrier = { VK_STRUCTURE_TYPE_IMAGE_MEMORY_BARRIER }; barrier.srcAccessMask = srcAccess; @@ -982,7 +982,7 @@ struct vk_buffer vulkan_create_buffer( alloc.memoryTypeIndex = vulkan_find_memory_type( &context->memory_properties, mem_reqs.memoryTypeBits, - VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | + VK_MEMORY_PROPERTY_HOST_VISIBLE_BIT | VK_MEMORY_PROPERTY_HOST_COHERENT_BIT); vkAllocateMemory(context->device, &alloc, NULL, &buffer.memory); vkBindBufferMemory(context->device, buffer.buffer, buffer.memory, 0); @@ -1011,12 +1011,12 @@ static struct vk_descriptor_pool *vulkan_alloc_descriptor_pool( const struct vk_descriptor_manager *manager) { unsigned i; - VkDescriptorPoolCreateInfo pool_info = { + VkDescriptorPoolCreateInfo pool_info = { VK_STRUCTURE_TYPE_DESCRIPTOR_POOL_CREATE_INFO }; - VkDescriptorSetAllocateInfo alloc_info = { + VkDescriptorSetAllocateInfo alloc_info = { VK_STRUCTURE_TYPE_DESCRIPTOR_SET_ALLOCATE_INFO }; - struct vk_descriptor_pool *pool = + struct vk_descriptor_pool *pool = (struct vk_descriptor_pool*)calloc(1, sizeof(*pool)); if (!pool) return NULL; @@ -1120,12 +1120,12 @@ static bool vulkan_buffer_chain_suballoc(struct vk_buffer_chain *chain, range->data = (uint8_t*)chain->current->buffer.mapped + chain->offset; range->buffer = chain->current->buffer.buffer; range->offset = chain->offset; - chain->offset = (next_offset + chain->alignment - 1) + chain->offset = (next_offset + chain->alignment - 1) & ~(chain->alignment - 1); return true; } - + return false; } @@ -1149,7 +1149,7 @@ struct vk_buffer_chain vulkan_buffer_chain_init( VkBufferUsageFlags usage) { struct vk_buffer_chain chain; - + chain.block_size = block_size; chain.alignment = alignment; chain.offset = 0; @@ -1194,7 +1194,7 @@ bool vulkan_buffer_chain_alloc(const struct vulkan_context *context, } /* We have to allocate a new node, might allocate larger - * buffer here than block_size in case we have + * buffer here than block_size in case we have * a very large allocation. */ if (size < chain->block_size) size = chain->block_size; @@ -1684,7 +1684,7 @@ bool vulkan_context_init(gfx_ctx_vulkan_data_t *vk, } RARCH_LOG("Vulkan dynamic library loaded.\n"); - + GetInstanceProcAddr = (PFN_vkGetInstanceProcAddr)dylib_proc(vulkan_library, "vkGetInstanceProcAddr"); @@ -2012,7 +2012,7 @@ bool vulkan_surface_create(gfx_ctx_vulkan_data_t *vk, PFN_vkCreateWaylandSurfaceKHR create; if (!VULKAN_SYMBOL_WRAPPER_LOAD_INSTANCE_SYMBOL(vk->context.instance, "vkCreateWaylandSurfaceKHR", create)) return false; - VkWaylandSurfaceCreateInfoKHR surf_info; + VkWaylandSurfaceCreateInfoKHR surf_info; memset(&surf_info, 0, sizeof(surf_info)); @@ -2091,7 +2091,7 @@ bool vulkan_surface_create(gfx_ctx_vulkan_data_t *vk, surf_info.window = *(const Window*)surface; if (create(vk->context.instance, - &surf_info, NULL, &vk->vk_surface) + &surf_info, NULL, &vk->vk_surface) != VK_SUCCESS) return false; } @@ -2114,7 +2114,7 @@ bool vulkan_surface_create(gfx_ctx_vulkan_data_t *vk, surf_info.window = *(const xcb_window_t*)surface; if (create(vk->context.instance, - &surf_info, NULL, &vk->vk_surface) + &surf_info, NULL, &vk->vk_surface) != VK_SUCCESS) return false; } @@ -2136,7 +2136,7 @@ bool vulkan_surface_create(gfx_ctx_vulkan_data_t *vk, surf_info.mirSurface = surface; if (create(vk->context.instance, - &surf_info, NULL, &vk->vk_surface) + &surf_info, NULL, &vk->vk_surface) != VK_SUCCESS) return false; } @@ -2386,7 +2386,7 @@ bool vulkan_create_swapchain(gfx_ctx_vulkan_data_t *vk, VkExtent2D swapchain_size; VkSwapchainKHR old_swapchain; VkSurfaceTransformFlagBitsKHR pre_transform; - VkSwapchainCreateInfoKHR info = { + VkSwapchainCreateInfoKHR info = { VK_STRUCTURE_TYPE_SWAPCHAIN_CREATE_INFO_KHR }; VkPresentModeKHR swapchain_present_mode = VK_PRESENT_MODE_FIFO_KHR; settings_t *settings = config_get_ptr(); @@ -2421,7 +2421,7 @@ bool vulkan_create_swapchain(gfx_ctx_vulkan_data_t *vk, swapchain_present_mode = VK_PRESENT_MODE_MAILBOX_KHR; break; } - else if (!swap_interval && present_modes[i] + else if (!swap_interval && present_modes[i] == VK_PRESENT_MODE_IMMEDIATE_KHR) { swapchain_present_mode = VK_PRESENT_MODE_IMMEDIATE_KHR; @@ -2531,11 +2531,11 @@ bool vulkan_create_swapchain(gfx_ctx_vulkan_data_t *vk, if (desired_swapchain_images < surface_properties.minImageCount) desired_swapchain_images = surface_properties.minImageCount; - if ((surface_properties.maxImageCount > 0) + if ((surface_properties.maxImageCount > 0) && (desired_swapchain_images > surface_properties.maxImageCount)) desired_swapchain_images = surface_properties.maxImageCount; - if (surface_properties.supportedTransforms + if (surface_properties.supportedTransforms & VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR) pre_transform = VK_SURFACE_TRANSFORM_IDENTITY_BIT_KHR; else @@ -2565,7 +2565,7 @@ bool vulkan_create_swapchain(gfx_ctx_vulkan_data_t *vk, info.presentMode = swapchain_present_mode; info.clipped = true; info.oldSwapchain = old_swapchain; - info.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT + info.imageUsage = VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT; if (vkCreateSwapchainKHR(vk->context.device, diff --git a/gfx/common/vulkan_common.h b/gfx/common/vulkan_common.h index 732e7173e1..e4714142ef 100644 --- a/gfx/common/vulkan_common.h +++ b/gfx/common/vulkan_common.h @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2016-2017 - Hans-Kristian Arntzen - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/gfx/common/wayland_common.h b/gfx/common/wayland_common.h index 4cec21d386..e48f450907 100644 --- a/gfx/common/wayland_common.h +++ b/gfx/common/wayland_common.h @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/gfx/common/win32_common.c b/gfx/common/win32_common.c index 426632bbd0..766838e671 100644 --- a/gfx/common/win32_common.c +++ b/gfx/common/win32_common.c @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -673,8 +673,8 @@ LRESULT CALLBACK WndProcGDI(HWND hwnd, UINT message, if (gdi && gdi->memDC) { RECT rect; - HBRUSH brush = CreateSolidBrush(RGB(1,81,127)); - + HBRUSH brush = CreateSolidBrush(RGB(1,81,127)); + GetClientRect(hwnd, &rect); StretchBlt(gdi->winDC, diff --git a/gfx/common/win32_common.h b/gfx/common/win32_common.h index c87a991fdb..9df4db8246 100644 --- a/gfx/common/win32_common.h +++ b/gfx/common/win32_common.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/gfx/common/x11_common.c b/gfx/common/x11_common.c index 1375fd1186..c7894ed41d 100644 --- a/gfx/common/x11_common.c +++ b/gfx/common/x11_common.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -139,7 +139,7 @@ void x11_move_window(Display *dpy, Window win, int x, int y, xev.xclient.message_type = XA_NET_MOVERESIZE_WINDOW; xev.xclient.window = win; xev.xclient.format = 32; - xev.xclient.data.l[0] = (1 << MOVERESIZE_X_SHIFT) + xev.xclient.data.l[0] = (1 << MOVERESIZE_X_SHIFT) | (1 << MOVERESIZE_Y_SHIFT); xev.xclient.data.l[1] = x; xev.xclient.data.l[2] = y; @@ -252,7 +252,7 @@ static bool get_video_mode(video_frame_info_t *video_info, *desktop_mode = *modes[0]; - /* If we use black frame insertion, we fake a 60 Hz monitor + /* If we use black frame insertion, we fake a 60 Hz monitor * for 120 Hz one, etc, so try to match that. */ refresh_mod = video_info->black_frame_insertion ? 0.5f : 1.0f; @@ -391,7 +391,7 @@ static void x11_handle_key_event(XEvent *event, XIC ic, bool filter) bool down = event->type == KeyPress; int num = 0; KeySym keysym = 0; - + chars[0] = '\0'; if (!filter) @@ -407,7 +407,7 @@ static void x11_handle_key_event(XEvent *event, XIC ic, bool filter) /* XwcLookupString doesn't seem to work. */ num = Xutf8LookupString(ic, &event->xkey, keybuf, ARRAY_SIZE(keybuf), &keysym, &status); - /* libc functions need UTF-8 locale to work properly, + /* libc functions need UTF-8 locale to work properly, * which makes mbrtowc a bit impractical. * * Use custom UTF8 -> UTF-32 conversion. */ @@ -464,7 +464,7 @@ bool x11_alive(void *data) switch (event.type) { case ClientMessage: - if (event.xclient.window == g_x11_win && + if (event.xclient.window == g_x11_win && (Atom)event.xclient.data.l[0] == g_x11_quit_atom) frontend_driver_set_signal_handler_state(1); break; diff --git a/gfx/common/x11_common.h b/gfx/common/x11_common.h index d70f2d28c6..23fc4898bc 100644 --- a/gfx/common/x11_common.h +++ b/gfx/common/x11_common.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/gfx/common/xinerama_common.c b/gfx/common/xinerama_common.c index 0ce48c66ed..34879e8275 100644 --- a/gfx/common/xinerama_common.c +++ b/gfx/common/xinerama_common.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/gfx/common/xinerama_common.h b/gfx/common/xinerama_common.h index e66c17b849..3a7e00e4cf 100644 --- a/gfx/common/xinerama_common.h +++ b/gfx/common/xinerama_common.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/gfx/drivers/ctr_gfx.c b/gfx/drivers/ctr_gfx.c index 0aabb51ccd..720fac0834 100644 --- a/gfx/drivers/ctr_gfx.c +++ b/gfx/drivers/ctr_gfx.c @@ -436,7 +436,7 @@ static void* ctr_init(const video_info_t* video, driver_ctl(RARCH_DRIVER_CTL_SET_REFRESH_RATE, &refresh_rate); aptHook(&ctr->lcd_aptHook, ctr_lcd_aptHook, ctr); - font_driver_init_osd(ctr, false, + font_driver_init_osd(ctr, false, video->is_threaded, FONT_DRIVER_RENDER_CTR); @@ -826,7 +826,7 @@ static bool ctr_frame(void* data, const void* frame, topFramebufferInfo.unk = 0x00000000; u8* framebufferInfoHeader = gfxSharedMemory+0x200+gfxThreadID*0x80; - GSPGPU_FramebufferInfo* + GSPGPU_FramebufferInfo* framebufferInfo = (GSPGPU_FramebufferInfo*)&framebufferInfoHeader[0x4]; framebufferInfoHeader[0x0] ^= 1; framebufferInfo[framebufferInfoHeader[0x0]] = topFramebufferInfo; diff --git a/gfx/drivers/d3d.c b/gfx/drivers/d3d.c index 48aefd123e..4ef1375f90 100644 --- a/gfx/drivers/d3d.c +++ b/gfx/drivers/d3d.c @@ -333,8 +333,8 @@ static void d3d_viewport_info(void *data, struct video_viewport *vp) { d3d_video_t *d3d = (d3d_video_t*)data; - if ( !d3d || - !d3d->renderchain_driver || + if ( !d3d || + !d3d->renderchain_driver || !d3d->renderchain_driver->viewport_info) return; @@ -372,7 +372,7 @@ static void d3d_overlay_render(d3d_video_t *d3d, video_frame_info_t *video_info, vert[i][7] = 1.0f; vert[i][8] = overlay->alpha_mod; } - + d3d_viewport_info(d3d, &vp); overlay_width = vp.width; @@ -514,7 +514,7 @@ void d3d_make_d3dpp(void *data, #ifdef _XBOX d3dpp->Windowed = false; #else - d3dpp->Windowed = settings->bools.video_windowed_fullscreen + d3dpp->Windowed = settings->bools.video_windowed_fullscreen || !info->fullscreen; #endif FS_PRESENTINTERVAL(d3dpp) = D3DPRESENT_INTERVAL_IMMEDIATE; @@ -545,13 +545,13 @@ void d3d_make_d3dpp(void *data, d3dpp->BackBufferFormat = #ifdef _XBOX360 global->console.screen.gamma_correction ? - (D3DFORMAT)MAKESRGBFMT(info->rgb32 ? + (D3DFORMAT)MAKESRGBFMT(info->rgb32 ? D3DFMT_X8R8G8B8 : D3DFMT_LIN_R5G6B5) : #endif info->rgb32 ? D3DFMT_X8R8G8B8 : D3DFMT_LIN_R5G6B5; #else d3dpp->hDeviceWindow = win32_get_window(); - d3dpp->BackBufferFormat = !d3dpp->Windowed ? + d3dpp->BackBufferFormat = !d3dpp->Windowed ? D3DFMT_X8R8G8B8 : D3DFMT_UNKNOWN; #endif @@ -647,7 +647,7 @@ static bool d3d_init_base(void *data, const video_info_t *info) #endif if (!d3d_create_device(&d3d->dev, &d3dpp, - g_pD3D, + g_pD3D, focus_window, d3d->cur_mon_id) ) @@ -724,8 +724,8 @@ static void d3d_calculate_rect(void *data, if (fabsf(device_aspect - desired_aspect) < 0.0001f) { - /* If the aspect ratios of screen and desired aspect - * ratio are sufficiently equal (floating point stuff), + /* If the aspect ratios of screen and desired aspect + * ratio are sufficiently equal (floating point stuff), * assume they are actually equal. */ } @@ -823,7 +823,7 @@ static bool d3d_initialize(d3d_video_t *d3d, const video_info_t *info) strlcpy(settings->paths.path_font, "game:\\media\\Arial_12.xpr", sizeof(settings->paths.path_font)); #endif - font_driver_init_osd(d3d, false, + font_driver_init_osd(d3d, false, info->is_threaded, FONT_DRIVER_RENDER_DIRECT3D_API); @@ -1513,8 +1513,8 @@ static bool d3d_read_viewport(void *data, uint8_t *buffer, bool is_idle) { d3d_video_t *d3d = (d3d_video_t*)data; - if ( !d3d || - !d3d->renderchain_driver || + if ( !d3d || + !d3d->renderchain_driver || !d3d->renderchain_driver->read_viewport) return false; @@ -1660,7 +1660,7 @@ static void video_texture_load_d3d(d3d_video_t *d3d, uintptr_t *id) { *id = (uintptr_t)d3d_texture_new(d3d->dev, NULL, - ti->width, ti->height, 1, + ti->width, ti->height, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, 0, 0, 0, NULL, NULL); } diff --git a/gfx/drivers/d3d.h b/gfx/drivers/d3d.h index efd0d7ca76..dc72306b8e 100644 --- a/gfx/drivers/d3d.h +++ b/gfx/drivers/d3d.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/gfx/drivers/dispmanx_gfx.c b/gfx/drivers/dispmanx_gfx.c index 18afe085ae..5eeaf51e7b 100644 --- a/gfx/drivers/dispmanx_gfx.c +++ b/gfx/drivers/dispmanx_gfx.c @@ -32,7 +32,7 @@ struct dispmanx_page { - /* Each page contains it's own resource handler + /* Each page contains it's own resource handler * instead of pointing to in by page number */ DISPMANX_RESOURCE_HANDLE_T resource; bool used; @@ -40,11 +40,11 @@ struct dispmanx_page * isolating it's used flag access. */ slock_t *page_used_mutex; - /* This field will allow us to access the + /* This field will allow us to access the * main _dispvars struct from the vsync CB function */ struct dispmanx_video *dispvars; - /* This field will allow us to access the + /* This field will allow us to access the * surface the page belongs to. */ struct dispmanx_surface *surface; }; @@ -60,23 +60,23 @@ struct dispmanx_surface * already when we enter the surface update function. No time to wait * for free pages before blitting and showing the just rendered frame! */ struct dispmanx_page *next_page; - unsigned int bpp; + unsigned int bpp; VC_RECT_T src_rect; VC_RECT_T dst_rect; VC_RECT_T bmp_rect; - /* Each surface has it's own element, and the + /* Each surface has it's own element, and the * resources are contained one in each page */ DISPMANX_ELEMENT_HANDLE_T element; - VC_DISPMANX_ALPHA_T alpha; + VC_DISPMANX_ALPHA_T alpha; VC_IMAGE_TYPE_T pixformat; - /* Surfaces with a higher layer will be on top of + /* Surfaces with a higher layer will be on top of * the ones with lower. Default is 0. */ int layer; - /* We need to keep this value for the blitting on + /* We need to keep this value for the blitting on * the surface_update function. */ int pitch; }; @@ -111,17 +111,17 @@ struct dispmanx_video bool rgb32; - /* We use this to keep track of internal resolution changes + /* We use this to keep track of internal resolution changes * done by cores in the main surface or in the menu. * We need these outside the surface because we free surfaces * and then we want to test if these values have changed before * recreating them. */ - int core_width; - int core_height; + int core_width; + int core_height; int core_pitch; - int menu_width; + int menu_width; int menu_height; - int menu_pitch; + int menu_pitch; /* Both main and menu surfaces are going to have the same aspect, * so we keep it here for future reference. */ float aspect_ratio; @@ -145,7 +145,7 @@ static struct dispmanx_page *dispmanx_get_free_page(struct dispmanx_video *_disp break; } } - + /* If no page is free at the moment, * wait until a free page is freed by vsync CB. */ if (!page) @@ -171,7 +171,7 @@ static void dispmanx_vsync_callback(DISPMANX_UPDATE_HANDLE_T u, void *data) struct dispmanx_surface *surface = page->surface; /* Marking the page as free must be done before the signaling - * so when update_main continues (it won't continue until we signal) + * so when update_main continues (it won't continue until we signal) * we can chose this page as free */ if (surface->current_page) { @@ -181,13 +181,13 @@ static void dispmanx_vsync_callback(DISPMANX_UPDATE_HANDLE_T u, void *data) surface->current_page->used = false; slock_unlock(surface->current_page->page_used_mutex); } - + /* The page on which we issued the flip that * caused this callback becomes the visible one */ surface->current_page = page; - /* These two things must be isolated "atomically" to avoid getting - * a false positive in the pending_mutex test in update_main. */ + /* These two things must be isolated "atomically" to avoid getting + * a false positive in the pending_mutex test in update_main. */ slock_lock(page->dispvars->pending_mutex); page->dispvars->pageflip_pending--; @@ -202,19 +202,19 @@ static void dispmanx_surface_free(struct dispmanx_video *_dispvars, int i; struct dispmanx_surface *surface = *sp; - /* What if we run into the vsync cb code after freeing the surface? + /* What if we run into the vsync cb code after freeing the surface? * We could be trying to get non-existant lock, signal non-existant condition.. - * So we wait for any pending flips to complete before freeing any surface. */ + * So we wait for any pending flips to complete before freeing any surface. */ slock_lock(_dispvars->pending_mutex); if (_dispvars->pageflip_pending > 0) scond_wait(_dispvars->vsync_condition, _dispvars->pending_mutex); slock_unlock(_dispvars->pending_mutex); for (i = 0; i < surface->numpages; i++) - { + { vc_dispmanx_resource_delete(surface->pages[i].resource); - surface->pages[i].used = false; - slock_free(surface->pages[i].page_used_mutex); + surface->pages[i].used = false; + slock_free(surface->pages[i].page_used_mutex); } free(surface->pages); @@ -238,12 +238,12 @@ static void dispmanx_surface_setup(struct dispmanx_video *_dispvars, *sp = calloc(1, sizeof(struct dispmanx_surface)); - surface = *sp; + surface = *sp; /* Setup surface parameters */ surface->numpages = numpages; - /* We receive the pitch for what we consider "useful info", - * excluding things that are between scanlines. + /* We receive the pitch for what we consider "useful info", + * excluding things that are between scanlines. * Then we align it to 16 pixels (not bytes) for performance reasons. */ surface->pitch = ALIGN_UP(visible_pitch, (pixformat == VC_IMAGE_XRGB8888 ? 64 : 32)); @@ -258,10 +258,10 @@ static void dispmanx_surface_setup(struct dispmanx_video *_dispvars, for (i = 0; i < surface->numpages; i++) { - surface->pages[i].used = false; - surface->pages[i].surface = surface; - surface->pages[i].dispvars = _dispvars; - surface->pages[i].page_used_mutex = slock_new(); + surface->pages[i].used = false; + surface->pages[i].surface = surface; + surface->pages[i].dispvars = _dispvars; + surface->pages[i].page_used_mutex = slock_new(); } /* No need to mutex this access to the "used" member because @@ -269,16 +269,16 @@ static void dispmanx_surface_setup(struct dispmanx_video *_dispvars, surface->next_page = &(surface->pages[0]); surface->next_page->used = true; - /* The "visible" width obtained from the core pitch. We blit based on + /* The "visible" width obtained from the core pitch. We blit based on * the "visible" width, for cores with things between scanlines. */ visible_width = visible_pitch / (bpp / 8); - + dst_width = _dispvars->dispmanx_height * aspect; dst_height = _dispvars->dispmanx_height; /* If we obtain a scaled image width that is bigger than the physical screen width, * then we keep the physical screen width as our maximun width. */ - if (dst_width > _dispvars->dispmanx_width) + if (dst_width > _dispvars->dispmanx_width) dst_width = _dispvars->dispmanx_width; dst_xpos = (_dispvars->dispmanx_width - dst_width) / 2; @@ -291,15 +291,15 @@ static void dispmanx_surface_setup(struct dispmanx_video *_dispvars, for (i = 0; i < surface->numpages; i++) { - surface->pages[i].resource = vc_dispmanx_resource_create(pixformat, + surface->pages[i].resource = vc_dispmanx_resource_create(pixformat, visible_width, src_height, &(_dispvars->vc_image_ptr)); } /* Add element. */ _dispvars->update = vc_dispmanx_update_start(0); surface->element = vc_dispmanx_element_add( - _dispvars->update,_dispvars->display, layer, - &surface->dst_rect, surface->pages[0].resource, + _dispvars->update,_dispvars->display, layer, + &surface->dst_rect, surface->pages[0].resource, &surface->src_rect, DISPMANX_PROTECTION_NONE, &surface->alpha, 0, (DISPMANX_TRANSFORM_T)0); @@ -309,7 +309,7 @@ static void dispmanx_surface_setup(struct dispmanx_video *_dispvars, static void dispmanx_surface_update_async(const void *frame, struct dispmanx_surface *surface) { struct dispmanx_page *page = NULL; - + /* Since it's an async update, there's no need for multiple pages */ page = &(surface->pages[0]); @@ -363,20 +363,20 @@ static void dispmanx_blank_console (struct dispmanx_video *_dispvars) /* Since pitch will be aligned to 16 pixels (not bytes) we use a * 16 pixels image to save the alignment */ uint16_t image[16] = {0x0000}; - float aspect = (float)_dispvars->dispmanx_width / (float)_dispvars->dispmanx_height; + float aspect = (float)_dispvars->dispmanx_width / (float)_dispvars->dispmanx_height; dispmanx_surface_setup(_dispvars, - 16, - 1, - 32, - 16, + 16, + 1, + 32, + 16, VC_IMAGE_RGB565, 255, aspect, 1, -1, &_dispvars->back_surface); - + /* Updating 1-page surface synchronously asks for truble, since the 1st CB will * signal but not free because the only page is on screen, so get_free will wait forever. */ dispmanx_surface_update_async(image, _dispvars->back_surface); @@ -393,8 +393,8 @@ static void *dispmanx_gfx_init(const video_info_t *video, bcm_host_init(); _dispvars->display = vc_dispmanx_display_open(0 /* LCD */); - /* If the console framebuffer has active overscan settings, - * the user must have overscan_scale=1 in config.txt to have + /* If the console framebuffer has active overscan settings, + * the user must have overscan_scale=1 in config.txt to have * the same size for both fb console and dispmanx. */ graphics_get_display_size(_dispvars->display, &_dispvars->dispmanx_width, &_dispvars->dispmanx_height); @@ -403,11 +403,11 @@ static void *dispmanx_gfx_init(const video_info_t *video, _dispvars->vc_image_ptr = 0; _dispvars->pageflip_pending = 0; _dispvars->menu_active = false; - _dispvars->rgb32 = video->rgb32; + _dispvars->rgb32 = video->rgb32; - /* It's very important that we set aspect here because the + /* It's very important that we set aspect here because the * call seq when a core is loaded is gfx_init()->set_aspect()->gfx_frame() - * and we don't want the main surface to be setup in set_aspect() + * and we don't want the main surface to be setup in set_aspect() * before we get to gfx_frame(). */ _dispvars->aspect_ratio = video_driver_get_aspect_ratio(); @@ -424,8 +424,8 @@ static void *dispmanx_gfx_init(const video_info_t *video, if (input && input_data) *input = NULL; - - /* Enable/disable dispmanx bilinear filtering. */ + + /* Enable/disable dispmanx bilinear filtering. */ dispmanx_set_scaling(video->smooth); dispmanx_blank_console(_dispvars); @@ -442,8 +442,8 @@ static bool dispmanx_gfx_frame(void *data, const void *frame, unsigned width, if (!frame) return true; - if ( (width != _dispvars->core_width) || - (height != _dispvars->core_height) || + if ( (width != _dispvars->core_width) || + (height != _dispvars->core_height) || (_dispvars->aspect_ratio != aspect)) { /* Sanity check. */ @@ -455,25 +455,25 @@ static bool dispmanx_gfx_frame(void *data, const void *frame, unsigned width, _dispvars->core_pitch = pitch; _dispvars->aspect_ratio = aspect; - if (_dispvars->main_surface != NULL) + if (_dispvars->main_surface != NULL) dispmanx_surface_free(_dispvars, &_dispvars->main_surface); - /* Internal resolution or ratio has changed, so we need + /* Internal resolution or ratio has changed, so we need * to recreate the main surface. */ - dispmanx_surface_setup(_dispvars, - width, - height, - pitch, + dispmanx_surface_setup(_dispvars, + width, + height, + pitch, _dispvars->rgb32 ? 32 : 16, _dispvars->rgb32 ? VC_IMAGE_XRGB8888 : VC_IMAGE_RGB565, 255, - _dispvars->aspect_ratio, + _dispvars->aspect_ratio, video_info->max_swapchain_images, 0, &_dispvars->main_surface); - /* We need to recreate the menu surface too, if it exists already, so we - * free it and let dispmanx_set_texture_frame() recreate it as it detects it's NULL.*/ + /* We need to recreate the menu surface too, if it exists already, so we + * free it and let dispmanx_set_texture_frame() recreate it as it detects it's NULL.*/ if (_dispvars->menu_active && _dispvars->menu_surface) dispmanx_surface_free(_dispvars, &_dispvars->menu_surface); } @@ -514,14 +514,14 @@ static void dispmanx_set_texture_frame(void *data, const void *frame, bool rgb32 _dispvars->menu_pitch = width * (rgb32 ? 4 : 2); /* Menu surface only needs a page as it will be updated asynchronously. */ - dispmanx_surface_setup(_dispvars, - width, - height, - _dispvars->menu_pitch, + dispmanx_surface_setup(_dispvars, + width, + height, + _dispvars->menu_pitch, 16, VC_IMAGE_RGBA16, 210, - _dispvars->aspect_ratio, + _dispvars->aspect_ratio, 1, 0, &_dispvars->menu_surface); @@ -583,7 +583,7 @@ static bool dispmanx_gfx_set_shader(void *data, (void)type; (void)path; - return false; + return false; } static void dispmanx_gfx_set_rotation(void *data, unsigned rotation) @@ -600,15 +600,15 @@ static bool dispmanx_gfx_read_viewport(void *data, uint8_t *buffer, bool is_idle return true; } -static void dispmanx_set_aspect_ratio (void *data, unsigned aspect_ratio_idx) +static void dispmanx_set_aspect_ratio (void *data, unsigned aspect_ratio_idx) { /* Due to RetroArch setting the data pointer to NULL internally * on core change, data is going to be NULL here after we load - * a new core from the GUI, so we can't count on accessing it - * to store the aspect ratio we are going to use, so we tell RA + * a new core from the GUI, so we can't count on accessing it + * to store the aspect ratio we are going to use, so we tell RA * to keep track of the new aspect ratio and we get it in gfx_frame() - * with video_driver_get_aspect_ratio() to find out if it has changed. */ - + * with video_driver_get_aspect_ratio() to find out if it has changed. */ + switch (aspect_ratio_idx) { case ASPECT_RATIO_SQUARE: @@ -669,7 +669,7 @@ static void dispmanx_gfx_free(void *data) dispmanx_surface_free(_dispvars, &_dispvars->main_surface); dispmanx_surface_free(_dispvars, &_dispvars->back_surface); - if (_dispvars->menu_surface) + if (_dispvars->menu_surface) dispmanx_surface_free(_dispvars, &_dispvars->menu_surface); /* Close display and deinitialize. */ diff --git a/gfx/drivers/drm_gfx.c b/gfx/drivers/drm_gfx.c index 01fb0dec6a..4516bd10e1 100644 --- a/gfx/drivers/drm_gfx.c +++ b/gfx/drivers/drm_gfx.c @@ -68,18 +68,18 @@ struct drm_rect struct drm_page { - struct modeset_buf buf; + struct modeset_buf buf; bool used; /* Each page has it's own mutex for * isolating it's used flag access. */ slock_t *page_used_mutex; - /* This field will allow us to access the + /* This field will allow us to access the * main _dispvars struct from the vsync CB function */ - struct drm_video *drmvars; + struct drm_video *drmvars; - /* This field will allow us to access the + /* This field will allow us to access the * surface the page belongs to. */ struct drm_surface *surface; }; @@ -93,18 +93,18 @@ struct drm_surface /* the page that's currently on screen */ struct drm_page *current_page; - unsigned int bpp; + unsigned int bpp; uint32_t pixformat; - + /* The internal buffers size. */ int src_width; int src_height; - /* Surfaces with a higher layer will be on top of + /* Surfaces with a higher layer will be on top of * the ones with lower. Default is 0. */ int layer; - /* We need to keep this value for the blitting on + /* We need to keep this value for the blitting on * the surface_update function. */ int pitch; int total_pitch; @@ -123,7 +123,7 @@ struct drm_struct drmModeCrtcPtr orig_crtc; - uint32_t plane_id; + uint32_t plane_id; uint32_t plane_fb_prop_id; drmModeEncoder *encoder; @@ -136,13 +136,13 @@ struct drm_video struct drm_surface *main_surface; struct drm_surface *menu_surface; - /* Total dispmanx video dimensions. + /* Total dispmanx video dimensions. * Not counting overscan settings. */ unsigned int kms_width; unsigned int kms_height; /* For threading */ - scond_t *vsync_condition; + scond_t *vsync_condition; slock_t *vsync_cond_mutex; slock_t *pending_mutex; @@ -151,13 +151,13 @@ struct drm_video bool rgb32; - /* We use this to keep track of internal resolution changes + /* We use this to keep track of internal resolution changes * done by cores in the main surface or in the menu. * We need these outside the surface because we free surfaces * and then we want to test if these values have changed before * recreating them. */ - int core_width; - int core_height; + int core_width; + int core_height; int core_pitch; /* Both main and menu surfaces are going to have the same aspect, * so we keep it here for future reference. */ @@ -172,15 +172,15 @@ static int modeset_create_dumbfb(int fd, static void deinit_drm(void) { - /* Restore the original videomode/connector/scanoutbuffer(fb) - * combination (the original CRTC, that is). */ + /* Restore the original videomode/connector/scanoutbuffer(fb) + * combination (the original CRTC, that is). */ drmModeSetCrtc(drm.fd, drm.orig_crtc->crtc_id, drm.orig_crtc->buffer_id, drm.orig_crtc->x, drm.orig_crtc->y, - &drm.connector_id, 1, &drm.orig_crtc->mode); + &drm.connector_id, 1, &drm.orig_crtc->mode); #if 0 - /* TODO: Free surfaces here along + /* TODO: Free surfaces here along * with their pages (framebuffers)! */ if (bufs[0].fb_id) @@ -193,12 +193,12 @@ static void deinit_drm(void) static void drm_surface_free(void *data, struct drm_surface **sp) { - int i; + int i; struct drm_video *_drmvars = data; struct drm_surface *surface = *sp; for (i = 0; i < surface->numpages; i++) - surface->pages[i].used = false; + surface->pages[i].used = false; free(surface->pages); @@ -212,9 +212,9 @@ static void drm_surface_set_aspect(struct drm_surface *surface, float aspect) surface->aspect = aspect; } -static void drm_surface_setup(void *data, int src_width, int src_height, +static void drm_surface_setup(void *data, int src_width, int src_height, int pitch, int bpp, uint32_t pixformat, - int alpha, float aspect, int numpages, int layer, + int alpha, float aspect, int numpages, int layer, struct drm_surface **sp) { struct drm_video *_drmvars = data; @@ -223,23 +223,23 @@ static void drm_surface_setup(void *data, int src_width, int src_height, *sp = calloc (1, sizeof(struct drm_surface)); - surface = *sp; + surface = *sp; /* Setup surface parameters */ surface->numpages = numpages; - /* We receive the total pitch, including things that are - * between scanlines and we calculate the visible pitch - * from the visible width. + /* We receive the total pitch, including things that are + * between scanlines and we calculate the visible pitch + * from the visible width. * * These will be used to increase the offsets for blitting. */ surface->total_pitch = pitch; - surface->pitch = src_width * bpp; + surface->pitch = src_width * bpp; surface->bpp = bpp; surface->pixformat = pixformat; surface->src_width = src_width; surface->src_height = src_height; surface->aspect = aspect; - + /* Allocate memory for all the pages in each surface * and initialize variables inside each page's struct. */ surface->pages = (struct drm_page*) @@ -247,10 +247,10 @@ static void drm_surface_setup(void *data, int src_width, int src_height, for (i = 0; i < surface->numpages; i++) { - surface->pages[i].used = false; - surface->pages[i].surface = surface; - surface->pages[i].drmvars = _drmvars; - surface->pages[i].page_used_mutex = slock_new(); + surface->pages[i].used = false; + surface->pages[i].surface = surface; + surface->pages[i].drmvars = _drmvars; + surface->pages[i].page_used_mutex = slock_new(); } /* Create the framebuffer for each one of the pages of the surface. */ @@ -259,7 +259,7 @@ static void drm_surface_setup(void *data, int src_width, int src_height, surface->pages[i].buf.width = src_width; surface->pages[i].buf.height = src_height; int ret = modeset_create_dumbfb( - drm.fd, &surface->pages[i].buf, bpp, pixformat); + drm.fd, &surface->pages[i].buf, bpp, pixformat); if (ret) { @@ -272,20 +272,20 @@ static void drm_surface_setup(void *data, int src_width, int src_height, static void drm_page_flip(struct drm_surface *surface) { - /* We alredy have the id of the FB_ID property of + /* We alredy have the id of the FB_ID property of * the plane on which we are going to do a pageflip: * we got it back in drm_plane_setup() */ int ret; static drmModeAtomicReqPtr req = NULL; - req = drmModeAtomicAlloc(); + req = drmModeAtomicAlloc(); - /* We add the buffer to the plane properties we want to - * set on an atomically, in a single step. + /* We add the buffer to the plane properties we want to + * set on an atomically, in a single step. * We pass the plane id, the property id and the new fb id. */ - ret = drmModeAtomicAddProperty(req, - drm.plane_id, - drm.plane_fb_prop_id, + ret = drmModeAtomicAddProperty(req, + drm.plane_id, + drm.plane_fb_prop_id, surface->pages[surface->flip_page].buf.fb_id); if (ret < 0) @@ -294,9 +294,9 @@ static void drm_page_flip(struct drm_surface *surface) } /*... now we just need to do the commit */ - /* REMEMBER!!! The DRM_MODE_PAGE_FLIP_EVENT flag asks the kernel - * to send you an event to the drm.fd once the - * pageflip is complete. If you don't want -12 errors + /* REMEMBER!!! The DRM_MODE_PAGE_FLIP_EVENT flag asks the kernel + * to send you an event to the drm.fd once the + * pageflip is complete. If you don't want -12 errors * (ENOMEM), namely "Cannot allocate memory", then * you must drain the event queue of that fd. */ ret = drmModeAtomicCommit(drm.fd, req, 0, NULL); @@ -324,7 +324,7 @@ static void drm_surface_update(void *data, const void *frame, for (line = 0; line < surface->src_height; line++) { memcpy ( - surface->pages[surface->flip_page].buf.map + dst_offset, + surface->pages[surface->flip_page].buf.map + dst_offset, (uint8_t*)frame + src_offset, surface->pitch); src_offset += surface->total_pitch; @@ -342,7 +342,7 @@ static uint32_t get_plane_prop_id(uint32_t obj_id, const char *name) int i,j; drmModePlaneRes *plane_resources; drmModePlane *plane; - drmModeObjectProperties *props; + drmModeObjectProperties *props; drmModePropertyRes **props_info; char format_str[5]; @@ -354,16 +354,16 @@ static uint32_t get_plane_prop_id(uint32_t obj_id, const char *name) if (plane->plane_id != obj_id) continue; - /* TODO: Improvement. We get all the properties of the + /* TODO: Improvement. We get all the properties of the * plane and info about the properties. - * We should have done this already... + * We should have done this already... * This implementation must be improved. */ props = drmModeObjectGetProperties(drm.fd, plane->plane_id, DRM_MODE_OBJECT_PLANE); props_info = malloc(props->count_props * sizeof *props_info); for (j = 0; j < props->count_props; ++j) - props_info[j] = drmModeGetProperty(drm.fd, props->props[j]); + props_info[j] = drmModeGetProperty(drm.fd, props->props[j]); /* We look for the prop_id we need */ for (j = 0; j < props->count_props; j++) @@ -409,7 +409,7 @@ static uint64_t drm_plane_type(drmModePlane *plane) * access them simultaneously here. * We are interested in OVERLAY planes only, that's type 0 or DRM_PLANE_TYPE_OVERLAY * (see /usr/xf86drmMode.h for definition). */ - drmModeObjectPropertiesPtr props = + drmModeObjectPropertiesPtr props = drmModeObjectGetProperties(drm.fd, plane->plane_id, DRM_MODE_OBJECT_PLANE); for (j = 0; j < props->count_props; j++) @@ -421,14 +421,14 @@ static uint64_t drm_plane_type(drmModePlane *plane) return (0); } -/* This configures our only overlay plane to render the given surface. */ +/* This configures our only overlay plane to render the given surface. */ static void drm_plane_setup(struct drm_surface *surface) { int i,j; char fmt_name[5]; /* Get plane resources */ - drmModePlane *plane; + drmModePlane *plane; drmModePlaneRes *plane_resources; plane_resources = drmModeGetPlaneResources(drm.fd); if (!plane_resources) @@ -437,14 +437,14 @@ static void drm_plane_setup(struct drm_surface *surface) } RARCH_LOG ("DRM: Number of planes on FD %d is %d\n", - drm.fd, plane_resources->count_planes); + drm.fd, plane_resources->count_planes); - /* dump_planes(drm.fd); */ + /* dump_planes(drm.fd); */ - /* Look for a plane/overlay we can use with the configured CRTC + /* Look for a plane/overlay we can use with the configured CRTC * Find a plane which can be connected to our CRTC. Find the * CRTC index first, then iterate over available planes. - * Yes, strangely we need the in-use CRTC index to mask possible_crtc + * Yes, strangely we need the in-use CRTC index to mask possible_crtc * during the planes iteration... */ unsigned int crtc_index = 0; for (i = 0; i < (unsigned int)drm.resources->count_crtcs; i++) @@ -457,8 +457,8 @@ static void drm_plane_setup(struct drm_surface *surface) } } - /* Programmer!! Save your sanity!! Primary planes have to - * cover the entire CRTC, and if you don't do that, you + /* Programmer!! Save your sanity!! Primary planes have to + * cover the entire CRTC, and if you don't do that, you * will get dmesg error "Plane must cover entire CRTC". * * Look at linux/source/drivers/gpu/drm/drm_plane_helper.c comments for more info. @@ -473,20 +473,20 @@ static void drm_plane_setup(struct drm_surface *surface) continue; } - /* We are only interested in overlay planes. No overlay, no fun. + /* We are only interested in overlay planes. No overlay, no fun. * (no scaling, must cover crtc..etc) so we skip primary planes */ if (drm_plane_type(plane) != DRM_PLANE_TYPE_OVERLAY) { RARCH_LOG ("DRM: plane with ID %d is not an overlay. May be primary or cursor. Not usable.\n", plane->plane_id); continue; - } + } if (!format_support(plane, surface->pixformat)) { RARCH_LOG ("DRM: plane with ID %d does not support framebuffer format\n", plane->plane_id); continue; - } + } drm.plane_id = plane->plane_id; drmModeFreePlane(plane); @@ -504,7 +504,7 @@ static void drm_plane_setup(struct drm_surface *surface) } /* We are going to be changing the framebuffer ID property of the chosen overlay every time - * we do a pageflip, so we get the property ID here to have it handy on the PageFlip function. */ + * we do a pageflip, so we get the property ID here to have it handy on the PageFlip function. */ drm.plane_fb_prop_id = get_plane_prop_id(drm.plane_id, "FB_ID"); if (!drm.plane_fb_prop_id) { @@ -531,14 +531,14 @@ static void drm_plane_setup(struct drm_surface *surface) uint32_t src_x = 0; uint32_t src_y = 0; - /* We have to set a buffer for the plane, whatever buffer we want, + /* We have to set a buffer for the plane, whatever buffer we want, * but we must set a buffer so the plane starts reading from it now. */ - if (drmModeSetPlane(drm.fd, drm.plane_id, drm.crtc_id, + if (drmModeSetPlane(drm.fd, drm.plane_id, drm.crtc_id, surface->pages[surface->flip_page].buf.fb_id, plane_flags, plane_x, plane_y, plane_w, plane_h, src_x<<16, src_y<<16, src_w<<16, src_h<<16)) { - RARCH_ERR("[DRM]: failed to enable plane: %s\n", strerror(errno)); + RARCH_ERR("[DRM]: failed to enable plane: %s\n", strerror(errno)); } RARCH_LOG("[DRM]: src_w %d, src_h %d, plane_w %d, plane_h %d\n", @@ -615,7 +615,7 @@ static bool init_drm(void) * VERY important or we won't get all the available planes on drmGetPlaneResources()! * We also need to enable the ATOMIC cap to see the atomic properties in objects!! */ ret = drmSetClientCap(drm.fd, DRM_CLIENT_CAP_UNIVERSAL_PLANES, 1); - if (ret) + if (ret) RARCH_ERR ("DRM: can't set UNIVERSAL PLANES cap.\n"); else RARCH_LOG ("DRM: UNIVERSAL PLANES cap set\n"); @@ -623,8 +623,8 @@ static bool init_drm(void) ret = drmSetClientCap(drm.fd, DRM_CLIENT_CAP_ATOMIC, 1); if (ret) - { - /*If this happens, check kernel support and kernel parameters + { + /*If this happens, check kernel support and kernel parameters * (add i915.nuclear_pageflip=y to the kernel boot line for example) */ RARCH_ERR ("DRM: can't set ATOMIC caps: %s\n", strerror(errno)); } @@ -674,7 +674,7 @@ static bool init_drm(void) drm.crtc_id = drm.encoder->crtc_id; drm.connector_id = connector->connector_id; - /* Backup original crtc and it's mode, so we can restore the original video mode + /* Backup original crtc and it's mode, so we can restore the original video mode * on exit in case we change it. */ drm.orig_crtc = drmModeGetCrtc(drm.fd, drm.encoder->crtc_id); drm.current_mode = &(drm.orig_crtc->mode); @@ -683,7 +683,7 @@ static bool init_drm(void) struct modeset_buf buf; buf.width = drm.current_mode->hdisplay; buf.height = drm.current_mode->vdisplay; - ret = modeset_create_dumbfb(drm.fd, &buf, 4, DRM_FORMAT_XRGB8888); + ret = modeset_create_dumbfb(drm.fd, &buf, 4, DRM_FORMAT_XRGB8888); if (ret) { RARCH_ERR ("DRM: can't create dumb fb\n"); @@ -692,7 +692,7 @@ static bool init_drm(void) if (drmModeSetCrtc(drm.fd, drm.crtc_id, buf.fb_id, 0, 0, &drm.connector_id, 1, drm.current_mode)) { - RARCH_ERR ("DRM: failed to set mode\n"); + RARCH_ERR ("DRM: failed to set mode\n"); return false; } @@ -710,11 +710,11 @@ static void *drm_gfx_init(const video_info_t *video, /* Setup surface parameters */ _drmvars->menu_active = false; - _drmvars->rgb32 = video->rgb32; + _drmvars->rgb32 = video->rgb32; - /* It's very important that we set aspect here because the + /* It's very important that we set aspect here because the * call seq when a core is loaded is gfx_init()->set_aspect()->gfx_frame() - * and we don't want the main surface to be setup in set_aspect() + * and we don't want the main surface to be setup in set_aspect() * before we get to gfx_frame(). */ _drmvars->current_aspect = video_driver_get_aspect_ratio(); @@ -743,9 +743,9 @@ static void *drm_gfx_init(const video_info_t *video, RARCH_LOG ("DRM: Init successful.\n"); } - _drmvars->kms_width = drm.current_mode->hdisplay; - _drmvars->kms_height = drm.current_mode->vdisplay; - + _drmvars->kms_width = drm.current_mode->hdisplay; + _drmvars->kms_height = drm.current_mode->vdisplay; + return _drmvars; } @@ -755,7 +755,7 @@ static bool drm_gfx_frame(void *data, const void *frame, unsigned width, { struct drm_video *_drmvars = data; - if ( ( width != _drmvars->core_width) || + if ( ( width != _drmvars->core_width) || (height != _drmvars->core_height)) { /* Sanity check. */ @@ -766,22 +766,22 @@ static bool drm_gfx_frame(void *data, const void *frame, unsigned width, _drmvars->core_height = height; _drmvars->core_pitch = pitch; - if (_drmvars->main_surface != NULL) + if (_drmvars->main_surface != NULL) drm_surface_free(_drmvars, &_drmvars->main_surface); /* We need to recreate the main surface and it's pages (buffers). */ - drm_surface_setup(_drmvars, - width, - height, - pitch, + drm_surface_setup(_drmvars, + width, + height, + pitch, _drmvars->rgb32 ? 4 : 2, _drmvars->rgb32 ? DRM_FORMAT_XRGB8888 : DRM_FORMAT_RGB565, 255, - _drmvars->current_aspect, + _drmvars->current_aspect, 3, 0, &_drmvars->main_surface); - + /* We need to change the plane to read from the main surface */ drm_plane_setup(_drmvars->main_surface); } @@ -820,34 +820,34 @@ static void drm_set_texture_frame(void *data, const void *frame, bool rgb32, if (!_drmvars->menu_active) return; - /* If menu is active in this frame but the + /* If menu is active in this frame but the * menu surface is NULL, we allocate a new one.*/ if (!_drmvars->menu_surface) { - drm_surface_setup(_drmvars, - width, - height, - width * 4, + drm_surface_setup(_drmvars, + width, + height, + width * 4, 4, DRM_FORMAT_XRGB8888, 210, - _drmvars->current_aspect, + _drmvars->current_aspect, 2, 0, &_drmvars->menu_surface); - /* We need to re-setup the ONLY plane as the setup + /* We need to re-setup the ONLY plane as the setup * depends on input buffers dimensions. */ drm_plane_setup(_drmvars->menu_surface); } - /* We have to go on a pixel format conversion adventure - * for now, until we can convince RGUI to output + /* We have to go on a pixel format conversion adventure + * for now, until we can convince RGUI to output * in an 8888 format. */ - unsigned int src_pitch = width * 2; + unsigned int src_pitch = width * 2; unsigned int dst_pitch = width * 4; unsigned int dst_width = width; - uint32_t line[dst_width]; + uint32_t line[dst_width]; /* The output pixel array with the converted pixels. */ char *frame_output = (char *) malloc (dst_pitch * height); @@ -859,12 +859,12 @@ static void drm_set_texture_frame(void *data, const void *frame, bool rgb32, { for (j = 0; j < src_pitch / 2; j++) { - uint16_t src_pix = *((uint16_t*)frame + (src_pitch / 2 * i) + j); + uint16_t src_pix = *((uint16_t*)frame + (src_pitch / 2 * i) + j); /* The hex AND is for keeping only the part we need for each component. */ uint32_t R = (src_pix << 8) & 0x00FF0000; uint32_t G = (src_pix << 4) & 0x0000FF00; uint32_t B = (src_pix << 0) & 0x000000FF; - line[j] = (0 | R | G | B); + line[j] = (0 | R | G | B); } memcpy(dst_base_addr + (dst_pitch * i), (char*)line, dst_pitch); } @@ -923,7 +923,7 @@ static bool drm_gfx_set_shader(void *data, (void)type; (void)path; - return false; + return false; } static void drm_gfx_set_rotation(void *data, unsigned rotation) @@ -940,20 +940,20 @@ static bool drm_gfx_read_viewport(void *data, uint8_t *buffer, bool is_idle) return true; } -static void drm_set_aspect_ratio (void *data, unsigned aspect_ratio_idx) +static void drm_set_aspect_ratio (void *data, unsigned aspect_ratio_idx) { struct drm_video *_drmvars = data; /* Here we obtain the new aspect ratio. */ float new_aspect = aspectratio_lut[aspect_ratio_idx].value; if (_drmvars->current_aspect != new_aspect) - { + { _drmvars->current_aspect = new_aspect; drm_surface_set_aspect(_drmvars->main_surface, new_aspect); if (_drmvars->menu_active) { drm_surface_set_aspect(_drmvars->menu_surface, new_aspect); - drm_plane_setup(_drmvars->menu_surface); + drm_plane_setup(_drmvars->menu_surface); } } } @@ -996,13 +996,13 @@ static void drm_gfx_free(void *data) drm_surface_free(_drmvars, &_drmvars->main_surface); - if (_drmvars->menu_surface) + if (_drmvars->menu_surface) drm_surface_free(_drmvars, &_drmvars->menu_surface); /* Destroy mutexes and conditions. */ slock_free(_drmvars->pending_mutex); slock_free(_drmvars->vsync_cond_mutex); - scond_free(_drmvars->vsync_condition); + scond_free(_drmvars->vsync_condition); free(_drmvars); } diff --git a/gfx/drivers/exynos_gfx.c b/gfx/drivers/exynos_gfx.c index 4b0476f4b5..6d0efe41e7 100644 --- a/gfx/drivers/exynos_gfx.c +++ b/gfx/drivers/exynos_gfx.c @@ -195,10 +195,10 @@ static int exynos_get_device_index(void) return index; } -/* The main pageflip handler, which the DRM executes +/* The main pageflip handler, which the DRM executes * when it flips to the page. * - * Decreases the pending pageflip count and + * Decreases the pending pageflip count and * updates the current page. */ static void exynos_page_flip_handler(int fd, unsigned frame, unsigned sec, @@ -222,7 +222,7 @@ static struct exynos_page *exynos_get_free_page( { unsigned i; - for (i = 0; i < cnt; ++i) + for (i = 0; i < cnt; ++i) { if (!p[i].used) return &p[i]; @@ -1513,7 +1513,7 @@ static bool exynos_gfx_set_shader(void *data, (void)type; (void)path; - return false; + return false; } static bool exynos_gfx_read_viewport(void *data, uint8_t *buffer, bool is_idle) diff --git a/gfx/drivers/gdi_gfx.c b/gfx/drivers/gdi_gfx.c index b1ded17fdb..c28aa01784 100644 --- a/gfx/drivers/gdi_gfx.c +++ b/gfx/drivers/gdi_gfx.c @@ -190,7 +190,7 @@ static bool gdi_gfx_frame(void *data, const void *frame, bool draw = true; gdi_t *gdi = (gdi_t*)data; HWND hwnd = win32_get_window(); - BITMAPINFO *info; + BITMAPINFO *info; if (!frame || !frame_width || !frame_height) return true; @@ -493,7 +493,7 @@ static void gdi_set_texture_frame(void *data, } } -static void gdi_set_osd_msg(void *data, +static void gdi_set_osd_msg(void *data, video_frame_info_t *video_info, const char *msg, const void *params, void *font) diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index c717513f74..27c79b9a1e 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -740,19 +740,19 @@ static void gl_render_osd_background( video_coords_t coords; struct uniform_info uniform_param; float colors[4]; - const unsigned + const unsigned vertices_total = 6; float *dummy = (float*)calloc(4 * vertices_total, sizeof(float)); float *verts = (float*)malloc(2 * vertices_total * sizeof(float)); settings_t *settings = config_get_ptr(); - int msg_width = + int msg_width = font_driver_get_message_width(NULL, msg, strlen(msg), 1.0f); /* shader driver expects vertex coords as 0..1 */ float x = video_info->font_msg_pos_x; float y = video_info->font_msg_pos_y; float width = msg_width / (float)video_info->width; - float height = + float height = settings->floats.video_font_size / (float)video_info->height; float x2 = 0.005f; /* extend background around text */ @@ -796,7 +796,7 @@ static void gl_render_osd_background( coords_data.handle_data = NULL; coords_data.data = &coords; - + video_driver_set_viewport(video_info->width, video_info->height, true, false); @@ -1033,7 +1033,7 @@ static bool gl_frame(void *data, const void *frame, glBindTexture(GL_TEXTURE_2D, gl->texture[gl->tex_index]); /* Can be NULL for frame dupe / NULL render. */ - if (frame) + if (frame) { if (!gl->hw_render_fbo_init) { @@ -1082,7 +1082,7 @@ static bool gl_frame(void *data, const void *frame, if (gl->fbo_feedback_enable) { - const struct video_fbo_rect + const struct video_fbo_rect *rect = &gl->fbo_rect[gl->fbo_feedback_pass]; GLfloat xamt = (GLfloat)rect->img_width / rect->width; GLfloat yamt = (GLfloat)rect->img_height / rect->height; @@ -1946,7 +1946,7 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo video_context_driver_input_driver(&inp); if (video->font_enable) - font_driver_init_osd(gl, false, + font_driver_init_osd(gl, false, video->is_threaded, FONT_DRIVER_RENDER_OPENGL_API); diff --git a/gfx/drivers/gl_shaders/pipeline_snowflake.glsl.frag.h b/gfx/drivers/gl_shaders/pipeline_snowflake.glsl.frag.h index 1b048d2223..c6ad48e071 100644 --- a/gfx/drivers/gl_shaders/pipeline_snowflake.glsl.frag.h +++ b/gfx/drivers/gl_shaders/pipeline_snowflake.glsl.frag.h @@ -1,4 +1,4 @@ -/* credits to: TheTimJames +/* credits to: TheTimJames https://www.shadertoy.com/view/Md2GRw */ @@ -17,17 +17,17 @@ static const char* stock_fragment_xmb_snowflake = GLSL( } float rand_float(float x) - { + { return rand(vec2(x, 1.0)); } - + float snow(vec3 pos, vec2 uv, float o) { vec2 d = (pos.xy - uv); float a = atan(d.y,d.x) + sin(atime*1.0 + o) * 10.0; - + float dist = d.x*d.x + d.y*d.y; - + if(dist < pos.z/400.0) { float col = 0.0; @@ -41,7 +41,7 @@ static const char* stock_fragment_xmb_snowflake = GLSL( } return col * pos.z; } - + return 0.0; } @@ -54,12 +54,12 @@ static const char* stock_fragment_xmb_snowflake = GLSL( float z = rand_float(float(i) + 13.0); float x = 1.8 - (3.6) * (rand_float(floor((time*((z + 1.0) / 2.0) +o) / 2.0)) + sin(time * o /1000.0) / 10.0); float y = 1.0 - mod((time * ((z + 1.0)/2.0)) + o, 2.0); - - color += snow(vec3(x,y,z), c, o); + + color += snow(vec3(x,y,z), c, o); } - + return color; - } + } void main(void) { @@ -67,9 +67,9 @@ static const char* stock_fragment_xmb_snowflake = GLSL( uv = uv * 2.0 - 1.0; vec2 p = uv; p.x *= OutputSize.x / OutputSize.y; - + atime = (time + 1.0) / 4.0; - + gl_FragColor = vec4(col(p)); } diff --git a/gfx/drivers/gl_shaders/pipeline_xmb_ribbon_simple.cg.h b/gfx/drivers/gl_shaders/pipeline_xmb_ribbon_simple.cg.h index 256ae4378b..52f2385bbe 100644 --- a/gfx/drivers/gl_shaders/pipeline_xmb_ribbon_simple.cg.h +++ b/gfx/drivers/gl_shaders/pipeline_xmb_ribbon_simple.cg.h @@ -51,7 +51,7 @@ static const char *stock_xmb_ribbon_simple = CG( float4 color : COLOR; }; - output main_fragment(uniform input IN) + output main_fragment(uniform input IN) { output OUT; OUT.color = float4(0.05, 0.05, 0.05, 1.0); diff --git a/gfx/drivers/gx_gfx.c b/gfx/drivers/gx_gfx.c index 14b7f61c38..7726a4a876 100644 --- a/gfx/drivers/gx_gfx.c +++ b/gfx/drivers/gx_gfx.c @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis * Copyright (C) 2012-2015 - Michael Lelli - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -270,7 +270,7 @@ static void retrace_callback(u32 retrace_count) static bool gx_isValidXOrigin(int origin) { - if(origin < 0 || origin + gx_used_system_xOrigin < 0 || + if(origin < 0 || origin + gx_used_system_xOrigin < 0 || gx_mode.viWidth + origin + gx_used_system_xOrigin > 720) return false; return true; @@ -304,7 +304,7 @@ static void gx_set_video_mode(void *data, unsigned fbWidth, unsigned lines, VIDEO_SetPostRetraceCallback(NULL); g_draw_done = false; /* wait for next even field */ - /* this prevents screen artifacts when switching + /* this prevents screen artifacts when switching * between interlaced & non-interlaced modes */ do VIDEO_WaitVSync(); while (!VIDEO_GetNextField()); @@ -418,7 +418,7 @@ static void gx_set_video_mode(void *data, unsigned fbWidth, unsigned lines, } gx_mode.viXOrigin = gx_xOrigin = tmpOrigin; - gx_mode.viYOrigin = gx_yOrigin = + gx_mode.viYOrigin = gx_yOrigin = (max_height - gx_mode.viHeight) / (2 * viHeightMultiplier); gx_xOriginNeg = 0, gx_xOriginPos = 0; @@ -485,7 +485,7 @@ static void gx_set_video_mode(void *data, unsigned fbWidth, unsigned lines, GX_SetDispCopyDst((u16)xfbWidth, (u16)xfbHeight); GX_SetCopyFilter(gx_mode.aa, gx_mode.sample_pattern, - (gx_mode.xfbMode == VI_XFBMODE_SF) + (gx_mode.xfbMode == VI_XFBMODE_SF) ? GX_FALSE : settings->bools.video_vfilter, gx_mode.vfilter); GXColor color = { 0, 0, 0, 0xff }; @@ -495,7 +495,7 @@ static void gx_set_video_mode(void *data, unsigned fbWidth, unsigned lines, GX_SetPixelFmt(GX_PF_RGB8_Z24, GX_ZC_LINEAR); GX_InvalidateTexAll(); GX_Flush(); - + /* Now apply all the configuration to the screen */ VIDEO_Configure(&gx_mode); VIDEO_ClearFrameBuffer(&gx_mode, gx->framebuf[0], COLOR_BLACK); @@ -507,7 +507,7 @@ static void gx_set_video_mode(void *data, unsigned fbWidth, unsigned lines, VIDEO_SetBlack(false); VIDEO_Flush(); VIDEO_WaitVSync(); - + RARCH_LOG("[GX]: Resolution: %dx%d (%s)\n", gx_mode.fbWidth, gx_mode.efbHeight, (gx_mode.viTVMode & 3) == VI_INTERLACE ? "interlaced" : "progressive"); @@ -524,7 +524,7 @@ static void gx_set_video_mode(void *data, unsigned fbWidth, unsigned lines, if (modetype == VI_NON_INTERLACE) refresh_rate = 59.8261f; } - + driver_ctl(RARCH_DRIVER_CTL_SET_REFRESH_RATE, &refresh_rate); } @@ -977,8 +977,8 @@ static void gx_resize(void *data) #endif if (fabs(device_aspect - desired_aspect) < 0.0001) { - /* If the aspect ratios of screen and desired aspect ratio - * are sufficiently equal (floating point stuff), + /* If the aspect ratios of screen and desired aspect ratio + * are sufficiently equal (floating point stuff), * assume they are actually equal. */ } else if (device_aspect > desired_aspect) @@ -1111,8 +1111,8 @@ static void gx_blit_line(gx_video_t *gx, { uint8_t rem = 1 << ((i + j * FONT_WIDTH) & 7); unsigned offset = (i + j * FONT_WIDTH) >> 3; - bool col = - (bitmap_bin[FONT_OFFSET((unsigned char)*message) + offset] + bool col = + (bitmap_bin[FONT_OFFSET((unsigned char)*message) + offset] & rem); GXColor c = b; @@ -1213,7 +1213,7 @@ static void gx_set_texture_enable(void *data, bool enable, bool full_screen) return; gx->menu_texture_enable = enable; - /* need to make sure the game texture is the right pixel + /* need to make sure the game texture is the right pixel * format for menu overlay. */ gx->should_resize = true; } @@ -1379,7 +1379,7 @@ static bool gx_overlay_load(void *data, images[i].height * sizeof(uint32_t)); /* Default. Stretch to whole screen. */ - gx_overlay_tex_geom(gx, i, 0, 0, 1, 1); + gx_overlay_tex_geom(gx, i, 0, 0, 1, 1); gx_overlay_vertex_geom(gx, i, 0, 0, 1, 1); gx->overlay[i].alpha_mod = 1.0f; } @@ -1647,7 +1647,7 @@ static bool gx_set_shader(void *data, (void)type; (void)path; - return false; + return false; } video_driver_t video_gx = { diff --git a/gfx/drivers/gx_gfx_vi_encoder.c b/gfx/drivers/gx_gfx_vi_encoder.c index 104650f040..5b7a4ca905 100644 --- a/gfx/drivers/gx_gfx_vi_encoder.c +++ b/gfx/drivers/gx_gfx_vi_encoder.c @@ -1,413 +1,413 @@ -/**************************************************************************** - * vi_encoder.c - * - * Wii Audio/Video Encoder support - * - * Copyright (C) 2009 Eke-Eke, with some code from libogc (C) Hector Martin - * - * Redistribution and use of this code or any derivative works are permitted - * provided that the following conditions are met: - * - * - Redistributions may not be sold, nor may they be used in a commercial - * product or activity. - * - * - Redistributions that are modified from the original source must include the - * complete source code, including the source code for all components used by a - * binary built from the modified sources. However, as a special exception, the - * source code distributed need not include anything that is normally distributed - * (in either source or binary form) with the major components (compiler, kernel, - * and so on) of the operating system on which the executable runs, unless that - * component itself accompanies the executable. - * - * - Redistributions must reproduce the above copyright notice, this list of - * conditions and the following disclaimer in the documentation and/or other - * materials provided with the distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" - * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE - * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE - * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE - * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR - * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF - * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS - * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN - * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) - * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE - * POSSIBILITY OF SUCH DAMAGE. - * - ****************************************************************************************/ - -#include -#include -#include -#include -#include - -#include - -#include "../../defines/gx_defines.h" - -void udelay(int us); - -static u32 i2cIdentFirst = 0; -static u32 i2cIdentFlag = 1; -static vu32* const _i2cReg = (u32*)0xCD800000; - -static INLINE void __viOpenI2C(u32 channel) -{ - u32 val = ((_i2cReg[49]&~0x8000)|0x4000) | _SHIFTL(channel,15,1); - _i2cReg[49] = val; -} - -static INLINE void __viSetSCL(u32 channel) -{ - u32 val = (_i2cReg[48]&~0x4000) | _SHIFTL(channel,14,1); - _i2cReg[48] = val; -} - -static INLINE void __viSetSDA(u32 channel) -{ - u32 val = (_i2cReg[48]&~0x8000) | _SHIFTL(channel,15,1); - _i2cReg[48] = val; -} - -#define __viGetSDA() (_SHIFTR(_i2cReg[50],15,1)) - -static u32 __sendSlaveAddress(u8 addr) -{ - u32 i; - - __viSetSDA(i2cIdentFlag^1); - udelay(2); - - __viSetSCL(0); - for(i=0;i<8;i++) - { - if (addr&0x80) - __viSetSDA(i2cIdentFlag); - else - __viSetSDA(i2cIdentFlag^1); - udelay(2); - - __viSetSCL(1); - udelay(2); - - __viSetSCL(0); - addr <<= 1; - } - - __viOpenI2C(0); - udelay(2); - - __viSetSCL(1); - udelay(2); - - if ((i2cIdentFlag == 1) && __viGetSDA()!=0) - return 0; - - __viSetSDA(i2cIdentFlag^1); - __viOpenI2C(1); - __viSetSCL(0); - - return 1; -} - -static u32 __VISendI2CData(u8 addr,void *val,u32 len) -{ - u8 c; - s32 i,j; - u32 level,ret; - - if(i2cIdentFirst==0) - { - __viOpenI2C(0); - udelay(4); - - i2cIdentFlag = 0; - if(__viGetSDA()!=0) - i2cIdentFlag = 1; - i2cIdentFirst = 1; - } - - _CPU_ISR_Disable(level); - - __viOpenI2C(1); - __viSetSCL(1); - - __viSetSDA(i2cIdentFlag); - udelay(4); - - ret = __sendSlaveAddress(addr); - - if(ret == 0) - { - _CPU_ISR_Restore(level); - return 0; - } - - __viOpenI2C(1); - for(i=0;i +#include +#include +#include +#include + +#include + +#include "../../defines/gx_defines.h" + +void udelay(int us); + +static u32 i2cIdentFirst = 0; +static u32 i2cIdentFlag = 1; +static vu32* const _i2cReg = (u32*)0xCD800000; + +static INLINE void __viOpenI2C(u32 channel) +{ + u32 val = ((_i2cReg[49]&~0x8000)|0x4000) | _SHIFTL(channel,15,1); + _i2cReg[49] = val; +} + +static INLINE void __viSetSCL(u32 channel) +{ + u32 val = (_i2cReg[48]&~0x4000) | _SHIFTL(channel,14,1); + _i2cReg[48] = val; +} + +static INLINE void __viSetSDA(u32 channel) +{ + u32 val = (_i2cReg[48]&~0x8000) | _SHIFTL(channel,15,1); + _i2cReg[48] = val; +} + +#define __viGetSDA() (_SHIFTR(_i2cReg[50],15,1)) + +static u32 __sendSlaveAddress(u8 addr) +{ + u32 i; + + __viSetSDA(i2cIdentFlag^1); + udelay(2); + + __viSetSCL(0); + for(i=0;i<8;i++) + { + if (addr&0x80) + __viSetSDA(i2cIdentFlag); + else + __viSetSDA(i2cIdentFlag^1); + udelay(2); + + __viSetSCL(1); + udelay(2); + + __viSetSCL(0); + addr <<= 1; + } + + __viOpenI2C(0); + udelay(2); + + __viSetSCL(1); + udelay(2); + + if ((i2cIdentFlag == 1) && __viGetSDA()!=0) + return 0; + + __viSetSDA(i2cIdentFlag^1); + __viOpenI2C(1); + __viSetSCL(0); + + return 1; +} + +static u32 __VISendI2CData(u8 addr,void *val,u32 len) +{ + u8 c; + s32 i,j; + u32 level,ret; + + if(i2cIdentFirst==0) + { + __viOpenI2C(0); + udelay(4); + + i2cIdentFlag = 0; + if(__viGetSDA()!=0) + i2cIdentFlag = 1; + i2cIdentFirst = 1; + } + + _CPU_ISR_Disable(level); + + __viOpenI2C(1); + __viSetSCL(1); + + __viSetSDA(i2cIdentFlag); + udelay(4); + + ret = __sendSlaveAddress(addr); + + if(ret == 0) + { + _CPU_ISR_Restore(level); + return 0; + } + + __viOpenI2C(1); + for(i=0;ifbname, &status); @@ -873,7 +873,7 @@ static void omap_render_msg(omap_video_t *vid, const char *msg) int base_x, base_y; int glyph_width, glyph_height; const uint8_t *src = NULL; - const struct font_glyph *glyph = + const struct font_glyph *glyph = vid->font_driver->get_glyph(vid->font, (uint8_t)*msg); if (!glyph) @@ -888,7 +888,7 @@ static void omap_render_msg(omap_video_t *vid, const char *msg) glyph_width = glyph->width; glyph_height = glyph->height; - src = atlas->buffer + glyph->atlas_offset_x + + src = atlas->buffer + glyph->atlas_offset_x + glyph->atlas_offset_y * atlas->width; if (base_x < 0) @@ -1085,7 +1085,7 @@ static bool omap_gfx_set_shader(void *data, (void)type; (void)path; - return false; + return false; } static void omap_gfx_set_rotation(void *data, unsigned rotation) diff --git a/gfx/drivers/psp1_gfx.c b/gfx/drivers/psp1_gfx.c index 128fab83b5..8133a8dcf5 100644 --- a/gfx/drivers/psp1_gfx.c +++ b/gfx/drivers/psp1_gfx.c @@ -122,7 +122,7 @@ typedef struct psp1_video #define PSP_FRAME_SLICE_COUNT (PSP_FRAME_ROWS_COUNT * PSP_FRAME_COLUMNS_COUNT) #define PSP_FRAME_VERTEX_COUNT (PSP_FRAME_SLICE_COUNT * 2) -static INLINE void psp_set_screen_coords (psp1_sprite_t* framecoords, +static INLINE void psp_set_screen_coords (psp1_sprite_t* framecoords, int x, int y, int width, int height, unsigned rotation) { int i; @@ -261,7 +261,7 @@ static void psp_on_vblank(u32 sub, psp1_video_t *psp) static void *psp_init(const video_info_t *video, const input_driver_t **input, void **input_data) { - /* TODO : add ASSERT() checks or use main RAM if + /* TODO : add ASSERT() checks or use main RAM if * VRAM is too low for desired video->input_scale. */ int pixel_format, lut_pixel_format, lut_block_count; @@ -284,11 +284,11 @@ static void *psp_init(const video_info_t *video, psp->vp.full_width = SCEGU_SCR_WIDTH; psp->vp.full_height = SCEGU_SCR_HEIGHT; - /* Make sure anything using uncached pointers reserves + /* Make sure anything using uncached pointers reserves * whole cachelines (memory address and size need to be a multiple of 64) * so it isn't overwritten by an unlucky cache writeback. * - * This includes display lists since the Gu library uses + * This includes display lists since the Gu library uses * uncached pointers to write to them. */ /* Allocate more space if bigger display lists are needed. */ @@ -367,8 +367,8 @@ static void *psp_init(const video_info_t *video, psp->draw_buffer = SCEGU_VRAM_BP_0; psp->bpp_log2 = 1; - pixel_format = - (video_driver_get_pixel_format() == RETRO_PIXEL_FORMAT_0RGB1555) + pixel_format = + (video_driver_get_pixel_format() == RETRO_PIXEL_FORMAT_0RGB1555) ? GU_PSM_5551 : GU_PSM_5650 ; lut_pixel_format = GU_PSM_T16; @@ -410,7 +410,7 @@ static void *psp_init(const video_info_t *video, sceGuFinish(); sceGuSync(0, 0); - + /* TODO : check if necessary */ sceDisplayWaitVblankStart(); sceGuDisplay(GU_TRUE); @@ -428,10 +428,10 @@ static void *psp_init(const video_info_t *video, /* green only */ sceGuBlendFunc(GU_ADD, GU_FIX, GU_FIX, 0x0000FF00, 0xFFFFFFFF); - sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF | GU_VERTEX_32BITF | + sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF | GU_VERTEX_32BITF | GU_TRANSFORM_2D, PSP_FRAME_VERTEX_COUNT, NULL, (void*)(psp->frame_coords)); - + /* restore */ sceGuBlendFunc(GU_ADD, GU_FIX, GU_FIX, 0xFFFFFFFF, 0xFFFFFFFF); @@ -446,7 +446,7 @@ static void *psp_init(const video_info_t *video, sceGuClutMode(pixel_format, 0, color_mask, 0); sceGuClutLoad(lut_block_count, LUT_b); - sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF | GU_VERTEX_32BITF | + sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF | GU_VERTEX_32BITF | GU_TRANSFORM_2D, PSP_FRAME_VERTEX_COUNT, NULL, (void*)(psp->frame_coords)); @@ -544,10 +544,10 @@ static bool psp_frame(void *data, const void *frame, sceGuTexFilter(psp->tex_filter, psp->tex_filter); sceGuClear(GU_COLOR_BUFFER_BIT); - /* frame in VRAM ? texture/palette was + /* frame in VRAM ? texture/palette was * set in core so draw directly */ - if (psp->hw_render) - sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF | GU_VERTEX_32BITF | + if (psp->hw_render) + sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF | GU_VERTEX_32BITF | GU_TRANSFORM_2D, PSP_FRAME_VERTEX_COUNT, NULL, (void*)(psp->frame_coords)); else @@ -672,7 +672,7 @@ static void psp_set_texture_frame(void *data, const void *frame, bool rgb32, #endif sceGuBlendFunc(GU_ADD, GU_FIX, GU_FIX, 0xF0F0F0F0, 0x0F0F0F0F); ; - sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF | GU_VERTEX_32BITF | + sceGuDrawArray(GU_SPRITES, GU_TEXTURE_32BITF | GU_VERTEX_32BITF | GU_TRANSFORM_2D, PSP_FRAME_VERTEX_COUNT, NULL, psp->menu.frame_coords); sceGuFinish(); @@ -725,7 +725,7 @@ static void psp_update_viewport(psp1_video_t* psp, if ((fabsf(device_aspect - desired_aspect) < 0.0001f) || (fabsf((16.0/9.0) - desired_aspect) < 0.02f)) { - /* If the aspect ratios of screen and desired aspect + /* If the aspect ratios of screen and desired aspect * ratio are sufficiently equal (floating point stuff), * assume they are actually equal. */ @@ -825,7 +825,7 @@ static void psp_apply_state_changes(void *data) static void psp_viewport_info(void *data, struct video_viewport *vp) { psp1_video_t *psp = (psp1_video_t*)data; - + if (psp) *vp = psp->vp; } @@ -951,7 +951,7 @@ static bool psp_set_shader(void *data, (void)type; (void)path; - return false; + return false; } video_driver_t video_psp1 = { diff --git a/gfx/drivers/psp1_gfx.h b/gfx/drivers/psp1_gfx.h index 4d2021379c..5798f56149 100644 --- a/gfx/drivers/psp1_gfx.h +++ b/gfx/drivers/psp1_gfx.h @@ -32,7 +32,7 @@ typedef struct int ge_callback_id; GuSwapBuffersCallback swapBuffersCallback; - int swapBuffersBehaviour; + int swapBuffersBehaviour; } GuSettings; typedef struct diff --git a/gfx/drivers/sdl2_gfx.c b/gfx/drivers/sdl2_gfx.c index 8431ebb531..a77061f6e5 100644 --- a/gfx/drivers/sdl2_gfx.c +++ b/gfx/drivers/sdl2_gfx.c @@ -178,7 +178,7 @@ static void sdl2_render_msg(sdl2_video_t *vid, const char *msg) { SDL_Rect src_rect, dst_rect; int off_x, off_y, tex_x, tex_y; - const struct font_glyph *gly = + const struct font_glyph *gly = vid->font_driver->get_glyph(vid->font_data, (uint8_t)*msg); if (!gly) @@ -292,7 +292,7 @@ static void sdl_refresh_viewport(sdl2_video_t *vid) vid->video.force_aspect); else if (settings->uints.video_aspect_ratio_idx == ASPECT_RATIO_CUSTOM) { - const struct video_viewport *custom = + const struct video_viewport *custom = (const struct video_viewport*)video_viewport_get_custom(); vid->vp.x = custom->x; @@ -694,7 +694,7 @@ static void sdl2_poke_texture_enable(void *data, bool enable, bool full_screen) vid->menu.active = enable; } -static void sdl2_poke_set_osd_msg(void *data, +static void sdl2_poke_set_osd_msg(void *data, video_frame_info_t *video_info, const char *msg, const void *params, void *font) @@ -760,7 +760,7 @@ static bool sdl2_gfx_set_shader(void *data, (void)type; (void)path; - return false; + return false; } video_driver_t video_sdl2 = { diff --git a/gfx/drivers/sdl_gfx.c b/gfx/drivers/sdl_gfx.c index 7f2060296c..0e2d2d473a 100644 --- a/gfx/drivers/sdl_gfx.c +++ b/gfx/drivers/sdl_gfx.c @@ -152,7 +152,7 @@ static void sdl_render_msg(sdl_video_t *vid, SDL_Surface *buffer, base_x = msg_base_x + glyph->draw_offset_x; base_y = msg_base_y + glyph->draw_offset_y; - src = atlas->buffer + glyph->atlas_offset_x + src = atlas->buffer + glyph->atlas_offset_x + glyph->atlas_offset_y * atlas->width; if (base_x < 0) @@ -470,7 +470,7 @@ static void sdl_apply_state_changes(void *data) static void sdl_set_texture_frame(void *data, const void *frame, bool rgb32, unsigned width, unsigned height, float alpha) { - enum scaler_pix_fmt format = rgb32 + enum scaler_pix_fmt format = rgb32 ? SCALER_FMT_ARGB8888 : SCALER_FMT_RGBA4444; sdl_video_t *vid = (sdl_video_t*)data; @@ -560,7 +560,7 @@ static bool sdl_gfx_set_shader(void *data, (void)type; (void)path; - return false; + return false; } static void sdl_gfx_set_rotation(void *data, unsigned rotation) diff --git a/gfx/drivers/sunxi_gfx.c b/gfx/drivers/sunxi_gfx.c index 90a9eadbc5..2c4eecbe5f 100644 --- a/gfx/drivers/sunxi_gfx.c +++ b/gfx/drivers/sunxi_gfx.c @@ -492,7 +492,7 @@ void pixman_composite_src_8888_8888_asm_neon(int width, uint16_t *src, int src_stride_pixels); -/* Pointer to the blitting function. Will be asigned +/* Pointer to the blitting function. Will be asigned * when we find out what bpp the core uses. */ void (*pixman_blit) (int width, int height, @@ -503,7 +503,7 @@ void (*pixman_blit) (int width, struct sunxi_page { - uint32_t *address; + uint32_t *address; unsigned int offset; }; @@ -523,13 +523,13 @@ struct sunxi_video unsigned int src_pitch; unsigned int src_bpp; unsigned int src_bytes_per_pixel; - unsigned int src_pixels_per_line; + unsigned int src_pixels_per_line; unsigned int dst_pitch; unsigned int dst_pixels_per_line; - unsigned int bytes_per_pixel; + unsigned int bytes_per_pixel; - struct sunxi_page *pages; - struct sunxi_page *nextPage; + struct sunxi_page *pages; + struct sunxi_page *nextPage; bool pageflip_pending; /* Keep the vsync while loop going. Set to false to exit. */ @@ -541,7 +541,7 @@ struct sunxi_video /* For threading */ sthread_t *vsync_thread; - scond_t *vsync_condition; + scond_t *vsync_condition; slock_t *pending_mutex; /* menu data */ @@ -611,7 +611,7 @@ static void sunxi_vsync_thread_func(void *data) _dispvars->pageflip_pending = false; scond_signal(_dispvars->vsync_condition); slock_unlock(_dispvars->pending_mutex); - } + } } static void *sunxi_gfx_init(const video_info_t *video, @@ -642,9 +642,9 @@ static void *sunxi_gfx_init(const video_info_t *video, _dispvars->keep_vsync = true; _dispvars->menu_active = false; _dispvars->bytes_per_pixel = video->rgb32 ? 4 : 2; - /* It's very important that we set aspect here because the + /* It's very important that we set aspect here because the * call seq when a core is loaded is gfx_init()->set_aspect()->gfx_frame() - * and we don't want the main surface to be setup in set_aspect() + * and we don't want the main surface to be setup in set_aspect() * before we get to gfx_frame(). */ _dispvars->aspect_ratio = video_driver_get_aspect_ratio(); @@ -688,15 +688,15 @@ static void sunxi_gfx_free(void *data) _dispvars->keep_vsync = false; sthread_join(_dispvars->vsync_thread); } - - slock_free(_dispvars->pending_mutex); + + slock_free(_dispvars->pending_mutex); scond_free(_dispvars->vsync_condition); - free(_dispvars->pages); + free(_dispvars->pages); /* Restore text console contents and reactivate cursor blinking. */ sunxi_restore_console(_dispvars); - + sunxi_disp_close(_dispvars->sunxi_disp); free(_dispvars); } @@ -714,14 +714,14 @@ static void sunxi_update_main(const void *frame, struct sunxi_video *_dispvars) pixman_blit( _dispvars->src_width, _dispvars->src_height, - _dispvars->nextPage->address, + _dispvars->nextPage->address, _dispvars->dst_pixels_per_line, (uint16_t*)frame, _dispvars->src_pixels_per_line ); /* Issue pageflip. Will flip on next vsync. */ - sunxi_layer_set_rgb_input_buffer(_dispvars->sunxi_disp, _dispvars->sunxi_disp->bits_per_pixel, + sunxi_layer_set_rgb_input_buffer(_dispvars->sunxi_disp, _dispvars->sunxi_disp->bits_per_pixel, _dispvars->nextPage->offset, _dispvars->src_width, _dispvars->src_height, _dispvars->sunxi_disp->xres); @@ -740,16 +740,16 @@ static void sunxi_setup_scale (void *data, _dispvars->src_width = width; _dispvars->src_height = height; - /* Total pitch, including things the + /* Total pitch, including things the * cores render between "visible" scanlines. */ - _dispvars->src_pitch = pitch; + _dispvars->src_pitch = pitch; /* Pixels per line */ _dispvars->src_pixels_per_line = _dispvars->src_pitch/_dispvars->bytes_per_pixel; - /* Incremental offset that sums up on + /* Incremental offset that sums up on * each previous page offset. - * Total offset of each page has to + * Total offset of each page has to * be adjusted when internal resolution changes. */ for (i = 0; i < NUMPAGES; i++) { @@ -758,7 +758,7 @@ static void sunxi_setup_scale (void *data, } visible_width = _dispvars->sunxi_disp->yres * _dispvars->aspect_ratio; - xpos = (_dispvars->sunxi_disp->xres - visible_width) / 2; + xpos = (_dispvars->sunxi_disp->xres - visible_width) / 2; /* setup layer window */ sunxi_layer_set_output_window(_dispvars->sunxi_disp, xpos, 0, visible_width, _dispvars->sunxi_disp->yres); @@ -854,7 +854,7 @@ static bool sunxi_gfx_set_shader(void *data, (void)type; (void)path; - return false; + return false; } static void sunxi_set_texture_enable(void *data, bool state, bool full_screen) @@ -863,7 +863,7 @@ static void sunxi_set_texture_enable(void *data, bool state, bool full_screen) /* If it wasn't active and starts being active... */ if (!_dispvars->menu_active && state) - { + { /* Stop the vsync thread. */ _dispvars->keep_vsync = false; sthread_join(_dispvars->vsync_thread); @@ -889,10 +889,10 @@ static void sunxi_set_texture_frame(void *data, const void *frame, bool rgb32, /* We have to go on a pixel format conversion adventure for now, until we can * convince RGUI to output in an 8888 format. */ - unsigned int src_pitch = width * 2; + unsigned int src_pitch = width * 2; unsigned int dst_pitch = _dispvars->sunxi_disp->xres * 4; unsigned int dst_width = _dispvars->sunxi_disp->xres; - uint32_t line[dst_width]; + uint32_t line[dst_width]; /* Remember, memcpy() works with 8bits pointers for increments. */ char *dst_base_addr = (char*)(_dispvars->pages[0].address); @@ -901,24 +901,24 @@ static void sunxi_set_texture_frame(void *data, const void *frame, bool rgb32, { for (j = 0; j < src_pitch / 2; j++) { - uint16_t src_pix = *((uint16_t*)frame + (src_pitch / 2 * i) + j); + uint16_t src_pix = *((uint16_t*)frame + (src_pitch / 2 * i) + j); /* The hex AND is for keeping only the part we need for each component. */ uint32_t R = (src_pix << 8) & 0x00FF0000; uint32_t G = (src_pix << 4) & 0x0000FF00; uint32_t B = (src_pix << 0) & 0x000000FF; - line[j] = (0 | R | G | B); + line[j] = (0 | R | G | B); } memcpy(dst_base_addr + (dst_pitch * i), (char*)line, dst_pitch); } /* Issue pageflip. Will flip on next vsync. */ sunxi_layer_set_rgb_input_buffer(_dispvars->sunxi_disp, - _dispvars->sunxi_disp->bits_per_pixel, + _dispvars->sunxi_disp->bits_per_pixel, _dispvars->pages[0].offset, width, height, _dispvars->sunxi_disp->xres); } } -static void sunxi_set_aspect_ratio (void *data, unsigned aspect_ratio_idx) +static void sunxi_set_aspect_ratio (void *data, unsigned aspect_ratio_idx) { struct sunxi_video *_dispvars = (struct sunxi_video*)data; float new_aspect = aspectratio_lut[aspect_ratio_idx].value; diff --git a/gfx/drivers/vga_gfx.c b/gfx/drivers/vga_gfx.c index 9bbf431186..301dec6e19 100644 --- a/gfx/drivers/vga_gfx.c +++ b/gfx/drivers/vga_gfx.c @@ -139,7 +139,7 @@ static void *vga_gfx_init(const video_info_t *video, vga_gfx_create(); if (video->font_enable) - font_driver_init_osd(NULL, false, + font_driver_init_osd(NULL, false, video->is_threaded, FONT_DRIVER_RENDER_VGA); return vga; diff --git a/gfx/drivers/vita2d_gfx.c b/gfx/drivers/vita2d_gfx.c index 8cc1ba72be..8e4c13ee35 100644 --- a/gfx/drivers/vita2d_gfx.c +++ b/gfx/drivers/vita2d_gfx.c @@ -42,7 +42,7 @@ extern void *memcpy_neon(void *dst, const void *src, size_t n); static void vita2d_gfx_set_viewport(void *data, unsigned viewport_width, unsigned viewport_height, bool force_full, bool allow_rotate); - + static void *vita2d_gfx_init(const video_info_t *video, const input_driver_t **input, void **input_data) { @@ -86,7 +86,7 @@ static void *vita2d_gfx_init(const video_info_t *video, vita->vsync = video->vsync; vita->rgb32 = video->rgb32; - vita->tex_filter = video->smooth + vita->tex_filter = video->smooth ? SCE_GXM_TEXTURE_FILTER_LINEAR : SCE_GXM_TEXTURE_FILTER_POINT; video_driver_set_size(&temp_width, &temp_height); @@ -106,7 +106,7 @@ static void *vita2d_gfx_init(const video_info_t *video, #ifdef HAVE_OVERLAY vita->overlay_enable = false; #endif - font_driver_init_osd(vita, false, + font_driver_init_osd(vita, false, video->is_threaded, FONT_DRIVER_RENDER_VITA2D); @@ -479,21 +479,21 @@ static void vita2d_gfx_set_viewport(void *data, unsigned viewport_width, if (fabsf(device_aspect - desired_aspect) < 0.0001f) { - /* If the aspect ratios of screen and desired aspect - * ratio are sufficiently equal (floating point stuff), + /* If the aspect ratios of screen and desired aspect + * ratio are sufficiently equal (floating point stuff), * assume they are actually equal. */ } else if (device_aspect > desired_aspect) { - delta = (desired_aspect / device_aspect - 1.0f) + delta = (desired_aspect / device_aspect - 1.0f) / 2.0f + 0.5f; x = (int)roundf(viewport_width * (0.5f - delta)); viewport_width = (unsigned)roundf(2.0f * viewport_width * delta); } else { - delta = (device_aspect / desired_aspect - 1.0f) + delta = (device_aspect / desired_aspect - 1.0f) / 2.0f + 0.5f; y = (int)roundf(viewport_height * (0.5f - delta)); viewport_height = (unsigned)roundf(2.0f * viewport_height * delta); @@ -569,7 +569,7 @@ static void vita_set_filtering(void *data, unsigned index, bool smooth) if (vita) { - vita->tex_filter = smooth ? + vita->tex_filter = smooth ? SCE_GXM_TEXTURE_FILTER_LINEAR : SCE_GXM_TEXTURE_FILTER_POINT; vita2d_texture_set_filters(vita->texture,vita->tex_filter, vita->tex_filter); @@ -696,13 +696,13 @@ static uintptr_t vita_load_texture(void *video_data, void *data, uint32_t *tex32 = NULL; const uint32_t *frame32 = NULL; struct texture_image *image = (struct texture_image*)data; - struct vita2d_texture *texture = vita2d_create_empty_texture_format(image->width, + struct vita2d_texture *texture = vita2d_create_empty_texture_format(image->width, image->height,SCE_GXM_TEXTURE_FORMAT_U8U8U8U8_ARGB); if (!texture) return 0; - if ((filter_type == TEXTURE_FILTER_MIPMAP_LINEAR) || + if ((filter_type == TEXTURE_FILTER_MIPMAP_LINEAR) || (filter_type == TEXTURE_FILTER_LINEAR)) vita2d_texture_set_filters(texture, SCE_GXM_TEXTURE_FILTER_LINEAR, @@ -771,7 +771,7 @@ static bool vita_get_current_sw_framebuffer(void *data, framebuffer->data = vita2d_texture_get_datap(vita->texture); framebuffer->pitch = vita2d_texture_get_stride(vita->texture); - framebuffer->format = vita->rgb32 + framebuffer->format = vita->rgb32 ? RETRO_PIXEL_FORMAT_XRGB8888 : RETRO_PIXEL_FORMAT_RGB565; framebuffer->memory_flags = 0; @@ -849,7 +849,7 @@ static bool vita2d_overlay_load(void *data, const void *image_data, unsigned num for (j = 0; j < o->height; j++) for (k = 0; k < o->width; k++) tex32[k + j*stride] = frame32[k + j*pitch]; - + vita2d_overlay_tex_geom(vita, i, 0, 0, 1, 1); /* Default. Stretch to whole screen. */ vita2d_overlay_vertex_geom(vita, i, 0, 0, 1, 1); vita->overlay[i].alpha_mod = 1.0f; @@ -881,7 +881,7 @@ static void vita2d_overlay_vertex_geom(void *data, unsigned image, { vita_video_t *vita = (vita_video_t*)data; struct vita_overlay_data *o = NULL; - + /* Flipped, so we preserve top-down semantics. */ /*y = 1.0f - y; h = -h;*/ @@ -891,7 +891,7 @@ static void vita2d_overlay_vertex_geom(void *data, unsigned image, if (o) { - + o->w = w*PSP_FB_WIDTH/o->width; o->h = h*PSP_FB_HEIGHT/o->height; o->x = PSP_FB_WIDTH*(1-w)/2+x; @@ -924,14 +924,14 @@ static void vita2d_render_overlay(void *data) for (i = 0; i < vita->overlays; i++) { - vita2d_draw_texture_tint_part_scale(vita->overlay[i].tex, - vita->overlay[i].x, - vita->overlay[i].y, - vita->overlay[i].tex_x, - vita->overlay[i].tex_y, - vita->overlay[i].tex_w, - vita->overlay[i].tex_h, - vita->overlay[i].w, + vita2d_draw_texture_tint_part_scale(vita->overlay[i].tex, + vita->overlay[i].x, + vita->overlay[i].y, + vita->overlay[i].tex_x, + vita->overlay[i].tex_y, + vita->overlay[i].tex_w, + vita->overlay[i].tex_h, + vita->overlay[i].w, vita->overlay[i].h, RGBA8(0xFF,0xFF,0xFF,(uint8_t)(vita->overlay[i].alpha_mod * 255.0f))); } diff --git a/gfx/drivers/vulkan.c b/gfx/drivers/vulkan.c index dafcb40fb7..f18f2ba290 100644 --- a/gfx/drivers/vulkan.c +++ b/gfx/drivers/vulkan.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2016-2017 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -78,7 +78,7 @@ static void vulkan_init_render_pass( VK_STRUCTURE_TYPE_RENDER_PASS_CREATE_INFO }; VkAttachmentDescription attachment = {0}; VkSubpassDescription subpass = {0}; - VkAttachmentReference color_ref = { 0, + VkAttachmentReference color_ref = { 0, VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL }; /* Backbuffer format. */ @@ -93,7 +93,7 @@ static void vulkan_init_render_pass( attachment.stencilLoadOp = VK_ATTACHMENT_LOAD_OP_DONT_CARE; attachment.stencilStoreOp = VK_ATTACHMENT_STORE_OP_DONT_CARE; - /* The image layout will be attachment_optimal + /* The image layout will be attachment_optimal * when we're executing the renderpass. */ attachment.initialLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; attachment.finalLayout = VK_IMAGE_LAYOUT_COLOR_ATTACHMENT_OPTIMAL; @@ -170,9 +170,9 @@ static void vulkan_init_framebuffers( static void vulkan_init_pipeline_layout( vk_t *vk) { - VkDescriptorSetLayoutCreateInfo set_layout_info = { + VkDescriptorSetLayoutCreateInfo set_layout_info = { VK_STRUCTURE_TYPE_DESCRIPTOR_SET_LAYOUT_CREATE_INFO }; - VkPipelineLayoutCreateInfo layout_info = { + VkPipelineLayoutCreateInfo layout_info = { VK_STRUCTURE_TYPE_PIPELINE_LAYOUT_CREATE_INFO }; VkDescriptorSetLayoutBinding bindings[2] = {{0}}; @@ -245,22 +245,22 @@ static void vulkan_init_pipelines( ; unsigned i; - VkPipelineInputAssemblyStateCreateInfo input_assembly = { + VkPipelineInputAssemblyStateCreateInfo input_assembly = { VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO }; - VkPipelineVertexInputStateCreateInfo vertex_input = { + VkPipelineVertexInputStateCreateInfo vertex_input = { VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO }; - VkPipelineRasterizationStateCreateInfo raster = { + VkPipelineRasterizationStateCreateInfo raster = { VK_STRUCTURE_TYPE_PIPELINE_RASTERIZATION_STATE_CREATE_INFO }; VkPipelineColorBlendAttachmentState blend_attachment = {0}; - VkPipelineColorBlendStateCreateInfo blend = { + VkPipelineColorBlendStateCreateInfo blend = { VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO }; - VkPipelineViewportStateCreateInfo viewport = { + VkPipelineViewportStateCreateInfo viewport = { VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO }; - VkPipelineDepthStencilStateCreateInfo depth_stencil = { + VkPipelineDepthStencilStateCreateInfo depth_stencil = { VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO }; - VkPipelineMultisampleStateCreateInfo multisample = { + VkPipelineMultisampleStateCreateInfo multisample = { VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO }; - VkPipelineDynamicStateCreateInfo dynamic = { + VkPipelineDynamicStateCreateInfo dynamic = { VK_STRUCTURE_TYPE_PIPELINE_DYNAMIC_STATE_CREATE_INFO }; VkPipelineShaderStageCreateInfo shader_stages[2] = { @@ -268,9 +268,9 @@ static void vulkan_init_pipelines( { VK_STRUCTURE_TYPE_PIPELINE_SHADER_STAGE_CREATE_INFO }, }; - VkGraphicsPipelineCreateInfo pipe = { + VkGraphicsPipelineCreateInfo pipe = { VK_STRUCTURE_TYPE_GRAPHICS_PIPELINE_CREATE_INFO }; - VkShaderModuleCreateInfo module_info = { + VkShaderModuleCreateInfo module_info = { VK_STRUCTURE_TYPE_SHADER_MODULE_CREATE_INFO }; VkVertexInputAttributeDescription attributes[3] = {{0}}; VkVertexInputBindingDescription binding = {0}; @@ -517,13 +517,13 @@ static void vulkan_init_command_buffers(vk_t *vk) for (i = 0; i < vk->num_swapchain_images; i++) { - VkCommandPoolCreateInfo pool_info = { + VkCommandPoolCreateInfo pool_info = { VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO }; - VkCommandBufferAllocateInfo info = { + VkCommandBufferAllocateInfo info = { VK_STRUCTURE_TYPE_COMMAND_BUFFER_ALLOCATE_INFO }; pool_info.queueFamilyIndex = vk->context->graphics_queue_index; - pool_info.flags = + pool_info.flags = VK_COMMAND_POOL_CREATE_RESET_COMMAND_BUFFER_BIT; vkCreateCommandPool(vk->context->device, @@ -622,7 +622,7 @@ static void vulkan_init_descriptor_pool(vk_t *vk) for (i = 0; i < vk->num_swapchain_images; i++) { - vk->swapchain[i].descriptor_manager = + vk->swapchain[i].descriptor_manager = vulkan_create_descriptor_manager( vk->context->device, pool_sizes, 2, vk->pipelines.set_layout); @@ -761,7 +761,7 @@ static bool vulkan_init_default_filter_chain(vk_t *vk) vk->filter_chain = vulkan_filter_chain_create_default( &info, - vk->video.smooth ? + vk->video.smooth ? VULKAN_FILTER_CHAIN_LINEAR : VULKAN_FILTER_CHAIN_NEAREST); if (!vk->filter_chain) @@ -848,10 +848,10 @@ static void vulkan_init_static_resources(vk_t *vk) { unsigned i; uint32_t blank[4 * 4]; - VkCommandPoolCreateInfo pool_info = { + VkCommandPoolCreateInfo pool_info = { VK_STRUCTURE_TYPE_COMMAND_POOL_CREATE_INFO }; /* Create the pipeline cache. */ - VkPipelineCacheCreateInfo cache = { + VkPipelineCacheCreateInfo cache = { VK_STRUCTURE_TYPE_PIPELINE_CACHE_CREATE_INFO }; vkCreatePipelineCache(vk->context->device, @@ -1072,8 +1072,8 @@ static void vulkan_init_hw_render(vk_t *vk) static void vulkan_init_readback(vk_t *vk) { /* Only bother with this if we're doing GPU recording. - * Check recording_is_enabled() and not - * driver.recording_data, because recording is + * Check recording_is_enabled() and not + * driver.recording_data, because recording is * not initialized yet. */ settings_t *settings = config_get_ptr(); @@ -1171,7 +1171,7 @@ static void *vulkan_init(const video_info_t *video, vk->fullscreen = video->fullscreen; vk->tex_w = RARCH_SCALE_BASE * video->input_scale; vk->tex_h = RARCH_SCALE_BASE * video->input_scale; - vk->tex_fmt = video->rgb32 + vk->tex_fmt = video->rgb32 ? VK_FORMAT_B8G8R8A8_UNORM : VK_FORMAT_R5G6B5_UNORM_PACK16; vk->keep_aspect = video->force_aspect; RARCH_LOG("[Vulkan]: Using %s format.\n", video->rgb32 ? "BGRA8888" : "RGB565"); @@ -1195,7 +1195,7 @@ static void *vulkan_init(const video_info_t *video, video_context_driver_input_driver(&inp); if (video->font_enable) - font_driver_init_osd(vk, false, + font_driver_init_osd(vk, false, video->is_threaded, FONT_DRIVER_RENDER_VULKAN_API); @@ -1422,21 +1422,21 @@ static void vulkan_set_viewport(void *data, unsigned viewport_width, if (fabsf(device_aspect - desired_aspect) < 0.0001f) { - /* If the aspect ratios of screen and desired aspect - * ratio are sufficiently equal (floating point stuff), + /* If the aspect ratios of screen and desired aspect + * ratio are sufficiently equal (floating point stuff), * assume they are actually equal. */ } else if (device_aspect > desired_aspect) { - delta = (desired_aspect / device_aspect - 1.0f) + delta = (desired_aspect / device_aspect - 1.0f) / 2.0f + 0.5f; x = (int)roundf(viewport_width * (0.5f - delta)); viewport_width = (unsigned)roundf(2.0f * viewport_width * delta); } else { - delta = (device_aspect / desired_aspect - 1.0f) + delta = (device_aspect / desired_aspect - 1.0f) / 2.0f + 0.5f; y = (int)roundf(viewport_height * (0.5f - delta)); viewport_height = (unsigned)roundf(2.0f * viewport_height * delta); @@ -1604,13 +1604,13 @@ static bool vulkan_frame(void *data, const void *frame, unsigned height = video_info->height; VkClearValue clear_color; - VkCommandBufferBeginInfo begin_info = { + VkCommandBufferBeginInfo begin_info = { VK_STRUCTURE_TYPE_COMMAND_BUFFER_BEGIN_INFO }; - VkRenderPassBeginInfo rp_info = { + VkRenderPassBeginInfo rp_info = { VK_STRUCTURE_TYPE_RENDER_PASS_BEGIN_INFO }; - VkSubmitInfo submit_info = { + VkSubmitInfo submit_info = { VK_STRUCTURE_TYPE_SUBMIT_INFO }; - unsigned frame_index = + unsigned frame_index = vk->context->current_swapchain_index; /* Bookkeeping on start of frame. */ @@ -1658,12 +1658,12 @@ static bool vulkan_frame(void *data, const void *frame, const uint8_t *src = (const uint8_t*)frame; unsigned bpp = vk->video.rgb32 ? 4 : 2; - if ( chain->texture.width != frame_width + if ( chain->texture.width != frame_width || chain->texture.height != frame_height) { chain->texture = vulkan_create_texture(vk, &chain->texture, frame_width, frame_height, chain->texture.format, NULL, NULL, - chain->texture_optimal.memory + chain->texture_optimal.memory ? VULKAN_TEXTURE_STAGING : VULKAN_TEXTURE_STREAMED); vulkan_map_persistent_texture( @@ -1685,7 +1685,7 @@ static bool vulkan_frame(void *data, const void *frame, if (chain->texture.stride == pitch && pitch == frame_width * bpp) memcpy(dst, src, frame_width * frame_height * bpp); else - for (y = 0; y < frame_height; y++, + for (y = 0; y < frame_height; y++, dst += chain->texture.stride, src += pitch) memcpy(dst, src, frame_width * bpp); } @@ -1849,8 +1849,8 @@ static bool vulkan_frame(void *data, const void *frame, if (chain->backbuffer.image != VK_NULL_HANDLE && (vk->readback.pending || vk->readback.streamed)) { - /* We cannot safely read back from an image which - * has already been presented as we need to + /* We cannot safely read back from an image which + * has already been presented as we need to * maintain the PRESENT_SRC_KHR layout. * * If we're reading back, perform the readback before presenting. @@ -2068,7 +2068,7 @@ static bool vulkan_get_current_sw_framebuffer(void *data, { struct vk_per_frame *chain = NULL; vk_t *vk = (vk_t*)data; - vk->chain = + vk->chain = &vk->swapchain[vk->context->current_swapchain_index]; chain = vk->chain; @@ -2095,7 +2095,7 @@ static bool vulkan_get_current_sw_framebuffer(void *data, framebuffer->data = chain->texture.mapped; framebuffer->pitch = chain->texture.stride; - framebuffer->format = vk->video.rgb32 + framebuffer->format = vk->video.rgb32 ? RETRO_PIXEL_FORMAT_XRGB8888 : RETRO_PIXEL_FORMAT_RGB565; framebuffer->memory_flags = 0; @@ -2369,7 +2369,7 @@ static bool vulkan_read_viewport(void *data, uint8_t *buffer, bool is_idle) { unsigned x, y; const uint8_t *src = (const uint8_t*)staging->mapped; - buffer += 3 * (vk->vp.height - 1) + buffer += 3 * (vk->vp.height - 1) * vk->vp.width; for (y = 0; y < vk->vp.height; y++, @@ -2532,7 +2532,7 @@ static bool vulkan_overlay_load(void *data, const void *image_data, unsigned num_images) { unsigned i, j; - const struct texture_image *images = + const struct texture_image *images = (const struct texture_image*)image_data; vk_t *vk = (vk_t*)data; static const struct vk_color white = { diff --git a/gfx/drivers/xenon360_gfx.c b/gfx/drivers/xenon360_gfx.c index 3832e7c538..9101d047cc 100644 --- a/gfx/drivers/xenon360_gfx.c +++ b/gfx/drivers/xenon360_gfx.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -284,7 +284,7 @@ static bool xenon360_gfx_set_shader(void *data, (void)type; (void)path; - return false; + return false; } static void xenon360_gfx_viewport_info(void *data, struct video_viewport *vp) diff --git a/gfx/drivers/xshm_gfx.c b/gfx/drivers/xshm_gfx.c index 75882f5f21..900a8a61a4 100644 --- a/gfx/drivers/xshm_gfx.c +++ b/gfx/drivers/xshm_gfx.c @@ -40,10 +40,10 @@ typedef struct xshm { Display* display; Window wndw; - + int width; int height; - + XShmSegmentInfo shmInfo; XImage* image; GC gc; @@ -54,11 +54,11 @@ static void *xshm_gfx_init(const video_info_t *video, { xshm_t* xshm = (xshm_t*)malloc(sizeof(xshm_t)); Window parent; - + XInitThreads(); - + xshm->display = XOpenDisplay(NULL); - + #ifdef RARCH_INTERNAL parent = DefaultRootWindow(xshm->display); #else @@ -71,26 +71,26 @@ static void *xshm_gfx_init(const video_info_t *video, 0, 24, CopyFromParent, NULL, CWBorderPixel, &attributes); XSetWindowBackground(xshm->display, xshm->wndw, 0); XMapWindow(xshm->display, xshm->wndw); - + xshm->shmInfo.shmid = shmget(IPC_PRIVATE, sizeof(uint32_t) * video->width * video->height, IPC_CREAT|0600); if (xshm->shmInfo.shmid<0) abort();//seems like an out of memory situation... let's just blow up - + xshm->shmInfo.shmaddr = (char*)shmat(xshm->shmInfo.shmid, 0, 0); xshm->shmInfo.readOnly = False; XShmAttach(xshm->display, &xshm->shmInfo); XSync(xshm->display, False);//no idea why this is required, but I get weird errors without it xshm->image = XShmCreateImage(xshm->display, NULL, 24, ZPixmap, xshm->shmInfo.shmaddr, &xshm->shmInfo, video->width, video->height); - + xshm->gc = XCreateGC(xshm->display, xshm->wndw, 0, NULL); - + xshm->width = video->width; xshm->height = video->height; - + if (input) *input = NULL; if (input_data) *input_data = NULL; - + return xshm; } @@ -100,7 +100,7 @@ static bool xshm_gfx_frame(void *data, const void *frame, unsigned width, { xshm_t* xshm = (xshm_t*)data; int y; - + for (y=0;yshmInfo.shmaddr + sizeof(uint32_t)*xshm->width*y, @@ -110,17 +110,17 @@ static bool xshm_gfx_frame(void *data, const void *frame, unsigned width, #ifdef HAVE_MENU menu_driver_frame(video_info); #endif - + XShmPutImage(xshm->display, xshm->wndw, xshm->gc, xshm->image, 0, 0, 0, 0, xshm->width, xshm->height, False); XFlush(xshm->display); - + return true; } static void xshm_gfx_set_nonblock_state(void *data, bool toggle) { - + } static bool xshm_gfx_alive(void *data) @@ -140,17 +140,17 @@ static bool xshm_gfx_suppress_screensaver(void *data, bool enable) static void xshm_gfx_free(void *data) { - + } static void xshm_gfx_set_rotation(void *data, unsigned rotation) { - + } static void xshm_gfx_viewport_info(void *data, struct video_viewport *vp) { - + } static bool xshm_gfx_read_viewport(void *data, uint8_t *buffer, bool is_idle) @@ -160,29 +160,29 @@ static bool xshm_gfx_read_viewport(void *data, uint8_t *buffer, bool is_idle) static void xshm_poke_set_filtering(void *data, unsigned index, bool smooth) { - + } static void xshm_poke_set_aspect_ratio(void *data, unsigned aspect_ratio_idx) { - + } static void xshm_poke_apply_state_changes(void *data) { - + } #ifdef HAVE_MENU static void xshm_poke_set_texture_frame(void *data, const void *frame, bool rgb32, unsigned width, unsigned height, float alpha) { - + } static void xshm_poke_texture_enable(void *data, bool enable, bool full_screen) { - + } static void xshm_poke_set_osd_msg(void *data, @@ -190,17 +190,17 @@ static void xshm_poke_set_osd_msg(void *data, const char *msg, const struct font_params *params, void *font) { - + } static void xshm_show_mouse(void *data, bool state) { - + } static void xshm_grab_mouse_toggle(void *data) { - + } #endif @@ -247,7 +247,7 @@ static bool xshm_gfx_set_shader(void *data, (void)type; (void)path; - return false; + return false; } video_driver_t video_xshm = { diff --git a/gfx/drivers/xvideo.c b/gfx/drivers/xvideo.c index dc3738c551..8df8f528bb 100644 --- a/gfx/drivers/xvideo.c +++ b/gfx/drivers/xvideo.c @@ -98,11 +98,11 @@ static void xv_set_nonblock_state(void *data, bool state) static INLINE void xv_calculate_yuv(uint8_t *y, uint8_t *u, uint8_t *v, unsigned r, unsigned g, unsigned b) { - int y_ = (int)(+((double)r * 0.257) + ((double)g * 0.504) + int y_ = (int)(+((double)r * 0.257) + ((double)g * 0.504) + ((double)b * 0.098) + 16.0); - int u_ = (int)(-((double)r * 0.148) - ((double)g * 0.291) + int u_ = (int)(-((double)r * 0.148) - ((double)g * 0.291) + ((double)b * 0.439) + 128.0); - int v_ = (int)(+((double)r * 0.439) - ((double)g * 0.368) + int v_ = (int)(+((double)r * 0.439) - ((double)g * 0.368) - ((double)b * 0.071) + 128.0); *y = y_ < 0 ? 0 : (y_ > 255 ? 255 : y_); @@ -139,8 +139,8 @@ static void xv_init_font(xv_t *xv, const char *font_path, unsigned font_size) if (!settings->bools.video_font_enable) return; - if (font_renderer_create_default((const void**)&xv->font_driver, - &xv->font, *settings->paths.path_font + if (font_renderer_create_default((const void**)&xv->font_driver, + &xv->font, *settings->paths.path_font ? settings->paths.path_font : NULL, settings->floats.video_font_size)) { @@ -234,7 +234,7 @@ static void render32_yuy2(xv_t *xv, const void *input_, uint8_t y0, u, v; unsigned img_width; uint32_t p = *input++; - p = ((p >> 8) & 0xf800) | ((p >> 5) & 0x07e0) + p = ((p >> 8) & 0xf800) | ((p >> 5) & 0x07e0) | ((p >> 3) & 0x1f); /* ARGB -> RGB16 */ y0 = xv->ytable[p]; @@ -268,7 +268,7 @@ static void render32_uyvy(xv_t *xv, const void *input_, uint8_t y0, u, v; unsigned img_width; uint32_t p = *input++; - p = ((p >> 8) & 0xf800) + p = ((p >> 8) & 0xf800) | ((p >> 5) & 0x07e0) | ((p >> 3) & 0x1f); /* ARGB -> RGB16 */ y0 = xv->ytable[p]; @@ -335,8 +335,8 @@ static bool xv_adaptor_set_format(xv_t *xv, Display *dpy, { for (j = 0; j < ARRAY_SIZE(formats); j++) { - if (format[i].type == XvYUV - && format[i].bits_per_pixel == 16 + if (format[i].type == XvYUV + && format[i].bits_per_pixel == 16 && format[i].format == XvPacked) { if (format[i].component_order[0] == formats[j].components[0] && @@ -345,7 +345,7 @@ static bool xv_adaptor_set_format(xv_t *xv, Display *dpy, format[i].component_order[3] == formats[j].components[3]) { xv->fourcc = format[i].id; - xv->render_func = video->rgb32 + xv->render_func = video->rgb32 ? formats[j].render_32 : formats[j].render_16; xv->luma_index[0] = formats[j].luma_index[0]; @@ -387,7 +387,7 @@ static void xv_calc_out_rect(bool keep_aspect, float desired_aspect = video_driver_get_aspect_ratio(); float device_aspect = (float)vp_width / vp_height; - /* If the aspect ratios of screen and desired aspect ratio + /* If the aspect ratios of screen and desired aspect ratio * are sufficiently equal (floating point stuff), * assume they are actually equal. */ @@ -453,7 +453,7 @@ static void *xv_init(const video_info_t *video, RARCH_ERR("[XVideo]: Check DISPLAY variable and if X is running.\n"); goto error; } - + av_info = video_viewport_get_system_av_info(); if (av_info) @@ -492,7 +492,7 @@ static void *xv_init(const video_info_t *video, for (i = 0; i < adaptor_count; i++) { - /* Find adaptor that supports both input (memory->drawable) + /* Find adaptor that supports both input (memory->drawable) * and image (drawable->screen) masks. */ if (adaptor_info[i].num_formats < 1) @@ -524,7 +524,7 @@ static void *xv_init(const video_info_t *video, visualtemplate.screen = DefaultScreen(g_x11_dpy); visualtemplate.depth = xv->depth; visualtemplate.visual = 0; - visualinfo = XGetVisualInfo(g_x11_dpy, VisualIDMask | + visualinfo = XGetVisualInfo(g_x11_dpy, VisualIDMask | VisualScreenMask | VisualDepthMask, &visualtemplate, &visualmatches); if (!visualinfo) @@ -541,7 +541,7 @@ static void *xv_init(const video_info_t *video, attributes.colormap = g_x11_cmap; attributes.border_pixel = 0; - attributes.event_mask = StructureNotifyMask | KeyPressMask | + attributes.event_mask = StructureNotifyMask | KeyPressMask | KeyReleaseMask | ButtonReleaseMask | ButtonPressMask | DestroyNotify | ClientMessage; if (video->fullscreen) @@ -677,7 +677,7 @@ static bool xv_check_resize(xv_t *xv, unsigned width, unsigned height) xv->width = xv->image->width; xv->height = xv->image->height; - xv->shminfo.shmid = + xv->shminfo.shmid = shmget(IPC_PRIVATE, xv->image->data_size, IPC_CREAT | 0777); if (xv->shminfo.shmid < 0) @@ -686,7 +686,7 @@ static bool xv_check_resize(xv_t *xv, unsigned width, unsigned height) return false; } - xv->shminfo.shmaddr = xv->image->data = + xv->shminfo.shmaddr = xv->image->data = (char*)shmat(xv->shminfo.shmid, NULL, 0); xv->shminfo.readOnly = false; @@ -733,21 +733,21 @@ static void xv_render_msg(xv_t *xv, const char *msg, int base_x, base_y, glyph_width, glyph_height, max_width, max_height; const uint8_t *src = NULL; uint8_t *out = NULL; - const struct font_glyph *glyph = + const struct font_glyph *glyph = xv->font_driver->get_glyph(xv->font, (uint8_t)*msg); if (!glyph) continue; - /* Make sure we always start on the correct boundary + /* Make sure we always start on the correct boundary * so the indices are correct. */ - base_x = (msg_base_x + glyph->draw_offset_x + 1) & ~1; + base_x = (msg_base_x + glyph->draw_offset_x + 1) & ~1; base_y = msg_base_y + glyph->draw_offset_y; glyph_width = glyph->width; glyph_height = glyph->height; - src = atlas->buffer + glyph->atlas_offset_x + + src = atlas->buffer + glyph->atlas_offset_x + glyph->atlas_offset_y * atlas->width; if (base_x < 0) @@ -793,21 +793,21 @@ static void xv_render_msg(xv_t *xv, const char *msg, alpha[1] = src[x + 1]; /* Blended alpha for the sub-sampled U/V channels. */ - alpha_sub = (alpha[0] + alpha[1]) >> 1; + alpha_sub = (alpha[0] + alpha[1]) >> 1; for (i = 0; i < 2; i++) { - unsigned blended = (xv->font_y * alpha[i] + unsigned blended = (xv->font_y * alpha[i] + ((256 - alpha[i]) * out[out_x + luma_index[i]])) >> 8; out[out_x + luma_index[i]] = blended; } /* Blend chroma channels */ - blended = (xv->font_u * alpha_sub + blended = (xv->font_u * alpha_sub + ((256 - alpha_sub) * out[out_x + chroma_u_index])) >> 8; out[out_x + chroma_u_index] = blended; - blended = (xv->font_v * alpha_sub + blended = (xv->font_v * alpha_sub + ((256 - alpha_sub) * out[out_x + chroma_v_index])) >> 8; out[out_x + chroma_v_index] = blended; } @@ -938,7 +938,7 @@ static bool xv_set_shader(void *data, (void)type; (void)path; - return false; + return false; } video_driver_t video_xvideo = { diff --git a/gfx/drivers_context/android_ctx.c b/gfx/drivers_context/android_ctx.c index 341aa465c6..acd73fe27c 100644 --- a/gfx/drivers_context/android_ctx.c +++ b/gfx/drivers_context/android_ctx.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -230,7 +230,7 @@ static void android_gfx_ctx_check_window(void *data, bool *quit, break; case GFX_CTX_VULKAN_API: #ifdef HAVE_VULKAN - /* Swapchains are recreated in set_resize as a + /* Swapchains are recreated in set_resize as a * central place, so use that to trigger swapchain reinit. */ *resize = and->vk.need_new_swapchain; new_width = and->width; @@ -370,7 +370,7 @@ static bool android_gfx_ctx_bind_api(void *data, enum gfx_ctx_api api, unsigned major, unsigned minor) { unsigned version; - + switch (api) { case GFX_CTX_OPENGL_API: @@ -582,7 +582,7 @@ static uint32_t android_gfx_ctx_get_flags(void *data) { uint32_t flags = 0; BIT32_SET(flags, GFX_CTX_FLAGS_NONE); - + return flags; } diff --git a/gfx/drivers_context/cgl_ctx.c b/gfx/drivers_context/cgl_ctx.c index 4593b46d8e..53e923da92 100644 --- a/gfx/drivers_context/cgl_ctx.c +++ b/gfx/drivers_context/cgl_ctx.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -116,7 +116,7 @@ static bool gfx_ctx_cgl_set_video_mode(void *data, static void gfx_ctx_cgl_destroy(void *data) { gfx_ctx_cgl_data_t *cgl = (gfx_ctx_cgl_data_t*)data; - + if (cgl->glCtx) { CGLSetCurrentContext(NULL); @@ -230,9 +230,9 @@ static CGSSurfaceID attach_gl_context_to_window(CGLContextObj glCtx, CGSConnectionID cid = CGSMainConnectionID(); printf("cid:%d wid:%d\n", cid, wid); - + /* determine window size */ - /* FIXME/TODO - CGWindowListCopyWindowInfo was introduced on OSX 10.5, + /* FIXME/TODO - CGWindowListCopyWindowInfo was introduced on OSX 10.5, * find alternative for lower versions. */ wins = CGWindowListCopyWindowInfo(kCGWindowListOptionIncludingWindow, wid); /* expect one result only */ win = (CFDictionaryRef)CFArrayGetValueAtIndex(wins, 0); @@ -242,33 +242,33 @@ static CGSSurfaceID attach_gl_context_to_window(CGLContextObj glCtx, CFNumberGetValue((CFNumberRef)CFDictionaryGetValue(bnd, CFSTR("Height")), kCFNumberFloat64Type, &h); CFRelease(wins); - + /* create a surface. */ if(CGSAddSurface(cid, wid, &sid) != kCGErrorSuccess) { printf("ERR: no surface\n"); } printf("sid:%d\n", sid); - + /* set surface size, and order it frontmost */ if(CGSSetSurfaceBounds(cid, wid, sid, CGRectMake(0, 0, w, h)) != kCGErrorSuccess) printf("ERR: cant set bounds\n"); if(CGSOrderSurface(cid, wid, sid, 1, 0) != kCGErrorSuccess) printf("ERR: cant order front\n"); - + /* attach context to the surface */ if(CGLSetSurface(glCtx, cid, wid, sid) != kCGErrorSuccess) { printf("ERR: cant set surface\n"); } - + /* check drawable */ CGLGetParameter(glCtx, kCGLCPHasDrawable, ¶ms); if(params != 1) { printf("ERR: no drawable\n"); } - + *width = (int)w; *height = (int)h; diff --git a/gfx/drivers_context/d3d_ctx.c b/gfx/drivers_context/d3d_ctx.c index d5e3923be9..4a5e6d667d 100644 --- a/gfx/drivers_context/d3d_ctx.c +++ b/gfx/drivers_context/d3d_ctx.c @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis * Copyright (C) 2012-2014 - OV2 - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -341,7 +341,7 @@ static void gfx_ctx_d3d_swap_interval(void *data, unsigned interval) { d3d_video_t *d3d = (d3d_video_t*)data; #ifdef _XBOX - unsigned d3d_interval = interval ? + unsigned d3d_interval = interval ? D3DPRESENT_INTERVAL_ONE : D3DPRESENT_INTERVAL_IMMEDIATE; d3d_set_render_state(d3d->dev, XBOX_PRESENTATIONINTERVAL, d3d_interval); diff --git a/gfx/drivers_context/drm_ctx.c b/gfx/drivers_context/drm_ctx.c index e5eb203075..5c101eb57f 100644 --- a/gfx/drivers_context/drm_ctx.c +++ b/gfx/drivers_context/drm_ctx.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -85,7 +85,7 @@ typedef struct gfx_ctx_drm_data unsigned fb_width; unsigned fb_height; - bool core_hw_context_enable; + bool core_hw_context_enable; } gfx_ctx_drm_data_t; struct drm_fb @@ -161,7 +161,7 @@ static void drm_flip_handler(int fd, unsigned frame, (void)fd; (void)sec; (void)usec; - + #if 0 static unsigned first_page_flip; static unsigned last_page_flip; @@ -189,7 +189,7 @@ static bool gfx_ctx_drm_wait_flip(bool block) if (!waiting_for_flip) return false; - + if (block) timeout = -1; @@ -207,7 +207,7 @@ static bool gfx_ctx_drm_wait_flip(bool block) /* This buffer is not on-screen anymore. Release it to GBM. */ gbm_surface_release_buffer(g_gbm_surface, g_bo); /* This buffer is being shown now. */ - g_bo = g_next_bo; + g_bo = g_next_bo; return false; } @@ -225,7 +225,7 @@ static bool gfx_ctx_drm_queue_flip(void) if (drmModePageFlip(g_drm_fd, g_crtc_id, fb->fb_id, DRM_MODE_PAGE_FLIP_EVENT, &waiting_for_flip) == 0) return true; - + /* Failed to queue page flip. */ return false; } @@ -248,7 +248,7 @@ static void gfx_ctx_drm_swap_buffers(void *data, void *data2) break; } - /* I guess we have to wait for flip to have taken + /* I guess we have to wait for flip to have taken * place before another flip can be queued up. * * If true, we are still waiting for a flip @@ -263,7 +263,7 @@ static void gfx_ctx_drm_swap_buffers(void *data, void *data2) gbm_surface_has_free_buffers(g_gbm_surface)) return; - gfx_ctx_drm_wait_flip(true); + gfx_ctx_drm_wait_flip(true); } static void gfx_ctx_drm_get_video_size(void *data, @@ -389,7 +389,7 @@ nextgpu: drm_setup(fd); - /* First mode is assumed to be the "optimal" + /* First mode is assumed to be the "optimal" * one for get_video_size() purposes. */ drm->fb_width = g_drm_connector->modes[0].hdisplay; drm->fb_height = g_drm_connector->modes[0].vdisplay; @@ -454,7 +454,7 @@ static EGLint *gfx_ctx_drm_egl_fill_attribs( *attr++ = drm->egl.minor; /* Technically, we don't have core/compat until 3.2. - * Version 3.1 is either compat or not depending + * Version 3.1 is either compat or not depending * on GL_ARB_compatibility. */ if (version >= 3002) { @@ -476,7 +476,7 @@ static EGLint *gfx_ctx_drm_egl_fill_attribs( case GFX_CTX_OPENGL_ES_API: #ifdef HAVE_OPENGLES *attr++ = EGL_CONTEXT_CLIENT_VERSION; - *attr++ = drm->egl.major + *attr++ = drm->egl.major ? (EGLint)drm->egl.major : 2; #ifdef EGL_KHR_create_context if (drm->egl.minor > 0) @@ -581,7 +581,7 @@ static bool gfx_ctx_drm_egl_set_video_mode(gfx_ctx_drm_data_t *drm) attr = gfx_ctx_drm_egl_fill_attribs(drm, egl_attribs); egl_attribs_ptr = &egl_attribs[0]; - if (!egl_create_context(&drm->egl, (attr != egl_attribs_ptr) + if (!egl_create_context(&drm->egl, (attr != egl_attribs_ptr) ? egl_attribs_ptr : NULL)) goto error; @@ -622,14 +622,14 @@ static bool gfx_ctx_drm_set_video_mode(void *data, frontend_driver_install_signal_handler(); - /* If we use black frame insertion, - * we fake a 60 Hz monitor for 120 Hz one, + /* If we use black frame insertion, + * we fake a 60 Hz monitor for 120 Hz one, * etc, so try to match that. */ - refresh_mod = video_info->black_frame_insertion + refresh_mod = video_info->black_frame_insertion ? 0.5f : 1.0f; /* Find desired video mode, and use that. - * If not fullscreen, we get desired windowed size, + * If not fullscreen, we get desired windowed size, * which is not appropriate. */ if ((width == 0 && height == 0) || !fullscreen) g_drm_mode = &g_drm_connector->modes[0]; @@ -637,7 +637,7 @@ static bool gfx_ctx_drm_set_video_mode(void *data, { /* Try to match refresh_rate as closely as possible. * - * Lower resolutions tend to have multiple supported + * Lower resolutions tend to have multiple supported * refresh rates as well. */ float minimum_fps_diff = 0.0f; @@ -646,7 +646,7 @@ static bool gfx_ctx_drm_set_video_mode(void *data, for (i = 0; i < g_drm_connector->count_modes; i++) { float diff; - if (width != g_drm_connector->modes[i].hdisplay || + if (width != g_drm_connector->modes[i].hdisplay || height != g_drm_connector->modes[i].vdisplay) continue; diff --git a/gfx/drivers_context/gdi_ctx.c b/gfx/drivers_context/gdi_ctx.c index 9d1e5980ae..eee7296ad4 100644 --- a/gfx/drivers_context/gdi_ctx.c +++ b/gfx/drivers_context/gdi_ctx.c @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis * Copyright (C) 2016-2017 - Brad Parker - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -136,7 +136,7 @@ static void *gfx_ctx_gdi_init( if (g_inited) return NULL; - + win32_window_reset(); win32_monitor_init(); diff --git a/gfx/drivers_context/gfx_null_ctx.c b/gfx/drivers_context/gfx_null_ctx.c index e6bf37c819..1dd79a9b6f 100644 --- a/gfx/drivers_context/gfx_null_ctx.c +++ b/gfx/drivers_context/gfx_null_ctx.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -64,7 +64,7 @@ static void gfx_ctx_null_destroy(void *data) (void)data; } -static void gfx_ctx_null_input_driver(void *data, +static void gfx_ctx_null_input_driver(void *data, const char *name, const input_driver_t **input, void **input_data) { diff --git a/gfx/drivers_context/khr_display_ctx.c b/gfx/drivers_context/khr_display_ctx.c index 53e3bfb528..b0dd26cc64 100644 --- a/gfx/drivers_context/khr_display_ctx.c +++ b/gfx/drivers_context/khr_display_ctx.c @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2016-2017 - Hans-Kristian Arntzen - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -242,7 +242,7 @@ const gfx_ctx_driver_t gfx_ctx_khr_display = { "khr_display", gfx_ctx_khr_display_get_flags, gfx_ctx_khr_display_set_flags, - NULL, + NULL, gfx_ctx_khr_display_get_context_data, NULL }; diff --git a/gfx/drivers_context/mali_fbdev_ctx.c b/gfx/drivers_context/mali_fbdev_ctx.c index e9b97dbe78..aa7e7395b4 100644 --- a/gfx/drivers_context/mali_fbdev_ctx.c +++ b/gfx/drivers_context/mali_fbdev_ctx.c @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -168,7 +168,7 @@ static bool gfx_ctx_mali_fbdev_set_video_mode(void *data, close(fd); fd = -1; - + width = vinfo.xres; height = vinfo.yres; diff --git a/gfx/drivers_context/opendingux_fbdev_ctx.c b/gfx/drivers_context/opendingux_fbdev_ctx.c index b50317e200..9ad56bc662 100644 --- a/gfx/drivers_context/opendingux_fbdev_ctx.c +++ b/gfx/drivers_context/opendingux_fbdev_ctx.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2014 2015 - Jean-Andre Santoni - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -79,7 +79,7 @@ static void *gfx_ctx_opendingux_init(video_frame_info_t *video_info, void *video if (!viv) return NULL; - + #ifdef HAVE_EGL frontend_driver_install_signal_handler(); diff --git a/gfx/drivers_context/ps3_ctx.c b/gfx/drivers_context/ps3_ctx.c index 0c3775ec58..050e241db9 100644 --- a/gfx/drivers_context/ps3_ctx.c +++ b/gfx/drivers_context/ps3_ctx.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -102,7 +102,7 @@ static void gfx_ctx_ps3_get_available_resolutions(void) } global->console.screen.resolutions.count = 0; - global->console.screen.resolutions.list = + global->console.screen.resolutions.list = malloc(resolution_count * sizeof(uint32_t)); for (i = 0; i < num_videomodes; i++) @@ -119,15 +119,15 @@ static void gfx_ctx_ps3_get_available_resolutions(void) if (global->console.screen.resolutions.current.id == videomode[i]) { defaultresolution = false; - global->console.screen.resolutions.current.idx = + global->console.screen.resolutions.current.idx = global->console.screen.resolutions.count-1; } } } - /* In case we didn't specify a resolution - + /* In case we didn't specify a resolution - * make the last resolution - that was added to the list (the highest resolution) + that was added to the list (the highest resolution) the default resolution */ if (global->console.screen.resolutions.current.id > num_videomodes || defaultresolution) { @@ -195,7 +195,7 @@ static void gfx_ctx_ps3_get_video_size(void *data, #if defined(HAVE_PSGL) if (ps3) - psglGetDeviceDimensions(ps3->gl_device, width, height); + psglGetDeviceDimensions(ps3->gl_device, width, height); #endif } @@ -224,7 +224,7 @@ static void *gfx_ctx_ps3_init(video_frame_info_t *video_info, void *video_driver sys_spu_initialize(6, 1); psglInit(&options); - params.enable = + params.enable = PSGL_DEVICE_PARAMETERS_COLOR_FORMAT | PSGL_DEVICE_PARAMETERS_DEPTH_FORMAT | PSGL_DEVICE_PARAMETERS_MULTISAMPLING_MODE; @@ -265,7 +265,7 @@ static void *gfx_ctx_ps3_init(video_frame_info_t *video_info, void *video_driver psglResetCurrentContext(); #endif - global->console.screen.pal_enable = + global->console.screen.pal_enable = cellVideoOutGetResolutionAvailability( CELL_VIDEO_OUT_PRIMARY, CELL_VIDEO_OUT_RESOLUTION_576, CELL_VIDEO_OUT_ASPECT_AUTO, 0); diff --git a/gfx/drivers_context/sdl_gl_ctx.c b/gfx/drivers_context/sdl_gl_ctx.c index 6c9f70df40..4827c7da84 100644 --- a/gfx/drivers_context/sdl_gl_ctx.c +++ b/gfx/drivers_context/sdl_gl_ctx.c @@ -114,7 +114,7 @@ static void sdl_ctx_destroy(void *data) if (!sdl) return; - + sdl_ctx_destroy_resources(sdl); free(sdl); } diff --git a/gfx/drivers_context/vc_egl_ctx.c b/gfx/drivers_context/vc_egl_ctx.c index 26e1b695f4..62714cf62c 100644 --- a/gfx/drivers_context/vc_egl_ctx.c +++ b/gfx/drivers_context/vc_egl_ctx.c @@ -110,23 +110,23 @@ static void gfx_ctx_vc_get_video_size(void *data, vc_ctx_data_t *vc = (vc_ctx_data_t*)data; settings_t *settings = config_get_ptr(); - /* Use dispmanx upscaling if + /* Use dispmanx upscaling if * fullscreen_x and fullscreen_y are set. */ if (settings->uints.video_fullscreen_x != 0 && settings->uints.video_fullscreen_y != 0) { /* Keep input and output aspect ratio equal. - * There are other aspect ratio settings + * There are other aspect ratio settings * which can be used to stretch video output. */ /* Calculate source and destination aspect ratios. */ - float srcAspect = (float)settings->uints.video_fullscreen_x + float srcAspect = (float)settings->uints.video_fullscreen_x / (float)settings->uints.video_fullscreen_y; float dstAspect = (float)vc->fb_width / (float)vc->fb_height; - /* If source and destination aspect ratios + /* If source and destination aspect ratios * are not equal correct source width. */ if (srcAspect != dstAspect) *width = (unsigned)(settings->uints.video_fullscreen_y * dstAspect); @@ -198,7 +198,7 @@ static void *gfx_ctx_vc_init(video_frame_info_t *video_info, void *video_driver) /* If we set this env variable, Broadcom's EGL implementation will block * on vsync with a double buffer when we call eglSwapBuffers. Less input lag! - * Has to be done before any EGL call. + * Has to be done before any EGL call. * NOTE this is commented out because it should be the right way to do it, but * currently it doesn't work, so we are using an vsync callback based solution.*/ /* if (video_info->max_swapchain_images <= 2) @@ -216,7 +216,7 @@ static void *gfx_ctx_vc_init(video_frame_info_t *video_info, void *video_driver) goto error; } - if (!egl_create_context(&vc->egl, (vc_api == GFX_CTX_OPENGL_ES_API) + if (!egl_create_context(&vc->egl, (vc_api == GFX_CTX_OPENGL_ES_API) ? context_attributes : NULL)) { egl_report_error(); @@ -236,7 +236,7 @@ static void *gfx_ctx_vc_init(video_frame_info_t *video_info, void *video_driver) src_rect.x = 0; src_rect.y = 0; - /* Use dispmanx upscaling if fullscreen_x + /* Use dispmanx upscaling if fullscreen_x * and fullscreen_y are set. */ if (settings->uints.video_fullscreen_x != 0 && settings->uints.video_fullscreen_y != 0) @@ -281,11 +281,11 @@ static void *gfx_ctx_vc_init(video_frame_info_t *video_info, void *video_driver) settings->uints.video_fullscreen_y != 0) { /* Keep input and output aspect ratio equal. - * There are other aspect ratio settings which + * There are other aspect ratio settings which * can be used to stretch video output. */ /* Calculate source and destination aspect ratios. */ - float srcAspect = (float)settings->uints.video_fullscreen_x + float srcAspect = (float)settings->uints.video_fullscreen_x / (float)settings->uints.video_fullscreen_y; float dstAspect = (float)vc->fb_width / (float)vc->fb_height; @@ -313,7 +313,7 @@ static void *gfx_ctx_vc_init(video_frame_info_t *video_info, void *video_driver) vc->vsync_condition_mutex = slock_new(); vc->vsync_callback_set = false; if (video_info->max_swapchain_images <= 2) { - /* Start sending vsync callbacks so we can wait for vsync after eglSwapBuffers */ + /* Start sending vsync callbacks so we can wait for vsync after eglSwapBuffers */ vc_dispmanx_vsync_callback(vc->dispman_display, dispmanx_vsync_callback, (void*)vc); vc->vsync_callback_set = true; } @@ -525,7 +525,7 @@ static bool gfx_ctx_vc_image_buffer_init(void *data, peglCreateImageKHR = (PFNEGLCREATEIMAGEKHRPROC)egl_get_proc_address("eglCreateImageKHR"); peglDestroyImageKHR = (PFNEGLDESTROYIMAGEKHRPROC)egl_get_proc_address("eglDestroyImageKHR"); - if (!peglCreateImageKHR || !peglDestroyImageKHR + if (!peglCreateImageKHR || !peglDestroyImageKHR || !gfx_ctx_vc_egl_query_extension(vc, "KHR_image")) return false; @@ -644,7 +644,7 @@ static void gfx_ctx_vc_swap_buffers(void *data, void *data2) } slock_lock(vc->vsync_condition_mutex); scond_wait(vc->vsync_condition, vc->vsync_condition_mutex); - slock_unlock(vc->vsync_condition_mutex); + slock_unlock(vc->vsync_condition_mutex); } else if (vc->vsync_callback_set) { /* Stop generating vsync callbacks from now on */ diff --git a/gfx/drivers_context/vivante_fbdev_ctx.c b/gfx/drivers_context/vivante_fbdev_ctx.c index 17fdf3e19b..10ea704ee6 100644 --- a/gfx/drivers_context/vivante_fbdev_ctx.c +++ b/gfx/drivers_context/vivante_fbdev_ctx.c @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011 2017 - Daniel De Matteis * Copyright (C) 2014 2015 - Jean-Andre Santoni - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/gfx/drivers_context/wayland_ctx.c b/gfx/drivers_context/wayland_ctx.c index cde0887fb0..29f45c925b 100644 --- a/gfx/drivers_context/wayland_ctx.c +++ b/gfx/drivers_context/wayland_ctx.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -68,7 +68,7 @@ typedef struct gfx_ctx_wayland_data struct wl_seat *seat; struct wl_shm *shm; unsigned swap_interval; - bool core_hw_context_enable; + bool core_hw_context_enable; unsigned buffer_scale; @@ -293,7 +293,7 @@ static void pointer_handle_button(void *data, wl->input.mouse.middle = true; } else - { + { if (button == BTN_LEFT) wl->input.mouse.left = false; else if (button == BTN_RIGHT) @@ -645,7 +645,7 @@ static void gfx_ctx_wl_check_window(void *data, bool *quit, { case GFX_CTX_VULKAN_API: #ifdef HAVE_VULKAN - /* Swapchains are recreated in set_resize as a + /* Swapchains are recreated in set_resize as a * central place, so use that to trigger swapchain reinit. */ *resize = wl->vk.need_new_swapchain; #endif @@ -1133,7 +1133,7 @@ static bool gfx_ctx_wl_set_video_mode(void *data, #ifdef HAVE_VULKAN if (!vulkan_surface_create(&wl->vk, VULKAN_WSI_WAYLAND, - wl->input.dpy, wl->surface, + wl->input.dpy, wl->surface, wl->width, wl->height, wl->swap_interval)) goto error; #endif diff --git a/gfx/drivers_context/wgl_ctx.c b/gfx/drivers_context/wgl_ctx.c index 9b5e441503..c6179a088f 100644 --- a/gfx/drivers_context/wgl_ctx.c +++ b/gfx/drivers_context/wgl_ctx.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -159,9 +159,9 @@ static void create_gl_context(HWND hwnd, bool *quit) else { win32_hrc = wglCreateContext(win32_hdc); - + /* We'll create shared context later if not. */ - if (win32_hrc && !core_context && !debug) + if (win32_hrc && !core_context && !debug) { win32_hw_hrc = wglCreateContext(win32_hdc); if (win32_hw_hrc) @@ -203,7 +203,7 @@ static void create_gl_context(HWND hwnd, bool *quit) *aptr++ = win32_minor; /* Technically, we don't have core/compat until 3.2. - * Version 3.1 is either compat or not depending + * Version 3.1 is either compat or not depending * on GL_ARB_compatibility. */ if ((win32_major * 1000 + win32_minor) >= 3002) @@ -280,7 +280,7 @@ void create_graphics_context(HWND hwnd, bool *quit) height = rect.bottom - rect.top; if (!vulkan_surface_create(&win32_vk, VULKAN_WSI_WIN32, - &instance, &hwnd, + &instance, &hwnd, width, height, win32_interval)) *quit = true; @@ -462,7 +462,7 @@ static void *gfx_ctx_wgl_init(video_frame_info_t *video_info, void *video_driver return NULL; dll_handle = dylib_load("OpenGL32.dll"); - + win32_window_reset(); win32_monitor_init(); diff --git a/gfx/drivers_context/x_ctx.c b/gfx/drivers_context/x_ctx.c index 1faa28b95f..64673379cd 100644 --- a/gfx/drivers_context/x_ctx.c +++ b/gfx/drivers_context/x_ctx.c @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis * Copyright (C) 2016-2017 - Brad Parker - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -169,7 +169,7 @@ static int GLXExtensionSupported(Display *dpy, const char *extension) const char *client_extensions = glXGetClientString(dpy, GLX_EXTENSIONS); const char *pos = strstr(extensionsString, extension); - if ( (pos != NULL) && + if ( (pos != NULL) && (pos == extensionsString || pos[-1] == ' ') && (pos[strlen(extension)] == ' ' || pos[strlen(extension)] == '\0') ) @@ -178,7 +178,7 @@ static int GLXExtensionSupported(Display *dpy, const char *extension) pos = strstr(client_extensions, extension); if ( - (pos != NULL) && + (pos != NULL) && (pos == extensionsString || pos[-1] == ' ') && (pos[strlen(extension)] == ' ' || pos[strlen(extension)] == '\0') ) @@ -227,7 +227,7 @@ static void gfx_ctx_x_destroy_resources(gfx_ctx_x_data_t *x) x->g_hw_ctx = NULL; } } - + if (g_x11_win) { if (x->g_glx_win) @@ -290,7 +290,7 @@ static void gfx_ctx_x_destroy(void *data) gfx_ctx_x_data_t *x = (gfx_ctx_x_data_t*)data; if (!x) return; - + gfx_ctx_x_destroy_resources(x); switch (x_api) @@ -706,8 +706,8 @@ static bool gfx_ctx_x_set_video_mode(void *data, g_x11_win = XCreateWindow(g_x11_dpy, RootWindow(g_x11_dpy, vi->screen), x_off, y_off, width, height, 0, - vi->depth, InputOutput, vi->visual, - CWBorderPixel | CWColormap | CWEventMask | + vi->depth, InputOutput, vi->visual, + CWBorderPixel | CWColormap | CWEventMask | (true_full ? CWOverrideRedirect : 0), &swa); XSetWindowBackground(g_x11_dpy, g_x11_win, 0); @@ -740,13 +740,13 @@ static bool gfx_ctx_x_set_video_mode(void *data, } else if (fullscreen) { - /* We attempted true fullscreen, but failed. + /* We attempted true fullscreen, but failed. * Attempt using windowed fullscreen. */ XMapRaised(g_x11_dpy, g_x11_win); RARCH_LOG("[GLX]: Using windowed fullscreen.\n"); - /* We have to move the window to the screen we want + /* We have to move the window to the screen we want * to go fullscreen on first. * x_off and y_off usually get ignored in XCreateWindow(). */ @@ -756,7 +756,7 @@ static bool gfx_ctx_x_set_video_mode(void *data, else { XMapWindow(g_x11_dpy, g_x11_win); - /* If we want to map the window on a different screen, + /* If we want to map the window on a different screen, * we'll have to do it by force. * Otherwise, we should try to let the window manager sort it out. * x_off and y_off usually get ignored in XCreateWindow(). */ @@ -788,7 +788,7 @@ static bool gfx_ctx_x_set_video_mode(void *data, if (x->g_core_es_core) { /* Technically, we don't have core/compat until 3.2. - * Version 3.1 is either compat or not depending on + * Version 3.1 is either compat or not depending on * GL_ARB_compatibility. */ *aptr++ = GLX_CONTEXT_PROFILE_MASK_ARB; @@ -864,7 +864,7 @@ static bool gfx_ctx_x_set_video_mode(void *data, /* Use XCB surface since it's the most supported WSI. * We can obtain the XCB connection directly from X11. */ if (!vulkan_surface_create(&x->vk, VULKAN_WSI_XCB, - g_x11_dpy, &g_x11_win, + g_x11_dpy, &g_x11_win, width, height, x->g_interval)) goto error; } @@ -923,7 +923,7 @@ static bool gfx_ctx_x_set_video_mode(void *data, gfx_ctx_x_swap_interval(data, x->g_interval); - /* This can blow up on some drivers. + /* This can blow up on some drivers. * It's not fatal, so override errors for this call. */ old_handler = XSetErrorHandler(x_nul_handler); XSetInputFocus(g_x11_dpy, g_x11_win, RevertToNone, CurrentTime); diff --git a/gfx/drivers_context/xegl_ctx.c b/gfx/drivers_context/xegl_ctx.c index 351c021215..59d7d65c62 100644 --- a/gfx/drivers_context/xegl_ctx.c +++ b/gfx/drivers_context/xegl_ctx.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis -* +* * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -87,7 +87,7 @@ static void gfx_ctx_xegl_destroy(void *data) free(data); - /* Do not close g_x11_dpy. We'll keep one for the entire application + /* Do not close g_x11_dpy. We'll keep one for the entire application * lifecycle to work-around nVidia EGL limitations. */ } @@ -212,7 +212,7 @@ static EGLint *xegl_fill_attribs(xegl_ctx_data_t *xegl, EGLint *attr) *attr++ = xegl->egl.minor; /* Technically, we don't have core/compat until 3.2. - * Version 3.1 is either compat or not depending + * Version 3.1 is either compat or not depending * on GL_ARB_compatibility. */ if (version >= 3002) @@ -294,7 +294,7 @@ static bool gfx_ctx_xegl_set_video_mode(void *data, swa.colormap = g_x11_cmap = XCreateColormap( g_x11_dpy, RootWindow(g_x11_dpy, vi->screen), vi->visual, AllocNone); - swa.event_mask = StructureNotifyMask | KeyPressMask | + swa.event_mask = StructureNotifyMask | KeyPressMask | ButtonPressMask | ButtonReleaseMask | KeyReleaseMask; swa.override_redirect = fullscreen ? True : False; @@ -337,8 +337,8 @@ static bool gfx_ctx_xegl_set_video_mode(void *data, g_x11_win = XCreateWindow(g_x11_dpy, RootWindow(g_x11_dpy, vi->screen), x_off, y_off, width, height, 0, - vi->depth, InputOutput, vi->visual, - CWBorderPixel | CWColormap | CWEventMask | + vi->depth, InputOutput, vi->visual, + CWBorderPixel | CWColormap | CWEventMask | (true_full ? CWOverrideRedirect : 0), &swa); XSetWindowBackground(g_x11_dpy, g_x11_win, 0); @@ -362,14 +362,14 @@ static bool gfx_ctx_xegl_set_video_mode(void *data, RARCH_LOG("[X/EGL]: Using true fullscreen.\n"); XMapRaised(g_x11_dpy, g_x11_win); } - else if (fullscreen) + else if (fullscreen) { /* We attempted true fullscreen, but failed. * Attempt using windowed fullscreen. */ XMapRaised(g_x11_dpy, g_x11_win); RARCH_LOG("[X/EGL]: Using windowed fullscreen.\n"); - /* We have to move the window to the screen we + /* We have to move the window to the screen we * want to go fullscreen on first. * x_off and y_off usually get ignored in XCreateWindow(). */ @@ -380,7 +380,7 @@ static bool gfx_ctx_xegl_set_video_mode(void *data, { XMapWindow(g_x11_dpy, g_x11_win); - /* If we want to map the window on a different screen, + /* If we want to map the window on a different screen, * we'll have to do it by force. * * Otherwise, we should try to let the window manager sort it out. @@ -397,7 +397,7 @@ static bool gfx_ctx_xegl_set_video_mode(void *data, gfx_ctx_xegl_set_swap_interval(&xegl->egl, xegl->egl.interval); #endif - /* This can blow up on some drivers. It's not fatal, + /* This can blow up on some drivers. It's not fatal, * so override errors for this call. */ old_handler = XSetErrorHandler(x_nul_handler); @@ -583,7 +583,7 @@ const gfx_ctx_driver_t gfx_ctx_x_egl = gfx_ctx_xegl_init, gfx_ctx_xegl_destroy, gfx_ctx_xegl_bind_api, - gfx_ctx_xegl_set_swap_interval, + gfx_ctx_xegl_set_swap_interval, gfx_ctx_xegl_set_video_mode, x11_get_video_size, NULL, /* get_video_output_size */ diff --git a/gfx/drivers_font/caca_font.c b/gfx/drivers_font/caca_font.c index 6d6f37196a..0454aa3844 100644 --- a/gfx/drivers_font/caca_font.c +++ b/gfx/drivers_font/caca_font.c @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis * Copyright (C) 2016-2017 - Brad Parker - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/gfx/drivers_font/ctr_font.c b/gfx/drivers_font/ctr_font.c index e78054768b..08d3080ce5 100644 --- a/gfx/drivers_font/ctr_font.c +++ b/gfx/drivers_font/ctr_font.c @@ -262,7 +262,7 @@ static void ctr_font_render_line( GPU_SetViewport(NULL, VIRT_TO_PHYS(ctr->drawbuffers.top.left), 0, 0, CTR_TOP_FRAMEBUFFER_HEIGHT, - ctr->video_mode == CTR_VIDEO_MODE_800x240 + ctr->video_mode == CTR_VIDEO_MODE_800x240 ? CTR_TOP_FRAMEBUFFER_WIDTH * 2 : CTR_TOP_FRAMEBUFFER_WIDTH); GPU_DrawArray(GPU_GEOMETRY_PRIM, 0, v - ctr->vertex_cache.current); diff --git a/gfx/drivers_font/d3d_w32_font.c b/gfx/drivers_font/d3d_w32_font.c index 892197f16b..c0c707689e 100644 --- a/gfx/drivers_font/d3d_w32_font.c +++ b/gfx/drivers_font/d3d_w32_font.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/gfx/drivers_font/gdi_font.c b/gfx/drivers_font/gdi_font.c index 177b38b2bf..133de8af2f 100644 --- a/gfx/drivers_font/gdi_font.c +++ b/gfx/drivers_font/gdi_font.c @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis * Copyright (C) 2016-2017 - Brad Parker - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/gfx/drivers_font/gl_raster_font.c b/gfx/drivers_font/gl_raster_font.c index 16a2bbc55f..72d84a3205 100644 --- a/gfx/drivers_font/gl_raster_font.c +++ b/gfx/drivers_font/gl_raster_font.c @@ -303,7 +303,7 @@ static void gl_raster_font_render_line( { i = 0; while ((i < MAX_MSG_LEN_CHUNK) && (msg < msg_end)) - { + { int off_x, off_y, tex_x, tex_y, width, height; unsigned code = utf8_walk(&msg); const struct font_glyph *glyph = font->font_driver->get_glyph( @@ -374,7 +374,7 @@ static void gl_raster_font_render_message( for (;;) { const char *delim = strchr(msg, '\n'); - unsigned msg_len = delim + unsigned msg_len = delim ? (unsigned)(delim - msg) : (unsigned)strlen(msg); /* Draw the line */ diff --git a/gfx/drivers_font/ps_libdbgfont.c b/gfx/drivers_font/ps_libdbgfont.c index 25268c031e..d98f1d8cd3 100644 --- a/gfx/drivers_font/ps_libdbgfont.c +++ b/gfx/drivers_font/ps_libdbgfont.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -96,7 +96,7 @@ static void libdbg_font_render_msg( DbgFontPrint(x, y, scale - 0.01f, WHITE, msg); #ifdef SN_TARGET_PSP2 - /* FIXME - if we ever get around to this port, + /* FIXME - if we ever get around to this port, * move this out to some better place */ sceDbgFontFlush(); #endif diff --git a/gfx/drivers_font/vga_font.c b/gfx/drivers_font/vga_font.c index 229186e3c7..a217494edc 100644 --- a/gfx/drivers_font/vga_font.c +++ b/gfx/drivers_font/vga_font.c @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2016 - Daniel De Matteis * Copyright (C) 2016 - Brad Parker - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/gfx/drivers_font/vita2d_font.c b/gfx/drivers_font/vita2d_font.c index 7a4777a3eb..f6cdcace8a 100644 --- a/gfx/drivers_font/vita2d_font.c +++ b/gfx/drivers_font/vita2d_font.c @@ -38,14 +38,14 @@ static void *vita2d_font_init_font(void *data, bool is_threaded) { unsigned int stride, pitch, j, k; - const uint8_t *frame32 = NULL; + const uint8_t *frame32 = NULL; uint8_t *tex32 = NULL; const struct font_atlas *atlas = NULL; vita_font_t *font = (vita_font_t*)calloc(1, sizeof(*font)); if (!font) return NULL; - + font->vita = (vita_video_t*)data; if (!font_renderer_create_default((const void**)&font->font_driver, @@ -78,7 +78,7 @@ static void *vita2d_font_init_font(void *data, for (j = 0; j < atlas->height; j++) for (k = 0; k < atlas->width; k++) tex32[k + j*stride] = frame32[k + j*pitch]; - + font->atlas->dirty = false; return font; @@ -169,7 +169,7 @@ static void vita2d_font_render_line( int off_x, off_y, tex_x, tex_y, width, height; unsigned int stride, pitch, j, k; const struct font_glyph *glyph = NULL; - const uint8_t *frame32 = NULL; + const uint8_t *frame32 = NULL; uint8_t *tex32 = NULL; const char *msg_tmp = &msg[i]; unsigned code = utf8_walk(&msg_tmp); @@ -192,7 +192,7 @@ static void vita2d_font_render_line( tex_y = glyph->atlas_offset_y; width = glyph->width; height = glyph->height; - + if (font->atlas->dirty) { stride = vita2d_texture_get_stride(font->texture); @@ -203,7 +203,7 @@ static void vita2d_font_render_line( for (j = 0; j < font->atlas->height; j++) for (k = 0; k < font->atlas->width; k++) tex32[k + j*stride] = frame32[k + j*pitch]; - + font->atlas->dirty = false; } diff --git a/gfx/drivers_font/vulkan_raster_font.c b/gfx/drivers_font/vulkan_raster_font.c index c76910b500..a562aa33b0 100644 --- a/gfx/drivers_font/vulkan_raster_font.c +++ b/gfx/drivers_font/vulkan_raster_font.c @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2016-2017 - Hans-Kristian Arntzen - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -43,7 +43,7 @@ static void *vulkan_raster_font_init_font(void *data, const char *font_path, float font_size, bool is_threaded) { - vulkan_raster_t *font = + vulkan_raster_t *font = (vulkan_raster_t*)calloc(1, sizeof(*font)); #if 0 @@ -95,7 +95,7 @@ static void vulkan_raster_font_free_font(void *data, bool is_threaded) font->font_driver->free(font->font_data); vkQueueWaitIdle(font->vk->context->queue); - vulkan_destroy_texture( + vulkan_destroy_texture( font->vk->context->device, &font->texture); vulkan_destroy_texture( font->vk->context->device, &font->texture_optimal); @@ -124,7 +124,7 @@ static int vulkan_get_message_width(void *data, const char *msg, unsigned msg_len, float scale) { vulkan_raster_t *font = (vulkan_raster_t*)data; - + unsigned i; int delta_x = 0; @@ -133,7 +133,7 @@ static int vulkan_get_message_width(void *data, const char *msg, for (i = 0; i < msg_len; i++) { - const struct font_glyph *glyph = + const struct font_glyph *glyph = font->font_driver->get_glyph(font->font_data, (uint8_t)msg[i]); if (!glyph) /* Do something smarter here ... */ glyph = font->font_driver->get_glyph(font->font_data, '?'); @@ -272,7 +272,7 @@ static void vulkan_raster_font_render_message( static void vulkan_raster_font_flush(vulkan_raster_t *font) { struct vk_draw_triangles call; - + call.pipeline = font->vk->pipelines.font; call.texture = &font->texture_optimal; call.sampler = font->vk->samplers.mipmap_linear; @@ -407,7 +407,7 @@ static void vulkan_raster_font_render_msg( color_dark[3] = color[3] * drop_alpha; vulkan_raster_font_render_message(font, msg, scale, color_dark, - x + scale * drop_x / vk->vp.width, y + + x + scale * drop_x / vk->vp.width, y + scale * drop_y / vk->vp.height, text_align); } diff --git a/gfx/drivers_font/xdk1_xfonts.c b/gfx/drivers_font/xdk1_xfonts.c index 4e0c808d64..f76883f683 100644 --- a/gfx/drivers_font/xdk1_xfonts.c +++ b/gfx/drivers_font/xdk1_xfonts.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -60,7 +60,7 @@ static void xfonts_free_font(void *data, bool is_threaded) if (font) free(font); - + font = NULL; } diff --git a/gfx/drivers_font_renderer/bitmap.h b/gfx/drivers_font_renderer/bitmap.h index 5a5a4ba82b..8483021532 100644 --- a/gfx/drivers_font_renderer/bitmap.h +++ b/gfx/drivers_font_renderer/bitmap.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/gfx/drivers_font_renderer/bitmapfont.c b/gfx/drivers_font_renderer/bitmapfont.c index b6d289ec03..71a0996420 100644 --- a/gfx/drivers_font_renderer/bitmapfont.c +++ b/gfx/drivers_font_renderer/bitmapfont.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -56,7 +56,7 @@ static void char_to_texture(bm_renderer_t *handle, uint8_t letter, unsigned atlas_x, unsigned atlas_y) { unsigned y, x; - uint8_t *target = handle->atlas.buffer + atlas_x + + uint8_t *target = handle->atlas.buffer + atlas_x + atlas_y * handle->atlas.width; for (y = 0; y < FONT_HEIGHT; y++) @@ -101,9 +101,9 @@ static void *font_renderer_bmp_init(const char *font_path, float font_size) for (i = 0; i < BMP_ATLAS_SIZE; i++) { - unsigned x = (i % BMP_ATLAS_COLS) * + unsigned x = (i % BMP_ATLAS_COLS) * handle->scale_factor * FONT_WIDTH; - unsigned y = (i / BMP_ATLAS_COLS) * + unsigned y = (i / BMP_ATLAS_COLS) * handle->scale_factor * FONT_HEIGHT; char_to_texture(handle, i, x, y); @@ -138,10 +138,10 @@ static const char *font_renderer_bmp_get_default_font(void) static int font_renderer_bmp_get_line_height(void* data) { bm_renderer_t *handle = (bm_renderer_t*)data; - + if (!handle) return FONT_HEIGHT; - + return FONT_HEIGHT * handle->scale_factor; } diff --git a/gfx/drivers_font_renderer/coretext.c b/gfx/drivers_font_renderer/coretext.c index 9205e00f22..33a321b97e 100644 --- a/gfx/drivers_font_renderer/coretext.c +++ b/gfx/drivers_font_renderer/coretext.c @@ -124,7 +124,7 @@ static bool coretext_font_renderer_create_atlas(CTFontRef face, ct_font_renderer #if MAC_OS_X_VERSION_MAX_ALLOWED >= 1080 kCTFontOrientationDefault, #else - kCTFontDefaultOrientation, + kCTFontDefaultOrientation, #endif glyphs, advances, CT_ATLAS_SIZE); @@ -177,8 +177,8 @@ static bool coretext_font_renderer_create_atlas(CTFontRef face, ct_font_renderer CGContextSetTextMatrix(offscreen, CGAffineTransformIdentity); - attr = CFDictionaryCreate(NULL, (const void **)&keys, (const void **)&values, - sizeof(keys) / sizeof(keys[0]), &kCFTypeDictionaryKeyCallBacks, + attr = CFDictionaryCreate(NULL, (const void **)&keys, (const void **)&values, + sizeof(keys) / sizeof(keys[0]), &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks); for (i = 0; i < CT_ATLAS_SIZE; i++) @@ -208,7 +208,7 @@ static bool coretext_font_renderer_create_atlas(CTFontRef face, ct_font_renderer glyph_cstr[1] = 0; glyph_cfstr = CFStringCreateWithCString( NULL, glyph_cstr, kCFStringEncodingASCII ); - attrString = + attrString = CFAttributedStringCreate(NULL, glyph_cfstr, attr); CFRelease(glyph_cfstr); glyph_cfstr = NULL; @@ -232,7 +232,7 @@ static bool coretext_font_renderer_create_atlas(CTFontRef face, ct_font_renderer for (c = 0; c < max_width; c++) { unsigned src_idx = (unsigned)(r * bytesPerRow + c); - unsigned dest_idx = + unsigned dest_idx = (r + offset_y) * (CT_ATLAS_COLS * max_width) + (c + offset_x); uint8_t v = src[src_idx]; diff --git a/gfx/drivers_font_renderer/freetype.c b/gfx/drivers_font_renderer/freetype.c index 966ab74548..2c4edbf965 100644 --- a/gfx/drivers_font_renderer/freetype.c +++ b/gfx/drivers_font_renderer/freetype.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -263,7 +263,7 @@ error: return NULL; } -/* Not the cleanest way to do things for sure, +/* Not the cleanest way to do things for sure, * but should hopefully work ... */ static const char *font_paths[] = { diff --git a/gfx/drivers_font_renderer/stb_unicode.c b/gfx/drivers_font_renderer/stb_unicode.c index d22a461f61..878b3cd93d 100644 --- a/gfx/drivers_font_renderer/stb_unicode.c +++ b/gfx/drivers_font_renderer/stb_unicode.c @@ -211,7 +211,7 @@ static bool font_renderer_stb_unicode_create_atlas( static void *font_renderer_stb_unicode_init(const char *font_path, float font_size) { int ascent, descent, line_gap; - stb_unicode_font_renderer_t *self = + stb_unicode_font_renderer_t *self = (stb_unicode_font_renderer_t*)calloc(1, sizeof(*self)); if (!self || font_size < 1.0) diff --git a/gfx/drivers_renderchain/d3d8_renderchain.c b/gfx/drivers_renderchain/d3d8_renderchain.c index faef44aee7..3427ce988e 100644 --- a/gfx/drivers_renderchain/d3d8_renderchain.c +++ b/gfx/drivers_renderchain/d3d8_renderchain.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -78,17 +78,17 @@ static bool d3d8_renderchain_create_first_pass(void *data, LPDIRECT3DDEVICE d3dr = (LPDIRECT3DDEVICE)d3d->dev; d3d8_renderchain_t *chain = (d3d8_renderchain_t*)d3d->renderchain_data; - chain->vertex_buf = d3d_vertex_buffer_new(d3dr, 4 * sizeof(Vertex), - D3DUSAGE_WRITEONLY, D3DFVF_CUSTOMVERTEX, D3DPOOL_MANAGED, + chain->vertex_buf = d3d_vertex_buffer_new(d3dr, 4 * sizeof(Vertex), + D3DUSAGE_WRITEONLY, D3DFVF_CUSTOMVERTEX, D3DPOOL_MANAGED, NULL); if (!chain->vertex_buf) return false; - chain->tex = d3d_texture_new(d3dr, NULL, + chain->tex = d3d_texture_new(d3dr, NULL, chain->tex_w, chain->tex_h, 1, 0, - info->rgb32 - ? + info->rgb32 + ? #ifdef _XBOX D3DFMT_LIN_X8R8G8B8 : D3DFMT_LIN_R5G6B5, #else @@ -193,7 +193,7 @@ static void d3d8_renderchain_blit_to_texture(void *data, const void *frame, } /* Set the texture to NULL so D3D doesn't complain about it being in use... */ - d3d_set_texture(d3dr, 0, NULL); + d3d_set_texture(d3dr, 0, NULL); d3d_texture_blit(chain->pixel_size, chain->tex, &d3dlr, frame, width, height, pitch); } @@ -249,7 +249,7 @@ static bool d3d8_renderchain_init(void *data, unsigned fmt = (rgb32) ? RETRO_PIXEL_FORMAT_XRGB8888 : RETRO_PIXEL_FORMAT_RGB565; struct video_viewport *custom_vp = video_viewport_get_custom(); (void)final_viewport_data; - + video_driver_get_size(&width, &height); chain->dev = (LPDIRECT3DDEVICE)dev_data; @@ -346,7 +346,7 @@ static void d3d8_renderchain_convert_geometry( (void)width; (void)height; (void)final_viewport_data; - + /* stub */ } @@ -361,7 +361,7 @@ static bool d3d8_renderchain_reinit(void *data, return false; chain->pixel_size = video->rgb32 ? sizeof(uint32_t) : sizeof(uint16_t); - chain->tex_w = chain->tex_h = RARCH_SCALE_BASE * video->input_scale; + chain->tex_w = chain->tex_h = RARCH_SCALE_BASE * video->input_scale; RARCH_LOG( "Reinitializing renderchain - and textures (%u x %u @ %u bpp)\n", chain->tex_w, chain->tex_h, chain->pixel_size * CHAR_BIT); diff --git a/gfx/drivers_renderchain/d3d9_hlsl_renderchain.c b/gfx/drivers_renderchain/d3d9_hlsl_renderchain.c index 8d96721d86..b40c011604 100644 --- a/gfx/drivers_renderchain/d3d9_hlsl_renderchain.c +++ b/gfx/drivers_renderchain/d3d9_hlsl_renderchain.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -99,14 +99,14 @@ static bool hlsl_d3d9_renderchain_create_first_pass(void *data, d3d->renderchain_data; chain->vertex_buf = d3d_vertex_buffer_new( - d3dr, 4 * sizeof(Vertex), - D3DUSAGE_WRITEONLY, D3DFVF_CUSTOMVERTEX, D3DPOOL_MANAGED, + d3dr, 4 * sizeof(Vertex), + D3DUSAGE_WRITEONLY, D3DFVF_CUSTOMVERTEX, D3DPOOL_MANAGED, NULL); if (!chain->vertex_buf) return false; - chain->tex = d3d_texture_new(d3dr, NULL, + chain->tex = d3d_texture_new(d3dr, NULL, chain->tex_w, chain->tex_h, 1, 0, #ifdef _XBOX info->rgb32 ? D3DFMT_LIN_X8R8G8B8 : D3DFMT_LIN_R5G6B5, @@ -137,7 +137,7 @@ static void hlsl_d3d9_renderchain_set_vertices( video_shader_ctx_info_t shader_info; unsigned width, height; d3d_video_t *d3d = (d3d_video_t*)data; - hlsl_d3d9_renderchain_t *chain = d3d ? + hlsl_d3d9_renderchain_t *chain = d3d ? (hlsl_d3d9_renderchain_t*)d3d->renderchain_data : NULL; video_driver_get_size(&width, &height); @@ -191,7 +191,7 @@ static void hlsl_d3d9_renderchain_set_vertices( d3d_vertex_buffer_unlock(chain->vertex_buf); } - hlsl_d3d9_renderchain_set_mvp(chain, + hlsl_d3d9_renderchain_set_mvp(chain, d3d, width, height, d3d->dev_rotation); shader_info.data = d3d; @@ -236,7 +236,7 @@ static void hlsl_d3d9_renderchain_blit_to_texture( } /* Set the texture to NULL so D3D doesn't complain about it being in use... */ - d3d_set_texture(d3dr, 0, NULL); + d3d_set_texture(d3dr, 0, NULL); d3d_texture_blit(chain->pixel_size, chain->tex, &d3dlr, frame, width, height, pitch); } @@ -269,7 +269,7 @@ static void hlsl_d3d9_renderchain_free(void *data) void *hlsl_d3d9_renderchain_new(void) { - hlsl_d3d9_renderchain_t *renderchain = + hlsl_d3d9_renderchain_t *renderchain = (hlsl_d3d9_renderchain_t*)calloc(1, sizeof(*renderchain)); if (!renderchain) return NULL; @@ -277,7 +277,7 @@ void *hlsl_d3d9_renderchain_new(void) return renderchain; } -static bool hlsl_d3d9_renderchain_init_shader(void *data, +static bool hlsl_d3d9_renderchain_init_shader(void *data, void *renderchain_data) { video_shader_ctx_init_t init; @@ -316,12 +316,12 @@ static bool hlsl_d3d9_renderchain_init(void *data, const LinkInfo *link_info = (const LinkInfo*)info_data; hlsl_d3d9_renderchain_t *chain = (hlsl_d3d9_renderchain_t*) d3d->renderchain_data; - unsigned fmt = (rgb32) + unsigned fmt = (rgb32) ? RETRO_PIXEL_FORMAT_XRGB8888 : RETRO_PIXEL_FORMAT_RGB565; struct video_viewport *custom_vp = video_viewport_get_custom(); (void)final_viewport_data; - + if (!hlsl_d3d9_renderchain_init_shader(d3d, NULL)) return false; @@ -426,7 +426,7 @@ static void hlsl_d3d9_renderchain_convert_geometry( (void)width; (void)height; (void)final_viewport_data; - + /* stub */ } @@ -442,7 +442,7 @@ static bool hlsl_d3d9_renderchain_reinit(void *data, chain->pixel_size = video->rgb32 ? sizeof(uint32_t) : sizeof(uint16_t); chain->tex_w = RARCH_SCALE_BASE * video->input_scale; - chain->tex_h = RARCH_SCALE_BASE * video->input_scale; + chain->tex_h = RARCH_SCALE_BASE * video->input_scale; RARCH_LOG( "Reinitializing renderchain - and textures (%u x %u @ %u bpp)\n", diff --git a/gfx/drivers_renderchain/gl1_renderchain.c b/gfx/drivers_renderchain/gl1_renderchain.c index 56a5d27650..3eb1f887c7 100644 --- a/gfx/drivers_renderchain/gl1_renderchain.c +++ b/gfx/drivers_renderchain/gl1_renderchain.c @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis * Copyright (C) 2012-2015 - Michael Lelli - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -213,7 +213,7 @@ static void gl1_renderchain_restore_default_state(void *data, } static void gl1_renderchain_copy_frame( - void *data, + void *data, void *chain_data, video_frame_info_t *video_info, const void *frame, diff --git a/gfx/drivers_renderchain/gl2_renderchain.c b/gfx/drivers_renderchain/gl2_renderchain.c index 9f4a14fb07..95168fb8aa 100644 --- a/gfx/drivers_renderchain/gl2_renderchain.c +++ b/gfx/drivers_renderchain/gl2_renderchain.c @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis * Copyright (C) 2012-2015 - Michael Lelli - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -177,7 +177,7 @@ void gl_load_texture_data( const void *frame, unsigned base_size); void gl_set_viewport( - void *data, video_frame_info_t *video_info, + void *data, video_frame_info_t *video_info, unsigned viewport_width, unsigned viewport_height, bool force_full, bool allow_rotate); @@ -198,12 +198,12 @@ static void gl2_renderchain_convert_geometry( break; case RARCH_SCALE_ABSOLUTE: - fbo_rect->img_width = fbo_rect->max_img_width = + fbo_rect->img_width = fbo_rect->max_img_width = fbo_scale->abs_x; break; case RARCH_SCALE_VIEWPORT: - fbo_rect->img_width = fbo_rect->max_img_width = + fbo_rect->img_width = fbo_rect->max_img_width = fbo_scale->scale_x * vp_width; break; } @@ -221,7 +221,7 @@ static void gl2_renderchain_convert_geometry( break; case RARCH_SCALE_VIEWPORT: - fbo_rect->img_height = fbo_rect->max_img_height = + fbo_rect->img_height = fbo_rect->max_img_height = fbo_scale->scale_y * vp_height; break; } @@ -248,7 +248,7 @@ static bool gl_recreate_fbo( RARCH_GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, *texture, 0); - if (gl2_check_fb_status(RARCH_GL_FRAMEBUFFER) + if (gl2_check_fb_status(RARCH_GL_FRAMEBUFFER) == RARCH_GL_FRAMEBUFFER_COMPLETE) return true; @@ -256,13 +256,13 @@ static bool gl_recreate_fbo( return false; } -static void gl_check_fbo_dimension(gl_t *gl, +static void gl_check_fbo_dimension(gl_t *gl, void *chain_data, unsigned i, bool update_feedback) { struct video_fbo_rect *fbo_rect = &gl->fbo_rect[i]; - /* Check proactively since we might suddently + /* Check proactively since we might suddently * get sizes of tex_w width or tex_h height. */ gl2_renderchain_t *chain = (gl2_renderchain_t*)chain_data; unsigned img_width = fbo_rect->max_img_width; @@ -275,14 +275,14 @@ static void gl_check_fbo_dimension(gl_t *gl, gl_recreate_fbo(fbo_rect, chain->fbo[i], &chain->fbo_texture[i]); - /* Update feedback texture in-place so we avoid having to + /* Update feedback texture in-place so we avoid having to * juggle two different fbo_rect structs since they get updated here. */ if (update_feedback) { if (gl_recreate_fbo(fbo_rect, gl->fbo_feedback, &gl->fbo_feedback_texture)) { - /* Make sure the feedback textures are cleared + /* Make sure the feedback textures are cleared * so we don't feedback noise. */ glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClear(GL_COLOR_BUFFER_BIT); @@ -293,7 +293,7 @@ static void gl_check_fbo_dimension(gl_t *gl, i, fbo_rect->width, fbo_rect->height); } -/* On resize, we might have to recreate our FBOs +/* On resize, we might have to recreate our FBOs * due to "Viewport" scale, and set a new viewport. */ static void gl2_renderchain_check_fbo_dimensions(void *data, @@ -309,7 +309,7 @@ static void gl2_renderchain_check_fbo_dimensions(void *data, struct video_fbo_rect *fbo_rect = &gl->fbo_rect[i]; if (fbo_rect) { - bool update_feedback = gl->fbo_feedback_enable + bool update_feedback = gl->fbo_feedback_enable && (unsigned)i == gl->fbo_feedback_pass; if ((fbo_rect->max_img_width > fbo_rect->width) || @@ -590,7 +590,7 @@ static bool gl_create_fbo_targets(gl_t *gl, void *chain_data) if (status != RARCH_GL_FRAMEBUFFER_COMPLETE) goto error; - /* Make sure the feedback textures are cleared + /* Make sure the feedback textures are cleared * so we don't feedback noise. */ glClearColor(0.0f, 0.0f, 0.0f, 0.0f); glClear(GL_COLOR_BUFFER_BIT); @@ -606,7 +606,7 @@ error: return false; } -static void gl_create_fbo_texture(gl_t *gl, +static void gl_create_fbo_texture(gl_t *gl, void *chain_data, unsigned i, GLuint texture) { GLenum mag_filter, wrap_enum; @@ -617,7 +617,7 @@ static void gl_create_fbo_texture(gl_t *gl, gl2_renderchain_t *chain = (gl2_renderchain_t*)chain_data; settings_t *settings = config_get_ptr(); GLuint base_filt = settings->bools.video_smooth ? GL_LINEAR : GL_NEAREST; - GLuint base_mip_filt = settings->bools.video_smooth ? + GLuint base_mip_filt = settings->bools.video_smooth ? GL_LINEAR_MIPMAP_LINEAR : GL_NEAREST_MIPMAP_NEAREST; unsigned mip_level = i + 2; bool mipmapped = video_shader_driver_mipmap_input(&mip_level); @@ -628,7 +628,7 @@ static void gl_create_fbo_texture(gl_t *gl, if (video_shader_driver_filter_type(&filter_type)) { - min_filter = mipmapped ? (smooth ? + min_filter = mipmapped ? (smooth ? GL_LINEAR_MIPMAP_LINEAR : GL_NEAREST_MIPMAP_NEAREST) : (smooth ? GL_LINEAR : GL_NEAREST); } @@ -663,21 +663,21 @@ static void gl_create_fbo_texture(gl_t *gl, { #ifndef HAVE_OPENGLES bool srgb_fbo = chain->fbo_scale[i].srgb_fbo; - + if (!fp_fbo && srgb_fbo) { if (!chain->has_srgb_fbo) RARCH_ERR("[GL]: sRGB FBO was requested, but it is not supported. Falling back to UNORM. Result may have banding!\n"); } - + if (settings->bools.video_force_srgb_disable) srgb_fbo = false; - + if (srgb_fbo && chain->has_srgb_fbo) { RARCH_LOG("[GL]: FBO pass #%d is sRGB.\n", i); #ifdef HAVE_OPENGLES2 - /* EXT defines are same as core GLES3 defines, + /* EXT defines are same as core GLES3 defines, * but GLES3 variant requires different arguments. */ glTexImage2D(GL_TEXTURE_2D, 0, GL_SRGB_ALPHA_EXT, @@ -700,7 +700,7 @@ static void gl_create_fbo_texture(gl_t *gl, gl->fbo_rect[i].width, gl->fbo_rect[i].height, 0, GL_RGBA, GL_UNSIGNED_BYTE, NULL); #else - /* Avoid potential performance + /* Avoid potential performance * reductions on particular platforms. */ gl_load_texture_image(GL_TEXTURE_2D, 0, RARCH_GL_INTERNAL_FORMAT32, @@ -734,7 +734,7 @@ static void gl_create_fbo_textures(gl_t *gl, void *chain_data) } /* Compute FBO geometry. - * When width/height changes or window sizes change, + * When width/height changes or window sizes change, * we have to recalculate geometry of our FBO. */ static void gl2_renderchain_recompute_pass_sizes( @@ -807,7 +807,7 @@ static void gl2_renderchain_start_render(void *data, video_frame_info_t *video_info) { /* Used when rendering to an FBO. - * Texture coords have to be aligned + * Texture coords have to be aligned * with vertex coordinates. */ static const GLfloat fbo_vertexes[] = { 0, 0, @@ -825,7 +825,7 @@ static void gl2_renderchain_start_render(void *data, video_info, gl->fbo_rect[0].img_width, gl->fbo_rect[0].img_height, true, false); - /* Need to preserve the "flipped" state when in FBO + /* Need to preserve the "flipped" state when in FBO * as well to have consistent texture coordinates. * * We will "flip" it in place on last pass. */ @@ -885,7 +885,7 @@ void gl2_renderchain_init( if (!scale.valid) { scale.scale_x = 1.0f; - scale.scale_y = 1.0f; + scale.scale_y = 1.0f; scale.type_x = scale.type_y = RARCH_SCALE_INPUT; scale.valid = true; } @@ -902,7 +902,7 @@ void gl2_renderchain_init( if (!chain->fbo_scale[i].valid) { chain->fbo_scale[i].scale_x = chain->fbo_scale[i].scale_y = 1.0f; - chain->fbo_scale[i].type_x = chain->fbo_scale[i].type_y = + chain->fbo_scale[i].type_x = chain->fbo_scale[i].type_y = RARCH_SCALE_INPUT; chain->fbo_scale[i].valid = true; } @@ -923,7 +923,7 @@ void gl2_renderchain_init( gl->fbo_feedback_enable = video_shader_driver_get_feedback_pass( &gl->fbo_feedback_pass); - if (gl->fbo_feedback_enable && gl->fbo_feedback_pass + if (gl->fbo_feedback_enable && gl->fbo_feedback_pass < (unsigned)chain->fbo_pass) { RARCH_LOG("[GL]: Creating feedback FBO %d @ %ux%u\n", i, @@ -1064,7 +1064,7 @@ static void gl2_renderchain_bind_prev_texture( memcpy(&gl->prev_info[0], tex_info, sizeof(*tex_info)); - /* Implement feedback by swapping out FBO/textures + /* Implement feedback by swapping out FBO/textures * for FBO pass #N and feedbacks. */ if (gl->fbo_feedback_enable) { @@ -1098,7 +1098,7 @@ static void gl2_renderchain_viewport_info( } static bool gl2_renderchain_read_viewport( - void *data, + void *data, void *chain_data, uint8_t *buffer, bool is_idle) { @@ -1160,7 +1160,7 @@ static bool gl2_renderchain_read_viewport( glUnmapBuffer(GL_PIXEL_PACK_BUFFER); glBindBuffer(GL_PIXEL_PACK_BUFFER, 0); } - else + else #endif { /* Use slow synchronous readbacks. Use this with plain screenshots @@ -1272,7 +1272,7 @@ static void gl2_renderchain_restore_default_state( } static void gl2_renderchain_copy_frame( - void *data, + void *data, void *chain_data, video_frame_info_t *video_info, const void *frame, @@ -1280,7 +1280,7 @@ static void gl2_renderchain_copy_frame( { gl_t *gl = (gl_t*)data; gl2_renderchain_t *chain = (gl2_renderchain_t*)chain_data; - + (void)chain; #if defined(HAVE_PSGL) @@ -1315,7 +1315,7 @@ static void gl2_renderchain_copy_frame( img_info.rgb32 = (gl->base_size == 4); img_info.handle = &img; - new_egl = + new_egl = video_context_driver_write_to_image_buffer(&img_info); if (img == EGL_NO_IMAGE_KHR) diff --git a/gfx/drivers_renderchain/null_renderchain.c b/gfx/drivers_renderchain/null_renderchain.c index a3ed173615..c017cb9876 100644 --- a/gfx/drivers_renderchain/null_renderchain.c +++ b/gfx/drivers_renderchain/null_renderchain.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/gfx/drivers_shader/shader_gl_cg.c b/gfx/drivers_shader/shader_gl_cg.c index e37b40352c..34bb362d9c 100644 --- a/gfx/drivers_shader/shader_gl_cg.c +++ b/gfx/drivers_shader/shader_gl_cg.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -294,7 +294,7 @@ static bool gl_cg_set_coords(void *handle_data, void *shader_data, const struct } static void gl_cg_set_texture_info( - cg_shader_data_t *cg, + cg_shader_data_t *cg, const struct cg_fbo_params *params, const struct video_tex_info *info) { @@ -316,7 +316,7 @@ static void gl_cg_set_texture_info( } static void gl_cg_set_params(void *data, void *shader_data, - unsigned width, unsigned height, + unsigned width, unsigned height, unsigned tex_width, unsigned tex_height, unsigned out_width, unsigned out_height, unsigned frame_count, @@ -717,7 +717,7 @@ static bool gl_cg_load_imports(void *data) core_get_memory(&mem_info); - if ((memtype != -1u) && + if ((memtype != -1u) && (cg->shader->variable[i].addr >= mem_info.size)) { RARCH_ERR("Address out of bounds.\n"); @@ -744,7 +744,7 @@ static bool gl_cg_load_imports(void *data) tracker_info.script_is_file = true; } - tracker_info.script_class = + tracker_info.script_class = *cg->shader->script_class ? cg->shader->script_class : NULL; #endif @@ -1019,7 +1019,7 @@ static void gl_cg_set_program_attributes(void *data, unsigned i) attr_buf_tex[0] = attr_buf_vid_size[0] = attr_buf_tex_size[0] = attr_buf_coord[0] = '\0'; - snprintf(attr_buf_tex, sizeof(attr_buf_tex), + snprintf(attr_buf_tex, sizeof(attr_buf_tex), "%s.texture", prev_names[j]); snprintf(attr_buf_vid_size, sizeof(attr_buf_vid_size), "%s.video_size", prev_names[j]); @@ -1031,14 +1031,14 @@ static void gl_cg_set_program_attributes(void *data, unsigned i) cg->prg[i].prev[j].tex = cgGetNamedParameter(cg->prg[i].fprg, attr_buf_tex); - cg->prg[i].prev[j].vid_size_v = + cg->prg[i].prev[j].vid_size_v = cgGetNamedParameter(cg->prg[i].vprg, attr_buf_vid_size); - cg->prg[i].prev[j].vid_size_f = + cg->prg[i].prev[j].vid_size_f = cgGetNamedParameter(cg->prg[i].fprg, attr_buf_vid_size); - cg->prg[i].prev[j].tex_size_v = + cg->prg[i].prev[j].tex_size_v = cgGetNamedParameter(cg->prg[i].vprg, attr_buf_tex_size); - cg->prg[i].prev[j].tex_size_f = + cg->prg[i].prev[j].tex_size_f = cgGetNamedParameter(cg->prg[i].fprg, attr_buf_tex_size); cg->prg[i].prev[j].coord = cgGetNamedParameter(cg->prg[i].vprg, @@ -1109,7 +1109,7 @@ static void *gl_cg_init(void *data, const char *path) memset(cg->alias_define, 0, sizeof(cg->alias_define)); - if ( !string_is_empty(path) + if ( !string_is_empty(path) && string_is_equal_fast(path_get_extension(path), "cgp", 3)) { if (!gl_cg_load_preset(cg, path)) @@ -1126,12 +1126,12 @@ static void *gl_cg_init(void *data, const char *path) for (i = 1; i <= cg->shader->passes; i++) gl_cg_set_program_attributes(cg, i); - /* If we aren't using last pass non-FBO shader, + /* If we aren't using last pass non-FBO shader, * this shader will be assumed to be "fixed-function". * * Just use prg[0] for that pass, which will be * pass-through. */ - cg->prg[cg->shader->passes + 1] = cg->prg[0]; + cg->prg[cg->shader->passes + 1] = cg->prg[0]; /* No need to apply Android hack in Cg. */ cg->prg[VIDEO_SHADER_STOCK_BLEND] = cg->prg[0]; diff --git a/gfx/drivers_shader/shader_glsl.c b/gfx/drivers_shader/shader_glsl.c index e013c95acf..dc5b96528d 100644 --- a/gfx/drivers_shader/shader_glsl.c +++ b/gfx/drivers_shader/shader_glsl.c @@ -525,7 +525,7 @@ static bool gl_glsl_compile_programs( * load the file here, and pretend * we were really using XML all along. */ - if ( !string_is_empty(pass->source.path) + if ( !string_is_empty(pass->source.path) && !gl_glsl_load_source_path(pass, pass->source.path)) { RARCH_ERR("Failed to load GLSL shader: %s.\n", @@ -737,7 +737,7 @@ static void gl_glsl_destroy_resources(glsl_shader_data_t *glsl) return; glsl->current_idx = 0; - + glUseProgram(0); for (i = 0; i < GFX_MAX_SHADERS; i++) @@ -1465,8 +1465,8 @@ static bool gl_glsl_set_mvp(void *data, void *shader_data, const void *mat_data) { const math_matrix_4x4 *mat = (const math_matrix_4x4*)mat_data; - if ( (glsl->current_idx != glsl->active_idx) || - (mat->data != glsl->current_mat_data_pointer[glsl->active_idx]) || + if ( (glsl->current_idx != glsl->active_idx) || + (mat->data != glsl->current_mat_data_pointer[glsl->active_idx]) || (*mat->data != glsl->current_mat_data[glsl->active_idx])) { glUniformMatrix4fv(loc, 1, GL_FALSE, mat->data); @@ -1497,7 +1497,7 @@ static bool gl_glsl_set_coords(void *handle_data, void *shader_data, size_t size = 0; GLfloat *buffer = short_buffer; glsl_shader_data_t *glsl = (glsl_shader_data_t*)shader_data; - const struct shader_uniforms *uni = glsl + const struct shader_uniforms *uni = glsl ? &glsl->uniforms[glsl->active_idx] : NULL; if (!glsl || !glsl->shader->modern || !coords) diff --git a/gfx/drivers_shader/shader_glsl.h b/gfx/drivers_shader/shader_glsl.h index 7f77693a59..311bccdc95 100644 --- a/gfx/drivers_shader/shader_glsl.h +++ b/gfx/drivers_shader/shader_glsl.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/gfx/drivers_shader/shader_hlsl.c b/gfx/drivers_shader/shader_hlsl.c index 9ffedf5ef1..afc79cf913 100644 --- a/gfx/drivers_shader/shader_hlsl.c +++ b/gfx/drivers_shader/shader_hlsl.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -35,7 +35,7 @@ #include "../drivers/d3d_shaders/opaque.hlsl.d3d9.h" #include "shader_hlsl.h" -struct shader_program_hlsl_data +struct shader_program_hlsl_data { LPDIRECT3DVERTEXSHADER vprg; LPDIRECT3DPIXELSHADER fprg; @@ -188,9 +188,9 @@ static bool hlsl_compile_program( if (program_info->is_file) { ret_fp = D3DXCompileShaderFromFile(program_info->combined, NULL, NULL, - "main_fragment", "ps_3_0", 0, &code_f, &listing_f, &program->f_ctable); + "main_fragment", "ps_3_0", 0, &code_f, &listing_f, &program->f_ctable); ret_vp = D3DXCompileShaderFromFile(program_info->combined, NULL, NULL, - "main_vertex", "vs_3_0", 0, &code_v, &listing_v, &program->v_ctable); + "main_vertex", "vs_3_0", 0, &code_v, &listing_v, &program->v_ctable); } else { diff --git a/gfx/drivers_shader/shader_hlsl.h b/gfx/drivers_shader/shader_hlsl.h index 77bbe3c599..b5be3eb16f 100644 --- a/gfx/drivers_shader/shader_hlsl.h +++ b/gfx/drivers_shader/shader_hlsl.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/gfx/drivers_shader/shader_null.c b/gfx/drivers_shader/shader_null.c index 8ee92bff40..d85cfd1b97 100644 --- a/gfx/drivers_shader/shader_null.c +++ b/gfx/drivers_shader/shader_null.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/gfx/drivers_shader/shader_vulkan.h b/gfx/drivers_shader/shader_vulkan.h index 26c373023e..79ac7f2d8f 100644 --- a/gfx/drivers_shader/shader_vulkan.h +++ b/gfx/drivers_shader/shader_vulkan.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2016 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -65,7 +65,7 @@ enum vulkan_filter_chain_scale struct vulkan_filter_chain_pass_info { - /* For the last pass, make sure VIEWPORT scale + /* For the last pass, make sure VIEWPORT scale * with scale factors of 1 are used. */ enum vulkan_filter_chain_scale scale_type_x; enum vulkan_filter_chain_scale scale_type_y; diff --git a/gfx/drivers_shader/slang_preprocess.h b/gfx/drivers_shader/slang_preprocess.h index e889f31947..d2c94de12d 100644 --- a/gfx/drivers_shader/slang_preprocess.h +++ b/gfx/drivers_shader/slang_preprocess.h @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2017 - Hans-Kristian Arntzen - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/gfx/drivers_tracker/video_state_python.h b/gfx/drivers_tracker/video_state_python.h index 4abdb929f2..3addbc790c 100644 --- a/gfx/drivers_tracker/video_state_python.h +++ b/gfx/drivers_tracker/video_state_python.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -30,7 +30,7 @@ py_state_t *py_state_new(const char *program, void py_state_free(py_state_t *handle); -float py_state_get(py_state_t *handle, +float py_state_get(py_state_t *handle, const char *id, unsigned frame_count); #endif diff --git a/gfx/font_driver.c b/gfx/font_driver.c index 1390412f68..61969afe56 100644 --- a/gfx/font_driver.c +++ b/gfx/font_driver.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -51,7 +51,7 @@ int font_renderer_create_default(const void **data, void **handle, { unsigned i; - const font_renderer_driver_t **drv = + const font_renderer_driver_t **drv = (const font_renderer_driver_t**)data; for (i = 0; font_backends[i]; i++) @@ -502,8 +502,8 @@ font_data_t *font_driver_init_first( bool ok = false; #ifdef HAVE_THREADS - if ( threading_hint - && is_threaded + if ( threading_hint + && is_threaded && !video_driver_is_hw_context()) ok = video_thread_font_init(&font_driver, &font_handle, video_data, font_path, font_size, api, font_init_first, @@ -528,7 +528,7 @@ font_data_t *font_driver_init_first( void font_driver_init_osd( void *video_data, - bool threading_hint, + bool threading_hint, bool is_threaded, enum font_driver_render_api api) { diff --git a/gfx/font_driver.h b/gfx/font_driver.h index eaa3ef6a85..2656d358c6 100644 --- a/gfx/font_driver.h +++ b/gfx/font_driver.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -49,10 +49,10 @@ enum text_alignment /* All coordinates and offsets are top-left oriented. * - * This is a texture-atlas approach which allows text to + * This is a texture-atlas approach which allows text to * be drawn in a single draw call. * - * It is up to the code using this interface to actually + * It is up to the code using this interface to actually * generate proper vertex buffers and upload the atlas texture to GPU. */ struct font_glyph @@ -64,7 +64,7 @@ struct font_glyph unsigned atlas_offset_x; unsigned atlas_offset_y; - /* When drawing this glyph, apply an offset to + /* When drawing this glyph, apply an offset to * current X/Y draw coordinate. */ int draw_offset_x; int draw_offset_y; @@ -115,7 +115,7 @@ typedef struct font_renderer void (*bind_block)(void *data, void *block); void (*flush)(unsigned width, unsigned height, void *data, video_frame_info_t *video_info); - + int (*get_message_width)(void *data, const char *msg, unsigned msg_len_full, float scale); } font_renderer_t; @@ -133,7 +133,7 @@ typedef struct font_renderer_driver const char *(*get_default_font)(void); const char *ident; - + int (*get_line_height)(void* data); } font_renderer_driver_t; @@ -147,7 +147,7 @@ typedef struct /* font_path can be NULL for default font. */ int font_renderer_create_default(const void **driver, void **handle, const char *font_path, unsigned font_size); - + void font_driver_render_msg(video_frame_info_t *video_info, void *font_data, const char *msg, const void *params); diff --git a/gfx/include/GL/glext.h b/gfx/include/GL/glext.h index a1381696b4..a0d2948292 100644 --- a/gfx/include/GL/glext.h +++ b/gfx/include/GL/glext.h @@ -7,7 +7,7 @@ extern "C" { /* ** Copyright (c) 2007-2012 The Khronos Group Inc. -** +** ** Permission is hereby granted, free of charge, to any person obtaining a ** copy of this software and/or associated documentation files (the ** "Materials"), to deal in the Materials without restriction, including @@ -15,10 +15,10 @@ extern "C" { ** distribute, sublicense, and/or sell copies of the Materials, and to ** permit persons to whom the Materials are furnished to do so, subject to ** the following conditions: -** +** ** The above copyright notice and this permission notice shall be included ** in all copies or substantial portions of the Materials. -** +** ** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, ** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF ** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. diff --git a/gfx/include/d3d8/d3d8.h b/gfx/include/d3d8/d3d8.h index 2600282c16..adf91ebf0b 100644 --- a/gfx/include/d3d8/d3d8.h +++ b/gfx/include/d3d8/d3d8.h @@ -1,1279 +1,1279 @@ -/*==========================================================================; - * - * Copyright (C) Microsoft Corporation. All Rights Reserved. - * - * File: d3d8.h - * Content: Direct3D include file - * - ****************************************************************************/ - -#ifndef _D3D8_H_ -#define _D3D8_H_ - -#ifndef DIRECT3D_VERSION -#define DIRECT3D_VERSION 0x0800 -#endif //DIRECT3D_VERSION - -// include this file content only if compiling for DX8 interfaces -#if(DIRECT3D_VERSION >= 0x0800) - - -/* This identifier is passed to Direct3DCreate8 in order to ensure that an - * application was built against the correct header files. This number is - * incremented whenever a header (or other) change would require applications - * to be rebuilt. If the version doesn't match, Direct3DCreate8 will fail. - * (The number itself has no meaning.)*/ - -#define D3D_SDK_VERSION 220 - - -#include - -#define COM_NO_WINDOWS_H -#include - -#include - -#if !defined(HMONITOR_DECLARED) && (WINVER < 0x0500) - #define HMONITOR_DECLARED - DECLARE_HANDLE(HMONITOR); -#endif - -#define D3DAPI WINAPI - -/* - * Interface IID's - */ -#if defined( _WIN32 ) && !defined( _NO_COM) - -/* IID_IDirect3D8 */ -/* {1DD9E8DA-1C77-4d40-B0CF-98FEFDFF9512} */ -DEFINE_GUID(IID_IDirect3D8, 0x1dd9e8da, 0x1c77, 0x4d40, 0xb0, 0xcf, 0x98, 0xfe, 0xfd, 0xff, 0x95, 0x12); - -/* IID_IDirect3DDevice8 */ -/* {7385E5DF-8FE8-41D5-86B6-D7B48547B6CF} */ -DEFINE_GUID(IID_IDirect3DDevice8, 0x7385e5df, 0x8fe8, 0x41d5, 0x86, 0xb6, 0xd7, 0xb4, 0x85, 0x47, 0xb6, 0xcf); - -/* IID_IDirect3DResource8 */ -/* {1B36BB7B-09B7-410a-B445-7D1430D7B33F} */ -DEFINE_GUID(IID_IDirect3DResource8, 0x1b36bb7b, 0x9b7, 0x410a, 0xb4, 0x45, 0x7d, 0x14, 0x30, 0xd7, 0xb3, 0x3f); - -/* IID_IDirect3DBaseTexture8 */ -/* {B4211CFA-51B9-4a9f-AB78-DB99B2BB678E} */ -DEFINE_GUID(IID_IDirect3DBaseTexture8, 0xb4211cfa, 0x51b9, 0x4a9f, 0xab, 0x78, 0xdb, 0x99, 0xb2, 0xbb, 0x67, 0x8e); - -/* IID_IDirect3DTexture8 */ -/* {E4CDD575-2866-4f01-B12E-7EECE1EC9358} */ -DEFINE_GUID(IID_IDirect3DTexture8, 0xe4cdd575, 0x2866, 0x4f01, 0xb1, 0x2e, 0x7e, 0xec, 0xe1, 0xec, 0x93, 0x58); - -/* IID_IDirect3DCubeTexture8 */ -/* {3EE5B968-2ACA-4c34-8BB5-7E0C3D19B750} */ -DEFINE_GUID(IID_IDirect3DCubeTexture8, 0x3ee5b968, 0x2aca, 0x4c34, 0x8b, 0xb5, 0x7e, 0x0c, 0x3d, 0x19, 0xb7, 0x50); - -/* IID_IDirect3DVolumeTexture8 */ -/* {4B8AAAFA-140F-42ba-9131-597EAFAA2EAD} */ -DEFINE_GUID(IID_IDirect3DVolumeTexture8, 0x4b8aaafa, 0x140f, 0x42ba, 0x91, 0x31, 0x59, 0x7e, 0xaf, 0xaa, 0x2e, 0xad); - -/* IID_IDirect3DVertexBuffer8 */ -/* {8AEEEAC7-05F9-44d4-B591-000B0DF1CB95} */ -DEFINE_GUID(IID_IDirect3DVertexBuffer8, 0x8aeeeac7, 0x05f9, 0x44d4, 0xb5, 0x91, 0x00, 0x0b, 0x0d, 0xf1, 0xcb, 0x95); - -/* IID_IDirect3DIndexBuffer8 */ -/* {0E689C9A-053D-44a0-9D92-DB0E3D750F86} */ -DEFINE_GUID(IID_IDirect3DIndexBuffer8, 0x0e689c9a, 0x053d, 0x44a0, 0x9d, 0x92, 0xdb, 0x0e, 0x3d, 0x75, 0x0f, 0x86); - -/* IID_IDirect3DSurface8 */ -/* {B96EEBCA-B326-4ea5-882F-2FF5BAE021DD} */ -DEFINE_GUID(IID_IDirect3DSurface8, 0xb96eebca, 0xb326, 0x4ea5, 0x88, 0x2f, 0x2f, 0xf5, 0xba, 0xe0, 0x21, 0xdd); - -/* IID_IDirect3DVolume8 */ -/* {BD7349F5-14F1-42e4-9C79-972380DB40C0} */ -DEFINE_GUID(IID_IDirect3DVolume8, 0xbd7349f5, 0x14f1, 0x42e4, 0x9c, 0x79, 0x97, 0x23, 0x80, 0xdb, 0x40, 0xc0); - -/* IID_IDirect3DSwapChain8 */ -/* {928C088B-76B9-4C6B-A536-A590853876CD} */ -DEFINE_GUID(IID_IDirect3DSwapChain8, 0x928c088b, 0x76b9, 0x4c6b, 0xa5, 0x36, 0xa5, 0x90, 0x85, 0x38, 0x76, 0xcd); - -#endif - -#ifdef __cplusplus - -interface IDirect3D8; -interface IDirect3DDevice8; - -interface IDirect3DResource8; -interface IDirect3DBaseTexture8; -interface IDirect3DTexture8; -interface IDirect3DVolumeTexture8; -interface IDirect3DCubeTexture8; - -interface IDirect3DVertexBuffer8; -interface IDirect3DIndexBuffer8; - -interface IDirect3DSurface8; -interface IDirect3DVolume8; - -interface IDirect3DSwapChain8; - -#endif - - -typedef interface IDirect3D8 IDirect3D8; -typedef interface IDirect3DDevice8 IDirect3DDevice8; -typedef interface IDirect3DResource8 IDirect3DResource8; -typedef interface IDirect3DBaseTexture8 IDirect3DBaseTexture8; -typedef interface IDirect3DTexture8 IDirect3DTexture8; -typedef interface IDirect3DVolumeTexture8 IDirect3DVolumeTexture8; -typedef interface IDirect3DCubeTexture8 IDirect3DCubeTexture8; -typedef interface IDirect3DVertexBuffer8 IDirect3DVertexBuffer8; -typedef interface IDirect3DIndexBuffer8 IDirect3DIndexBuffer8; -typedef interface IDirect3DSurface8 IDirect3DSurface8; -typedef interface IDirect3DVolume8 IDirect3DVolume8; -typedef interface IDirect3DSwapChain8 IDirect3DSwapChain8; - -#include "d3d8types.h" -#include "d3d8caps.h" - - -#ifdef __cplusplus -extern "C" { -#endif - -/* - * DLL Function for creating a Direct3D8 object. This object supports - * enumeration and allows the creation of Direct3DDevice8 objects. - * Pass the value of the constant D3D_SDK_VERSION to this function, so - * that the run-time can validate that your application was compiled - * against the right headers. - */ - -IDirect3D8 * WINAPI Direct3DCreate8(UINT SDKVersion); - - -/* - * Direct3D interfaces - */ - - - - - - -#undef INTERFACE -#define INTERFACE IDirect3D8 - -DECLARE_INTERFACE_(IDirect3D8, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3D8 methods ***/ - STDMETHOD(RegisterSoftwareDevice)(THIS_ void* pInitializeFunction) PURE; - STDMETHOD_(UINT, GetAdapterCount)(THIS) PURE; - STDMETHOD(GetAdapterIdentifier)(THIS_ UINT Adapter,DWORD Flags,D3DADAPTER_IDENTIFIER8* pIdentifier) PURE; - STDMETHOD_(UINT, GetAdapterModeCount)(THIS_ UINT Adapter) PURE; - STDMETHOD(EnumAdapterModes)(THIS_ UINT Adapter,UINT Mode,D3DDISPLAYMODE* pMode) PURE; - STDMETHOD(GetAdapterDisplayMode)(THIS_ UINT Adapter,D3DDISPLAYMODE* pMode) PURE; - STDMETHOD(CheckDeviceType)(THIS_ UINT Adapter,D3DDEVTYPE CheckType,D3DFORMAT DisplayFormat,D3DFORMAT BackBufferFormat,BOOL Windowed) PURE; - STDMETHOD(CheckDeviceFormat)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,DWORD Usage,D3DRESOURCETYPE RType,D3DFORMAT CheckFormat) PURE; - STDMETHOD(CheckDeviceMultiSampleType)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT SurfaceFormat,BOOL Windowed,D3DMULTISAMPLE_TYPE MultiSampleType) PURE; - STDMETHOD(CheckDepthStencilMatch)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,D3DFORMAT RenderTargetFormat,D3DFORMAT DepthStencilFormat) PURE; - STDMETHOD(GetDeviceCaps)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,D3DCAPS8* pCaps) PURE; - STDMETHOD_(HMONITOR, GetAdapterMonitor)(THIS_ UINT Adapter) PURE; - STDMETHOD(CreateDevice)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,HWND hFocusWindow,DWORD BehaviorFlags,D3DPRESENT_PARAMETERS* pPresentationParameters,IDirect3DDevice8** ppReturnedDeviceInterface) PURE; -}; - -typedef struct IDirect3D8 *LPDIRECT3D8, *PDIRECT3D8; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3D8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3D8_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3D8_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3D8_RegisterSoftwareDevice(p,a) (p)->lpVtbl->RegisterSoftwareDevice(p,a) -#define IDirect3D8_GetAdapterCount(p) (p)->lpVtbl->GetAdapterCount(p) -#define IDirect3D8_GetAdapterIdentifier(p,a,b,c) (p)->lpVtbl->GetAdapterIdentifier(p,a,b,c) -#define IDirect3D8_GetAdapterModeCount(p,a) (p)->lpVtbl->GetAdapterModeCount(p,a) -#define IDirect3D8_EnumAdapterModes(p,a,b,c) (p)->lpVtbl->EnumAdapterModes(p,a,b,c) -#define IDirect3D8_GetAdapterDisplayMode(p,a,b) (p)->lpVtbl->GetAdapterDisplayMode(p,a,b) -#define IDirect3D8_CheckDeviceType(p,a,b,c,d,e) (p)->lpVtbl->CheckDeviceType(p,a,b,c,d,e) -#define IDirect3D8_CheckDeviceFormat(p,a,b,c,d,e,f) (p)->lpVtbl->CheckDeviceFormat(p,a,b,c,d,e,f) -#define IDirect3D8_CheckDeviceMultiSampleType(p,a,b,c,d,e) (p)->lpVtbl->CheckDeviceMultiSampleType(p,a,b,c,d,e) -#define IDirect3D8_CheckDepthStencilMatch(p,a,b,c,d,e) (p)->lpVtbl->CheckDepthStencilMatch(p,a,b,c,d,e) -#define IDirect3D8_GetDeviceCaps(p,a,b,c) (p)->lpVtbl->GetDeviceCaps(p,a,b,c) -#define IDirect3D8_GetAdapterMonitor(p,a) (p)->lpVtbl->GetAdapterMonitor(p,a) -#define IDirect3D8_CreateDevice(p,a,b,c,d,e,f) (p)->lpVtbl->CreateDevice(p,a,b,c,d,e,f) -#else -#define IDirect3D8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3D8_AddRef(p) (p)->AddRef() -#define IDirect3D8_Release(p) (p)->Release() -#define IDirect3D8_RegisterSoftwareDevice(p,a) (p)->RegisterSoftwareDevice(a) -#define IDirect3D8_GetAdapterCount(p) (p)->GetAdapterCount() -#define IDirect3D8_GetAdapterIdentifier(p,a,b,c) (p)->GetAdapterIdentifier(a,b,c) -#define IDirect3D8_GetAdapterModeCount(p,a) (p)->GetAdapterModeCount(a) -#define IDirect3D8_EnumAdapterModes(p,a,b,c) (p)->EnumAdapterModes(a,b,c) -#define IDirect3D8_GetAdapterDisplayMode(p,a,b) (p)->GetAdapterDisplayMode(a,b) -#define IDirect3D8_CheckDeviceType(p,a,b,c,d,e) (p)->CheckDeviceType(a,b,c,d,e) -#define IDirect3D8_CheckDeviceFormat(p,a,b,c,d,e,f) (p)->CheckDeviceFormat(a,b,c,d,e,f) -#define IDirect3D8_CheckDeviceMultiSampleType(p,a,b,c,d,e) (p)->CheckDeviceMultiSampleType(a,b,c,d,e) -#define IDirect3D8_CheckDepthStencilMatch(p,a,b,c,d,e) (p)->CheckDepthStencilMatch(a,b,c,d,e) -#define IDirect3D8_GetDeviceCaps(p,a,b,c) (p)->GetDeviceCaps(a,b,c) -#define IDirect3D8_GetAdapterMonitor(p,a) (p)->GetAdapterMonitor(a) -#define IDirect3D8_CreateDevice(p,a,b,c,d,e,f) (p)->CreateDevice(a,b,c,d,e,f) -#endif - - - - - - - - - - - - - - - - - - - -#undef INTERFACE -#define INTERFACE IDirect3DDevice8 - -DECLARE_INTERFACE_(IDirect3DDevice8, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DDevice8 methods ***/ - STDMETHOD(TestCooperativeLevel)(THIS) PURE; - STDMETHOD_(UINT, GetAvailableTextureMem)(THIS) PURE; - STDMETHOD(ResourceManagerDiscardBytes)(THIS_ DWORD Bytes) PURE; - STDMETHOD(GetDirect3D)(THIS_ IDirect3D8** ppD3D8) PURE; - STDMETHOD(GetDeviceCaps)(THIS_ D3DCAPS8* pCaps) PURE; - STDMETHOD(GetDisplayMode)(THIS_ D3DDISPLAYMODE* pMode) PURE; - STDMETHOD(GetCreationParameters)(THIS_ D3DDEVICE_CREATION_PARAMETERS *pParameters) PURE; - STDMETHOD(SetCursorProperties)(THIS_ UINT XHotSpot,UINT YHotSpot,IDirect3DSurface8* pCursorBitmap) PURE; - STDMETHOD_(void, SetCursorPosition)(THIS_ int X,int Y,DWORD Flags) PURE; - STDMETHOD_(BOOL, ShowCursor)(THIS_ BOOL bShow) PURE; - STDMETHOD(CreateAdditionalSwapChain)(THIS_ D3DPRESENT_PARAMETERS* pPresentationParameters,IDirect3DSwapChain8** pSwapChain) PURE; - STDMETHOD(Reset)(THIS_ D3DPRESENT_PARAMETERS* pPresentationParameters) PURE; - STDMETHOD(Present)(THIS_ CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion) PURE; - STDMETHOD(GetBackBuffer)(THIS_ UINT BackBuffer,D3DBACKBUFFER_TYPE Type,IDirect3DSurface8** ppBackBuffer) PURE; - STDMETHOD(GetRasterStatus)(THIS_ D3DRASTER_STATUS* pRasterStatus) PURE; - STDMETHOD_(void, SetGammaRamp)(THIS_ DWORD Flags,CONST D3DGAMMARAMP* pRamp) PURE; - STDMETHOD_(void, GetGammaRamp)(THIS_ D3DGAMMARAMP* pRamp) PURE; - STDMETHOD(CreateTexture)(THIS_ UINT Width,UINT Height,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DTexture8** ppTexture) PURE; - STDMETHOD(CreateVolumeTexture)(THIS_ UINT Width,UINT Height,UINT Depth,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DVolumeTexture8** ppVolumeTexture) PURE; - STDMETHOD(CreateCubeTexture)(THIS_ UINT EdgeLength,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DCubeTexture8** ppCubeTexture) PURE; - STDMETHOD(CreateVertexBuffer)(THIS_ UINT Length,DWORD Usage,DWORD FVF,D3DPOOL Pool,IDirect3DVertexBuffer8** ppVertexBuffer) PURE; - STDMETHOD(CreateIndexBuffer)(THIS_ UINT Length,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DIndexBuffer8** ppIndexBuffer) PURE; - STDMETHOD(CreateRenderTarget)(THIS_ UINT Width,UINT Height,D3DFORMAT Format,D3DMULTISAMPLE_TYPE MultiSample,BOOL Lockable,IDirect3DSurface8** ppSurface) PURE; - STDMETHOD(CreateDepthStencilSurface)(THIS_ UINT Width,UINT Height,D3DFORMAT Format,D3DMULTISAMPLE_TYPE MultiSample,IDirect3DSurface8** ppSurface) PURE; - STDMETHOD(CreateImageSurface)(THIS_ UINT Width,UINT Height,D3DFORMAT Format,IDirect3DSurface8** ppSurface) PURE; - STDMETHOD(CopyRects)(THIS_ IDirect3DSurface8* pSourceSurface,CONST RECT* pSourceRectsArray,UINT cRects,IDirect3DSurface8* pDestinationSurface,CONST POINT* pDestPointsArray) PURE; - STDMETHOD(UpdateTexture)(THIS_ IDirect3DBaseTexture8* pSourceTexture,IDirect3DBaseTexture8* pDestinationTexture) PURE; - STDMETHOD(GetFrontBuffer)(THIS_ IDirect3DSurface8* pDestSurface) PURE; - STDMETHOD(SetRenderTarget)(THIS_ IDirect3DSurface8* pRenderTarget,IDirect3DSurface8* pNewZStencil) PURE; - STDMETHOD(GetRenderTarget)(THIS_ IDirect3DSurface8** ppRenderTarget) PURE; - STDMETHOD(GetDepthStencilSurface)(THIS_ IDirect3DSurface8** ppZStencilSurface) PURE; - STDMETHOD(BeginScene)(THIS) PURE; - STDMETHOD(EndScene)(THIS) PURE; - STDMETHOD(Clear)(THIS_ DWORD Count,CONST D3DRECT* pRects,DWORD Flags,D3DCOLOR Color,float Z,DWORD Stencil) PURE; - STDMETHOD(SetTransform)(THIS_ D3DTRANSFORMSTATETYPE State,CONST D3DMATRIX* pMatrix) PURE; - STDMETHOD(GetTransform)(THIS_ D3DTRANSFORMSTATETYPE State,D3DMATRIX* pMatrix) PURE; - STDMETHOD(MultiplyTransform)(THIS_ D3DTRANSFORMSTATETYPE,CONST D3DMATRIX*) PURE; - STDMETHOD(SetViewport)(THIS_ CONST D3DVIEWPORT8* pViewport) PURE; - STDMETHOD(GetViewport)(THIS_ D3DVIEWPORT8* pViewport) PURE; - STDMETHOD(SetMaterial)(THIS_ CONST D3DMATERIAL8* pMaterial) PURE; - STDMETHOD(GetMaterial)(THIS_ D3DMATERIAL8* pMaterial) PURE; - STDMETHOD(SetLight)(THIS_ DWORD Index,CONST D3DLIGHT8*) PURE; - STDMETHOD(GetLight)(THIS_ DWORD Index,D3DLIGHT8*) PURE; - STDMETHOD(LightEnable)(THIS_ DWORD Index,BOOL Enable) PURE; - STDMETHOD(GetLightEnable)(THIS_ DWORD Index,BOOL* pEnable) PURE; - STDMETHOD(SetClipPlane)(THIS_ DWORD Index,CONST float* pPlane) PURE; - STDMETHOD(GetClipPlane)(THIS_ DWORD Index,float* pPlane) PURE; - STDMETHOD(SetRenderState)(THIS_ D3DRENDERSTATETYPE State,DWORD Value) PURE; - STDMETHOD(GetRenderState)(THIS_ D3DRENDERSTATETYPE State,DWORD* pValue) PURE; - STDMETHOD(BeginStateBlock)(THIS) PURE; - STDMETHOD(EndStateBlock)(THIS_ DWORD* pToken) PURE; - STDMETHOD(ApplyStateBlock)(THIS_ DWORD Token) PURE; - STDMETHOD(CaptureStateBlock)(THIS_ DWORD Token) PURE; - STDMETHOD(DeleteStateBlock)(THIS_ DWORD Token) PURE; - STDMETHOD(CreateStateBlock)(THIS_ D3DSTATEBLOCKTYPE Type,DWORD* pToken) PURE; - STDMETHOD(SetClipStatus)(THIS_ CONST D3DCLIPSTATUS8* pClipStatus) PURE; - STDMETHOD(GetClipStatus)(THIS_ D3DCLIPSTATUS8* pClipStatus) PURE; - STDMETHOD(GetTexture)(THIS_ DWORD Stage,IDirect3DBaseTexture8** ppTexture) PURE; - STDMETHOD(SetTexture)(THIS_ DWORD Stage,IDirect3DBaseTexture8* pTexture) PURE; - STDMETHOD(GetTextureStageState)(THIS_ DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD* pValue) PURE; - STDMETHOD(SetTextureStageState)(THIS_ DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD Value) PURE; - STDMETHOD(ValidateDevice)(THIS_ DWORD* pNumPasses) PURE; - STDMETHOD(GetInfo)(THIS_ DWORD DevInfoID,void* pDevInfoStruct,DWORD DevInfoStructSize) PURE; - STDMETHOD(SetPaletteEntries)(THIS_ UINT PaletteNumber,CONST PALETTEENTRY* pEntries) PURE; - STDMETHOD(GetPaletteEntries)(THIS_ UINT PaletteNumber,PALETTEENTRY* pEntries) PURE; - STDMETHOD(SetCurrentTexturePalette)(THIS_ UINT PaletteNumber) PURE; - STDMETHOD(GetCurrentTexturePalette)(THIS_ UINT *PaletteNumber) PURE; - STDMETHOD(DrawPrimitive)(THIS_ D3DPRIMITIVETYPE PrimitiveType,UINT StartVertex,UINT PrimitiveCount) PURE; - STDMETHOD(DrawIndexedPrimitive)(THIS_ D3DPRIMITIVETYPE,UINT minIndex,UINT NumVertices,UINT startIndex,UINT primCount) PURE; - STDMETHOD(DrawPrimitiveUP)(THIS_ D3DPRIMITIVETYPE PrimitiveType,UINT PrimitiveCount,CONST void* pVertexStreamZeroData,UINT VertexStreamZeroStride) PURE; - STDMETHOD(DrawIndexedPrimitiveUP)(THIS_ D3DPRIMITIVETYPE PrimitiveType,UINT MinVertexIndex,UINT NumVertexIndices,UINT PrimitiveCount,CONST void* pIndexData,D3DFORMAT IndexDataFormat,CONST void* pVertexStreamZeroData,UINT VertexStreamZeroStride) PURE; - STDMETHOD(ProcessVertices)(THIS_ UINT SrcStartIndex,UINT DestIndex,UINT VertexCount,IDirect3DVertexBuffer8* pDestBuffer,DWORD Flags) PURE; - STDMETHOD(CreateVertexShader)(THIS_ CONST DWORD* pDeclaration,CONST DWORD* pFunction,DWORD* pHandle,DWORD Usage) PURE; - STDMETHOD(SetVertexShader)(THIS_ DWORD Handle) PURE; - STDMETHOD(GetVertexShader)(THIS_ DWORD* pHandle) PURE; - STDMETHOD(DeleteVertexShader)(THIS_ DWORD Handle) PURE; - STDMETHOD(SetVertexShaderConstant)(THIS_ DWORD Register,CONST void* pConstantData,DWORD ConstantCount) PURE; - STDMETHOD(GetVertexShaderConstant)(THIS_ DWORD Register,void* pConstantData,DWORD ConstantCount) PURE; - STDMETHOD(GetVertexShaderDeclaration)(THIS_ DWORD Handle,void* pData,DWORD* pSizeOfData) PURE; - STDMETHOD(GetVertexShaderFunction)(THIS_ DWORD Handle,void* pData,DWORD* pSizeOfData) PURE; - STDMETHOD(SetStreamSource)(THIS_ UINT StreamNumber,IDirect3DVertexBuffer8* pStreamData,UINT Stride) PURE; - STDMETHOD(GetStreamSource)(THIS_ UINT StreamNumber,IDirect3DVertexBuffer8** ppStreamData,UINT* pStride) PURE; - STDMETHOD(SetIndices)(THIS_ IDirect3DIndexBuffer8* pIndexData,UINT BaseVertexIndex) PURE; - STDMETHOD(GetIndices)(THIS_ IDirect3DIndexBuffer8** ppIndexData,UINT* pBaseVertexIndex) PURE; - STDMETHOD(CreatePixelShader)(THIS_ CONST DWORD* pFunction,DWORD* pHandle) PURE; - STDMETHOD(SetPixelShader)(THIS_ DWORD Handle) PURE; - STDMETHOD(GetPixelShader)(THIS_ DWORD* pHandle) PURE; - STDMETHOD(DeletePixelShader)(THIS_ DWORD Handle) PURE; - STDMETHOD(SetPixelShaderConstant)(THIS_ DWORD Register,CONST void* pConstantData,DWORD ConstantCount) PURE; - STDMETHOD(GetPixelShaderConstant)(THIS_ DWORD Register,void* pConstantData,DWORD ConstantCount) PURE; - STDMETHOD(GetPixelShaderFunction)(THIS_ DWORD Handle,void* pData,DWORD* pSizeOfData) PURE; - STDMETHOD(DrawRectPatch)(THIS_ UINT Handle,CONST float* pNumSegs,CONST D3DRECTPATCH_INFO* pRectPatchInfo) PURE; - STDMETHOD(DrawTriPatch)(THIS_ UINT Handle,CONST float* pNumSegs,CONST D3DTRIPATCH_INFO* pTriPatchInfo) PURE; - STDMETHOD(DeletePatch)(THIS_ UINT Handle) PURE; -}; - -typedef struct IDirect3DDevice8 *LPDIRECT3DDEVICE8, *PDIRECT3DDEVICE8; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DDevice8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DDevice8_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DDevice8_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DDevice8_TestCooperativeLevel(p) (p)->lpVtbl->TestCooperativeLevel(p) -#define IDirect3DDevice8_GetAvailableTextureMem(p) (p)->lpVtbl->GetAvailableTextureMem(p) -#define IDirect3DDevice8_ResourceManagerDiscardBytes(p,a) (p)->lpVtbl->ResourceManagerDiscardBytes(p,a) -#define IDirect3DDevice8_GetDirect3D(p,a) (p)->lpVtbl->GetDirect3D(p,a) -#define IDirect3DDevice8_GetDeviceCaps(p,a) (p)->lpVtbl->GetDeviceCaps(p,a) -#define IDirect3DDevice8_GetDisplayMode(p,a) (p)->lpVtbl->GetDisplayMode(p,a) -#define IDirect3DDevice8_GetCreationParameters(p,a) (p)->lpVtbl->GetCreationParameters(p,a) -#define IDirect3DDevice8_SetCursorProperties(p,a,b,c) (p)->lpVtbl->SetCursorProperties(p,a,b,c) -#define IDirect3DDevice8_SetCursorPosition(p,a,b,c) (p)->lpVtbl->SetCursorPosition(p,a,b,c) -#define IDirect3DDevice8_ShowCursor(p,a) (p)->lpVtbl->ShowCursor(p,a) -#define IDirect3DDevice8_CreateAdditionalSwapChain(p,a,b) (p)->lpVtbl->CreateAdditionalSwapChain(p,a,b) -#define IDirect3DDevice8_Reset(p,a) (p)->lpVtbl->Reset(p,a) -#define IDirect3DDevice8_Present(p,a,b,c,d) (p)->lpVtbl->Present(p,a,b,c,d) -#define IDirect3DDevice8_GetBackBuffer(p,a,b,c) (p)->lpVtbl->GetBackBuffer(p,a,b,c) -#define IDirect3DDevice8_GetRasterStatus(p,a) (p)->lpVtbl->GetRasterStatus(p,a) -#define IDirect3DDevice8_SetGammaRamp(p,a,b) (p)->lpVtbl->SetGammaRamp(p,a,b) -#define IDirect3DDevice8_GetGammaRamp(p,a) (p)->lpVtbl->GetGammaRamp(p,a) -#define IDirect3DDevice8_CreateTexture(p,a,b,c,d,e,f,g) (p)->lpVtbl->CreateTexture(p,a,b,c,d,e,f,g) -#define IDirect3DDevice8_CreateVolumeTexture(p,a,b,c,d,e,f,g,h) (p)->lpVtbl->CreateVolumeTexture(p,a,b,c,d,e,f,g,h) -#define IDirect3DDevice8_CreateCubeTexture(p,a,b,c,d,e,f) (p)->lpVtbl->CreateCubeTexture(p,a,b,c,d,e,f) -#define IDirect3DDevice8_CreateVertexBuffer(p,a,b,c,d,e) (p)->lpVtbl->CreateVertexBuffer(p,a,b,c,d,e) -#define IDirect3DDevice8_CreateIndexBuffer(p,a,b,c,d,e) (p)->lpVtbl->CreateIndexBuffer(p,a,b,c,d,e) -#define IDirect3DDevice8_CreateRenderTarget(p,a,b,c,d,e,f) (p)->lpVtbl->CreateRenderTarget(p,a,b,c,d,e,f) -#define IDirect3DDevice8_CreateDepthStencilSurface(p,a,b,c,d,e) (p)->lpVtbl->CreateDepthStencilSurface(p,a,b,c,d,e) -#define IDirect3DDevice8_CreateImageSurface(p,a,b,c,d) (p)->lpVtbl->CreateImageSurface(p,a,b,c,d) -#define IDirect3DDevice8_CopyRects(p,a,b,c,d,e) (p)->lpVtbl->CopyRects(p,a,b,c,d,e) -#define IDirect3DDevice8_UpdateTexture(p,a,b) (p)->lpVtbl->UpdateTexture(p,a,b) -#define IDirect3DDevice8_GetFrontBuffer(p,a) (p)->lpVtbl->GetFrontBuffer(p,a) -#define IDirect3DDevice8_SetRenderTarget(p,a,b) (p)->lpVtbl->SetRenderTarget(p,a,b) -#define IDirect3DDevice8_GetRenderTarget(p,a) (p)->lpVtbl->GetRenderTarget(p,a) -#define IDirect3DDevice8_GetDepthStencilSurface(p,a) (p)->lpVtbl->GetDepthStencilSurface(p,a) -#define IDirect3DDevice8_BeginScene(p) (p)->lpVtbl->BeginScene(p) -#define IDirect3DDevice8_EndScene(p) (p)->lpVtbl->EndScene(p) -#define IDirect3DDevice8_Clear(p,a,b,c,d,e,f) (p)->lpVtbl->Clear(p,a,b,c,d,e,f) -#define IDirect3DDevice8_SetTransform(p,a,b) (p)->lpVtbl->SetTransform(p,a,b) -#define IDirect3DDevice8_GetTransform(p,a,b) (p)->lpVtbl->GetTransform(p,a,b) -#define IDirect3DDevice8_MultiplyTransform(p,a,b) (p)->lpVtbl->MultiplyTransform(p,a,b) -#define IDirect3DDevice8_SetViewport(p,a) (p)->lpVtbl->SetViewport(p,a) -#define IDirect3DDevice8_GetViewport(p,a) (p)->lpVtbl->GetViewport(p,a) -#define IDirect3DDevice8_SetMaterial(p,a) (p)->lpVtbl->SetMaterial(p,a) -#define IDirect3DDevice8_GetMaterial(p,a) (p)->lpVtbl->GetMaterial(p,a) -#define IDirect3DDevice8_SetLight(p,a,b) (p)->lpVtbl->SetLight(p,a,b) -#define IDirect3DDevice8_GetLight(p,a,b) (p)->lpVtbl->GetLight(p,a,b) -#define IDirect3DDevice8_LightEnable(p,a,b) (p)->lpVtbl->LightEnable(p,a,b) -#define IDirect3DDevice8_GetLightEnable(p,a,b) (p)->lpVtbl->GetLightEnable(p,a,b) -#define IDirect3DDevice8_SetClipPlane(p,a,b) (p)->lpVtbl->SetClipPlane(p,a,b) -#define IDirect3DDevice8_GetClipPlane(p,a,b) (p)->lpVtbl->GetClipPlane(p,a,b) -#define IDirect3DDevice8_SetRenderState(p,a,b) (p)->lpVtbl->SetRenderState(p,a,b) -#define IDirect3DDevice8_GetRenderState(p,a,b) (p)->lpVtbl->GetRenderState(p,a,b) -#define IDirect3DDevice8_BeginStateBlock(p) (p)->lpVtbl->BeginStateBlock(p) -#define IDirect3DDevice8_EndStateBlock(p,a) (p)->lpVtbl->EndStateBlock(p,a) -#define IDirect3DDevice8_ApplyStateBlock(p,a) (p)->lpVtbl->ApplyStateBlock(p,a) -#define IDirect3DDevice8_CaptureStateBlock(p,a) (p)->lpVtbl->CaptureStateBlock(p,a) -#define IDirect3DDevice8_DeleteStateBlock(p,a) (p)->lpVtbl->DeleteStateBlock(p,a) -#define IDirect3DDevice8_CreateStateBlock(p,a,b) (p)->lpVtbl->CreateStateBlock(p,a,b) -#define IDirect3DDevice8_SetClipStatus(p,a) (p)->lpVtbl->SetClipStatus(p,a) -#define IDirect3DDevice8_GetClipStatus(p,a) (p)->lpVtbl->GetClipStatus(p,a) -#define IDirect3DDevice8_GetTexture(p,a,b) (p)->lpVtbl->GetTexture(p,a,b) -#define IDirect3DDevice8_SetTexture(p,a,b) (p)->lpVtbl->SetTexture(p,a,b) -#define IDirect3DDevice8_GetTextureStageState(p,a,b,c) (p)->lpVtbl->GetTextureStageState(p,a,b,c) -#define IDirect3DDevice8_SetTextureStageState(p,a,b,c) (p)->lpVtbl->SetTextureStageState(p,a,b,c) -#define IDirect3DDevice8_ValidateDevice(p,a) (p)->lpVtbl->ValidateDevice(p,a) -#define IDirect3DDevice8_GetInfo(p,a,b,c) (p)->lpVtbl->GetInfo(p,a,b,c) -#define IDirect3DDevice8_SetPaletteEntries(p,a,b) (p)->lpVtbl->SetPaletteEntries(p,a,b) -#define IDirect3DDevice8_GetPaletteEntries(p,a,b) (p)->lpVtbl->GetPaletteEntries(p,a,b) -#define IDirect3DDevice8_SetCurrentTexturePalette(p,a) (p)->lpVtbl->SetCurrentTexturePalette(p,a) -#define IDirect3DDevice8_GetCurrentTexturePalette(p,a) (p)->lpVtbl->GetCurrentTexturePalette(p,a) -#define IDirect3DDevice8_DrawPrimitive(p,a,b,c) (p)->lpVtbl->DrawPrimitive(p,a,b,c) -#define IDirect3DDevice8_DrawIndexedPrimitive(p,a,b,c,d,e) (p)->lpVtbl->DrawIndexedPrimitive(p,a,b,c,d,e) -#define IDirect3DDevice8_DrawPrimitiveUP(p,a,b,c,d) (p)->lpVtbl->DrawPrimitiveUP(p,a,b,c,d) -#define IDirect3DDevice8_DrawIndexedPrimitiveUP(p,a,b,c,d,e,f,g,h) (p)->lpVtbl->DrawIndexedPrimitiveUP(p,a,b,c,d,e,f,g,h) -#define IDirect3DDevice8_ProcessVertices(p,a,b,c,d,e) (p)->lpVtbl->ProcessVertices(p,a,b,c,d,e) -#define IDirect3DDevice8_CreateVertexShader(p,a,b,c,d) (p)->lpVtbl->CreateVertexShader(p,a,b,c,d) -#define IDirect3DDevice8_SetVertexShader(p,a) (p)->lpVtbl->SetVertexShader(p,a) -#define IDirect3DDevice8_GetVertexShader(p,a) (p)->lpVtbl->GetVertexShader(p,a) -#define IDirect3DDevice8_DeleteVertexShader(p,a) (p)->lpVtbl->DeleteVertexShader(p,a) -#define IDirect3DDevice8_SetVertexShaderConstant(p,a,b,c) (p)->lpVtbl->SetVertexShaderConstant(p,a,b,c) -#define IDirect3DDevice8_GetVertexShaderConstant(p,a,b,c) (p)->lpVtbl->GetVertexShaderConstant(p,a,b,c) -#define IDirect3DDevice8_GetVertexShaderDeclaration(p,a,b,c) (p)->lpVtbl->GetVertexShaderDeclaration(p,a,b,c) -#define IDirect3DDevice8_GetVertexShaderFunction(p,a,b,c) (p)->lpVtbl->GetVertexShaderFunction(p,a,b,c) -#define IDirect3DDevice8_SetStreamSource(p,a,b,c) (p)->lpVtbl->SetStreamSource(p,a,b,c) -#define IDirect3DDevice8_GetStreamSource(p,a,b,c) (p)->lpVtbl->GetStreamSource(p,a,b,c) -#define IDirect3DDevice8_SetIndices(p,a,b) (p)->lpVtbl->SetIndices(p,a,b) -#define IDirect3DDevice8_GetIndices(p,a,b) (p)->lpVtbl->GetIndices(p,a,b) -#define IDirect3DDevice8_CreatePixelShader(p,a,b) (p)->lpVtbl->CreatePixelShader(p,a,b) -#define IDirect3DDevice8_SetPixelShader(p,a) (p)->lpVtbl->SetPixelShader(p,a) -#define IDirect3DDevice8_GetPixelShader(p,a) (p)->lpVtbl->GetPixelShader(p,a) -#define IDirect3DDevice8_DeletePixelShader(p,a) (p)->lpVtbl->DeletePixelShader(p,a) -#define IDirect3DDevice8_SetPixelShaderConstant(p,a,b,c) (p)->lpVtbl->SetPixelShaderConstant(p,a,b,c) -#define IDirect3DDevice8_GetPixelShaderConstant(p,a,b,c) (p)->lpVtbl->GetPixelShaderConstant(p,a,b,c) -#define IDirect3DDevice8_GetPixelShaderFunction(p,a,b,c) (p)->lpVtbl->GetPixelShaderFunction(p,a,b,c) -#define IDirect3DDevice8_DrawRectPatch(p,a,b,c) (p)->lpVtbl->DrawRectPatch(p,a,b,c) -#define IDirect3DDevice8_DrawTriPatch(p,a,b,c) (p)->lpVtbl->DrawTriPatch(p,a,b,c) -#define IDirect3DDevice8_DeletePatch(p,a) (p)->lpVtbl->DeletePatch(p,a) -#else -#define IDirect3DDevice8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DDevice8_AddRef(p) (p)->AddRef() -#define IDirect3DDevice8_Release(p) (p)->Release() -#define IDirect3DDevice8_TestCooperativeLevel(p) (p)->TestCooperativeLevel() -#define IDirect3DDevice8_GetAvailableTextureMem(p) (p)->GetAvailableTextureMem() -#define IDirect3DDevice8_ResourceManagerDiscardBytes(p,a) (p)->ResourceManagerDiscardBytes(a) -#define IDirect3DDevice8_GetDirect3D(p,a) (p)->GetDirect3D(a) -#define IDirect3DDevice8_GetDeviceCaps(p,a) (p)->GetDeviceCaps(a) -#define IDirect3DDevice8_GetDisplayMode(p,a) (p)->GetDisplayMode(a) -#define IDirect3DDevice8_GetCreationParameters(p,a) (p)->GetCreationParameters(a) -#define IDirect3DDevice8_SetCursorProperties(p,a,b,c) (p)->SetCursorProperties(a,b,c) -#define IDirect3DDevice8_SetCursorPosition(p,a,b,c) (p)->SetCursorPosition(a,b,c) -#define IDirect3DDevice8_ShowCursor(p,a) (p)->ShowCursor(a) -#define IDirect3DDevice8_CreateAdditionalSwapChain(p,a,b) (p)->CreateAdditionalSwapChain(a,b) -#define IDirect3DDevice8_Reset(p,a) (p)->Reset(a) -#define IDirect3DDevice8_Present(p,a,b,c,d) (p)->Present(a,b,c,d) -#define IDirect3DDevice8_GetBackBuffer(p,a,b,c) (p)->GetBackBuffer(a,b,c) -#define IDirect3DDevice8_GetRasterStatus(p,a) (p)->GetRasterStatus(a) -#define IDirect3DDevice8_SetGammaRamp(p,a,b) (p)->SetGammaRamp(a,b) -#define IDirect3DDevice8_GetGammaRamp(p,a) (p)->GetGammaRamp(a) -#define IDirect3DDevice8_CreateTexture(p,a,b,c,d,e,f,g) (p)->CreateTexture(a,b,c,d,e,f,g) -#define IDirect3DDevice8_CreateVolumeTexture(p,a,b,c,d,e,f,g,h) (p)->CreateVolumeTexture(a,b,c,d,e,f,g,h) -#define IDirect3DDevice8_CreateCubeTexture(p,a,b,c,d,e,f) (p)->CreateCubeTexture(a,b,c,d,e,f) -#define IDirect3DDevice8_CreateVertexBuffer(p,a,b,c,d,e) (p)->CreateVertexBuffer(a,b,c,d,e) -#define IDirect3DDevice8_CreateIndexBuffer(p,a,b,c,d,e) (p)->CreateIndexBuffer(a,b,c,d,e) -#define IDirect3DDevice8_CreateRenderTarget(p,a,b,c,d,e,f) (p)->CreateRenderTarget(a,b,c,d,e,f) -#define IDirect3DDevice8_CreateDepthStencilSurface(p,a,b,c,d,e) (p)->CreateDepthStencilSurface(a,b,c,d,e) -#define IDirect3DDevice8_CreateImageSurface(p,a,b,c,d) (p)->CreateImageSurface(a,b,c,d) -#define IDirect3DDevice8_CopyRects(p,a,b,c,d,e) (p)->CopyRects(a,b,c,d,e) -#define IDirect3DDevice8_UpdateTexture(p,a,b) (p)->UpdateTexture(a,b) -#define IDirect3DDevice8_GetFrontBuffer(p,a) (p)->GetFrontBuffer(a) -#define IDirect3DDevice8_SetRenderTarget(p,a,b) (p)->SetRenderTarget(a,b) -#define IDirect3DDevice8_GetRenderTarget(p,a) (p)->GetRenderTarget(a) -#define IDirect3DDevice8_GetDepthStencilSurface(p,a) (p)->GetDepthStencilSurface(a) -#define IDirect3DDevice8_BeginScene(p) (p)->BeginScene() -#define IDirect3DDevice8_EndScene(p) (p)->EndScene() -#define IDirect3DDevice8_Clear(p,a,b,c,d,e,f) (p)->Clear(a,b,c,d,e,f) -#define IDirect3DDevice8_SetTransform(p,a,b) (p)->SetTransform(a,b) -#define IDirect3DDevice8_GetTransform(p,a,b) (p)->GetTransform(a,b) -#define IDirect3DDevice8_MultiplyTransform(p,a,b) (p)->MultiplyTransform(a,b) -#define IDirect3DDevice8_SetViewport(p,a) (p)->SetViewport(a) -#define IDirect3DDevice8_GetViewport(p,a) (p)->GetViewport(a) -#define IDirect3DDevice8_SetMaterial(p,a) (p)->SetMaterial(a) -#define IDirect3DDevice8_GetMaterial(p,a) (p)->GetMaterial(a) -#define IDirect3DDevice8_SetLight(p,a,b) (p)->SetLight(a,b) -#define IDirect3DDevice8_GetLight(p,a,b) (p)->GetLight(a,b) -#define IDirect3DDevice8_LightEnable(p,a,b) (p)->LightEnable(a,b) -#define IDirect3DDevice8_GetLightEnable(p,a,b) (p)->GetLightEnable(a,b) -#define IDirect3DDevice8_SetClipPlane(p,a,b) (p)->SetClipPlane(a,b) -#define IDirect3DDevice8_GetClipPlane(p,a,b) (p)->GetClipPlane(a,b) -#define IDirect3DDevice8_SetRenderState(p,a,b) (p)->SetRenderState(a,b) -#define IDirect3DDevice8_GetRenderState(p,a,b) (p)->GetRenderState(a,b) -#define IDirect3DDevice8_BeginStateBlock(p) (p)->BeginStateBlock() -#define IDirect3DDevice8_EndStateBlock(p,a) (p)->EndStateBlock(a) -#define IDirect3DDevice8_ApplyStateBlock(p,a) (p)->ApplyStateBlock(a) -#define IDirect3DDevice8_CaptureStateBlock(p,a) (p)->CaptureStateBlock(a) -#define IDirect3DDevice8_DeleteStateBlock(p,a) (p)->DeleteStateBlock(a) -#define IDirect3DDevice8_CreateStateBlock(p,a,b) (p)->CreateStateBlock(a,b) -#define IDirect3DDevice8_SetClipStatus(p,a) (p)->SetClipStatus(a) -#define IDirect3DDevice8_GetClipStatus(p,a) (p)->GetClipStatus(a) -#define IDirect3DDevice8_GetTexture(p,a,b) (p)->GetTexture(a,b) -#define IDirect3DDevice8_SetTexture(p,a,b) (p)->SetTexture(a,b) -#define IDirect3DDevice8_GetTextureStageState(p,a,b,c) (p)->GetTextureStageState(a,b,c) -#define IDirect3DDevice8_SetTextureStageState(p,a,b,c) (p)->SetTextureStageState(a,b,c) -#define IDirect3DDevice8_ValidateDevice(p,a) (p)->ValidateDevice(a) -#define IDirect3DDevice8_GetInfo(p,a,b,c) (p)->GetInfo(a,b,c) -#define IDirect3DDevice8_SetPaletteEntries(p,a,b) (p)->SetPaletteEntries(a,b) -#define IDirect3DDevice8_GetPaletteEntries(p,a,b) (p)->GetPaletteEntries(a,b) -#define IDirect3DDevice8_SetCurrentTexturePalette(p,a) (p)->SetCurrentTexturePalette(a) -#define IDirect3DDevice8_GetCurrentTexturePalette(p,a) (p)->GetCurrentTexturePalette(a) -#define IDirect3DDevice8_DrawPrimitive(p,a,b,c) (p)->DrawPrimitive(a,b,c) -#define IDirect3DDevice8_DrawIndexedPrimitive(p,a,b,c,d,e) (p)->DrawIndexedPrimitive(a,b,c,d,e) -#define IDirect3DDevice8_DrawPrimitiveUP(p,a,b,c,d) (p)->DrawPrimitiveUP(a,b,c,d) -#define IDirect3DDevice8_DrawIndexedPrimitiveUP(p,a,b,c,d,e,f,g,h) (p)->DrawIndexedPrimitiveUP(a,b,c,d,e,f,g,h) -#define IDirect3DDevice8_ProcessVertices(p,a,b,c,d,e) (p)->ProcessVertices(a,b,c,d,e) -#define IDirect3DDevice8_CreateVertexShader(p,a,b,c,d) (p)->CreateVertexShader(a,b,c,d) -#define IDirect3DDevice8_SetVertexShader(p,a) (p)->SetVertexShader(a) -#define IDirect3DDevice8_GetVertexShader(p,a) (p)->GetVertexShader(a) -#define IDirect3DDevice8_DeleteVertexShader(p,a) (p)->DeleteVertexShader(a) -#define IDirect3DDevice8_SetVertexShaderConstant(p,a,b,c) (p)->SetVertexShaderConstant(a,b,c) -#define IDirect3DDevice8_GetVertexShaderConstant(p,a,b,c) (p)->GetVertexShaderConstant(a,b,c) -#define IDirect3DDevice8_GetVertexShaderDeclaration(p,a,b,c) (p)->GetVertexShaderDeclaration(a,b,c) -#define IDirect3DDevice8_GetVertexShaderFunction(p,a,b,c) (p)->GetVertexShaderFunction(a,b,c) -#define IDirect3DDevice8_SetStreamSource(p,a,b,c) (p)->SetStreamSource(a,b,c) -#define IDirect3DDevice8_GetStreamSource(p,a,b,c) (p)->GetStreamSource(a,b,c) -#define IDirect3DDevice8_SetIndices(p,a,b) (p)->SetIndices(a,b) -#define IDirect3DDevice8_GetIndices(p,a,b) (p)->GetIndices(a,b) -#define IDirect3DDevice8_CreatePixelShader(p,a,b) (p)->CreatePixelShader(a,b) -#define IDirect3DDevice8_SetPixelShader(p,a) (p)->SetPixelShader(a) -#define IDirect3DDevice8_GetPixelShader(p,a) (p)->GetPixelShader(a) -#define IDirect3DDevice8_DeletePixelShader(p,a) (p)->DeletePixelShader(a) -#define IDirect3DDevice8_SetPixelShaderConstant(p,a,b,c) (p)->SetPixelShaderConstant(a,b,c) -#define IDirect3DDevice8_GetPixelShaderConstant(p,a,b,c) (p)->GetPixelShaderConstant(a,b,c) -#define IDirect3DDevice8_GetPixelShaderFunction(p,a,b,c) (p)->GetPixelShaderFunction(a,b,c) -#define IDirect3DDevice8_DrawRectPatch(p,a,b,c) (p)->DrawRectPatch(a,b,c) -#define IDirect3DDevice8_DrawTriPatch(p,a,b,c) (p)->DrawTriPatch(a,b,c) -#define IDirect3DDevice8_DeletePatch(p,a) (p)->DeletePatch(a) -#endif - - - -#undef INTERFACE -#define INTERFACE IDirect3DSwapChain8 - -DECLARE_INTERFACE_(IDirect3DSwapChain8, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DSwapChain8 methods ***/ - STDMETHOD(Present)(THIS_ CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion) PURE; - STDMETHOD(GetBackBuffer)(THIS_ UINT BackBuffer,D3DBACKBUFFER_TYPE Type,IDirect3DSurface8** ppBackBuffer) PURE; -}; - -typedef struct IDirect3DSwapChain8 *LPDIRECT3DSWAPCHAIN8, *PDIRECT3DSWAPCHAIN8; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DSwapChain8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DSwapChain8_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DSwapChain8_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DSwapChain8_Present(p,a,b,c,d) (p)->lpVtbl->Present(p,a,b,c,d) -#define IDirect3DSwapChain8_GetBackBuffer(p,a,b,c) (p)->lpVtbl->GetBackBuffer(p,a,b,c) -#else -#define IDirect3DSwapChain8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DSwapChain8_AddRef(p) (p)->AddRef() -#define IDirect3DSwapChain8_Release(p) (p)->Release() -#define IDirect3DSwapChain8_Present(p,a,b,c,d) (p)->Present(a,b,c,d) -#define IDirect3DSwapChain8_GetBackBuffer(p,a,b,c) (p)->GetBackBuffer(a,b,c) -#endif - - - -#undef INTERFACE -#define INTERFACE IDirect3DResource8 - -DECLARE_INTERFACE_(IDirect3DResource8, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DResource8 methods ***/ - STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; - STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; - STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; - STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; - STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; - STDMETHOD_(DWORD, GetPriority)(THIS) PURE; - STDMETHOD_(void, PreLoad)(THIS) PURE; - STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; -}; - -typedef struct IDirect3DResource8 *LPDIRECT3DRESOURCE8, *PDIRECT3DRESOURCE8; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DResource8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DResource8_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DResource8_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DResource8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) -#define IDirect3DResource8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) -#define IDirect3DResource8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) -#define IDirect3DResource8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) -#define IDirect3DResource8_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) -#define IDirect3DResource8_GetPriority(p) (p)->lpVtbl->GetPriority(p) -#define IDirect3DResource8_PreLoad(p) (p)->lpVtbl->PreLoad(p) -#define IDirect3DResource8_GetType(p) (p)->lpVtbl->GetType(p) -#else -#define IDirect3DResource8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DResource8_AddRef(p) (p)->AddRef() -#define IDirect3DResource8_Release(p) (p)->Release() -#define IDirect3DResource8_GetDevice(p,a) (p)->GetDevice(a) -#define IDirect3DResource8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) -#define IDirect3DResource8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) -#define IDirect3DResource8_FreePrivateData(p,a) (p)->FreePrivateData(a) -#define IDirect3DResource8_SetPriority(p,a) (p)->SetPriority(a) -#define IDirect3DResource8_GetPriority(p) (p)->GetPriority() -#define IDirect3DResource8_PreLoad(p) (p)->PreLoad() -#define IDirect3DResource8_GetType(p) (p)->GetType() -#endif - - - - -#undef INTERFACE -#define INTERFACE IDirect3DBaseTexture8 - -DECLARE_INTERFACE_(IDirect3DBaseTexture8, IDirect3DResource8) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DResource8 methods ***/ - STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; - STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; - STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; - STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; - STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; - STDMETHOD_(DWORD, GetPriority)(THIS) PURE; - STDMETHOD_(void, PreLoad)(THIS) PURE; - STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; - STDMETHOD_(DWORD, SetLOD)(THIS_ DWORD LODNew) PURE; - STDMETHOD_(DWORD, GetLOD)(THIS) PURE; - STDMETHOD_(DWORD, GetLevelCount)(THIS) PURE; -}; - -typedef struct IDirect3DBaseTexture8 *LPDIRECT3DBASETEXTURE8, *PDIRECT3DBASETEXTURE8; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DBaseTexture8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DBaseTexture8_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DBaseTexture8_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DBaseTexture8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) -#define IDirect3DBaseTexture8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) -#define IDirect3DBaseTexture8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) -#define IDirect3DBaseTexture8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) -#define IDirect3DBaseTexture8_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) -#define IDirect3DBaseTexture8_GetPriority(p) (p)->lpVtbl->GetPriority(p) -#define IDirect3DBaseTexture8_PreLoad(p) (p)->lpVtbl->PreLoad(p) -#define IDirect3DBaseTexture8_GetType(p) (p)->lpVtbl->GetType(p) -#define IDirect3DBaseTexture8_SetLOD(p,a) (p)->lpVtbl->SetLOD(p,a) -#define IDirect3DBaseTexture8_GetLOD(p) (p)->lpVtbl->GetLOD(p) -#define IDirect3DBaseTexture8_GetLevelCount(p) (p)->lpVtbl->GetLevelCount(p) -#else -#define IDirect3DBaseTexture8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DBaseTexture8_AddRef(p) (p)->AddRef() -#define IDirect3DBaseTexture8_Release(p) (p)->Release() -#define IDirect3DBaseTexture8_GetDevice(p,a) (p)->GetDevice(a) -#define IDirect3DBaseTexture8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) -#define IDirect3DBaseTexture8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) -#define IDirect3DBaseTexture8_FreePrivateData(p,a) (p)->FreePrivateData(a) -#define IDirect3DBaseTexture8_SetPriority(p,a) (p)->SetPriority(a) -#define IDirect3DBaseTexture8_GetPriority(p) (p)->GetPriority() -#define IDirect3DBaseTexture8_PreLoad(p) (p)->PreLoad() -#define IDirect3DBaseTexture8_GetType(p) (p)->GetType() -#define IDirect3DBaseTexture8_SetLOD(p,a) (p)->SetLOD(a) -#define IDirect3DBaseTexture8_GetLOD(p) (p)->GetLOD() -#define IDirect3DBaseTexture8_GetLevelCount(p) (p)->GetLevelCount() -#endif - - - - - -#undef INTERFACE -#define INTERFACE IDirect3DTexture8 - -DECLARE_INTERFACE_(IDirect3DTexture8, IDirect3DBaseTexture8) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DBaseTexture8 methods ***/ - STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; - STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; - STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; - STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; - STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; - STDMETHOD_(DWORD, GetPriority)(THIS) PURE; - STDMETHOD_(void, PreLoad)(THIS) PURE; - STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; - STDMETHOD_(DWORD, SetLOD)(THIS_ DWORD LODNew) PURE; - STDMETHOD_(DWORD, GetLOD)(THIS) PURE; - STDMETHOD_(DWORD, GetLevelCount)(THIS) PURE; - STDMETHOD(GetLevelDesc)(THIS_ UINT Level,D3DSURFACE_DESC *pDesc) PURE; - STDMETHOD(GetSurfaceLevel)(THIS_ UINT Level,IDirect3DSurface8** ppSurfaceLevel) PURE; - STDMETHOD(LockRect)(THIS_ UINT Level,D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags) PURE; - STDMETHOD(UnlockRect)(THIS_ UINT Level) PURE; - STDMETHOD(AddDirtyRect)(THIS_ CONST RECT* pDirtyRect) PURE; -}; - -typedef struct IDirect3DTexture8 *LPDIRECT3DTEXTURE8, *PDIRECT3DTEXTURE8; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DTexture8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DTexture8_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DTexture8_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DTexture8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) -#define IDirect3DTexture8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) -#define IDirect3DTexture8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) -#define IDirect3DTexture8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) -#define IDirect3DTexture8_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) -#define IDirect3DTexture8_GetPriority(p) (p)->lpVtbl->GetPriority(p) -#define IDirect3DTexture8_PreLoad(p) (p)->lpVtbl->PreLoad(p) -#define IDirect3DTexture8_GetType(p) (p)->lpVtbl->GetType(p) -#define IDirect3DTexture8_SetLOD(p,a) (p)->lpVtbl->SetLOD(p,a) -#define IDirect3DTexture8_GetLOD(p) (p)->lpVtbl->GetLOD(p) -#define IDirect3DTexture8_GetLevelCount(p) (p)->lpVtbl->GetLevelCount(p) -#define IDirect3DTexture8_GetLevelDesc(p,a,b) (p)->lpVtbl->GetLevelDesc(p,a,b) -#define IDirect3DTexture8_GetSurfaceLevel(p,a,b) (p)->lpVtbl->GetSurfaceLevel(p,a,b) -#define IDirect3DTexture8_LockRect(p,a,b,c,d) (p)->lpVtbl->LockRect(p,a,b,c,d) -#define IDirect3DTexture8_UnlockRect(p,a) (p)->lpVtbl->UnlockRect(p,a) -#define IDirect3DTexture8_AddDirtyRect(p,a) (p)->lpVtbl->AddDirtyRect(p,a) -#else -#define IDirect3DTexture8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DTexture8_AddRef(p) (p)->AddRef() -#define IDirect3DTexture8_Release(p) (p)->Release() -#define IDirect3DTexture8_GetDevice(p,a) (p)->GetDevice(a) -#define IDirect3DTexture8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) -#define IDirect3DTexture8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) -#define IDirect3DTexture8_FreePrivateData(p,a) (p)->FreePrivateData(a) -#define IDirect3DTexture8_SetPriority(p,a) (p)->SetPriority(a) -#define IDirect3DTexture8_GetPriority(p) (p)->GetPriority() -#define IDirect3DTexture8_PreLoad(p) (p)->PreLoad() -#define IDirect3DTexture8_GetType(p) (p)->GetType() -#define IDirect3DTexture8_SetLOD(p,a) (p)->SetLOD(a) -#define IDirect3DTexture8_GetLOD(p) (p)->GetLOD() -#define IDirect3DTexture8_GetLevelCount(p) (p)->GetLevelCount() -#define IDirect3DTexture8_GetLevelDesc(p,a,b) (p)->GetLevelDesc(a,b) -#define IDirect3DTexture8_GetSurfaceLevel(p,a,b) (p)->GetSurfaceLevel(a,b) -#define IDirect3DTexture8_LockRect(p,a,b,c,d) (p)->LockRect(a,b,c,d) -#define IDirect3DTexture8_UnlockRect(p,a) (p)->UnlockRect(a) -#define IDirect3DTexture8_AddDirtyRect(p,a) (p)->AddDirtyRect(a) -#endif - - - - - -#undef INTERFACE -#define INTERFACE IDirect3DVolumeTexture8 - -DECLARE_INTERFACE_(IDirect3DVolumeTexture8, IDirect3DBaseTexture8) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DBaseTexture8 methods ***/ - STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; - STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; - STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; - STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; - STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; - STDMETHOD_(DWORD, GetPriority)(THIS) PURE; - STDMETHOD_(void, PreLoad)(THIS) PURE; - STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; - STDMETHOD_(DWORD, SetLOD)(THIS_ DWORD LODNew) PURE; - STDMETHOD_(DWORD, GetLOD)(THIS) PURE; - STDMETHOD_(DWORD, GetLevelCount)(THIS) PURE; - STDMETHOD(GetLevelDesc)(THIS_ UINT Level,D3DVOLUME_DESC *pDesc) PURE; - STDMETHOD(GetVolumeLevel)(THIS_ UINT Level,IDirect3DVolume8** ppVolumeLevel) PURE; - STDMETHOD(LockBox)(THIS_ UINT Level,D3DLOCKED_BOX* pLockedVolume,CONST D3DBOX* pBox,DWORD Flags) PURE; - STDMETHOD(UnlockBox)(THIS_ UINT Level) PURE; - STDMETHOD(AddDirtyBox)(THIS_ CONST D3DBOX* pDirtyBox) PURE; -}; - -typedef struct IDirect3DVolumeTexture8 *LPDIRECT3DVOLUMETEXTURE8, *PDIRECT3DVOLUMETEXTURE8; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DVolumeTexture8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DVolumeTexture8_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DVolumeTexture8_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DVolumeTexture8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) -#define IDirect3DVolumeTexture8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) -#define IDirect3DVolumeTexture8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) -#define IDirect3DVolumeTexture8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) -#define IDirect3DVolumeTexture8_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) -#define IDirect3DVolumeTexture8_GetPriority(p) (p)->lpVtbl->GetPriority(p) -#define IDirect3DVolumeTexture8_PreLoad(p) (p)->lpVtbl->PreLoad(p) -#define IDirect3DVolumeTexture8_GetType(p) (p)->lpVtbl->GetType(p) -#define IDirect3DVolumeTexture8_SetLOD(p,a) (p)->lpVtbl->SetLOD(p,a) -#define IDirect3DVolumeTexture8_GetLOD(p) (p)->lpVtbl->GetLOD(p) -#define IDirect3DVolumeTexture8_GetLevelCount(p) (p)->lpVtbl->GetLevelCount(p) -#define IDirect3DVolumeTexture8_GetLevelDesc(p,a,b) (p)->lpVtbl->GetLevelDesc(p,a,b) -#define IDirect3DVolumeTexture8_GetVolumeLevel(p,a,b) (p)->lpVtbl->GetVolumeLevel(p,a,b) -#define IDirect3DVolumeTexture8_LockBox(p,a,b,c,d) (p)->lpVtbl->LockBox(p,a,b,c,d) -#define IDirect3DVolumeTexture8_UnlockBox(p,a) (p)->lpVtbl->UnlockBox(p,a) -#define IDirect3DVolumeTexture8_AddDirtyBox(p,a) (p)->lpVtbl->AddDirtyBox(p,a) -#else -#define IDirect3DVolumeTexture8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DVolumeTexture8_AddRef(p) (p)->AddRef() -#define IDirect3DVolumeTexture8_Release(p) (p)->Release() -#define IDirect3DVolumeTexture8_GetDevice(p,a) (p)->GetDevice(a) -#define IDirect3DVolumeTexture8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) -#define IDirect3DVolumeTexture8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) -#define IDirect3DVolumeTexture8_FreePrivateData(p,a) (p)->FreePrivateData(a) -#define IDirect3DVolumeTexture8_SetPriority(p,a) (p)->SetPriority(a) -#define IDirect3DVolumeTexture8_GetPriority(p) (p)->GetPriority() -#define IDirect3DVolumeTexture8_PreLoad(p) (p)->PreLoad() -#define IDirect3DVolumeTexture8_GetType(p) (p)->GetType() -#define IDirect3DVolumeTexture8_SetLOD(p,a) (p)->SetLOD(a) -#define IDirect3DVolumeTexture8_GetLOD(p) (p)->GetLOD() -#define IDirect3DVolumeTexture8_GetLevelCount(p) (p)->GetLevelCount() -#define IDirect3DVolumeTexture8_GetLevelDesc(p,a,b) (p)->GetLevelDesc(a,b) -#define IDirect3DVolumeTexture8_GetVolumeLevel(p,a,b) (p)->GetVolumeLevel(a,b) -#define IDirect3DVolumeTexture8_LockBox(p,a,b,c,d) (p)->LockBox(a,b,c,d) -#define IDirect3DVolumeTexture8_UnlockBox(p,a) (p)->UnlockBox(a) -#define IDirect3DVolumeTexture8_AddDirtyBox(p,a) (p)->AddDirtyBox(a) -#endif - - - - - -#undef INTERFACE -#define INTERFACE IDirect3DCubeTexture8 - -DECLARE_INTERFACE_(IDirect3DCubeTexture8, IDirect3DBaseTexture8) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DBaseTexture8 methods ***/ - STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; - STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; - STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; - STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; - STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; - STDMETHOD_(DWORD, GetPriority)(THIS) PURE; - STDMETHOD_(void, PreLoad)(THIS) PURE; - STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; - STDMETHOD_(DWORD, SetLOD)(THIS_ DWORD LODNew) PURE; - STDMETHOD_(DWORD, GetLOD)(THIS) PURE; - STDMETHOD_(DWORD, GetLevelCount)(THIS) PURE; - STDMETHOD(GetLevelDesc)(THIS_ UINT Level,D3DSURFACE_DESC *pDesc) PURE; - STDMETHOD(GetCubeMapSurface)(THIS_ D3DCUBEMAP_FACES FaceType,UINT Level,IDirect3DSurface8** ppCubeMapSurface) PURE; - STDMETHOD(LockRect)(THIS_ D3DCUBEMAP_FACES FaceType,UINT Level,D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags) PURE; - STDMETHOD(UnlockRect)(THIS_ D3DCUBEMAP_FACES FaceType,UINT Level) PURE; - STDMETHOD(AddDirtyRect)(THIS_ D3DCUBEMAP_FACES FaceType,CONST RECT* pDirtyRect) PURE; -}; - -typedef struct IDirect3DCubeTexture8 *LPDIRECT3DCUBETEXTURE8, *PDIRECT3DCUBETEXTURE8; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DCubeTexture8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DCubeTexture8_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DCubeTexture8_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DCubeTexture8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) -#define IDirect3DCubeTexture8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) -#define IDirect3DCubeTexture8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) -#define IDirect3DCubeTexture8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) -#define IDirect3DCubeTexture8_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) -#define IDirect3DCubeTexture8_GetPriority(p) (p)->lpVtbl->GetPriority(p) -#define IDirect3DCubeTexture8_PreLoad(p) (p)->lpVtbl->PreLoad(p) -#define IDirect3DCubeTexture8_GetType(p) (p)->lpVtbl->GetType(p) -#define IDirect3DCubeTexture8_SetLOD(p,a) (p)->lpVtbl->SetLOD(p,a) -#define IDirect3DCubeTexture8_GetLOD(p) (p)->lpVtbl->GetLOD(p) -#define IDirect3DCubeTexture8_GetLevelCount(p) (p)->lpVtbl->GetLevelCount(p) -#define IDirect3DCubeTexture8_GetLevelDesc(p,a,b) (p)->lpVtbl->GetLevelDesc(p,a,b) -#define IDirect3DCubeTexture8_GetCubeMapSurface(p,a,b,c) (p)->lpVtbl->GetCubeMapSurface(p,a,b,c) -#define IDirect3DCubeTexture8_LockRect(p,a,b,c,d,e) (p)->lpVtbl->LockRect(p,a,b,c,d,e) -#define IDirect3DCubeTexture8_UnlockRect(p,a,b) (p)->lpVtbl->UnlockRect(p,a,b) -#define IDirect3DCubeTexture8_AddDirtyRect(p,a,b) (p)->lpVtbl->AddDirtyRect(p,a,b) -#else -#define IDirect3DCubeTexture8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DCubeTexture8_AddRef(p) (p)->AddRef() -#define IDirect3DCubeTexture8_Release(p) (p)->Release() -#define IDirect3DCubeTexture8_GetDevice(p,a) (p)->GetDevice(a) -#define IDirect3DCubeTexture8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) -#define IDirect3DCubeTexture8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) -#define IDirect3DCubeTexture8_FreePrivateData(p,a) (p)->FreePrivateData(a) -#define IDirect3DCubeTexture8_SetPriority(p,a) (p)->SetPriority(a) -#define IDirect3DCubeTexture8_GetPriority(p) (p)->GetPriority() -#define IDirect3DCubeTexture8_PreLoad(p) (p)->PreLoad() -#define IDirect3DCubeTexture8_GetType(p) (p)->GetType() -#define IDirect3DCubeTexture8_SetLOD(p,a) (p)->SetLOD(a) -#define IDirect3DCubeTexture8_GetLOD(p) (p)->GetLOD() -#define IDirect3DCubeTexture8_GetLevelCount(p) (p)->GetLevelCount() -#define IDirect3DCubeTexture8_GetLevelDesc(p,a,b) (p)->GetLevelDesc(a,b) -#define IDirect3DCubeTexture8_GetCubeMapSurface(p,a,b,c) (p)->GetCubeMapSurface(a,b,c) -#define IDirect3DCubeTexture8_LockRect(p,a,b,c,d,e) (p)->LockRect(a,b,c,d,e) -#define IDirect3DCubeTexture8_UnlockRect(p,a,b) (p)->UnlockRect(a,b) -#define IDirect3DCubeTexture8_AddDirtyRect(p,a,b) (p)->AddDirtyRect(a,b) -#endif - - - - -#undef INTERFACE -#define INTERFACE IDirect3DVertexBuffer8 - -DECLARE_INTERFACE_(IDirect3DVertexBuffer8, IDirect3DResource8) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DResource8 methods ***/ - STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; - STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; - STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; - STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; - STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; - STDMETHOD_(DWORD, GetPriority)(THIS) PURE; - STDMETHOD_(void, PreLoad)(THIS) PURE; - STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; - STDMETHOD(Lock)(THIS_ UINT OffsetToLock,UINT SizeToLock,BYTE** ppbData,DWORD Flags) PURE; - STDMETHOD(Unlock)(THIS) PURE; - STDMETHOD(GetDesc)(THIS_ D3DVERTEXBUFFER_DESC *pDesc) PURE; -}; - -typedef struct IDirect3DVertexBuffer8 *LPDIRECT3DVERTEXBUFFER8, *PDIRECT3DVERTEXBUFFER8; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DVertexBuffer8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DVertexBuffer8_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DVertexBuffer8_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DVertexBuffer8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) -#define IDirect3DVertexBuffer8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) -#define IDirect3DVertexBuffer8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) -#define IDirect3DVertexBuffer8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) -#define IDirect3DVertexBuffer8_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) -#define IDirect3DVertexBuffer8_GetPriority(p) (p)->lpVtbl->GetPriority(p) -#define IDirect3DVertexBuffer8_PreLoad(p) (p)->lpVtbl->PreLoad(p) -#define IDirect3DVertexBuffer8_GetType(p) (p)->lpVtbl->GetType(p) -#define IDirect3DVertexBuffer8_Lock(p,a,b,c,d) (p)->lpVtbl->Lock(p,a,b,c,d) -#define IDirect3DVertexBuffer8_Unlock(p) (p)->lpVtbl->Unlock(p) -#define IDirect3DVertexBuffer8_GetDesc(p,a) (p)->lpVtbl->GetDesc(p,a) -#else -#define IDirect3DVertexBuffer8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DVertexBuffer8_AddRef(p) (p)->AddRef() -#define IDirect3DVertexBuffer8_Release(p) (p)->Release() -#define IDirect3DVertexBuffer8_GetDevice(p,a) (p)->GetDevice(a) -#define IDirect3DVertexBuffer8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) -#define IDirect3DVertexBuffer8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) -#define IDirect3DVertexBuffer8_FreePrivateData(p,a) (p)->FreePrivateData(a) -#define IDirect3DVertexBuffer8_SetPriority(p,a) (p)->SetPriority(a) -#define IDirect3DVertexBuffer8_GetPriority(p) (p)->GetPriority() -#define IDirect3DVertexBuffer8_PreLoad(p) (p)->PreLoad() -#define IDirect3DVertexBuffer8_GetType(p) (p)->GetType() -#define IDirect3DVertexBuffer8_Lock(p,a,b,c,d) (p)->Lock(a,b,c,d) -#define IDirect3DVertexBuffer8_Unlock(p) (p)->Unlock() -#define IDirect3DVertexBuffer8_GetDesc(p,a) (p)->GetDesc(a) -#endif - - - - -#undef INTERFACE -#define INTERFACE IDirect3DIndexBuffer8 - -DECLARE_INTERFACE_(IDirect3DIndexBuffer8, IDirect3DResource8) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DResource8 methods ***/ - STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; - STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; - STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; - STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; - STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; - STDMETHOD_(DWORD, GetPriority)(THIS) PURE; - STDMETHOD_(void, PreLoad)(THIS) PURE; - STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; - STDMETHOD(Lock)(THIS_ UINT OffsetToLock,UINT SizeToLock,BYTE** ppbData,DWORD Flags) PURE; - STDMETHOD(Unlock)(THIS) PURE; - STDMETHOD(GetDesc)(THIS_ D3DINDEXBUFFER_DESC *pDesc) PURE; -}; - -typedef struct IDirect3DIndexBuffer8 *LPDIRECT3DINDEXBUFFER8, *PDIRECT3DINDEXBUFFER8; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DIndexBuffer8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DIndexBuffer8_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DIndexBuffer8_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DIndexBuffer8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) -#define IDirect3DIndexBuffer8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) -#define IDirect3DIndexBuffer8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) -#define IDirect3DIndexBuffer8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) -#define IDirect3DIndexBuffer8_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) -#define IDirect3DIndexBuffer8_GetPriority(p) (p)->lpVtbl->GetPriority(p) -#define IDirect3DIndexBuffer8_PreLoad(p) (p)->lpVtbl->PreLoad(p) -#define IDirect3DIndexBuffer8_GetType(p) (p)->lpVtbl->GetType(p) -#define IDirect3DIndexBuffer8_Lock(p,a,b,c,d) (p)->lpVtbl->Lock(p,a,b,c,d) -#define IDirect3DIndexBuffer8_Unlock(p) (p)->lpVtbl->Unlock(p) -#define IDirect3DIndexBuffer8_GetDesc(p,a) (p)->lpVtbl->GetDesc(p,a) -#else -#define IDirect3DIndexBuffer8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DIndexBuffer8_AddRef(p) (p)->AddRef() -#define IDirect3DIndexBuffer8_Release(p) (p)->Release() -#define IDirect3DIndexBuffer8_GetDevice(p,a) (p)->GetDevice(a) -#define IDirect3DIndexBuffer8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) -#define IDirect3DIndexBuffer8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) -#define IDirect3DIndexBuffer8_FreePrivateData(p,a) (p)->FreePrivateData(a) -#define IDirect3DIndexBuffer8_SetPriority(p,a) (p)->SetPriority(a) -#define IDirect3DIndexBuffer8_GetPriority(p) (p)->GetPriority() -#define IDirect3DIndexBuffer8_PreLoad(p) (p)->PreLoad() -#define IDirect3DIndexBuffer8_GetType(p) (p)->GetType() -#define IDirect3DIndexBuffer8_Lock(p,a,b,c,d) (p)->Lock(a,b,c,d) -#define IDirect3DIndexBuffer8_Unlock(p) (p)->Unlock() -#define IDirect3DIndexBuffer8_GetDesc(p,a) (p)->GetDesc(a) -#endif - - - - -#undef INTERFACE -#define INTERFACE IDirect3DSurface8 - -DECLARE_INTERFACE_(IDirect3DSurface8, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DSurface8 methods ***/ - STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; - STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; - STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; - STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; - STDMETHOD(GetContainer)(THIS_ REFIID riid,void** ppContainer) PURE; - STDMETHOD(GetDesc)(THIS_ D3DSURFACE_DESC *pDesc) PURE; - STDMETHOD(LockRect)(THIS_ D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags) PURE; - STDMETHOD(UnlockRect)(THIS) PURE; -}; - -typedef struct IDirect3DSurface8 *LPDIRECT3DSURFACE8, *PDIRECT3DSURFACE8; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DSurface8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DSurface8_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DSurface8_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DSurface8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) -#define IDirect3DSurface8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) -#define IDirect3DSurface8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) -#define IDirect3DSurface8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) -#define IDirect3DSurface8_GetContainer(p,a,b) (p)->lpVtbl->GetContainer(p,a,b) -#define IDirect3DSurface8_GetDesc(p,a) (p)->lpVtbl->GetDesc(p,a) -#define IDirect3DSurface8_LockRect(p,a,b,c) (p)->lpVtbl->LockRect(p,a,b,c) -#define IDirect3DSurface8_UnlockRect(p) (p)->lpVtbl->UnlockRect(p) -#else -#define IDirect3DSurface8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DSurface8_AddRef(p) (p)->AddRef() -#define IDirect3DSurface8_Release(p) (p)->Release() -#define IDirect3DSurface8_GetDevice(p,a) (p)->GetDevice(a) -#define IDirect3DSurface8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) -#define IDirect3DSurface8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) -#define IDirect3DSurface8_FreePrivateData(p,a) (p)->FreePrivateData(a) -#define IDirect3DSurface8_GetContainer(p,a,b) (p)->GetContainer(a,b) -#define IDirect3DSurface8_GetDesc(p,a) (p)->GetDesc(a) -#define IDirect3DSurface8_LockRect(p,a,b,c) (p)->LockRect(a,b,c) -#define IDirect3DSurface8_UnlockRect(p) (p)->UnlockRect() -#endif - - - - -#undef INTERFACE -#define INTERFACE IDirect3DVolume8 - -DECLARE_INTERFACE_(IDirect3DVolume8, IUnknown) -{ - /*** IUnknown methods ***/ - STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - /*** IDirect3DVolume8 methods ***/ - STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; - STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; - STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; - STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; - STDMETHOD(GetContainer)(THIS_ REFIID riid,void** ppContainer) PURE; - STDMETHOD(GetDesc)(THIS_ D3DVOLUME_DESC *pDesc) PURE; - STDMETHOD(LockBox)(THIS_ D3DLOCKED_BOX * pLockedVolume,CONST D3DBOX* pBox,DWORD Flags) PURE; - STDMETHOD(UnlockBox)(THIS) PURE; -}; - -typedef struct IDirect3DVolume8 *LPDIRECT3DVOLUME8, *PDIRECT3DVOLUME8; - -#if !defined(__cplusplus) || defined(CINTERFACE) -#define IDirect3DVolume8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) -#define IDirect3DVolume8_AddRef(p) (p)->lpVtbl->AddRef(p) -#define IDirect3DVolume8_Release(p) (p)->lpVtbl->Release(p) -#define IDirect3DVolume8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) -#define IDirect3DVolume8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) -#define IDirect3DVolume8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) -#define IDirect3DVolume8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) -#define IDirect3DVolume8_GetContainer(p,a,b) (p)->lpVtbl->GetContainer(p,a,b) -#define IDirect3DVolume8_GetDesc(p,a) (p)->lpVtbl->GetDesc(p,a) -#define IDirect3DVolume8_LockBox(p,a,b,c) (p)->lpVtbl->LockBox(p,a,b,c) -#define IDirect3DVolume8_UnlockBox(p) (p)->lpVtbl->UnlockBox(p) -#else -#define IDirect3DVolume8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) -#define IDirect3DVolume8_AddRef(p) (p)->AddRef() -#define IDirect3DVolume8_Release(p) (p)->Release() -#define IDirect3DVolume8_GetDevice(p,a) (p)->GetDevice(a) -#define IDirect3DVolume8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) -#define IDirect3DVolume8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) -#define IDirect3DVolume8_FreePrivateData(p,a) (p)->FreePrivateData(a) -#define IDirect3DVolume8_GetContainer(p,a,b) (p)->GetContainer(a,b) -#define IDirect3DVolume8_GetDesc(p,a) (p)->GetDesc(a) -#define IDirect3DVolume8_LockBox(p,a,b,c) (p)->LockBox(a,b,c) -#define IDirect3DVolume8_UnlockBox(p) (p)->UnlockBox() -#endif - -/**************************************************************************** - * Flags for SetPrivateData method on all D3D8 interfaces - * - * The passed pointer is an IUnknown ptr. The SizeOfData argument to SetPrivateData - * must be set to sizeof(IUnknown*). Direct3D will call AddRef through this - * pointer and Release when the private data is destroyed. The data will be - * destroyed when another SetPrivateData with the same GUID is set, when - * FreePrivateData is called, or when the D3D8 object is freed. - ****************************************************************************/ -#define D3DSPD_IUNKNOWN 0x00000001L - -/**************************************************************************** - * - * Parameter for IDirect3D8 Enum and GetCaps8 functions to get the info for - * the current mode only. - * - ****************************************************************************/ - -#define D3DCURRENT_DISPLAY_MODE 0x00EFFFFFL - -/**************************************************************************** - * - * Flags for IDirect3D8::CreateDevice's BehaviorFlags - * - ****************************************************************************/ - -#define D3DCREATE_FPU_PRESERVE 0x00000002L -#define D3DCREATE_MULTITHREADED 0x00000004L - -#define D3DCREATE_PUREDEVICE 0x00000010L -#define D3DCREATE_SOFTWARE_VERTEXPROCESSING 0x00000020L -#define D3DCREATE_HARDWARE_VERTEXPROCESSING 0x00000040L -#define D3DCREATE_MIXED_VERTEXPROCESSING 0x00000080L - -#define D3DCREATE_DISABLE_DRIVER_MANAGEMENT 0x00000100L - - -/**************************************************************************** - * - * Parameter for IDirect3D8::CreateDevice's iAdapter - * - ****************************************************************************/ - -#define D3DADAPTER_DEFAULT 0 - -/**************************************************************************** - * - * Flags for IDirect3D8::EnumAdapters - * - ****************************************************************************/ - -#define D3DENUM_NO_WHQL_LEVEL 0x00000002L - -/**************************************************************************** - * - * Maximum number of back-buffers supported in DX8 - * - ****************************************************************************/ - -#define D3DPRESENT_BACK_BUFFERS_MAX 3L - -/**************************************************************************** - * - * Flags for IDirect3DDevice8::SetGammaRamp - * - ****************************************************************************/ - -#define D3DSGR_NO_CALIBRATION 0x00000000L -#define D3DSGR_CALIBRATE 0x00000001L - -/**************************************************************************** - * - * Flags for IDirect3DDevice8::SetCursorPosition - * - ****************************************************************************/ - -#define D3DCURSOR_IMMEDIATE_UPDATE 0x00000001L - -/**************************************************************************** - * - * Flags for DrawPrimitive/DrawIndexedPrimitive - * Also valid for Begin/BeginIndexed - * Also valid for VertexBuffer::CreateVertexBuffer - ****************************************************************************/ - - -/* - * DirectDraw error codes - */ -#define _FACD3D 0x876 -#define MAKE_D3DHRESULT( code ) MAKE_HRESULT( 1, _FACD3D, code ) - -/* - * Direct3D Errors - */ -#define D3D_OK S_OK - -#define D3DERR_WRONGTEXTUREFORMAT MAKE_D3DHRESULT(2072) -#define D3DERR_UNSUPPORTEDCOLOROPERATION MAKE_D3DHRESULT(2073) -#define D3DERR_UNSUPPORTEDCOLORARG MAKE_D3DHRESULT(2074) -#define D3DERR_UNSUPPORTEDALPHAOPERATION MAKE_D3DHRESULT(2075) -#define D3DERR_UNSUPPORTEDALPHAARG MAKE_D3DHRESULT(2076) -#define D3DERR_TOOMANYOPERATIONS MAKE_D3DHRESULT(2077) -#define D3DERR_CONFLICTINGTEXTUREFILTER MAKE_D3DHRESULT(2078) -#define D3DERR_UNSUPPORTEDFACTORVALUE MAKE_D3DHRESULT(2079) -#define D3DERR_CONFLICTINGRENDERSTATE MAKE_D3DHRESULT(2081) -#define D3DERR_UNSUPPORTEDTEXTUREFILTER MAKE_D3DHRESULT(2082) -#define D3DERR_CONFLICTINGTEXTUREPALETTE MAKE_D3DHRESULT(2086) -#define D3DERR_DRIVERINTERNALERROR MAKE_D3DHRESULT(2087) - -#define D3DERR_NOTFOUND MAKE_D3DHRESULT(2150) -#define D3DERR_MOREDATA MAKE_D3DHRESULT(2151) -#define D3DERR_DEVICELOST MAKE_D3DHRESULT(2152) -#define D3DERR_DEVICENOTRESET MAKE_D3DHRESULT(2153) -#define D3DERR_NOTAVAILABLE MAKE_D3DHRESULT(2154) -#define D3DERR_OUTOFVIDEOMEMORY MAKE_D3DHRESULT(380) -#define D3DERR_INVALIDDEVICE MAKE_D3DHRESULT(2155) -#define D3DERR_INVALIDCALL MAKE_D3DHRESULT(2156) -#define D3DERR_DRIVERINVALIDCALL MAKE_D3DHRESULT(2157) - -#ifdef __cplusplus -}; -#endif - -#endif /* (DIRECT3D_VERSION >= 0x0800) */ -#endif /* _D3D_H_ */ - +/*==========================================================================; + * + * Copyright (C) Microsoft Corporation. All Rights Reserved. + * + * File: d3d8.h + * Content: Direct3D include file + * + ****************************************************************************/ + +#ifndef _D3D8_H_ +#define _D3D8_H_ + +#ifndef DIRECT3D_VERSION +#define DIRECT3D_VERSION 0x0800 +#endif //DIRECT3D_VERSION + +// include this file content only if compiling for DX8 interfaces +#if(DIRECT3D_VERSION >= 0x0800) + + +/* This identifier is passed to Direct3DCreate8 in order to ensure that an + * application was built against the correct header files. This number is + * incremented whenever a header (or other) change would require applications + * to be rebuilt. If the version doesn't match, Direct3DCreate8 will fail. + * (The number itself has no meaning.)*/ + +#define D3D_SDK_VERSION 220 + + +#include + +#define COM_NO_WINDOWS_H +#include + +#include + +#if !defined(HMONITOR_DECLARED) && (WINVER < 0x0500) + #define HMONITOR_DECLARED + DECLARE_HANDLE(HMONITOR); +#endif + +#define D3DAPI WINAPI + +/* + * Interface IID's + */ +#if defined( _WIN32 ) && !defined( _NO_COM) + +/* IID_IDirect3D8 */ +/* {1DD9E8DA-1C77-4d40-B0CF-98FEFDFF9512} */ +DEFINE_GUID(IID_IDirect3D8, 0x1dd9e8da, 0x1c77, 0x4d40, 0xb0, 0xcf, 0x98, 0xfe, 0xfd, 0xff, 0x95, 0x12); + +/* IID_IDirect3DDevice8 */ +/* {7385E5DF-8FE8-41D5-86B6-D7B48547B6CF} */ +DEFINE_GUID(IID_IDirect3DDevice8, 0x7385e5df, 0x8fe8, 0x41d5, 0x86, 0xb6, 0xd7, 0xb4, 0x85, 0x47, 0xb6, 0xcf); + +/* IID_IDirect3DResource8 */ +/* {1B36BB7B-09B7-410a-B445-7D1430D7B33F} */ +DEFINE_GUID(IID_IDirect3DResource8, 0x1b36bb7b, 0x9b7, 0x410a, 0xb4, 0x45, 0x7d, 0x14, 0x30, 0xd7, 0xb3, 0x3f); + +/* IID_IDirect3DBaseTexture8 */ +/* {B4211CFA-51B9-4a9f-AB78-DB99B2BB678E} */ +DEFINE_GUID(IID_IDirect3DBaseTexture8, 0xb4211cfa, 0x51b9, 0x4a9f, 0xab, 0x78, 0xdb, 0x99, 0xb2, 0xbb, 0x67, 0x8e); + +/* IID_IDirect3DTexture8 */ +/* {E4CDD575-2866-4f01-B12E-7EECE1EC9358} */ +DEFINE_GUID(IID_IDirect3DTexture8, 0xe4cdd575, 0x2866, 0x4f01, 0xb1, 0x2e, 0x7e, 0xec, 0xe1, 0xec, 0x93, 0x58); + +/* IID_IDirect3DCubeTexture8 */ +/* {3EE5B968-2ACA-4c34-8BB5-7E0C3D19B750} */ +DEFINE_GUID(IID_IDirect3DCubeTexture8, 0x3ee5b968, 0x2aca, 0x4c34, 0x8b, 0xb5, 0x7e, 0x0c, 0x3d, 0x19, 0xb7, 0x50); + +/* IID_IDirect3DVolumeTexture8 */ +/* {4B8AAAFA-140F-42ba-9131-597EAFAA2EAD} */ +DEFINE_GUID(IID_IDirect3DVolumeTexture8, 0x4b8aaafa, 0x140f, 0x42ba, 0x91, 0x31, 0x59, 0x7e, 0xaf, 0xaa, 0x2e, 0xad); + +/* IID_IDirect3DVertexBuffer8 */ +/* {8AEEEAC7-05F9-44d4-B591-000B0DF1CB95} */ +DEFINE_GUID(IID_IDirect3DVertexBuffer8, 0x8aeeeac7, 0x05f9, 0x44d4, 0xb5, 0x91, 0x00, 0x0b, 0x0d, 0xf1, 0xcb, 0x95); + +/* IID_IDirect3DIndexBuffer8 */ +/* {0E689C9A-053D-44a0-9D92-DB0E3D750F86} */ +DEFINE_GUID(IID_IDirect3DIndexBuffer8, 0x0e689c9a, 0x053d, 0x44a0, 0x9d, 0x92, 0xdb, 0x0e, 0x3d, 0x75, 0x0f, 0x86); + +/* IID_IDirect3DSurface8 */ +/* {B96EEBCA-B326-4ea5-882F-2FF5BAE021DD} */ +DEFINE_GUID(IID_IDirect3DSurface8, 0xb96eebca, 0xb326, 0x4ea5, 0x88, 0x2f, 0x2f, 0xf5, 0xba, 0xe0, 0x21, 0xdd); + +/* IID_IDirect3DVolume8 */ +/* {BD7349F5-14F1-42e4-9C79-972380DB40C0} */ +DEFINE_GUID(IID_IDirect3DVolume8, 0xbd7349f5, 0x14f1, 0x42e4, 0x9c, 0x79, 0x97, 0x23, 0x80, 0xdb, 0x40, 0xc0); + +/* IID_IDirect3DSwapChain8 */ +/* {928C088B-76B9-4C6B-A536-A590853876CD} */ +DEFINE_GUID(IID_IDirect3DSwapChain8, 0x928c088b, 0x76b9, 0x4c6b, 0xa5, 0x36, 0xa5, 0x90, 0x85, 0x38, 0x76, 0xcd); + +#endif + +#ifdef __cplusplus + +interface IDirect3D8; +interface IDirect3DDevice8; + +interface IDirect3DResource8; +interface IDirect3DBaseTexture8; +interface IDirect3DTexture8; +interface IDirect3DVolumeTexture8; +interface IDirect3DCubeTexture8; + +interface IDirect3DVertexBuffer8; +interface IDirect3DIndexBuffer8; + +interface IDirect3DSurface8; +interface IDirect3DVolume8; + +interface IDirect3DSwapChain8; + +#endif + + +typedef interface IDirect3D8 IDirect3D8; +typedef interface IDirect3DDevice8 IDirect3DDevice8; +typedef interface IDirect3DResource8 IDirect3DResource8; +typedef interface IDirect3DBaseTexture8 IDirect3DBaseTexture8; +typedef interface IDirect3DTexture8 IDirect3DTexture8; +typedef interface IDirect3DVolumeTexture8 IDirect3DVolumeTexture8; +typedef interface IDirect3DCubeTexture8 IDirect3DCubeTexture8; +typedef interface IDirect3DVertexBuffer8 IDirect3DVertexBuffer8; +typedef interface IDirect3DIndexBuffer8 IDirect3DIndexBuffer8; +typedef interface IDirect3DSurface8 IDirect3DSurface8; +typedef interface IDirect3DVolume8 IDirect3DVolume8; +typedef interface IDirect3DSwapChain8 IDirect3DSwapChain8; + +#include "d3d8types.h" +#include "d3d8caps.h" + + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * DLL Function for creating a Direct3D8 object. This object supports + * enumeration and allows the creation of Direct3DDevice8 objects. + * Pass the value of the constant D3D_SDK_VERSION to this function, so + * that the run-time can validate that your application was compiled + * against the right headers. + */ + +IDirect3D8 * WINAPI Direct3DCreate8(UINT SDKVersion); + + +/* + * Direct3D interfaces + */ + + + + + + +#undef INTERFACE +#define INTERFACE IDirect3D8 + +DECLARE_INTERFACE_(IDirect3D8, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3D8 methods ***/ + STDMETHOD(RegisterSoftwareDevice)(THIS_ void* pInitializeFunction) PURE; + STDMETHOD_(UINT, GetAdapterCount)(THIS) PURE; + STDMETHOD(GetAdapterIdentifier)(THIS_ UINT Adapter,DWORD Flags,D3DADAPTER_IDENTIFIER8* pIdentifier) PURE; + STDMETHOD_(UINT, GetAdapterModeCount)(THIS_ UINT Adapter) PURE; + STDMETHOD(EnumAdapterModes)(THIS_ UINT Adapter,UINT Mode,D3DDISPLAYMODE* pMode) PURE; + STDMETHOD(GetAdapterDisplayMode)(THIS_ UINT Adapter,D3DDISPLAYMODE* pMode) PURE; + STDMETHOD(CheckDeviceType)(THIS_ UINT Adapter,D3DDEVTYPE CheckType,D3DFORMAT DisplayFormat,D3DFORMAT BackBufferFormat,BOOL Windowed) PURE; + STDMETHOD(CheckDeviceFormat)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,DWORD Usage,D3DRESOURCETYPE RType,D3DFORMAT CheckFormat) PURE; + STDMETHOD(CheckDeviceMultiSampleType)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT SurfaceFormat,BOOL Windowed,D3DMULTISAMPLE_TYPE MultiSampleType) PURE; + STDMETHOD(CheckDepthStencilMatch)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,D3DFORMAT AdapterFormat,D3DFORMAT RenderTargetFormat,D3DFORMAT DepthStencilFormat) PURE; + STDMETHOD(GetDeviceCaps)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,D3DCAPS8* pCaps) PURE; + STDMETHOD_(HMONITOR, GetAdapterMonitor)(THIS_ UINT Adapter) PURE; + STDMETHOD(CreateDevice)(THIS_ UINT Adapter,D3DDEVTYPE DeviceType,HWND hFocusWindow,DWORD BehaviorFlags,D3DPRESENT_PARAMETERS* pPresentationParameters,IDirect3DDevice8** ppReturnedDeviceInterface) PURE; +}; + +typedef struct IDirect3D8 *LPDIRECT3D8, *PDIRECT3D8; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3D8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3D8_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3D8_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3D8_RegisterSoftwareDevice(p,a) (p)->lpVtbl->RegisterSoftwareDevice(p,a) +#define IDirect3D8_GetAdapterCount(p) (p)->lpVtbl->GetAdapterCount(p) +#define IDirect3D8_GetAdapterIdentifier(p,a,b,c) (p)->lpVtbl->GetAdapterIdentifier(p,a,b,c) +#define IDirect3D8_GetAdapterModeCount(p,a) (p)->lpVtbl->GetAdapterModeCount(p,a) +#define IDirect3D8_EnumAdapterModes(p,a,b,c) (p)->lpVtbl->EnumAdapterModes(p,a,b,c) +#define IDirect3D8_GetAdapterDisplayMode(p,a,b) (p)->lpVtbl->GetAdapterDisplayMode(p,a,b) +#define IDirect3D8_CheckDeviceType(p,a,b,c,d,e) (p)->lpVtbl->CheckDeviceType(p,a,b,c,d,e) +#define IDirect3D8_CheckDeviceFormat(p,a,b,c,d,e,f) (p)->lpVtbl->CheckDeviceFormat(p,a,b,c,d,e,f) +#define IDirect3D8_CheckDeviceMultiSampleType(p,a,b,c,d,e) (p)->lpVtbl->CheckDeviceMultiSampleType(p,a,b,c,d,e) +#define IDirect3D8_CheckDepthStencilMatch(p,a,b,c,d,e) (p)->lpVtbl->CheckDepthStencilMatch(p,a,b,c,d,e) +#define IDirect3D8_GetDeviceCaps(p,a,b,c) (p)->lpVtbl->GetDeviceCaps(p,a,b,c) +#define IDirect3D8_GetAdapterMonitor(p,a) (p)->lpVtbl->GetAdapterMonitor(p,a) +#define IDirect3D8_CreateDevice(p,a,b,c,d,e,f) (p)->lpVtbl->CreateDevice(p,a,b,c,d,e,f) +#else +#define IDirect3D8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3D8_AddRef(p) (p)->AddRef() +#define IDirect3D8_Release(p) (p)->Release() +#define IDirect3D8_RegisterSoftwareDevice(p,a) (p)->RegisterSoftwareDevice(a) +#define IDirect3D8_GetAdapterCount(p) (p)->GetAdapterCount() +#define IDirect3D8_GetAdapterIdentifier(p,a,b,c) (p)->GetAdapterIdentifier(a,b,c) +#define IDirect3D8_GetAdapterModeCount(p,a) (p)->GetAdapterModeCount(a) +#define IDirect3D8_EnumAdapterModes(p,a,b,c) (p)->EnumAdapterModes(a,b,c) +#define IDirect3D8_GetAdapterDisplayMode(p,a,b) (p)->GetAdapterDisplayMode(a,b) +#define IDirect3D8_CheckDeviceType(p,a,b,c,d,e) (p)->CheckDeviceType(a,b,c,d,e) +#define IDirect3D8_CheckDeviceFormat(p,a,b,c,d,e,f) (p)->CheckDeviceFormat(a,b,c,d,e,f) +#define IDirect3D8_CheckDeviceMultiSampleType(p,a,b,c,d,e) (p)->CheckDeviceMultiSampleType(a,b,c,d,e) +#define IDirect3D8_CheckDepthStencilMatch(p,a,b,c,d,e) (p)->CheckDepthStencilMatch(a,b,c,d,e) +#define IDirect3D8_GetDeviceCaps(p,a,b,c) (p)->GetDeviceCaps(a,b,c) +#define IDirect3D8_GetAdapterMonitor(p,a) (p)->GetAdapterMonitor(a) +#define IDirect3D8_CreateDevice(p,a,b,c,d,e,f) (p)->CreateDevice(a,b,c,d,e,f) +#endif + + + + + + + + + + + + + + + + + + + +#undef INTERFACE +#define INTERFACE IDirect3DDevice8 + +DECLARE_INTERFACE_(IDirect3DDevice8, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DDevice8 methods ***/ + STDMETHOD(TestCooperativeLevel)(THIS) PURE; + STDMETHOD_(UINT, GetAvailableTextureMem)(THIS) PURE; + STDMETHOD(ResourceManagerDiscardBytes)(THIS_ DWORD Bytes) PURE; + STDMETHOD(GetDirect3D)(THIS_ IDirect3D8** ppD3D8) PURE; + STDMETHOD(GetDeviceCaps)(THIS_ D3DCAPS8* pCaps) PURE; + STDMETHOD(GetDisplayMode)(THIS_ D3DDISPLAYMODE* pMode) PURE; + STDMETHOD(GetCreationParameters)(THIS_ D3DDEVICE_CREATION_PARAMETERS *pParameters) PURE; + STDMETHOD(SetCursorProperties)(THIS_ UINT XHotSpot,UINT YHotSpot,IDirect3DSurface8* pCursorBitmap) PURE; + STDMETHOD_(void, SetCursorPosition)(THIS_ int X,int Y,DWORD Flags) PURE; + STDMETHOD_(BOOL, ShowCursor)(THIS_ BOOL bShow) PURE; + STDMETHOD(CreateAdditionalSwapChain)(THIS_ D3DPRESENT_PARAMETERS* pPresentationParameters,IDirect3DSwapChain8** pSwapChain) PURE; + STDMETHOD(Reset)(THIS_ D3DPRESENT_PARAMETERS* pPresentationParameters) PURE; + STDMETHOD(Present)(THIS_ CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion) PURE; + STDMETHOD(GetBackBuffer)(THIS_ UINT BackBuffer,D3DBACKBUFFER_TYPE Type,IDirect3DSurface8** ppBackBuffer) PURE; + STDMETHOD(GetRasterStatus)(THIS_ D3DRASTER_STATUS* pRasterStatus) PURE; + STDMETHOD_(void, SetGammaRamp)(THIS_ DWORD Flags,CONST D3DGAMMARAMP* pRamp) PURE; + STDMETHOD_(void, GetGammaRamp)(THIS_ D3DGAMMARAMP* pRamp) PURE; + STDMETHOD(CreateTexture)(THIS_ UINT Width,UINT Height,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DTexture8** ppTexture) PURE; + STDMETHOD(CreateVolumeTexture)(THIS_ UINT Width,UINT Height,UINT Depth,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DVolumeTexture8** ppVolumeTexture) PURE; + STDMETHOD(CreateCubeTexture)(THIS_ UINT EdgeLength,UINT Levels,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DCubeTexture8** ppCubeTexture) PURE; + STDMETHOD(CreateVertexBuffer)(THIS_ UINT Length,DWORD Usage,DWORD FVF,D3DPOOL Pool,IDirect3DVertexBuffer8** ppVertexBuffer) PURE; + STDMETHOD(CreateIndexBuffer)(THIS_ UINT Length,DWORD Usage,D3DFORMAT Format,D3DPOOL Pool,IDirect3DIndexBuffer8** ppIndexBuffer) PURE; + STDMETHOD(CreateRenderTarget)(THIS_ UINT Width,UINT Height,D3DFORMAT Format,D3DMULTISAMPLE_TYPE MultiSample,BOOL Lockable,IDirect3DSurface8** ppSurface) PURE; + STDMETHOD(CreateDepthStencilSurface)(THIS_ UINT Width,UINT Height,D3DFORMAT Format,D3DMULTISAMPLE_TYPE MultiSample,IDirect3DSurface8** ppSurface) PURE; + STDMETHOD(CreateImageSurface)(THIS_ UINT Width,UINT Height,D3DFORMAT Format,IDirect3DSurface8** ppSurface) PURE; + STDMETHOD(CopyRects)(THIS_ IDirect3DSurface8* pSourceSurface,CONST RECT* pSourceRectsArray,UINT cRects,IDirect3DSurface8* pDestinationSurface,CONST POINT* pDestPointsArray) PURE; + STDMETHOD(UpdateTexture)(THIS_ IDirect3DBaseTexture8* pSourceTexture,IDirect3DBaseTexture8* pDestinationTexture) PURE; + STDMETHOD(GetFrontBuffer)(THIS_ IDirect3DSurface8* pDestSurface) PURE; + STDMETHOD(SetRenderTarget)(THIS_ IDirect3DSurface8* pRenderTarget,IDirect3DSurface8* pNewZStencil) PURE; + STDMETHOD(GetRenderTarget)(THIS_ IDirect3DSurface8** ppRenderTarget) PURE; + STDMETHOD(GetDepthStencilSurface)(THIS_ IDirect3DSurface8** ppZStencilSurface) PURE; + STDMETHOD(BeginScene)(THIS) PURE; + STDMETHOD(EndScene)(THIS) PURE; + STDMETHOD(Clear)(THIS_ DWORD Count,CONST D3DRECT* pRects,DWORD Flags,D3DCOLOR Color,float Z,DWORD Stencil) PURE; + STDMETHOD(SetTransform)(THIS_ D3DTRANSFORMSTATETYPE State,CONST D3DMATRIX* pMatrix) PURE; + STDMETHOD(GetTransform)(THIS_ D3DTRANSFORMSTATETYPE State,D3DMATRIX* pMatrix) PURE; + STDMETHOD(MultiplyTransform)(THIS_ D3DTRANSFORMSTATETYPE,CONST D3DMATRIX*) PURE; + STDMETHOD(SetViewport)(THIS_ CONST D3DVIEWPORT8* pViewport) PURE; + STDMETHOD(GetViewport)(THIS_ D3DVIEWPORT8* pViewport) PURE; + STDMETHOD(SetMaterial)(THIS_ CONST D3DMATERIAL8* pMaterial) PURE; + STDMETHOD(GetMaterial)(THIS_ D3DMATERIAL8* pMaterial) PURE; + STDMETHOD(SetLight)(THIS_ DWORD Index,CONST D3DLIGHT8*) PURE; + STDMETHOD(GetLight)(THIS_ DWORD Index,D3DLIGHT8*) PURE; + STDMETHOD(LightEnable)(THIS_ DWORD Index,BOOL Enable) PURE; + STDMETHOD(GetLightEnable)(THIS_ DWORD Index,BOOL* pEnable) PURE; + STDMETHOD(SetClipPlane)(THIS_ DWORD Index,CONST float* pPlane) PURE; + STDMETHOD(GetClipPlane)(THIS_ DWORD Index,float* pPlane) PURE; + STDMETHOD(SetRenderState)(THIS_ D3DRENDERSTATETYPE State,DWORD Value) PURE; + STDMETHOD(GetRenderState)(THIS_ D3DRENDERSTATETYPE State,DWORD* pValue) PURE; + STDMETHOD(BeginStateBlock)(THIS) PURE; + STDMETHOD(EndStateBlock)(THIS_ DWORD* pToken) PURE; + STDMETHOD(ApplyStateBlock)(THIS_ DWORD Token) PURE; + STDMETHOD(CaptureStateBlock)(THIS_ DWORD Token) PURE; + STDMETHOD(DeleteStateBlock)(THIS_ DWORD Token) PURE; + STDMETHOD(CreateStateBlock)(THIS_ D3DSTATEBLOCKTYPE Type,DWORD* pToken) PURE; + STDMETHOD(SetClipStatus)(THIS_ CONST D3DCLIPSTATUS8* pClipStatus) PURE; + STDMETHOD(GetClipStatus)(THIS_ D3DCLIPSTATUS8* pClipStatus) PURE; + STDMETHOD(GetTexture)(THIS_ DWORD Stage,IDirect3DBaseTexture8** ppTexture) PURE; + STDMETHOD(SetTexture)(THIS_ DWORD Stage,IDirect3DBaseTexture8* pTexture) PURE; + STDMETHOD(GetTextureStageState)(THIS_ DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD* pValue) PURE; + STDMETHOD(SetTextureStageState)(THIS_ DWORD Stage,D3DTEXTURESTAGESTATETYPE Type,DWORD Value) PURE; + STDMETHOD(ValidateDevice)(THIS_ DWORD* pNumPasses) PURE; + STDMETHOD(GetInfo)(THIS_ DWORD DevInfoID,void* pDevInfoStruct,DWORD DevInfoStructSize) PURE; + STDMETHOD(SetPaletteEntries)(THIS_ UINT PaletteNumber,CONST PALETTEENTRY* pEntries) PURE; + STDMETHOD(GetPaletteEntries)(THIS_ UINT PaletteNumber,PALETTEENTRY* pEntries) PURE; + STDMETHOD(SetCurrentTexturePalette)(THIS_ UINT PaletteNumber) PURE; + STDMETHOD(GetCurrentTexturePalette)(THIS_ UINT *PaletteNumber) PURE; + STDMETHOD(DrawPrimitive)(THIS_ D3DPRIMITIVETYPE PrimitiveType,UINT StartVertex,UINT PrimitiveCount) PURE; + STDMETHOD(DrawIndexedPrimitive)(THIS_ D3DPRIMITIVETYPE,UINT minIndex,UINT NumVertices,UINT startIndex,UINT primCount) PURE; + STDMETHOD(DrawPrimitiveUP)(THIS_ D3DPRIMITIVETYPE PrimitiveType,UINT PrimitiveCount,CONST void* pVertexStreamZeroData,UINT VertexStreamZeroStride) PURE; + STDMETHOD(DrawIndexedPrimitiveUP)(THIS_ D3DPRIMITIVETYPE PrimitiveType,UINT MinVertexIndex,UINT NumVertexIndices,UINT PrimitiveCount,CONST void* pIndexData,D3DFORMAT IndexDataFormat,CONST void* pVertexStreamZeroData,UINT VertexStreamZeroStride) PURE; + STDMETHOD(ProcessVertices)(THIS_ UINT SrcStartIndex,UINT DestIndex,UINT VertexCount,IDirect3DVertexBuffer8* pDestBuffer,DWORD Flags) PURE; + STDMETHOD(CreateVertexShader)(THIS_ CONST DWORD* pDeclaration,CONST DWORD* pFunction,DWORD* pHandle,DWORD Usage) PURE; + STDMETHOD(SetVertexShader)(THIS_ DWORD Handle) PURE; + STDMETHOD(GetVertexShader)(THIS_ DWORD* pHandle) PURE; + STDMETHOD(DeleteVertexShader)(THIS_ DWORD Handle) PURE; + STDMETHOD(SetVertexShaderConstant)(THIS_ DWORD Register,CONST void* pConstantData,DWORD ConstantCount) PURE; + STDMETHOD(GetVertexShaderConstant)(THIS_ DWORD Register,void* pConstantData,DWORD ConstantCount) PURE; + STDMETHOD(GetVertexShaderDeclaration)(THIS_ DWORD Handle,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(GetVertexShaderFunction)(THIS_ DWORD Handle,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(SetStreamSource)(THIS_ UINT StreamNumber,IDirect3DVertexBuffer8* pStreamData,UINT Stride) PURE; + STDMETHOD(GetStreamSource)(THIS_ UINT StreamNumber,IDirect3DVertexBuffer8** ppStreamData,UINT* pStride) PURE; + STDMETHOD(SetIndices)(THIS_ IDirect3DIndexBuffer8* pIndexData,UINT BaseVertexIndex) PURE; + STDMETHOD(GetIndices)(THIS_ IDirect3DIndexBuffer8** ppIndexData,UINT* pBaseVertexIndex) PURE; + STDMETHOD(CreatePixelShader)(THIS_ CONST DWORD* pFunction,DWORD* pHandle) PURE; + STDMETHOD(SetPixelShader)(THIS_ DWORD Handle) PURE; + STDMETHOD(GetPixelShader)(THIS_ DWORD* pHandle) PURE; + STDMETHOD(DeletePixelShader)(THIS_ DWORD Handle) PURE; + STDMETHOD(SetPixelShaderConstant)(THIS_ DWORD Register,CONST void* pConstantData,DWORD ConstantCount) PURE; + STDMETHOD(GetPixelShaderConstant)(THIS_ DWORD Register,void* pConstantData,DWORD ConstantCount) PURE; + STDMETHOD(GetPixelShaderFunction)(THIS_ DWORD Handle,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(DrawRectPatch)(THIS_ UINT Handle,CONST float* pNumSegs,CONST D3DRECTPATCH_INFO* pRectPatchInfo) PURE; + STDMETHOD(DrawTriPatch)(THIS_ UINT Handle,CONST float* pNumSegs,CONST D3DTRIPATCH_INFO* pTriPatchInfo) PURE; + STDMETHOD(DeletePatch)(THIS_ UINT Handle) PURE; +}; + +typedef struct IDirect3DDevice8 *LPDIRECT3DDEVICE8, *PDIRECT3DDEVICE8; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DDevice8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DDevice8_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DDevice8_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DDevice8_TestCooperativeLevel(p) (p)->lpVtbl->TestCooperativeLevel(p) +#define IDirect3DDevice8_GetAvailableTextureMem(p) (p)->lpVtbl->GetAvailableTextureMem(p) +#define IDirect3DDevice8_ResourceManagerDiscardBytes(p,a) (p)->lpVtbl->ResourceManagerDiscardBytes(p,a) +#define IDirect3DDevice8_GetDirect3D(p,a) (p)->lpVtbl->GetDirect3D(p,a) +#define IDirect3DDevice8_GetDeviceCaps(p,a) (p)->lpVtbl->GetDeviceCaps(p,a) +#define IDirect3DDevice8_GetDisplayMode(p,a) (p)->lpVtbl->GetDisplayMode(p,a) +#define IDirect3DDevice8_GetCreationParameters(p,a) (p)->lpVtbl->GetCreationParameters(p,a) +#define IDirect3DDevice8_SetCursorProperties(p,a,b,c) (p)->lpVtbl->SetCursorProperties(p,a,b,c) +#define IDirect3DDevice8_SetCursorPosition(p,a,b,c) (p)->lpVtbl->SetCursorPosition(p,a,b,c) +#define IDirect3DDevice8_ShowCursor(p,a) (p)->lpVtbl->ShowCursor(p,a) +#define IDirect3DDevice8_CreateAdditionalSwapChain(p,a,b) (p)->lpVtbl->CreateAdditionalSwapChain(p,a,b) +#define IDirect3DDevice8_Reset(p,a) (p)->lpVtbl->Reset(p,a) +#define IDirect3DDevice8_Present(p,a,b,c,d) (p)->lpVtbl->Present(p,a,b,c,d) +#define IDirect3DDevice8_GetBackBuffer(p,a,b,c) (p)->lpVtbl->GetBackBuffer(p,a,b,c) +#define IDirect3DDevice8_GetRasterStatus(p,a) (p)->lpVtbl->GetRasterStatus(p,a) +#define IDirect3DDevice8_SetGammaRamp(p,a,b) (p)->lpVtbl->SetGammaRamp(p,a,b) +#define IDirect3DDevice8_GetGammaRamp(p,a) (p)->lpVtbl->GetGammaRamp(p,a) +#define IDirect3DDevice8_CreateTexture(p,a,b,c,d,e,f,g) (p)->lpVtbl->CreateTexture(p,a,b,c,d,e,f,g) +#define IDirect3DDevice8_CreateVolumeTexture(p,a,b,c,d,e,f,g,h) (p)->lpVtbl->CreateVolumeTexture(p,a,b,c,d,e,f,g,h) +#define IDirect3DDevice8_CreateCubeTexture(p,a,b,c,d,e,f) (p)->lpVtbl->CreateCubeTexture(p,a,b,c,d,e,f) +#define IDirect3DDevice8_CreateVertexBuffer(p,a,b,c,d,e) (p)->lpVtbl->CreateVertexBuffer(p,a,b,c,d,e) +#define IDirect3DDevice8_CreateIndexBuffer(p,a,b,c,d,e) (p)->lpVtbl->CreateIndexBuffer(p,a,b,c,d,e) +#define IDirect3DDevice8_CreateRenderTarget(p,a,b,c,d,e,f) (p)->lpVtbl->CreateRenderTarget(p,a,b,c,d,e,f) +#define IDirect3DDevice8_CreateDepthStencilSurface(p,a,b,c,d,e) (p)->lpVtbl->CreateDepthStencilSurface(p,a,b,c,d,e) +#define IDirect3DDevice8_CreateImageSurface(p,a,b,c,d) (p)->lpVtbl->CreateImageSurface(p,a,b,c,d) +#define IDirect3DDevice8_CopyRects(p,a,b,c,d,e) (p)->lpVtbl->CopyRects(p,a,b,c,d,e) +#define IDirect3DDevice8_UpdateTexture(p,a,b) (p)->lpVtbl->UpdateTexture(p,a,b) +#define IDirect3DDevice8_GetFrontBuffer(p,a) (p)->lpVtbl->GetFrontBuffer(p,a) +#define IDirect3DDevice8_SetRenderTarget(p,a,b) (p)->lpVtbl->SetRenderTarget(p,a,b) +#define IDirect3DDevice8_GetRenderTarget(p,a) (p)->lpVtbl->GetRenderTarget(p,a) +#define IDirect3DDevice8_GetDepthStencilSurface(p,a) (p)->lpVtbl->GetDepthStencilSurface(p,a) +#define IDirect3DDevice8_BeginScene(p) (p)->lpVtbl->BeginScene(p) +#define IDirect3DDevice8_EndScene(p) (p)->lpVtbl->EndScene(p) +#define IDirect3DDevice8_Clear(p,a,b,c,d,e,f) (p)->lpVtbl->Clear(p,a,b,c,d,e,f) +#define IDirect3DDevice8_SetTransform(p,a,b) (p)->lpVtbl->SetTransform(p,a,b) +#define IDirect3DDevice8_GetTransform(p,a,b) (p)->lpVtbl->GetTransform(p,a,b) +#define IDirect3DDevice8_MultiplyTransform(p,a,b) (p)->lpVtbl->MultiplyTransform(p,a,b) +#define IDirect3DDevice8_SetViewport(p,a) (p)->lpVtbl->SetViewport(p,a) +#define IDirect3DDevice8_GetViewport(p,a) (p)->lpVtbl->GetViewport(p,a) +#define IDirect3DDevice8_SetMaterial(p,a) (p)->lpVtbl->SetMaterial(p,a) +#define IDirect3DDevice8_GetMaterial(p,a) (p)->lpVtbl->GetMaterial(p,a) +#define IDirect3DDevice8_SetLight(p,a,b) (p)->lpVtbl->SetLight(p,a,b) +#define IDirect3DDevice8_GetLight(p,a,b) (p)->lpVtbl->GetLight(p,a,b) +#define IDirect3DDevice8_LightEnable(p,a,b) (p)->lpVtbl->LightEnable(p,a,b) +#define IDirect3DDevice8_GetLightEnable(p,a,b) (p)->lpVtbl->GetLightEnable(p,a,b) +#define IDirect3DDevice8_SetClipPlane(p,a,b) (p)->lpVtbl->SetClipPlane(p,a,b) +#define IDirect3DDevice8_GetClipPlane(p,a,b) (p)->lpVtbl->GetClipPlane(p,a,b) +#define IDirect3DDevice8_SetRenderState(p,a,b) (p)->lpVtbl->SetRenderState(p,a,b) +#define IDirect3DDevice8_GetRenderState(p,a,b) (p)->lpVtbl->GetRenderState(p,a,b) +#define IDirect3DDevice8_BeginStateBlock(p) (p)->lpVtbl->BeginStateBlock(p) +#define IDirect3DDevice8_EndStateBlock(p,a) (p)->lpVtbl->EndStateBlock(p,a) +#define IDirect3DDevice8_ApplyStateBlock(p,a) (p)->lpVtbl->ApplyStateBlock(p,a) +#define IDirect3DDevice8_CaptureStateBlock(p,a) (p)->lpVtbl->CaptureStateBlock(p,a) +#define IDirect3DDevice8_DeleteStateBlock(p,a) (p)->lpVtbl->DeleteStateBlock(p,a) +#define IDirect3DDevice8_CreateStateBlock(p,a,b) (p)->lpVtbl->CreateStateBlock(p,a,b) +#define IDirect3DDevice8_SetClipStatus(p,a) (p)->lpVtbl->SetClipStatus(p,a) +#define IDirect3DDevice8_GetClipStatus(p,a) (p)->lpVtbl->GetClipStatus(p,a) +#define IDirect3DDevice8_GetTexture(p,a,b) (p)->lpVtbl->GetTexture(p,a,b) +#define IDirect3DDevice8_SetTexture(p,a,b) (p)->lpVtbl->SetTexture(p,a,b) +#define IDirect3DDevice8_GetTextureStageState(p,a,b,c) (p)->lpVtbl->GetTextureStageState(p,a,b,c) +#define IDirect3DDevice8_SetTextureStageState(p,a,b,c) (p)->lpVtbl->SetTextureStageState(p,a,b,c) +#define IDirect3DDevice8_ValidateDevice(p,a) (p)->lpVtbl->ValidateDevice(p,a) +#define IDirect3DDevice8_GetInfo(p,a,b,c) (p)->lpVtbl->GetInfo(p,a,b,c) +#define IDirect3DDevice8_SetPaletteEntries(p,a,b) (p)->lpVtbl->SetPaletteEntries(p,a,b) +#define IDirect3DDevice8_GetPaletteEntries(p,a,b) (p)->lpVtbl->GetPaletteEntries(p,a,b) +#define IDirect3DDevice8_SetCurrentTexturePalette(p,a) (p)->lpVtbl->SetCurrentTexturePalette(p,a) +#define IDirect3DDevice8_GetCurrentTexturePalette(p,a) (p)->lpVtbl->GetCurrentTexturePalette(p,a) +#define IDirect3DDevice8_DrawPrimitive(p,a,b,c) (p)->lpVtbl->DrawPrimitive(p,a,b,c) +#define IDirect3DDevice8_DrawIndexedPrimitive(p,a,b,c,d,e) (p)->lpVtbl->DrawIndexedPrimitive(p,a,b,c,d,e) +#define IDirect3DDevice8_DrawPrimitiveUP(p,a,b,c,d) (p)->lpVtbl->DrawPrimitiveUP(p,a,b,c,d) +#define IDirect3DDevice8_DrawIndexedPrimitiveUP(p,a,b,c,d,e,f,g,h) (p)->lpVtbl->DrawIndexedPrimitiveUP(p,a,b,c,d,e,f,g,h) +#define IDirect3DDevice8_ProcessVertices(p,a,b,c,d,e) (p)->lpVtbl->ProcessVertices(p,a,b,c,d,e) +#define IDirect3DDevice8_CreateVertexShader(p,a,b,c,d) (p)->lpVtbl->CreateVertexShader(p,a,b,c,d) +#define IDirect3DDevice8_SetVertexShader(p,a) (p)->lpVtbl->SetVertexShader(p,a) +#define IDirect3DDevice8_GetVertexShader(p,a) (p)->lpVtbl->GetVertexShader(p,a) +#define IDirect3DDevice8_DeleteVertexShader(p,a) (p)->lpVtbl->DeleteVertexShader(p,a) +#define IDirect3DDevice8_SetVertexShaderConstant(p,a,b,c) (p)->lpVtbl->SetVertexShaderConstant(p,a,b,c) +#define IDirect3DDevice8_GetVertexShaderConstant(p,a,b,c) (p)->lpVtbl->GetVertexShaderConstant(p,a,b,c) +#define IDirect3DDevice8_GetVertexShaderDeclaration(p,a,b,c) (p)->lpVtbl->GetVertexShaderDeclaration(p,a,b,c) +#define IDirect3DDevice8_GetVertexShaderFunction(p,a,b,c) (p)->lpVtbl->GetVertexShaderFunction(p,a,b,c) +#define IDirect3DDevice8_SetStreamSource(p,a,b,c) (p)->lpVtbl->SetStreamSource(p,a,b,c) +#define IDirect3DDevice8_GetStreamSource(p,a,b,c) (p)->lpVtbl->GetStreamSource(p,a,b,c) +#define IDirect3DDevice8_SetIndices(p,a,b) (p)->lpVtbl->SetIndices(p,a,b) +#define IDirect3DDevice8_GetIndices(p,a,b) (p)->lpVtbl->GetIndices(p,a,b) +#define IDirect3DDevice8_CreatePixelShader(p,a,b) (p)->lpVtbl->CreatePixelShader(p,a,b) +#define IDirect3DDevice8_SetPixelShader(p,a) (p)->lpVtbl->SetPixelShader(p,a) +#define IDirect3DDevice8_GetPixelShader(p,a) (p)->lpVtbl->GetPixelShader(p,a) +#define IDirect3DDevice8_DeletePixelShader(p,a) (p)->lpVtbl->DeletePixelShader(p,a) +#define IDirect3DDevice8_SetPixelShaderConstant(p,a,b,c) (p)->lpVtbl->SetPixelShaderConstant(p,a,b,c) +#define IDirect3DDevice8_GetPixelShaderConstant(p,a,b,c) (p)->lpVtbl->GetPixelShaderConstant(p,a,b,c) +#define IDirect3DDevice8_GetPixelShaderFunction(p,a,b,c) (p)->lpVtbl->GetPixelShaderFunction(p,a,b,c) +#define IDirect3DDevice8_DrawRectPatch(p,a,b,c) (p)->lpVtbl->DrawRectPatch(p,a,b,c) +#define IDirect3DDevice8_DrawTriPatch(p,a,b,c) (p)->lpVtbl->DrawTriPatch(p,a,b,c) +#define IDirect3DDevice8_DeletePatch(p,a) (p)->lpVtbl->DeletePatch(p,a) +#else +#define IDirect3DDevice8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DDevice8_AddRef(p) (p)->AddRef() +#define IDirect3DDevice8_Release(p) (p)->Release() +#define IDirect3DDevice8_TestCooperativeLevel(p) (p)->TestCooperativeLevel() +#define IDirect3DDevice8_GetAvailableTextureMem(p) (p)->GetAvailableTextureMem() +#define IDirect3DDevice8_ResourceManagerDiscardBytes(p,a) (p)->ResourceManagerDiscardBytes(a) +#define IDirect3DDevice8_GetDirect3D(p,a) (p)->GetDirect3D(a) +#define IDirect3DDevice8_GetDeviceCaps(p,a) (p)->GetDeviceCaps(a) +#define IDirect3DDevice8_GetDisplayMode(p,a) (p)->GetDisplayMode(a) +#define IDirect3DDevice8_GetCreationParameters(p,a) (p)->GetCreationParameters(a) +#define IDirect3DDevice8_SetCursorProperties(p,a,b,c) (p)->SetCursorProperties(a,b,c) +#define IDirect3DDevice8_SetCursorPosition(p,a,b,c) (p)->SetCursorPosition(a,b,c) +#define IDirect3DDevice8_ShowCursor(p,a) (p)->ShowCursor(a) +#define IDirect3DDevice8_CreateAdditionalSwapChain(p,a,b) (p)->CreateAdditionalSwapChain(a,b) +#define IDirect3DDevice8_Reset(p,a) (p)->Reset(a) +#define IDirect3DDevice8_Present(p,a,b,c,d) (p)->Present(a,b,c,d) +#define IDirect3DDevice8_GetBackBuffer(p,a,b,c) (p)->GetBackBuffer(a,b,c) +#define IDirect3DDevice8_GetRasterStatus(p,a) (p)->GetRasterStatus(a) +#define IDirect3DDevice8_SetGammaRamp(p,a,b) (p)->SetGammaRamp(a,b) +#define IDirect3DDevice8_GetGammaRamp(p,a) (p)->GetGammaRamp(a) +#define IDirect3DDevice8_CreateTexture(p,a,b,c,d,e,f,g) (p)->CreateTexture(a,b,c,d,e,f,g) +#define IDirect3DDevice8_CreateVolumeTexture(p,a,b,c,d,e,f,g,h) (p)->CreateVolumeTexture(a,b,c,d,e,f,g,h) +#define IDirect3DDevice8_CreateCubeTexture(p,a,b,c,d,e,f) (p)->CreateCubeTexture(a,b,c,d,e,f) +#define IDirect3DDevice8_CreateVertexBuffer(p,a,b,c,d,e) (p)->CreateVertexBuffer(a,b,c,d,e) +#define IDirect3DDevice8_CreateIndexBuffer(p,a,b,c,d,e) (p)->CreateIndexBuffer(a,b,c,d,e) +#define IDirect3DDevice8_CreateRenderTarget(p,a,b,c,d,e,f) (p)->CreateRenderTarget(a,b,c,d,e,f) +#define IDirect3DDevice8_CreateDepthStencilSurface(p,a,b,c,d,e) (p)->CreateDepthStencilSurface(a,b,c,d,e) +#define IDirect3DDevice8_CreateImageSurface(p,a,b,c,d) (p)->CreateImageSurface(a,b,c,d) +#define IDirect3DDevice8_CopyRects(p,a,b,c,d,e) (p)->CopyRects(a,b,c,d,e) +#define IDirect3DDevice8_UpdateTexture(p,a,b) (p)->UpdateTexture(a,b) +#define IDirect3DDevice8_GetFrontBuffer(p,a) (p)->GetFrontBuffer(a) +#define IDirect3DDevice8_SetRenderTarget(p,a,b) (p)->SetRenderTarget(a,b) +#define IDirect3DDevice8_GetRenderTarget(p,a) (p)->GetRenderTarget(a) +#define IDirect3DDevice8_GetDepthStencilSurface(p,a) (p)->GetDepthStencilSurface(a) +#define IDirect3DDevice8_BeginScene(p) (p)->BeginScene() +#define IDirect3DDevice8_EndScene(p) (p)->EndScene() +#define IDirect3DDevice8_Clear(p,a,b,c,d,e,f) (p)->Clear(a,b,c,d,e,f) +#define IDirect3DDevice8_SetTransform(p,a,b) (p)->SetTransform(a,b) +#define IDirect3DDevice8_GetTransform(p,a,b) (p)->GetTransform(a,b) +#define IDirect3DDevice8_MultiplyTransform(p,a,b) (p)->MultiplyTransform(a,b) +#define IDirect3DDevice8_SetViewport(p,a) (p)->SetViewport(a) +#define IDirect3DDevice8_GetViewport(p,a) (p)->GetViewport(a) +#define IDirect3DDevice8_SetMaterial(p,a) (p)->SetMaterial(a) +#define IDirect3DDevice8_GetMaterial(p,a) (p)->GetMaterial(a) +#define IDirect3DDevice8_SetLight(p,a,b) (p)->SetLight(a,b) +#define IDirect3DDevice8_GetLight(p,a,b) (p)->GetLight(a,b) +#define IDirect3DDevice8_LightEnable(p,a,b) (p)->LightEnable(a,b) +#define IDirect3DDevice8_GetLightEnable(p,a,b) (p)->GetLightEnable(a,b) +#define IDirect3DDevice8_SetClipPlane(p,a,b) (p)->SetClipPlane(a,b) +#define IDirect3DDevice8_GetClipPlane(p,a,b) (p)->GetClipPlane(a,b) +#define IDirect3DDevice8_SetRenderState(p,a,b) (p)->SetRenderState(a,b) +#define IDirect3DDevice8_GetRenderState(p,a,b) (p)->GetRenderState(a,b) +#define IDirect3DDevice8_BeginStateBlock(p) (p)->BeginStateBlock() +#define IDirect3DDevice8_EndStateBlock(p,a) (p)->EndStateBlock(a) +#define IDirect3DDevice8_ApplyStateBlock(p,a) (p)->ApplyStateBlock(a) +#define IDirect3DDevice8_CaptureStateBlock(p,a) (p)->CaptureStateBlock(a) +#define IDirect3DDevice8_DeleteStateBlock(p,a) (p)->DeleteStateBlock(a) +#define IDirect3DDevice8_CreateStateBlock(p,a,b) (p)->CreateStateBlock(a,b) +#define IDirect3DDevice8_SetClipStatus(p,a) (p)->SetClipStatus(a) +#define IDirect3DDevice8_GetClipStatus(p,a) (p)->GetClipStatus(a) +#define IDirect3DDevice8_GetTexture(p,a,b) (p)->GetTexture(a,b) +#define IDirect3DDevice8_SetTexture(p,a,b) (p)->SetTexture(a,b) +#define IDirect3DDevice8_GetTextureStageState(p,a,b,c) (p)->GetTextureStageState(a,b,c) +#define IDirect3DDevice8_SetTextureStageState(p,a,b,c) (p)->SetTextureStageState(a,b,c) +#define IDirect3DDevice8_ValidateDevice(p,a) (p)->ValidateDevice(a) +#define IDirect3DDevice8_GetInfo(p,a,b,c) (p)->GetInfo(a,b,c) +#define IDirect3DDevice8_SetPaletteEntries(p,a,b) (p)->SetPaletteEntries(a,b) +#define IDirect3DDevice8_GetPaletteEntries(p,a,b) (p)->GetPaletteEntries(a,b) +#define IDirect3DDevice8_SetCurrentTexturePalette(p,a) (p)->SetCurrentTexturePalette(a) +#define IDirect3DDevice8_GetCurrentTexturePalette(p,a) (p)->GetCurrentTexturePalette(a) +#define IDirect3DDevice8_DrawPrimitive(p,a,b,c) (p)->DrawPrimitive(a,b,c) +#define IDirect3DDevice8_DrawIndexedPrimitive(p,a,b,c,d,e) (p)->DrawIndexedPrimitive(a,b,c,d,e) +#define IDirect3DDevice8_DrawPrimitiveUP(p,a,b,c,d) (p)->DrawPrimitiveUP(a,b,c,d) +#define IDirect3DDevice8_DrawIndexedPrimitiveUP(p,a,b,c,d,e,f,g,h) (p)->DrawIndexedPrimitiveUP(a,b,c,d,e,f,g,h) +#define IDirect3DDevice8_ProcessVertices(p,a,b,c,d,e) (p)->ProcessVertices(a,b,c,d,e) +#define IDirect3DDevice8_CreateVertexShader(p,a,b,c,d) (p)->CreateVertexShader(a,b,c,d) +#define IDirect3DDevice8_SetVertexShader(p,a) (p)->SetVertexShader(a) +#define IDirect3DDevice8_GetVertexShader(p,a) (p)->GetVertexShader(a) +#define IDirect3DDevice8_DeleteVertexShader(p,a) (p)->DeleteVertexShader(a) +#define IDirect3DDevice8_SetVertexShaderConstant(p,a,b,c) (p)->SetVertexShaderConstant(a,b,c) +#define IDirect3DDevice8_GetVertexShaderConstant(p,a,b,c) (p)->GetVertexShaderConstant(a,b,c) +#define IDirect3DDevice8_GetVertexShaderDeclaration(p,a,b,c) (p)->GetVertexShaderDeclaration(a,b,c) +#define IDirect3DDevice8_GetVertexShaderFunction(p,a,b,c) (p)->GetVertexShaderFunction(a,b,c) +#define IDirect3DDevice8_SetStreamSource(p,a,b,c) (p)->SetStreamSource(a,b,c) +#define IDirect3DDevice8_GetStreamSource(p,a,b,c) (p)->GetStreamSource(a,b,c) +#define IDirect3DDevice8_SetIndices(p,a,b) (p)->SetIndices(a,b) +#define IDirect3DDevice8_GetIndices(p,a,b) (p)->GetIndices(a,b) +#define IDirect3DDevice8_CreatePixelShader(p,a,b) (p)->CreatePixelShader(a,b) +#define IDirect3DDevice8_SetPixelShader(p,a) (p)->SetPixelShader(a) +#define IDirect3DDevice8_GetPixelShader(p,a) (p)->GetPixelShader(a) +#define IDirect3DDevice8_DeletePixelShader(p,a) (p)->DeletePixelShader(a) +#define IDirect3DDevice8_SetPixelShaderConstant(p,a,b,c) (p)->SetPixelShaderConstant(a,b,c) +#define IDirect3DDevice8_GetPixelShaderConstant(p,a,b,c) (p)->GetPixelShaderConstant(a,b,c) +#define IDirect3DDevice8_GetPixelShaderFunction(p,a,b,c) (p)->GetPixelShaderFunction(a,b,c) +#define IDirect3DDevice8_DrawRectPatch(p,a,b,c) (p)->DrawRectPatch(a,b,c) +#define IDirect3DDevice8_DrawTriPatch(p,a,b,c) (p)->DrawTriPatch(a,b,c) +#define IDirect3DDevice8_DeletePatch(p,a) (p)->DeletePatch(a) +#endif + + + +#undef INTERFACE +#define INTERFACE IDirect3DSwapChain8 + +DECLARE_INTERFACE_(IDirect3DSwapChain8, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DSwapChain8 methods ***/ + STDMETHOD(Present)(THIS_ CONST RECT* pSourceRect,CONST RECT* pDestRect,HWND hDestWindowOverride,CONST RGNDATA* pDirtyRegion) PURE; + STDMETHOD(GetBackBuffer)(THIS_ UINT BackBuffer,D3DBACKBUFFER_TYPE Type,IDirect3DSurface8** ppBackBuffer) PURE; +}; + +typedef struct IDirect3DSwapChain8 *LPDIRECT3DSWAPCHAIN8, *PDIRECT3DSWAPCHAIN8; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DSwapChain8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DSwapChain8_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DSwapChain8_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DSwapChain8_Present(p,a,b,c,d) (p)->lpVtbl->Present(p,a,b,c,d) +#define IDirect3DSwapChain8_GetBackBuffer(p,a,b,c) (p)->lpVtbl->GetBackBuffer(p,a,b,c) +#else +#define IDirect3DSwapChain8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DSwapChain8_AddRef(p) (p)->AddRef() +#define IDirect3DSwapChain8_Release(p) (p)->Release() +#define IDirect3DSwapChain8_Present(p,a,b,c,d) (p)->Present(a,b,c,d) +#define IDirect3DSwapChain8_GetBackBuffer(p,a,b,c) (p)->GetBackBuffer(a,b,c) +#endif + + + +#undef INTERFACE +#define INTERFACE IDirect3DResource8 + +DECLARE_INTERFACE_(IDirect3DResource8, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DResource8 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; + STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; + STDMETHOD_(DWORD, GetPriority)(THIS) PURE; + STDMETHOD_(void, PreLoad)(THIS) PURE; + STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; +}; + +typedef struct IDirect3DResource8 *LPDIRECT3DRESOURCE8, *PDIRECT3DRESOURCE8; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DResource8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DResource8_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DResource8_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DResource8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DResource8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirect3DResource8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirect3DResource8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirect3DResource8_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) +#define IDirect3DResource8_GetPriority(p) (p)->lpVtbl->GetPriority(p) +#define IDirect3DResource8_PreLoad(p) (p)->lpVtbl->PreLoad(p) +#define IDirect3DResource8_GetType(p) (p)->lpVtbl->GetType(p) +#else +#define IDirect3DResource8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DResource8_AddRef(p) (p)->AddRef() +#define IDirect3DResource8_Release(p) (p)->Release() +#define IDirect3DResource8_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DResource8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirect3DResource8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirect3DResource8_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirect3DResource8_SetPriority(p,a) (p)->SetPriority(a) +#define IDirect3DResource8_GetPriority(p) (p)->GetPriority() +#define IDirect3DResource8_PreLoad(p) (p)->PreLoad() +#define IDirect3DResource8_GetType(p) (p)->GetType() +#endif + + + + +#undef INTERFACE +#define INTERFACE IDirect3DBaseTexture8 + +DECLARE_INTERFACE_(IDirect3DBaseTexture8, IDirect3DResource8) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DResource8 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; + STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; + STDMETHOD_(DWORD, GetPriority)(THIS) PURE; + STDMETHOD_(void, PreLoad)(THIS) PURE; + STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; + STDMETHOD_(DWORD, SetLOD)(THIS_ DWORD LODNew) PURE; + STDMETHOD_(DWORD, GetLOD)(THIS) PURE; + STDMETHOD_(DWORD, GetLevelCount)(THIS) PURE; +}; + +typedef struct IDirect3DBaseTexture8 *LPDIRECT3DBASETEXTURE8, *PDIRECT3DBASETEXTURE8; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DBaseTexture8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DBaseTexture8_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DBaseTexture8_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DBaseTexture8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DBaseTexture8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirect3DBaseTexture8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirect3DBaseTexture8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirect3DBaseTexture8_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) +#define IDirect3DBaseTexture8_GetPriority(p) (p)->lpVtbl->GetPriority(p) +#define IDirect3DBaseTexture8_PreLoad(p) (p)->lpVtbl->PreLoad(p) +#define IDirect3DBaseTexture8_GetType(p) (p)->lpVtbl->GetType(p) +#define IDirect3DBaseTexture8_SetLOD(p,a) (p)->lpVtbl->SetLOD(p,a) +#define IDirect3DBaseTexture8_GetLOD(p) (p)->lpVtbl->GetLOD(p) +#define IDirect3DBaseTexture8_GetLevelCount(p) (p)->lpVtbl->GetLevelCount(p) +#else +#define IDirect3DBaseTexture8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DBaseTexture8_AddRef(p) (p)->AddRef() +#define IDirect3DBaseTexture8_Release(p) (p)->Release() +#define IDirect3DBaseTexture8_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DBaseTexture8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirect3DBaseTexture8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirect3DBaseTexture8_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirect3DBaseTexture8_SetPriority(p,a) (p)->SetPriority(a) +#define IDirect3DBaseTexture8_GetPriority(p) (p)->GetPriority() +#define IDirect3DBaseTexture8_PreLoad(p) (p)->PreLoad() +#define IDirect3DBaseTexture8_GetType(p) (p)->GetType() +#define IDirect3DBaseTexture8_SetLOD(p,a) (p)->SetLOD(a) +#define IDirect3DBaseTexture8_GetLOD(p) (p)->GetLOD() +#define IDirect3DBaseTexture8_GetLevelCount(p) (p)->GetLevelCount() +#endif + + + + + +#undef INTERFACE +#define INTERFACE IDirect3DTexture8 + +DECLARE_INTERFACE_(IDirect3DTexture8, IDirect3DBaseTexture8) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DBaseTexture8 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; + STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; + STDMETHOD_(DWORD, GetPriority)(THIS) PURE; + STDMETHOD_(void, PreLoad)(THIS) PURE; + STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; + STDMETHOD_(DWORD, SetLOD)(THIS_ DWORD LODNew) PURE; + STDMETHOD_(DWORD, GetLOD)(THIS) PURE; + STDMETHOD_(DWORD, GetLevelCount)(THIS) PURE; + STDMETHOD(GetLevelDesc)(THIS_ UINT Level,D3DSURFACE_DESC *pDesc) PURE; + STDMETHOD(GetSurfaceLevel)(THIS_ UINT Level,IDirect3DSurface8** ppSurfaceLevel) PURE; + STDMETHOD(LockRect)(THIS_ UINT Level,D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags) PURE; + STDMETHOD(UnlockRect)(THIS_ UINT Level) PURE; + STDMETHOD(AddDirtyRect)(THIS_ CONST RECT* pDirtyRect) PURE; +}; + +typedef struct IDirect3DTexture8 *LPDIRECT3DTEXTURE8, *PDIRECT3DTEXTURE8; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DTexture8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DTexture8_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DTexture8_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DTexture8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DTexture8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirect3DTexture8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirect3DTexture8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirect3DTexture8_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) +#define IDirect3DTexture8_GetPriority(p) (p)->lpVtbl->GetPriority(p) +#define IDirect3DTexture8_PreLoad(p) (p)->lpVtbl->PreLoad(p) +#define IDirect3DTexture8_GetType(p) (p)->lpVtbl->GetType(p) +#define IDirect3DTexture8_SetLOD(p,a) (p)->lpVtbl->SetLOD(p,a) +#define IDirect3DTexture8_GetLOD(p) (p)->lpVtbl->GetLOD(p) +#define IDirect3DTexture8_GetLevelCount(p) (p)->lpVtbl->GetLevelCount(p) +#define IDirect3DTexture8_GetLevelDesc(p,a,b) (p)->lpVtbl->GetLevelDesc(p,a,b) +#define IDirect3DTexture8_GetSurfaceLevel(p,a,b) (p)->lpVtbl->GetSurfaceLevel(p,a,b) +#define IDirect3DTexture8_LockRect(p,a,b,c,d) (p)->lpVtbl->LockRect(p,a,b,c,d) +#define IDirect3DTexture8_UnlockRect(p,a) (p)->lpVtbl->UnlockRect(p,a) +#define IDirect3DTexture8_AddDirtyRect(p,a) (p)->lpVtbl->AddDirtyRect(p,a) +#else +#define IDirect3DTexture8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DTexture8_AddRef(p) (p)->AddRef() +#define IDirect3DTexture8_Release(p) (p)->Release() +#define IDirect3DTexture8_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DTexture8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirect3DTexture8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirect3DTexture8_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirect3DTexture8_SetPriority(p,a) (p)->SetPriority(a) +#define IDirect3DTexture8_GetPriority(p) (p)->GetPriority() +#define IDirect3DTexture8_PreLoad(p) (p)->PreLoad() +#define IDirect3DTexture8_GetType(p) (p)->GetType() +#define IDirect3DTexture8_SetLOD(p,a) (p)->SetLOD(a) +#define IDirect3DTexture8_GetLOD(p) (p)->GetLOD() +#define IDirect3DTexture8_GetLevelCount(p) (p)->GetLevelCount() +#define IDirect3DTexture8_GetLevelDesc(p,a,b) (p)->GetLevelDesc(a,b) +#define IDirect3DTexture8_GetSurfaceLevel(p,a,b) (p)->GetSurfaceLevel(a,b) +#define IDirect3DTexture8_LockRect(p,a,b,c,d) (p)->LockRect(a,b,c,d) +#define IDirect3DTexture8_UnlockRect(p,a) (p)->UnlockRect(a) +#define IDirect3DTexture8_AddDirtyRect(p,a) (p)->AddDirtyRect(a) +#endif + + + + + +#undef INTERFACE +#define INTERFACE IDirect3DVolumeTexture8 + +DECLARE_INTERFACE_(IDirect3DVolumeTexture8, IDirect3DBaseTexture8) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DBaseTexture8 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; + STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; + STDMETHOD_(DWORD, GetPriority)(THIS) PURE; + STDMETHOD_(void, PreLoad)(THIS) PURE; + STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; + STDMETHOD_(DWORD, SetLOD)(THIS_ DWORD LODNew) PURE; + STDMETHOD_(DWORD, GetLOD)(THIS) PURE; + STDMETHOD_(DWORD, GetLevelCount)(THIS) PURE; + STDMETHOD(GetLevelDesc)(THIS_ UINT Level,D3DVOLUME_DESC *pDesc) PURE; + STDMETHOD(GetVolumeLevel)(THIS_ UINT Level,IDirect3DVolume8** ppVolumeLevel) PURE; + STDMETHOD(LockBox)(THIS_ UINT Level,D3DLOCKED_BOX* pLockedVolume,CONST D3DBOX* pBox,DWORD Flags) PURE; + STDMETHOD(UnlockBox)(THIS_ UINT Level) PURE; + STDMETHOD(AddDirtyBox)(THIS_ CONST D3DBOX* pDirtyBox) PURE; +}; + +typedef struct IDirect3DVolumeTexture8 *LPDIRECT3DVOLUMETEXTURE8, *PDIRECT3DVOLUMETEXTURE8; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DVolumeTexture8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DVolumeTexture8_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DVolumeTexture8_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DVolumeTexture8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DVolumeTexture8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirect3DVolumeTexture8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirect3DVolumeTexture8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirect3DVolumeTexture8_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) +#define IDirect3DVolumeTexture8_GetPriority(p) (p)->lpVtbl->GetPriority(p) +#define IDirect3DVolumeTexture8_PreLoad(p) (p)->lpVtbl->PreLoad(p) +#define IDirect3DVolumeTexture8_GetType(p) (p)->lpVtbl->GetType(p) +#define IDirect3DVolumeTexture8_SetLOD(p,a) (p)->lpVtbl->SetLOD(p,a) +#define IDirect3DVolumeTexture8_GetLOD(p) (p)->lpVtbl->GetLOD(p) +#define IDirect3DVolumeTexture8_GetLevelCount(p) (p)->lpVtbl->GetLevelCount(p) +#define IDirect3DVolumeTexture8_GetLevelDesc(p,a,b) (p)->lpVtbl->GetLevelDesc(p,a,b) +#define IDirect3DVolumeTexture8_GetVolumeLevel(p,a,b) (p)->lpVtbl->GetVolumeLevel(p,a,b) +#define IDirect3DVolumeTexture8_LockBox(p,a,b,c,d) (p)->lpVtbl->LockBox(p,a,b,c,d) +#define IDirect3DVolumeTexture8_UnlockBox(p,a) (p)->lpVtbl->UnlockBox(p,a) +#define IDirect3DVolumeTexture8_AddDirtyBox(p,a) (p)->lpVtbl->AddDirtyBox(p,a) +#else +#define IDirect3DVolumeTexture8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DVolumeTexture8_AddRef(p) (p)->AddRef() +#define IDirect3DVolumeTexture8_Release(p) (p)->Release() +#define IDirect3DVolumeTexture8_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DVolumeTexture8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirect3DVolumeTexture8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirect3DVolumeTexture8_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirect3DVolumeTexture8_SetPriority(p,a) (p)->SetPriority(a) +#define IDirect3DVolumeTexture8_GetPriority(p) (p)->GetPriority() +#define IDirect3DVolumeTexture8_PreLoad(p) (p)->PreLoad() +#define IDirect3DVolumeTexture8_GetType(p) (p)->GetType() +#define IDirect3DVolumeTexture8_SetLOD(p,a) (p)->SetLOD(a) +#define IDirect3DVolumeTexture8_GetLOD(p) (p)->GetLOD() +#define IDirect3DVolumeTexture8_GetLevelCount(p) (p)->GetLevelCount() +#define IDirect3DVolumeTexture8_GetLevelDesc(p,a,b) (p)->GetLevelDesc(a,b) +#define IDirect3DVolumeTexture8_GetVolumeLevel(p,a,b) (p)->GetVolumeLevel(a,b) +#define IDirect3DVolumeTexture8_LockBox(p,a,b,c,d) (p)->LockBox(a,b,c,d) +#define IDirect3DVolumeTexture8_UnlockBox(p,a) (p)->UnlockBox(a) +#define IDirect3DVolumeTexture8_AddDirtyBox(p,a) (p)->AddDirtyBox(a) +#endif + + + + + +#undef INTERFACE +#define INTERFACE IDirect3DCubeTexture8 + +DECLARE_INTERFACE_(IDirect3DCubeTexture8, IDirect3DBaseTexture8) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DBaseTexture8 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; + STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; + STDMETHOD_(DWORD, GetPriority)(THIS) PURE; + STDMETHOD_(void, PreLoad)(THIS) PURE; + STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; + STDMETHOD_(DWORD, SetLOD)(THIS_ DWORD LODNew) PURE; + STDMETHOD_(DWORD, GetLOD)(THIS) PURE; + STDMETHOD_(DWORD, GetLevelCount)(THIS) PURE; + STDMETHOD(GetLevelDesc)(THIS_ UINT Level,D3DSURFACE_DESC *pDesc) PURE; + STDMETHOD(GetCubeMapSurface)(THIS_ D3DCUBEMAP_FACES FaceType,UINT Level,IDirect3DSurface8** ppCubeMapSurface) PURE; + STDMETHOD(LockRect)(THIS_ D3DCUBEMAP_FACES FaceType,UINT Level,D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags) PURE; + STDMETHOD(UnlockRect)(THIS_ D3DCUBEMAP_FACES FaceType,UINT Level) PURE; + STDMETHOD(AddDirtyRect)(THIS_ D3DCUBEMAP_FACES FaceType,CONST RECT* pDirtyRect) PURE; +}; + +typedef struct IDirect3DCubeTexture8 *LPDIRECT3DCUBETEXTURE8, *PDIRECT3DCUBETEXTURE8; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DCubeTexture8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DCubeTexture8_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DCubeTexture8_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DCubeTexture8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DCubeTexture8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirect3DCubeTexture8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirect3DCubeTexture8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirect3DCubeTexture8_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) +#define IDirect3DCubeTexture8_GetPriority(p) (p)->lpVtbl->GetPriority(p) +#define IDirect3DCubeTexture8_PreLoad(p) (p)->lpVtbl->PreLoad(p) +#define IDirect3DCubeTexture8_GetType(p) (p)->lpVtbl->GetType(p) +#define IDirect3DCubeTexture8_SetLOD(p,a) (p)->lpVtbl->SetLOD(p,a) +#define IDirect3DCubeTexture8_GetLOD(p) (p)->lpVtbl->GetLOD(p) +#define IDirect3DCubeTexture8_GetLevelCount(p) (p)->lpVtbl->GetLevelCount(p) +#define IDirect3DCubeTexture8_GetLevelDesc(p,a,b) (p)->lpVtbl->GetLevelDesc(p,a,b) +#define IDirect3DCubeTexture8_GetCubeMapSurface(p,a,b,c) (p)->lpVtbl->GetCubeMapSurface(p,a,b,c) +#define IDirect3DCubeTexture8_LockRect(p,a,b,c,d,e) (p)->lpVtbl->LockRect(p,a,b,c,d,e) +#define IDirect3DCubeTexture8_UnlockRect(p,a,b) (p)->lpVtbl->UnlockRect(p,a,b) +#define IDirect3DCubeTexture8_AddDirtyRect(p,a,b) (p)->lpVtbl->AddDirtyRect(p,a,b) +#else +#define IDirect3DCubeTexture8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DCubeTexture8_AddRef(p) (p)->AddRef() +#define IDirect3DCubeTexture8_Release(p) (p)->Release() +#define IDirect3DCubeTexture8_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DCubeTexture8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirect3DCubeTexture8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirect3DCubeTexture8_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirect3DCubeTexture8_SetPriority(p,a) (p)->SetPriority(a) +#define IDirect3DCubeTexture8_GetPriority(p) (p)->GetPriority() +#define IDirect3DCubeTexture8_PreLoad(p) (p)->PreLoad() +#define IDirect3DCubeTexture8_GetType(p) (p)->GetType() +#define IDirect3DCubeTexture8_SetLOD(p,a) (p)->SetLOD(a) +#define IDirect3DCubeTexture8_GetLOD(p) (p)->GetLOD() +#define IDirect3DCubeTexture8_GetLevelCount(p) (p)->GetLevelCount() +#define IDirect3DCubeTexture8_GetLevelDesc(p,a,b) (p)->GetLevelDesc(a,b) +#define IDirect3DCubeTexture8_GetCubeMapSurface(p,a,b,c) (p)->GetCubeMapSurface(a,b,c) +#define IDirect3DCubeTexture8_LockRect(p,a,b,c,d,e) (p)->LockRect(a,b,c,d,e) +#define IDirect3DCubeTexture8_UnlockRect(p,a,b) (p)->UnlockRect(a,b) +#define IDirect3DCubeTexture8_AddDirtyRect(p,a,b) (p)->AddDirtyRect(a,b) +#endif + + + + +#undef INTERFACE +#define INTERFACE IDirect3DVertexBuffer8 + +DECLARE_INTERFACE_(IDirect3DVertexBuffer8, IDirect3DResource8) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DResource8 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; + STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; + STDMETHOD_(DWORD, GetPriority)(THIS) PURE; + STDMETHOD_(void, PreLoad)(THIS) PURE; + STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; + STDMETHOD(Lock)(THIS_ UINT OffsetToLock,UINT SizeToLock,BYTE** ppbData,DWORD Flags) PURE; + STDMETHOD(Unlock)(THIS) PURE; + STDMETHOD(GetDesc)(THIS_ D3DVERTEXBUFFER_DESC *pDesc) PURE; +}; + +typedef struct IDirect3DVertexBuffer8 *LPDIRECT3DVERTEXBUFFER8, *PDIRECT3DVERTEXBUFFER8; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DVertexBuffer8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DVertexBuffer8_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DVertexBuffer8_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DVertexBuffer8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DVertexBuffer8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirect3DVertexBuffer8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirect3DVertexBuffer8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirect3DVertexBuffer8_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) +#define IDirect3DVertexBuffer8_GetPriority(p) (p)->lpVtbl->GetPriority(p) +#define IDirect3DVertexBuffer8_PreLoad(p) (p)->lpVtbl->PreLoad(p) +#define IDirect3DVertexBuffer8_GetType(p) (p)->lpVtbl->GetType(p) +#define IDirect3DVertexBuffer8_Lock(p,a,b,c,d) (p)->lpVtbl->Lock(p,a,b,c,d) +#define IDirect3DVertexBuffer8_Unlock(p) (p)->lpVtbl->Unlock(p) +#define IDirect3DVertexBuffer8_GetDesc(p,a) (p)->lpVtbl->GetDesc(p,a) +#else +#define IDirect3DVertexBuffer8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DVertexBuffer8_AddRef(p) (p)->AddRef() +#define IDirect3DVertexBuffer8_Release(p) (p)->Release() +#define IDirect3DVertexBuffer8_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DVertexBuffer8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirect3DVertexBuffer8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirect3DVertexBuffer8_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirect3DVertexBuffer8_SetPriority(p,a) (p)->SetPriority(a) +#define IDirect3DVertexBuffer8_GetPriority(p) (p)->GetPriority() +#define IDirect3DVertexBuffer8_PreLoad(p) (p)->PreLoad() +#define IDirect3DVertexBuffer8_GetType(p) (p)->GetType() +#define IDirect3DVertexBuffer8_Lock(p,a,b,c,d) (p)->Lock(a,b,c,d) +#define IDirect3DVertexBuffer8_Unlock(p) (p)->Unlock() +#define IDirect3DVertexBuffer8_GetDesc(p,a) (p)->GetDesc(a) +#endif + + + + +#undef INTERFACE +#define INTERFACE IDirect3DIndexBuffer8 + +DECLARE_INTERFACE_(IDirect3DIndexBuffer8, IDirect3DResource8) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DResource8 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; + STDMETHOD_(DWORD, SetPriority)(THIS_ DWORD PriorityNew) PURE; + STDMETHOD_(DWORD, GetPriority)(THIS) PURE; + STDMETHOD_(void, PreLoad)(THIS) PURE; + STDMETHOD_(D3DRESOURCETYPE, GetType)(THIS) PURE; + STDMETHOD(Lock)(THIS_ UINT OffsetToLock,UINT SizeToLock,BYTE** ppbData,DWORD Flags) PURE; + STDMETHOD(Unlock)(THIS) PURE; + STDMETHOD(GetDesc)(THIS_ D3DINDEXBUFFER_DESC *pDesc) PURE; +}; + +typedef struct IDirect3DIndexBuffer8 *LPDIRECT3DINDEXBUFFER8, *PDIRECT3DINDEXBUFFER8; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DIndexBuffer8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DIndexBuffer8_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DIndexBuffer8_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DIndexBuffer8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DIndexBuffer8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirect3DIndexBuffer8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirect3DIndexBuffer8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirect3DIndexBuffer8_SetPriority(p,a) (p)->lpVtbl->SetPriority(p,a) +#define IDirect3DIndexBuffer8_GetPriority(p) (p)->lpVtbl->GetPriority(p) +#define IDirect3DIndexBuffer8_PreLoad(p) (p)->lpVtbl->PreLoad(p) +#define IDirect3DIndexBuffer8_GetType(p) (p)->lpVtbl->GetType(p) +#define IDirect3DIndexBuffer8_Lock(p,a,b,c,d) (p)->lpVtbl->Lock(p,a,b,c,d) +#define IDirect3DIndexBuffer8_Unlock(p) (p)->lpVtbl->Unlock(p) +#define IDirect3DIndexBuffer8_GetDesc(p,a) (p)->lpVtbl->GetDesc(p,a) +#else +#define IDirect3DIndexBuffer8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DIndexBuffer8_AddRef(p) (p)->AddRef() +#define IDirect3DIndexBuffer8_Release(p) (p)->Release() +#define IDirect3DIndexBuffer8_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DIndexBuffer8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirect3DIndexBuffer8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirect3DIndexBuffer8_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirect3DIndexBuffer8_SetPriority(p,a) (p)->SetPriority(a) +#define IDirect3DIndexBuffer8_GetPriority(p) (p)->GetPriority() +#define IDirect3DIndexBuffer8_PreLoad(p) (p)->PreLoad() +#define IDirect3DIndexBuffer8_GetType(p) (p)->GetType() +#define IDirect3DIndexBuffer8_Lock(p,a,b,c,d) (p)->Lock(a,b,c,d) +#define IDirect3DIndexBuffer8_Unlock(p) (p)->Unlock() +#define IDirect3DIndexBuffer8_GetDesc(p,a) (p)->GetDesc(a) +#endif + + + + +#undef INTERFACE +#define INTERFACE IDirect3DSurface8 + +DECLARE_INTERFACE_(IDirect3DSurface8, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DSurface8 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; + STDMETHOD(GetContainer)(THIS_ REFIID riid,void** ppContainer) PURE; + STDMETHOD(GetDesc)(THIS_ D3DSURFACE_DESC *pDesc) PURE; + STDMETHOD(LockRect)(THIS_ D3DLOCKED_RECT* pLockedRect,CONST RECT* pRect,DWORD Flags) PURE; + STDMETHOD(UnlockRect)(THIS) PURE; +}; + +typedef struct IDirect3DSurface8 *LPDIRECT3DSURFACE8, *PDIRECT3DSURFACE8; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DSurface8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DSurface8_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DSurface8_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DSurface8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DSurface8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirect3DSurface8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirect3DSurface8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirect3DSurface8_GetContainer(p,a,b) (p)->lpVtbl->GetContainer(p,a,b) +#define IDirect3DSurface8_GetDesc(p,a) (p)->lpVtbl->GetDesc(p,a) +#define IDirect3DSurface8_LockRect(p,a,b,c) (p)->lpVtbl->LockRect(p,a,b,c) +#define IDirect3DSurface8_UnlockRect(p) (p)->lpVtbl->UnlockRect(p) +#else +#define IDirect3DSurface8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DSurface8_AddRef(p) (p)->AddRef() +#define IDirect3DSurface8_Release(p) (p)->Release() +#define IDirect3DSurface8_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DSurface8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirect3DSurface8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirect3DSurface8_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirect3DSurface8_GetContainer(p,a,b) (p)->GetContainer(a,b) +#define IDirect3DSurface8_GetDesc(p,a) (p)->GetDesc(a) +#define IDirect3DSurface8_LockRect(p,a,b,c) (p)->LockRect(a,b,c) +#define IDirect3DSurface8_UnlockRect(p) (p)->UnlockRect() +#endif + + + + +#undef INTERFACE +#define INTERFACE IDirect3DVolume8 + +DECLARE_INTERFACE_(IDirect3DVolume8, IUnknown) +{ + /*** IUnknown methods ***/ + STDMETHOD(QueryInterface)(THIS_ REFIID riid, void** ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + /*** IDirect3DVolume8 methods ***/ + STDMETHOD(GetDevice)(THIS_ IDirect3DDevice8** ppDevice) PURE; + STDMETHOD(SetPrivateData)(THIS_ REFGUID refguid,CONST void* pData,DWORD SizeOfData,DWORD Flags) PURE; + STDMETHOD(GetPrivateData)(THIS_ REFGUID refguid,void* pData,DWORD* pSizeOfData) PURE; + STDMETHOD(FreePrivateData)(THIS_ REFGUID refguid) PURE; + STDMETHOD(GetContainer)(THIS_ REFIID riid,void** ppContainer) PURE; + STDMETHOD(GetDesc)(THIS_ D3DVOLUME_DESC *pDesc) PURE; + STDMETHOD(LockBox)(THIS_ D3DLOCKED_BOX * pLockedVolume,CONST D3DBOX* pBox,DWORD Flags) PURE; + STDMETHOD(UnlockBox)(THIS) PURE; +}; + +typedef struct IDirect3DVolume8 *LPDIRECT3DVOLUME8, *PDIRECT3DVOLUME8; + +#if !defined(__cplusplus) || defined(CINTERFACE) +#define IDirect3DVolume8_QueryInterface(p,a,b) (p)->lpVtbl->QueryInterface(p,a,b) +#define IDirect3DVolume8_AddRef(p) (p)->lpVtbl->AddRef(p) +#define IDirect3DVolume8_Release(p) (p)->lpVtbl->Release(p) +#define IDirect3DVolume8_GetDevice(p,a) (p)->lpVtbl->GetDevice(p,a) +#define IDirect3DVolume8_SetPrivateData(p,a,b,c,d) (p)->lpVtbl->SetPrivateData(p,a,b,c,d) +#define IDirect3DVolume8_GetPrivateData(p,a,b,c) (p)->lpVtbl->GetPrivateData(p,a,b,c) +#define IDirect3DVolume8_FreePrivateData(p,a) (p)->lpVtbl->FreePrivateData(p,a) +#define IDirect3DVolume8_GetContainer(p,a,b) (p)->lpVtbl->GetContainer(p,a,b) +#define IDirect3DVolume8_GetDesc(p,a) (p)->lpVtbl->GetDesc(p,a) +#define IDirect3DVolume8_LockBox(p,a,b,c) (p)->lpVtbl->LockBox(p,a,b,c) +#define IDirect3DVolume8_UnlockBox(p) (p)->lpVtbl->UnlockBox(p) +#else +#define IDirect3DVolume8_QueryInterface(p,a,b) (p)->QueryInterface(a,b) +#define IDirect3DVolume8_AddRef(p) (p)->AddRef() +#define IDirect3DVolume8_Release(p) (p)->Release() +#define IDirect3DVolume8_GetDevice(p,a) (p)->GetDevice(a) +#define IDirect3DVolume8_SetPrivateData(p,a,b,c,d) (p)->SetPrivateData(a,b,c,d) +#define IDirect3DVolume8_GetPrivateData(p,a,b,c) (p)->GetPrivateData(a,b,c) +#define IDirect3DVolume8_FreePrivateData(p,a) (p)->FreePrivateData(a) +#define IDirect3DVolume8_GetContainer(p,a,b) (p)->GetContainer(a,b) +#define IDirect3DVolume8_GetDesc(p,a) (p)->GetDesc(a) +#define IDirect3DVolume8_LockBox(p,a,b,c) (p)->LockBox(a,b,c) +#define IDirect3DVolume8_UnlockBox(p) (p)->UnlockBox() +#endif + +/**************************************************************************** + * Flags for SetPrivateData method on all D3D8 interfaces + * + * The passed pointer is an IUnknown ptr. The SizeOfData argument to SetPrivateData + * must be set to sizeof(IUnknown*). Direct3D will call AddRef through this + * pointer and Release when the private data is destroyed. The data will be + * destroyed when another SetPrivateData with the same GUID is set, when + * FreePrivateData is called, or when the D3D8 object is freed. + ****************************************************************************/ +#define D3DSPD_IUNKNOWN 0x00000001L + +/**************************************************************************** + * + * Parameter for IDirect3D8 Enum and GetCaps8 functions to get the info for + * the current mode only. + * + ****************************************************************************/ + +#define D3DCURRENT_DISPLAY_MODE 0x00EFFFFFL + +/**************************************************************************** + * + * Flags for IDirect3D8::CreateDevice's BehaviorFlags + * + ****************************************************************************/ + +#define D3DCREATE_FPU_PRESERVE 0x00000002L +#define D3DCREATE_MULTITHREADED 0x00000004L + +#define D3DCREATE_PUREDEVICE 0x00000010L +#define D3DCREATE_SOFTWARE_VERTEXPROCESSING 0x00000020L +#define D3DCREATE_HARDWARE_VERTEXPROCESSING 0x00000040L +#define D3DCREATE_MIXED_VERTEXPROCESSING 0x00000080L + +#define D3DCREATE_DISABLE_DRIVER_MANAGEMENT 0x00000100L + + +/**************************************************************************** + * + * Parameter for IDirect3D8::CreateDevice's iAdapter + * + ****************************************************************************/ + +#define D3DADAPTER_DEFAULT 0 + +/**************************************************************************** + * + * Flags for IDirect3D8::EnumAdapters + * + ****************************************************************************/ + +#define D3DENUM_NO_WHQL_LEVEL 0x00000002L + +/**************************************************************************** + * + * Maximum number of back-buffers supported in DX8 + * + ****************************************************************************/ + +#define D3DPRESENT_BACK_BUFFERS_MAX 3L + +/**************************************************************************** + * + * Flags for IDirect3DDevice8::SetGammaRamp + * + ****************************************************************************/ + +#define D3DSGR_NO_CALIBRATION 0x00000000L +#define D3DSGR_CALIBRATE 0x00000001L + +/**************************************************************************** + * + * Flags for IDirect3DDevice8::SetCursorPosition + * + ****************************************************************************/ + +#define D3DCURSOR_IMMEDIATE_UPDATE 0x00000001L + +/**************************************************************************** + * + * Flags for DrawPrimitive/DrawIndexedPrimitive + * Also valid for Begin/BeginIndexed + * Also valid for VertexBuffer::CreateVertexBuffer + ****************************************************************************/ + + +/* + * DirectDraw error codes + */ +#define _FACD3D 0x876 +#define MAKE_D3DHRESULT( code ) MAKE_HRESULT( 1, _FACD3D, code ) + +/* + * Direct3D Errors + */ +#define D3D_OK S_OK + +#define D3DERR_WRONGTEXTUREFORMAT MAKE_D3DHRESULT(2072) +#define D3DERR_UNSUPPORTEDCOLOROPERATION MAKE_D3DHRESULT(2073) +#define D3DERR_UNSUPPORTEDCOLORARG MAKE_D3DHRESULT(2074) +#define D3DERR_UNSUPPORTEDALPHAOPERATION MAKE_D3DHRESULT(2075) +#define D3DERR_UNSUPPORTEDALPHAARG MAKE_D3DHRESULT(2076) +#define D3DERR_TOOMANYOPERATIONS MAKE_D3DHRESULT(2077) +#define D3DERR_CONFLICTINGTEXTUREFILTER MAKE_D3DHRESULT(2078) +#define D3DERR_UNSUPPORTEDFACTORVALUE MAKE_D3DHRESULT(2079) +#define D3DERR_CONFLICTINGRENDERSTATE MAKE_D3DHRESULT(2081) +#define D3DERR_UNSUPPORTEDTEXTUREFILTER MAKE_D3DHRESULT(2082) +#define D3DERR_CONFLICTINGTEXTUREPALETTE MAKE_D3DHRESULT(2086) +#define D3DERR_DRIVERINTERNALERROR MAKE_D3DHRESULT(2087) + +#define D3DERR_NOTFOUND MAKE_D3DHRESULT(2150) +#define D3DERR_MOREDATA MAKE_D3DHRESULT(2151) +#define D3DERR_DEVICELOST MAKE_D3DHRESULT(2152) +#define D3DERR_DEVICENOTRESET MAKE_D3DHRESULT(2153) +#define D3DERR_NOTAVAILABLE MAKE_D3DHRESULT(2154) +#define D3DERR_OUTOFVIDEOMEMORY MAKE_D3DHRESULT(380) +#define D3DERR_INVALIDDEVICE MAKE_D3DHRESULT(2155) +#define D3DERR_INVALIDCALL MAKE_D3DHRESULT(2156) +#define D3DERR_DRIVERINVALIDCALL MAKE_D3DHRESULT(2157) + +#ifdef __cplusplus +}; +#endif + +#endif /* (DIRECT3D_VERSION >= 0x0800) */ +#endif /* _D3D_H_ */ + diff --git a/gfx/include/d3d8/d3dx8.h b/gfx/include/d3d8/d3dx8.h index a7d30d74eb..fc2688c43a 100644 --- a/gfx/include/d3d8/d3dx8.h +++ b/gfx/include/d3d8/d3dx8.h @@ -1,44 +1,44 @@ -/////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) Microsoft Corporation. All Rights Reserved. -// -// File: d3dx8.h -// Content: D3DX utility library -// -/////////////////////////////////////////////////////////////////////////// - -#ifndef __D3DX8_H__ -#define __D3DX8_H__ - -#include "d3d8.h" -#include - -#ifndef D3DXINLINE -#ifdef _MSC_VER - #if (_MSC_VER >= 1200) - #define D3DXINLINE __forceinline - #else - #define D3DXINLINE __inline - #endif -#else - #ifdef __cplusplus - #define D3DXINLINE inline - #else - #define D3DXINLINE - #endif -#endif -#endif - - -#define D3DX_DEFAULT ULONG_MAX -#define D3DX_DEFAULT_FLOAT FLT_MAX - -#include "d3dx8math.h" -#include "d3dx8core.h" -#include "d3dx8tex.h" -#include "d3dx8mesh.h" -#include "d3dx8shape.h" -#include "d3dx8effect.h" - - -#endif //__D3DX8_H__ +/////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Microsoft Corporation. All Rights Reserved. +// +// File: d3dx8.h +// Content: D3DX utility library +// +/////////////////////////////////////////////////////////////////////////// + +#ifndef __D3DX8_H__ +#define __D3DX8_H__ + +#include "d3d8.h" +#include + +#ifndef D3DXINLINE +#ifdef _MSC_VER + #if (_MSC_VER >= 1200) + #define D3DXINLINE __forceinline + #else + #define D3DXINLINE __inline + #endif +#else + #ifdef __cplusplus + #define D3DXINLINE inline + #else + #define D3DXINLINE + #endif +#endif +#endif + + +#define D3DX_DEFAULT ULONG_MAX +#define D3DX_DEFAULT_FLOAT FLT_MAX + +#include "d3dx8math.h" +#include "d3dx8core.h" +#include "d3dx8tex.h" +#include "d3dx8mesh.h" +#include "d3dx8shape.h" +#include "d3dx8effect.h" + + +#endif //__D3DX8_H__ diff --git a/gfx/include/d3d8/d3dx8core.h b/gfx/include/d3d8/d3dx8core.h index 7db338f9b4..2d70af640c 100644 --- a/gfx/include/d3d8/d3dx8core.h +++ b/gfx/include/d3d8/d3dx8core.h @@ -1,563 +1,563 @@ -/////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) Microsoft Corporation. All Rights Reserved. -// -// File: d3dx8core.h -// Content: D3DX core types and functions -// -/////////////////////////////////////////////////////////////////////////// - -#include "d3dx8.h" - -#ifndef __D3DX8CORE_H__ -#define __D3DX8CORE_H__ - - - -/////////////////////////////////////////////////////////////////////////// -// ID3DXBuffer: -// ------------ -// The buffer object is used by D3DX to return arbitrary size data. -// -// GetBufferPointer - -// Returns a pointer to the beginning of the buffer. -// -// GetBufferSize - -// Returns the size of the buffer, in bytes. -/////////////////////////////////////////////////////////////////////////// - -typedef interface ID3DXBuffer ID3DXBuffer; -typedef interface ID3DXBuffer *LPD3DXBUFFER; - -// {932E6A7E-C68E-45dd-A7BF-53D19C86DB1F} -DEFINE_GUID(IID_ID3DXBuffer, -0x932e6a7e, 0xc68e, 0x45dd, 0xa7, 0xbf, 0x53, 0xd1, 0x9c, 0x86, 0xdb, 0x1f); - -#undef INTERFACE -#define INTERFACE ID3DXBuffer - -DECLARE_INTERFACE_(ID3DXBuffer, IUnknown) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // ID3DXBuffer - STDMETHOD_(LPVOID, GetBufferPointer)(THIS) PURE; - STDMETHOD_(DWORD, GetBufferSize)(THIS) PURE; -}; - - - -/////////////////////////////////////////////////////////////////////////// -// ID3DXFont: -// ---------- -// Font objects contain the textures and resources needed to render -// a specific font on a specific device. -// -// Begin - -// Prepartes device for drawing text. This is optional.. if DrawText -// is called outside of Begin/End, it will call Begin and End for you. -// -// DrawText - -// Draws formatted text on a D3D device. Some parameters are -// surprisingly similar to those of GDI's DrawText function. See GDI -// documentation for a detailed description of these parameters. -// -// End - -// Restores device state to how it was when Begin was called. -// -// OnLostDevice, OnResetDevice - -// Call OnLostDevice() on this object before calling Reset() on the -// device, so that this object can release any stateblocks and video -// memory resources. After Reset(), the call OnResetDevice(). -// -/////////////////////////////////////////////////////////////////////////// - -typedef interface ID3DXFont ID3DXFont; -typedef interface ID3DXFont *LPD3DXFONT; - - -// {89FAD6A5-024D-49af-8FE7-F51123B85E25} -DEFINE_GUID( IID_ID3DXFont, -0x89fad6a5, 0x24d, 0x49af, 0x8f, 0xe7, 0xf5, 0x11, 0x23, 0xb8, 0x5e, 0x25); - - -#undef INTERFACE -#define INTERFACE ID3DXFont - -DECLARE_INTERFACE_(ID3DXFont, IUnknown) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // ID3DXFont - STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; - STDMETHOD(GetLogFont)(THIS_ LOGFONT* pLogFont) PURE; - - STDMETHOD(Begin)(THIS) PURE; - STDMETHOD_(INT, DrawTextA)(THIS_ LPCSTR pString, INT Count, LPRECT pRect, DWORD Format, D3DCOLOR Color) PURE; - STDMETHOD_(INT, DrawTextW)(THIS_ LPCWSTR pString, INT Count, LPRECT pRect, DWORD Format, D3DCOLOR Color) PURE; - STDMETHOD(End)(THIS) PURE; - - STDMETHOD(OnLostDevice)(THIS) PURE; - STDMETHOD(OnResetDevice)(THIS) PURE; -}; - -#ifndef DrawText -#ifdef UNICODE -#define DrawText DrawTextW -#else -#define DrawText DrawTextA -#endif -#endif - - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - -HRESULT WINAPI - D3DXCreateFont( - LPDIRECT3DDEVICE8 pDevice, - HFONT hFont, - LPD3DXFONT* ppFont); - - -HRESULT WINAPI - D3DXCreateFontIndirect( - LPDIRECT3DDEVICE8 pDevice, - CONST LOGFONT* pLogFont, - LPD3DXFONT* ppFont); - -#ifdef __cplusplus -} -#endif //__cplusplus - - - - -/////////////////////////////////////////////////////////////////////////// -// ID3DXSprite: -// ------------ -// This object intends to provide an easy way to drawing sprites using D3D. -// -// Begin - -// Prepares device for drawing sprites -// -// Draw, DrawAffine, DrawTransform - -// Draws a sprite in screen-space. Before transformation, the sprite is -// the size of SrcRect, with its top-left corner at the origin (0,0). -// The color and alpha channels are modulated by Color. -// -// End - -// Restores device state to how it was when Begin was called. -// -// OnLostDevice, OnResetDevice - -// Call OnLostDevice() on this object before calling Reset() on the -// device, so that this object can release any stateblocks and video -// memory resources. After Reset(), the call OnResetDevice(). -/////////////////////////////////////////////////////////////////////////// - -typedef interface ID3DXSprite ID3DXSprite; -typedef interface ID3DXSprite *LPD3DXSPRITE; - - -// {13D69D15-F9B0-4e0f-B39E-C91EB33F6CE7} -DEFINE_GUID( IID_ID3DXSprite, -0x13d69d15, 0xf9b0, 0x4e0f, 0xb3, 0x9e, 0xc9, 0x1e, 0xb3, 0x3f, 0x6c, 0xe7); - - -#undef INTERFACE -#define INTERFACE ID3DXSprite - -DECLARE_INTERFACE_(ID3DXSprite, IUnknown) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // ID3DXSprite - STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; - - STDMETHOD(Begin)(THIS) PURE; - - STDMETHOD(Draw)(THIS_ LPDIRECT3DTEXTURE8 pSrcTexture, - CONST RECT* pSrcRect, CONST D3DXVECTOR2* pScaling, - CONST D3DXVECTOR2* pRotationCenter, FLOAT Rotation, - CONST D3DXVECTOR2* pTranslation, D3DCOLOR Color) PURE; - - STDMETHOD(DrawTransform)(THIS_ LPDIRECT3DTEXTURE8 pSrcTexture, - CONST RECT* pSrcRect, CONST D3DXMATRIX* pTransform, - D3DCOLOR Color) PURE; - - STDMETHOD(End)(THIS) PURE; - - STDMETHOD(OnLostDevice)(THIS) PURE; - STDMETHOD(OnResetDevice)(THIS) PURE; -}; - - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - - -HRESULT WINAPI - D3DXCreateSprite( - LPDIRECT3DDEVICE8 pDevice, - LPD3DXSPRITE* ppSprite); - -#ifdef __cplusplus -} -#endif //__cplusplus - - - - -/////////////////////////////////////////////////////////////////////////// -// ID3DXRenderToSurface: -// --------------------- -// This object abstracts rendering to surfaces. These surfaces do not -// necessarily need to be render targets. If they are not, a compatible -// render target is used, and the result copied into surface at end scene. -// -// BeginScene, EndScene - -// Call BeginScene() and EndScene() at the beginning and ending of your -// scene. These calls will setup and restore render targets, viewports, -// etc.. -// -// OnLostDevice, OnResetDevice - -// Call OnLostDevice() on this object before calling Reset() on the -// device, so that this object can release any stateblocks and video -// memory resources. After Reset(), the call OnResetDevice(). -/////////////////////////////////////////////////////////////////////////// - -typedef struct _D3DXRTS_DESC -{ - UINT Width; - UINT Height; - D3DFORMAT Format; - BOOL DepthStencil; - D3DFORMAT DepthStencilFormat; - -} D3DXRTS_DESC; - - -typedef interface ID3DXRenderToSurface ID3DXRenderToSurface; -typedef interface ID3DXRenderToSurface *LPD3DXRENDERTOSURFACE; - - -// {82DF5B90-E34E-496e-AC1C-62117A6A5913} -DEFINE_GUID( IID_ID3DXRenderToSurface, -0x82df5b90, 0xe34e, 0x496e, 0xac, 0x1c, 0x62, 0x11, 0x7a, 0x6a, 0x59, 0x13); - - -#undef INTERFACE -#define INTERFACE ID3DXRenderToSurface - -DECLARE_INTERFACE_(ID3DXRenderToSurface, IUnknown) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // ID3DXRenderToSurface - STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; - STDMETHOD(GetDesc)(THIS_ D3DXRTS_DESC* pDesc) PURE; - - STDMETHOD(BeginScene)(THIS_ LPDIRECT3DSURFACE8 pSurface, CONST D3DVIEWPORT8* pViewport) PURE; - STDMETHOD(EndScene)(THIS) PURE; - - STDMETHOD(OnLostDevice)(THIS) PURE; - STDMETHOD(OnResetDevice)(THIS) PURE; -}; - - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - -HRESULT WINAPI - D3DXCreateRenderToSurface( - LPDIRECT3DDEVICE8 pDevice, - UINT Width, - UINT Height, - D3DFORMAT Format, - BOOL DepthStencil, - D3DFORMAT DepthStencilFormat, - LPD3DXRENDERTOSURFACE* ppRenderToSurface); - -#ifdef __cplusplus -} -#endif //__cplusplus - - - -/////////////////////////////////////////////////////////////////////////// -// ID3DXRenderToEnvMap: -// -------------------- -// This object abstracts rendering to environment maps. These surfaces -// do not necessarily need to be render targets. If they are not, a -// compatible render target is used, and the result copied into the -// environment map at end scene. -// -// BeginCube, BeginSphere, BeginHemisphere, BeginParabolic - -// This function initiates the rendering of the environment map. As -// parameters, you pass the textures in which will get filled in with -// the resulting environment map. -// -// Face - -// Call this function to initiate the drawing of each face. For each -// environment map, you will call this six times.. once for each face -// in D3DCUBEMAP_FACES. -// -// End - -// This will restore all render targets, and if needed compose all the -// rendered faces into the environment map surfaces. -// -// OnLostDevice, OnResetDevice - -// Call OnLostDevice() on this object before calling Reset() on the -// device, so that this object can release any stateblocks and video -// memory resources. After Reset(), the call OnResetDevice(). -/////////////////////////////////////////////////////////////////////////// - -typedef struct _D3DXRTE_DESC -{ - UINT Size; - D3DFORMAT Format; - BOOL DepthStencil; - D3DFORMAT DepthStencilFormat; -} D3DXRTE_DESC; - - -typedef interface ID3DXRenderToEnvMap ID3DXRenderToEnvMap; -typedef interface ID3DXRenderToEnvMap *LPD3DXRenderToEnvMap; - -// {4E42C623-9451-44b7-8C86-ABCCDE5D52C8} -DEFINE_GUID( IID_ID3DXRenderToEnvMap, -0x4e42c623, 0x9451, 0x44b7, 0x8c, 0x86, 0xab, 0xcc, 0xde, 0x5d, 0x52, 0xc8); - - -#undef INTERFACE -#define INTERFACE ID3DXRenderToEnvMap - -DECLARE_INTERFACE_(ID3DXRenderToEnvMap, IUnknown) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // ID3DXRenderToEnvMap - STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; - STDMETHOD(GetDesc)(THIS_ D3DXRTE_DESC* pDesc) PURE; - - STDMETHOD(BeginCube)(THIS_ - LPDIRECT3DCUBETEXTURE8 pCubeTex) PURE; - - STDMETHOD(BeginSphere)(THIS_ - LPDIRECT3DTEXTURE8 pTex) PURE; - - STDMETHOD(BeginHemisphere)(THIS_ - LPDIRECT3DTEXTURE8 pTexZPos, - LPDIRECT3DTEXTURE8 pTexZNeg) PURE; - - STDMETHOD(BeginParabolic)(THIS_ - LPDIRECT3DTEXTURE8 pTexZPos, - LPDIRECT3DTEXTURE8 pTexZNeg) PURE; - - STDMETHOD(Face)(THIS_ D3DCUBEMAP_FACES Face) PURE; - STDMETHOD(End)(THIS) PURE; - - STDMETHOD(OnLostDevice)(THIS) PURE; - STDMETHOD(OnResetDevice)(THIS) PURE; -}; - - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - -HRESULT WINAPI - D3DXCreateRenderToEnvMap( - LPDIRECT3DDEVICE8 pDevice, - UINT Size, - D3DFORMAT Format, - BOOL DepthStencil, - D3DFORMAT DepthStencilFormat, - LPD3DXRenderToEnvMap* ppRenderToEnvMap); - -#ifdef __cplusplus -} -#endif //__cplusplus - - - -/////////////////////////////////////////////////////////////////////////// -// Shader assemblers: -/////////////////////////////////////////////////////////////////////////// - -//------------------------------------------------------------------------- -// D3DXASM flags: -// -------------- -// -// D3DXASM_DEBUG -// Generate debug info. -// -// D3DXASM_SKIPVALIDATION -// Do not validate the generated code against known capabilities and -// constraints. This option is only recommended when assembling shaders -// you KNOW will work. (ie. have assembled before without this option.) -//------------------------------------------------------------------------- - -#define D3DXASM_DEBUG (1 << 0) -#define D3DXASM_SKIPVALIDATION (1 << 1) - - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - -//------------------------------------------------------------------------- -// D3DXAssembleShader: -// ------------------- -// Assembles an ascii description of a vertex or pixel shader into -// binary form. -// -// Parameters: -// pSrcFile -// Source file name -// hSrcModule -// Module handle. if NULL, current module will be used. -// pSrcResource -// Resource name in module -// pSrcData -// Pointer to source code -// SrcDataLen -// Size of source code, in bytes -// Flags -// D3DXASM_xxx flags -// ppConstants -// Returns an ID3DXBuffer object containing constant declarations. -// ppCompiledShader -// Returns an ID3DXBuffer object containing the object code. -// ppCompilationErrors -// Returns an ID3DXBuffer object containing ascii error messages -//------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXAssembleShaderFromFileA( - LPCSTR pSrcFile, - DWORD Flags, - LPD3DXBUFFER* ppConstants, - LPD3DXBUFFER* ppCompiledShader, - LPD3DXBUFFER* ppCompilationErrors); - -HRESULT WINAPI - D3DXAssembleShaderFromFileW( - LPCWSTR pSrcFile, - DWORD Flags, - LPD3DXBUFFER* ppConstants, - LPD3DXBUFFER* ppCompiledShader, - LPD3DXBUFFER* ppCompilationErrors); - -#ifdef UNICODE -#define D3DXAssembleShaderFromFile D3DXAssembleShaderFromFileW -#else -#define D3DXAssembleShaderFromFile D3DXAssembleShaderFromFileA -#endif - -HRESULT WINAPI - D3DXAssembleShaderFromResourceA( - HMODULE hSrcModule, - LPCSTR pSrcResource, - DWORD Flags, - LPD3DXBUFFER* ppConstants, - LPD3DXBUFFER* ppCompiledShader, - LPD3DXBUFFER* ppCompilationErrors); - -HRESULT WINAPI - D3DXAssembleShaderFromResourceW( - HMODULE hSrcModule, - LPCWSTR pSrcResource, - DWORD Flags, - LPD3DXBUFFER* ppConstants, - LPD3DXBUFFER* ppCompiledShader, - LPD3DXBUFFER* ppCompilationErrors); - -#ifdef UNICODE -#define D3DXAssembleShaderFromResource D3DXAssembleShaderFromResourceW -#else -#define D3DXAssembleShaderFromResource D3DXAssembleShaderFromResourceA -#endif - -HRESULT WINAPI - D3DXAssembleShader( - LPCVOID pSrcData, - UINT SrcDataLen, - DWORD Flags, - LPD3DXBUFFER* ppConstants, - LPD3DXBUFFER* ppCompiledShader, - LPD3DXBUFFER* ppCompilationErrors); - - -#ifdef __cplusplus -} -#endif //__cplusplus - - - -/////////////////////////////////////////////////////////////////////////// -// Misc APIs: -/////////////////////////////////////////////////////////////////////////// - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - -//------------------------------------------------------------------------- -// D3DXGetErrorString: -// ------------------ -// Returns the error string for given an hresult. Interprets all D3DX and -// D3D hresults. -// -// Parameters: -// hr -// The error code to be deciphered. -// pBuffer -// Pointer to the buffer to be filled in. -// BufferLen -// Count of characters in buffer. Any error message longer than this -// length will be truncated to fit. -//------------------------------------------------------------------------- -HRESULT WINAPI - D3DXGetErrorStringA( - HRESULT hr, - LPSTR pBuffer, - UINT BufferLen); - -HRESULT WINAPI - D3DXGetErrorStringW( - HRESULT hr, - LPWSTR pBuffer, - UINT BufferLen); - -#ifdef UNICODE -#define D3DXGetErrorString D3DXGetErrorStringW -#else -#define D3DXGetErrorString D3DXGetErrorStringA -#endif - - - -#ifdef __cplusplus -} -#endif //__cplusplus - -#endif //__D3DX8CORE_H__ +/////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Microsoft Corporation. All Rights Reserved. +// +// File: d3dx8core.h +// Content: D3DX core types and functions +// +/////////////////////////////////////////////////////////////////////////// + +#include "d3dx8.h" + +#ifndef __D3DX8CORE_H__ +#define __D3DX8CORE_H__ + + + +/////////////////////////////////////////////////////////////////////////// +// ID3DXBuffer: +// ------------ +// The buffer object is used by D3DX to return arbitrary size data. +// +// GetBufferPointer - +// Returns a pointer to the beginning of the buffer. +// +// GetBufferSize - +// Returns the size of the buffer, in bytes. +/////////////////////////////////////////////////////////////////////////// + +typedef interface ID3DXBuffer ID3DXBuffer; +typedef interface ID3DXBuffer *LPD3DXBUFFER; + +// {932E6A7E-C68E-45dd-A7BF-53D19C86DB1F} +DEFINE_GUID(IID_ID3DXBuffer, +0x932e6a7e, 0xc68e, 0x45dd, 0xa7, 0xbf, 0x53, 0xd1, 0x9c, 0x86, 0xdb, 0x1f); + +#undef INTERFACE +#define INTERFACE ID3DXBuffer + +DECLARE_INTERFACE_(ID3DXBuffer, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXBuffer + STDMETHOD_(LPVOID, GetBufferPointer)(THIS) PURE; + STDMETHOD_(DWORD, GetBufferSize)(THIS) PURE; +}; + + + +/////////////////////////////////////////////////////////////////////////// +// ID3DXFont: +// ---------- +// Font objects contain the textures and resources needed to render +// a specific font on a specific device. +// +// Begin - +// Prepartes device for drawing text. This is optional.. if DrawText +// is called outside of Begin/End, it will call Begin and End for you. +// +// DrawText - +// Draws formatted text on a D3D device. Some parameters are +// surprisingly similar to those of GDI's DrawText function. See GDI +// documentation for a detailed description of these parameters. +// +// End - +// Restores device state to how it was when Begin was called. +// +// OnLostDevice, OnResetDevice - +// Call OnLostDevice() on this object before calling Reset() on the +// device, so that this object can release any stateblocks and video +// memory resources. After Reset(), the call OnResetDevice(). +// +/////////////////////////////////////////////////////////////////////////// + +typedef interface ID3DXFont ID3DXFont; +typedef interface ID3DXFont *LPD3DXFONT; + + +// {89FAD6A5-024D-49af-8FE7-F51123B85E25} +DEFINE_GUID( IID_ID3DXFont, +0x89fad6a5, 0x24d, 0x49af, 0x8f, 0xe7, 0xf5, 0x11, 0x23, 0xb8, 0x5e, 0x25); + + +#undef INTERFACE +#define INTERFACE ID3DXFont + +DECLARE_INTERFACE_(ID3DXFont, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXFont + STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; + STDMETHOD(GetLogFont)(THIS_ LOGFONT* pLogFont) PURE; + + STDMETHOD(Begin)(THIS) PURE; + STDMETHOD_(INT, DrawTextA)(THIS_ LPCSTR pString, INT Count, LPRECT pRect, DWORD Format, D3DCOLOR Color) PURE; + STDMETHOD_(INT, DrawTextW)(THIS_ LPCWSTR pString, INT Count, LPRECT pRect, DWORD Format, D3DCOLOR Color) PURE; + STDMETHOD(End)(THIS) PURE; + + STDMETHOD(OnLostDevice)(THIS) PURE; + STDMETHOD(OnResetDevice)(THIS) PURE; +}; + +#ifndef DrawText +#ifdef UNICODE +#define DrawText DrawTextW +#else +#define DrawText DrawTextA +#endif +#endif + + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + +HRESULT WINAPI + D3DXCreateFont( + LPDIRECT3DDEVICE8 pDevice, + HFONT hFont, + LPD3DXFONT* ppFont); + + +HRESULT WINAPI + D3DXCreateFontIndirect( + LPDIRECT3DDEVICE8 pDevice, + CONST LOGFONT* pLogFont, + LPD3DXFONT* ppFont); + +#ifdef __cplusplus +} +#endif //__cplusplus + + + + +/////////////////////////////////////////////////////////////////////////// +// ID3DXSprite: +// ------------ +// This object intends to provide an easy way to drawing sprites using D3D. +// +// Begin - +// Prepares device for drawing sprites +// +// Draw, DrawAffine, DrawTransform - +// Draws a sprite in screen-space. Before transformation, the sprite is +// the size of SrcRect, with its top-left corner at the origin (0,0). +// The color and alpha channels are modulated by Color. +// +// End - +// Restores device state to how it was when Begin was called. +// +// OnLostDevice, OnResetDevice - +// Call OnLostDevice() on this object before calling Reset() on the +// device, so that this object can release any stateblocks and video +// memory resources. After Reset(), the call OnResetDevice(). +/////////////////////////////////////////////////////////////////////////// + +typedef interface ID3DXSprite ID3DXSprite; +typedef interface ID3DXSprite *LPD3DXSPRITE; + + +// {13D69D15-F9B0-4e0f-B39E-C91EB33F6CE7} +DEFINE_GUID( IID_ID3DXSprite, +0x13d69d15, 0xf9b0, 0x4e0f, 0xb3, 0x9e, 0xc9, 0x1e, 0xb3, 0x3f, 0x6c, 0xe7); + + +#undef INTERFACE +#define INTERFACE ID3DXSprite + +DECLARE_INTERFACE_(ID3DXSprite, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXSprite + STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; + + STDMETHOD(Begin)(THIS) PURE; + + STDMETHOD(Draw)(THIS_ LPDIRECT3DTEXTURE8 pSrcTexture, + CONST RECT* pSrcRect, CONST D3DXVECTOR2* pScaling, + CONST D3DXVECTOR2* pRotationCenter, FLOAT Rotation, + CONST D3DXVECTOR2* pTranslation, D3DCOLOR Color) PURE; + + STDMETHOD(DrawTransform)(THIS_ LPDIRECT3DTEXTURE8 pSrcTexture, + CONST RECT* pSrcRect, CONST D3DXMATRIX* pTransform, + D3DCOLOR Color) PURE; + + STDMETHOD(End)(THIS) PURE; + + STDMETHOD(OnLostDevice)(THIS) PURE; + STDMETHOD(OnResetDevice)(THIS) PURE; +}; + + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + + +HRESULT WINAPI + D3DXCreateSprite( + LPDIRECT3DDEVICE8 pDevice, + LPD3DXSPRITE* ppSprite); + +#ifdef __cplusplus +} +#endif //__cplusplus + + + + +/////////////////////////////////////////////////////////////////////////// +// ID3DXRenderToSurface: +// --------------------- +// This object abstracts rendering to surfaces. These surfaces do not +// necessarily need to be render targets. If they are not, a compatible +// render target is used, and the result copied into surface at end scene. +// +// BeginScene, EndScene - +// Call BeginScene() and EndScene() at the beginning and ending of your +// scene. These calls will setup and restore render targets, viewports, +// etc.. +// +// OnLostDevice, OnResetDevice - +// Call OnLostDevice() on this object before calling Reset() on the +// device, so that this object can release any stateblocks and video +// memory resources. After Reset(), the call OnResetDevice(). +/////////////////////////////////////////////////////////////////////////// + +typedef struct _D3DXRTS_DESC +{ + UINT Width; + UINT Height; + D3DFORMAT Format; + BOOL DepthStencil; + D3DFORMAT DepthStencilFormat; + +} D3DXRTS_DESC; + + +typedef interface ID3DXRenderToSurface ID3DXRenderToSurface; +typedef interface ID3DXRenderToSurface *LPD3DXRENDERTOSURFACE; + + +// {82DF5B90-E34E-496e-AC1C-62117A6A5913} +DEFINE_GUID( IID_ID3DXRenderToSurface, +0x82df5b90, 0xe34e, 0x496e, 0xac, 0x1c, 0x62, 0x11, 0x7a, 0x6a, 0x59, 0x13); + + +#undef INTERFACE +#define INTERFACE ID3DXRenderToSurface + +DECLARE_INTERFACE_(ID3DXRenderToSurface, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXRenderToSurface + STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; + STDMETHOD(GetDesc)(THIS_ D3DXRTS_DESC* pDesc) PURE; + + STDMETHOD(BeginScene)(THIS_ LPDIRECT3DSURFACE8 pSurface, CONST D3DVIEWPORT8* pViewport) PURE; + STDMETHOD(EndScene)(THIS) PURE; + + STDMETHOD(OnLostDevice)(THIS) PURE; + STDMETHOD(OnResetDevice)(THIS) PURE; +}; + + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + +HRESULT WINAPI + D3DXCreateRenderToSurface( + LPDIRECT3DDEVICE8 pDevice, + UINT Width, + UINT Height, + D3DFORMAT Format, + BOOL DepthStencil, + D3DFORMAT DepthStencilFormat, + LPD3DXRENDERTOSURFACE* ppRenderToSurface); + +#ifdef __cplusplus +} +#endif //__cplusplus + + + +/////////////////////////////////////////////////////////////////////////// +// ID3DXRenderToEnvMap: +// -------------------- +// This object abstracts rendering to environment maps. These surfaces +// do not necessarily need to be render targets. If they are not, a +// compatible render target is used, and the result copied into the +// environment map at end scene. +// +// BeginCube, BeginSphere, BeginHemisphere, BeginParabolic - +// This function initiates the rendering of the environment map. As +// parameters, you pass the textures in which will get filled in with +// the resulting environment map. +// +// Face - +// Call this function to initiate the drawing of each face. For each +// environment map, you will call this six times.. once for each face +// in D3DCUBEMAP_FACES. +// +// End - +// This will restore all render targets, and if needed compose all the +// rendered faces into the environment map surfaces. +// +// OnLostDevice, OnResetDevice - +// Call OnLostDevice() on this object before calling Reset() on the +// device, so that this object can release any stateblocks and video +// memory resources. After Reset(), the call OnResetDevice(). +/////////////////////////////////////////////////////////////////////////// + +typedef struct _D3DXRTE_DESC +{ + UINT Size; + D3DFORMAT Format; + BOOL DepthStencil; + D3DFORMAT DepthStencilFormat; +} D3DXRTE_DESC; + + +typedef interface ID3DXRenderToEnvMap ID3DXRenderToEnvMap; +typedef interface ID3DXRenderToEnvMap *LPD3DXRenderToEnvMap; + +// {4E42C623-9451-44b7-8C86-ABCCDE5D52C8} +DEFINE_GUID( IID_ID3DXRenderToEnvMap, +0x4e42c623, 0x9451, 0x44b7, 0x8c, 0x86, 0xab, 0xcc, 0xde, 0x5d, 0x52, 0xc8); + + +#undef INTERFACE +#define INTERFACE ID3DXRenderToEnvMap + +DECLARE_INTERFACE_(ID3DXRenderToEnvMap, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXRenderToEnvMap + STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; + STDMETHOD(GetDesc)(THIS_ D3DXRTE_DESC* pDesc) PURE; + + STDMETHOD(BeginCube)(THIS_ + LPDIRECT3DCUBETEXTURE8 pCubeTex) PURE; + + STDMETHOD(BeginSphere)(THIS_ + LPDIRECT3DTEXTURE8 pTex) PURE; + + STDMETHOD(BeginHemisphere)(THIS_ + LPDIRECT3DTEXTURE8 pTexZPos, + LPDIRECT3DTEXTURE8 pTexZNeg) PURE; + + STDMETHOD(BeginParabolic)(THIS_ + LPDIRECT3DTEXTURE8 pTexZPos, + LPDIRECT3DTEXTURE8 pTexZNeg) PURE; + + STDMETHOD(Face)(THIS_ D3DCUBEMAP_FACES Face) PURE; + STDMETHOD(End)(THIS) PURE; + + STDMETHOD(OnLostDevice)(THIS) PURE; + STDMETHOD(OnResetDevice)(THIS) PURE; +}; + + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + +HRESULT WINAPI + D3DXCreateRenderToEnvMap( + LPDIRECT3DDEVICE8 pDevice, + UINT Size, + D3DFORMAT Format, + BOOL DepthStencil, + D3DFORMAT DepthStencilFormat, + LPD3DXRenderToEnvMap* ppRenderToEnvMap); + +#ifdef __cplusplus +} +#endif //__cplusplus + + + +/////////////////////////////////////////////////////////////////////////// +// Shader assemblers: +/////////////////////////////////////////////////////////////////////////// + +//------------------------------------------------------------------------- +// D3DXASM flags: +// -------------- +// +// D3DXASM_DEBUG +// Generate debug info. +// +// D3DXASM_SKIPVALIDATION +// Do not validate the generated code against known capabilities and +// constraints. This option is only recommended when assembling shaders +// you KNOW will work. (ie. have assembled before without this option.) +//------------------------------------------------------------------------- + +#define D3DXASM_DEBUG (1 << 0) +#define D3DXASM_SKIPVALIDATION (1 << 1) + + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + +//------------------------------------------------------------------------- +// D3DXAssembleShader: +// ------------------- +// Assembles an ascii description of a vertex or pixel shader into +// binary form. +// +// Parameters: +// pSrcFile +// Source file name +// hSrcModule +// Module handle. if NULL, current module will be used. +// pSrcResource +// Resource name in module +// pSrcData +// Pointer to source code +// SrcDataLen +// Size of source code, in bytes +// Flags +// D3DXASM_xxx flags +// ppConstants +// Returns an ID3DXBuffer object containing constant declarations. +// ppCompiledShader +// Returns an ID3DXBuffer object containing the object code. +// ppCompilationErrors +// Returns an ID3DXBuffer object containing ascii error messages +//------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXAssembleShaderFromFileA( + LPCSTR pSrcFile, + DWORD Flags, + LPD3DXBUFFER* ppConstants, + LPD3DXBUFFER* ppCompiledShader, + LPD3DXBUFFER* ppCompilationErrors); + +HRESULT WINAPI + D3DXAssembleShaderFromFileW( + LPCWSTR pSrcFile, + DWORD Flags, + LPD3DXBUFFER* ppConstants, + LPD3DXBUFFER* ppCompiledShader, + LPD3DXBUFFER* ppCompilationErrors); + +#ifdef UNICODE +#define D3DXAssembleShaderFromFile D3DXAssembleShaderFromFileW +#else +#define D3DXAssembleShaderFromFile D3DXAssembleShaderFromFileA +#endif + +HRESULT WINAPI + D3DXAssembleShaderFromResourceA( + HMODULE hSrcModule, + LPCSTR pSrcResource, + DWORD Flags, + LPD3DXBUFFER* ppConstants, + LPD3DXBUFFER* ppCompiledShader, + LPD3DXBUFFER* ppCompilationErrors); + +HRESULT WINAPI + D3DXAssembleShaderFromResourceW( + HMODULE hSrcModule, + LPCWSTR pSrcResource, + DWORD Flags, + LPD3DXBUFFER* ppConstants, + LPD3DXBUFFER* ppCompiledShader, + LPD3DXBUFFER* ppCompilationErrors); + +#ifdef UNICODE +#define D3DXAssembleShaderFromResource D3DXAssembleShaderFromResourceW +#else +#define D3DXAssembleShaderFromResource D3DXAssembleShaderFromResourceA +#endif + +HRESULT WINAPI + D3DXAssembleShader( + LPCVOID pSrcData, + UINT SrcDataLen, + DWORD Flags, + LPD3DXBUFFER* ppConstants, + LPD3DXBUFFER* ppCompiledShader, + LPD3DXBUFFER* ppCompilationErrors); + + +#ifdef __cplusplus +} +#endif //__cplusplus + + + +/////////////////////////////////////////////////////////////////////////// +// Misc APIs: +/////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + +//------------------------------------------------------------------------- +// D3DXGetErrorString: +// ------------------ +// Returns the error string for given an hresult. Interprets all D3DX and +// D3D hresults. +// +// Parameters: +// hr +// The error code to be deciphered. +// pBuffer +// Pointer to the buffer to be filled in. +// BufferLen +// Count of characters in buffer. Any error message longer than this +// length will be truncated to fit. +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXGetErrorStringA( + HRESULT hr, + LPSTR pBuffer, + UINT BufferLen); + +HRESULT WINAPI + D3DXGetErrorStringW( + HRESULT hr, + LPWSTR pBuffer, + UINT BufferLen); + +#ifdef UNICODE +#define D3DXGetErrorString D3DXGetErrorStringW +#else +#define D3DXGetErrorString D3DXGetErrorStringA +#endif + + + +#ifdef __cplusplus +} +#endif //__cplusplus + +#endif //__D3DX8CORE_H__ diff --git a/gfx/include/d3d8/d3dx8effect.h b/gfx/include/d3d8/d3dx8effect.h index 96fc382815..8444935877 100644 --- a/gfx/include/d3d8/d3dx8effect.h +++ b/gfx/include/d3d8/d3dx8effect.h @@ -1,226 +1,226 @@ -/////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) Microsoft Corporation. All Rights Reserved. -// -// File: d3dx8effect.h -// Content: D3DX effect types and functions -// -/////////////////////////////////////////////////////////////////////////// - -#include "d3dx8.h" - -#ifndef __D3DX8EFFECT_H__ -#define __D3DX8EFFECT_H__ - - -#define D3DXFX_DONOTSAVESTATE (1 << 0) - - -typedef enum _D3DXPARAMETERTYPE -{ - D3DXPT_DWORD = 0, - D3DXPT_FLOAT = 1, - D3DXPT_VECTOR = 2, - D3DXPT_MATRIX = 3, - D3DXPT_TEXTURE = 4, - D3DXPT_VERTEXSHADER = 5, - D3DXPT_PIXELSHADER = 6, - D3DXPT_CONSTANT = 7, - D3DXPT_STRING = 8, - D3DXPT_FORCE_DWORD = 0x7fffffff /* force 32-bit size enum */ - -} D3DXPARAMETERTYPE; - - -typedef struct _D3DXEFFECT_DESC -{ - UINT Parameters; - UINT Techniques; - -} D3DXEFFECT_DESC; - - -typedef struct _D3DXPARAMETER_DESC -{ - LPCSTR Name; - LPCSTR Index; - D3DXPARAMETERTYPE Type; - -} D3DXPARAMETER_DESC; - - -typedef struct _D3DXTECHNIQUE_DESC -{ - LPCSTR Name; - LPCSTR Index; - UINT Passes; - -} D3DXTECHNIQUE_DESC; - - -typedef struct _D3DXPASS_DESC -{ - LPCSTR Name; - LPCSTR Index; - -} D3DXPASS_DESC; - - - -////////////////////////////////////////////////////////////////////////////// -// ID3DXEffect /////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -typedef interface ID3DXEffect ID3DXEffect; -typedef interface ID3DXEffect *LPD3DXEFFECT; - -// {648B1CEB-8D4E-4d66-B6FA-E44969E82E89} -DEFINE_GUID( IID_ID3DXEffect, -0x648b1ceb, 0x8d4e, 0x4d66, 0xb6, 0xfa, 0xe4, 0x49, 0x69, 0xe8, 0x2e, 0x89); - - -#undef INTERFACE -#define INTERFACE ID3DXEffect - -DECLARE_INTERFACE_(ID3DXEffect, IUnknown) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // ID3DXEffect - STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; - STDMETHOD(GetDesc)(THIS_ D3DXEFFECT_DESC* pDesc) PURE; - STDMETHOD(GetParameterDesc)(THIS_ LPCSTR pParameter, D3DXPARAMETER_DESC* pDesc) PURE; - STDMETHOD(GetTechniqueDesc)(THIS_ LPCSTR pTechnique, D3DXTECHNIQUE_DESC* pDesc) PURE; - STDMETHOD(GetPassDesc)(THIS_ LPCSTR pTechnique, LPCSTR pPass, D3DXPASS_DESC* pDesc) PURE; - STDMETHOD(FindNextValidTechnique)(THIS_ LPCSTR pTechnique, D3DXTECHNIQUE_DESC* pDesc) PURE; - STDMETHOD(CloneEffect)(THIS_ LPDIRECT3DDEVICE8 pDevice, LPD3DXEFFECT* ppEffect) PURE; - STDMETHOD(GetCompiledEffect)(THIS_ LPD3DXBUFFER* ppCompiledEffect) PURE; - - STDMETHOD(SetTechnique)(THIS_ LPCSTR pTechnique) PURE; - STDMETHOD(GetTechnique)(THIS_ LPCSTR* ppTechnique) PURE; - - STDMETHOD(SetDword)(THIS_ LPCSTR pParameter, DWORD dw) PURE; - STDMETHOD(GetDword)(THIS_ LPCSTR pParameter, DWORD* pdw) PURE; - STDMETHOD(SetFloat)(THIS_ LPCSTR pParameter, FLOAT f) PURE; - STDMETHOD(GetFloat)(THIS_ LPCSTR pParameter, FLOAT* pf) PURE; - STDMETHOD(SetVector)(THIS_ LPCSTR pParameter, CONST D3DXVECTOR4* pVector) PURE; - STDMETHOD(GetVector)(THIS_ LPCSTR pParameter, D3DXVECTOR4* pVector) PURE; - STDMETHOD(SetMatrix)(THIS_ LPCSTR pParameter, CONST D3DXMATRIX* pMatrix) PURE; - STDMETHOD(GetMatrix)(THIS_ LPCSTR pParameter, D3DXMATRIX* pMatrix) PURE; - STDMETHOD(SetTexture)(THIS_ LPCSTR pParameter, LPDIRECT3DBASETEXTURE8 pTexture) PURE; - STDMETHOD(GetTexture)(THIS_ LPCSTR pParameter, LPDIRECT3DBASETEXTURE8 *ppTexture) PURE; - STDMETHOD(SetVertexShader)(THIS_ LPCSTR pParameter, DWORD Handle) PURE; - STDMETHOD(GetVertexShader)(THIS_ LPCSTR pParameter, DWORD* pHandle) PURE; - STDMETHOD(SetPixelShader)(THIS_ LPCSTR pParameter, DWORD Handle) PURE; - STDMETHOD(GetPixelShader)(THIS_ LPCSTR pParameter, DWORD* pHandle) PURE; - STDMETHOD(SetString)(THIS_ LPCSTR pParameter, LPCSTR pString) PURE; - STDMETHOD(GetString)(THIS_ LPCSTR pParameter, LPCSTR* ppString) PURE; - STDMETHOD_(BOOL, IsParameterUsed)(THIS_ LPCSTR pParameter) PURE; - - STDMETHOD(Validate)(THIS) PURE; - STDMETHOD(Begin)(THIS_ UINT *pPasses, DWORD Flags) PURE; - STDMETHOD(Pass)(THIS_ UINT Pass) PURE; - STDMETHOD(End)(THIS) PURE; - STDMETHOD(OnLostDevice)(THIS) PURE; - STDMETHOD(OnResetDevice)(THIS) PURE; -}; - - - -////////////////////////////////////////////////////////////////////////////// -// APIs ////////////////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - - -//---------------------------------------------------------------------------- -// D3DXCreateEffect: -// ----------------- -// Creates an effect from an ascii or binaray effect description. -// -// Parameters: -// pDevice -// Pointer of the device on which to create the effect -// pSrcFile -// Name of the file containing the effect description -// hSrcModule -// Module handle. if NULL, current module will be used. -// pSrcResource -// Resource name in module -// pSrcData -// Pointer to effect description -// SrcDataSize -// Size of the effect description in bytes -// ppEffect -// Returns a buffer containing created effect. -// ppCompilationErrors -// Returns a buffer containing any error messages which occurred during -// compile. Or NULL if you do not care about the error messages. -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXCreateEffectFromFileA( - LPDIRECT3DDEVICE8 pDevice, - LPCSTR pSrcFile, - LPD3DXEFFECT* ppEffect, - LPD3DXBUFFER* ppCompilationErrors); - -HRESULT WINAPI - D3DXCreateEffectFromFileW( - LPDIRECT3DDEVICE8 pDevice, - LPCWSTR pSrcFile, - LPD3DXEFFECT* ppEffect, - LPD3DXBUFFER* ppCompilationErrors); - -#ifdef UNICODE -#define D3DXCreateEffectFromFile D3DXCreateEffectFromFileW -#else -#define D3DXCreateEffectFromFile D3DXCreateEffectFromFileA -#endif - - -HRESULT WINAPI - D3DXCreateEffectFromResourceA( - LPDIRECT3DDEVICE8 pDevice, - HMODULE hSrcModule, - LPCSTR pSrcResource, - LPD3DXEFFECT* ppEffect, - LPD3DXBUFFER* ppCompilationErrors); - -HRESULT WINAPI - D3DXCreateEffectFromResourceW( - LPDIRECT3DDEVICE8 pDevice, - HMODULE hSrcModule, - LPCWSTR pSrcResource, - LPD3DXEFFECT* ppEffect, - LPD3DXBUFFER* ppCompilationErrors); - -#ifdef UNICODE -#define D3DXCreateEffectFromResource D3DXCreateEffectFromResourceW -#else -#define D3DXCreateEffectFromResource D3DXCreateEffectFromResourceA -#endif - - -HRESULT WINAPI - D3DXCreateEffect( - LPDIRECT3DDEVICE8 pDevice, - LPCVOID pSrcData, - UINT SrcDataSize, - LPD3DXEFFECT* ppEffect, - LPD3DXBUFFER* ppCompilationErrors); - - -#ifdef __cplusplus -} -#endif //__cplusplus - -#endif //__D3DX8EFFECT_H__ +/////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Microsoft Corporation. All Rights Reserved. +// +// File: d3dx8effect.h +// Content: D3DX effect types and functions +// +/////////////////////////////////////////////////////////////////////////// + +#include "d3dx8.h" + +#ifndef __D3DX8EFFECT_H__ +#define __D3DX8EFFECT_H__ + + +#define D3DXFX_DONOTSAVESTATE (1 << 0) + + +typedef enum _D3DXPARAMETERTYPE +{ + D3DXPT_DWORD = 0, + D3DXPT_FLOAT = 1, + D3DXPT_VECTOR = 2, + D3DXPT_MATRIX = 3, + D3DXPT_TEXTURE = 4, + D3DXPT_VERTEXSHADER = 5, + D3DXPT_PIXELSHADER = 6, + D3DXPT_CONSTANT = 7, + D3DXPT_STRING = 8, + D3DXPT_FORCE_DWORD = 0x7fffffff /* force 32-bit size enum */ + +} D3DXPARAMETERTYPE; + + +typedef struct _D3DXEFFECT_DESC +{ + UINT Parameters; + UINT Techniques; + +} D3DXEFFECT_DESC; + + +typedef struct _D3DXPARAMETER_DESC +{ + LPCSTR Name; + LPCSTR Index; + D3DXPARAMETERTYPE Type; + +} D3DXPARAMETER_DESC; + + +typedef struct _D3DXTECHNIQUE_DESC +{ + LPCSTR Name; + LPCSTR Index; + UINT Passes; + +} D3DXTECHNIQUE_DESC; + + +typedef struct _D3DXPASS_DESC +{ + LPCSTR Name; + LPCSTR Index; + +} D3DXPASS_DESC; + + + +////////////////////////////////////////////////////////////////////////////// +// ID3DXEffect /////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +typedef interface ID3DXEffect ID3DXEffect; +typedef interface ID3DXEffect *LPD3DXEFFECT; + +// {648B1CEB-8D4E-4d66-B6FA-E44969E82E89} +DEFINE_GUID( IID_ID3DXEffect, +0x648b1ceb, 0x8d4e, 0x4d66, 0xb6, 0xfa, 0xe4, 0x49, 0x69, 0xe8, 0x2e, 0x89); + + +#undef INTERFACE +#define INTERFACE ID3DXEffect + +DECLARE_INTERFACE_(ID3DXEffect, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXEffect + STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; + STDMETHOD(GetDesc)(THIS_ D3DXEFFECT_DESC* pDesc) PURE; + STDMETHOD(GetParameterDesc)(THIS_ LPCSTR pParameter, D3DXPARAMETER_DESC* pDesc) PURE; + STDMETHOD(GetTechniqueDesc)(THIS_ LPCSTR pTechnique, D3DXTECHNIQUE_DESC* pDesc) PURE; + STDMETHOD(GetPassDesc)(THIS_ LPCSTR pTechnique, LPCSTR pPass, D3DXPASS_DESC* pDesc) PURE; + STDMETHOD(FindNextValidTechnique)(THIS_ LPCSTR pTechnique, D3DXTECHNIQUE_DESC* pDesc) PURE; + STDMETHOD(CloneEffect)(THIS_ LPDIRECT3DDEVICE8 pDevice, LPD3DXEFFECT* ppEffect) PURE; + STDMETHOD(GetCompiledEffect)(THIS_ LPD3DXBUFFER* ppCompiledEffect) PURE; + + STDMETHOD(SetTechnique)(THIS_ LPCSTR pTechnique) PURE; + STDMETHOD(GetTechnique)(THIS_ LPCSTR* ppTechnique) PURE; + + STDMETHOD(SetDword)(THIS_ LPCSTR pParameter, DWORD dw) PURE; + STDMETHOD(GetDword)(THIS_ LPCSTR pParameter, DWORD* pdw) PURE; + STDMETHOD(SetFloat)(THIS_ LPCSTR pParameter, FLOAT f) PURE; + STDMETHOD(GetFloat)(THIS_ LPCSTR pParameter, FLOAT* pf) PURE; + STDMETHOD(SetVector)(THIS_ LPCSTR pParameter, CONST D3DXVECTOR4* pVector) PURE; + STDMETHOD(GetVector)(THIS_ LPCSTR pParameter, D3DXVECTOR4* pVector) PURE; + STDMETHOD(SetMatrix)(THIS_ LPCSTR pParameter, CONST D3DXMATRIX* pMatrix) PURE; + STDMETHOD(GetMatrix)(THIS_ LPCSTR pParameter, D3DXMATRIX* pMatrix) PURE; + STDMETHOD(SetTexture)(THIS_ LPCSTR pParameter, LPDIRECT3DBASETEXTURE8 pTexture) PURE; + STDMETHOD(GetTexture)(THIS_ LPCSTR pParameter, LPDIRECT3DBASETEXTURE8 *ppTexture) PURE; + STDMETHOD(SetVertexShader)(THIS_ LPCSTR pParameter, DWORD Handle) PURE; + STDMETHOD(GetVertexShader)(THIS_ LPCSTR pParameter, DWORD* pHandle) PURE; + STDMETHOD(SetPixelShader)(THIS_ LPCSTR pParameter, DWORD Handle) PURE; + STDMETHOD(GetPixelShader)(THIS_ LPCSTR pParameter, DWORD* pHandle) PURE; + STDMETHOD(SetString)(THIS_ LPCSTR pParameter, LPCSTR pString) PURE; + STDMETHOD(GetString)(THIS_ LPCSTR pParameter, LPCSTR* ppString) PURE; + STDMETHOD_(BOOL, IsParameterUsed)(THIS_ LPCSTR pParameter) PURE; + + STDMETHOD(Validate)(THIS) PURE; + STDMETHOD(Begin)(THIS_ UINT *pPasses, DWORD Flags) PURE; + STDMETHOD(Pass)(THIS_ UINT Pass) PURE; + STDMETHOD(End)(THIS) PURE; + STDMETHOD(OnLostDevice)(THIS) PURE; + STDMETHOD(OnResetDevice)(THIS) PURE; +}; + + + +////////////////////////////////////////////////////////////////////////////// +// APIs ////////////////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + + +//---------------------------------------------------------------------------- +// D3DXCreateEffect: +// ----------------- +// Creates an effect from an ascii or binaray effect description. +// +// Parameters: +// pDevice +// Pointer of the device on which to create the effect +// pSrcFile +// Name of the file containing the effect description +// hSrcModule +// Module handle. if NULL, current module will be used. +// pSrcResource +// Resource name in module +// pSrcData +// Pointer to effect description +// SrcDataSize +// Size of the effect description in bytes +// ppEffect +// Returns a buffer containing created effect. +// ppCompilationErrors +// Returns a buffer containing any error messages which occurred during +// compile. Or NULL if you do not care about the error messages. +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXCreateEffectFromFileA( + LPDIRECT3DDEVICE8 pDevice, + LPCSTR pSrcFile, + LPD3DXEFFECT* ppEffect, + LPD3DXBUFFER* ppCompilationErrors); + +HRESULT WINAPI + D3DXCreateEffectFromFileW( + LPDIRECT3DDEVICE8 pDevice, + LPCWSTR pSrcFile, + LPD3DXEFFECT* ppEffect, + LPD3DXBUFFER* ppCompilationErrors); + +#ifdef UNICODE +#define D3DXCreateEffectFromFile D3DXCreateEffectFromFileW +#else +#define D3DXCreateEffectFromFile D3DXCreateEffectFromFileA +#endif + + +HRESULT WINAPI + D3DXCreateEffectFromResourceA( + LPDIRECT3DDEVICE8 pDevice, + HMODULE hSrcModule, + LPCSTR pSrcResource, + LPD3DXEFFECT* ppEffect, + LPD3DXBUFFER* ppCompilationErrors); + +HRESULT WINAPI + D3DXCreateEffectFromResourceW( + LPDIRECT3DDEVICE8 pDevice, + HMODULE hSrcModule, + LPCWSTR pSrcResource, + LPD3DXEFFECT* ppEffect, + LPD3DXBUFFER* ppCompilationErrors); + +#ifdef UNICODE +#define D3DXCreateEffectFromResource D3DXCreateEffectFromResourceW +#else +#define D3DXCreateEffectFromResource D3DXCreateEffectFromResourceA +#endif + + +HRESULT WINAPI + D3DXCreateEffect( + LPDIRECT3DDEVICE8 pDevice, + LPCVOID pSrcData, + UINT SrcDataSize, + LPD3DXEFFECT* ppEffect, + LPD3DXBUFFER* ppCompilationErrors); + + +#ifdef __cplusplus +} +#endif //__cplusplus + +#endif //__D3DX8EFFECT_H__ diff --git a/gfx/include/d3d8/d3dx8math.h b/gfx/include/d3d8/d3dx8math.h index fa15ff778a..a1a68fd6b6 100644 --- a/gfx/include/d3d8/d3dx8math.h +++ b/gfx/include/d3d8/d3dx8math.h @@ -1,1213 +1,1213 @@ -////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) Microsoft Corporation. All Rights Reserved. -// -// File: d3dx8math.h -// Content: D3DX math types and functions -// -////////////////////////////////////////////////////////////////////////////// - -#include "d3dx8.h" - -#ifndef __D3DX8MATH_H__ -#define __D3DX8MATH_H__ - -#include -#pragma warning(disable:4201) /* anonymous unions warning */ - -//=========================================================================== -// -// General purpose utilities -// -//=========================================================================== -#define D3DX_PI ((FLOAT) 3.141592654f) -#define D3DX_1BYPI ((FLOAT) 0.318309886f) - -#define D3DXToRadian( degree ) ((degree) * (D3DX_PI / 180.0f)) -#define D3DXToDegree( radian ) ((radian) * (180.0f / D3DX_PI)) - - - -//=========================================================================== -// -// Vectors -// -//=========================================================================== - -//-------------------------- -// 2D Vector -//-------------------------- -typedef struct D3DXVECTOR2 -{ -#ifdef __cplusplus -public: - D3DXVECTOR2() {}; - D3DXVECTOR2( CONST FLOAT * ); - D3DXVECTOR2( FLOAT x, FLOAT y ); - - // casting - operator FLOAT* (); - operator CONST FLOAT* () const; - - // assignment operators - D3DXVECTOR2& operator += ( CONST D3DXVECTOR2& ); - D3DXVECTOR2& operator -= ( CONST D3DXVECTOR2& ); - D3DXVECTOR2& operator *= ( FLOAT ); - D3DXVECTOR2& operator /= ( FLOAT ); - - // unary operators - D3DXVECTOR2 operator + () const; - D3DXVECTOR2 operator - () const; - - // binary operators - D3DXVECTOR2 operator + ( CONST D3DXVECTOR2& ) const; - D3DXVECTOR2 operator - ( CONST D3DXVECTOR2& ) const; - D3DXVECTOR2 operator * ( FLOAT ) const; - D3DXVECTOR2 operator / ( FLOAT ) const; - - friend D3DXVECTOR2 operator * ( FLOAT, CONST D3DXVECTOR2& ); - - BOOL operator == ( CONST D3DXVECTOR2& ) const; - BOOL operator != ( CONST D3DXVECTOR2& ) const; - - -public: -#endif //__cplusplus - FLOAT x, y; -} D3DXVECTOR2, *LPD3DXVECTOR2; - - -//-------------------------- -// 3D Vector -//-------------------------- -#ifdef __cplusplus -typedef struct D3DXVECTOR3 : public D3DVECTOR -{ -public: - D3DXVECTOR3() {}; - D3DXVECTOR3( CONST FLOAT * ); - D3DXVECTOR3( CONST D3DVECTOR& ); - D3DXVECTOR3( FLOAT x, FLOAT y, FLOAT z ); - - // casting - operator FLOAT* (); - operator CONST FLOAT* () const; - - // assignment operators - D3DXVECTOR3& operator += ( CONST D3DXVECTOR3& ); - D3DXVECTOR3& operator -= ( CONST D3DXVECTOR3& ); - D3DXVECTOR3& operator *= ( FLOAT ); - D3DXVECTOR3& operator /= ( FLOAT ); - - // unary operators - D3DXVECTOR3 operator + () const; - D3DXVECTOR3 operator - () const; - - // binary operators - D3DXVECTOR3 operator + ( CONST D3DXVECTOR3& ) const; - D3DXVECTOR3 operator - ( CONST D3DXVECTOR3& ) const; - D3DXVECTOR3 operator * ( FLOAT ) const; - D3DXVECTOR3 operator / ( FLOAT ) const; - - friend D3DXVECTOR3 operator * ( FLOAT, CONST struct D3DXVECTOR3& ); - - BOOL operator == ( CONST D3DXVECTOR3& ) const; - BOOL operator != ( CONST D3DXVECTOR3& ) const; - -} D3DXVECTOR3, *LPD3DXVECTOR3; - -#else //!__cplusplus -typedef struct _D3DVECTOR D3DXVECTOR3, *LPD3DXVECTOR3; -#endif //!__cplusplus - - -//-------------------------- -// 4D Vector -//-------------------------- -typedef struct D3DXVECTOR4 -{ -#ifdef __cplusplus -public: - D3DXVECTOR4() {}; - D3DXVECTOR4( CONST FLOAT* ); - D3DXVECTOR4( FLOAT x, FLOAT y, FLOAT z, FLOAT w ); - - // casting - operator FLOAT* (); - operator CONST FLOAT* () const; - - // assignment operators - D3DXVECTOR4& operator += ( CONST D3DXVECTOR4& ); - D3DXVECTOR4& operator -= ( CONST D3DXVECTOR4& ); - D3DXVECTOR4& operator *= ( FLOAT ); - D3DXVECTOR4& operator /= ( FLOAT ); - - // unary operators - D3DXVECTOR4 operator + () const; - D3DXVECTOR4 operator - () const; - - // binary operators - D3DXVECTOR4 operator + ( CONST D3DXVECTOR4& ) const; - D3DXVECTOR4 operator - ( CONST D3DXVECTOR4& ) const; - D3DXVECTOR4 operator * ( FLOAT ) const; - D3DXVECTOR4 operator / ( FLOAT ) const; - - friend D3DXVECTOR4 operator * ( FLOAT, CONST D3DXVECTOR4& ); - - BOOL operator == ( CONST D3DXVECTOR4& ) const; - BOOL operator != ( CONST D3DXVECTOR4& ) const; - -public: -#endif //__cplusplus - FLOAT x, y, z, w; -} D3DXVECTOR4, *LPD3DXVECTOR4; - - -//=========================================================================== -// -// Matrices -// -//=========================================================================== -#ifdef __cplusplus -typedef struct D3DXMATRIX : public D3DMATRIX -{ -public: - D3DXMATRIX() {}; - D3DXMATRIX( CONST FLOAT * ); - D3DXMATRIX( CONST D3DMATRIX& ); - D3DXMATRIX( FLOAT _11, FLOAT _12, FLOAT _13, FLOAT _14, - FLOAT _21, FLOAT _22, FLOAT _23, FLOAT _24, - FLOAT _31, FLOAT _32, FLOAT _33, FLOAT _34, - FLOAT _41, FLOAT _42, FLOAT _43, FLOAT _44 ); - - - // access grants - FLOAT& operator () ( UINT Row, UINT Col ); - FLOAT operator () ( UINT Row, UINT Col ) const; - - // casting operators - operator FLOAT* (); - operator CONST FLOAT* () const; - - // assignment operators - D3DXMATRIX& operator *= ( CONST D3DXMATRIX& ); - D3DXMATRIX& operator += ( CONST D3DXMATRIX& ); - D3DXMATRIX& operator -= ( CONST D3DXMATRIX& ); - D3DXMATRIX& operator *= ( FLOAT ); - D3DXMATRIX& operator /= ( FLOAT ); - - // unary operators - D3DXMATRIX operator + () const; - D3DXMATRIX operator - () const; - - // binary operators - D3DXMATRIX operator * ( CONST D3DXMATRIX& ) const; - D3DXMATRIX operator + ( CONST D3DXMATRIX& ) const; - D3DXMATRIX operator - ( CONST D3DXMATRIX& ) const; - D3DXMATRIX operator * ( FLOAT ) const; - D3DXMATRIX operator / ( FLOAT ) const; - - friend D3DXMATRIX operator * ( FLOAT, CONST D3DXMATRIX& ); - - BOOL operator == ( CONST D3DXMATRIX& ) const; - BOOL operator != ( CONST D3DXMATRIX& ) const; - -} D3DXMATRIX, *LPD3DXMATRIX; - -#else //!__cplusplus -typedef struct _D3DMATRIX D3DXMATRIX, *LPD3DXMATRIX; -#endif //!__cplusplus - -//=========================================================================== -// -// Aligned Matrices -// -// This class helps keep matrices 16-byte aligned as preferred by P4 cpus. -// It aligns matrices on the stack and on the heap or in global scope. -// It does this using __declspec(align(16)) which works on VC7 and on VC 6 -// with the processor pack. Unfortunately there is no way to detect the -// latter so this is turned on only on VC7. On other compilers this is the -// the same as D3DXMATRIX. -// Using this class on a compiler that does not actually do the alignment -// can be dangerous since it will not expose bugs that ignore alignment. -// E.g if an object of this class in inside a struct or class, and some code -// memcopys data in it assuming tight packing. This could break on a compiler -// that eventually start aligning the matrix. -// -//=========================================================================== -#ifdef __cplusplus -typedef struct _D3DXMATRIXA16 : public D3DXMATRIX -{ - _D3DXMATRIXA16() {} - _D3DXMATRIXA16( CONST FLOAT * f): D3DXMATRIX(f) {} - _D3DXMATRIXA16( CONST D3DMATRIX& m): D3DXMATRIX(m) {} - _D3DXMATRIXA16( FLOAT _11, FLOAT _12, FLOAT _13, FLOAT _14, - FLOAT _21, FLOAT _22, FLOAT _23, FLOAT _24, - FLOAT _31, FLOAT _32, FLOAT _33, FLOAT _34, - FLOAT _41, FLOAT _42, FLOAT _43, FLOAT _44 ) : - D3DXMATRIX(_11, _12, _13, _14, - _21, _22, _23, _24, - _31, _32, _33, _34, - _41, _42, _43, _44) {} - void* operator new(size_t s) - { - LPBYTE p = ::new BYTE[s + 16]; - if (p) - { - BYTE offset = (BYTE)(16 - ((UINT_PTR)p & 15)); - p += offset; - p[-1] = offset; - } - return p; - }; - - void* operator new[](size_t s) - { - LPBYTE p = ::new BYTE[s + 16]; - if (p) - { - BYTE offset = (BYTE)(16 - ((UINT_PTR)p & 15)); - p += offset; - p[-1] = offset; - } - return p; - }; - - // This is NOT a virtual operator. If you cast - // to D3DXMATRIX, do not delete using that - void operator delete(void* p) - { - if(p) - { - BYTE* pb = static_cast(p); - pb -= pb[-1]; - ::delete [] pb; - } - }; - - // This is NOT a virtual operator. If you cast - // to D3DXMATRIX, do not delete using that - void operator delete[](void* p) - { - if(p) - { - BYTE* pb = static_cast(p); - pb -= pb[-1]; - ::delete [] pb; - } - }; - - struct _D3DXMATRIXA16& operator=(CONST D3DXMATRIX& rhs) - { - memcpy(&_11, &rhs, sizeof(D3DXMATRIX)); - return *this; - }; -} _D3DXMATRIXA16; - -#else //!__cplusplus -typedef D3DXMATRIX _D3DXMATRIXA16; -#endif //!__cplusplus - -#if _MSC_VER >= 1300 // VC7 -#define _ALIGN_16 __declspec(align(16)) -#else -#define _ALIGN_16 // Earlier compiler may not understand this, do nothing. -#endif - -#define D3DXMATRIXA16 _ALIGN_16 _D3DXMATRIXA16 - -typedef D3DXMATRIXA16 *LPD3DXMATRIXA16; - -//=========================================================================== -// -// Quaternions -// -//=========================================================================== -typedef struct D3DXQUATERNION -{ -#ifdef __cplusplus -public: - D3DXQUATERNION() {} - D3DXQUATERNION( CONST FLOAT * ); - D3DXQUATERNION( FLOAT x, FLOAT y, FLOAT z, FLOAT w ); - - // casting - operator FLOAT* (); - operator CONST FLOAT* () const; - - // assignment operators - D3DXQUATERNION& operator += ( CONST D3DXQUATERNION& ); - D3DXQUATERNION& operator -= ( CONST D3DXQUATERNION& ); - D3DXQUATERNION& operator *= ( CONST D3DXQUATERNION& ); - D3DXQUATERNION& operator *= ( FLOAT ); - D3DXQUATERNION& operator /= ( FLOAT ); - - // unary operators - D3DXQUATERNION operator + () const; - D3DXQUATERNION operator - () const; - - // binary operators - D3DXQUATERNION operator + ( CONST D3DXQUATERNION& ) const; - D3DXQUATERNION operator - ( CONST D3DXQUATERNION& ) const; - D3DXQUATERNION operator * ( CONST D3DXQUATERNION& ) const; - D3DXQUATERNION operator * ( FLOAT ) const; - D3DXQUATERNION operator / ( FLOAT ) const; - - friend D3DXQUATERNION operator * (FLOAT, CONST D3DXQUATERNION& ); - - BOOL operator == ( CONST D3DXQUATERNION& ) const; - BOOL operator != ( CONST D3DXQUATERNION& ) const; - -#endif //__cplusplus - FLOAT x, y, z, w; -} D3DXQUATERNION, *LPD3DXQUATERNION; - - -//=========================================================================== -// -// Planes -// -//=========================================================================== -typedef struct D3DXPLANE -{ -#ifdef __cplusplus -public: - D3DXPLANE() {} - D3DXPLANE( CONST FLOAT* ); - D3DXPLANE( FLOAT a, FLOAT b, FLOAT c, FLOAT d ); - - // casting - operator FLOAT* (); - operator CONST FLOAT* () const; - - // unary operators - D3DXPLANE operator + () const; - D3DXPLANE operator - () const; - - // binary operators - BOOL operator == ( CONST D3DXPLANE& ) const; - BOOL operator != ( CONST D3DXPLANE& ) const; - -#endif //__cplusplus - FLOAT a, b, c, d; -} D3DXPLANE, *LPD3DXPLANE; - - -//=========================================================================== -// -// Colors -// -//=========================================================================== - -typedef struct D3DXCOLOR -{ -#ifdef __cplusplus -public: - D3DXCOLOR() {} - D3DXCOLOR( DWORD argb ); - D3DXCOLOR( CONST FLOAT * ); - D3DXCOLOR( CONST D3DCOLORVALUE& ); - D3DXCOLOR( FLOAT r, FLOAT g, FLOAT b, FLOAT a ); - - // casting - operator DWORD () const; - - operator FLOAT* (); - operator CONST FLOAT* () const; - - operator D3DCOLORVALUE* (); - operator CONST D3DCOLORVALUE* () const; - - operator D3DCOLORVALUE& (); - operator CONST D3DCOLORVALUE& () const; - - // assignment operators - D3DXCOLOR& operator += ( CONST D3DXCOLOR& ); - D3DXCOLOR& operator -= ( CONST D3DXCOLOR& ); - D3DXCOLOR& operator *= ( FLOAT ); - D3DXCOLOR& operator /= ( FLOAT ); - - // unary operators - D3DXCOLOR operator + () const; - D3DXCOLOR operator - () const; - - // binary operators - D3DXCOLOR operator + ( CONST D3DXCOLOR& ) const; - D3DXCOLOR operator - ( CONST D3DXCOLOR& ) const; - D3DXCOLOR operator * ( FLOAT ) const; - D3DXCOLOR operator / ( FLOAT ) const; - - friend D3DXCOLOR operator * (FLOAT, CONST D3DXCOLOR& ); - - BOOL operator == ( CONST D3DXCOLOR& ) const; - BOOL operator != ( CONST D3DXCOLOR& ) const; - -#endif //__cplusplus - FLOAT r, g, b, a; -} D3DXCOLOR, *LPD3DXCOLOR; - - - -//=========================================================================== -// -// D3DX math functions: -// -// NOTE: -// * All these functions can take the same object as in and out parameters. -// -// * Out parameters are typically also returned as return values, so that -// the output of one function may be used as a parameter to another. -// -//=========================================================================== - -//-------------------------- -// 2D Vector -//-------------------------- - -// inline - -FLOAT D3DXVec2Length - ( CONST D3DXVECTOR2 *pV ); - -FLOAT D3DXVec2LengthSq - ( CONST D3DXVECTOR2 *pV ); - -FLOAT D3DXVec2Dot - ( CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); - -// Z component of ((x1,y1,0) cross (x2,y2,0)) -FLOAT D3DXVec2CCW - ( CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); - -D3DXVECTOR2* D3DXVec2Add - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); - -D3DXVECTOR2* D3DXVec2Subtract - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); - -// Minimize each component. x = min(x1, x2), y = min(y1, y2) -D3DXVECTOR2* D3DXVec2Minimize - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); - -// Maximize each component. x = max(x1, x2), y = max(y1, y2) -D3DXVECTOR2* D3DXVec2Maximize - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); - -D3DXVECTOR2* D3DXVec2Scale - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, FLOAT s ); - -// Linear interpolation. V1 + s(V2-V1) -D3DXVECTOR2* D3DXVec2Lerp - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2, - FLOAT s ); - -// non-inline -#ifdef __cplusplus -extern "C" { -#endif - -D3DXVECTOR2* WINAPI D3DXVec2Normalize - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV ); - -// Hermite interpolation between position V1, tangent T1 (when s == 0) -// and position V2, tangent T2 (when s == 1). -D3DXVECTOR2* WINAPI D3DXVec2Hermite - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pT1, - CONST D3DXVECTOR2 *pV2, CONST D3DXVECTOR2 *pT2, FLOAT s ); - -// CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1) -D3DXVECTOR2* WINAPI D3DXVec2CatmullRom - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV0, CONST D3DXVECTOR2 *pV1, - CONST D3DXVECTOR2 *pV2, CONST D3DXVECTOR2 *pV3, FLOAT s ); - -// Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) -D3DXVECTOR2* WINAPI D3DXVec2BaryCentric - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2, - CONST D3DXVECTOR2 *pV3, FLOAT f, FLOAT g); - -// Transform (x, y, 0, 1) by matrix. -D3DXVECTOR4* WINAPI D3DXVec2Transform - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR2 *pV, CONST D3DXMATRIX *pM ); - -// Transform (x, y, 0, 1) by matrix, project result back into w=1. -D3DXVECTOR2* WINAPI D3DXVec2TransformCoord - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, CONST D3DXMATRIX *pM ); - -// Transform (x, y, 0, 0) by matrix. -D3DXVECTOR2* WINAPI D3DXVec2TransformNormal - ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, CONST D3DXMATRIX *pM ); - -#ifdef __cplusplus -} -#endif - - -//-------------------------- -// 3D Vector -//-------------------------- - -// inline - -FLOAT D3DXVec3Length - ( CONST D3DXVECTOR3 *pV ); - -FLOAT D3DXVec3LengthSq - ( CONST D3DXVECTOR3 *pV ); - -FLOAT D3DXVec3Dot - ( CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); - -D3DXVECTOR3* D3DXVec3Cross - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); - -D3DXVECTOR3* D3DXVec3Add - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); - -D3DXVECTOR3* D3DXVec3Subtract - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); - -// Minimize each component. x = min(x1, x2), y = min(y1, y2), ... -D3DXVECTOR3* D3DXVec3Minimize - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); - -// Maximize each component. x = max(x1, x2), y = max(y1, y2), ... -D3DXVECTOR3* D3DXVec3Maximize - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); - -D3DXVECTOR3* D3DXVec3Scale - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, FLOAT s); - -// Linear interpolation. V1 + s(V2-V1) -D3DXVECTOR3* D3DXVec3Lerp - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, - FLOAT s ); - -// non-inline -#ifdef __cplusplus -extern "C" { -#endif - -D3DXVECTOR3* WINAPI D3DXVec3Normalize - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV ); - -// Hermite interpolation between position V1, tangent T1 (when s == 0) -// and position V2, tangent T2 (when s == 1). -D3DXVECTOR3* WINAPI D3DXVec3Hermite - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pT1, - CONST D3DXVECTOR3 *pV2, CONST D3DXVECTOR3 *pT2, FLOAT s ); - -// CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1) -D3DXVECTOR3* WINAPI D3DXVec3CatmullRom - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV0, CONST D3DXVECTOR3 *pV1, - CONST D3DXVECTOR3 *pV2, CONST D3DXVECTOR3 *pV3, FLOAT s ); - -// Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) -D3DXVECTOR3* WINAPI D3DXVec3BaryCentric - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, - CONST D3DXVECTOR3 *pV3, FLOAT f, FLOAT g); - -// Transform (x, y, z, 1) by matrix. -D3DXVECTOR4* WINAPI D3DXVec3Transform - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM ); - -// Transform (x, y, z, 1) by matrix, project result back into w=1. -D3DXVECTOR3* WINAPI D3DXVec3TransformCoord - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM ); - -// Transform (x, y, z, 0) by matrix. If you transforming a normal by a -// non-affine matrix, the matrix you pass to this function should be the -// transpose of the inverse of the matrix you would use to transform a coord. -D3DXVECTOR3* WINAPI D3DXVec3TransformNormal - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM ); - -// Project vector from object space into screen space -D3DXVECTOR3* WINAPI D3DXVec3Project - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DVIEWPORT8 *pViewport, - CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld); - -// Project vector from screen space into object space -D3DXVECTOR3* WINAPI D3DXVec3Unproject - ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DVIEWPORT8 *pViewport, - CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld); - -#ifdef __cplusplus -} -#endif - - - -//-------------------------- -// 4D Vector -//-------------------------- - -// inline - -FLOAT D3DXVec4Length - ( CONST D3DXVECTOR4 *pV ); - -FLOAT D3DXVec4LengthSq - ( CONST D3DXVECTOR4 *pV ); - -FLOAT D3DXVec4Dot - ( CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2 ); - -D3DXVECTOR4* D3DXVec4Add - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2); - -D3DXVECTOR4* D3DXVec4Subtract - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2); - -// Minimize each component. x = min(x1, x2), y = min(y1, y2), ... -D3DXVECTOR4* D3DXVec4Minimize - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2); - -// Maximize each component. x = max(x1, x2), y = max(y1, y2), ... -D3DXVECTOR4* D3DXVec4Maximize - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2); - -D3DXVECTOR4* D3DXVec4Scale - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV, FLOAT s); - -// Linear interpolation. V1 + s(V2-V1) -D3DXVECTOR4* D3DXVec4Lerp - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2, - FLOAT s ); - -// non-inline -#ifdef __cplusplus -extern "C" { -#endif - -// Cross-product in 4 dimensions. -D3DXVECTOR4* WINAPI D3DXVec4Cross - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2, - CONST D3DXVECTOR4 *pV3); - -D3DXVECTOR4* WINAPI D3DXVec4Normalize - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV ); - -// Hermite interpolation between position V1, tangent T1 (when s == 0) -// and position V2, tangent T2 (when s == 1). -D3DXVECTOR4* WINAPI D3DXVec4Hermite - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pT1, - CONST D3DXVECTOR4 *pV2, CONST D3DXVECTOR4 *pT2, FLOAT s ); - -// CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1) -D3DXVECTOR4* WINAPI D3DXVec4CatmullRom - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV0, CONST D3DXVECTOR4 *pV1, - CONST D3DXVECTOR4 *pV2, CONST D3DXVECTOR4 *pV3, FLOAT s ); - -// Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) -D3DXVECTOR4* WINAPI D3DXVec4BaryCentric - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2, - CONST D3DXVECTOR4 *pV3, FLOAT f, FLOAT g); - -// Transform vector by matrix. -D3DXVECTOR4* WINAPI D3DXVec4Transform - ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV, CONST D3DXMATRIX *pM ); - -#ifdef __cplusplus -} -#endif - - -//-------------------------- -// 4D Matrix -//-------------------------- - -// inline - -D3DXMATRIX* D3DXMatrixIdentity - ( D3DXMATRIX *pOut ); - -BOOL D3DXMatrixIsIdentity - ( CONST D3DXMATRIX *pM ); - - -// non-inline -#ifdef __cplusplus -extern "C" { -#endif - -FLOAT WINAPI D3DXMatrixfDeterminant - ( CONST D3DXMATRIX *pM ); - -D3DXMATRIX* WINAPI D3DXMatrixTranspose - ( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM ); - -// Matrix multiplication. The result represents the transformation M2 -// followed by the transformation M1. (Out = M1 * M2) -D3DXMATRIX* WINAPI D3DXMatrixMultiply - ( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM1, CONST D3DXMATRIX *pM2 ); - -// Matrix multiplication, followed by a transpose. (Out = T(M1 * M2)) -D3DXMATRIX* WINAPI D3DXMatrixMultiplyTranspose - ( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM1, CONST D3DXMATRIX *pM2 ); - -// Calculate inverse of matrix. Inversion my fail, in which case NULL will -// be returned. The determinant of pM is also returned it pfDeterminant -// is non-NULL. -D3DXMATRIX* WINAPI D3DXMatrixInverse - ( D3DXMATRIX *pOut, FLOAT *pDeterminant, CONST D3DXMATRIX *pM ); - -// Build a matrix which scales by (sx, sy, sz) -D3DXMATRIX* WINAPI D3DXMatrixScaling - ( D3DXMATRIX *pOut, FLOAT sx, FLOAT sy, FLOAT sz ); - -// Build a matrix which translates by (x, y, z) -D3DXMATRIX* WINAPI D3DXMatrixTranslation - ( D3DXMATRIX *pOut, FLOAT x, FLOAT y, FLOAT z ); - -// Build a matrix which rotates around the X axis -D3DXMATRIX* WINAPI D3DXMatrixRotationX - ( D3DXMATRIX *pOut, FLOAT Angle ); - -// Build a matrix which rotates around the Y axis -D3DXMATRIX* WINAPI D3DXMatrixRotationY - ( D3DXMATRIX *pOut, FLOAT Angle ); - -// Build a matrix which rotates around the Z axis -D3DXMATRIX* WINAPI D3DXMatrixRotationZ - ( D3DXMATRIX *pOut, FLOAT Angle ); - -// Build a matrix which rotates around an arbitrary axis -D3DXMATRIX* WINAPI D3DXMatrixRotationAxis - ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pV, FLOAT Angle ); - -// Build a matrix from a quaternion -D3DXMATRIX* WINAPI D3DXMatrixRotationQuaternion - ( D3DXMATRIX *pOut, CONST D3DXQUATERNION *pQ); - -// Yaw around the Y axis, a pitch around the X axis, -// and a roll around the Z axis. -D3DXMATRIX* WINAPI D3DXMatrixRotationYawPitchRoll - ( D3DXMATRIX *pOut, FLOAT Yaw, FLOAT Pitch, FLOAT Roll ); - - -// Build transformation matrix. NULL arguments are treated as identity. -// Mout = Msc-1 * Msr-1 * Ms * Msr * Msc * Mrc-1 * Mr * Mrc * Mt -D3DXMATRIX* WINAPI D3DXMatrixTransformation - ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pScalingCenter, - CONST D3DXQUATERNION *pScalingRotation, CONST D3DXVECTOR3 *pScaling, - CONST D3DXVECTOR3 *pRotationCenter, CONST D3DXQUATERNION *pRotation, - CONST D3DXVECTOR3 *pTranslation); - -// Build affine transformation matrix. NULL arguments are treated as identity. -// Mout = Ms * Mrc-1 * Mr * Mrc * Mt -D3DXMATRIX* WINAPI D3DXMatrixAffineTransformation - ( D3DXMATRIX *pOut, FLOAT Scaling, CONST D3DXVECTOR3 *pRotationCenter, - CONST D3DXQUATERNION *pRotation, CONST D3DXVECTOR3 *pTranslation); - -// Build a lookat matrix. (right-handed) -D3DXMATRIX* WINAPI D3DXMatrixLookAtRH - ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pEye, CONST D3DXVECTOR3 *pAt, - CONST D3DXVECTOR3 *pUp ); - -// Build a lookat matrix. (left-handed) -D3DXMATRIX* WINAPI D3DXMatrixLookAtLH - ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pEye, CONST D3DXVECTOR3 *pAt, - CONST D3DXVECTOR3 *pUp ); - -// Build a perspective projection matrix. (right-handed) -D3DXMATRIX* WINAPI D3DXMatrixPerspectiveRH - ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); - -// Build a perspective projection matrix. (left-handed) -D3DXMATRIX* WINAPI D3DXMatrixPerspectiveLH - ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); - -// Build a perspective projection matrix. (right-handed) -D3DXMATRIX* WINAPI D3DXMatrixPerspectiveFovRH - ( D3DXMATRIX *pOut, FLOAT fovy, FLOAT Aspect, FLOAT zn, FLOAT zf ); - -// Build a perspective projection matrix. (left-handed) -D3DXMATRIX* WINAPI D3DXMatrixPerspectiveFovLH - ( D3DXMATRIX *pOut, FLOAT fovy, FLOAT Aspect, FLOAT zn, FLOAT zf ); - -// Build a perspective projection matrix. (right-handed) -D3DXMATRIX* WINAPI D3DXMatrixPerspectiveOffCenterRH - ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, - FLOAT zf ); - -// Build a perspective projection matrix. (left-handed) -D3DXMATRIX* WINAPI D3DXMatrixPerspectiveOffCenterLH - ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, - FLOAT zf ); - -// Build an ortho projection matrix. (right-handed) -D3DXMATRIX* WINAPI D3DXMatrixOrthoRH - ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); - -// Build an ortho projection matrix. (left-handed) -D3DXMATRIX* WINAPI D3DXMatrixOrthoLH - ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); - -// Build an ortho projection matrix. (right-handed) -D3DXMATRIX* WINAPI D3DXMatrixOrthoOffCenterRH - ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, - FLOAT zf ); - -// Build an ortho projection matrix. (left-handed) -D3DXMATRIX* WINAPI D3DXMatrixOrthoOffCenterLH - ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, - FLOAT zf ); - -// Build a matrix which flattens geometry into a plane, as if casting -// a shadow from a light. -D3DXMATRIX* WINAPI D3DXMatrixShadow - ( D3DXMATRIX *pOut, CONST D3DXVECTOR4 *pLight, - CONST D3DXPLANE *pPlane ); - -// Build a matrix which reflects the coordinate system about a plane -D3DXMATRIX* WINAPI D3DXMatrixReflect - ( D3DXMATRIX *pOut, CONST D3DXPLANE *pPlane ); - -#ifdef __cplusplus -} -#endif - - -//-------------------------- -// Quaternion -//-------------------------- - -// inline - -FLOAT D3DXQuaternionLength - ( CONST D3DXQUATERNION *pQ ); - -// Length squared, or "norm" -FLOAT D3DXQuaternionLengthSq - ( CONST D3DXQUATERNION *pQ ); - -FLOAT D3DXQuaternionDot - ( CONST D3DXQUATERNION *pQ1, CONST D3DXQUATERNION *pQ2 ); - -// (0, 0, 0, 1) -D3DXQUATERNION* D3DXQuaternionIdentity - ( D3DXQUATERNION *pOut ); - -BOOL D3DXQuaternionIsIdentity - ( CONST D3DXQUATERNION *pQ ); - -// (-x, -y, -z, w) -D3DXQUATERNION* D3DXQuaternionConjugate - ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); - - -// non-inline -#ifdef __cplusplus -extern "C" { -#endif - -// Compute a quaternin's axis and angle of rotation. Expects unit quaternions. -void WINAPI D3DXQuaternionToAxisAngle - ( CONST D3DXQUATERNION *pQ, D3DXVECTOR3 *pAxis, FLOAT *pAngle ); - -// Build a quaternion from a rotation matrix. -D3DXQUATERNION* WINAPI D3DXQuaternionRotationMatrix - ( D3DXQUATERNION *pOut, CONST D3DXMATRIX *pM); - -// Rotation about arbitrary axis. -D3DXQUATERNION* WINAPI D3DXQuaternionRotationAxis - ( D3DXQUATERNION *pOut, CONST D3DXVECTOR3 *pV, FLOAT Angle ); - -// Yaw around the Y axis, a pitch around the X axis, -// and a roll around the Z axis. -D3DXQUATERNION* WINAPI D3DXQuaternionRotationYawPitchRoll - ( D3DXQUATERNION *pOut, FLOAT Yaw, FLOAT Pitch, FLOAT Roll ); - -// Quaternion multiplication. The result represents the rotation Q2 -// followed by the rotation Q1. (Out = Q2 * Q1) -D3DXQUATERNION* WINAPI D3DXQuaternionMultiply - ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, - CONST D3DXQUATERNION *pQ2 ); - -D3DXQUATERNION* WINAPI D3DXQuaternionNormalize - ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); - -// Conjugate and re-norm -D3DXQUATERNION* WINAPI D3DXQuaternionInverse - ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); - -// Expects unit quaternions. -// if q = (cos(theta), sin(theta) * v); ln(q) = (0, theta * v) -D3DXQUATERNION* WINAPI D3DXQuaternionLn - ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); - -// Expects pure quaternions. (w == 0) w is ignored in calculation. -// if q = (0, theta * v); exp(q) = (cos(theta), sin(theta) * v) -D3DXQUATERNION* WINAPI D3DXQuaternionExp - ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); - -// Spherical linear interpolation between Q1 (t == 0) and Q2 (t == 1). -// Expects unit quaternions. -D3DXQUATERNION* WINAPI D3DXQuaternionSlerp - ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, - CONST D3DXQUATERNION *pQ2, FLOAT t ); - -// Spherical quadrangle interpolation. -// Slerp(Slerp(Q1, C, t), Slerp(A, B, t), 2t(1-t)) -D3DXQUATERNION* WINAPI D3DXQuaternionSquad - ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, - CONST D3DXQUATERNION *pA, CONST D3DXQUATERNION *pB, - CONST D3DXQUATERNION *pC, FLOAT t ); - -// Setup control points for spherical quadrangle interpolation -// from Q1 to Q2. The control points are chosen in such a way -// to ensure the continuity of tangents with adjacent segments. -void WINAPI D3DXQuaternionSquadSetup - ( D3DXQUATERNION *pAOut, D3DXQUATERNION *pBOut, D3DXQUATERNION *pCOut, - CONST D3DXQUATERNION *pQ0, CONST D3DXQUATERNION *pQ1, - CONST D3DXQUATERNION *pQ2, CONST D3DXQUATERNION *pQ3 ); - -// Barycentric interpolation. -// Slerp(Slerp(Q1, Q2, f+g), Slerp(Q1, Q3, f+g), g/(f+g)) -D3DXQUATERNION* WINAPI D3DXQuaternionBaryCentric - ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, - CONST D3DXQUATERNION *pQ2, CONST D3DXQUATERNION *pQ3, - FLOAT f, FLOAT g ); - -#ifdef __cplusplus -} -#endif - - -//-------------------------- -// Plane -//-------------------------- - -// inline - -// ax + by + cz + dw -FLOAT D3DXPlaneDot - ( CONST D3DXPLANE *pP, CONST D3DXVECTOR4 *pV); - -// ax + by + cz + d -FLOAT D3DXPlaneDotCoord - ( CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV); - -// ax + by + cz -FLOAT D3DXPlaneDotNormal - ( CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV); - -// non-inline -#ifdef __cplusplus -extern "C" { -#endif - -// Normalize plane (so that |a,b,c| == 1) -D3DXPLANE* WINAPI D3DXPlaneNormalize - ( D3DXPLANE *pOut, CONST D3DXPLANE *pP); - -// Find the intersection between a plane and a line. If the line is -// parallel to the plane, NULL is returned. -D3DXVECTOR3* WINAPI D3DXPlaneIntersectLine - ( D3DXVECTOR3 *pOut, CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV1, - CONST D3DXVECTOR3 *pV2); - -// Construct a plane from a point and a normal -D3DXPLANE* WINAPI D3DXPlaneFromPointNormal - ( D3DXPLANE *pOut, CONST D3DXVECTOR3 *pPoint, CONST D3DXVECTOR3 *pNormal); - -// Construct a plane from 3 points -D3DXPLANE* WINAPI D3DXPlaneFromPoints - ( D3DXPLANE *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, - CONST D3DXVECTOR3 *pV3); - -// Transform a plane by a matrix. The vector (a,b,c) must be normal. -// M should be the inverse transpose of the transformation desired. -D3DXPLANE* WINAPI D3DXPlaneTransform - ( D3DXPLANE *pOut, CONST D3DXPLANE *pP, CONST D3DXMATRIX *pM ); - -#ifdef __cplusplus -} -#endif - - -//-------------------------- -// Color -//-------------------------- - -// inline - -// (1-r, 1-g, 1-b, a) -D3DXCOLOR* D3DXColorNegative - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC); - -D3DXCOLOR* D3DXColorAdd - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2); - -D3DXCOLOR* D3DXColorSubtract - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2); - -D3DXCOLOR* D3DXColorScale - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT s); - -// (r1*r2, g1*g2, b1*b2, a1*a2) -D3DXCOLOR* D3DXColorModulate - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2); - -// Linear interpolation of r,g,b, and a. C1 + s(C2-C1) -D3DXCOLOR* D3DXColorLerp - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2, FLOAT s); - -// non-inline -#ifdef __cplusplus -extern "C" { -#endif - -// Interpolate r,g,b between desaturated color and color. -// DesaturatedColor + s(Color - DesaturatedColor) -D3DXCOLOR* WINAPI D3DXColorAdjustSaturation - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT s); - -// Interpolate r,g,b between 50% grey and color. Grey + s(Color - Grey) -D3DXCOLOR* WINAPI D3DXColorAdjustContrast - (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT c); - -#ifdef __cplusplus -} -#endif - - - - -//-------------------------- -// Misc -//-------------------------- - -#ifdef __cplusplus -extern "C" { -#endif - -// Calculate Fresnel term given the cosine of theta (likely obtained by -// taking the dot of two normals), and the refraction index of the material. -FLOAT WINAPI D3DXFresnelTerm - (FLOAT CosTheta, FLOAT RefractionIndex); - -#ifdef __cplusplus -} -#endif - - - -//=========================================================================== -// -// Matrix Stack -// -//=========================================================================== - -typedef interface ID3DXMatrixStack ID3DXMatrixStack; -typedef interface ID3DXMatrixStack *LPD3DXMATRIXSTACK; - -// {E3357330-CC5E-11d2-A434-00A0C90629A8} -DEFINE_GUID( IID_ID3DXMatrixStack, -0xe3357330, 0xcc5e, 0x11d2, 0xa4, 0x34, 0x0, 0xa0, 0xc9, 0x6, 0x29, 0xa8); - - -#undef INTERFACE -#define INTERFACE ID3DXMatrixStack - -DECLARE_INTERFACE_(ID3DXMatrixStack, IUnknown) -{ - // - // IUnknown methods - // - STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; - STDMETHOD_(ULONG,AddRef)(THIS) PURE; - STDMETHOD_(ULONG,Release)(THIS) PURE; - - // - // ID3DXMatrixStack methods - // - - // Pops the top of the stack, returns the current top - // *after* popping the top. - STDMETHOD(Pop)(THIS) PURE; - - // Pushes the stack by one, duplicating the current matrix. - STDMETHOD(Push)(THIS) PURE; - - // Loads identity in the current matrix. - STDMETHOD(LoadIdentity)(THIS) PURE; - - // Loads the given matrix into the current matrix - STDMETHOD(LoadMatrix)(THIS_ CONST D3DXMATRIX* pM ) PURE; - - // Right-Multiplies the given matrix to the current matrix. - // (transformation is about the current world origin) - STDMETHOD(MultMatrix)(THIS_ CONST D3DXMATRIX* pM ) PURE; - - // Left-Multiplies the given matrix to the current matrix - // (transformation is about the local origin of the object) - STDMETHOD(MultMatrixLocal)(THIS_ CONST D3DXMATRIX* pM ) PURE; - - // Right multiply the current matrix with the computed rotation - // matrix, counterclockwise about the given axis with the given angle. - // (rotation is about the current world origin) - STDMETHOD(RotateAxis) - (THIS_ CONST D3DXVECTOR3* pV, FLOAT Angle) PURE; - - // Left multiply the current matrix with the computed rotation - // matrix, counterclockwise about the given axis with the given angle. - // (rotation is about the local origin of the object) - STDMETHOD(RotateAxisLocal) - (THIS_ CONST D3DXVECTOR3* pV, FLOAT Angle) PURE; - - // Right multiply the current matrix with the computed rotation - // matrix. All angles are counterclockwise. (rotation is about the - // current world origin) - - // The rotation is composed of a yaw around the Y axis, a pitch around - // the X axis, and a roll around the Z axis. - STDMETHOD(RotateYawPitchRoll) - (THIS_ FLOAT Yaw, FLOAT Pitch, FLOAT Roll) PURE; - - // Left multiply the current matrix with the computed rotation - // matrix. All angles are counterclockwise. (rotation is about the - // local origin of the object) - - // The rotation is composed of a yaw around the Y axis, a pitch around - // the X axis, and a roll around the Z axis. - STDMETHOD(RotateYawPitchRollLocal) - (THIS_ FLOAT Yaw, FLOAT Pitch, FLOAT Roll) PURE; - - // Right multiply the current matrix with the computed scale - // matrix. (transformation is about the current world origin) - STDMETHOD(Scale)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE; - - // Left multiply the current matrix with the computed scale - // matrix. (transformation is about the local origin of the object) - STDMETHOD(ScaleLocal)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE; - - // Right multiply the current matrix with the computed translation - // matrix. (transformation is about the current world origin) - STDMETHOD(Translate)(THIS_ FLOAT x, FLOAT y, FLOAT z ) PURE; - - // Left multiply the current matrix with the computed translation - // matrix. (transformation is about the local origin of the object) - STDMETHOD(TranslateLocal)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE; - - /* Obtain the current matrix at the top of the stack */ - STDMETHOD_(D3DXMATRIX*, GetTop)(THIS) PURE; -}; - -#ifdef __cplusplus -extern "C" { -#endif - -HRESULT WINAPI - D3DXCreateMatrixStack( - DWORD Flags, - LPD3DXMATRIXSTACK* ppStack); - -#ifdef __cplusplus -} -#endif - -#include "d3dx8math.inl" - -#pragma warning(default:4201) - -#endif /* __D3DX8MATH_H__ */ +////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Microsoft Corporation. All Rights Reserved. +// +// File: d3dx8math.h +// Content: D3DX math types and functions +// +////////////////////////////////////////////////////////////////////////////// + +#include "d3dx8.h" + +#ifndef __D3DX8MATH_H__ +#define __D3DX8MATH_H__ + +#include +#pragma warning(disable:4201) /* anonymous unions warning */ + +//=========================================================================== +// +// General purpose utilities +// +//=========================================================================== +#define D3DX_PI ((FLOAT) 3.141592654f) +#define D3DX_1BYPI ((FLOAT) 0.318309886f) + +#define D3DXToRadian( degree ) ((degree) * (D3DX_PI / 180.0f)) +#define D3DXToDegree( radian ) ((radian) * (180.0f / D3DX_PI)) + + + +//=========================================================================== +// +// Vectors +// +//=========================================================================== + +//-------------------------- +// 2D Vector +//-------------------------- +typedef struct D3DXVECTOR2 +{ +#ifdef __cplusplus +public: + D3DXVECTOR2() {}; + D3DXVECTOR2( CONST FLOAT * ); + D3DXVECTOR2( FLOAT x, FLOAT y ); + + // casting + operator FLOAT* (); + operator CONST FLOAT* () const; + + // assignment operators + D3DXVECTOR2& operator += ( CONST D3DXVECTOR2& ); + D3DXVECTOR2& operator -= ( CONST D3DXVECTOR2& ); + D3DXVECTOR2& operator *= ( FLOAT ); + D3DXVECTOR2& operator /= ( FLOAT ); + + // unary operators + D3DXVECTOR2 operator + () const; + D3DXVECTOR2 operator - () const; + + // binary operators + D3DXVECTOR2 operator + ( CONST D3DXVECTOR2& ) const; + D3DXVECTOR2 operator - ( CONST D3DXVECTOR2& ) const; + D3DXVECTOR2 operator * ( FLOAT ) const; + D3DXVECTOR2 operator / ( FLOAT ) const; + + friend D3DXVECTOR2 operator * ( FLOAT, CONST D3DXVECTOR2& ); + + BOOL operator == ( CONST D3DXVECTOR2& ) const; + BOOL operator != ( CONST D3DXVECTOR2& ) const; + + +public: +#endif //__cplusplus + FLOAT x, y; +} D3DXVECTOR2, *LPD3DXVECTOR2; + + +//-------------------------- +// 3D Vector +//-------------------------- +#ifdef __cplusplus +typedef struct D3DXVECTOR3 : public D3DVECTOR +{ +public: + D3DXVECTOR3() {}; + D3DXVECTOR3( CONST FLOAT * ); + D3DXVECTOR3( CONST D3DVECTOR& ); + D3DXVECTOR3( FLOAT x, FLOAT y, FLOAT z ); + + // casting + operator FLOAT* (); + operator CONST FLOAT* () const; + + // assignment operators + D3DXVECTOR3& operator += ( CONST D3DXVECTOR3& ); + D3DXVECTOR3& operator -= ( CONST D3DXVECTOR3& ); + D3DXVECTOR3& operator *= ( FLOAT ); + D3DXVECTOR3& operator /= ( FLOAT ); + + // unary operators + D3DXVECTOR3 operator + () const; + D3DXVECTOR3 operator - () const; + + // binary operators + D3DXVECTOR3 operator + ( CONST D3DXVECTOR3& ) const; + D3DXVECTOR3 operator - ( CONST D3DXVECTOR3& ) const; + D3DXVECTOR3 operator * ( FLOAT ) const; + D3DXVECTOR3 operator / ( FLOAT ) const; + + friend D3DXVECTOR3 operator * ( FLOAT, CONST struct D3DXVECTOR3& ); + + BOOL operator == ( CONST D3DXVECTOR3& ) const; + BOOL operator != ( CONST D3DXVECTOR3& ) const; + +} D3DXVECTOR3, *LPD3DXVECTOR3; + +#else //!__cplusplus +typedef struct _D3DVECTOR D3DXVECTOR3, *LPD3DXVECTOR3; +#endif //!__cplusplus + + +//-------------------------- +// 4D Vector +//-------------------------- +typedef struct D3DXVECTOR4 +{ +#ifdef __cplusplus +public: + D3DXVECTOR4() {}; + D3DXVECTOR4( CONST FLOAT* ); + D3DXVECTOR4( FLOAT x, FLOAT y, FLOAT z, FLOAT w ); + + // casting + operator FLOAT* (); + operator CONST FLOAT* () const; + + // assignment operators + D3DXVECTOR4& operator += ( CONST D3DXVECTOR4& ); + D3DXVECTOR4& operator -= ( CONST D3DXVECTOR4& ); + D3DXVECTOR4& operator *= ( FLOAT ); + D3DXVECTOR4& operator /= ( FLOAT ); + + // unary operators + D3DXVECTOR4 operator + () const; + D3DXVECTOR4 operator - () const; + + // binary operators + D3DXVECTOR4 operator + ( CONST D3DXVECTOR4& ) const; + D3DXVECTOR4 operator - ( CONST D3DXVECTOR4& ) const; + D3DXVECTOR4 operator * ( FLOAT ) const; + D3DXVECTOR4 operator / ( FLOAT ) const; + + friend D3DXVECTOR4 operator * ( FLOAT, CONST D3DXVECTOR4& ); + + BOOL operator == ( CONST D3DXVECTOR4& ) const; + BOOL operator != ( CONST D3DXVECTOR4& ) const; + +public: +#endif //__cplusplus + FLOAT x, y, z, w; +} D3DXVECTOR4, *LPD3DXVECTOR4; + + +//=========================================================================== +// +// Matrices +// +//=========================================================================== +#ifdef __cplusplus +typedef struct D3DXMATRIX : public D3DMATRIX +{ +public: + D3DXMATRIX() {}; + D3DXMATRIX( CONST FLOAT * ); + D3DXMATRIX( CONST D3DMATRIX& ); + D3DXMATRIX( FLOAT _11, FLOAT _12, FLOAT _13, FLOAT _14, + FLOAT _21, FLOAT _22, FLOAT _23, FLOAT _24, + FLOAT _31, FLOAT _32, FLOAT _33, FLOAT _34, + FLOAT _41, FLOAT _42, FLOAT _43, FLOAT _44 ); + + + // access grants + FLOAT& operator () ( UINT Row, UINT Col ); + FLOAT operator () ( UINT Row, UINT Col ) const; + + // casting operators + operator FLOAT* (); + operator CONST FLOAT* () const; + + // assignment operators + D3DXMATRIX& operator *= ( CONST D3DXMATRIX& ); + D3DXMATRIX& operator += ( CONST D3DXMATRIX& ); + D3DXMATRIX& operator -= ( CONST D3DXMATRIX& ); + D3DXMATRIX& operator *= ( FLOAT ); + D3DXMATRIX& operator /= ( FLOAT ); + + // unary operators + D3DXMATRIX operator + () const; + D3DXMATRIX operator - () const; + + // binary operators + D3DXMATRIX operator * ( CONST D3DXMATRIX& ) const; + D3DXMATRIX operator + ( CONST D3DXMATRIX& ) const; + D3DXMATRIX operator - ( CONST D3DXMATRIX& ) const; + D3DXMATRIX operator * ( FLOAT ) const; + D3DXMATRIX operator / ( FLOAT ) const; + + friend D3DXMATRIX operator * ( FLOAT, CONST D3DXMATRIX& ); + + BOOL operator == ( CONST D3DXMATRIX& ) const; + BOOL operator != ( CONST D3DXMATRIX& ) const; + +} D3DXMATRIX, *LPD3DXMATRIX; + +#else //!__cplusplus +typedef struct _D3DMATRIX D3DXMATRIX, *LPD3DXMATRIX; +#endif //!__cplusplus + +//=========================================================================== +// +// Aligned Matrices +// +// This class helps keep matrices 16-byte aligned as preferred by P4 cpus. +// It aligns matrices on the stack and on the heap or in global scope. +// It does this using __declspec(align(16)) which works on VC7 and on VC 6 +// with the processor pack. Unfortunately there is no way to detect the +// latter so this is turned on only on VC7. On other compilers this is the +// the same as D3DXMATRIX. +// Using this class on a compiler that does not actually do the alignment +// can be dangerous since it will not expose bugs that ignore alignment. +// E.g if an object of this class in inside a struct or class, and some code +// memcopys data in it assuming tight packing. This could break on a compiler +// that eventually start aligning the matrix. +// +//=========================================================================== +#ifdef __cplusplus +typedef struct _D3DXMATRIXA16 : public D3DXMATRIX +{ + _D3DXMATRIXA16() {} + _D3DXMATRIXA16( CONST FLOAT * f): D3DXMATRIX(f) {} + _D3DXMATRIXA16( CONST D3DMATRIX& m): D3DXMATRIX(m) {} + _D3DXMATRIXA16( FLOAT _11, FLOAT _12, FLOAT _13, FLOAT _14, + FLOAT _21, FLOAT _22, FLOAT _23, FLOAT _24, + FLOAT _31, FLOAT _32, FLOAT _33, FLOAT _34, + FLOAT _41, FLOAT _42, FLOAT _43, FLOAT _44 ) : + D3DXMATRIX(_11, _12, _13, _14, + _21, _22, _23, _24, + _31, _32, _33, _34, + _41, _42, _43, _44) {} + void* operator new(size_t s) + { + LPBYTE p = ::new BYTE[s + 16]; + if (p) + { + BYTE offset = (BYTE)(16 - ((UINT_PTR)p & 15)); + p += offset; + p[-1] = offset; + } + return p; + }; + + void* operator new[](size_t s) + { + LPBYTE p = ::new BYTE[s + 16]; + if (p) + { + BYTE offset = (BYTE)(16 - ((UINT_PTR)p & 15)); + p += offset; + p[-1] = offset; + } + return p; + }; + + // This is NOT a virtual operator. If you cast + // to D3DXMATRIX, do not delete using that + void operator delete(void* p) + { + if(p) + { + BYTE* pb = static_cast(p); + pb -= pb[-1]; + ::delete [] pb; + } + }; + + // This is NOT a virtual operator. If you cast + // to D3DXMATRIX, do not delete using that + void operator delete[](void* p) + { + if(p) + { + BYTE* pb = static_cast(p); + pb -= pb[-1]; + ::delete [] pb; + } + }; + + struct _D3DXMATRIXA16& operator=(CONST D3DXMATRIX& rhs) + { + memcpy(&_11, &rhs, sizeof(D3DXMATRIX)); + return *this; + }; +} _D3DXMATRIXA16; + +#else //!__cplusplus +typedef D3DXMATRIX _D3DXMATRIXA16; +#endif //!__cplusplus + +#if _MSC_VER >= 1300 // VC7 +#define _ALIGN_16 __declspec(align(16)) +#else +#define _ALIGN_16 // Earlier compiler may not understand this, do nothing. +#endif + +#define D3DXMATRIXA16 _ALIGN_16 _D3DXMATRIXA16 + +typedef D3DXMATRIXA16 *LPD3DXMATRIXA16; + +//=========================================================================== +// +// Quaternions +// +//=========================================================================== +typedef struct D3DXQUATERNION +{ +#ifdef __cplusplus +public: + D3DXQUATERNION() {} + D3DXQUATERNION( CONST FLOAT * ); + D3DXQUATERNION( FLOAT x, FLOAT y, FLOAT z, FLOAT w ); + + // casting + operator FLOAT* (); + operator CONST FLOAT* () const; + + // assignment operators + D3DXQUATERNION& operator += ( CONST D3DXQUATERNION& ); + D3DXQUATERNION& operator -= ( CONST D3DXQUATERNION& ); + D3DXQUATERNION& operator *= ( CONST D3DXQUATERNION& ); + D3DXQUATERNION& operator *= ( FLOAT ); + D3DXQUATERNION& operator /= ( FLOAT ); + + // unary operators + D3DXQUATERNION operator + () const; + D3DXQUATERNION operator - () const; + + // binary operators + D3DXQUATERNION operator + ( CONST D3DXQUATERNION& ) const; + D3DXQUATERNION operator - ( CONST D3DXQUATERNION& ) const; + D3DXQUATERNION operator * ( CONST D3DXQUATERNION& ) const; + D3DXQUATERNION operator * ( FLOAT ) const; + D3DXQUATERNION operator / ( FLOAT ) const; + + friend D3DXQUATERNION operator * (FLOAT, CONST D3DXQUATERNION& ); + + BOOL operator == ( CONST D3DXQUATERNION& ) const; + BOOL operator != ( CONST D3DXQUATERNION& ) const; + +#endif //__cplusplus + FLOAT x, y, z, w; +} D3DXQUATERNION, *LPD3DXQUATERNION; + + +//=========================================================================== +// +// Planes +// +//=========================================================================== +typedef struct D3DXPLANE +{ +#ifdef __cplusplus +public: + D3DXPLANE() {} + D3DXPLANE( CONST FLOAT* ); + D3DXPLANE( FLOAT a, FLOAT b, FLOAT c, FLOAT d ); + + // casting + operator FLOAT* (); + operator CONST FLOAT* () const; + + // unary operators + D3DXPLANE operator + () const; + D3DXPLANE operator - () const; + + // binary operators + BOOL operator == ( CONST D3DXPLANE& ) const; + BOOL operator != ( CONST D3DXPLANE& ) const; + +#endif //__cplusplus + FLOAT a, b, c, d; +} D3DXPLANE, *LPD3DXPLANE; + + +//=========================================================================== +// +// Colors +// +//=========================================================================== + +typedef struct D3DXCOLOR +{ +#ifdef __cplusplus +public: + D3DXCOLOR() {} + D3DXCOLOR( DWORD argb ); + D3DXCOLOR( CONST FLOAT * ); + D3DXCOLOR( CONST D3DCOLORVALUE& ); + D3DXCOLOR( FLOAT r, FLOAT g, FLOAT b, FLOAT a ); + + // casting + operator DWORD () const; + + operator FLOAT* (); + operator CONST FLOAT* () const; + + operator D3DCOLORVALUE* (); + operator CONST D3DCOLORVALUE* () const; + + operator D3DCOLORVALUE& (); + operator CONST D3DCOLORVALUE& () const; + + // assignment operators + D3DXCOLOR& operator += ( CONST D3DXCOLOR& ); + D3DXCOLOR& operator -= ( CONST D3DXCOLOR& ); + D3DXCOLOR& operator *= ( FLOAT ); + D3DXCOLOR& operator /= ( FLOAT ); + + // unary operators + D3DXCOLOR operator + () const; + D3DXCOLOR operator - () const; + + // binary operators + D3DXCOLOR operator + ( CONST D3DXCOLOR& ) const; + D3DXCOLOR operator - ( CONST D3DXCOLOR& ) const; + D3DXCOLOR operator * ( FLOAT ) const; + D3DXCOLOR operator / ( FLOAT ) const; + + friend D3DXCOLOR operator * (FLOAT, CONST D3DXCOLOR& ); + + BOOL operator == ( CONST D3DXCOLOR& ) const; + BOOL operator != ( CONST D3DXCOLOR& ) const; + +#endif //__cplusplus + FLOAT r, g, b, a; +} D3DXCOLOR, *LPD3DXCOLOR; + + + +//=========================================================================== +// +// D3DX math functions: +// +// NOTE: +// * All these functions can take the same object as in and out parameters. +// +// * Out parameters are typically also returned as return values, so that +// the output of one function may be used as a parameter to another. +// +//=========================================================================== + +//-------------------------- +// 2D Vector +//-------------------------- + +// inline + +FLOAT D3DXVec2Length + ( CONST D3DXVECTOR2 *pV ); + +FLOAT D3DXVec2LengthSq + ( CONST D3DXVECTOR2 *pV ); + +FLOAT D3DXVec2Dot + ( CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); + +// Z component of ((x1,y1,0) cross (x2,y2,0)) +FLOAT D3DXVec2CCW + ( CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); + +D3DXVECTOR2* D3DXVec2Add + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); + +D3DXVECTOR2* D3DXVec2Subtract + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); + +// Minimize each component. x = min(x1, x2), y = min(y1, y2) +D3DXVECTOR2* D3DXVec2Minimize + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); + +// Maximize each component. x = max(x1, x2), y = max(y1, y2) +D3DXVECTOR2* D3DXVec2Maximize + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2 ); + +D3DXVECTOR2* D3DXVec2Scale + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, FLOAT s ); + +// Linear interpolation. V1 + s(V2-V1) +D3DXVECTOR2* D3DXVec2Lerp + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2, + FLOAT s ); + +// non-inline +#ifdef __cplusplus +extern "C" { +#endif + +D3DXVECTOR2* WINAPI D3DXVec2Normalize + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV ); + +// Hermite interpolation between position V1, tangent T1 (when s == 0) +// and position V2, tangent T2 (when s == 1). +D3DXVECTOR2* WINAPI D3DXVec2Hermite + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pT1, + CONST D3DXVECTOR2 *pV2, CONST D3DXVECTOR2 *pT2, FLOAT s ); + +// CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1) +D3DXVECTOR2* WINAPI D3DXVec2CatmullRom + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV0, CONST D3DXVECTOR2 *pV1, + CONST D3DXVECTOR2 *pV2, CONST D3DXVECTOR2 *pV3, FLOAT s ); + +// Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) +D3DXVECTOR2* WINAPI D3DXVec2BaryCentric + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV1, CONST D3DXVECTOR2 *pV2, + CONST D3DXVECTOR2 *pV3, FLOAT f, FLOAT g); + +// Transform (x, y, 0, 1) by matrix. +D3DXVECTOR4* WINAPI D3DXVec2Transform + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR2 *pV, CONST D3DXMATRIX *pM ); + +// Transform (x, y, 0, 1) by matrix, project result back into w=1. +D3DXVECTOR2* WINAPI D3DXVec2TransformCoord + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, CONST D3DXMATRIX *pM ); + +// Transform (x, y, 0, 0) by matrix. +D3DXVECTOR2* WINAPI D3DXVec2TransformNormal + ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, CONST D3DXMATRIX *pM ); + +#ifdef __cplusplus +} +#endif + + +//-------------------------- +// 3D Vector +//-------------------------- + +// inline + +FLOAT D3DXVec3Length + ( CONST D3DXVECTOR3 *pV ); + +FLOAT D3DXVec3LengthSq + ( CONST D3DXVECTOR3 *pV ); + +FLOAT D3DXVec3Dot + ( CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); + +D3DXVECTOR3* D3DXVec3Cross + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); + +D3DXVECTOR3* D3DXVec3Add + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); + +D3DXVECTOR3* D3DXVec3Subtract + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); + +// Minimize each component. x = min(x1, x2), y = min(y1, y2), ... +D3DXVECTOR3* D3DXVec3Minimize + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); + +// Maximize each component. x = max(x1, x2), y = max(y1, y2), ... +D3DXVECTOR3* D3DXVec3Maximize + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2 ); + +D3DXVECTOR3* D3DXVec3Scale + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, FLOAT s); + +// Linear interpolation. V1 + s(V2-V1) +D3DXVECTOR3* D3DXVec3Lerp + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, + FLOAT s ); + +// non-inline +#ifdef __cplusplus +extern "C" { +#endif + +D3DXVECTOR3* WINAPI D3DXVec3Normalize + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV ); + +// Hermite interpolation between position V1, tangent T1 (when s == 0) +// and position V2, tangent T2 (when s == 1). +D3DXVECTOR3* WINAPI D3DXVec3Hermite + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pT1, + CONST D3DXVECTOR3 *pV2, CONST D3DXVECTOR3 *pT2, FLOAT s ); + +// CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1) +D3DXVECTOR3* WINAPI D3DXVec3CatmullRom + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV0, CONST D3DXVECTOR3 *pV1, + CONST D3DXVECTOR3 *pV2, CONST D3DXVECTOR3 *pV3, FLOAT s ); + +// Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) +D3DXVECTOR3* WINAPI D3DXVec3BaryCentric + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, + CONST D3DXVECTOR3 *pV3, FLOAT f, FLOAT g); + +// Transform (x, y, z, 1) by matrix. +D3DXVECTOR4* WINAPI D3DXVec3Transform + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM ); + +// Transform (x, y, z, 1) by matrix, project result back into w=1. +D3DXVECTOR3* WINAPI D3DXVec3TransformCoord + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM ); + +// Transform (x, y, z, 0) by matrix. If you transforming a normal by a +// non-affine matrix, the matrix you pass to this function should be the +// transpose of the inverse of the matrix you would use to transform a coord. +D3DXVECTOR3* WINAPI D3DXVec3TransformNormal + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM ); + +// Project vector from object space into screen space +D3DXVECTOR3* WINAPI D3DXVec3Project + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DVIEWPORT8 *pViewport, + CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld); + +// Project vector from screen space into object space +D3DXVECTOR3* WINAPI D3DXVec3Unproject + ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DVIEWPORT8 *pViewport, + CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld); + +#ifdef __cplusplus +} +#endif + + + +//-------------------------- +// 4D Vector +//-------------------------- + +// inline + +FLOAT D3DXVec4Length + ( CONST D3DXVECTOR4 *pV ); + +FLOAT D3DXVec4LengthSq + ( CONST D3DXVECTOR4 *pV ); + +FLOAT D3DXVec4Dot + ( CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2 ); + +D3DXVECTOR4* D3DXVec4Add + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2); + +D3DXVECTOR4* D3DXVec4Subtract + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2); + +// Minimize each component. x = min(x1, x2), y = min(y1, y2), ... +D3DXVECTOR4* D3DXVec4Minimize + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2); + +// Maximize each component. x = max(x1, x2), y = max(y1, y2), ... +D3DXVECTOR4* D3DXVec4Maximize + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2); + +D3DXVECTOR4* D3DXVec4Scale + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV, FLOAT s); + +// Linear interpolation. V1 + s(V2-V1) +D3DXVECTOR4* D3DXVec4Lerp + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2, + FLOAT s ); + +// non-inline +#ifdef __cplusplus +extern "C" { +#endif + +// Cross-product in 4 dimensions. +D3DXVECTOR4* WINAPI D3DXVec4Cross + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2, + CONST D3DXVECTOR4 *pV3); + +D3DXVECTOR4* WINAPI D3DXVec4Normalize + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV ); + +// Hermite interpolation between position V1, tangent T1 (when s == 0) +// and position V2, tangent T2 (when s == 1). +D3DXVECTOR4* WINAPI D3DXVec4Hermite + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pT1, + CONST D3DXVECTOR4 *pV2, CONST D3DXVECTOR4 *pT2, FLOAT s ); + +// CatmullRom interpolation between V1 (when s == 0) and V2 (when s == 1) +D3DXVECTOR4* WINAPI D3DXVec4CatmullRom + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV0, CONST D3DXVECTOR4 *pV1, + CONST D3DXVECTOR4 *pV2, CONST D3DXVECTOR4 *pV3, FLOAT s ); + +// Barycentric coordinates. V1 + f(V2-V1) + g(V3-V1) +D3DXVECTOR4* WINAPI D3DXVec4BaryCentric + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV1, CONST D3DXVECTOR4 *pV2, + CONST D3DXVECTOR4 *pV3, FLOAT f, FLOAT g); + +// Transform vector by matrix. +D3DXVECTOR4* WINAPI D3DXVec4Transform + ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV, CONST D3DXMATRIX *pM ); + +#ifdef __cplusplus +} +#endif + + +//-------------------------- +// 4D Matrix +//-------------------------- + +// inline + +D3DXMATRIX* D3DXMatrixIdentity + ( D3DXMATRIX *pOut ); + +BOOL D3DXMatrixIsIdentity + ( CONST D3DXMATRIX *pM ); + + +// non-inline +#ifdef __cplusplus +extern "C" { +#endif + +FLOAT WINAPI D3DXMatrixfDeterminant + ( CONST D3DXMATRIX *pM ); + +D3DXMATRIX* WINAPI D3DXMatrixTranspose + ( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM ); + +// Matrix multiplication. The result represents the transformation M2 +// followed by the transformation M1. (Out = M1 * M2) +D3DXMATRIX* WINAPI D3DXMatrixMultiply + ( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM1, CONST D3DXMATRIX *pM2 ); + +// Matrix multiplication, followed by a transpose. (Out = T(M1 * M2)) +D3DXMATRIX* WINAPI D3DXMatrixMultiplyTranspose + ( D3DXMATRIX *pOut, CONST D3DXMATRIX *pM1, CONST D3DXMATRIX *pM2 ); + +// Calculate inverse of matrix. Inversion my fail, in which case NULL will +// be returned. The determinant of pM is also returned it pfDeterminant +// is non-NULL. +D3DXMATRIX* WINAPI D3DXMatrixInverse + ( D3DXMATRIX *pOut, FLOAT *pDeterminant, CONST D3DXMATRIX *pM ); + +// Build a matrix which scales by (sx, sy, sz) +D3DXMATRIX* WINAPI D3DXMatrixScaling + ( D3DXMATRIX *pOut, FLOAT sx, FLOAT sy, FLOAT sz ); + +// Build a matrix which translates by (x, y, z) +D3DXMATRIX* WINAPI D3DXMatrixTranslation + ( D3DXMATRIX *pOut, FLOAT x, FLOAT y, FLOAT z ); + +// Build a matrix which rotates around the X axis +D3DXMATRIX* WINAPI D3DXMatrixRotationX + ( D3DXMATRIX *pOut, FLOAT Angle ); + +// Build a matrix which rotates around the Y axis +D3DXMATRIX* WINAPI D3DXMatrixRotationY + ( D3DXMATRIX *pOut, FLOAT Angle ); + +// Build a matrix which rotates around the Z axis +D3DXMATRIX* WINAPI D3DXMatrixRotationZ + ( D3DXMATRIX *pOut, FLOAT Angle ); + +// Build a matrix which rotates around an arbitrary axis +D3DXMATRIX* WINAPI D3DXMatrixRotationAxis + ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pV, FLOAT Angle ); + +// Build a matrix from a quaternion +D3DXMATRIX* WINAPI D3DXMatrixRotationQuaternion + ( D3DXMATRIX *pOut, CONST D3DXQUATERNION *pQ); + +// Yaw around the Y axis, a pitch around the X axis, +// and a roll around the Z axis. +D3DXMATRIX* WINAPI D3DXMatrixRotationYawPitchRoll + ( D3DXMATRIX *pOut, FLOAT Yaw, FLOAT Pitch, FLOAT Roll ); + + +// Build transformation matrix. NULL arguments are treated as identity. +// Mout = Msc-1 * Msr-1 * Ms * Msr * Msc * Mrc-1 * Mr * Mrc * Mt +D3DXMATRIX* WINAPI D3DXMatrixTransformation + ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pScalingCenter, + CONST D3DXQUATERNION *pScalingRotation, CONST D3DXVECTOR3 *pScaling, + CONST D3DXVECTOR3 *pRotationCenter, CONST D3DXQUATERNION *pRotation, + CONST D3DXVECTOR3 *pTranslation); + +// Build affine transformation matrix. NULL arguments are treated as identity. +// Mout = Ms * Mrc-1 * Mr * Mrc * Mt +D3DXMATRIX* WINAPI D3DXMatrixAffineTransformation + ( D3DXMATRIX *pOut, FLOAT Scaling, CONST D3DXVECTOR3 *pRotationCenter, + CONST D3DXQUATERNION *pRotation, CONST D3DXVECTOR3 *pTranslation); + +// Build a lookat matrix. (right-handed) +D3DXMATRIX* WINAPI D3DXMatrixLookAtRH + ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pEye, CONST D3DXVECTOR3 *pAt, + CONST D3DXVECTOR3 *pUp ); + +// Build a lookat matrix. (left-handed) +D3DXMATRIX* WINAPI D3DXMatrixLookAtLH + ( D3DXMATRIX *pOut, CONST D3DXVECTOR3 *pEye, CONST D3DXVECTOR3 *pAt, + CONST D3DXVECTOR3 *pUp ); + +// Build a perspective projection matrix. (right-handed) +D3DXMATRIX* WINAPI D3DXMatrixPerspectiveRH + ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); + +// Build a perspective projection matrix. (left-handed) +D3DXMATRIX* WINAPI D3DXMatrixPerspectiveLH + ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); + +// Build a perspective projection matrix. (right-handed) +D3DXMATRIX* WINAPI D3DXMatrixPerspectiveFovRH + ( D3DXMATRIX *pOut, FLOAT fovy, FLOAT Aspect, FLOAT zn, FLOAT zf ); + +// Build a perspective projection matrix. (left-handed) +D3DXMATRIX* WINAPI D3DXMatrixPerspectiveFovLH + ( D3DXMATRIX *pOut, FLOAT fovy, FLOAT Aspect, FLOAT zn, FLOAT zf ); + +// Build a perspective projection matrix. (right-handed) +D3DXMATRIX* WINAPI D3DXMatrixPerspectiveOffCenterRH + ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, + FLOAT zf ); + +// Build a perspective projection matrix. (left-handed) +D3DXMATRIX* WINAPI D3DXMatrixPerspectiveOffCenterLH + ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, + FLOAT zf ); + +// Build an ortho projection matrix. (right-handed) +D3DXMATRIX* WINAPI D3DXMatrixOrthoRH + ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); + +// Build an ortho projection matrix. (left-handed) +D3DXMATRIX* WINAPI D3DXMatrixOrthoLH + ( D3DXMATRIX *pOut, FLOAT w, FLOAT h, FLOAT zn, FLOAT zf ); + +// Build an ortho projection matrix. (right-handed) +D3DXMATRIX* WINAPI D3DXMatrixOrthoOffCenterRH + ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, + FLOAT zf ); + +// Build an ortho projection matrix. (left-handed) +D3DXMATRIX* WINAPI D3DXMatrixOrthoOffCenterLH + ( D3DXMATRIX *pOut, FLOAT l, FLOAT r, FLOAT b, FLOAT t, FLOAT zn, + FLOAT zf ); + +// Build a matrix which flattens geometry into a plane, as if casting +// a shadow from a light. +D3DXMATRIX* WINAPI D3DXMatrixShadow + ( D3DXMATRIX *pOut, CONST D3DXVECTOR4 *pLight, + CONST D3DXPLANE *pPlane ); + +// Build a matrix which reflects the coordinate system about a plane +D3DXMATRIX* WINAPI D3DXMatrixReflect + ( D3DXMATRIX *pOut, CONST D3DXPLANE *pPlane ); + +#ifdef __cplusplus +} +#endif + + +//-------------------------- +// Quaternion +//-------------------------- + +// inline + +FLOAT D3DXQuaternionLength + ( CONST D3DXQUATERNION *pQ ); + +// Length squared, or "norm" +FLOAT D3DXQuaternionLengthSq + ( CONST D3DXQUATERNION *pQ ); + +FLOAT D3DXQuaternionDot + ( CONST D3DXQUATERNION *pQ1, CONST D3DXQUATERNION *pQ2 ); + +// (0, 0, 0, 1) +D3DXQUATERNION* D3DXQuaternionIdentity + ( D3DXQUATERNION *pOut ); + +BOOL D3DXQuaternionIsIdentity + ( CONST D3DXQUATERNION *pQ ); + +// (-x, -y, -z, w) +D3DXQUATERNION* D3DXQuaternionConjugate + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); + + +// non-inline +#ifdef __cplusplus +extern "C" { +#endif + +// Compute a quaternin's axis and angle of rotation. Expects unit quaternions. +void WINAPI D3DXQuaternionToAxisAngle + ( CONST D3DXQUATERNION *pQ, D3DXVECTOR3 *pAxis, FLOAT *pAngle ); + +// Build a quaternion from a rotation matrix. +D3DXQUATERNION* WINAPI D3DXQuaternionRotationMatrix + ( D3DXQUATERNION *pOut, CONST D3DXMATRIX *pM); + +// Rotation about arbitrary axis. +D3DXQUATERNION* WINAPI D3DXQuaternionRotationAxis + ( D3DXQUATERNION *pOut, CONST D3DXVECTOR3 *pV, FLOAT Angle ); + +// Yaw around the Y axis, a pitch around the X axis, +// and a roll around the Z axis. +D3DXQUATERNION* WINAPI D3DXQuaternionRotationYawPitchRoll + ( D3DXQUATERNION *pOut, FLOAT Yaw, FLOAT Pitch, FLOAT Roll ); + +// Quaternion multiplication. The result represents the rotation Q2 +// followed by the rotation Q1. (Out = Q2 * Q1) +D3DXQUATERNION* WINAPI D3DXQuaternionMultiply + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, + CONST D3DXQUATERNION *pQ2 ); + +D3DXQUATERNION* WINAPI D3DXQuaternionNormalize + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); + +// Conjugate and re-norm +D3DXQUATERNION* WINAPI D3DXQuaternionInverse + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); + +// Expects unit quaternions. +// if q = (cos(theta), sin(theta) * v); ln(q) = (0, theta * v) +D3DXQUATERNION* WINAPI D3DXQuaternionLn + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); + +// Expects pure quaternions. (w == 0) w is ignored in calculation. +// if q = (0, theta * v); exp(q) = (cos(theta), sin(theta) * v) +D3DXQUATERNION* WINAPI D3DXQuaternionExp + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); + +// Spherical linear interpolation between Q1 (t == 0) and Q2 (t == 1). +// Expects unit quaternions. +D3DXQUATERNION* WINAPI D3DXQuaternionSlerp + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, + CONST D3DXQUATERNION *pQ2, FLOAT t ); + +// Spherical quadrangle interpolation. +// Slerp(Slerp(Q1, C, t), Slerp(A, B, t), 2t(1-t)) +D3DXQUATERNION* WINAPI D3DXQuaternionSquad + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, + CONST D3DXQUATERNION *pA, CONST D3DXQUATERNION *pB, + CONST D3DXQUATERNION *pC, FLOAT t ); + +// Setup control points for spherical quadrangle interpolation +// from Q1 to Q2. The control points are chosen in such a way +// to ensure the continuity of tangents with adjacent segments. +void WINAPI D3DXQuaternionSquadSetup + ( D3DXQUATERNION *pAOut, D3DXQUATERNION *pBOut, D3DXQUATERNION *pCOut, + CONST D3DXQUATERNION *pQ0, CONST D3DXQUATERNION *pQ1, + CONST D3DXQUATERNION *pQ2, CONST D3DXQUATERNION *pQ3 ); + +// Barycentric interpolation. +// Slerp(Slerp(Q1, Q2, f+g), Slerp(Q1, Q3, f+g), g/(f+g)) +D3DXQUATERNION* WINAPI D3DXQuaternionBaryCentric + ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ1, + CONST D3DXQUATERNION *pQ2, CONST D3DXQUATERNION *pQ3, + FLOAT f, FLOAT g ); + +#ifdef __cplusplus +} +#endif + + +//-------------------------- +// Plane +//-------------------------- + +// inline + +// ax + by + cz + dw +FLOAT D3DXPlaneDot + ( CONST D3DXPLANE *pP, CONST D3DXVECTOR4 *pV); + +// ax + by + cz + d +FLOAT D3DXPlaneDotCoord + ( CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV); + +// ax + by + cz +FLOAT D3DXPlaneDotNormal + ( CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV); + +// non-inline +#ifdef __cplusplus +extern "C" { +#endif + +// Normalize plane (so that |a,b,c| == 1) +D3DXPLANE* WINAPI D3DXPlaneNormalize + ( D3DXPLANE *pOut, CONST D3DXPLANE *pP); + +// Find the intersection between a plane and a line. If the line is +// parallel to the plane, NULL is returned. +D3DXVECTOR3* WINAPI D3DXPlaneIntersectLine + ( D3DXVECTOR3 *pOut, CONST D3DXPLANE *pP, CONST D3DXVECTOR3 *pV1, + CONST D3DXVECTOR3 *pV2); + +// Construct a plane from a point and a normal +D3DXPLANE* WINAPI D3DXPlaneFromPointNormal + ( D3DXPLANE *pOut, CONST D3DXVECTOR3 *pPoint, CONST D3DXVECTOR3 *pNormal); + +// Construct a plane from 3 points +D3DXPLANE* WINAPI D3DXPlaneFromPoints + ( D3DXPLANE *pOut, CONST D3DXVECTOR3 *pV1, CONST D3DXVECTOR3 *pV2, + CONST D3DXVECTOR3 *pV3); + +// Transform a plane by a matrix. The vector (a,b,c) must be normal. +// M should be the inverse transpose of the transformation desired. +D3DXPLANE* WINAPI D3DXPlaneTransform + ( D3DXPLANE *pOut, CONST D3DXPLANE *pP, CONST D3DXMATRIX *pM ); + +#ifdef __cplusplus +} +#endif + + +//-------------------------- +// Color +//-------------------------- + +// inline + +// (1-r, 1-g, 1-b, a) +D3DXCOLOR* D3DXColorNegative + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC); + +D3DXCOLOR* D3DXColorAdd + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2); + +D3DXCOLOR* D3DXColorSubtract + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2); + +D3DXCOLOR* D3DXColorScale + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT s); + +// (r1*r2, g1*g2, b1*b2, a1*a2) +D3DXCOLOR* D3DXColorModulate + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2); + +// Linear interpolation of r,g,b, and a. C1 + s(C2-C1) +D3DXCOLOR* D3DXColorLerp + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC1, CONST D3DXCOLOR *pC2, FLOAT s); + +// non-inline +#ifdef __cplusplus +extern "C" { +#endif + +// Interpolate r,g,b between desaturated color and color. +// DesaturatedColor + s(Color - DesaturatedColor) +D3DXCOLOR* WINAPI D3DXColorAdjustSaturation + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT s); + +// Interpolate r,g,b between 50% grey and color. Grey + s(Color - Grey) +D3DXCOLOR* WINAPI D3DXColorAdjustContrast + (D3DXCOLOR *pOut, CONST D3DXCOLOR *pC, FLOAT c); + +#ifdef __cplusplus +} +#endif + + + + +//-------------------------- +// Misc +//-------------------------- + +#ifdef __cplusplus +extern "C" { +#endif + +// Calculate Fresnel term given the cosine of theta (likely obtained by +// taking the dot of two normals), and the refraction index of the material. +FLOAT WINAPI D3DXFresnelTerm + (FLOAT CosTheta, FLOAT RefractionIndex); + +#ifdef __cplusplus +} +#endif + + + +//=========================================================================== +// +// Matrix Stack +// +//=========================================================================== + +typedef interface ID3DXMatrixStack ID3DXMatrixStack; +typedef interface ID3DXMatrixStack *LPD3DXMATRIXSTACK; + +// {E3357330-CC5E-11d2-A434-00A0C90629A8} +DEFINE_GUID( IID_ID3DXMatrixStack, +0xe3357330, 0xcc5e, 0x11d2, 0xa4, 0x34, 0x0, 0xa0, 0xc9, 0x6, 0x29, 0xa8); + + +#undef INTERFACE +#define INTERFACE ID3DXMatrixStack + +DECLARE_INTERFACE_(ID3DXMatrixStack, IUnknown) +{ + // + // IUnknown methods + // + STDMETHOD(QueryInterface)(THIS_ REFIID riid, LPVOID * ppvObj) PURE; + STDMETHOD_(ULONG,AddRef)(THIS) PURE; + STDMETHOD_(ULONG,Release)(THIS) PURE; + + // + // ID3DXMatrixStack methods + // + + // Pops the top of the stack, returns the current top + // *after* popping the top. + STDMETHOD(Pop)(THIS) PURE; + + // Pushes the stack by one, duplicating the current matrix. + STDMETHOD(Push)(THIS) PURE; + + // Loads identity in the current matrix. + STDMETHOD(LoadIdentity)(THIS) PURE; + + // Loads the given matrix into the current matrix + STDMETHOD(LoadMatrix)(THIS_ CONST D3DXMATRIX* pM ) PURE; + + // Right-Multiplies the given matrix to the current matrix. + // (transformation is about the current world origin) + STDMETHOD(MultMatrix)(THIS_ CONST D3DXMATRIX* pM ) PURE; + + // Left-Multiplies the given matrix to the current matrix + // (transformation is about the local origin of the object) + STDMETHOD(MultMatrixLocal)(THIS_ CONST D3DXMATRIX* pM ) PURE; + + // Right multiply the current matrix with the computed rotation + // matrix, counterclockwise about the given axis with the given angle. + // (rotation is about the current world origin) + STDMETHOD(RotateAxis) + (THIS_ CONST D3DXVECTOR3* pV, FLOAT Angle) PURE; + + // Left multiply the current matrix with the computed rotation + // matrix, counterclockwise about the given axis with the given angle. + // (rotation is about the local origin of the object) + STDMETHOD(RotateAxisLocal) + (THIS_ CONST D3DXVECTOR3* pV, FLOAT Angle) PURE; + + // Right multiply the current matrix with the computed rotation + // matrix. All angles are counterclockwise. (rotation is about the + // current world origin) + + // The rotation is composed of a yaw around the Y axis, a pitch around + // the X axis, and a roll around the Z axis. + STDMETHOD(RotateYawPitchRoll) + (THIS_ FLOAT Yaw, FLOAT Pitch, FLOAT Roll) PURE; + + // Left multiply the current matrix with the computed rotation + // matrix. All angles are counterclockwise. (rotation is about the + // local origin of the object) + + // The rotation is composed of a yaw around the Y axis, a pitch around + // the X axis, and a roll around the Z axis. + STDMETHOD(RotateYawPitchRollLocal) + (THIS_ FLOAT Yaw, FLOAT Pitch, FLOAT Roll) PURE; + + // Right multiply the current matrix with the computed scale + // matrix. (transformation is about the current world origin) + STDMETHOD(Scale)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE; + + // Left multiply the current matrix with the computed scale + // matrix. (transformation is about the local origin of the object) + STDMETHOD(ScaleLocal)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE; + + // Right multiply the current matrix with the computed translation + // matrix. (transformation is about the current world origin) + STDMETHOD(Translate)(THIS_ FLOAT x, FLOAT y, FLOAT z ) PURE; + + // Left multiply the current matrix with the computed translation + // matrix. (transformation is about the local origin of the object) + STDMETHOD(TranslateLocal)(THIS_ FLOAT x, FLOAT y, FLOAT z) PURE; + + /* Obtain the current matrix at the top of the stack */ + STDMETHOD_(D3DXMATRIX*, GetTop)(THIS) PURE; +}; + +#ifdef __cplusplus +extern "C" { +#endif + +HRESULT WINAPI + D3DXCreateMatrixStack( + DWORD Flags, + LPD3DXMATRIXSTACK* ppStack); + +#ifdef __cplusplus +} +#endif + +#include "d3dx8math.inl" + +#pragma warning(default:4201) + +#endif /* __D3DX8MATH_H__ */ diff --git a/gfx/include/d3d8/d3dx8mesh.h b/gfx/include/d3d8/d3dx8mesh.h index d4cadd95b9..f17d92c8bd 100644 --- a/gfx/include/d3d8/d3dx8mesh.h +++ b/gfx/include/d3d8/d3dx8mesh.h @@ -1,760 +1,760 @@ -////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) Microsoft Corporation. All Rights Reserved. -// -// File: d3dx8mesh.h -// Content: D3DX mesh types and functions -// -////////////////////////////////////////////////////////////////////////////// - -#include "d3dx8.h" - -#ifndef __D3DX8MESH_H__ -#define __D3DX8MESH_H__ - -#include "dxfile.h" // defines LPDIRECTXFILEDATA - -// {2A835771-BF4D-43f4-8E14-82A809F17D8A} -DEFINE_GUID(IID_ID3DXBaseMesh, -0x2a835771, 0xbf4d, 0x43f4, 0x8e, 0x14, 0x82, 0xa8, 0x9, 0xf1, 0x7d, 0x8a); - -// {CCAE5C3B-4DD1-4d0f-997E-4684CA64557F} -DEFINE_GUID(IID_ID3DXMesh, -0xccae5c3b, 0x4dd1, 0x4d0f, 0x99, 0x7e, 0x46, 0x84, 0xca, 0x64, 0x55, 0x7f); - -// {19FBE386-C282-4659-97BD-CB869B084A6C} -DEFINE_GUID(IID_ID3DXPMesh, -0x19fbe386, 0xc282, 0x4659, 0x97, 0xbd, 0xcb, 0x86, 0x9b, 0x8, 0x4a, 0x6c); - -// {4E3CA05C-D4FF-4d11-8A02-16459E08F6F4} -DEFINE_GUID(IID_ID3DXSPMesh, -0x4e3ca05c, 0xd4ff, 0x4d11, 0x8a, 0x2, 0x16, 0x45, 0x9e, 0x8, 0xf6, 0xf4); - -// {8DB06ECC-EBFC-408a-9404-3074B4773515} -DEFINE_GUID(IID_ID3DXSkinMesh, -0x8db06ecc, 0xebfc, 0x408a, 0x94, 0x4, 0x30, 0x74, 0xb4, 0x77, 0x35, 0x15); - -// Mesh options - lower 3 bytes only, upper byte used by _D3DXMESHOPT option flags -enum _D3DXMESH { - D3DXMESH_32BIT = 0x001, // If set, then use 32 bit indices, if not set use 16 bit indices. - D3DXMESH_DONOTCLIP = 0x002, // Use D3DUSAGE_DONOTCLIP for VB & IB. - D3DXMESH_POINTS = 0x004, // Use D3DUSAGE_POINTS for VB & IB. - D3DXMESH_RTPATCHES = 0x008, // Use D3DUSAGE_RTPATCHES for VB & IB. - D3DXMESH_NPATCHES = 0x4000,// Use D3DUSAGE_NPATCHES for VB & IB. - D3DXMESH_VB_SYSTEMMEM = 0x010, // Use D3DPOOL_SYSTEMMEM for VB. Overrides D3DXMESH_MANAGEDVERTEXBUFFER - D3DXMESH_VB_MANAGED = 0x020, // Use D3DPOOL_MANAGED for VB. - D3DXMESH_VB_WRITEONLY = 0x040, // Use D3DUSAGE_WRITEONLY for VB. - D3DXMESH_VB_DYNAMIC = 0x080, // Use D3DUSAGE_DYNAMIC for VB. - D3DXMESH_VB_SOFTWAREPROCESSING = 0x8000, // Use D3DUSAGE_SOFTWAREPROCESSING for VB. - D3DXMESH_IB_SYSTEMMEM = 0x100, // Use D3DPOOL_SYSTEMMEM for IB. Overrides D3DXMESH_MANAGEDINDEXBUFFER - D3DXMESH_IB_MANAGED = 0x200, // Use D3DPOOL_MANAGED for IB. - D3DXMESH_IB_WRITEONLY = 0x400, // Use D3DUSAGE_WRITEONLY for IB. - D3DXMESH_IB_DYNAMIC = 0x800, // Use D3DUSAGE_DYNAMIC for IB. - D3DXMESH_IB_SOFTWAREPROCESSING= 0x10000, // Use D3DUSAGE_SOFTWAREPROCESSING for IB. - - D3DXMESH_VB_SHARE = 0x1000, // Valid for Clone* calls only, forces cloned mesh/pmesh to share vertex buffer - - D3DXMESH_USEHWONLY = 0x2000, // Valid for ID3DXSkinMesh::ConvertToBlendedMesh - - // Helper options - D3DXMESH_SYSTEMMEM = 0x110, // D3DXMESH_VB_SYSTEMMEM | D3DXMESH_IB_SYSTEMMEM - D3DXMESH_MANAGED = 0x220, // D3DXMESH_VB_MANAGED | D3DXMESH_IB_MANAGED - D3DXMESH_WRITEONLY = 0x440, // D3DXMESH_VB_WRITEONLY | D3DXMESH_IB_WRITEONLY - D3DXMESH_DYNAMIC = 0x880, // D3DXMESH_VB_DYNAMIC | D3DXMESH_IB_DYNAMIC - D3DXMESH_SOFTWAREPROCESSING = 0x18000, // D3DXMESH_VB_SOFTWAREPROCESSING | D3DXMESH_IB_SOFTWAREPROCESSING - -}; - -// option field values for specifying min value in D3DXGeneratePMesh and D3DXSimplifyMesh -enum _D3DXMESHSIMP -{ - D3DXMESHSIMP_VERTEX = 0x1, - D3DXMESHSIMP_FACE = 0x2, - -}; - -enum _MAX_FVF_DECL_SIZE -{ - MAX_FVF_DECL_SIZE = 20 -}; - -typedef struct ID3DXBaseMesh *LPD3DXBASEMESH; -typedef struct ID3DXMesh *LPD3DXMESH; -typedef struct ID3DXPMesh *LPD3DXPMESH; -typedef struct ID3DXSPMesh *LPD3DXSPMESH; -typedef struct ID3DXSkinMesh *LPD3DXSKINMESH; - -typedef struct _D3DXATTRIBUTERANGE -{ - DWORD AttribId; - DWORD FaceStart; - DWORD FaceCount; - DWORD VertexStart; - DWORD VertexCount; -} D3DXATTRIBUTERANGE; - -typedef D3DXATTRIBUTERANGE* LPD3DXATTRIBUTERANGE; - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus -struct D3DXMATERIAL -{ - D3DMATERIAL8 MatD3D; - LPSTR pTextureFilename; -}; -typedef struct D3DXMATERIAL *LPD3DXMATERIAL; -#ifdef __cplusplus -} -#endif //__cplusplus - -typedef struct _D3DXATTRIBUTEWEIGHTS -{ - FLOAT Position; - FLOAT Boundary; - FLOAT Normal; - FLOAT Diffuse; - FLOAT Specular; - FLOAT Tex[8]; -} D3DXATTRIBUTEWEIGHTS; - -typedef D3DXATTRIBUTEWEIGHTS* LPD3DXATTRIBUTEWEIGHTS; - -enum _D3DXWELDEPSILONSFLAGS -{ - D3DXWELDEPSILONS_WELDALL = 0x1, // weld all vertices marked by adjacency as being overlapping - - D3DXWELDEPSILONS_WELDPARTIALMATCHES = 0x2, // if a given vertex component is within epsilon, modify partial matched - // vertices so that both components identical AND if all components "equal" - // remove one of the vertices - D3DXWELDEPSILONS_DONOTREMOVEVERTICES = 0x4, // instructs weld to only allow modifications to vertices and not removal - // ONLY valid if D3DXWELDEPSILONS_WELDPARTIALMATCHES is set - // useful to modify vertices to be equal, but not allow vertices to be removed -}; - -typedef struct _D3DXWELDEPSILONS -{ - FLOAT SkinWeights; - FLOAT Normal; - FLOAT Tex[8]; - DWORD Flags; -} D3DXWELDEPSILONS; - -typedef D3DXWELDEPSILONS* LPD3DXWELDEPSILONS; - - -#undef INTERFACE -#define INTERFACE ID3DXBaseMesh - -DECLARE_INTERFACE_(ID3DXBaseMesh, IUnknown) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // ID3DXBaseMesh - STDMETHOD(DrawSubset)(THIS_ DWORD AttribId) PURE; - STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE; - STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE; - STDMETHOD_(DWORD, GetFVF)(THIS) PURE; - STDMETHOD(GetDeclaration)(THIS_ DWORD Declaration[MAX_FVF_DECL_SIZE]) PURE; - STDMETHOD_(DWORD, GetOptions)(THIS) PURE; - STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; - STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options, - DWORD FVF, LPDIRECT3DDEVICE8 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; - STDMETHOD(CloneMesh)(THIS_ DWORD Options, - CONST DWORD *pDeclaration, LPDIRECT3DDEVICE8 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; - STDMETHOD(GetVertexBuffer)(THIS_ LPDIRECT3DVERTEXBUFFER8* ppVB) PURE; - STDMETHOD(GetIndexBuffer)(THIS_ LPDIRECT3DINDEXBUFFER8* ppIB) PURE; - STDMETHOD(LockVertexBuffer)(THIS_ DWORD Flags, BYTE** ppData) PURE; - STDMETHOD(UnlockVertexBuffer)(THIS) PURE; - STDMETHOD(LockIndexBuffer)(THIS_ DWORD Flags, BYTE** ppData) PURE; - STDMETHOD(UnlockIndexBuffer)(THIS) PURE; - STDMETHOD(GetAttributeTable)( - THIS_ D3DXATTRIBUTERANGE *pAttribTable, DWORD* pAttribTableSize) PURE; - - STDMETHOD(ConvertPointRepsToAdjacency)(THIS_ CONST DWORD* pPRep, DWORD* pAdjacency) PURE; - STDMETHOD(ConvertAdjacencyToPointReps)(THIS_ CONST DWORD* pAdjacency, DWORD* pPRep) PURE; - STDMETHOD(GenerateAdjacency)(THIS_ FLOAT Epsilon, DWORD* pAdjacency) PURE; -}; - - -#undef INTERFACE -#define INTERFACE ID3DXMesh - -DECLARE_INTERFACE_(ID3DXMesh, ID3DXBaseMesh) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // ID3DXBaseMesh - STDMETHOD(DrawSubset)(THIS_ DWORD AttribId) PURE; - STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE; - STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE; - STDMETHOD_(DWORD, GetFVF)(THIS) PURE; - STDMETHOD(GetDeclaration)(THIS_ DWORD Declaration[MAX_FVF_DECL_SIZE]) PURE; - STDMETHOD_(DWORD, GetOptions)(THIS) PURE; - STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; - STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options, - DWORD FVF, LPDIRECT3DDEVICE8 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; - STDMETHOD(CloneMesh)(THIS_ DWORD Options, - CONST DWORD *pDeclaration, LPDIRECT3DDEVICE8 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; - STDMETHOD(GetVertexBuffer)(THIS_ LPDIRECT3DVERTEXBUFFER8* ppVB) PURE; - STDMETHOD(GetIndexBuffer)(THIS_ LPDIRECT3DINDEXBUFFER8* ppIB) PURE; - STDMETHOD(LockVertexBuffer)(THIS_ DWORD Flags, BYTE** ppData) PURE; - STDMETHOD(UnlockVertexBuffer)(THIS) PURE; - STDMETHOD(LockIndexBuffer)(THIS_ DWORD Flags, BYTE** ppData) PURE; - STDMETHOD(UnlockIndexBuffer)(THIS) PURE; - STDMETHOD(GetAttributeTable)( - THIS_ D3DXATTRIBUTERANGE *pAttribTable, DWORD* pAttribTableSize) PURE; - - STDMETHOD(ConvertPointRepsToAdjacency)(THIS_ CONST DWORD* pPRep, DWORD* pAdjacency) PURE; - STDMETHOD(ConvertAdjacencyToPointReps)(THIS_ CONST DWORD* pAdjacency, DWORD* pPRep) PURE; - STDMETHOD(GenerateAdjacency)(THIS_ FLOAT Epsilon, DWORD* pAdjacency) PURE; - - // ID3DXMesh - STDMETHOD(LockAttributeBuffer)(THIS_ DWORD Flags, DWORD** ppData) PURE; - STDMETHOD(UnlockAttributeBuffer)(THIS) PURE; - STDMETHOD(Optimize)(THIS_ DWORD Flags, CONST DWORD* pAdjacencyIn, DWORD* pAdjacencyOut, - DWORD* pFaceRemap, LPD3DXBUFFER *ppVertexRemap, - LPD3DXMESH* ppOptMesh) PURE; - STDMETHOD(OptimizeInplace)(THIS_ DWORD Flags, CONST DWORD* pAdjacencyIn, DWORD* pAdjacencyOut, - DWORD* pFaceRemap, LPD3DXBUFFER *ppVertexRemap) PURE; - -}; - - -#undef INTERFACE -#define INTERFACE ID3DXPMesh - -DECLARE_INTERFACE_(ID3DXPMesh, ID3DXBaseMesh) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // ID3DXBaseMesh - STDMETHOD(DrawSubset)(THIS_ DWORD AttribId) PURE; - STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE; - STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE; - STDMETHOD_(DWORD, GetFVF)(THIS) PURE; - STDMETHOD(GetDeclaration)(THIS_ DWORD Declaration[MAX_FVF_DECL_SIZE]) PURE; - STDMETHOD_(DWORD, GetOptions)(THIS) PURE; - STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; - STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options, - DWORD FVF, LPDIRECT3DDEVICE8 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; - STDMETHOD(CloneMesh)(THIS_ DWORD Options, - CONST DWORD *pDeclaration, LPDIRECT3DDEVICE8 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; - STDMETHOD(GetVertexBuffer)(THIS_ LPDIRECT3DVERTEXBUFFER8* ppVB) PURE; - STDMETHOD(GetIndexBuffer)(THIS_ LPDIRECT3DINDEXBUFFER8* ppIB) PURE; - STDMETHOD(LockVertexBuffer)(THIS_ DWORD Flags, BYTE** ppData) PURE; - STDMETHOD(UnlockVertexBuffer)(THIS) PURE; - STDMETHOD(LockIndexBuffer)(THIS_ DWORD Flags, BYTE** ppData) PURE; - STDMETHOD(UnlockIndexBuffer)(THIS) PURE; - STDMETHOD(GetAttributeTable)( - THIS_ D3DXATTRIBUTERANGE *pAttribTable, DWORD* pAttribTableSize) PURE; - - STDMETHOD(ConvertPointRepsToAdjacency)(THIS_ CONST DWORD* pPRep, DWORD* pAdjacency) PURE; - STDMETHOD(ConvertAdjacencyToPointReps)(THIS_ CONST DWORD* pAdjacency, DWORD* pPRep) PURE; - STDMETHOD(GenerateAdjacency)(THIS_ FLOAT Epsilon, DWORD* pAdjacency) PURE; - - // ID3DXPMesh - STDMETHOD(ClonePMeshFVF)(THIS_ DWORD Options, - DWORD FVF, LPDIRECT3DDEVICE8 pD3D, LPD3DXPMESH* ppCloneMesh) PURE; - STDMETHOD(ClonePMesh)(THIS_ DWORD Options, - CONST DWORD *pDeclaration, LPDIRECT3DDEVICE8 pD3D, LPD3DXPMESH* ppCloneMesh) PURE; - STDMETHOD(SetNumFaces)(THIS_ DWORD Faces) PURE; - STDMETHOD(SetNumVertices)(THIS_ DWORD Vertices) PURE; - STDMETHOD_(DWORD, GetMaxFaces)(THIS) PURE; - STDMETHOD_(DWORD, GetMinFaces)(THIS) PURE; - STDMETHOD_(DWORD, GetMaxVertices)(THIS) PURE; - STDMETHOD_(DWORD, GetMinVertices)(THIS) PURE; - STDMETHOD(Save)(THIS_ IStream *pStream, LPD3DXMATERIAL pMaterials, DWORD NumMaterials) PURE; - - STDMETHOD(Optimize)(THIS_ DWORD Flags, DWORD* pAdjacencyOut, - DWORD* pFaceRemap, LPD3DXBUFFER *ppVertexRemap, - LPD3DXMESH* ppOptMesh) PURE; - - STDMETHOD(OptimizeBaseLOD)(THIS_ DWORD Flags, DWORD* pFaceRemap) PURE; - STDMETHOD(TrimByFaces)(THIS_ DWORD NewFacesMin, DWORD NewFacesMax, DWORD *rgiFaceRemap, DWORD *rgiVertRemap) PURE; - STDMETHOD(TrimByVertices)(THIS_ DWORD NewVerticesMin, DWORD NewVerticesMax, DWORD *rgiFaceRemap, DWORD *rgiVertRemap) PURE; - - STDMETHOD(GetAdjacency)(THIS_ DWORD* pAdjacency) PURE; -}; - - -#undef INTERFACE -#define INTERFACE ID3DXSPMesh - -DECLARE_INTERFACE_(ID3DXSPMesh, IUnknown) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // ID3DXSPMesh - STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE; - STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE; - STDMETHOD_(DWORD, GetFVF)(THIS) PURE; - STDMETHOD(GetDeclaration)(THIS_ DWORD Declaration[MAX_FVF_DECL_SIZE]) PURE; - STDMETHOD_(DWORD, GetOptions)(THIS) PURE; - STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; - STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options, - DWORD FVF, LPDIRECT3DDEVICE8 pD3D, DWORD *pAdjacencyOut, DWORD *pVertexRemapOut, LPD3DXMESH* ppCloneMesh) PURE; - STDMETHOD(CloneMesh)(THIS_ DWORD Options, - CONST DWORD *pDeclaration, LPDIRECT3DDEVICE8 pD3DDevice, DWORD *pAdjacencyOut, DWORD *pVertexRemapOut, LPD3DXMESH* ppCloneMesh) PURE; - STDMETHOD(ClonePMeshFVF)(THIS_ DWORD Options, - DWORD FVF, LPDIRECT3DDEVICE8 pD3D, DWORD *pVertexRemapOut, LPD3DXPMESH* ppCloneMesh) PURE; - STDMETHOD(ClonePMesh)(THIS_ DWORD Options, - CONST DWORD *pDeclaration, LPDIRECT3DDEVICE8 pD3D, DWORD *pVertexRemapOut, LPD3DXPMESH* ppCloneMesh) PURE; - STDMETHOD(ReduceFaces)(THIS_ DWORD Faces) PURE; - STDMETHOD(ReduceVertices)(THIS_ DWORD Vertices) PURE; - STDMETHOD_(DWORD, GetMaxFaces)(THIS) PURE; - STDMETHOD_(DWORD, GetMaxVertices)(THIS) PURE; - STDMETHOD(GetVertexAttributeWeights)(THIS_ LPD3DXATTRIBUTEWEIGHTS pVertexAttributeWeights) PURE; - STDMETHOD(GetVertexWeights)(THIS_ FLOAT *pVertexWeights) PURE; -}; - -#define UNUSED16 (0xffff) -#define UNUSED32 (0xffffffff) - -// ID3DXMesh::Optimize options - upper byte only, lower 3 bytes used from _D3DXMESH option flags -enum _D3DXMESHOPT { - D3DXMESHOPT_COMPACT = 0x01000000, - D3DXMESHOPT_ATTRSORT = 0x02000000, - D3DXMESHOPT_VERTEXCACHE = 0x04000000, - D3DXMESHOPT_STRIPREORDER = 0x08000000, - D3DXMESHOPT_IGNOREVERTS = 0x10000000, // optimize faces only, don't touch vertices - D3DXMESHOPT_SHAREVB = 0x1000, // same as D3DXMESH_VB_SHARE -}; - -// Subset of the mesh that has the same attribute and bone combination. -// This subset can be rendered in a single draw call -typedef struct _D3DXBONECOMBINATION -{ - DWORD AttribId; - DWORD FaceStart; - DWORD FaceCount; - DWORD VertexStart; - DWORD VertexCount; - DWORD* BoneId; -} D3DXBONECOMBINATION, *LPD3DXBONECOMBINATION; - - -#undef INTERFACE -#define INTERFACE ID3DXSkinMesh - -DECLARE_INTERFACE_(ID3DXSkinMesh, IUnknown) -{ - // IUnknown - STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; - STDMETHOD_(ULONG, AddRef)(THIS) PURE; - STDMETHOD_(ULONG, Release)(THIS) PURE; - - // ID3DXMesh - STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE; - STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE; - STDMETHOD_(DWORD, GetFVF)(THIS) PURE; - STDMETHOD(GetDeclaration)(THIS_ DWORD Declaration[MAX_FVF_DECL_SIZE]) PURE; - STDMETHOD_(DWORD, GetOptions)(THIS) PURE; - STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; - STDMETHOD(GetVertexBuffer)(THIS_ LPDIRECT3DVERTEXBUFFER8* ppVB) PURE; - STDMETHOD(GetIndexBuffer)(THIS_ LPDIRECT3DINDEXBUFFER8* ppIB) PURE; - STDMETHOD(LockVertexBuffer)(THIS_ DWORD flags, BYTE** ppData) PURE; - STDMETHOD(UnlockVertexBuffer)(THIS) PURE; - STDMETHOD(LockIndexBuffer)(THIS_ DWORD flags, BYTE** ppData) PURE; - STDMETHOD(UnlockIndexBuffer)(THIS) PURE; - STDMETHOD(LockAttributeBuffer)(THIS_ DWORD flags, DWORD** ppData) PURE; - STDMETHOD(UnlockAttributeBuffer)(THIS) PURE; - // ID3DXSkinMesh - STDMETHOD_(DWORD, GetNumBones)(THIS) PURE; - STDMETHOD(GetOriginalMesh)(THIS_ LPD3DXMESH* ppMesh) PURE; - STDMETHOD(SetBoneInfluence)(THIS_ DWORD bone, DWORD numInfluences, CONST DWORD* vertices, CONST FLOAT* weights) PURE; - STDMETHOD_(DWORD, GetNumBoneInfluences)(THIS_ DWORD bone) PURE; - STDMETHOD(GetBoneInfluence)(THIS_ DWORD bone, DWORD* vertices, FLOAT* weights) PURE; - STDMETHOD(GetMaxVertexInfluences)(THIS_ DWORD* maxVertexInfluences) PURE; - STDMETHOD(GetMaxFaceInfluences)(THIS_ DWORD* maxFaceInfluences) PURE; - - STDMETHOD(ConvertToBlendedMesh)(THIS_ DWORD Options, - CONST LPDWORD pAdjacencyIn, - LPDWORD pAdjacencyOut, - DWORD* pNumBoneCombinations, - LPD3DXBUFFER* ppBoneCombinationTable, - DWORD* pFaceRemap, - LPD3DXBUFFER *ppVertexRemap, - LPD3DXMESH* ppMesh) PURE; - - STDMETHOD(ConvertToIndexedBlendedMesh)(THIS_ DWORD Options, - CONST LPDWORD pAdjacencyIn, - DWORD paletteSize, - LPDWORD pAdjacencyOut, - DWORD* pNumBoneCombinations, - LPD3DXBUFFER* ppBoneCombinationTable, - DWORD* pFaceRemap, - LPD3DXBUFFER *ppVertexRemap, - LPD3DXMESH* ppMesh) PURE; - - STDMETHOD(GenerateSkinnedMesh)(THIS_ DWORD Options, - FLOAT minWeight, - CONST LPDWORD pAdjacencyIn, - LPDWORD pAdjacencyOut, - DWORD* pFaceRemap, - LPD3DXBUFFER *ppVertexRemap, - LPD3DXMESH* ppMesh) PURE; - STDMETHOD(UpdateSkinnedMesh)(THIS_ CONST D3DXMATRIX* pBoneTransforms, CONST D3DXMATRIX* pBoneInvTransforms, LPD3DXMESH pMesh) PURE; -}; - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - -HRESULT WINAPI - D3DXCreateMesh( - DWORD NumFaces, - DWORD NumVertices, - DWORD Options, - CONST DWORD *pDeclaration, - LPDIRECT3DDEVICE8 pD3D, - LPD3DXMESH* ppMesh); - -HRESULT WINAPI - D3DXCreateMeshFVF( - DWORD NumFaces, - DWORD NumVertices, - DWORD Options, - DWORD FVF, - LPDIRECT3DDEVICE8 pD3D, - LPD3DXMESH* ppMesh); - -HRESULT WINAPI - D3DXCreateSPMesh( - LPD3DXMESH pMesh, - CONST DWORD* pAdjacency, - CONST LPD3DXATTRIBUTEWEIGHTS pVertexAttributeWeights, - CONST FLOAT *pVertexWeights, - LPD3DXSPMESH* ppSMesh); - -// clean a mesh up for simplification, try to make manifold -HRESULT WINAPI - D3DXCleanMesh( - LPD3DXMESH pMeshIn, - CONST DWORD* pAdjacencyIn, - LPD3DXMESH* ppMeshOut, - DWORD* pAdjacencyOut, - LPD3DXBUFFER* ppErrorsAndWarnings); - -HRESULT WINAPI - D3DXValidMesh( - LPD3DXMESH pMeshIn, - CONST DWORD* pAdjacency, - LPD3DXBUFFER* ppErrorsAndWarnings); - -HRESULT WINAPI - D3DXGeneratePMesh( - LPD3DXMESH pMesh, - CONST DWORD* pAdjacency, - CONST LPD3DXATTRIBUTEWEIGHTS pVertexAttributeWeights, - CONST FLOAT *pVertexWeights, - DWORD MinValue, - DWORD Options, - LPD3DXPMESH* ppPMesh); - -HRESULT WINAPI - D3DXSimplifyMesh( - LPD3DXMESH pMesh, - CONST DWORD* pAdjacency, - CONST LPD3DXATTRIBUTEWEIGHTS pVertexAttributeWeights, - CONST FLOAT *pVertexWeights, - DWORD MinValue, - DWORD Options, - LPD3DXMESH* ppMesh); - -HRESULT WINAPI - D3DXComputeBoundingSphere( - PVOID pPointsFVF, - DWORD NumVertices, - DWORD FVF, - D3DXVECTOR3 *pCenter, - FLOAT *pRadius); - -HRESULT WINAPI - D3DXComputeBoundingBox( - PVOID pPointsFVF, - DWORD NumVertices, - DWORD FVF, - D3DXVECTOR3 *pMin, - D3DXVECTOR3 *pMax); - -HRESULT WINAPI - D3DXComputeNormals( - LPD3DXBASEMESH pMesh, - CONST DWORD *pAdjacency); - -HRESULT WINAPI - D3DXCreateBuffer( - DWORD NumBytes, - LPD3DXBUFFER *ppBuffer); - - -HRESULT WINAPI - D3DXLoadMeshFromX( - LPSTR pFilename, - DWORD Options, - LPDIRECT3DDEVICE8 pD3D, - LPD3DXBUFFER *ppAdjacency, - LPD3DXBUFFER *ppMaterials, - DWORD *pNumMaterials, - LPD3DXMESH *ppMesh); - -HRESULT WINAPI - D3DXLoadMeshFromXInMemory( - PBYTE Memory, - DWORD SizeOfMemory, - DWORD Options, - LPDIRECT3DDEVICE8 pD3D, - LPD3DXBUFFER *ppAdjacency, - LPD3DXBUFFER *ppMaterials, - DWORD *pNumMaterials, - LPD3DXMESH *ppMesh); - -HRESULT WINAPI - D3DXLoadMeshFromXResource( - HMODULE Module, - LPCTSTR Name, - LPCTSTR Type, - DWORD Options, - LPDIRECT3DDEVICE8 pD3D, - LPD3DXBUFFER *ppAdjacency, - LPD3DXBUFFER *ppMaterials, - DWORD *pNumMaterials, - LPD3DXMESH *ppMesh); - -HRESULT WINAPI - D3DXSaveMeshToX( - LPSTR pFilename, - LPD3DXMESH pMesh, - CONST DWORD* pAdjacency, - CONST LPD3DXMATERIAL pMaterials, - DWORD NumMaterials, - DWORD Format - ); - -HRESULT WINAPI - D3DXCreatePMeshFromStream( - IStream *pStream, - DWORD Options, - LPDIRECT3DDEVICE8 pD3DDevice, - LPD3DXBUFFER *ppMaterials, - DWORD* pNumMaterials, - LPD3DXPMESH *ppPMesh); - -HRESULT WINAPI - D3DXCreateSkinMesh( - DWORD NumFaces, - DWORD NumVertices, - DWORD NumBones, - DWORD Options, - CONST DWORD *pDeclaration, - LPDIRECT3DDEVICE8 pD3D, - LPD3DXSKINMESH* ppSkinMesh); - -HRESULT WINAPI - D3DXCreateSkinMeshFVF( - DWORD NumFaces, - DWORD NumVertices, - DWORD NumBones, - DWORD Options, - DWORD FVF, - LPDIRECT3DDEVICE8 pD3D, - LPD3DXSKINMESH* ppSkinMesh); - -HRESULT WINAPI - D3DXCreateSkinMeshFromMesh( - LPD3DXMESH pMesh, - DWORD numBones, - LPD3DXSKINMESH* ppSkinMesh); - -HRESULT WINAPI - D3DXLoadMeshFromXof( - LPDIRECTXFILEDATA pXofObjMesh, - DWORD Options, - LPDIRECT3DDEVICE8 pD3DDevice, - LPD3DXBUFFER *ppAdjacency, - LPD3DXBUFFER *ppMaterials, - DWORD *pNumMaterials, - LPD3DXMESH *ppMesh); - -HRESULT WINAPI - D3DXLoadSkinMeshFromXof( - LPDIRECTXFILEDATA pxofobjMesh, - DWORD Options, - LPDIRECT3DDEVICE8 pD3D, - LPD3DXBUFFER* ppAdjacency, - LPD3DXBUFFER* ppMaterials, - DWORD *pMatOut, - LPD3DXBUFFER* ppBoneNames, - LPD3DXBUFFER* ppBoneTransforms, - LPD3DXSKINMESH* ppMesh); - -HRESULT WINAPI - D3DXTessellateNPatches( - LPD3DXMESH pMeshIn, - CONST DWORD* pAdjacencyIn, - FLOAT NumSegs, - BOOL QuadraticInterpNormals, // if false use linear intrep for normals, if true use quadratic - LPD3DXMESH *ppMeshOut, - LPD3DXBUFFER *ppAdjacencyOut); - -UINT WINAPI - D3DXGetFVFVertexSize(DWORD FVF); - -HRESULT WINAPI - D3DXDeclaratorFromFVF( - DWORD FVF, - DWORD Declaration[MAX_FVF_DECL_SIZE]); - -HRESULT WINAPI - D3DXFVFFromDeclarator( - CONST DWORD *pDeclarator, - DWORD *pFVF); - -HRESULT WINAPI - D3DXWeldVertices( - CONST LPD3DXMESH pMesh, - LPD3DXWELDEPSILONS pEpsilons, - CONST DWORD *pAdjacencyIn, - DWORD *pAdjacencyOut, - DWORD* pFaceRemap, - LPD3DXBUFFER *ppVertexRemap); - -typedef struct _D3DXINTERSECTINFO -{ - DWORD FaceIndex; // index of face intersected - FLOAT U; // Barycentric Hit Coordinates - FLOAT V; // Barycentric Hit Coordinates - FLOAT Dist; // Ray-Intersection Parameter Distance -} D3DXINTERSECTINFO, *LPD3DXINTERSECTINFO; - - -HRESULT WINAPI - D3DXIntersect( - LPD3DXBASEMESH pMesh, - CONST D3DXVECTOR3 *pRayPos, - CONST D3DXVECTOR3 *pRayDir, - BOOL *pHit, // True if any faces were intersected - DWORD *pFaceIndex, // index of closest face intersected - FLOAT *pU, // Barycentric Hit Coordinates - FLOAT *pV, // Barycentric Hit Coordinates - FLOAT *pDist, // Ray-Intersection Parameter Distance - LPD3DXBUFFER *ppAllHits, // Array of D3DXINTERSECTINFOs for all hits (not just closest) - DWORD *pCountOfHits); // Number of entries in AllHits array - -HRESULT WINAPI - D3DXIntersectSubset( - LPD3DXBASEMESH pMesh, - DWORD AttribId, - CONST D3DXVECTOR3 *pRayPos, - CONST D3DXVECTOR3 *pRayDir, - BOOL *pHit, // True if any faces were intersected - DWORD *pFaceIndex, // index of closest face intersected - FLOAT *pU, // Barycentric Hit Coordinates - FLOAT *pV, // Barycentric Hit Coordinates - FLOAT *pDist, // Ray-Intersection Parameter Distance - LPD3DXBUFFER *ppAllHits, // Array of D3DXINTERSECTINFOs for all hits (not just closest) - DWORD *pCountOfHits); // Number of entries in AllHits array - - -HRESULT WINAPI D3DXSplitMesh - ( - CONST LPD3DXMESH pMeshIn, - CONST DWORD *pAdjacencyIn, - CONST DWORD MaxSize, - CONST DWORD Options, - DWORD *pMeshesOut, - LPD3DXBUFFER *ppMeshArrayOut, - LPD3DXBUFFER *ppAdjacencyArrayOut, - LPD3DXBUFFER *ppFaceRemapArrayOut, - LPD3DXBUFFER *ppVertRemapArrayOut - ); - -BOOL D3DXIntersectTri -( - CONST D3DXVECTOR3 *p0, // Triangle vertex 0 position - CONST D3DXVECTOR3 *p1, // Triangle vertex 1 position - CONST D3DXVECTOR3 *p2, // Triangle vertex 2 position - CONST D3DXVECTOR3 *pRayPos, // Ray origin - CONST D3DXVECTOR3 *pRayDir, // Ray direction - FLOAT *pU, // Barycentric Hit Coordinates - FLOAT *pV, // Barycentric Hit Coordinates - FLOAT *pDist); // Ray-Intersection Parameter Distance - -BOOL WINAPI - D3DXSphereBoundProbe( - CONST D3DXVECTOR3 *pCenter, - FLOAT Radius, - CONST D3DXVECTOR3 *pRayPosition, - CONST D3DXVECTOR3 *pRayDirection); - -BOOL WINAPI - D3DXBoxBoundProbe( - CONST D3DXVECTOR3 *pMin, - CONST D3DXVECTOR3 *pMax, - CONST D3DXVECTOR3 *pRayPosition, - CONST D3DXVECTOR3 *pRayDirection); - -enum _D3DXERR { - D3DXERR_CANNOTMODIFYINDEXBUFFER = MAKE_DDHRESULT(2900), - D3DXERR_INVALIDMESH = MAKE_DDHRESULT(2901), - D3DXERR_CANNOTATTRSORT = MAKE_DDHRESULT(2902), - D3DXERR_SKINNINGNOTSUPPORTED = MAKE_DDHRESULT(2903), - D3DXERR_TOOMANYINFLUENCES = MAKE_DDHRESULT(2904), - D3DXERR_INVALIDDATA = MAKE_DDHRESULT(2905), - D3DXERR_LOADEDMESHASNODATA = MAKE_DDHRESULT(2906), -}; - - -#define D3DX_COMP_TANGENT_NONE 0xFFFFFFFF - -HRESULT WINAPI D3DXComputeTangent(LPD3DXMESH InMesh, - DWORD TexStage, - LPD3DXMESH OutMesh, - DWORD TexStageUVec, - DWORD TexStageVVec, - DWORD Wrap, - DWORD *Adjacency); - -HRESULT WINAPI -D3DXConvertMeshSubsetToSingleStrip -( - LPD3DXBASEMESH MeshIn, - DWORD AttribId, - DWORD IBOptions, - LPDIRECT3DINDEXBUFFER8 *ppIndexBuffer, - DWORD *pNumIndices -); - -HRESULT WINAPI -D3DXConvertMeshSubsetToStrips -( - LPD3DXBASEMESH MeshIn, - DWORD AttribId, - DWORD IBOptions, - LPDIRECT3DINDEXBUFFER8 *ppIndexBuffer, - DWORD *pNumIndices, - LPD3DXBUFFER *ppStripLengths, - DWORD *pNumStrips -); - - -#ifdef __cplusplus -} -#endif //__cplusplus - -#endif //__D3DX8MESH_H__ - - +////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Microsoft Corporation. All Rights Reserved. +// +// File: d3dx8mesh.h +// Content: D3DX mesh types and functions +// +////////////////////////////////////////////////////////////////////////////// + +#include "d3dx8.h" + +#ifndef __D3DX8MESH_H__ +#define __D3DX8MESH_H__ + +#include "dxfile.h" // defines LPDIRECTXFILEDATA + +// {2A835771-BF4D-43f4-8E14-82A809F17D8A} +DEFINE_GUID(IID_ID3DXBaseMesh, +0x2a835771, 0xbf4d, 0x43f4, 0x8e, 0x14, 0x82, 0xa8, 0x9, 0xf1, 0x7d, 0x8a); + +// {CCAE5C3B-4DD1-4d0f-997E-4684CA64557F} +DEFINE_GUID(IID_ID3DXMesh, +0xccae5c3b, 0x4dd1, 0x4d0f, 0x99, 0x7e, 0x46, 0x84, 0xca, 0x64, 0x55, 0x7f); + +// {19FBE386-C282-4659-97BD-CB869B084A6C} +DEFINE_GUID(IID_ID3DXPMesh, +0x19fbe386, 0xc282, 0x4659, 0x97, 0xbd, 0xcb, 0x86, 0x9b, 0x8, 0x4a, 0x6c); + +// {4E3CA05C-D4FF-4d11-8A02-16459E08F6F4} +DEFINE_GUID(IID_ID3DXSPMesh, +0x4e3ca05c, 0xd4ff, 0x4d11, 0x8a, 0x2, 0x16, 0x45, 0x9e, 0x8, 0xf6, 0xf4); + +// {8DB06ECC-EBFC-408a-9404-3074B4773515} +DEFINE_GUID(IID_ID3DXSkinMesh, +0x8db06ecc, 0xebfc, 0x408a, 0x94, 0x4, 0x30, 0x74, 0xb4, 0x77, 0x35, 0x15); + +// Mesh options - lower 3 bytes only, upper byte used by _D3DXMESHOPT option flags +enum _D3DXMESH { + D3DXMESH_32BIT = 0x001, // If set, then use 32 bit indices, if not set use 16 bit indices. + D3DXMESH_DONOTCLIP = 0x002, // Use D3DUSAGE_DONOTCLIP for VB & IB. + D3DXMESH_POINTS = 0x004, // Use D3DUSAGE_POINTS for VB & IB. + D3DXMESH_RTPATCHES = 0x008, // Use D3DUSAGE_RTPATCHES for VB & IB. + D3DXMESH_NPATCHES = 0x4000,// Use D3DUSAGE_NPATCHES for VB & IB. + D3DXMESH_VB_SYSTEMMEM = 0x010, // Use D3DPOOL_SYSTEMMEM for VB. Overrides D3DXMESH_MANAGEDVERTEXBUFFER + D3DXMESH_VB_MANAGED = 0x020, // Use D3DPOOL_MANAGED for VB. + D3DXMESH_VB_WRITEONLY = 0x040, // Use D3DUSAGE_WRITEONLY for VB. + D3DXMESH_VB_DYNAMIC = 0x080, // Use D3DUSAGE_DYNAMIC for VB. + D3DXMESH_VB_SOFTWAREPROCESSING = 0x8000, // Use D3DUSAGE_SOFTWAREPROCESSING for VB. + D3DXMESH_IB_SYSTEMMEM = 0x100, // Use D3DPOOL_SYSTEMMEM for IB. Overrides D3DXMESH_MANAGEDINDEXBUFFER + D3DXMESH_IB_MANAGED = 0x200, // Use D3DPOOL_MANAGED for IB. + D3DXMESH_IB_WRITEONLY = 0x400, // Use D3DUSAGE_WRITEONLY for IB. + D3DXMESH_IB_DYNAMIC = 0x800, // Use D3DUSAGE_DYNAMIC for IB. + D3DXMESH_IB_SOFTWAREPROCESSING= 0x10000, // Use D3DUSAGE_SOFTWAREPROCESSING for IB. + + D3DXMESH_VB_SHARE = 0x1000, // Valid for Clone* calls only, forces cloned mesh/pmesh to share vertex buffer + + D3DXMESH_USEHWONLY = 0x2000, // Valid for ID3DXSkinMesh::ConvertToBlendedMesh + + // Helper options + D3DXMESH_SYSTEMMEM = 0x110, // D3DXMESH_VB_SYSTEMMEM | D3DXMESH_IB_SYSTEMMEM + D3DXMESH_MANAGED = 0x220, // D3DXMESH_VB_MANAGED | D3DXMESH_IB_MANAGED + D3DXMESH_WRITEONLY = 0x440, // D3DXMESH_VB_WRITEONLY | D3DXMESH_IB_WRITEONLY + D3DXMESH_DYNAMIC = 0x880, // D3DXMESH_VB_DYNAMIC | D3DXMESH_IB_DYNAMIC + D3DXMESH_SOFTWAREPROCESSING = 0x18000, // D3DXMESH_VB_SOFTWAREPROCESSING | D3DXMESH_IB_SOFTWAREPROCESSING + +}; + +// option field values for specifying min value in D3DXGeneratePMesh and D3DXSimplifyMesh +enum _D3DXMESHSIMP +{ + D3DXMESHSIMP_VERTEX = 0x1, + D3DXMESHSIMP_FACE = 0x2, + +}; + +enum _MAX_FVF_DECL_SIZE +{ + MAX_FVF_DECL_SIZE = 20 +}; + +typedef struct ID3DXBaseMesh *LPD3DXBASEMESH; +typedef struct ID3DXMesh *LPD3DXMESH; +typedef struct ID3DXPMesh *LPD3DXPMESH; +typedef struct ID3DXSPMesh *LPD3DXSPMESH; +typedef struct ID3DXSkinMesh *LPD3DXSKINMESH; + +typedef struct _D3DXATTRIBUTERANGE +{ + DWORD AttribId; + DWORD FaceStart; + DWORD FaceCount; + DWORD VertexStart; + DWORD VertexCount; +} D3DXATTRIBUTERANGE; + +typedef D3DXATTRIBUTERANGE* LPD3DXATTRIBUTERANGE; + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus +struct D3DXMATERIAL +{ + D3DMATERIAL8 MatD3D; + LPSTR pTextureFilename; +}; +typedef struct D3DXMATERIAL *LPD3DXMATERIAL; +#ifdef __cplusplus +} +#endif //__cplusplus + +typedef struct _D3DXATTRIBUTEWEIGHTS +{ + FLOAT Position; + FLOAT Boundary; + FLOAT Normal; + FLOAT Diffuse; + FLOAT Specular; + FLOAT Tex[8]; +} D3DXATTRIBUTEWEIGHTS; + +typedef D3DXATTRIBUTEWEIGHTS* LPD3DXATTRIBUTEWEIGHTS; + +enum _D3DXWELDEPSILONSFLAGS +{ + D3DXWELDEPSILONS_WELDALL = 0x1, // weld all vertices marked by adjacency as being overlapping + + D3DXWELDEPSILONS_WELDPARTIALMATCHES = 0x2, // if a given vertex component is within epsilon, modify partial matched + // vertices so that both components identical AND if all components "equal" + // remove one of the vertices + D3DXWELDEPSILONS_DONOTREMOVEVERTICES = 0x4, // instructs weld to only allow modifications to vertices and not removal + // ONLY valid if D3DXWELDEPSILONS_WELDPARTIALMATCHES is set + // useful to modify vertices to be equal, but not allow vertices to be removed +}; + +typedef struct _D3DXWELDEPSILONS +{ + FLOAT SkinWeights; + FLOAT Normal; + FLOAT Tex[8]; + DWORD Flags; +} D3DXWELDEPSILONS; + +typedef D3DXWELDEPSILONS* LPD3DXWELDEPSILONS; + + +#undef INTERFACE +#define INTERFACE ID3DXBaseMesh + +DECLARE_INTERFACE_(ID3DXBaseMesh, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXBaseMesh + STDMETHOD(DrawSubset)(THIS_ DWORD AttribId) PURE; + STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE; + STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE; + STDMETHOD_(DWORD, GetFVF)(THIS) PURE; + STDMETHOD(GetDeclaration)(THIS_ DWORD Declaration[MAX_FVF_DECL_SIZE]) PURE; + STDMETHOD_(DWORD, GetOptions)(THIS) PURE; + STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; + STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options, + DWORD FVF, LPDIRECT3DDEVICE8 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; + STDMETHOD(CloneMesh)(THIS_ DWORD Options, + CONST DWORD *pDeclaration, LPDIRECT3DDEVICE8 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; + STDMETHOD(GetVertexBuffer)(THIS_ LPDIRECT3DVERTEXBUFFER8* ppVB) PURE; + STDMETHOD(GetIndexBuffer)(THIS_ LPDIRECT3DINDEXBUFFER8* ppIB) PURE; + STDMETHOD(LockVertexBuffer)(THIS_ DWORD Flags, BYTE** ppData) PURE; + STDMETHOD(UnlockVertexBuffer)(THIS) PURE; + STDMETHOD(LockIndexBuffer)(THIS_ DWORD Flags, BYTE** ppData) PURE; + STDMETHOD(UnlockIndexBuffer)(THIS) PURE; + STDMETHOD(GetAttributeTable)( + THIS_ D3DXATTRIBUTERANGE *pAttribTable, DWORD* pAttribTableSize) PURE; + + STDMETHOD(ConvertPointRepsToAdjacency)(THIS_ CONST DWORD* pPRep, DWORD* pAdjacency) PURE; + STDMETHOD(ConvertAdjacencyToPointReps)(THIS_ CONST DWORD* pAdjacency, DWORD* pPRep) PURE; + STDMETHOD(GenerateAdjacency)(THIS_ FLOAT Epsilon, DWORD* pAdjacency) PURE; +}; + + +#undef INTERFACE +#define INTERFACE ID3DXMesh + +DECLARE_INTERFACE_(ID3DXMesh, ID3DXBaseMesh) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXBaseMesh + STDMETHOD(DrawSubset)(THIS_ DWORD AttribId) PURE; + STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE; + STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE; + STDMETHOD_(DWORD, GetFVF)(THIS) PURE; + STDMETHOD(GetDeclaration)(THIS_ DWORD Declaration[MAX_FVF_DECL_SIZE]) PURE; + STDMETHOD_(DWORD, GetOptions)(THIS) PURE; + STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; + STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options, + DWORD FVF, LPDIRECT3DDEVICE8 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; + STDMETHOD(CloneMesh)(THIS_ DWORD Options, + CONST DWORD *pDeclaration, LPDIRECT3DDEVICE8 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; + STDMETHOD(GetVertexBuffer)(THIS_ LPDIRECT3DVERTEXBUFFER8* ppVB) PURE; + STDMETHOD(GetIndexBuffer)(THIS_ LPDIRECT3DINDEXBUFFER8* ppIB) PURE; + STDMETHOD(LockVertexBuffer)(THIS_ DWORD Flags, BYTE** ppData) PURE; + STDMETHOD(UnlockVertexBuffer)(THIS) PURE; + STDMETHOD(LockIndexBuffer)(THIS_ DWORD Flags, BYTE** ppData) PURE; + STDMETHOD(UnlockIndexBuffer)(THIS) PURE; + STDMETHOD(GetAttributeTable)( + THIS_ D3DXATTRIBUTERANGE *pAttribTable, DWORD* pAttribTableSize) PURE; + + STDMETHOD(ConvertPointRepsToAdjacency)(THIS_ CONST DWORD* pPRep, DWORD* pAdjacency) PURE; + STDMETHOD(ConvertAdjacencyToPointReps)(THIS_ CONST DWORD* pAdjacency, DWORD* pPRep) PURE; + STDMETHOD(GenerateAdjacency)(THIS_ FLOAT Epsilon, DWORD* pAdjacency) PURE; + + // ID3DXMesh + STDMETHOD(LockAttributeBuffer)(THIS_ DWORD Flags, DWORD** ppData) PURE; + STDMETHOD(UnlockAttributeBuffer)(THIS) PURE; + STDMETHOD(Optimize)(THIS_ DWORD Flags, CONST DWORD* pAdjacencyIn, DWORD* pAdjacencyOut, + DWORD* pFaceRemap, LPD3DXBUFFER *ppVertexRemap, + LPD3DXMESH* ppOptMesh) PURE; + STDMETHOD(OptimizeInplace)(THIS_ DWORD Flags, CONST DWORD* pAdjacencyIn, DWORD* pAdjacencyOut, + DWORD* pFaceRemap, LPD3DXBUFFER *ppVertexRemap) PURE; + +}; + + +#undef INTERFACE +#define INTERFACE ID3DXPMesh + +DECLARE_INTERFACE_(ID3DXPMesh, ID3DXBaseMesh) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXBaseMesh + STDMETHOD(DrawSubset)(THIS_ DWORD AttribId) PURE; + STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE; + STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE; + STDMETHOD_(DWORD, GetFVF)(THIS) PURE; + STDMETHOD(GetDeclaration)(THIS_ DWORD Declaration[MAX_FVF_DECL_SIZE]) PURE; + STDMETHOD_(DWORD, GetOptions)(THIS) PURE; + STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; + STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options, + DWORD FVF, LPDIRECT3DDEVICE8 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; + STDMETHOD(CloneMesh)(THIS_ DWORD Options, + CONST DWORD *pDeclaration, LPDIRECT3DDEVICE8 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; + STDMETHOD(GetVertexBuffer)(THIS_ LPDIRECT3DVERTEXBUFFER8* ppVB) PURE; + STDMETHOD(GetIndexBuffer)(THIS_ LPDIRECT3DINDEXBUFFER8* ppIB) PURE; + STDMETHOD(LockVertexBuffer)(THIS_ DWORD Flags, BYTE** ppData) PURE; + STDMETHOD(UnlockVertexBuffer)(THIS) PURE; + STDMETHOD(LockIndexBuffer)(THIS_ DWORD Flags, BYTE** ppData) PURE; + STDMETHOD(UnlockIndexBuffer)(THIS) PURE; + STDMETHOD(GetAttributeTable)( + THIS_ D3DXATTRIBUTERANGE *pAttribTable, DWORD* pAttribTableSize) PURE; + + STDMETHOD(ConvertPointRepsToAdjacency)(THIS_ CONST DWORD* pPRep, DWORD* pAdjacency) PURE; + STDMETHOD(ConvertAdjacencyToPointReps)(THIS_ CONST DWORD* pAdjacency, DWORD* pPRep) PURE; + STDMETHOD(GenerateAdjacency)(THIS_ FLOAT Epsilon, DWORD* pAdjacency) PURE; + + // ID3DXPMesh + STDMETHOD(ClonePMeshFVF)(THIS_ DWORD Options, + DWORD FVF, LPDIRECT3DDEVICE8 pD3D, LPD3DXPMESH* ppCloneMesh) PURE; + STDMETHOD(ClonePMesh)(THIS_ DWORD Options, + CONST DWORD *pDeclaration, LPDIRECT3DDEVICE8 pD3D, LPD3DXPMESH* ppCloneMesh) PURE; + STDMETHOD(SetNumFaces)(THIS_ DWORD Faces) PURE; + STDMETHOD(SetNumVertices)(THIS_ DWORD Vertices) PURE; + STDMETHOD_(DWORD, GetMaxFaces)(THIS) PURE; + STDMETHOD_(DWORD, GetMinFaces)(THIS) PURE; + STDMETHOD_(DWORD, GetMaxVertices)(THIS) PURE; + STDMETHOD_(DWORD, GetMinVertices)(THIS) PURE; + STDMETHOD(Save)(THIS_ IStream *pStream, LPD3DXMATERIAL pMaterials, DWORD NumMaterials) PURE; + + STDMETHOD(Optimize)(THIS_ DWORD Flags, DWORD* pAdjacencyOut, + DWORD* pFaceRemap, LPD3DXBUFFER *ppVertexRemap, + LPD3DXMESH* ppOptMesh) PURE; + + STDMETHOD(OptimizeBaseLOD)(THIS_ DWORD Flags, DWORD* pFaceRemap) PURE; + STDMETHOD(TrimByFaces)(THIS_ DWORD NewFacesMin, DWORD NewFacesMax, DWORD *rgiFaceRemap, DWORD *rgiVertRemap) PURE; + STDMETHOD(TrimByVertices)(THIS_ DWORD NewVerticesMin, DWORD NewVerticesMax, DWORD *rgiFaceRemap, DWORD *rgiVertRemap) PURE; + + STDMETHOD(GetAdjacency)(THIS_ DWORD* pAdjacency) PURE; +}; + + +#undef INTERFACE +#define INTERFACE ID3DXSPMesh + +DECLARE_INTERFACE_(ID3DXSPMesh, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXSPMesh + STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE; + STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE; + STDMETHOD_(DWORD, GetFVF)(THIS) PURE; + STDMETHOD(GetDeclaration)(THIS_ DWORD Declaration[MAX_FVF_DECL_SIZE]) PURE; + STDMETHOD_(DWORD, GetOptions)(THIS) PURE; + STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; + STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options, + DWORD FVF, LPDIRECT3DDEVICE8 pD3D, DWORD *pAdjacencyOut, DWORD *pVertexRemapOut, LPD3DXMESH* ppCloneMesh) PURE; + STDMETHOD(CloneMesh)(THIS_ DWORD Options, + CONST DWORD *pDeclaration, LPDIRECT3DDEVICE8 pD3DDevice, DWORD *pAdjacencyOut, DWORD *pVertexRemapOut, LPD3DXMESH* ppCloneMesh) PURE; + STDMETHOD(ClonePMeshFVF)(THIS_ DWORD Options, + DWORD FVF, LPDIRECT3DDEVICE8 pD3D, DWORD *pVertexRemapOut, LPD3DXPMESH* ppCloneMesh) PURE; + STDMETHOD(ClonePMesh)(THIS_ DWORD Options, + CONST DWORD *pDeclaration, LPDIRECT3DDEVICE8 pD3D, DWORD *pVertexRemapOut, LPD3DXPMESH* ppCloneMesh) PURE; + STDMETHOD(ReduceFaces)(THIS_ DWORD Faces) PURE; + STDMETHOD(ReduceVertices)(THIS_ DWORD Vertices) PURE; + STDMETHOD_(DWORD, GetMaxFaces)(THIS) PURE; + STDMETHOD_(DWORD, GetMaxVertices)(THIS) PURE; + STDMETHOD(GetVertexAttributeWeights)(THIS_ LPD3DXATTRIBUTEWEIGHTS pVertexAttributeWeights) PURE; + STDMETHOD(GetVertexWeights)(THIS_ FLOAT *pVertexWeights) PURE; +}; + +#define UNUSED16 (0xffff) +#define UNUSED32 (0xffffffff) + +// ID3DXMesh::Optimize options - upper byte only, lower 3 bytes used from _D3DXMESH option flags +enum _D3DXMESHOPT { + D3DXMESHOPT_COMPACT = 0x01000000, + D3DXMESHOPT_ATTRSORT = 0x02000000, + D3DXMESHOPT_VERTEXCACHE = 0x04000000, + D3DXMESHOPT_STRIPREORDER = 0x08000000, + D3DXMESHOPT_IGNOREVERTS = 0x10000000, // optimize faces only, don't touch vertices + D3DXMESHOPT_SHAREVB = 0x1000, // same as D3DXMESH_VB_SHARE +}; + +// Subset of the mesh that has the same attribute and bone combination. +// This subset can be rendered in a single draw call +typedef struct _D3DXBONECOMBINATION +{ + DWORD AttribId; + DWORD FaceStart; + DWORD FaceCount; + DWORD VertexStart; + DWORD VertexCount; + DWORD* BoneId; +} D3DXBONECOMBINATION, *LPD3DXBONECOMBINATION; + + +#undef INTERFACE +#define INTERFACE ID3DXSkinMesh + +DECLARE_INTERFACE_(ID3DXSkinMesh, IUnknown) +{ + // IUnknown + STDMETHOD(QueryInterface)(THIS_ REFIID iid, LPVOID *ppv) PURE; + STDMETHOD_(ULONG, AddRef)(THIS) PURE; + STDMETHOD_(ULONG, Release)(THIS) PURE; + + // ID3DXMesh + STDMETHOD_(DWORD, GetNumFaces)(THIS) PURE; + STDMETHOD_(DWORD, GetNumVertices)(THIS) PURE; + STDMETHOD_(DWORD, GetFVF)(THIS) PURE; + STDMETHOD(GetDeclaration)(THIS_ DWORD Declaration[MAX_FVF_DECL_SIZE]) PURE; + STDMETHOD_(DWORD, GetOptions)(THIS) PURE; + STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE8* ppDevice) PURE; + STDMETHOD(GetVertexBuffer)(THIS_ LPDIRECT3DVERTEXBUFFER8* ppVB) PURE; + STDMETHOD(GetIndexBuffer)(THIS_ LPDIRECT3DINDEXBUFFER8* ppIB) PURE; + STDMETHOD(LockVertexBuffer)(THIS_ DWORD flags, BYTE** ppData) PURE; + STDMETHOD(UnlockVertexBuffer)(THIS) PURE; + STDMETHOD(LockIndexBuffer)(THIS_ DWORD flags, BYTE** ppData) PURE; + STDMETHOD(UnlockIndexBuffer)(THIS) PURE; + STDMETHOD(LockAttributeBuffer)(THIS_ DWORD flags, DWORD** ppData) PURE; + STDMETHOD(UnlockAttributeBuffer)(THIS) PURE; + // ID3DXSkinMesh + STDMETHOD_(DWORD, GetNumBones)(THIS) PURE; + STDMETHOD(GetOriginalMesh)(THIS_ LPD3DXMESH* ppMesh) PURE; + STDMETHOD(SetBoneInfluence)(THIS_ DWORD bone, DWORD numInfluences, CONST DWORD* vertices, CONST FLOAT* weights) PURE; + STDMETHOD_(DWORD, GetNumBoneInfluences)(THIS_ DWORD bone) PURE; + STDMETHOD(GetBoneInfluence)(THIS_ DWORD bone, DWORD* vertices, FLOAT* weights) PURE; + STDMETHOD(GetMaxVertexInfluences)(THIS_ DWORD* maxVertexInfluences) PURE; + STDMETHOD(GetMaxFaceInfluences)(THIS_ DWORD* maxFaceInfluences) PURE; + + STDMETHOD(ConvertToBlendedMesh)(THIS_ DWORD Options, + CONST LPDWORD pAdjacencyIn, + LPDWORD pAdjacencyOut, + DWORD* pNumBoneCombinations, + LPD3DXBUFFER* ppBoneCombinationTable, + DWORD* pFaceRemap, + LPD3DXBUFFER *ppVertexRemap, + LPD3DXMESH* ppMesh) PURE; + + STDMETHOD(ConvertToIndexedBlendedMesh)(THIS_ DWORD Options, + CONST LPDWORD pAdjacencyIn, + DWORD paletteSize, + LPDWORD pAdjacencyOut, + DWORD* pNumBoneCombinations, + LPD3DXBUFFER* ppBoneCombinationTable, + DWORD* pFaceRemap, + LPD3DXBUFFER *ppVertexRemap, + LPD3DXMESH* ppMesh) PURE; + + STDMETHOD(GenerateSkinnedMesh)(THIS_ DWORD Options, + FLOAT minWeight, + CONST LPDWORD pAdjacencyIn, + LPDWORD pAdjacencyOut, + DWORD* pFaceRemap, + LPD3DXBUFFER *ppVertexRemap, + LPD3DXMESH* ppMesh) PURE; + STDMETHOD(UpdateSkinnedMesh)(THIS_ CONST D3DXMATRIX* pBoneTransforms, CONST D3DXMATRIX* pBoneInvTransforms, LPD3DXMESH pMesh) PURE; +}; + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + +HRESULT WINAPI + D3DXCreateMesh( + DWORD NumFaces, + DWORD NumVertices, + DWORD Options, + CONST DWORD *pDeclaration, + LPDIRECT3DDEVICE8 pD3D, + LPD3DXMESH* ppMesh); + +HRESULT WINAPI + D3DXCreateMeshFVF( + DWORD NumFaces, + DWORD NumVertices, + DWORD Options, + DWORD FVF, + LPDIRECT3DDEVICE8 pD3D, + LPD3DXMESH* ppMesh); + +HRESULT WINAPI + D3DXCreateSPMesh( + LPD3DXMESH pMesh, + CONST DWORD* pAdjacency, + CONST LPD3DXATTRIBUTEWEIGHTS pVertexAttributeWeights, + CONST FLOAT *pVertexWeights, + LPD3DXSPMESH* ppSMesh); + +// clean a mesh up for simplification, try to make manifold +HRESULT WINAPI + D3DXCleanMesh( + LPD3DXMESH pMeshIn, + CONST DWORD* pAdjacencyIn, + LPD3DXMESH* ppMeshOut, + DWORD* pAdjacencyOut, + LPD3DXBUFFER* ppErrorsAndWarnings); + +HRESULT WINAPI + D3DXValidMesh( + LPD3DXMESH pMeshIn, + CONST DWORD* pAdjacency, + LPD3DXBUFFER* ppErrorsAndWarnings); + +HRESULT WINAPI + D3DXGeneratePMesh( + LPD3DXMESH pMesh, + CONST DWORD* pAdjacency, + CONST LPD3DXATTRIBUTEWEIGHTS pVertexAttributeWeights, + CONST FLOAT *pVertexWeights, + DWORD MinValue, + DWORD Options, + LPD3DXPMESH* ppPMesh); + +HRESULT WINAPI + D3DXSimplifyMesh( + LPD3DXMESH pMesh, + CONST DWORD* pAdjacency, + CONST LPD3DXATTRIBUTEWEIGHTS pVertexAttributeWeights, + CONST FLOAT *pVertexWeights, + DWORD MinValue, + DWORD Options, + LPD3DXMESH* ppMesh); + +HRESULT WINAPI + D3DXComputeBoundingSphere( + PVOID pPointsFVF, + DWORD NumVertices, + DWORD FVF, + D3DXVECTOR3 *pCenter, + FLOAT *pRadius); + +HRESULT WINAPI + D3DXComputeBoundingBox( + PVOID pPointsFVF, + DWORD NumVertices, + DWORD FVF, + D3DXVECTOR3 *pMin, + D3DXVECTOR3 *pMax); + +HRESULT WINAPI + D3DXComputeNormals( + LPD3DXBASEMESH pMesh, + CONST DWORD *pAdjacency); + +HRESULT WINAPI + D3DXCreateBuffer( + DWORD NumBytes, + LPD3DXBUFFER *ppBuffer); + + +HRESULT WINAPI + D3DXLoadMeshFromX( + LPSTR pFilename, + DWORD Options, + LPDIRECT3DDEVICE8 pD3D, + LPD3DXBUFFER *ppAdjacency, + LPD3DXBUFFER *ppMaterials, + DWORD *pNumMaterials, + LPD3DXMESH *ppMesh); + +HRESULT WINAPI + D3DXLoadMeshFromXInMemory( + PBYTE Memory, + DWORD SizeOfMemory, + DWORD Options, + LPDIRECT3DDEVICE8 pD3D, + LPD3DXBUFFER *ppAdjacency, + LPD3DXBUFFER *ppMaterials, + DWORD *pNumMaterials, + LPD3DXMESH *ppMesh); + +HRESULT WINAPI + D3DXLoadMeshFromXResource( + HMODULE Module, + LPCTSTR Name, + LPCTSTR Type, + DWORD Options, + LPDIRECT3DDEVICE8 pD3D, + LPD3DXBUFFER *ppAdjacency, + LPD3DXBUFFER *ppMaterials, + DWORD *pNumMaterials, + LPD3DXMESH *ppMesh); + +HRESULT WINAPI + D3DXSaveMeshToX( + LPSTR pFilename, + LPD3DXMESH pMesh, + CONST DWORD* pAdjacency, + CONST LPD3DXMATERIAL pMaterials, + DWORD NumMaterials, + DWORD Format + ); + +HRESULT WINAPI + D3DXCreatePMeshFromStream( + IStream *pStream, + DWORD Options, + LPDIRECT3DDEVICE8 pD3DDevice, + LPD3DXBUFFER *ppMaterials, + DWORD* pNumMaterials, + LPD3DXPMESH *ppPMesh); + +HRESULT WINAPI + D3DXCreateSkinMesh( + DWORD NumFaces, + DWORD NumVertices, + DWORD NumBones, + DWORD Options, + CONST DWORD *pDeclaration, + LPDIRECT3DDEVICE8 pD3D, + LPD3DXSKINMESH* ppSkinMesh); + +HRESULT WINAPI + D3DXCreateSkinMeshFVF( + DWORD NumFaces, + DWORD NumVertices, + DWORD NumBones, + DWORD Options, + DWORD FVF, + LPDIRECT3DDEVICE8 pD3D, + LPD3DXSKINMESH* ppSkinMesh); + +HRESULT WINAPI + D3DXCreateSkinMeshFromMesh( + LPD3DXMESH pMesh, + DWORD numBones, + LPD3DXSKINMESH* ppSkinMesh); + +HRESULT WINAPI + D3DXLoadMeshFromXof( + LPDIRECTXFILEDATA pXofObjMesh, + DWORD Options, + LPDIRECT3DDEVICE8 pD3DDevice, + LPD3DXBUFFER *ppAdjacency, + LPD3DXBUFFER *ppMaterials, + DWORD *pNumMaterials, + LPD3DXMESH *ppMesh); + +HRESULT WINAPI + D3DXLoadSkinMeshFromXof( + LPDIRECTXFILEDATA pxofobjMesh, + DWORD Options, + LPDIRECT3DDEVICE8 pD3D, + LPD3DXBUFFER* ppAdjacency, + LPD3DXBUFFER* ppMaterials, + DWORD *pMatOut, + LPD3DXBUFFER* ppBoneNames, + LPD3DXBUFFER* ppBoneTransforms, + LPD3DXSKINMESH* ppMesh); + +HRESULT WINAPI + D3DXTessellateNPatches( + LPD3DXMESH pMeshIn, + CONST DWORD* pAdjacencyIn, + FLOAT NumSegs, + BOOL QuadraticInterpNormals, // if false use linear intrep for normals, if true use quadratic + LPD3DXMESH *ppMeshOut, + LPD3DXBUFFER *ppAdjacencyOut); + +UINT WINAPI + D3DXGetFVFVertexSize(DWORD FVF); + +HRESULT WINAPI + D3DXDeclaratorFromFVF( + DWORD FVF, + DWORD Declaration[MAX_FVF_DECL_SIZE]); + +HRESULT WINAPI + D3DXFVFFromDeclarator( + CONST DWORD *pDeclarator, + DWORD *pFVF); + +HRESULT WINAPI + D3DXWeldVertices( + CONST LPD3DXMESH pMesh, + LPD3DXWELDEPSILONS pEpsilons, + CONST DWORD *pAdjacencyIn, + DWORD *pAdjacencyOut, + DWORD* pFaceRemap, + LPD3DXBUFFER *ppVertexRemap); + +typedef struct _D3DXINTERSECTINFO +{ + DWORD FaceIndex; // index of face intersected + FLOAT U; // Barycentric Hit Coordinates + FLOAT V; // Barycentric Hit Coordinates + FLOAT Dist; // Ray-Intersection Parameter Distance +} D3DXINTERSECTINFO, *LPD3DXINTERSECTINFO; + + +HRESULT WINAPI + D3DXIntersect( + LPD3DXBASEMESH pMesh, + CONST D3DXVECTOR3 *pRayPos, + CONST D3DXVECTOR3 *pRayDir, + BOOL *pHit, // True if any faces were intersected + DWORD *pFaceIndex, // index of closest face intersected + FLOAT *pU, // Barycentric Hit Coordinates + FLOAT *pV, // Barycentric Hit Coordinates + FLOAT *pDist, // Ray-Intersection Parameter Distance + LPD3DXBUFFER *ppAllHits, // Array of D3DXINTERSECTINFOs for all hits (not just closest) + DWORD *pCountOfHits); // Number of entries in AllHits array + +HRESULT WINAPI + D3DXIntersectSubset( + LPD3DXBASEMESH pMesh, + DWORD AttribId, + CONST D3DXVECTOR3 *pRayPos, + CONST D3DXVECTOR3 *pRayDir, + BOOL *pHit, // True if any faces were intersected + DWORD *pFaceIndex, // index of closest face intersected + FLOAT *pU, // Barycentric Hit Coordinates + FLOAT *pV, // Barycentric Hit Coordinates + FLOAT *pDist, // Ray-Intersection Parameter Distance + LPD3DXBUFFER *ppAllHits, // Array of D3DXINTERSECTINFOs for all hits (not just closest) + DWORD *pCountOfHits); // Number of entries in AllHits array + + +HRESULT WINAPI D3DXSplitMesh + ( + CONST LPD3DXMESH pMeshIn, + CONST DWORD *pAdjacencyIn, + CONST DWORD MaxSize, + CONST DWORD Options, + DWORD *pMeshesOut, + LPD3DXBUFFER *ppMeshArrayOut, + LPD3DXBUFFER *ppAdjacencyArrayOut, + LPD3DXBUFFER *ppFaceRemapArrayOut, + LPD3DXBUFFER *ppVertRemapArrayOut + ); + +BOOL D3DXIntersectTri +( + CONST D3DXVECTOR3 *p0, // Triangle vertex 0 position + CONST D3DXVECTOR3 *p1, // Triangle vertex 1 position + CONST D3DXVECTOR3 *p2, // Triangle vertex 2 position + CONST D3DXVECTOR3 *pRayPos, // Ray origin + CONST D3DXVECTOR3 *pRayDir, // Ray direction + FLOAT *pU, // Barycentric Hit Coordinates + FLOAT *pV, // Barycentric Hit Coordinates + FLOAT *pDist); // Ray-Intersection Parameter Distance + +BOOL WINAPI + D3DXSphereBoundProbe( + CONST D3DXVECTOR3 *pCenter, + FLOAT Radius, + CONST D3DXVECTOR3 *pRayPosition, + CONST D3DXVECTOR3 *pRayDirection); + +BOOL WINAPI + D3DXBoxBoundProbe( + CONST D3DXVECTOR3 *pMin, + CONST D3DXVECTOR3 *pMax, + CONST D3DXVECTOR3 *pRayPosition, + CONST D3DXVECTOR3 *pRayDirection); + +enum _D3DXERR { + D3DXERR_CANNOTMODIFYINDEXBUFFER = MAKE_DDHRESULT(2900), + D3DXERR_INVALIDMESH = MAKE_DDHRESULT(2901), + D3DXERR_CANNOTATTRSORT = MAKE_DDHRESULT(2902), + D3DXERR_SKINNINGNOTSUPPORTED = MAKE_DDHRESULT(2903), + D3DXERR_TOOMANYINFLUENCES = MAKE_DDHRESULT(2904), + D3DXERR_INVALIDDATA = MAKE_DDHRESULT(2905), + D3DXERR_LOADEDMESHASNODATA = MAKE_DDHRESULT(2906), +}; + + +#define D3DX_COMP_TANGENT_NONE 0xFFFFFFFF + +HRESULT WINAPI D3DXComputeTangent(LPD3DXMESH InMesh, + DWORD TexStage, + LPD3DXMESH OutMesh, + DWORD TexStageUVec, + DWORD TexStageVVec, + DWORD Wrap, + DWORD *Adjacency); + +HRESULT WINAPI +D3DXConvertMeshSubsetToSingleStrip +( + LPD3DXBASEMESH MeshIn, + DWORD AttribId, + DWORD IBOptions, + LPDIRECT3DINDEXBUFFER8 *ppIndexBuffer, + DWORD *pNumIndices +); + +HRESULT WINAPI +D3DXConvertMeshSubsetToStrips +( + LPD3DXBASEMESH MeshIn, + DWORD AttribId, + DWORD IBOptions, + LPDIRECT3DINDEXBUFFER8 *ppIndexBuffer, + DWORD *pNumIndices, + LPD3DXBUFFER *ppStripLengths, + DWORD *pNumStrips +); + + +#ifdef __cplusplus +} +#endif //__cplusplus + +#endif //__D3DX8MESH_H__ + + diff --git a/gfx/include/d3d8/d3dx8shape.h b/gfx/include/d3d8/d3dx8shape.h index c4d3630983..e874d6479f 100644 --- a/gfx/include/d3d8/d3dx8shape.h +++ b/gfx/include/d3d8/d3dx8shape.h @@ -1,220 +1,220 @@ -/////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) Microsoft Corporation. All Rights Reserved. -// -// File: d3dx8shapes.h -// Content: D3DX simple shapes -// -/////////////////////////////////////////////////////////////////////////// - -#include "d3dx8.h" - -#ifndef __D3DX8SHAPES_H__ -#define __D3DX8SHAPES_H__ - -/////////////////////////////////////////////////////////////////////////// -// Functions: -/////////////////////////////////////////////////////////////////////////// - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - - -//------------------------------------------------------------------------- -// D3DXCreatePolygon: -// ------------------ -// Creates a mesh containing an n-sided polygon. The polygon is centered -// at the origin. -// -// Parameters: -// -// pDevice The D3D device with which the mesh is going to be used. -// Length Length of each side. -// Sides Number of sides the polygon has. (Must be >= 3) -// ppMesh The mesh object which will be created -// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. -//------------------------------------------------------------------------- -HRESULT WINAPI - D3DXCreatePolygon( - LPDIRECT3DDEVICE8 pDevice, - FLOAT Length, - UINT Sides, - LPD3DXMESH* ppMesh, - LPD3DXBUFFER* ppAdjacency); - - -//------------------------------------------------------------------------- -// D3DXCreateBox: -// -------------- -// Creates a mesh containing an axis-aligned box. The box is centered at -// the origin. -// -// Parameters: -// -// pDevice The D3D device with which the mesh is going to be used. -// Width Width of box (along X-axis) -// Height Height of box (along Y-axis) -// Depth Depth of box (along Z-axis) -// ppMesh The mesh object which will be created -// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. -//------------------------------------------------------------------------- -HRESULT WINAPI - D3DXCreateBox( - LPDIRECT3DDEVICE8 pDevice, - FLOAT Width, - FLOAT Height, - FLOAT Depth, - LPD3DXMESH* ppMesh, - LPD3DXBUFFER* ppAdjacency); - - -//------------------------------------------------------------------------- -// D3DXCreateCylinder: -// ------------------- -// Creates a mesh containing a cylinder. The generated cylinder is -// centered at the origin, and its axis is aligned with the Z-axis. -// -// Parameters: -// -// pDevice The D3D device with which the mesh is going to be used. -// Radius1 Radius at -Z end (should be >= 0.0f) -// Radius2 Radius at +Z end (should be >= 0.0f) -// Length Length of cylinder (along Z-axis) -// Slices Number of slices about the main axis -// Stacks Number of stacks along the main axis -// ppMesh The mesh object which will be created -// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. -//------------------------------------------------------------------------- -HRESULT WINAPI - D3DXCreateCylinder( - LPDIRECT3DDEVICE8 pDevice, - FLOAT Radius1, - FLOAT Radius2, - FLOAT Length, - UINT Slices, - UINT Stacks, - LPD3DXMESH* ppMesh, - LPD3DXBUFFER* ppAdjacency); - - -//------------------------------------------------------------------------- -// D3DXCreateSphere: -// ----------------- -// Creates a mesh containing a sphere. The sphere is centered at the -// origin. -// -// Parameters: -// -// pDevice The D3D device with which the mesh is going to be used. -// Radius Radius of the sphere (should be >= 0.0f) -// Slices Number of slices about the main axis -// Stacks Number of stacks along the main axis -// ppMesh The mesh object which will be created -// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. -//------------------------------------------------------------------------- -HRESULT WINAPI - D3DXCreateSphere( - LPDIRECT3DDEVICE8 pDevice, - FLOAT Radius, - UINT Slices, - UINT Stacks, - LPD3DXMESH* ppMesh, - LPD3DXBUFFER* ppAdjacency); - - -//------------------------------------------------------------------------- -// D3DXCreateTorus: -// ---------------- -// Creates a mesh containing a torus. The generated torus is centered at -// the origin, and its axis is aligned with the Z-axis. -// -// Parameters: -// -// pDevice The D3D device with which the mesh is going to be used. -// InnerRadius Inner radius of the torus (should be >= 0.0f) -// OuterRadius Outer radius of the torue (should be >= 0.0f) -// Sides Number of sides in a cross-section (must be >= 3) -// Rings Number of rings making up the torus (must be >= 3) -// ppMesh The mesh object which will be created -// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. -//------------------------------------------------------------------------- -HRESULT WINAPI - D3DXCreateTorus( - LPDIRECT3DDEVICE8 pDevice, - FLOAT InnerRadius, - FLOAT OuterRadius, - UINT Sides, - UINT Rings, - LPD3DXMESH* ppMesh, - LPD3DXBUFFER* ppAdjacency); - - -//------------------------------------------------------------------------- -// D3DXCreateTeapot: -// ----------------- -// Creates a mesh containing a teapot. -// -// Parameters: -// -// pDevice The D3D device with which the mesh is going to be used. -// ppMesh The mesh object which will be created -// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. -//------------------------------------------------------------------------- -HRESULT WINAPI - D3DXCreateTeapot( - LPDIRECT3DDEVICE8 pDevice, - LPD3DXMESH* ppMesh, - LPD3DXBUFFER* ppAdjacency); - - -//------------------------------------------------------------------------- -// D3DXCreateText: -// --------------- -// Creates a mesh containing the specified text using the font associated -// with the device context. -// -// Parameters: -// -// pDevice The D3D device with which the mesh is going to be used. -// hDC Device context, with desired font selected -// pText Text to generate -// Deviation Maximum chordal deviation from true font outlines -// Extrusion Amount to extrude text in -Z direction -// ppMesh The mesh object which will be created -// pGlyphMetrics Address of buffer to receive glyph metric data (or NULL) -//------------------------------------------------------------------------- -HRESULT WINAPI - D3DXCreateTextA( - LPDIRECT3DDEVICE8 pDevice, - HDC hDC, - LPCSTR pText, - FLOAT Deviation, - FLOAT Extrusion, - LPD3DXMESH* ppMesh, - LPD3DXBUFFER* ppAdjacency, - LPGLYPHMETRICSFLOAT pGlyphMetrics); - -HRESULT WINAPI - D3DXCreateTextW( - LPDIRECT3DDEVICE8 pDevice, - HDC hDC, - LPCWSTR pText, - FLOAT Deviation, - FLOAT Extrusion, - LPD3DXMESH* ppMesh, - LPD3DXBUFFER* ppAdjacency, - LPGLYPHMETRICSFLOAT pGlyphMetrics); - -#ifdef UNICODE -#define D3DXCreateText D3DXCreateTextW -#else -#define D3DXCreateText D3DXCreateTextA -#endif - - -#ifdef __cplusplus -} -#endif //__cplusplus - -#endif //__D3DX8SHAPES_H__ +/////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Microsoft Corporation. All Rights Reserved. +// +// File: d3dx8shapes.h +// Content: D3DX simple shapes +// +/////////////////////////////////////////////////////////////////////////// + +#include "d3dx8.h" + +#ifndef __D3DX8SHAPES_H__ +#define __D3DX8SHAPES_H__ + +/////////////////////////////////////////////////////////////////////////// +// Functions: +/////////////////////////////////////////////////////////////////////////// + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + + +//------------------------------------------------------------------------- +// D3DXCreatePolygon: +// ------------------ +// Creates a mesh containing an n-sided polygon. The polygon is centered +// at the origin. +// +// Parameters: +// +// pDevice The D3D device with which the mesh is going to be used. +// Length Length of each side. +// Sides Number of sides the polygon has. (Must be >= 3) +// ppMesh The mesh object which will be created +// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXCreatePolygon( + LPDIRECT3DDEVICE8 pDevice, + FLOAT Length, + UINT Sides, + LPD3DXMESH* ppMesh, + LPD3DXBUFFER* ppAdjacency); + + +//------------------------------------------------------------------------- +// D3DXCreateBox: +// -------------- +// Creates a mesh containing an axis-aligned box. The box is centered at +// the origin. +// +// Parameters: +// +// pDevice The D3D device with which the mesh is going to be used. +// Width Width of box (along X-axis) +// Height Height of box (along Y-axis) +// Depth Depth of box (along Z-axis) +// ppMesh The mesh object which will be created +// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXCreateBox( + LPDIRECT3DDEVICE8 pDevice, + FLOAT Width, + FLOAT Height, + FLOAT Depth, + LPD3DXMESH* ppMesh, + LPD3DXBUFFER* ppAdjacency); + + +//------------------------------------------------------------------------- +// D3DXCreateCylinder: +// ------------------- +// Creates a mesh containing a cylinder. The generated cylinder is +// centered at the origin, and its axis is aligned with the Z-axis. +// +// Parameters: +// +// pDevice The D3D device with which the mesh is going to be used. +// Radius1 Radius at -Z end (should be >= 0.0f) +// Radius2 Radius at +Z end (should be >= 0.0f) +// Length Length of cylinder (along Z-axis) +// Slices Number of slices about the main axis +// Stacks Number of stacks along the main axis +// ppMesh The mesh object which will be created +// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXCreateCylinder( + LPDIRECT3DDEVICE8 pDevice, + FLOAT Radius1, + FLOAT Radius2, + FLOAT Length, + UINT Slices, + UINT Stacks, + LPD3DXMESH* ppMesh, + LPD3DXBUFFER* ppAdjacency); + + +//------------------------------------------------------------------------- +// D3DXCreateSphere: +// ----------------- +// Creates a mesh containing a sphere. The sphere is centered at the +// origin. +// +// Parameters: +// +// pDevice The D3D device with which the mesh is going to be used. +// Radius Radius of the sphere (should be >= 0.0f) +// Slices Number of slices about the main axis +// Stacks Number of stacks along the main axis +// ppMesh The mesh object which will be created +// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXCreateSphere( + LPDIRECT3DDEVICE8 pDevice, + FLOAT Radius, + UINT Slices, + UINT Stacks, + LPD3DXMESH* ppMesh, + LPD3DXBUFFER* ppAdjacency); + + +//------------------------------------------------------------------------- +// D3DXCreateTorus: +// ---------------- +// Creates a mesh containing a torus. The generated torus is centered at +// the origin, and its axis is aligned with the Z-axis. +// +// Parameters: +// +// pDevice The D3D device with which the mesh is going to be used. +// InnerRadius Inner radius of the torus (should be >= 0.0f) +// OuterRadius Outer radius of the torue (should be >= 0.0f) +// Sides Number of sides in a cross-section (must be >= 3) +// Rings Number of rings making up the torus (must be >= 3) +// ppMesh The mesh object which will be created +// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXCreateTorus( + LPDIRECT3DDEVICE8 pDevice, + FLOAT InnerRadius, + FLOAT OuterRadius, + UINT Sides, + UINT Rings, + LPD3DXMESH* ppMesh, + LPD3DXBUFFER* ppAdjacency); + + +//------------------------------------------------------------------------- +// D3DXCreateTeapot: +// ----------------- +// Creates a mesh containing a teapot. +// +// Parameters: +// +// pDevice The D3D device with which the mesh is going to be used. +// ppMesh The mesh object which will be created +// ppAdjacency Returns a buffer containing adjacency info. Can be NULL. +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXCreateTeapot( + LPDIRECT3DDEVICE8 pDevice, + LPD3DXMESH* ppMesh, + LPD3DXBUFFER* ppAdjacency); + + +//------------------------------------------------------------------------- +// D3DXCreateText: +// --------------- +// Creates a mesh containing the specified text using the font associated +// with the device context. +// +// Parameters: +// +// pDevice The D3D device with which the mesh is going to be used. +// hDC Device context, with desired font selected +// pText Text to generate +// Deviation Maximum chordal deviation from true font outlines +// Extrusion Amount to extrude text in -Z direction +// ppMesh The mesh object which will be created +// pGlyphMetrics Address of buffer to receive glyph metric data (or NULL) +//------------------------------------------------------------------------- +HRESULT WINAPI + D3DXCreateTextA( + LPDIRECT3DDEVICE8 pDevice, + HDC hDC, + LPCSTR pText, + FLOAT Deviation, + FLOAT Extrusion, + LPD3DXMESH* ppMesh, + LPD3DXBUFFER* ppAdjacency, + LPGLYPHMETRICSFLOAT pGlyphMetrics); + +HRESULT WINAPI + D3DXCreateTextW( + LPDIRECT3DDEVICE8 pDevice, + HDC hDC, + LPCWSTR pText, + FLOAT Deviation, + FLOAT Extrusion, + LPD3DXMESH* ppMesh, + LPD3DXBUFFER* ppAdjacency, + LPGLYPHMETRICSFLOAT pGlyphMetrics); + +#ifdef UNICODE +#define D3DXCreateText D3DXCreateTextW +#else +#define D3DXCreateText D3DXCreateTextA +#endif + + +#ifdef __cplusplus +} +#endif //__cplusplus + +#endif //__D3DX8SHAPES_H__ diff --git a/gfx/include/d3d8/d3dx8tex.h b/gfx/include/d3d8/d3dx8tex.h index 2bdfce8b82..cb30a7cf37 100644 --- a/gfx/include/d3d8/d3dx8tex.h +++ b/gfx/include/d3d8/d3dx8tex.h @@ -1,1592 +1,1592 @@ -////////////////////////////////////////////////////////////////////////////// -// -// Copyright (C) Microsoft Corporation. All Rights Reserved. -// -// File: d3dx8tex.h -// Content: D3DX texturing APIs -// -////////////////////////////////////////////////////////////////////////////// - -#include "d3dx8.h" - -#ifndef __D3DX8TEX_H__ -#define __D3DX8TEX_H__ - - -//---------------------------------------------------------------------------- -// D3DX_FILTER flags: -// ------------------ -// -// A valid filter must contain one of these values: -// -// D3DX_FILTER_NONE -// No scaling or filtering will take place. Pixels outside the bounds -// of the source image are assumed to be transparent black. -// D3DX_FILTER_POINT -// Each destination pixel is computed by sampling the nearest pixel -// from the source image. -// D3DX_FILTER_LINEAR -// Each destination pixel is computed by linearly interpolating between -// the nearest pixels in the source image. This filter works best -// when the scale on each axis is less than 2. -// D3DX_FILTER_TRIANGLE -// Every pixel in the source image contributes equally to the -// destination image. This is the slowest of all the filters. -// D3DX_FILTER_BOX -// Each pixel is computed by averaging a 2x2(x2) box pixels from -// the source image. Only works when the dimensions of the -// destination are half those of the source. (as with mip maps) -// -// And can be OR'd with any of these optional flags: -// -// D3DX_FILTER_MIRROR_U -// Indicates that pixels off the edge of the texture on the U-axis -// should be mirrored, not wraped. -// D3DX_FILTER_MIRROR_V -// Indicates that pixels off the edge of the texture on the V-axis -// should be mirrored, not wraped. -// D3DX_FILTER_MIRROR_W -// Indicates that pixels off the edge of the texture on the W-axis -// should be mirrored, not wraped. -// D3DX_FILTER_MIRROR -// Same as specifying D3DX_FILTER_MIRROR_U | D3DX_FILTER_MIRROR_V | -// D3DX_FILTER_MIRROR_V -// D3DX_FILTER_DITHER -// Dithers the resulting image. -// -//---------------------------------------------------------------------------- - -#define D3DX_FILTER_NONE (1 << 0) -#define D3DX_FILTER_POINT (2 << 0) -#define D3DX_FILTER_LINEAR (3 << 0) -#define D3DX_FILTER_TRIANGLE (4 << 0) -#define D3DX_FILTER_BOX (5 << 0) - -#define D3DX_FILTER_MIRROR_U (1 << 16) -#define D3DX_FILTER_MIRROR_V (2 << 16) -#define D3DX_FILTER_MIRROR_W (4 << 16) -#define D3DX_FILTER_MIRROR (7 << 16) -#define D3DX_FILTER_DITHER (8 << 16) - - -//---------------------------------------------------------------------------- -// D3DX_NORMALMAP flags: -// --------------------- -// These flags are used to control how D3DXComputeNormalMap generates normal -// maps. Any number of these flags may be OR'd together in any combination. -// -// D3DX_NORMALMAP_MIRROR_U -// Indicates that pixels off the edge of the texture on the U-axis -// should be mirrored, not wraped. -// D3DX_NORMALMAP_MIRROR_V -// Indicates that pixels off the edge of the texture on the V-axis -// should be mirrored, not wraped. -// D3DX_NORMALMAP_MIRROR -// Same as specifying D3DX_NORMALMAP_MIRROR_U | D3DX_NORMALMAP_MIRROR_V -// D3DX_NORMALMAP_INVERTSIGN -// Inverts the direction of each normal -// D3DX_NORMALMAP_COMPUTE_OCCLUSION -// Compute the per pixel Occlusion term and encodes it into the alpha. -// An Alpha of 1 means that the pixel is not obscured in anyway, and -// an alpha of 0 would mean that the pixel is completly obscured. -// -//---------------------------------------------------------------------------- - -//---------------------------------------------------------------------------- - -#define D3DX_NORMALMAP_MIRROR_U (1 << 16) -#define D3DX_NORMALMAP_MIRROR_V (2 << 16) -#define D3DX_NORMALMAP_MIRROR (3 << 16) -#define D3DX_NORMALMAP_INVERTSIGN (8 << 16) -#define D3DX_NORMALMAP_COMPUTE_OCCLUSION (16 << 16) - - - - -//---------------------------------------------------------------------------- -// D3DX_CHANNEL flags: -// ------------------- -// These flags are used by functions which operate on or more channels -// in a texture. -// -// D3DX_CHANNEL_RED -// Indicates the red channel should be used -// D3DX_CHANNEL_BLUE -// Indicates the blue channel should be used -// D3DX_CHANNEL_GREEN -// Indicates the green channel should be used -// D3DX_CHANNEL_ALPHA -// Indicates the alpha channel should be used -// D3DX_CHANNEL_LUMINANCE -// Indicates the luminaces of the red green and blue channels should be -// used. -// -//---------------------------------------------------------------------------- - -#define D3DX_CHANNEL_RED (1 << 0) -#define D3DX_CHANNEL_BLUE (1 << 1) -#define D3DX_CHANNEL_GREEN (1 << 2) -#define D3DX_CHANNEL_ALPHA (1 << 3) -#define D3DX_CHANNEL_LUMINANCE (1 << 4) - - - - -//---------------------------------------------------------------------------- -// D3DXIMAGE_FILEFORMAT: -// --------------------- -// This enum is used to describe supported image file formats. -// -//---------------------------------------------------------------------------- - -typedef enum _D3DXIMAGE_FILEFORMAT -{ - D3DXIFF_BMP = 0, - D3DXIFF_JPG = 1, - D3DXIFF_TGA = 2, - D3DXIFF_PNG = 3, - D3DXIFF_DDS = 4, - D3DXIFF_PPM = 5, - D3DXIFF_DIB = 6, - D3DXIFF_FORCE_DWORD = 0x7fffffff - -} D3DXIMAGE_FILEFORMAT; - - -//---------------------------------------------------------------------------- -// LPD3DXFILL2D and LPD3DXFILL3D: -// ------------------------------ -// Function types used by the texture fill functions. -// -// Parameters: -// pOut -// Pointer to a vector which the function uses to return its result. -// X,Y,Z,W will be mapped to R,G,B,A respectivly. -// pTexCoord -// Pointer to a vector containing the coordinates of the texel currently -// being evaluated. Textures and VolumeTexture texcoord components -// range from 0 to 1. CubeTexture texcoord component range from -1 to 1. -// pTexelSize -// Pointer to a vector containing the dimensions of the current texel. -// pData -// Pointer to user data. -// -//---------------------------------------------------------------------------- - -typedef VOID (*LPD3DXFILL2D)(D3DXVECTOR4 *pOut, D3DXVECTOR2 *pTexCoord, D3DXVECTOR2 *pTexelSize, LPVOID pData); -typedef VOID (*LPD3DXFILL3D)(D3DXVECTOR4 *pOut, D3DXVECTOR3 *pTexCoord, D3DXVECTOR3 *pTexelSize, LPVOID pData); - - - -//---------------------------------------------------------------------------- -// D3DXIMAGE_INFO: -// --------------- -// This structure is used to return a rough description of what the -// the original contents of an image file looked like. -// -// Width -// Width of original image in pixels -// Height -// Height of original image in pixels -// Depth -// Depth of original image in pixels -// MipLevels -// Number of mip levels in original image -// Format -// D3D format which most closely describes the data in original image -// ResourceType -// D3DRESOURCETYPE representing the type of texture stored in the file. -// D3DRTYPE_TEXTURE, D3DRTYPE_VOLUMETEXTURE, or D3DRTYPE_CUBETEXTURE. -// ImageFileFormat -// D3DXIMAGE_FILEFORMAT representing the format of the image file. -// -//---------------------------------------------------------------------------- - -typedef struct _D3DXIMAGE_INFO -{ - UINT Width; - UINT Height; - UINT Depth; - UINT MipLevels; - D3DFORMAT Format; - D3DRESOURCETYPE ResourceType; - D3DXIMAGE_FILEFORMAT ImageFileFormat; - -} D3DXIMAGE_INFO; - - - - - -#ifdef __cplusplus -extern "C" { -#endif //__cplusplus - - - -////////////////////////////////////////////////////////////////////////////// -// Image File APIs /////////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// -; -//---------------------------------------------------------------------------- -// GetImageInfoFromFile/Resource: -// ------------------------------ -// Fills in a D3DXIMAGE_INFO struct with information about an image file. -// -// Parameters: -// pSrcFile -// File name of the source image. -// pSrcModule -// Module where resource is located, or NULL for module associated -// with image the os used to create the current process. -// pSrcResource -// Resource name -// pSrcData -// Pointer to file in memory. -// SrcDataSize -// Size in bytes of file in memory. -// pSrcInfo -// Pointer to a D3DXIMAGE_INFO structure to be filled in with the -// description of the data in the source image file. -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXGetImageInfoFromFileA( - LPCSTR pSrcFile, - D3DXIMAGE_INFO* pSrcInfo); - -HRESULT WINAPI - D3DXGetImageInfoFromFileW( - LPCWSTR pSrcFile, - D3DXIMAGE_INFO* pSrcInfo); - -#ifdef UNICODE -#define D3DXGetImageInfoFromFile D3DXGetImageInfoFromFileW -#else -#define D3DXGetImageInfoFromFile D3DXGetImageInfoFromFileA -#endif - - -HRESULT WINAPI - D3DXGetImageInfoFromResourceA( - HMODULE hSrcModule, - LPCSTR pSrcResource, - D3DXIMAGE_INFO* pSrcInfo); - -HRESULT WINAPI - D3DXGetImageInfoFromResourceW( - HMODULE hSrcModule, - LPCWSTR pSrcResource, - D3DXIMAGE_INFO* pSrcInfo); - -#ifdef UNICODE -#define D3DXGetImageInfoFromResource D3DXGetImageInfoFromResourceW -#else -#define D3DXGetImageInfoFromResource D3DXGetImageInfoFromResourceA -#endif - - -HRESULT WINAPI - D3DXGetImageInfoFromFileInMemory( - LPCVOID pSrcData, - UINT SrcDataSize, - D3DXIMAGE_INFO* pSrcInfo); - - - - -////////////////////////////////////////////////////////////////////////////// -// Load/Save Surface APIs //////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -//---------------------------------------------------------------------------- -// D3DXLoadSurfaceFromFile/Resource: -// --------------------------------- -// Load surface from a file or resource -// -// Parameters: -// pDestSurface -// Destination surface, which will receive the image. -// pDestPalette -// Destination palette of 256 colors, or NULL -// pDestRect -// Destination rectangle, or NULL for entire surface -// pSrcFile -// File name of the source image. -// pSrcModule -// Module where resource is located, or NULL for module associated -// with image the os used to create the current process. -// pSrcResource -// Resource name -// pSrcData -// Pointer to file in memory. -// SrcDataSize -// Size in bytes of file in memory. -// pSrcRect -// Source rectangle, or NULL for entire image -// Filter -// D3DX_FILTER flags controlling how the image is filtered. -// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. -// ColorKey -// Color to replace with transparent black, or 0 to disable colorkey. -// This is always a 32-bit ARGB color, independent of the source image -// format. Alpha is significant, and should usually be set to FF for -// opaque colorkeys. (ex. Opaque black == 0xff000000) -// pSrcInfo -// Pointer to a D3DXIMAGE_INFO structure to be filled in with the -// description of the data in the source image file, or NULL. -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXLoadSurfaceFromFileA( - LPDIRECT3DSURFACE8 pDestSurface, - CONST PALETTEENTRY* pDestPalette, - CONST RECT* pDestRect, - LPCSTR pSrcFile, - CONST RECT* pSrcRect, - DWORD Filter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo); - -HRESULT WINAPI - D3DXLoadSurfaceFromFileW( - LPDIRECT3DSURFACE8 pDestSurface, - CONST PALETTEENTRY* pDestPalette, - CONST RECT* pDestRect, - LPCWSTR pSrcFile, - CONST RECT* pSrcRect, - DWORD Filter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo); - -#ifdef UNICODE -#define D3DXLoadSurfaceFromFile D3DXLoadSurfaceFromFileW -#else -#define D3DXLoadSurfaceFromFile D3DXLoadSurfaceFromFileA -#endif - - - -HRESULT WINAPI - D3DXLoadSurfaceFromResourceA( - LPDIRECT3DSURFACE8 pDestSurface, - CONST PALETTEENTRY* pDestPalette, - CONST RECT* pDestRect, - HMODULE hSrcModule, - LPCSTR pSrcResource, - CONST RECT* pSrcRect, - DWORD Filter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo); - -HRESULT WINAPI - D3DXLoadSurfaceFromResourceW( - LPDIRECT3DSURFACE8 pDestSurface, - CONST PALETTEENTRY* pDestPalette, - CONST RECT* pDestRect, - HMODULE hSrcModule, - LPCWSTR pSrcResource, - CONST RECT* pSrcRect, - DWORD Filter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo); - - -#ifdef UNICODE -#define D3DXLoadSurfaceFromResource D3DXLoadSurfaceFromResourceW -#else -#define D3DXLoadSurfaceFromResource D3DXLoadSurfaceFromResourceA -#endif - - - -HRESULT WINAPI - D3DXLoadSurfaceFromFileInMemory( - LPDIRECT3DSURFACE8 pDestSurface, - CONST PALETTEENTRY* pDestPalette, - CONST RECT* pDestRect, - LPCVOID pSrcData, - UINT SrcDataSize, - CONST RECT* pSrcRect, - DWORD Filter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo); - - - -//---------------------------------------------------------------------------- -// D3DXLoadSurfaceFromSurface: -// --------------------------- -// Load surface from another surface (with color conversion) -// -// Parameters: -// pDestSurface -// Destination surface, which will receive the image. -// pDestPalette -// Destination palette of 256 colors, or NULL -// pDestRect -// Destination rectangle, or NULL for entire surface -// pSrcSurface -// Source surface -// pSrcPalette -// Source palette of 256 colors, or NULL -// pSrcRect -// Source rectangle, or NULL for entire surface -// Filter -// D3DX_FILTER flags controlling how the image is filtered. -// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. -// ColorKey -// Color to replace with transparent black, or 0 to disable colorkey. -// This is always a 32-bit ARGB color, independent of the source image -// format. Alpha is significant, and should usually be set to FF for -// opaque colorkeys. (ex. Opaque black == 0xff000000) -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXLoadSurfaceFromSurface( - LPDIRECT3DSURFACE8 pDestSurface, - CONST PALETTEENTRY* pDestPalette, - CONST RECT* pDestRect, - LPDIRECT3DSURFACE8 pSrcSurface, - CONST PALETTEENTRY* pSrcPalette, - CONST RECT* pSrcRect, - DWORD Filter, - D3DCOLOR ColorKey); - - -//---------------------------------------------------------------------------- -// D3DXLoadSurfaceFromMemory: -// -------------------------- -// Load surface from memory. -// -// Parameters: -// pDestSurface -// Destination surface, which will receive the image. -// pDestPalette -// Destination palette of 256 colors, or NULL -// pDestRect -// Destination rectangle, or NULL for entire surface -// pSrcMemory -// Pointer to the top-left corner of the source image in memory -// SrcFormat -// Pixel format of the source image. -// SrcPitch -// Pitch of source image, in bytes. For DXT formats, this number -// should represent the width of one row of cells, in bytes. -// pSrcPalette -// Source palette of 256 colors, or NULL -// pSrcRect -// Source rectangle. -// Filter -// D3DX_FILTER flags controlling how the image is filtered. -// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. -// ColorKey -// Color to replace with transparent black, or 0 to disable colorkey. -// This is always a 32-bit ARGB color, independent of the source image -// format. Alpha is significant, and should usually be set to FF for -// opaque colorkeys. (ex. Opaque black == 0xff000000) -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXLoadSurfaceFromMemory( - LPDIRECT3DSURFACE8 pDestSurface, - CONST PALETTEENTRY* pDestPalette, - CONST RECT* pDestRect, - LPCVOID pSrcMemory, - D3DFORMAT SrcFormat, - UINT SrcPitch, - CONST PALETTEENTRY* pSrcPalette, - CONST RECT* pSrcRect, - DWORD Filter, - D3DCOLOR ColorKey); - - -//---------------------------------------------------------------------------- -// D3DXSaveSurfaceToFile: -// ---------------------- -// Save a surface to a image file. -// -// Parameters: -// pDestFile -// File name of the destination file -// DestFormat -// D3DXIMAGE_FILEFORMAT specifying file format to use when saving. -// pSrcSurface -// Source surface, containing the image to be saved -// pSrcPalette -// Source palette of 256 colors, or NULL -// pSrcRect -// Source rectangle, or NULL for the entire image -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXSaveSurfaceToFileA( - LPCSTR pDestFile, - D3DXIMAGE_FILEFORMAT DestFormat, - LPDIRECT3DSURFACE8 pSrcSurface, - CONST PALETTEENTRY* pSrcPalette, - CONST RECT* pSrcRect); - -HRESULT WINAPI - D3DXSaveSurfaceToFileW( - LPCWSTR pDestFile, - D3DXIMAGE_FILEFORMAT DestFormat, - LPDIRECT3DSURFACE8 pSrcSurface, - CONST PALETTEENTRY* pSrcPalette, - CONST RECT* pSrcRect); - -#ifdef UNICODE -#define D3DXSaveSurfaceToFile D3DXSaveSurfaceToFileW -#else -#define D3DXSaveSurfaceToFile D3DXSaveSurfaceToFileA -#endif - - - - -////////////////////////////////////////////////////////////////////////////// -// Load/Save Volume APIs ///////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -//---------------------------------------------------------------------------- -// D3DXLoadVolumeFromFile/Resource: -// -------------------------------- -// Load volume from a file or resource -// -// Parameters: -// pDestVolume -// Destination volume, which will receive the image. -// pDestPalette -// Destination palette of 256 colors, or NULL -// pDestBox -// Destination box, or NULL for entire volume -// pSrcFile -// File name of the source image. -// pSrcModule -// Module where resource is located, or NULL for module associated -// with image the os used to create the current process. -// pSrcResource -// Resource name -// pSrcData -// Pointer to file in memory. -// SrcDataSize -// Size in bytes of file in memory. -// pSrcBox -// Source box, or NULL for entire image -// Filter -// D3DX_FILTER flags controlling how the image is filtered. -// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. -// ColorKey -// Color to replace with transparent black, or 0 to disable colorkey. -// This is always a 32-bit ARGB color, independent of the source image -// format. Alpha is significant, and should usually be set to FF for -// opaque colorkeys. (ex. Opaque black == 0xff000000) -// pSrcInfo -// Pointer to a D3DXIMAGE_INFO structure to be filled in with the -// description of the data in the source image file, or NULL. -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXLoadVolumeFromFileA( - LPDIRECT3DVOLUME8 pDestVolume, - CONST PALETTEENTRY* pDestPalette, - CONST D3DBOX* pDestBox, - LPCSTR pSrcFile, - CONST D3DBOX* pSrcBox, - DWORD Filter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo); - -HRESULT WINAPI - D3DXLoadVolumeFromFileW( - LPDIRECT3DVOLUME8 pDestVolume, - CONST PALETTEENTRY* pDestPalette, - CONST D3DBOX* pDestBox, - LPCWSTR pSrcFile, - CONST D3DBOX* pSrcBox, - DWORD Filter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo); - -#ifdef UNICODE -#define D3DXLoadVolumeFromFile D3DXLoadVolumeFromFileW -#else -#define D3DXLoadVolumeFromFile D3DXLoadVolumeFromFileA -#endif - - -HRESULT WINAPI - D3DXLoadVolumeFromResourceA( - LPDIRECT3DVOLUME8 pDestVolume, - CONST PALETTEENTRY* pDestPalette, - CONST D3DBOX* pDestBox, - HMODULE hSrcModule, - LPCSTR pSrcResource, - CONST D3DBOX* pSrcBox, - DWORD Filter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo); - -HRESULT WINAPI - D3DXLoadVolumeFromResourceW( - LPDIRECT3DVOLUME8 pDestVolume, - CONST PALETTEENTRY* pDestPalette, - CONST D3DBOX* pDestBox, - HMODULE hSrcModule, - LPCWSTR pSrcResource, - CONST D3DBOX* pSrcBox, - DWORD Filter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo); - -#ifdef UNICODE -#define D3DXLoadVolumeFromResource D3DXLoadVolumeFromResourceW -#else -#define D3DXLoadVolumeFromResource D3DXLoadVolumeFromResourceA -#endif - - - -HRESULT WINAPI - D3DXLoadVolumeFromFileInMemory( - LPDIRECT3DVOLUME8 pDestVolume, - CONST PALETTEENTRY* pDestPalette, - CONST D3DBOX* pDestBox, - LPCVOID pSrcData, - UINT SrcDataSize, - CONST D3DBOX* pSrcBox, - DWORD Filter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo); - - - -//---------------------------------------------------------------------------- -// D3DXLoadVolumeFromVolume: -// ------------------------- -// Load volume from another volume (with color conversion) -// -// Parameters: -// pDestVolume -// Destination volume, which will receive the image. -// pDestPalette -// Destination palette of 256 colors, or NULL -// pDestBox -// Destination box, or NULL for entire volume -// pSrcVolume -// Source volume -// pSrcPalette -// Source palette of 256 colors, or NULL -// pSrcBox -// Source box, or NULL for entire volume -// Filter -// D3DX_FILTER flags controlling how the image is filtered. -// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. -// ColorKey -// Color to replace with transparent black, or 0 to disable colorkey. -// This is always a 32-bit ARGB color, independent of the source image -// format. Alpha is significant, and should usually be set to FF for -// opaque colorkeys. (ex. Opaque black == 0xff000000) -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXLoadVolumeFromVolume( - LPDIRECT3DVOLUME8 pDestVolume, - CONST PALETTEENTRY* pDestPalette, - CONST D3DBOX* pDestBox, - LPDIRECT3DVOLUME8 pSrcVolume, - CONST PALETTEENTRY* pSrcPalette, - CONST D3DBOX* pSrcBox, - DWORD Filter, - D3DCOLOR ColorKey); - - - -//---------------------------------------------------------------------------- -// D3DXLoadVolumeFromMemory: -// ------------------------- -// Load volume from memory. -// -// Parameters: -// pDestVolume -// Destination volume, which will receive the image. -// pDestPalette -// Destination palette of 256 colors, or NULL -// pDestBox -// Destination box, or NULL for entire volume -// pSrcMemory -// Pointer to the top-left corner of the source volume in memory -// SrcFormat -// Pixel format of the source volume. -// SrcRowPitch -// Pitch of source image, in bytes. For DXT formats, this number -// should represent the size of one row of cells, in bytes. -// SrcSlicePitch -// Pitch of source image, in bytes. For DXT formats, this number -// should represent the size of one slice of cells, in bytes. -// pSrcPalette -// Source palette of 256 colors, or NULL -// pSrcBox -// Source box. -// Filter -// D3DX_FILTER flags controlling how the image is filtered. -// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. -// ColorKey -// Color to replace with transparent black, or 0 to disable colorkey. -// This is always a 32-bit ARGB color, independent of the source image -// format. Alpha is significant, and should usually be set to FF for -// opaque colorkeys. (ex. Opaque black == 0xff000000) -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXLoadVolumeFromMemory( - LPDIRECT3DVOLUME8 pDestVolume, - CONST PALETTEENTRY* pDestPalette, - CONST D3DBOX* pDestBox, - LPCVOID pSrcMemory, - D3DFORMAT SrcFormat, - UINT SrcRowPitch, - UINT SrcSlicePitch, - CONST PALETTEENTRY* pSrcPalette, - CONST D3DBOX* pSrcBox, - DWORD Filter, - D3DCOLOR ColorKey); - - - -//---------------------------------------------------------------------------- -// D3DXSaveVolumeToFile: -// --------------------- -// Save a volume to a image file. -// -// Parameters: -// pDestFile -// File name of the destination file -// DestFormat -// D3DXIMAGE_FILEFORMAT specifying file format to use when saving. -// pSrcVolume -// Source volume, containing the image to be saved -// pSrcPalette -// Source palette of 256 colors, or NULL -// pSrcBox -// Source box, or NULL for the entire volume -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXSaveVolumeToFileA( - LPCSTR pDestFile, - D3DXIMAGE_FILEFORMAT DestFormat, - LPDIRECT3DVOLUME8 pSrcVolume, - CONST PALETTEENTRY* pSrcPalette, - CONST D3DBOX* pSrcBox); - -HRESULT WINAPI - D3DXSaveVolumeToFileW( - LPCWSTR pDestFile, - D3DXIMAGE_FILEFORMAT DestFormat, - LPDIRECT3DVOLUME8 pSrcVolume, - CONST PALETTEENTRY* pSrcPalette, - CONST D3DBOX* pSrcBox); - -#ifdef UNICODE -#define D3DXSaveVolumeToFile D3DXSaveVolumeToFileW -#else -#define D3DXSaveVolumeToFile D3DXSaveVolumeToFileA -#endif - - - - -////////////////////////////////////////////////////////////////////////////// -// Create/Save Texture APIs ////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -//---------------------------------------------------------------------------- -// D3DXCheckTextureRequirements: -// ----------------------------- -// Checks texture creation parameters. If parameters are invalid, this -// function returns corrected parameters. -// -// Parameters: -// -// pDevice -// The D3D device to be used -// pWidth, pHeight, pDepth, pSize -// Desired size in pixels, or NULL. Returns corrected size. -// pNumMipLevels -// Number of desired mipmap levels, or NULL. Returns corrected number. -// Usage -// Texture usage flags -// pFormat -// Desired pixel format, or NULL. Returns corrected format. -// Pool -// Memory pool to be used to create texture -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXCheckTextureRequirements( - LPDIRECT3DDEVICE8 pDevice, - UINT* pWidth, - UINT* pHeight, - UINT* pNumMipLevels, - DWORD Usage, - D3DFORMAT* pFormat, - D3DPOOL Pool); - -HRESULT WINAPI - D3DXCheckCubeTextureRequirements( - LPDIRECT3DDEVICE8 pDevice, - UINT* pSize, - UINT* pNumMipLevels, - DWORD Usage, - D3DFORMAT* pFormat, - D3DPOOL Pool); - -HRESULT WINAPI - D3DXCheckVolumeTextureRequirements( - LPDIRECT3DDEVICE8 pDevice, - UINT* pWidth, - UINT* pHeight, - UINT* pDepth, - UINT* pNumMipLevels, - DWORD Usage, - D3DFORMAT* pFormat, - D3DPOOL Pool); - - -//---------------------------------------------------------------------------- -// D3DXCreateTexture: -// ------------------ -// Create an empty texture -// -// Parameters: -// -// pDevice -// The D3D device with which the texture is going to be used. -// Width, Height, Depth, Size -// size in pixels; these must be non-zero -// MipLevels -// number of mip levels desired; if zero or D3DX_DEFAULT, a complete -// mipmap chain will be created. -// Usage -// Texture usage flags -// Format -// Pixel format. -// Pool -// Memory pool to be used to create texture -// ppTexture, ppCubeTexture, ppVolumeTexture -// The texture object that will be created -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXCreateTexture( - LPDIRECT3DDEVICE8 pDevice, - UINT Width, - UINT Height, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - LPDIRECT3DTEXTURE8* ppTexture); - -HRESULT WINAPI - D3DXCreateCubeTexture( - LPDIRECT3DDEVICE8 pDevice, - UINT Size, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - LPDIRECT3DCUBETEXTURE8* ppCubeTexture); - -HRESULT WINAPI - D3DXCreateVolumeTexture( - LPDIRECT3DDEVICE8 pDevice, - UINT Width, - UINT Height, - UINT Depth, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); - - - -//---------------------------------------------------------------------------- -// D3DXCreateTextureFromFile/Resource: -// ----------------------------------- -// Create a texture object from a file or resource. -// -// Parameters: -// -// pDevice -// The D3D device with which the texture is going to be used. -// pSrcFile -// File name. -// hSrcModule -// Module handle. if NULL, current module will be used. -// pSrcResource -// Resource name in module -// pvSrcData -// Pointer to file in memory. -// SrcDataSize -// Size in bytes of file in memory. -// Width, Height, Depth, Size -// Size in pixels; if zero or D3DX_DEFAULT, the size will be taken -// from the file. -// MipLevels -// Number of mip levels; if zero or D3DX_DEFAULT, a complete mipmap -// chain will be created. -// Usage -// Texture usage flags -// Format -// Desired pixel format. If D3DFMT_UNKNOWN, the format will be -// taken from the file. -// Pool -// Memory pool to be used to create texture -// Filter -// D3DX_FILTER flags controlling how the image is filtered. -// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. -// MipFilter -// D3DX_FILTER flags controlling how each miplevel is filtered. -// Or D3DX_DEFAULT for D3DX_FILTER_BOX, -// ColorKey -// Color to replace with transparent black, or 0 to disable colorkey. -// This is always a 32-bit ARGB color, independent of the source image -// format. Alpha is significant, and should usually be set to FF for -// opaque colorkeys. (ex. Opaque black == 0xff000000) -// pSrcInfo -// Pointer to a D3DXIMAGE_INFO structure to be filled in with the -// description of the data in the source image file, or NULL. -// pPalette -// 256 color palette to be filled in, or NULL -// ppTexture, ppCubeTexture, ppVolumeTexture -// The texture object that will be created -// -//---------------------------------------------------------------------------- - - -// FromFile - -HRESULT WINAPI - D3DXCreateTextureFromFileA( - LPDIRECT3DDEVICE8 pDevice, - LPCSTR pSrcFile, - LPDIRECT3DTEXTURE8* ppTexture); - -HRESULT WINAPI - D3DXCreateTextureFromFileW( - LPDIRECT3DDEVICE8 pDevice, - LPCWSTR pSrcFile, - LPDIRECT3DTEXTURE8* ppTexture); - -#ifdef UNICODE -#define D3DXCreateTextureFromFile D3DXCreateTextureFromFileW -#else -#define D3DXCreateTextureFromFile D3DXCreateTextureFromFileA -#endif - - -HRESULT WINAPI - D3DXCreateCubeTextureFromFileA( - LPDIRECT3DDEVICE8 pDevice, - LPCSTR pSrcFile, - LPDIRECT3DCUBETEXTURE8* ppCubeTexture); - -HRESULT WINAPI - D3DXCreateCubeTextureFromFileW( - LPDIRECT3DDEVICE8 pDevice, - LPCWSTR pSrcFile, - LPDIRECT3DCUBETEXTURE8* ppCubeTexture); - -#ifdef UNICODE -#define D3DXCreateCubeTextureFromFile D3DXCreateCubeTextureFromFileW -#else -#define D3DXCreateCubeTextureFromFile D3DXCreateCubeTextureFromFileA -#endif - - -HRESULT WINAPI - D3DXCreateVolumeTextureFromFileA( - LPDIRECT3DDEVICE8 pDevice, - LPCSTR pSrcFile, - LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); - -HRESULT WINAPI - D3DXCreateVolumeTextureFromFileW( - LPDIRECT3DDEVICE8 pDevice, - LPCWSTR pSrcFile, - LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); - -#ifdef UNICODE -#define D3DXCreateVolumeTextureFromFile D3DXCreateVolumeTextureFromFileW -#else -#define D3DXCreateVolumeTextureFromFile D3DXCreateVolumeTextureFromFileA -#endif - - -// FromResource - -HRESULT WINAPI - D3DXCreateTextureFromResourceA( - LPDIRECT3DDEVICE8 pDevice, - HMODULE hSrcModule, - LPCSTR pSrcResource, - LPDIRECT3DTEXTURE8* ppTexture); - -HRESULT WINAPI - D3DXCreateTextureFromResourceW( - LPDIRECT3DDEVICE8 pDevice, - HMODULE hSrcModule, - LPCWSTR pSrcResource, - LPDIRECT3DTEXTURE8* ppTexture); - -#ifdef UNICODE -#define D3DXCreateTextureFromResource D3DXCreateTextureFromResourceW -#else -#define D3DXCreateTextureFromResource D3DXCreateTextureFromResourceA -#endif - - -HRESULT WINAPI - D3DXCreateCubeTextureFromResourceA( - LPDIRECT3DDEVICE8 pDevice, - HMODULE hSrcModule, - LPCSTR pSrcResource, - LPDIRECT3DCUBETEXTURE8* ppCubeTexture); - -HRESULT WINAPI - D3DXCreateCubeTextureFromResourceW( - LPDIRECT3DDEVICE8 pDevice, - HMODULE hSrcModule, - LPCWSTR pSrcResource, - LPDIRECT3DCUBETEXTURE8* ppCubeTexture); - -#ifdef UNICODE -#define D3DXCreateCubeTextureFromResource D3DXCreateCubeTextureFromResourceW -#else -#define D3DXCreateCubeTextureFromResource D3DXCreateCubeTextureFromResourceA -#endif - - -HRESULT WINAPI - D3DXCreateVolumeTextureFromResourceA( - LPDIRECT3DDEVICE8 pDevice, - HMODULE hSrcModule, - LPCSTR pSrcResource, - LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); - -HRESULT WINAPI - D3DXCreateVolumeTextureFromResourceW( - LPDIRECT3DDEVICE8 pDevice, - HMODULE hSrcModule, - LPCWSTR pSrcResource, - LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); - -#ifdef UNICODE -#define D3DXCreateVolumeTextureFromResource D3DXCreateVolumeTextureFromResourceW -#else -#define D3DXCreateVolumeTextureFromResource D3DXCreateVolumeTextureFromResourceA -#endif - - -// FromFileEx - -HRESULT WINAPI - D3DXCreateTextureFromFileExA( - LPDIRECT3DDEVICE8 pDevice, - LPCSTR pSrcFile, - UINT Width, - UINT Height, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DTEXTURE8* ppTexture); - -HRESULT WINAPI - D3DXCreateTextureFromFileExW( - LPDIRECT3DDEVICE8 pDevice, - LPCWSTR pSrcFile, - UINT Width, - UINT Height, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DTEXTURE8* ppTexture); - -#ifdef UNICODE -#define D3DXCreateTextureFromFileEx D3DXCreateTextureFromFileExW -#else -#define D3DXCreateTextureFromFileEx D3DXCreateTextureFromFileExA -#endif - - -HRESULT WINAPI - D3DXCreateCubeTextureFromFileExA( - LPDIRECT3DDEVICE8 pDevice, - LPCSTR pSrcFile, - UINT Size, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DCUBETEXTURE8* ppCubeTexture); - -HRESULT WINAPI - D3DXCreateCubeTextureFromFileExW( - LPDIRECT3DDEVICE8 pDevice, - LPCWSTR pSrcFile, - UINT Size, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DCUBETEXTURE8* ppCubeTexture); - -#ifdef UNICODE -#define D3DXCreateCubeTextureFromFileEx D3DXCreateCubeTextureFromFileExW -#else -#define D3DXCreateCubeTextureFromFileEx D3DXCreateCubeTextureFromFileExA -#endif - - -HRESULT WINAPI - D3DXCreateVolumeTextureFromFileExA( - LPDIRECT3DDEVICE8 pDevice, - LPCSTR pSrcFile, - UINT Width, - UINT Height, - UINT Depth, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); - -HRESULT WINAPI - D3DXCreateVolumeTextureFromFileExW( - LPDIRECT3DDEVICE8 pDevice, - LPCWSTR pSrcFile, - UINT Width, - UINT Height, - UINT Depth, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); - -#ifdef UNICODE -#define D3DXCreateVolumeTextureFromFileEx D3DXCreateVolumeTextureFromFileExW -#else -#define D3DXCreateVolumeTextureFromFileEx D3DXCreateVolumeTextureFromFileExA -#endif - - -// FromResourceEx - -HRESULT WINAPI - D3DXCreateTextureFromResourceExA( - LPDIRECT3DDEVICE8 pDevice, - HMODULE hSrcModule, - LPCSTR pSrcResource, - UINT Width, - UINT Height, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DTEXTURE8* ppTexture); - -HRESULT WINAPI - D3DXCreateTextureFromResourceExW( - LPDIRECT3DDEVICE8 pDevice, - HMODULE hSrcModule, - LPCWSTR pSrcResource, - UINT Width, - UINT Height, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DTEXTURE8* ppTexture); - -#ifdef UNICODE -#define D3DXCreateTextureFromResourceEx D3DXCreateTextureFromResourceExW -#else -#define D3DXCreateTextureFromResourceEx D3DXCreateTextureFromResourceExA -#endif - - -HRESULT WINAPI - D3DXCreateCubeTextureFromResourceExA( - LPDIRECT3DDEVICE8 pDevice, - HMODULE hSrcModule, - LPCSTR pSrcResource, - UINT Size, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DCUBETEXTURE8* ppCubeTexture); - -HRESULT WINAPI - D3DXCreateCubeTextureFromResourceExW( - LPDIRECT3DDEVICE8 pDevice, - HMODULE hSrcModule, - LPCWSTR pSrcResource, - UINT Size, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DCUBETEXTURE8* ppCubeTexture); - -#ifdef UNICODE -#define D3DXCreateCubeTextureFromResourceEx D3DXCreateCubeTextureFromResourceExW -#else -#define D3DXCreateCubeTextureFromResourceEx D3DXCreateCubeTextureFromResourceExA -#endif - - -HRESULT WINAPI - D3DXCreateVolumeTextureFromResourceExA( - LPDIRECT3DDEVICE8 pDevice, - HMODULE hSrcModule, - LPCSTR pSrcResource, - UINT Width, - UINT Height, - UINT Depth, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); - -HRESULT WINAPI - D3DXCreateVolumeTextureFromResourceExW( - LPDIRECT3DDEVICE8 pDevice, - HMODULE hSrcModule, - LPCWSTR pSrcResource, - UINT Width, - UINT Height, - UINT Depth, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); - -#ifdef UNICODE -#define D3DXCreateVolumeTextureFromResourceEx D3DXCreateVolumeTextureFromResourceExW -#else -#define D3DXCreateVolumeTextureFromResourceEx D3DXCreateVolumeTextureFromResourceExA -#endif - - -// FromFileInMemory - -HRESULT WINAPI - D3DXCreateTextureFromFileInMemory( - LPDIRECT3DDEVICE8 pDevice, - LPCVOID pSrcData, - UINT SrcDataSize, - LPDIRECT3DTEXTURE8* ppTexture); - -HRESULT WINAPI - D3DXCreateCubeTextureFromFileInMemory( - LPDIRECT3DDEVICE8 pDevice, - LPCVOID pSrcData, - UINT SrcDataSize, - LPDIRECT3DCUBETEXTURE8* ppCubeTexture); - -HRESULT WINAPI - D3DXCreateVolumeTextureFromFileInMemory( - LPDIRECT3DDEVICE8 pDevice, - LPCVOID pSrcData, - UINT SrcDataSize, - LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); - - -// FromFileInMemoryEx - -HRESULT WINAPI - D3DXCreateTextureFromFileInMemoryEx( - LPDIRECT3DDEVICE8 pDevice, - LPCVOID pSrcData, - UINT SrcDataSize, - UINT Width, - UINT Height, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DTEXTURE8* ppTexture); - -HRESULT WINAPI - D3DXCreateCubeTextureFromFileInMemoryEx( - LPDIRECT3DDEVICE8 pDevice, - LPCVOID pSrcData, - UINT SrcDataSize, - UINT Size, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DCUBETEXTURE8* ppCubeTexture); - -HRESULT WINAPI - D3DXCreateVolumeTextureFromFileInMemoryEx( - LPDIRECT3DDEVICE8 pDevice, - LPCVOID pSrcData, - UINT SrcDataSize, - UINT Width, - UINT Height, - UINT Depth, - UINT MipLevels, - DWORD Usage, - D3DFORMAT Format, - D3DPOOL Pool, - DWORD Filter, - DWORD MipFilter, - D3DCOLOR ColorKey, - D3DXIMAGE_INFO* pSrcInfo, - PALETTEENTRY* pPalette, - LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); - - - -//---------------------------------------------------------------------------- -// D3DXSaveTextureToFile: -// ---------------------- -// Save a texture to a file. -// -// Parameters: -// pDestFile -// File name of the destination file -// DestFormat -// D3DXIMAGE_FILEFORMAT specifying file format to use when saving. -// pSrcTexture -// Source texture, containing the image to be saved -// pSrcPalette -// Source palette of 256 colors, or NULL -// -//---------------------------------------------------------------------------- - - -HRESULT WINAPI - D3DXSaveTextureToFileA( - LPCSTR pDestFile, - D3DXIMAGE_FILEFORMAT DestFormat, - LPDIRECT3DBASETEXTURE8 pSrcTexture, - CONST PALETTEENTRY* pSrcPalette); - -HRESULT WINAPI - D3DXSaveTextureToFileW( - LPCWSTR pDestFile, - D3DXIMAGE_FILEFORMAT DestFormat, - LPDIRECT3DBASETEXTURE8 pSrcTexture, - CONST PALETTEENTRY* pSrcPalette); - -#ifdef UNICODE -#define D3DXSaveTextureToFile D3DXSaveTextureToFileW -#else -#define D3DXSaveTextureToFile D3DXSaveTextureToFileA -#endif - - - - -////////////////////////////////////////////////////////////////////////////// -// Misc Texture APIs ///////////////////////////////////////////////////////// -////////////////////////////////////////////////////////////////////////////// - -//---------------------------------------------------------------------------- -// D3DXFilterTexture: -// ------------------ -// Filters mipmaps levels of a texture. -// -// Parameters: -// pBaseTexture -// The texture object to be filtered -// pPalette -// 256 color palette to be used, or NULL for non-palettized formats -// SrcLevel -// The level whose image is used to generate the subsequent levels. -// Filter -// D3DX_FILTER flags controlling how each miplevel is filtered. -// Or D3DX_DEFAULT for D3DX_FILTER_BOX, -// -//---------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXFilterTexture( - LPDIRECT3DBASETEXTURE8 pBaseTexture, - CONST PALETTEENTRY* pPalette, - UINT SrcLevel, - DWORD Filter); - -#define D3DXFilterCubeTexture D3DXFilterTexture -#define D3DXFilterVolumeTexture D3DXFilterTexture - - - -//---------------------------------------------------------------------------- -// D3DXFillTexture: -// ---------------- -// Uses a user provided function to fill each texel of each mip level of a -// given texture. -// -// Paramters: -// pTexture, pCubeTexture, pVolumeTexture -// Pointer to the texture to be filled. -// pFunction -// Pointer to user provided evalutor function which will be used to -// compute the value of each texel. -// pData -// Pointer to an arbitrary block of user defined data. This pointer -// will be passed to the function provided in pFunction -//----------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXFillTexture( - LPDIRECT3DTEXTURE8 pTexture, - LPD3DXFILL2D pFunction, - LPVOID pData); - -HRESULT WINAPI - D3DXFillCubeTexture( - LPDIRECT3DCUBETEXTURE8 pCubeTexture, - LPD3DXFILL3D pFunction, - LPVOID pData); - -HRESULT WINAPI - D3DXFillVolumeTexture( - LPDIRECT3DVOLUMETEXTURE8 pVolumeTexture, - LPD3DXFILL3D pFunction, - LPVOID pData); - - - -//---------------------------------------------------------------------------- -// D3DXComputeNormalMap: -// --------------------- -// Converts a height map into a normal map. The (x,y,z) components of each -// normal are mapped to the (r,g,b) channels of the output texture. -// -// Parameters -// pTexture -// Pointer to the destination texture -// pSrcTexture -// Pointer to the source heightmap texture -// pSrcPalette -// Source palette of 256 colors, or NULL -// Flags -// D3DX_NORMALMAP flags -// Channel -// D3DX_CHANNEL specifying source of height information -// Amplitude -// The constant value which the height information is multiplied by. -//--------------------------------------------------------------------------- - -HRESULT WINAPI - D3DXComputeNormalMap( - LPDIRECT3DTEXTURE8 pTexture, - LPDIRECT3DTEXTURE8 pSrcTexture, - CONST PALETTEENTRY* pSrcPalette, - DWORD Flags, - DWORD Channel, - FLOAT Amplitude); - - - - -#ifdef __cplusplus -} -#endif //__cplusplus - -#endif //__D3DX8TEX_H__ +////////////////////////////////////////////////////////////////////////////// +// +// Copyright (C) Microsoft Corporation. All Rights Reserved. +// +// File: d3dx8tex.h +// Content: D3DX texturing APIs +// +////////////////////////////////////////////////////////////////////////////// + +#include "d3dx8.h" + +#ifndef __D3DX8TEX_H__ +#define __D3DX8TEX_H__ + + +//---------------------------------------------------------------------------- +// D3DX_FILTER flags: +// ------------------ +// +// A valid filter must contain one of these values: +// +// D3DX_FILTER_NONE +// No scaling or filtering will take place. Pixels outside the bounds +// of the source image are assumed to be transparent black. +// D3DX_FILTER_POINT +// Each destination pixel is computed by sampling the nearest pixel +// from the source image. +// D3DX_FILTER_LINEAR +// Each destination pixel is computed by linearly interpolating between +// the nearest pixels in the source image. This filter works best +// when the scale on each axis is less than 2. +// D3DX_FILTER_TRIANGLE +// Every pixel in the source image contributes equally to the +// destination image. This is the slowest of all the filters. +// D3DX_FILTER_BOX +// Each pixel is computed by averaging a 2x2(x2) box pixels from +// the source image. Only works when the dimensions of the +// destination are half those of the source. (as with mip maps) +// +// And can be OR'd with any of these optional flags: +// +// D3DX_FILTER_MIRROR_U +// Indicates that pixels off the edge of the texture on the U-axis +// should be mirrored, not wraped. +// D3DX_FILTER_MIRROR_V +// Indicates that pixels off the edge of the texture on the V-axis +// should be mirrored, not wraped. +// D3DX_FILTER_MIRROR_W +// Indicates that pixels off the edge of the texture on the W-axis +// should be mirrored, not wraped. +// D3DX_FILTER_MIRROR +// Same as specifying D3DX_FILTER_MIRROR_U | D3DX_FILTER_MIRROR_V | +// D3DX_FILTER_MIRROR_V +// D3DX_FILTER_DITHER +// Dithers the resulting image. +// +//---------------------------------------------------------------------------- + +#define D3DX_FILTER_NONE (1 << 0) +#define D3DX_FILTER_POINT (2 << 0) +#define D3DX_FILTER_LINEAR (3 << 0) +#define D3DX_FILTER_TRIANGLE (4 << 0) +#define D3DX_FILTER_BOX (5 << 0) + +#define D3DX_FILTER_MIRROR_U (1 << 16) +#define D3DX_FILTER_MIRROR_V (2 << 16) +#define D3DX_FILTER_MIRROR_W (4 << 16) +#define D3DX_FILTER_MIRROR (7 << 16) +#define D3DX_FILTER_DITHER (8 << 16) + + +//---------------------------------------------------------------------------- +// D3DX_NORMALMAP flags: +// --------------------- +// These flags are used to control how D3DXComputeNormalMap generates normal +// maps. Any number of these flags may be OR'd together in any combination. +// +// D3DX_NORMALMAP_MIRROR_U +// Indicates that pixels off the edge of the texture on the U-axis +// should be mirrored, not wraped. +// D3DX_NORMALMAP_MIRROR_V +// Indicates that pixels off the edge of the texture on the V-axis +// should be mirrored, not wraped. +// D3DX_NORMALMAP_MIRROR +// Same as specifying D3DX_NORMALMAP_MIRROR_U | D3DX_NORMALMAP_MIRROR_V +// D3DX_NORMALMAP_INVERTSIGN +// Inverts the direction of each normal +// D3DX_NORMALMAP_COMPUTE_OCCLUSION +// Compute the per pixel Occlusion term and encodes it into the alpha. +// An Alpha of 1 means that the pixel is not obscured in anyway, and +// an alpha of 0 would mean that the pixel is completly obscured. +// +//---------------------------------------------------------------------------- + +//---------------------------------------------------------------------------- + +#define D3DX_NORMALMAP_MIRROR_U (1 << 16) +#define D3DX_NORMALMAP_MIRROR_V (2 << 16) +#define D3DX_NORMALMAP_MIRROR (3 << 16) +#define D3DX_NORMALMAP_INVERTSIGN (8 << 16) +#define D3DX_NORMALMAP_COMPUTE_OCCLUSION (16 << 16) + + + + +//---------------------------------------------------------------------------- +// D3DX_CHANNEL flags: +// ------------------- +// These flags are used by functions which operate on or more channels +// in a texture. +// +// D3DX_CHANNEL_RED +// Indicates the red channel should be used +// D3DX_CHANNEL_BLUE +// Indicates the blue channel should be used +// D3DX_CHANNEL_GREEN +// Indicates the green channel should be used +// D3DX_CHANNEL_ALPHA +// Indicates the alpha channel should be used +// D3DX_CHANNEL_LUMINANCE +// Indicates the luminaces of the red green and blue channels should be +// used. +// +//---------------------------------------------------------------------------- + +#define D3DX_CHANNEL_RED (1 << 0) +#define D3DX_CHANNEL_BLUE (1 << 1) +#define D3DX_CHANNEL_GREEN (1 << 2) +#define D3DX_CHANNEL_ALPHA (1 << 3) +#define D3DX_CHANNEL_LUMINANCE (1 << 4) + + + + +//---------------------------------------------------------------------------- +// D3DXIMAGE_FILEFORMAT: +// --------------------- +// This enum is used to describe supported image file formats. +// +//---------------------------------------------------------------------------- + +typedef enum _D3DXIMAGE_FILEFORMAT +{ + D3DXIFF_BMP = 0, + D3DXIFF_JPG = 1, + D3DXIFF_TGA = 2, + D3DXIFF_PNG = 3, + D3DXIFF_DDS = 4, + D3DXIFF_PPM = 5, + D3DXIFF_DIB = 6, + D3DXIFF_FORCE_DWORD = 0x7fffffff + +} D3DXIMAGE_FILEFORMAT; + + +//---------------------------------------------------------------------------- +// LPD3DXFILL2D and LPD3DXFILL3D: +// ------------------------------ +// Function types used by the texture fill functions. +// +// Parameters: +// pOut +// Pointer to a vector which the function uses to return its result. +// X,Y,Z,W will be mapped to R,G,B,A respectivly. +// pTexCoord +// Pointer to a vector containing the coordinates of the texel currently +// being evaluated. Textures and VolumeTexture texcoord components +// range from 0 to 1. CubeTexture texcoord component range from -1 to 1. +// pTexelSize +// Pointer to a vector containing the dimensions of the current texel. +// pData +// Pointer to user data. +// +//---------------------------------------------------------------------------- + +typedef VOID (*LPD3DXFILL2D)(D3DXVECTOR4 *pOut, D3DXVECTOR2 *pTexCoord, D3DXVECTOR2 *pTexelSize, LPVOID pData); +typedef VOID (*LPD3DXFILL3D)(D3DXVECTOR4 *pOut, D3DXVECTOR3 *pTexCoord, D3DXVECTOR3 *pTexelSize, LPVOID pData); + + + +//---------------------------------------------------------------------------- +// D3DXIMAGE_INFO: +// --------------- +// This structure is used to return a rough description of what the +// the original contents of an image file looked like. +// +// Width +// Width of original image in pixels +// Height +// Height of original image in pixels +// Depth +// Depth of original image in pixels +// MipLevels +// Number of mip levels in original image +// Format +// D3D format which most closely describes the data in original image +// ResourceType +// D3DRESOURCETYPE representing the type of texture stored in the file. +// D3DRTYPE_TEXTURE, D3DRTYPE_VOLUMETEXTURE, or D3DRTYPE_CUBETEXTURE. +// ImageFileFormat +// D3DXIMAGE_FILEFORMAT representing the format of the image file. +// +//---------------------------------------------------------------------------- + +typedef struct _D3DXIMAGE_INFO +{ + UINT Width; + UINT Height; + UINT Depth; + UINT MipLevels; + D3DFORMAT Format; + D3DRESOURCETYPE ResourceType; + D3DXIMAGE_FILEFORMAT ImageFileFormat; + +} D3DXIMAGE_INFO; + + + + + +#ifdef __cplusplus +extern "C" { +#endif //__cplusplus + + + +////////////////////////////////////////////////////////////////////////////// +// Image File APIs /////////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// +; +//---------------------------------------------------------------------------- +// GetImageInfoFromFile/Resource: +// ------------------------------ +// Fills in a D3DXIMAGE_INFO struct with information about an image file. +// +// Parameters: +// pSrcFile +// File name of the source image. +// pSrcModule +// Module where resource is located, or NULL for module associated +// with image the os used to create the current process. +// pSrcResource +// Resource name +// pSrcData +// Pointer to file in memory. +// SrcDataSize +// Size in bytes of file in memory. +// pSrcInfo +// Pointer to a D3DXIMAGE_INFO structure to be filled in with the +// description of the data in the source image file. +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXGetImageInfoFromFileA( + LPCSTR pSrcFile, + D3DXIMAGE_INFO* pSrcInfo); + +HRESULT WINAPI + D3DXGetImageInfoFromFileW( + LPCWSTR pSrcFile, + D3DXIMAGE_INFO* pSrcInfo); + +#ifdef UNICODE +#define D3DXGetImageInfoFromFile D3DXGetImageInfoFromFileW +#else +#define D3DXGetImageInfoFromFile D3DXGetImageInfoFromFileA +#endif + + +HRESULT WINAPI + D3DXGetImageInfoFromResourceA( + HMODULE hSrcModule, + LPCSTR pSrcResource, + D3DXIMAGE_INFO* pSrcInfo); + +HRESULT WINAPI + D3DXGetImageInfoFromResourceW( + HMODULE hSrcModule, + LPCWSTR pSrcResource, + D3DXIMAGE_INFO* pSrcInfo); + +#ifdef UNICODE +#define D3DXGetImageInfoFromResource D3DXGetImageInfoFromResourceW +#else +#define D3DXGetImageInfoFromResource D3DXGetImageInfoFromResourceA +#endif + + +HRESULT WINAPI + D3DXGetImageInfoFromFileInMemory( + LPCVOID pSrcData, + UINT SrcDataSize, + D3DXIMAGE_INFO* pSrcInfo); + + + + +////////////////////////////////////////////////////////////////////////////// +// Load/Save Surface APIs //////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +//---------------------------------------------------------------------------- +// D3DXLoadSurfaceFromFile/Resource: +// --------------------------------- +// Load surface from a file or resource +// +// Parameters: +// pDestSurface +// Destination surface, which will receive the image. +// pDestPalette +// Destination palette of 256 colors, or NULL +// pDestRect +// Destination rectangle, or NULL for entire surface +// pSrcFile +// File name of the source image. +// pSrcModule +// Module where resource is located, or NULL for module associated +// with image the os used to create the current process. +// pSrcResource +// Resource name +// pSrcData +// Pointer to file in memory. +// SrcDataSize +// Size in bytes of file in memory. +// pSrcRect +// Source rectangle, or NULL for entire image +// Filter +// D3DX_FILTER flags controlling how the image is filtered. +// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. +// ColorKey +// Color to replace with transparent black, or 0 to disable colorkey. +// This is always a 32-bit ARGB color, independent of the source image +// format. Alpha is significant, and should usually be set to FF for +// opaque colorkeys. (ex. Opaque black == 0xff000000) +// pSrcInfo +// Pointer to a D3DXIMAGE_INFO structure to be filled in with the +// description of the data in the source image file, or NULL. +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXLoadSurfaceFromFileA( + LPDIRECT3DSURFACE8 pDestSurface, + CONST PALETTEENTRY* pDestPalette, + CONST RECT* pDestRect, + LPCSTR pSrcFile, + CONST RECT* pSrcRect, + DWORD Filter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo); + +HRESULT WINAPI + D3DXLoadSurfaceFromFileW( + LPDIRECT3DSURFACE8 pDestSurface, + CONST PALETTEENTRY* pDestPalette, + CONST RECT* pDestRect, + LPCWSTR pSrcFile, + CONST RECT* pSrcRect, + DWORD Filter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo); + +#ifdef UNICODE +#define D3DXLoadSurfaceFromFile D3DXLoadSurfaceFromFileW +#else +#define D3DXLoadSurfaceFromFile D3DXLoadSurfaceFromFileA +#endif + + + +HRESULT WINAPI + D3DXLoadSurfaceFromResourceA( + LPDIRECT3DSURFACE8 pDestSurface, + CONST PALETTEENTRY* pDestPalette, + CONST RECT* pDestRect, + HMODULE hSrcModule, + LPCSTR pSrcResource, + CONST RECT* pSrcRect, + DWORD Filter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo); + +HRESULT WINAPI + D3DXLoadSurfaceFromResourceW( + LPDIRECT3DSURFACE8 pDestSurface, + CONST PALETTEENTRY* pDestPalette, + CONST RECT* pDestRect, + HMODULE hSrcModule, + LPCWSTR pSrcResource, + CONST RECT* pSrcRect, + DWORD Filter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo); + + +#ifdef UNICODE +#define D3DXLoadSurfaceFromResource D3DXLoadSurfaceFromResourceW +#else +#define D3DXLoadSurfaceFromResource D3DXLoadSurfaceFromResourceA +#endif + + + +HRESULT WINAPI + D3DXLoadSurfaceFromFileInMemory( + LPDIRECT3DSURFACE8 pDestSurface, + CONST PALETTEENTRY* pDestPalette, + CONST RECT* pDestRect, + LPCVOID pSrcData, + UINT SrcDataSize, + CONST RECT* pSrcRect, + DWORD Filter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo); + + + +//---------------------------------------------------------------------------- +// D3DXLoadSurfaceFromSurface: +// --------------------------- +// Load surface from another surface (with color conversion) +// +// Parameters: +// pDestSurface +// Destination surface, which will receive the image. +// pDestPalette +// Destination palette of 256 colors, or NULL +// pDestRect +// Destination rectangle, or NULL for entire surface +// pSrcSurface +// Source surface +// pSrcPalette +// Source palette of 256 colors, or NULL +// pSrcRect +// Source rectangle, or NULL for entire surface +// Filter +// D3DX_FILTER flags controlling how the image is filtered. +// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. +// ColorKey +// Color to replace with transparent black, or 0 to disable colorkey. +// This is always a 32-bit ARGB color, independent of the source image +// format. Alpha is significant, and should usually be set to FF for +// opaque colorkeys. (ex. Opaque black == 0xff000000) +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXLoadSurfaceFromSurface( + LPDIRECT3DSURFACE8 pDestSurface, + CONST PALETTEENTRY* pDestPalette, + CONST RECT* pDestRect, + LPDIRECT3DSURFACE8 pSrcSurface, + CONST PALETTEENTRY* pSrcPalette, + CONST RECT* pSrcRect, + DWORD Filter, + D3DCOLOR ColorKey); + + +//---------------------------------------------------------------------------- +// D3DXLoadSurfaceFromMemory: +// -------------------------- +// Load surface from memory. +// +// Parameters: +// pDestSurface +// Destination surface, which will receive the image. +// pDestPalette +// Destination palette of 256 colors, or NULL +// pDestRect +// Destination rectangle, or NULL for entire surface +// pSrcMemory +// Pointer to the top-left corner of the source image in memory +// SrcFormat +// Pixel format of the source image. +// SrcPitch +// Pitch of source image, in bytes. For DXT formats, this number +// should represent the width of one row of cells, in bytes. +// pSrcPalette +// Source palette of 256 colors, or NULL +// pSrcRect +// Source rectangle. +// Filter +// D3DX_FILTER flags controlling how the image is filtered. +// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. +// ColorKey +// Color to replace with transparent black, or 0 to disable colorkey. +// This is always a 32-bit ARGB color, independent of the source image +// format. Alpha is significant, and should usually be set to FF for +// opaque colorkeys. (ex. Opaque black == 0xff000000) +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXLoadSurfaceFromMemory( + LPDIRECT3DSURFACE8 pDestSurface, + CONST PALETTEENTRY* pDestPalette, + CONST RECT* pDestRect, + LPCVOID pSrcMemory, + D3DFORMAT SrcFormat, + UINT SrcPitch, + CONST PALETTEENTRY* pSrcPalette, + CONST RECT* pSrcRect, + DWORD Filter, + D3DCOLOR ColorKey); + + +//---------------------------------------------------------------------------- +// D3DXSaveSurfaceToFile: +// ---------------------- +// Save a surface to a image file. +// +// Parameters: +// pDestFile +// File name of the destination file +// DestFormat +// D3DXIMAGE_FILEFORMAT specifying file format to use when saving. +// pSrcSurface +// Source surface, containing the image to be saved +// pSrcPalette +// Source palette of 256 colors, or NULL +// pSrcRect +// Source rectangle, or NULL for the entire image +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXSaveSurfaceToFileA( + LPCSTR pDestFile, + D3DXIMAGE_FILEFORMAT DestFormat, + LPDIRECT3DSURFACE8 pSrcSurface, + CONST PALETTEENTRY* pSrcPalette, + CONST RECT* pSrcRect); + +HRESULT WINAPI + D3DXSaveSurfaceToFileW( + LPCWSTR pDestFile, + D3DXIMAGE_FILEFORMAT DestFormat, + LPDIRECT3DSURFACE8 pSrcSurface, + CONST PALETTEENTRY* pSrcPalette, + CONST RECT* pSrcRect); + +#ifdef UNICODE +#define D3DXSaveSurfaceToFile D3DXSaveSurfaceToFileW +#else +#define D3DXSaveSurfaceToFile D3DXSaveSurfaceToFileA +#endif + + + + +////////////////////////////////////////////////////////////////////////////// +// Load/Save Volume APIs ///////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +//---------------------------------------------------------------------------- +// D3DXLoadVolumeFromFile/Resource: +// -------------------------------- +// Load volume from a file or resource +// +// Parameters: +// pDestVolume +// Destination volume, which will receive the image. +// pDestPalette +// Destination palette of 256 colors, or NULL +// pDestBox +// Destination box, or NULL for entire volume +// pSrcFile +// File name of the source image. +// pSrcModule +// Module where resource is located, or NULL for module associated +// with image the os used to create the current process. +// pSrcResource +// Resource name +// pSrcData +// Pointer to file in memory. +// SrcDataSize +// Size in bytes of file in memory. +// pSrcBox +// Source box, or NULL for entire image +// Filter +// D3DX_FILTER flags controlling how the image is filtered. +// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. +// ColorKey +// Color to replace with transparent black, or 0 to disable colorkey. +// This is always a 32-bit ARGB color, independent of the source image +// format. Alpha is significant, and should usually be set to FF for +// opaque colorkeys. (ex. Opaque black == 0xff000000) +// pSrcInfo +// Pointer to a D3DXIMAGE_INFO structure to be filled in with the +// description of the data in the source image file, or NULL. +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXLoadVolumeFromFileA( + LPDIRECT3DVOLUME8 pDestVolume, + CONST PALETTEENTRY* pDestPalette, + CONST D3DBOX* pDestBox, + LPCSTR pSrcFile, + CONST D3DBOX* pSrcBox, + DWORD Filter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo); + +HRESULT WINAPI + D3DXLoadVolumeFromFileW( + LPDIRECT3DVOLUME8 pDestVolume, + CONST PALETTEENTRY* pDestPalette, + CONST D3DBOX* pDestBox, + LPCWSTR pSrcFile, + CONST D3DBOX* pSrcBox, + DWORD Filter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo); + +#ifdef UNICODE +#define D3DXLoadVolumeFromFile D3DXLoadVolumeFromFileW +#else +#define D3DXLoadVolumeFromFile D3DXLoadVolumeFromFileA +#endif + + +HRESULT WINAPI + D3DXLoadVolumeFromResourceA( + LPDIRECT3DVOLUME8 pDestVolume, + CONST PALETTEENTRY* pDestPalette, + CONST D3DBOX* pDestBox, + HMODULE hSrcModule, + LPCSTR pSrcResource, + CONST D3DBOX* pSrcBox, + DWORD Filter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo); + +HRESULT WINAPI + D3DXLoadVolumeFromResourceW( + LPDIRECT3DVOLUME8 pDestVolume, + CONST PALETTEENTRY* pDestPalette, + CONST D3DBOX* pDestBox, + HMODULE hSrcModule, + LPCWSTR pSrcResource, + CONST D3DBOX* pSrcBox, + DWORD Filter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo); + +#ifdef UNICODE +#define D3DXLoadVolumeFromResource D3DXLoadVolumeFromResourceW +#else +#define D3DXLoadVolumeFromResource D3DXLoadVolumeFromResourceA +#endif + + + +HRESULT WINAPI + D3DXLoadVolumeFromFileInMemory( + LPDIRECT3DVOLUME8 pDestVolume, + CONST PALETTEENTRY* pDestPalette, + CONST D3DBOX* pDestBox, + LPCVOID pSrcData, + UINT SrcDataSize, + CONST D3DBOX* pSrcBox, + DWORD Filter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo); + + + +//---------------------------------------------------------------------------- +// D3DXLoadVolumeFromVolume: +// ------------------------- +// Load volume from another volume (with color conversion) +// +// Parameters: +// pDestVolume +// Destination volume, which will receive the image. +// pDestPalette +// Destination palette of 256 colors, or NULL +// pDestBox +// Destination box, or NULL for entire volume +// pSrcVolume +// Source volume +// pSrcPalette +// Source palette of 256 colors, or NULL +// pSrcBox +// Source box, or NULL for entire volume +// Filter +// D3DX_FILTER flags controlling how the image is filtered. +// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. +// ColorKey +// Color to replace with transparent black, or 0 to disable colorkey. +// This is always a 32-bit ARGB color, independent of the source image +// format. Alpha is significant, and should usually be set to FF for +// opaque colorkeys. (ex. Opaque black == 0xff000000) +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXLoadVolumeFromVolume( + LPDIRECT3DVOLUME8 pDestVolume, + CONST PALETTEENTRY* pDestPalette, + CONST D3DBOX* pDestBox, + LPDIRECT3DVOLUME8 pSrcVolume, + CONST PALETTEENTRY* pSrcPalette, + CONST D3DBOX* pSrcBox, + DWORD Filter, + D3DCOLOR ColorKey); + + + +//---------------------------------------------------------------------------- +// D3DXLoadVolumeFromMemory: +// ------------------------- +// Load volume from memory. +// +// Parameters: +// pDestVolume +// Destination volume, which will receive the image. +// pDestPalette +// Destination palette of 256 colors, or NULL +// pDestBox +// Destination box, or NULL for entire volume +// pSrcMemory +// Pointer to the top-left corner of the source volume in memory +// SrcFormat +// Pixel format of the source volume. +// SrcRowPitch +// Pitch of source image, in bytes. For DXT formats, this number +// should represent the size of one row of cells, in bytes. +// SrcSlicePitch +// Pitch of source image, in bytes. For DXT formats, this number +// should represent the size of one slice of cells, in bytes. +// pSrcPalette +// Source palette of 256 colors, or NULL +// pSrcBox +// Source box. +// Filter +// D3DX_FILTER flags controlling how the image is filtered. +// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. +// ColorKey +// Color to replace with transparent black, or 0 to disable colorkey. +// This is always a 32-bit ARGB color, independent of the source image +// format. Alpha is significant, and should usually be set to FF for +// opaque colorkeys. (ex. Opaque black == 0xff000000) +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXLoadVolumeFromMemory( + LPDIRECT3DVOLUME8 pDestVolume, + CONST PALETTEENTRY* pDestPalette, + CONST D3DBOX* pDestBox, + LPCVOID pSrcMemory, + D3DFORMAT SrcFormat, + UINT SrcRowPitch, + UINT SrcSlicePitch, + CONST PALETTEENTRY* pSrcPalette, + CONST D3DBOX* pSrcBox, + DWORD Filter, + D3DCOLOR ColorKey); + + + +//---------------------------------------------------------------------------- +// D3DXSaveVolumeToFile: +// --------------------- +// Save a volume to a image file. +// +// Parameters: +// pDestFile +// File name of the destination file +// DestFormat +// D3DXIMAGE_FILEFORMAT specifying file format to use when saving. +// pSrcVolume +// Source volume, containing the image to be saved +// pSrcPalette +// Source palette of 256 colors, or NULL +// pSrcBox +// Source box, or NULL for the entire volume +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXSaveVolumeToFileA( + LPCSTR pDestFile, + D3DXIMAGE_FILEFORMAT DestFormat, + LPDIRECT3DVOLUME8 pSrcVolume, + CONST PALETTEENTRY* pSrcPalette, + CONST D3DBOX* pSrcBox); + +HRESULT WINAPI + D3DXSaveVolumeToFileW( + LPCWSTR pDestFile, + D3DXIMAGE_FILEFORMAT DestFormat, + LPDIRECT3DVOLUME8 pSrcVolume, + CONST PALETTEENTRY* pSrcPalette, + CONST D3DBOX* pSrcBox); + +#ifdef UNICODE +#define D3DXSaveVolumeToFile D3DXSaveVolumeToFileW +#else +#define D3DXSaveVolumeToFile D3DXSaveVolumeToFileA +#endif + + + + +////////////////////////////////////////////////////////////////////////////// +// Create/Save Texture APIs ////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +//---------------------------------------------------------------------------- +// D3DXCheckTextureRequirements: +// ----------------------------- +// Checks texture creation parameters. If parameters are invalid, this +// function returns corrected parameters. +// +// Parameters: +// +// pDevice +// The D3D device to be used +// pWidth, pHeight, pDepth, pSize +// Desired size in pixels, or NULL. Returns corrected size. +// pNumMipLevels +// Number of desired mipmap levels, or NULL. Returns corrected number. +// Usage +// Texture usage flags +// pFormat +// Desired pixel format, or NULL. Returns corrected format. +// Pool +// Memory pool to be used to create texture +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXCheckTextureRequirements( + LPDIRECT3DDEVICE8 pDevice, + UINT* pWidth, + UINT* pHeight, + UINT* pNumMipLevels, + DWORD Usage, + D3DFORMAT* pFormat, + D3DPOOL Pool); + +HRESULT WINAPI + D3DXCheckCubeTextureRequirements( + LPDIRECT3DDEVICE8 pDevice, + UINT* pSize, + UINT* pNumMipLevels, + DWORD Usage, + D3DFORMAT* pFormat, + D3DPOOL Pool); + +HRESULT WINAPI + D3DXCheckVolumeTextureRequirements( + LPDIRECT3DDEVICE8 pDevice, + UINT* pWidth, + UINT* pHeight, + UINT* pDepth, + UINT* pNumMipLevels, + DWORD Usage, + D3DFORMAT* pFormat, + D3DPOOL Pool); + + +//---------------------------------------------------------------------------- +// D3DXCreateTexture: +// ------------------ +// Create an empty texture +// +// Parameters: +// +// pDevice +// The D3D device with which the texture is going to be used. +// Width, Height, Depth, Size +// size in pixels; these must be non-zero +// MipLevels +// number of mip levels desired; if zero or D3DX_DEFAULT, a complete +// mipmap chain will be created. +// Usage +// Texture usage flags +// Format +// Pixel format. +// Pool +// Memory pool to be used to create texture +// ppTexture, ppCubeTexture, ppVolumeTexture +// The texture object that will be created +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXCreateTexture( + LPDIRECT3DDEVICE8 pDevice, + UINT Width, + UINT Height, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + LPDIRECT3DTEXTURE8* ppTexture); + +HRESULT WINAPI + D3DXCreateCubeTexture( + LPDIRECT3DDEVICE8 pDevice, + UINT Size, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + LPDIRECT3DCUBETEXTURE8* ppCubeTexture); + +HRESULT WINAPI + D3DXCreateVolumeTexture( + LPDIRECT3DDEVICE8 pDevice, + UINT Width, + UINT Height, + UINT Depth, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); + + + +//---------------------------------------------------------------------------- +// D3DXCreateTextureFromFile/Resource: +// ----------------------------------- +// Create a texture object from a file or resource. +// +// Parameters: +// +// pDevice +// The D3D device with which the texture is going to be used. +// pSrcFile +// File name. +// hSrcModule +// Module handle. if NULL, current module will be used. +// pSrcResource +// Resource name in module +// pvSrcData +// Pointer to file in memory. +// SrcDataSize +// Size in bytes of file in memory. +// Width, Height, Depth, Size +// Size in pixels; if zero or D3DX_DEFAULT, the size will be taken +// from the file. +// MipLevels +// Number of mip levels; if zero or D3DX_DEFAULT, a complete mipmap +// chain will be created. +// Usage +// Texture usage flags +// Format +// Desired pixel format. If D3DFMT_UNKNOWN, the format will be +// taken from the file. +// Pool +// Memory pool to be used to create texture +// Filter +// D3DX_FILTER flags controlling how the image is filtered. +// Or D3DX_DEFAULT for D3DX_FILTER_TRIANGLE. +// MipFilter +// D3DX_FILTER flags controlling how each miplevel is filtered. +// Or D3DX_DEFAULT for D3DX_FILTER_BOX, +// ColorKey +// Color to replace with transparent black, or 0 to disable colorkey. +// This is always a 32-bit ARGB color, independent of the source image +// format. Alpha is significant, and should usually be set to FF for +// opaque colorkeys. (ex. Opaque black == 0xff000000) +// pSrcInfo +// Pointer to a D3DXIMAGE_INFO structure to be filled in with the +// description of the data in the source image file, or NULL. +// pPalette +// 256 color palette to be filled in, or NULL +// ppTexture, ppCubeTexture, ppVolumeTexture +// The texture object that will be created +// +//---------------------------------------------------------------------------- + + +// FromFile + +HRESULT WINAPI + D3DXCreateTextureFromFileA( + LPDIRECT3DDEVICE8 pDevice, + LPCSTR pSrcFile, + LPDIRECT3DTEXTURE8* ppTexture); + +HRESULT WINAPI + D3DXCreateTextureFromFileW( + LPDIRECT3DDEVICE8 pDevice, + LPCWSTR pSrcFile, + LPDIRECT3DTEXTURE8* ppTexture); + +#ifdef UNICODE +#define D3DXCreateTextureFromFile D3DXCreateTextureFromFileW +#else +#define D3DXCreateTextureFromFile D3DXCreateTextureFromFileA +#endif + + +HRESULT WINAPI + D3DXCreateCubeTextureFromFileA( + LPDIRECT3DDEVICE8 pDevice, + LPCSTR pSrcFile, + LPDIRECT3DCUBETEXTURE8* ppCubeTexture); + +HRESULT WINAPI + D3DXCreateCubeTextureFromFileW( + LPDIRECT3DDEVICE8 pDevice, + LPCWSTR pSrcFile, + LPDIRECT3DCUBETEXTURE8* ppCubeTexture); + +#ifdef UNICODE +#define D3DXCreateCubeTextureFromFile D3DXCreateCubeTextureFromFileW +#else +#define D3DXCreateCubeTextureFromFile D3DXCreateCubeTextureFromFileA +#endif + + +HRESULT WINAPI + D3DXCreateVolumeTextureFromFileA( + LPDIRECT3DDEVICE8 pDevice, + LPCSTR pSrcFile, + LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); + +HRESULT WINAPI + D3DXCreateVolumeTextureFromFileW( + LPDIRECT3DDEVICE8 pDevice, + LPCWSTR pSrcFile, + LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); + +#ifdef UNICODE +#define D3DXCreateVolumeTextureFromFile D3DXCreateVolumeTextureFromFileW +#else +#define D3DXCreateVolumeTextureFromFile D3DXCreateVolumeTextureFromFileA +#endif + + +// FromResource + +HRESULT WINAPI + D3DXCreateTextureFromResourceA( + LPDIRECT3DDEVICE8 pDevice, + HMODULE hSrcModule, + LPCSTR pSrcResource, + LPDIRECT3DTEXTURE8* ppTexture); + +HRESULT WINAPI + D3DXCreateTextureFromResourceW( + LPDIRECT3DDEVICE8 pDevice, + HMODULE hSrcModule, + LPCWSTR pSrcResource, + LPDIRECT3DTEXTURE8* ppTexture); + +#ifdef UNICODE +#define D3DXCreateTextureFromResource D3DXCreateTextureFromResourceW +#else +#define D3DXCreateTextureFromResource D3DXCreateTextureFromResourceA +#endif + + +HRESULT WINAPI + D3DXCreateCubeTextureFromResourceA( + LPDIRECT3DDEVICE8 pDevice, + HMODULE hSrcModule, + LPCSTR pSrcResource, + LPDIRECT3DCUBETEXTURE8* ppCubeTexture); + +HRESULT WINAPI + D3DXCreateCubeTextureFromResourceW( + LPDIRECT3DDEVICE8 pDevice, + HMODULE hSrcModule, + LPCWSTR pSrcResource, + LPDIRECT3DCUBETEXTURE8* ppCubeTexture); + +#ifdef UNICODE +#define D3DXCreateCubeTextureFromResource D3DXCreateCubeTextureFromResourceW +#else +#define D3DXCreateCubeTextureFromResource D3DXCreateCubeTextureFromResourceA +#endif + + +HRESULT WINAPI + D3DXCreateVolumeTextureFromResourceA( + LPDIRECT3DDEVICE8 pDevice, + HMODULE hSrcModule, + LPCSTR pSrcResource, + LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); + +HRESULT WINAPI + D3DXCreateVolumeTextureFromResourceW( + LPDIRECT3DDEVICE8 pDevice, + HMODULE hSrcModule, + LPCWSTR pSrcResource, + LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); + +#ifdef UNICODE +#define D3DXCreateVolumeTextureFromResource D3DXCreateVolumeTextureFromResourceW +#else +#define D3DXCreateVolumeTextureFromResource D3DXCreateVolumeTextureFromResourceA +#endif + + +// FromFileEx + +HRESULT WINAPI + D3DXCreateTextureFromFileExA( + LPDIRECT3DDEVICE8 pDevice, + LPCSTR pSrcFile, + UINT Width, + UINT Height, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DTEXTURE8* ppTexture); + +HRESULT WINAPI + D3DXCreateTextureFromFileExW( + LPDIRECT3DDEVICE8 pDevice, + LPCWSTR pSrcFile, + UINT Width, + UINT Height, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DTEXTURE8* ppTexture); + +#ifdef UNICODE +#define D3DXCreateTextureFromFileEx D3DXCreateTextureFromFileExW +#else +#define D3DXCreateTextureFromFileEx D3DXCreateTextureFromFileExA +#endif + + +HRESULT WINAPI + D3DXCreateCubeTextureFromFileExA( + LPDIRECT3DDEVICE8 pDevice, + LPCSTR pSrcFile, + UINT Size, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DCUBETEXTURE8* ppCubeTexture); + +HRESULT WINAPI + D3DXCreateCubeTextureFromFileExW( + LPDIRECT3DDEVICE8 pDevice, + LPCWSTR pSrcFile, + UINT Size, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DCUBETEXTURE8* ppCubeTexture); + +#ifdef UNICODE +#define D3DXCreateCubeTextureFromFileEx D3DXCreateCubeTextureFromFileExW +#else +#define D3DXCreateCubeTextureFromFileEx D3DXCreateCubeTextureFromFileExA +#endif + + +HRESULT WINAPI + D3DXCreateVolumeTextureFromFileExA( + LPDIRECT3DDEVICE8 pDevice, + LPCSTR pSrcFile, + UINT Width, + UINT Height, + UINT Depth, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); + +HRESULT WINAPI + D3DXCreateVolumeTextureFromFileExW( + LPDIRECT3DDEVICE8 pDevice, + LPCWSTR pSrcFile, + UINT Width, + UINT Height, + UINT Depth, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); + +#ifdef UNICODE +#define D3DXCreateVolumeTextureFromFileEx D3DXCreateVolumeTextureFromFileExW +#else +#define D3DXCreateVolumeTextureFromFileEx D3DXCreateVolumeTextureFromFileExA +#endif + + +// FromResourceEx + +HRESULT WINAPI + D3DXCreateTextureFromResourceExA( + LPDIRECT3DDEVICE8 pDevice, + HMODULE hSrcModule, + LPCSTR pSrcResource, + UINT Width, + UINT Height, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DTEXTURE8* ppTexture); + +HRESULT WINAPI + D3DXCreateTextureFromResourceExW( + LPDIRECT3DDEVICE8 pDevice, + HMODULE hSrcModule, + LPCWSTR pSrcResource, + UINT Width, + UINT Height, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DTEXTURE8* ppTexture); + +#ifdef UNICODE +#define D3DXCreateTextureFromResourceEx D3DXCreateTextureFromResourceExW +#else +#define D3DXCreateTextureFromResourceEx D3DXCreateTextureFromResourceExA +#endif + + +HRESULT WINAPI + D3DXCreateCubeTextureFromResourceExA( + LPDIRECT3DDEVICE8 pDevice, + HMODULE hSrcModule, + LPCSTR pSrcResource, + UINT Size, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DCUBETEXTURE8* ppCubeTexture); + +HRESULT WINAPI + D3DXCreateCubeTextureFromResourceExW( + LPDIRECT3DDEVICE8 pDevice, + HMODULE hSrcModule, + LPCWSTR pSrcResource, + UINT Size, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DCUBETEXTURE8* ppCubeTexture); + +#ifdef UNICODE +#define D3DXCreateCubeTextureFromResourceEx D3DXCreateCubeTextureFromResourceExW +#else +#define D3DXCreateCubeTextureFromResourceEx D3DXCreateCubeTextureFromResourceExA +#endif + + +HRESULT WINAPI + D3DXCreateVolumeTextureFromResourceExA( + LPDIRECT3DDEVICE8 pDevice, + HMODULE hSrcModule, + LPCSTR pSrcResource, + UINT Width, + UINT Height, + UINT Depth, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); + +HRESULT WINAPI + D3DXCreateVolumeTextureFromResourceExW( + LPDIRECT3DDEVICE8 pDevice, + HMODULE hSrcModule, + LPCWSTR pSrcResource, + UINT Width, + UINT Height, + UINT Depth, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); + +#ifdef UNICODE +#define D3DXCreateVolumeTextureFromResourceEx D3DXCreateVolumeTextureFromResourceExW +#else +#define D3DXCreateVolumeTextureFromResourceEx D3DXCreateVolumeTextureFromResourceExA +#endif + + +// FromFileInMemory + +HRESULT WINAPI + D3DXCreateTextureFromFileInMemory( + LPDIRECT3DDEVICE8 pDevice, + LPCVOID pSrcData, + UINT SrcDataSize, + LPDIRECT3DTEXTURE8* ppTexture); + +HRESULT WINAPI + D3DXCreateCubeTextureFromFileInMemory( + LPDIRECT3DDEVICE8 pDevice, + LPCVOID pSrcData, + UINT SrcDataSize, + LPDIRECT3DCUBETEXTURE8* ppCubeTexture); + +HRESULT WINAPI + D3DXCreateVolumeTextureFromFileInMemory( + LPDIRECT3DDEVICE8 pDevice, + LPCVOID pSrcData, + UINT SrcDataSize, + LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); + + +// FromFileInMemoryEx + +HRESULT WINAPI + D3DXCreateTextureFromFileInMemoryEx( + LPDIRECT3DDEVICE8 pDevice, + LPCVOID pSrcData, + UINT SrcDataSize, + UINT Width, + UINT Height, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DTEXTURE8* ppTexture); + +HRESULT WINAPI + D3DXCreateCubeTextureFromFileInMemoryEx( + LPDIRECT3DDEVICE8 pDevice, + LPCVOID pSrcData, + UINT SrcDataSize, + UINT Size, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DCUBETEXTURE8* ppCubeTexture); + +HRESULT WINAPI + D3DXCreateVolumeTextureFromFileInMemoryEx( + LPDIRECT3DDEVICE8 pDevice, + LPCVOID pSrcData, + UINT SrcDataSize, + UINT Width, + UINT Height, + UINT Depth, + UINT MipLevels, + DWORD Usage, + D3DFORMAT Format, + D3DPOOL Pool, + DWORD Filter, + DWORD MipFilter, + D3DCOLOR ColorKey, + D3DXIMAGE_INFO* pSrcInfo, + PALETTEENTRY* pPalette, + LPDIRECT3DVOLUMETEXTURE8* ppVolumeTexture); + + + +//---------------------------------------------------------------------------- +// D3DXSaveTextureToFile: +// ---------------------- +// Save a texture to a file. +// +// Parameters: +// pDestFile +// File name of the destination file +// DestFormat +// D3DXIMAGE_FILEFORMAT specifying file format to use when saving. +// pSrcTexture +// Source texture, containing the image to be saved +// pSrcPalette +// Source palette of 256 colors, or NULL +// +//---------------------------------------------------------------------------- + + +HRESULT WINAPI + D3DXSaveTextureToFileA( + LPCSTR pDestFile, + D3DXIMAGE_FILEFORMAT DestFormat, + LPDIRECT3DBASETEXTURE8 pSrcTexture, + CONST PALETTEENTRY* pSrcPalette); + +HRESULT WINAPI + D3DXSaveTextureToFileW( + LPCWSTR pDestFile, + D3DXIMAGE_FILEFORMAT DestFormat, + LPDIRECT3DBASETEXTURE8 pSrcTexture, + CONST PALETTEENTRY* pSrcPalette); + +#ifdef UNICODE +#define D3DXSaveTextureToFile D3DXSaveTextureToFileW +#else +#define D3DXSaveTextureToFile D3DXSaveTextureToFileA +#endif + + + + +////////////////////////////////////////////////////////////////////////////// +// Misc Texture APIs ///////////////////////////////////////////////////////// +////////////////////////////////////////////////////////////////////////////// + +//---------------------------------------------------------------------------- +// D3DXFilterTexture: +// ------------------ +// Filters mipmaps levels of a texture. +// +// Parameters: +// pBaseTexture +// The texture object to be filtered +// pPalette +// 256 color palette to be used, or NULL for non-palettized formats +// SrcLevel +// The level whose image is used to generate the subsequent levels. +// Filter +// D3DX_FILTER flags controlling how each miplevel is filtered. +// Or D3DX_DEFAULT for D3DX_FILTER_BOX, +// +//---------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXFilterTexture( + LPDIRECT3DBASETEXTURE8 pBaseTexture, + CONST PALETTEENTRY* pPalette, + UINT SrcLevel, + DWORD Filter); + +#define D3DXFilterCubeTexture D3DXFilterTexture +#define D3DXFilterVolumeTexture D3DXFilterTexture + + + +//---------------------------------------------------------------------------- +// D3DXFillTexture: +// ---------------- +// Uses a user provided function to fill each texel of each mip level of a +// given texture. +// +// Paramters: +// pTexture, pCubeTexture, pVolumeTexture +// Pointer to the texture to be filled. +// pFunction +// Pointer to user provided evalutor function which will be used to +// compute the value of each texel. +// pData +// Pointer to an arbitrary block of user defined data. This pointer +// will be passed to the function provided in pFunction +//----------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXFillTexture( + LPDIRECT3DTEXTURE8 pTexture, + LPD3DXFILL2D pFunction, + LPVOID pData); + +HRESULT WINAPI + D3DXFillCubeTexture( + LPDIRECT3DCUBETEXTURE8 pCubeTexture, + LPD3DXFILL3D pFunction, + LPVOID pData); + +HRESULT WINAPI + D3DXFillVolumeTexture( + LPDIRECT3DVOLUMETEXTURE8 pVolumeTexture, + LPD3DXFILL3D pFunction, + LPVOID pData); + + + +//---------------------------------------------------------------------------- +// D3DXComputeNormalMap: +// --------------------- +// Converts a height map into a normal map. The (x,y,z) components of each +// normal are mapped to the (r,g,b) channels of the output texture. +// +// Parameters +// pTexture +// Pointer to the destination texture +// pSrcTexture +// Pointer to the source heightmap texture +// pSrcPalette +// Source palette of 256 colors, or NULL +// Flags +// D3DX_NORMALMAP flags +// Channel +// D3DX_CHANNEL specifying source of height information +// Amplitude +// The constant value which the height information is multiplied by. +//--------------------------------------------------------------------------- + +HRESULT WINAPI + D3DXComputeNormalMap( + LPDIRECT3DTEXTURE8 pTexture, + LPDIRECT3DTEXTURE8 pSrcTexture, + CONST PALETTEENTRY* pSrcPalette, + DWORD Flags, + DWORD Channel, + FLOAT Amplitude); + + + + +#ifdef __cplusplus +} +#endif //__cplusplus + +#endif //__D3DX8TEX_H__ diff --git a/gfx/include/d3d9/d3dx9anim.h b/gfx/include/d3d9/d3dx9anim.h index ecdabdc52c..0d0a945344 100644 --- a/gfx/include/d3d9/d3dx9anim.h +++ b/gfx/include/d3d9/d3dx9anim.h @@ -10,19 +10,19 @@ #define __D3DX9ANIM_H__ /* {698CFB3F-9289-4d95-9A57-33A94B5A65F9} */ -DEFINE_GUID(IID_ID3DXAnimationSet, +DEFINE_GUID(IID_ID3DXAnimationSet, 0x698cfb3f, 0x9289, 0x4d95, 0x9a, 0x57, 0x33, 0xa9, 0x4b, 0x5a, 0x65, 0xf9); /* {FA4E8E3A-9786-407d-8B4C-5995893764AF} */ -DEFINE_GUID(IID_ID3DXKeyframedAnimationSet, +DEFINE_GUID(IID_ID3DXKeyframedAnimationSet, 0xfa4e8e3a, 0x9786, 0x407d, 0x8b, 0x4c, 0x59, 0x95, 0x89, 0x37, 0x64, 0xaf); /* {6CC2480D-3808-4739-9F88-DE49FACD8D4C} */ -DEFINE_GUID(IID_ID3DXCompressedAnimationSet, +DEFINE_GUID(IID_ID3DXCompressedAnimationSet, 0x6cc2480d, 0x3808, 0x4739, 0x9f, 0x88, 0xde, 0x49, 0xfa, 0xcd, 0x8d, 0x4c); /* {AC8948EC-F86D-43e2-96DE-31FC35F96D9E} */ -DEFINE_GUID(IID_ID3DXAnimationController, +DEFINE_GUID(IID_ID3DXAnimationController, 0xac8948ec, 0xf86d, 0x43e2, 0x96, 0xde, 0x31, 0xfc, 0x35, 0xf9, 0x6d, 0x9e); typedef enum _D3DXMESHDATATYPE @@ -82,22 +82,22 @@ typedef interface ID3DXAllocateHierarchy *LPD3DXALLOCATEHIERARCHY; DECLARE_INTERFACE(ID3DXAllocateHierarchy) { - STDMETHOD(CreateFrame)(THIS_ LPCSTR Name, + STDMETHOD(CreateFrame)(THIS_ LPCSTR Name, LPD3DXFRAME *ppNewFrame) PURE; - STDMETHOD(CreateMeshContainer)(THIS_ - LPCSTR Name, - CONST D3DXMESHDATA *pMeshData, - CONST D3DXMATERIAL *pMaterials, - CONST D3DXEFFECTINSTANCE *pEffectInstances, - DWORD NumMaterials, - CONST DWORD *pAdjacency, - LPD3DXSKININFO pSkinInfo, + STDMETHOD(CreateMeshContainer)(THIS_ + LPCSTR Name, + CONST D3DXMESHDATA *pMeshData, + CONST D3DXMATERIAL *pMaterials, + CONST D3DXEFFECTINSTANCE *pEffectInstances, + DWORD NumMaterials, + CONST DWORD *pAdjacency, + LPD3DXSKININFO pSkinInfo, LPD3DXMESHCONTAINER *ppNewMeshContainer) PURE; - STDMETHOD(DestroyFrame)(THIS_ LPD3DXFRAME pFrameToFree) PURE; + STDMETHOD(DestroyFrame)(THIS_ LPD3DXFRAME pFrameToFree) PURE; - STDMETHOD(DestroyMeshContainer)(THIS_ LPD3DXMESHCONTAINER pMeshContainerToFree) PURE; + STDMETHOD(DestroyMeshContainer)(THIS_ LPD3DXMESHCONTAINER pMeshContainerToFree) PURE; }; typedef interface ID3DXLoadUserData ID3DXLoadUserData; @@ -109,12 +109,12 @@ typedef interface ID3DXLoadUserData *LPD3DXLOADUSERDATA; DECLARE_INTERFACE(ID3DXLoadUserData) { STDMETHOD(LoadTopLevelData)(LPD3DXFILEDATA pXofChildData) PURE; - - STDMETHOD(LoadFrameChildData)(LPD3DXFRAME pFrame, + + STDMETHOD(LoadFrameChildData)(LPD3DXFRAME pFrame, + LPD3DXFILEDATA pXofChildData) PURE; + + STDMETHOD(LoadMeshChildData)(LPD3DXMESHCONTAINER pMeshContainer, LPD3DXFILEDATA pXofChildData) PURE; - - STDMETHOD(LoadMeshChildData)(LPD3DXMESHCONTAINER pMeshContainer, - LPD3DXFILEDATA pXofChildData) PURE; }; typedef interface ID3DXSaveUserData ID3DXSaveUserData; @@ -125,22 +125,22 @@ typedef interface ID3DXSaveUserData *LPD3DXSAVEUSERDATA; DECLARE_INTERFACE(ID3DXSaveUserData) { - STDMETHOD(AddFrameChildData)(CONST D3DXFRAME *pFrame, - LPD3DXFILESAVEOBJECT pXofSave, + STDMETHOD(AddFrameChildData)(CONST D3DXFRAME *pFrame, + LPD3DXFILESAVEOBJECT pXofSave, LPD3DXFILESAVEDATA pXofFrameData) PURE; - - STDMETHOD(AddMeshChildData)(CONST D3DXMESHCONTAINER *pMeshContainer, - LPD3DXFILESAVEOBJECT pXofSave, + + STDMETHOD(AddMeshChildData)(CONST D3DXMESHCONTAINER *pMeshContainer, + LPD3DXFILESAVEOBJECT pXofSave, LPD3DXFILESAVEDATA pXofMeshData) PURE; - - /* NOTE: this is called once per Save. All top level objects should be added using the + + /* NOTE: this is called once per Save. All top level objects should be added using the * provided interface. One call adds objects before the frame hierarchy, the other after */ - STDMETHOD(AddTopLevelDataObjectsPre)(LPD3DXFILESAVEOBJECT pXofSave) PURE; - STDMETHOD(AddTopLevelDataObjectsPost)(LPD3DXFILESAVEOBJECT pXofSave) PURE; + STDMETHOD(AddTopLevelDataObjectsPre)(LPD3DXFILESAVEOBJECT pXofSave) PURE; + STDMETHOD(AddTopLevelDataObjectsPost)(LPD3DXFILESAVEOBJECT pXofSave) PURE; /* callbacks for the user to register and then save templates to the XFile */ - STDMETHOD(RegisterTemplates)(LPD3DXFILE pXFileApi) PURE; - STDMETHOD(SaveTemplates)(LPD3DXFILESAVEOBJECT pXofSave) PURE; + STDMETHOD(RegisterTemplates)(LPD3DXFILE pXFileApi) PURE; + STDMETHOD(SaveTemplates)(LPD3DXFILESAVEOBJECT pXofSave) PURE; }; typedef enum _D3DXCALLBACK_SEARCH_FLAGS @@ -177,7 +177,7 @@ DECLARE_INTERFACE_(ID3DXAnimationSet, IUnknown) STDMETHOD(GetAnimationIndexByName)(THIS_ LPCSTR pName, UINT *pIndex) PURE; /* SRT */ - STDMETHOD(GetSRT)(THIS_ + STDMETHOD(GetSRT)(THIS_ DOUBLE PeriodicPosition, /* Position mapped to period (use GetPeriodicPosition) */ UINT Animation, /* Animation index */ D3DXVECTOR3 *pScale, /* Returns the scale */ @@ -185,7 +185,7 @@ DECLARE_INTERFACE_(ID3DXAnimationSet, IUnknown) D3DXVECTOR3 *pTranslation) PURE; /* Returns the translation */ /* Callbacks */ - STDMETHOD(GetCallback)(THIS_ + STDMETHOD(GetCallback)(THIS_ DOUBLE Position, /* Position from which to find callbacks */ DWORD Flags, /* Callback search flags */ DOUBLE *pCallbackPosition, /* Returns the position of the callback */ @@ -252,7 +252,7 @@ DECLARE_INTERFACE_(ID3DXKeyframedAnimationSet, ID3DXAnimationSet) STDMETHOD(GetAnimationIndexByName)(THIS_ LPCSTR pName, UINT *pIndex) PURE; /* SRT */ - STDMETHOD(GetSRT)(THIS_ + STDMETHOD(GetSRT)(THIS_ DOUBLE PeriodicPosition, /* Position mapped to period (use GetPeriodicPosition) */ UINT Animation, /* Animation index */ D3DXVECTOR3 *pScale, /* Returns the scale */ @@ -260,7 +260,7 @@ DECLARE_INTERFACE_(ID3DXKeyframedAnimationSet, ID3DXAnimationSet) D3DXVECTOR3 *pTranslation) PURE; /* Returns the translation */ /* Callbacks */ - STDMETHOD(GetCallback)(THIS_ + STDMETHOD(GetCallback)(THIS_ DOUBLE Position, /* Position from which to find callbacks */ DWORD Flags, /* Callback search flags */ DOUBLE *pCallbackPosition, /* Returns the position of the callback */ @@ -300,7 +300,7 @@ DECLARE_INTERFACE_(ID3DXKeyframedAnimationSet, ID3DXAnimationSet) STDMETHOD(UnregisterTranslationKey)(THIS_ UINT Animation, UINT Key) PURE; /* One-time animaton SRT keyframe registration */ - STDMETHOD(RegisterAnimationSRTKeys)(THIS_ + STDMETHOD(RegisterAnimationSRTKeys)(THIS_ LPCSTR pName, /* Animation name */ UINT NumScaleKeys, /* Number of scale keys */ UINT NumRotationKeys, /* Number of rotation keys */ @@ -311,7 +311,7 @@ DECLARE_INTERFACE_(ID3DXKeyframedAnimationSet, ID3DXAnimationSet) DWORD *pAnimationIndex) PURE; /* Returns the animation index */ /* Compression */ - STDMETHOD(Compress)(THIS_ + STDMETHOD(Compress)(THIS_ DWORD Flags, /* Compression flags (use D3DXCOMPRESS_STRONG for better results) */ FLOAT Lossiness, /* Compression loss ratio in the [0, 1] range */ LPD3DXFRAME pHierarchy, /* Frame hierarchy (optional) */ @@ -352,7 +352,7 @@ DECLARE_INTERFACE_(ID3DXCompressedAnimationSet, ID3DXAnimationSet) STDMETHOD(GetAnimationIndexByName)(THIS_ LPCSTR pName, UINT *pIndex) PURE; /* SRT */ - STDMETHOD(GetSRT)(THIS_ + STDMETHOD(GetSRT)(THIS_ DOUBLE PeriodicPosition, /* Position mapped to period (use GetPeriodicPosition) */ UINT Animation, /* Animation index */ D3DXVECTOR3 *pScale, /* Returns the scale */ @@ -360,7 +360,7 @@ DECLARE_INTERFACE_(ID3DXCompressedAnimationSet, ID3DXAnimationSet) D3DXVECTOR3 *pTranslation) PURE; /* Returns the translation */ /* Callbacks */ - STDMETHOD(GetCallback)(THIS_ + STDMETHOD(GetCallback)(THIS_ DOUBLE Position, /* Position from which to find callbacks */ DWORD Flags, /* Callback search flags */ DOUBLE *pCallbackPosition, /* Returns the position of the callback */ @@ -441,7 +441,7 @@ typedef interface ID3DXAnimationCallbackHandler *LPD3DXANIMATIONCALLBACKHANDLER; DECLARE_INTERFACE(ID3DXAnimationCallbackHandler) { - STDMETHOD(HandleCallback)(THIS_ UINT Track, LPVOID pCallbackData) PURE; + STDMETHOD(HandleCallback)(THIS_ UINT Track, LPVOID pCallbackData) PURE; }; typedef interface ID3DXAnimationController ID3DXAnimationController; @@ -464,11 +464,11 @@ DECLARE_INTERFACE_(ID3DXAnimationController, IUnknown) STDMETHOD_(UINT, GetMaxNumEvents)(THIS) PURE; /* Animation output registration */ - STDMETHOD(RegisterAnimationOutput)(THIS_ - LPCSTR pName, - D3DXMATRIX *pMatrix, - D3DXVECTOR3 *pScale, - D3DXQUATERNION *pRotation, + STDMETHOD(RegisterAnimationOutput)(THIS_ + LPCSTR pName, + D3DXMATRIX *pMatrix, + D3DXVECTOR3 *pScale, + D3DXQUATERNION *pRotation, D3DXVECTOR3 *pTranslation) PURE; /* Animation set registration */ @@ -528,11 +528,11 @@ DECLARE_INTERFACE_(ID3DXAnimationController, IUnknown) STDMETHOD(GetEventDesc)(THIS_ D3DXEVENTHANDLE hEvent, LPD3DXEVENT_DESC pDesc) PURE; /* Cloning */ - STDMETHOD(CloneAnimationController)(THIS_ - UINT MaxNumAnimationOutputs, - UINT MaxNumAnimationSets, - UINT MaxNumTracks, - UINT MaxNumEvents, + STDMETHOD(CloneAnimationController)(THIS_ + UINT MaxNumAnimationOutputs, + UINT MaxNumAnimationSets, + UINT MaxNumTracks, + UINT MaxNumEvents, LPD3DXANIMATIONCONTROLLER *ppAnimController) PURE; }; @@ -540,26 +540,26 @@ DECLARE_INTERFACE_(ID3DXAnimationController, IUnknown) extern "C" { #endif /* __cplusplus */ -HRESULT WINAPI +HRESULT WINAPI D3DXLoadMeshHierarchyFromXA ( LPCSTR Filename, DWORD MeshOptions, LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXALLOCATEHIERARCHY pAlloc, - LPD3DXLOADUSERDATA pUserDataLoader, + LPD3DXLOADUSERDATA pUserDataLoader, LPD3DXFRAME *ppFrameHierarchy, LPD3DXANIMATIONCONTROLLER *ppAnimController ); -HRESULT WINAPI +HRESULT WINAPI D3DXLoadMeshHierarchyFromXW ( LPCWSTR Filename, DWORD MeshOptions, LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXALLOCATEHIERARCHY pAlloc, - LPD3DXLOADUSERDATA pUserDataLoader, + LPD3DXLOADUSERDATA pUserDataLoader, LPD3DXFRAME *ppFrameHierarchy, LPD3DXANIMATIONCONTROLLER *ppAnimController ); @@ -570,7 +570,7 @@ D3DXLoadMeshHierarchyFromXW #define D3DXLoadMeshHierarchyFromX D3DXLoadMeshHierarchyFromXA #endif -HRESULT WINAPI +HRESULT WINAPI D3DXLoadMeshHierarchyFromXInMemory ( LPCVOID Memory, @@ -578,27 +578,27 @@ D3DXLoadMeshHierarchyFromXInMemory DWORD MeshOptions, LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXALLOCATEHIERARCHY pAlloc, - LPD3DXLOADUSERDATA pUserDataLoader, + LPD3DXLOADUSERDATA pUserDataLoader, LPD3DXFRAME *ppFrameHierarchy, LPD3DXANIMATIONCONTROLLER *ppAnimController ); -HRESULT WINAPI +HRESULT WINAPI D3DXSaveMeshHierarchyToFileA ( LPCSTR Filename, DWORD XFormat, - CONST D3DXFRAME *pFrameRoot, + CONST D3DXFRAME *pFrameRoot, LPD3DXANIMATIONCONTROLLER pAnimcontroller, LPD3DXSAVEUSERDATA pUserDataSaver ); -HRESULT WINAPI +HRESULT WINAPI D3DXSaveMeshHierarchyToFileW ( LPCWSTR Filename, DWORD XFormat, - CONST D3DXFRAME *pFrameRoot, + CONST D3DXFRAME *pFrameRoot, LPD3DXANIMATIONCONTROLLER pAnimController, LPD3DXSAVEUSERDATA pUserDataSaver ); @@ -616,14 +616,14 @@ D3DXFrameDestroy LPD3DXALLOCATEHIERARCHY pAlloc ); -HRESULT WINAPI +HRESULT WINAPI D3DXFrameAppendChild ( LPD3DXFRAME pFrameParent, CONST D3DXFRAME *pFrameChild ); -LPD3DXFRAME WINAPI +LPD3DXFRAME WINAPI D3DXFrameFind ( CONST D3DXFRAME *pFrameRoot, @@ -640,7 +640,7 @@ D3DXFrameRegisterNamedMatrices /* * D3DXFrameNumNamedMatrices: * -------------------------- - * Counts number of frames in a subtree that have non-null names + * Counts number of frames in a subtree that have non-null names * * Parameters: * pFrameRoot @@ -672,9 +672,9 @@ D3DXFrameNumNamedMatrices HRESULT WINAPI D3DXFrameCalculateBoundingSphere ( - CONST D3DXFRAME *pFrameRoot, - LPD3DXVECTOR3 pObjectCenter, - FLOAT *pObjectRadius + CONST D3DXFRAME *pFrameRoot, + LPD3DXVECTOR3 pObjectCenter, + FLOAT *pObjectRadius ); @@ -682,7 +682,7 @@ D3DXFrameCalculateBoundingSphere * D3DXCreateKeyframedAnimationSet: * -------------------------------- * This function creates a compressable keyframed animations set interface. - * + * * Parameters: * pName * Name of the animation set @@ -698,28 +698,28 @@ D3DXFrameCalculateBoundingSphere * Array of callback keys * ppAnimationSet * Returns the animation set interface - * + * */ HRESULT WINAPI D3DXCreateKeyframedAnimationSet ( - LPCSTR pName, + LPCSTR pName, DOUBLE TicksPerSecond, D3DXPLAYBACK_TYPE Playback, - UINT NumAnimations, - UINT NumCallbackKeys, - CONST D3DXKEY_CALLBACK *pCallbackKeys, - LPD3DXKEYFRAMEDANIMATIONSET *ppAnimationSet + UINT NumAnimations, + UINT NumCallbackKeys, + CONST D3DXKEY_CALLBACK *pCallbackKeys, + LPD3DXKEYFRAMEDANIMATIONSET *ppAnimationSet ); /* * D3DXCreateCompressedAnimationSet: * -------------------------------- - * This function creates a compressed animations set interface from + * This function creates a compressed animations set interface from * compressed data. - * + * * Parameters: * pName * Name of the animation set @@ -735,28 +735,28 @@ D3DXCreateKeyframedAnimationSet * Array of callback keys * ppAnimationSet * Returns the animation set interface - * + * */ HRESULT WINAPI D3DXCreateCompressedAnimationSet ( - LPCSTR pName, + LPCSTR pName, DOUBLE TicksPerSecond, D3DXPLAYBACK_TYPE Playback, - LPD3DXBUFFER pCompressedData, - UINT NumCallbackKeys, - CONST D3DXKEY_CALLBACK *pCallbackKeys, - LPD3DXCOMPRESSEDANIMATIONSET *ppAnimationSet + LPD3DXBUFFER pCompressedData, + UINT NumCallbackKeys, + CONST D3DXKEY_CALLBACK *pCallbackKeys, + LPD3DXCOMPRESSEDANIMATIONSET *ppAnimationSet ); HRESULT WINAPI D3DXCreateAnimationController ( - UINT MaxNumMatrices, - UINT MaxNumAnimationSets, - UINT MaxNumTracks, - UINT MaxNumEvents, + UINT MaxNumMatrices, + UINT MaxNumAnimationSets, + UINT MaxNumTracks, + UINT MaxNumEvents, LPD3DXANIMATIONCONTROLLER *ppAnimController ); diff --git a/gfx/include/d3d9/d3dx9core.h b/gfx/include/d3d9/d3dx9core.h index c3df8ce5c3..e3e10bd37e 100644 --- a/gfx/include/d3d9/d3dx9core.h +++ b/gfx/include/d3d9/d3dx9core.h @@ -24,7 +24,7 @@ BOOL WINAPI D3DXCheckVersion(UINT D3DSdkVersion, UINT D3DXSdkVersion); BOOL WINAPI - D3DXDebugMute(BOOL Mute); + D3DXDebugMute(BOOL Mute); UINT WINAPI D3DXGetDriverLevel(LPDIRECT3DDEVICE9 pDevice); @@ -37,7 +37,7 @@ typedef interface ID3DXBuffer ID3DXBuffer; typedef interface ID3DXBuffer *LPD3DXBUFFER; // {8BA5FB08-5195-40e2-AC58-0D989C3A0102} -DEFINE_GUID(IID_ID3DXBuffer, +DEFINE_GUID(IID_ID3DXBuffer, 0x8ba5fb08, 0x5195, 0x40e2, 0xac, 0x58, 0xd, 0x98, 0x9c, 0x3a, 0x1, 0x2); #undef INTERFACE @@ -70,7 +70,7 @@ typedef interface ID3DXSprite *LPD3DXSPRITE; // {BA0B762D-7D28-43ec-B9DC-2F84443B0614} -DEFINE_GUID(IID_ID3DXSprite, +DEFINE_GUID(IID_ID3DXSprite, 0xba0b762d, 0x7d28, 0x43ec, 0xb9, 0xdc, 0x2f, 0x84, 0x44, 0x3b, 0x6, 0x14); @@ -107,9 +107,9 @@ DECLARE_INTERFACE_(ID3DXSprite, IUnknown) extern "C" { #endif //__cplusplus -HRESULT WINAPI - D3DXCreateSprite( - LPDIRECT3DDEVICE9 pDevice, +HRESULT WINAPI + D3DXCreateSprite( + LPDIRECT3DDEVICE9 pDevice, LPD3DXSPRITE* ppSprite); #ifdef __cplusplus @@ -160,7 +160,7 @@ typedef interface ID3DXFont *LPD3DXFONT; // {D79DBB70-5F21-4d36-BBC2-FF525C213CDC} -DEFINE_GUID(IID_ID3DXFont, +DEFINE_GUID(IID_ID3DXFont, 0xd79dbb70, 0x5f21, 0x4d36, 0xbb, 0xc2, 0xff, 0x52, 0x5c, 0x21, 0x3c, 0xdc); @@ -228,9 +228,9 @@ extern "C" { #endif //__cplusplus -HRESULT WINAPI +HRESULT WINAPI D3DXCreateFontA( - LPDIRECT3DDEVICE9 pDevice, + LPDIRECT3DDEVICE9 pDevice, INT Height, UINT Width, UINT Weight, @@ -243,9 +243,9 @@ HRESULT WINAPI LPCSTR pFaceName, LPD3DXFONT* ppFont); -HRESULT WINAPI +HRESULT WINAPI D3DXCreateFontW( - LPDIRECT3DDEVICE9 pDevice, + LPDIRECT3DDEVICE9 pDevice, INT Height, UINT Width, UINT Weight, @@ -265,16 +265,16 @@ HRESULT WINAPI #endif -HRESULT WINAPI - D3DXCreateFontIndirectA( - LPDIRECT3DDEVICE9 pDevice, - CONST D3DXFONT_DESCA* pDesc, +HRESULT WINAPI + D3DXCreateFontIndirectA( + LPDIRECT3DDEVICE9 pDevice, + CONST D3DXFONT_DESCA* pDesc, LPD3DXFONT* ppFont); -HRESULT WINAPI - D3DXCreateFontIndirectW( - LPDIRECT3DDEVICE9 pDevice, - CONST D3DXFONT_DESCW* pDesc, +HRESULT WINAPI + D3DXCreateFontIndirectW( + LPDIRECT3DDEVICE9 pDevice, + CONST D3DXFONT_DESCW* pDesc, LPD3DXFONT* ppFont); #ifdef UNICODE @@ -304,7 +304,7 @@ typedef interface ID3DXRenderToSurface *LPD3DXRENDERTOSURFACE; // {6985F346-2C3D-43b3-BE8B-DAAE8A03D894} -DEFINE_GUID(IID_ID3DXRenderToSurface, +DEFINE_GUID(IID_ID3DXRenderToSurface, 0x6985f346, 0x2c3d, 0x43b3, 0xbe, 0x8b, 0xda, 0xae, 0x8a, 0x3, 0xd8, 0x94); @@ -364,7 +364,7 @@ typedef interface ID3DXRenderToEnvMap *LPD3DXRenderToEnvMap; // {313F1B4B-C7B0-4fa2-9D9D-8D380B64385E} -DEFINE_GUID(IID_ID3DXRenderToEnvMap, +DEFINE_GUID(IID_ID3DXRenderToEnvMap, 0x313f1b4b, 0xc7b0, 0x4fa2, 0x9d, 0x9d, 0x8d, 0x38, 0xb, 0x64, 0x38, 0x5e); @@ -382,17 +382,17 @@ DECLARE_INTERFACE_(ID3DXRenderToEnvMap, IUnknown) STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9* ppDevice) PURE; STDMETHOD(GetDesc)(THIS_ D3DXRTE_DESC* pDesc) PURE; - STDMETHOD(BeginCube)(THIS_ + STDMETHOD(BeginCube)(THIS_ LPDIRECT3DCUBETEXTURE9 pCubeTex) PURE; STDMETHOD(BeginSphere)(THIS_ LPDIRECT3DTEXTURE9 pTex) PURE; - STDMETHOD(BeginHemisphere)(THIS_ + STDMETHOD(BeginHemisphere)(THIS_ LPDIRECT3DTEXTURE9 pTexZPos, LPDIRECT3DTEXTURE9 pTexZNeg) PURE; - STDMETHOD(BeginParabolic)(THIS_ + STDMETHOD(BeginParabolic)(THIS_ LPDIRECT3DTEXTURE9 pTexZPos, LPDIRECT3DTEXTURE9 pTexZNeg) PURE; @@ -427,7 +427,7 @@ typedef interface ID3DXLine *LPD3DXLINE; // {D379BA7F-9042-4ac4-9F5E-58192A4C6BD8} -DEFINE_GUID(IID_ID3DXLine, +DEFINE_GUID(IID_ID3DXLine, 0xd379ba7f, 0x9042, 0x4ac4, 0x9f, 0x5e, 0x58, 0x19, 0x2a, 0x4c, 0x6b, 0xd8); #undef INTERFACE @@ -449,7 +449,7 @@ DECLARE_INTERFACE_(ID3DXLine, IUnknown) DWORD dwVertexListCount, D3DCOLOR Color) PURE; STDMETHOD(DrawTransform)(THIS_ CONST D3DXVECTOR3 *pVertexList, - DWORD dwVertexListCount, CONST D3DXMATRIX* pTransform, + DWORD dwVertexListCount, CONST D3DXMATRIX* pTransform, D3DCOLOR Color) PURE; STDMETHOD(SetPattern)(THIS_ DWORD dwPattern) PURE; diff --git a/gfx/include/d3d9/d3dx9effect.h b/gfx/include/d3d9/d3dx9effect.h index 4fbb3f75aa..3947c7a91b 100644 --- a/gfx/include/d3d9/d3dx9effect.h +++ b/gfx/include/d3d9/d3dx9effect.h @@ -108,7 +108,7 @@ typedef interface ID3DXEffectPool ID3DXEffectPool; typedef interface ID3DXEffectPool *LPD3DXEFFECTPOOL; // {9537AB04-3250-412e-8213-FCD2F8677933} -DEFINE_GUID(IID_ID3DXEffectPool, +DEFINE_GUID(IID_ID3DXEffectPool, 0x9537ab04, 0x3250, 0x412e, 0x82, 0x13, 0xfc, 0xd2, 0xf8, 0x67, 0x79, 0x33); @@ -134,7 +134,7 @@ typedef interface ID3DXBaseEffect ID3DXBaseEffect; typedef interface ID3DXBaseEffect *LPD3DXBASEEFFECT; // {017C18AC-103F-4417-8C51-6BF6EF1E56BE} -DEFINE_GUID(IID_ID3DXBaseEffect, +DEFINE_GUID(IID_ID3DXBaseEffect, 0x17c18ac, 0x103f, 0x4417, 0x8c, 0x51, 0x6b, 0xf6, 0xef, 0x1e, 0x56, 0xbe); @@ -209,7 +209,7 @@ DECLARE_INTERFACE_(ID3DXBaseEffect, IUnknown) //Set Range of an Array to pass to device //Useful for sending only a subrange of an array down to the device - STDMETHOD(SetArrayRange)(THIS_ D3DXHANDLE hParameter, UINT uStart, UINT uEnd) PURE; + STDMETHOD(SetArrayRange)(THIS_ D3DXHANDLE hParameter, UINT uStart, UINT uEnd) PURE; }; @@ -217,7 +217,7 @@ DECLARE_INTERFACE_(ID3DXBaseEffect, IUnknown) //---------------------------------------------------------------------------- // ID3DXEffectStateManager: // ------------------------ -// This is a user implemented interface that can be used to manage device +// This is a user implemented interface that can be used to manage device // state changes made by an Effect. //---------------------------------------------------------------------------- @@ -225,7 +225,7 @@ typedef interface ID3DXEffectStateManager ID3DXEffectStateManager; typedef interface ID3DXEffectStateManager *LPD3DXEFFECTSTATEMANAGER; // {79AAB587-6DBC-4fa7-82DE-37FA1781C5CE} -DEFINE_GUID(IID_ID3DXEffectStateManager, +DEFINE_GUID(IID_ID3DXEffectStateManager, 0x79aab587, 0x6dbc, 0x4fa7, 0x82, 0xde, 0x37, 0xfa, 0x17, 0x81, 0xc5, 0xce); #undef INTERFACE @@ -240,11 +240,11 @@ DECLARE_INTERFACE_(ID3DXEffectStateManager, IUnknown) STDMETHOD_(ULONG, AddRef)(THIS) PURE; STDMETHOD_(ULONG, Release)(THIS) PURE; - // The following methods are called by the Effect when it wants to make + // The following methods are called by the Effect when it wants to make // the corresponding device call. Note that: - // 1. Users manage the state and are therefore responsible for making the - // the corresponding device calls themselves inside their callbacks. - // 2. Effects pay attention to the return values of the callbacks, and so + // 1. Users manage the state and are therefore responsible for making the + // the corresponding device calls themselves inside their callbacks. + // 2. Effects pay attention to the return values of the callbacks, and so // users must pay attention to what they return in their callbacks. STDMETHOD(SetTransform)(THIS_ D3DTRANSFORMSTATETYPE State, CONST D3DMATRIX *pMatrix) PURE; @@ -276,7 +276,7 @@ typedef interface ID3DXEffect ID3DXEffect; typedef interface ID3DXEffect *LPD3DXEFFECT; // {F6CEB4B3-4E4C-40dd-B883-8D8DE5EA0CD5} -DEFINE_GUID(IID_ID3DXEffect, +DEFINE_GUID(IID_ID3DXEffect, 0xf6ceb4b3, 0x4e4c, 0x40dd, 0xb8, 0x83, 0x8d, 0x8d, 0xe5, 0xea, 0xc, 0xd5); #undef INTERFACE @@ -350,10 +350,10 @@ DECLARE_INTERFACE_(ID3DXEffect, ID3DXBaseEffect) //Set Range of an Array to pass to device //Usefull for sending only a subrange of an array down to the device - STDMETHOD(SetArrayRange)(THIS_ D3DXHANDLE hParameter, UINT uStart, UINT uEnd) PURE; + STDMETHOD(SetArrayRange)(THIS_ D3DXHANDLE hParameter, UINT uStart, UINT uEnd) PURE; // ID3DXBaseEffect - - + + // Pool STDMETHOD(GetPool)(THIS_ LPD3DXEFFECTPOOL* ppPool) PURE; @@ -394,7 +394,7 @@ DECLARE_INTERFACE_(ID3DXEffect, ID3DXBaseEffect) // Cloning STDMETHOD(CloneEffect)(THIS_ LPDIRECT3DDEVICE9 pDevice, LPD3DXEFFECT* ppEffect) PURE; - + // Fast path for setting variables directly in ID3DXEffect STDMETHOD(SetRawValue)(THIS_ D3DXHANDLE hParameter, LPCVOID pData, UINT ByteOffset, UINT Bytes) PURE; }; @@ -407,7 +407,7 @@ typedef interface ID3DXEffectCompiler ID3DXEffectCompiler; typedef interface ID3DXEffectCompiler *LPD3DXEFFECTCOMPILER; // {51B8A949-1A31-47e6-BEA0-4B30DB53F1E0} -DEFINE_GUID(IID_ID3DXEffectCompiler, +DEFINE_GUID(IID_ID3DXEffectCompiler, 0x51b8a949, 0x1a31, 0x47e6, 0xbe, 0xa0, 0x4b, 0x30, 0xdb, 0x53, 0xf1, 0xe0); @@ -479,10 +479,10 @@ DECLARE_INTERFACE_(ID3DXEffectCompiler, ID3DXBaseEffect) STDMETHOD(GetTexture)(THIS_ D3DXHANDLE hParameter, LPDIRECT3DBASETEXTURE9 *ppTexture) PURE; STDMETHOD(GetPixelShader)(THIS_ D3DXHANDLE hParameter, LPDIRECT3DPIXELSHADER9 *ppPShader) PURE; STDMETHOD(GetVertexShader)(THIS_ D3DXHANDLE hParameter, LPDIRECT3DVERTEXSHADER9 *ppVShader) PURE; - + //Set Range of an Array to pass to device //Usefull for sending only a subrange of an array down to the device - STDMETHOD(SetArrayRange)(THIS_ D3DXHANDLE hParameter, UINT uStart, UINT uEnd) PURE; + STDMETHOD(SetArrayRange)(THIS_ D3DXHANDLE hParameter, UINT uStart, UINT uEnd) PURE; // ID3DXBaseEffect // Parameter sharing, specialization, and information @@ -588,7 +588,7 @@ HRESULT WINAPI LPCSTR pSrcFile, CONST D3DXMACRO* pDefines, LPD3DXINCLUDE pInclude, - LPCSTR pSkipConstants, + LPCSTR pSkipConstants, DWORD Flags, LPD3DXEFFECTPOOL pPool, LPD3DXEFFECT* ppEffect, @@ -600,7 +600,7 @@ HRESULT WINAPI LPCWSTR pSrcFile, CONST D3DXMACRO* pDefines, LPD3DXINCLUDE pInclude, - LPCSTR pSkipConstants, + LPCSTR pSkipConstants, DWORD Flags, LPD3DXEFFECTPOOL pPool, LPD3DXEFFECT* ppEffect, @@ -620,7 +620,7 @@ HRESULT WINAPI LPCSTR pSrcResource, CONST D3DXMACRO* pDefines, LPD3DXINCLUDE pInclude, - LPCSTR pSkipConstants, + LPCSTR pSkipConstants, DWORD Flags, LPD3DXEFFECTPOOL pPool, LPD3DXEFFECT* ppEffect, @@ -633,7 +633,7 @@ HRESULT WINAPI LPCWSTR pSrcResource, CONST D3DXMACRO* pDefines, LPD3DXINCLUDE pInclude, - LPCSTR pSkipConstants, + LPCSTR pSkipConstants, DWORD Flags, LPD3DXEFFECTPOOL pPool, LPD3DXEFFECT* ppEffect, @@ -653,7 +653,7 @@ HRESULT WINAPI UINT SrcDataLen, CONST D3DXMACRO* pDefines, LPD3DXINCLUDE pInclude, - LPCSTR pSkipConstants, + LPCSTR pSkipConstants, DWORD Flags, LPD3DXEFFECTPOOL pPool, LPD3DXEFFECT* ppEffect, @@ -721,10 +721,10 @@ HRESULT WINAPI LPD3DXEFFECTCOMPILER* ppCompiler, LPD3DXBUFFER* ppParseErrors); -HRESULT WINAPI +HRESULT WINAPI D3DXDisassembleEffect( - LPD3DXEFFECT pEffect, - BOOL EnableColorCode, + LPD3DXEFFECT pEffect, + BOOL EnableColorCode, LPD3DXBUFFER *ppDisassembly); #ifdef __cplusplus diff --git a/gfx/include/d3d9/d3dx9math.h b/gfx/include/d3d9/d3dx9math.h index 165014b0df..f861629e0d 100644 --- a/gfx/include/d3d9/d3dx9math.h +++ b/gfx/include/d3d9/d3dx9math.h @@ -362,7 +362,7 @@ typedef struct _D3DMATRIX D3DXMATRIX, *LPD3DXMATRIX; * This class helps keep matrices 16-byte aligned as preferred by P4 cpus. * It aligns matrices on the stack and on the heap or in global scope. * It does this using __declspec(align(16)) which works on VC7 and on VC 6 - * with the processor pack. Unfortunately there is no way to detect the + * with the processor pack. Unfortunately there is no way to detect the * latter so this is turned on only on VC7. On other compilers this is the * the same as D3DXMATRIX. * @@ -392,7 +392,7 @@ typedef struct _D3DXMATRIXA16 : public D3DXMATRIX /* delete operators */ void operator delete ( void* ); /* These are NOT virtual; Do not */ void operator delete[] ( void* ); /* cast to D3DXMATRIX and delete. */ - + /* assignment operators */ _D3DXMATRIXA16& operator = ( CONST D3DXMATRIX& ); @@ -662,7 +662,7 @@ D3DXVECTOR2* WINAPI D3DXVec2TransformCoord // Transform (x, y, 0, 0) by matrix. D3DXVECTOR2* WINAPI D3DXVec2TransformNormal ( D3DXVECTOR2 *pOut, CONST D3DXVECTOR2 *pV, CONST D3DXMATRIX *pM ); - + // Transform Array (x, y, 0, 1) by matrix. D3DXVECTOR4* WINAPI D3DXVec2TransformArray ( D3DXVECTOR4 *pOut, UINT OutStride, CONST D3DXVECTOR2 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n); @@ -674,8 +674,8 @@ D3DXVECTOR2* WINAPI D3DXVec2TransformCoordArray // Transform Array (x, y, 0, 0) by matrix. D3DXVECTOR2* WINAPI D3DXVec2TransformNormalArray ( D3DXVECTOR2 *pOut, UINT OutStride, CONST D3DXVECTOR2 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n ); - - + + #ifdef __cplusplus } @@ -754,14 +754,14 @@ D3DXVECTOR4* WINAPI D3DXVec3Transform D3DXVECTOR3* WINAPI D3DXVec3TransformCoord ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM ); -// Transform (x, y, z, 0) by matrix. If you transforming a normal by a -// non-affine matrix, the matrix you pass to this function should be the +// Transform (x, y, z, 0) by matrix. If you transforming a normal by a +// non-affine matrix, the matrix you pass to this function should be the // transpose of the inverse of the matrix you would use to transform a coord. D3DXVECTOR3* WINAPI D3DXVec3TransformNormal ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DXMATRIX *pM ); - - -// Transform Array (x, y, z, 1) by matrix. + + +// Transform Array (x, y, z, 1) by matrix. D3DXVECTOR4* WINAPI D3DXVec3TransformArray ( D3DXVECTOR4 *pOut, UINT OutStride, CONST D3DXVECTOR3 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n ); @@ -769,8 +769,8 @@ D3DXVECTOR4* WINAPI D3DXVec3TransformArray D3DXVECTOR3* WINAPI D3DXVec3TransformCoordArray ( D3DXVECTOR3 *pOut, UINT OutStride, CONST D3DXVECTOR3 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n ); -// Transform (x, y, z, 0) by matrix. If you transforming a normal by a -// non-affine matrix, the matrix you pass to this function should be the +// Transform (x, y, z, 0) by matrix. If you transforming a normal by a +// non-affine matrix, the matrix you pass to this function should be the // transpose of the inverse of the matrix you would use to transform a coord. D3DXVECTOR3* WINAPI D3DXVec3TransformNormalArray ( D3DXVECTOR3 *pOut, UINT OutStride, CONST D3DXVECTOR3 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n ); @@ -784,7 +784,7 @@ D3DXVECTOR3* WINAPI D3DXVec3Project D3DXVECTOR3* WINAPI D3DXVec3Unproject ( D3DXVECTOR3 *pOut, CONST D3DXVECTOR3 *pV, CONST D3DVIEWPORT9 *pViewport, CONST D3DXMATRIX *pProjection, CONST D3DXMATRIX *pView, CONST D3DXMATRIX *pWorld); - + // Project vector Array from object space into screen space D3DXVECTOR3* WINAPI D3DXVec3ProjectArray ( D3DXVECTOR3 *pOut, UINT OutStride,CONST D3DXVECTOR3 *pV, UINT VStride,CONST D3DVIEWPORT9 *pViewport, @@ -871,7 +871,7 @@ D3DXVECTOR4* WINAPI D3DXVec4BaryCentric // Transform vector by matrix. D3DXVECTOR4* WINAPI D3DXVec4Transform ( D3DXVECTOR4 *pOut, CONST D3DXVECTOR4 *pV, CONST D3DXMATRIX *pM ); - + // Transform vector array by matrix. D3DXVECTOR4* WINAPI D3DXVec4TransformArray ( D3DXVECTOR4 *pOut, UINT OutStride, CONST D3DXVECTOR4 *pV, UINT VStride, CONST D3DXMATRIX *pM, UINT n ); @@ -903,7 +903,7 @@ FLOAT WINAPI D3DXMatrixDeterminant ( CONST D3DXMATRIX *pM ); HRESULT WINAPI D3DXMatrixDecompose - ( D3DXVECTOR3 *pOutScale, D3DXQUATERNION *pOutRotation, + ( D3DXVECTOR3 *pOutScale, D3DXQUATERNION *pOutRotation, D3DXVECTOR3 *pOutTranslation, CONST D3DXMATRIX *pM ); D3DXMATRIX* WINAPI D3DXMatrixTranspose @@ -968,9 +968,9 @@ D3DXMATRIX* WINAPI D3DXMatrixTransformation // Build 2D transformation matrix in XY plane. NULL arguments are treated as identity. // Mout = Msc-1 * Msr-1 * Ms * Msr * Msc * Mrc-1 * Mr * Mrc * Mt D3DXMATRIX* WINAPI D3DXMatrixTransformation2D - ( D3DXMATRIX *pOut, CONST D3DXVECTOR2* pScalingCenter, - FLOAT ScalingRotation, CONST D3DXVECTOR2* pScaling, - CONST D3DXVECTOR2* pRotationCenter, FLOAT Rotation, + ( D3DXMATRIX *pOut, CONST D3DXVECTOR2* pScalingCenter, + FLOAT ScalingRotation, CONST D3DXVECTOR2* pScaling, + CONST D3DXVECTOR2* pRotationCenter, FLOAT Rotation, CONST D3DXVECTOR2* pTranslation); // Build affine transformation matrix. NULL arguments are treated as identity. @@ -982,7 +982,7 @@ D3DXMATRIX* WINAPI D3DXMatrixAffineTransformation // Build 2D affine transformation matrix in XY plane. NULL arguments are treated as identity. // Mout = Ms * Mrc-1 * Mr * Mrc * Mt D3DXMATRIX* WINAPI D3DXMatrixAffineTransformation2D - ( D3DXMATRIX *pOut, FLOAT Scaling, CONST D3DXVECTOR2* pRotationCenter, + ( D3DXMATRIX *pOut, FLOAT Scaling, CONST D3DXVECTOR2* pRotationCenter, FLOAT Rotation, CONST D3DXVECTOR2* pTranslation); // Build a lookat matrix. (right-handed) @@ -1126,7 +1126,7 @@ D3DXQUATERNION* WINAPI D3DXQuaternionLn // if q = (0, theta * v); exp(q) = (cos(theta), sin(theta) * v) D3DXQUATERNION* WINAPI D3DXQuaternionExp ( D3DXQUATERNION *pOut, CONST D3DXQUATERNION *pQ ); - + // Spherical linear interpolation between Q1 (t == 0) and Q2 (t == 1). // Expects unit quaternions. D3DXQUATERNION* WINAPI D3DXQuaternionSlerp @@ -1141,11 +1141,11 @@ D3DXQUATERNION* WINAPI D3DXQuaternionSquad CONST D3DXQUATERNION *pC, FLOAT t ); // Setup control points for spherical quadrangle interpolation -// from Q1 to Q2. The control points are chosen in such a way +// from Q1 to Q2. The control points are chosen in such a way // to ensure the continuity of tangents with adjacent segments. void WINAPI D3DXQuaternionSquadSetup ( D3DXQUATERNION *pAOut, D3DXQUATERNION *pBOut, D3DXQUATERNION *pCOut, - CONST D3DXQUATERNION *pQ0, CONST D3DXQUATERNION *pQ1, + CONST D3DXQUATERNION *pQ0, CONST D3DXQUATERNION *pQ1, CONST D3DXQUATERNION *pQ2, CONST D3DXQUATERNION *pQ3 ); // Barycentric interpolation. @@ -1209,7 +1209,7 @@ D3DXPLANE* WINAPI D3DXPlaneFromPoints // M should be the inverse transpose of the transformation desired. D3DXPLANE* WINAPI D3DXPlaneTransform ( D3DXPLANE *pOut, CONST D3DXPLANE *pP, CONST D3DXMATRIX *pM ); - + // Transform an array of planes by a matrix. The vectors (a,b,c) must be normal. // M should be the inverse transpose of the transformation desired. D3DXPLANE* WINAPI D3DXPlaneTransformArray @@ -1276,7 +1276,7 @@ extern "C" { // Calculate Fresnel term given the cosine of theta (likely obtained by // taking the dot of two normals), and the refraction index of the material. FLOAT WINAPI D3DXFresnelTerm - (FLOAT CosTheta, FLOAT RefractionIndex); + (FLOAT CosTheta, FLOAT RefractionIndex); #ifdef __cplusplus } @@ -1292,7 +1292,7 @@ typedef interface ID3DXMatrixStack ID3DXMatrixStack; typedef interface ID3DXMatrixStack *LPD3DXMATRIXSTACK; // {C7885BA7-F990-4fe7-922D-8515E477DD85} -DEFINE_GUID(IID_ID3DXMatrixStack, +DEFINE_GUID(IID_ID3DXMatrixStack, 0xc7885ba7, 0xf990, 0x4fe7, 0x92, 0x2d, 0x85, 0x15, 0xe4, 0x77, 0xdd, 0x85); @@ -1387,9 +1387,9 @@ DECLARE_INTERFACE_(ID3DXMatrixStack, IUnknown) extern "C" { #endif -HRESULT WINAPI - D3DXCreateMatrixStack( - DWORD Flags, +HRESULT WINAPI + D3DXCreateMatrixStack( + DWORD Flags, LPD3DXMATRIXSTACK* ppStack); #ifdef __cplusplus @@ -1402,7 +1402,7 @@ HRESULT WINAPI // // NOTE: // * Most of these functions can take the same object as in and out parameters. -// The exceptions are the rotation functions. +// The exceptions are the rotation functions. // // * Out parameters are typically also returned as return values, so that // the output of one function may be used as a parameter to another. @@ -1426,19 +1426,19 @@ extern "C" { FLOAT* WINAPI D3DXSHEvalDirection ( FLOAT *pOut, UINT Order, CONST D3DXVECTOR3 *pDir ); - + FLOAT* WINAPI D3DXSHRotate ( FLOAT *pOut, UINT Order, CONST D3DXMATRIX *pMatrix, CONST FLOAT *pIn ); - + FLOAT* WINAPI D3DXSHRotateZ ( FLOAT *pOut, UINT Order, FLOAT Angle, CONST FLOAT *pIn ); - + FLOAT* WINAPI D3DXSHAdd ( FLOAT *pOut, UINT Order, CONST FLOAT *pA, CONST FLOAT *pB ); FLOAT* WINAPI D3DXSHScale ( FLOAT *pOut, UINT Order, CONST FLOAT *pIn, CONST FLOAT Scale ); - + FLOAT WINAPI D3DXSHDot ( UINT Order, CONST FLOAT *pA, CONST FLOAT *pB ); @@ -1456,7 +1456,7 @@ FLOAT* WINAPI D3DXSHMultiply6( FLOAT *pOut, CONST FLOAT *pF, CONST FLOAT *pG); //============================================================================ HRESULT WINAPI D3DXSHEvalDirectionalLight - ( UINT Order, CONST D3DXVECTOR3 *pDir, + ( UINT Order, CONST D3DXVECTOR3 *pDir, FLOAT RIntensity, FLOAT GIntensity, FLOAT BIntensity, FLOAT *pROut, FLOAT *pGOut, FLOAT *pBOut ); @@ -1469,7 +1469,7 @@ HRESULT WINAPI D3DXSHEvalConeLight ( UINT Order, CONST D3DXVECTOR3 *pDir, FLOAT Radius, FLOAT RIntensity, FLOAT GIntensity, FLOAT BIntensity, FLOAT *pROut, FLOAT *pGOut, FLOAT *pBOut ); - + HRESULT WINAPI D3DXSHEvalHemisphereLight ( UINT Order, CONST D3DXVECTOR3 *pDir, D3DXCOLOR Top, D3DXCOLOR Bottom, FLOAT *pROut, FLOAT *pGOut, FLOAT *pBOut ); @@ -1496,7 +1496,7 @@ HRESULT WINAPI D3DXSHEvalHemisphereLight // pGOut // Output SH vector for Green // pBOut -// Output SH vector for Blue +// Output SH vector for Blue // //============================================================================ diff --git a/gfx/include/d3d9/d3dx9mesh.h b/gfx/include/d3d9/d3dx9mesh.h index 6798c5898f..2418f7acdb 100644 --- a/gfx/include/d3d9/d3dx9mesh.h +++ b/gfx/include/d3d9/d3dx9mesh.h @@ -13,27 +13,27 @@ #define __D3DX9MESH_H__ // {7ED943DD-52E8-40b5-A8D8-76685C406330} -DEFINE_GUID(IID_ID3DXBaseMesh, +DEFINE_GUID(IID_ID3DXBaseMesh, 0x7ed943dd, 0x52e8, 0x40b5, 0xa8, 0xd8, 0x76, 0x68, 0x5c, 0x40, 0x63, 0x30); // {4020E5C2-1403-4929-883F-E2E849FAC195} -DEFINE_GUID(IID_ID3DXMesh, +DEFINE_GUID(IID_ID3DXMesh, 0x4020e5c2, 0x1403, 0x4929, 0x88, 0x3f, 0xe2, 0xe8, 0x49, 0xfa, 0xc1, 0x95); // {8875769A-D579-4088-AAEB-534D1AD84E96} -DEFINE_GUID(IID_ID3DXPMesh, +DEFINE_GUID(IID_ID3DXPMesh, 0x8875769a, 0xd579, 0x4088, 0xaa, 0xeb, 0x53, 0x4d, 0x1a, 0xd8, 0x4e, 0x96); // {667EA4C7-F1CD-4386-B523-7C0290B83CC5} -DEFINE_GUID(IID_ID3DXSPMesh, +DEFINE_GUID(IID_ID3DXSPMesh, 0x667ea4c7, 0xf1cd, 0x4386, 0xb5, 0x23, 0x7c, 0x2, 0x90, 0xb8, 0x3c, 0xc5); // {11EAA540-F9A6-4d49-AE6A-E19221F70CC4} -DEFINE_GUID(IID_ID3DXSkinInfo, +DEFINE_GUID(IID_ID3DXSkinInfo, 0x11eaa540, 0xf9a6, 0x4d49, 0xae, 0x6a, 0xe1, 0x92, 0x21, 0xf7, 0xc, 0xc4); // {3CE6CC22-DBF2-44f4-894D-F9C34A337139} -DEFINE_GUID(IID_ID3DXPatchMesh, +DEFINE_GUID(IID_ID3DXPatchMesh, 0x3ce6cc22, 0xdbf2, 0x44f4, 0x89, 0x4d, 0xf9, 0xc3, 0x4a, 0x33, 0x71, 0x39); //patch mesh can be quads or tris @@ -49,11 +49,11 @@ typedef enum _D3DXPATCHMESHTYPE { enum _D3DXMESH { D3DXMESH_32BIT = 0x001, // If set, then use 32 bit indices, if not set use 16 bit indices. D3DXMESH_DONOTCLIP = 0x002, // Use D3DUSAGE_DONOTCLIP for VB & IB. - D3DXMESH_POINTS = 0x004, // Use D3DUSAGE_POINTS for VB & IB. - D3DXMESH_RTPATCHES = 0x008, // Use D3DUSAGE_RTPATCHES for VB & IB. - D3DXMESH_NPATCHES = 0x4000,// Use D3DUSAGE_NPATCHES for VB & IB. + D3DXMESH_POINTS = 0x004, // Use D3DUSAGE_POINTS for VB & IB. + D3DXMESH_RTPATCHES = 0x008, // Use D3DUSAGE_RTPATCHES for VB & IB. + D3DXMESH_NPATCHES = 0x4000,// Use D3DUSAGE_NPATCHES for VB & IB. D3DXMESH_VB_SYSTEMMEM = 0x010, // Use D3DPOOL_SYSTEMMEM for VB. Overrides D3DXMESH_MANAGEDVERTEXBUFFER - D3DXMESH_VB_MANAGED = 0x020, // Use D3DPOOL_MANAGED for VB. + D3DXMESH_VB_MANAGED = 0x020, // Use D3DPOOL_MANAGED for VB. D3DXMESH_VB_WRITEONLY = 0x040, // Use D3DUSAGE_WRITEONLY for VB. D3DXMESH_VB_DYNAMIC = 0x080, // Use D3DUSAGE_DYNAMIC for VB. D3DXMESH_VB_SOFTWAREPROCESSING = 0x8000, // Use D3DUSAGE_SOFTWAREPROCESSING for VB. @@ -91,11 +91,11 @@ enum _D3DXMESHSIMP typedef enum _D3DXCLEANTYPE { D3DXCLEAN_BACKFACING = 0x00000001, D3DXCLEAN_BOWTIES = 0x00000002, - + // Helper options D3DXCLEAN_SKINNING = D3DXCLEAN_BACKFACING, // Bowtie cleaning modifies geometry and breaks skinning D3DXCLEAN_OPTIMIZATION = D3DXCLEAN_BACKFACING, - D3DXCLEAN_SIMPLIFICATION= D3DXCLEAN_BACKFACING | D3DXCLEAN_BOWTIES, + D3DXCLEAN_SIMPLIFICATION= D3DXCLEAN_BACKFACING | D3DXCLEAN_BOWTIES, } D3DXCLEANTYPE; enum _MAX_FVF_DECL_SIZE @@ -170,7 +170,7 @@ typedef D3DXMATERIAL *LPD3DXMATERIAL; typedef enum _D3DXEFFECTDEFAULTTYPE { - D3DXEDT_STRING = 0x1, // pValue points to a null terminated ASCII string + D3DXEDT_STRING = 0x1, // pValue points to a null terminated ASCII string D3DXEDT_FLOATS = 0x2, // pValue points to an array of floats - number of floats is NumBytes / sizeof(float) D3DXEDT_DWORD = 0x3, // pValue points to a DWORD @@ -208,7 +208,7 @@ enum _D3DXWELDEPSILONSFLAGS { D3DXWELDEPSILONS_WELDALL = 0x1, // weld all vertices marked by adjacency as being overlapping - D3DXWELDEPSILONS_WELDPARTIALMATCHES = 0x2, // if a given vertex component is within epsilon, modify partial matched + D3DXWELDEPSILONS_WELDPARTIALMATCHES = 0x2, // if a given vertex component is within epsilon, modify partial matched // vertices so that both components identical AND if all components "equal" // remove one of the vertices D3DXWELDEPSILONS_DONOTREMOVEVERTICES = 0x4, // instructs weld to only allow modifications to vertices and not removal @@ -258,9 +258,9 @@ DECLARE_INTERFACE_(ID3DXBaseMesh, IUnknown) STDMETHOD_(DWORD, GetNumBytesPerVertex)(THIS) PURE; STDMETHOD_(DWORD, GetOptions)(THIS) PURE; STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9* ppDevice) PURE; - STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options, + STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options, DWORD FVF, LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; - STDMETHOD(CloneMesh)(THIS_ DWORD Options, + STDMETHOD(CloneMesh)(THIS_ DWORD Options, CONST D3DVERTEXELEMENT9 *pDeclaration, LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; STDMETHOD(GetVertexBuffer)(THIS_ LPDIRECT3DVERTEXBUFFER9* ppVB) PURE; STDMETHOD(GetIndexBuffer)(THIS_ LPDIRECT3DINDEXBUFFER9* ppIB) PURE; @@ -298,9 +298,9 @@ DECLARE_INTERFACE_(ID3DXMesh, ID3DXBaseMesh) STDMETHOD_(DWORD, GetNumBytesPerVertex)(THIS) PURE; STDMETHOD_(DWORD, GetOptions)(THIS) PURE; STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9* ppDevice) PURE; - STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options, + STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options, DWORD FVF, LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; - STDMETHOD(CloneMesh)(THIS_ DWORD Options, + STDMETHOD(CloneMesh)(THIS_ DWORD Options, CONST D3DVERTEXELEMENT9 *pDeclaration, LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; STDMETHOD(GetVertexBuffer)(THIS_ LPDIRECT3DVERTEXBUFFER9* ppVB) PURE; STDMETHOD(GetIndexBuffer)(THIS_ LPDIRECT3DINDEXBUFFER9* ppIB) PURE; @@ -320,10 +320,10 @@ DECLARE_INTERFACE_(ID3DXMesh, ID3DXBaseMesh) // ID3DXMesh STDMETHOD(LockAttributeBuffer)(THIS_ DWORD Flags, DWORD** ppData) PURE; STDMETHOD(UnlockAttributeBuffer)(THIS) PURE; - STDMETHOD(Optimize)(THIS_ DWORD Flags, CONST DWORD* pAdjacencyIn, DWORD* pAdjacencyOut, - DWORD* pFaceRemap, LPD3DXBUFFER *ppVertexRemap, + STDMETHOD(Optimize)(THIS_ DWORD Flags, CONST DWORD* pAdjacencyIn, DWORD* pAdjacencyOut, + DWORD* pFaceRemap, LPD3DXBUFFER *ppVertexRemap, LPD3DXMESH* ppOptMesh) PURE; - STDMETHOD(OptimizeInplace)(THIS_ DWORD Flags, CONST DWORD* pAdjacencyIn, DWORD* pAdjacencyOut, + STDMETHOD(OptimizeInplace)(THIS_ DWORD Flags, CONST DWORD* pAdjacencyIn, DWORD* pAdjacencyOut, DWORD* pFaceRemap, LPD3DXBUFFER *ppVertexRemap) PURE; STDMETHOD(SetAttributeTable)(THIS_ CONST D3DXATTRIBUTERANGE *pAttribTable, DWORD cAttribTableSize) PURE; }; @@ -348,9 +348,9 @@ DECLARE_INTERFACE_(ID3DXPMesh, ID3DXBaseMesh) STDMETHOD_(DWORD, GetNumBytesPerVertex)(THIS) PURE; STDMETHOD_(DWORD, GetOptions)(THIS) PURE; STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9* ppDevice) PURE; - STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options, + STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options, DWORD FVF, LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; - STDMETHOD(CloneMesh)(THIS_ DWORD Options, + STDMETHOD(CloneMesh)(THIS_ DWORD Options, CONST D3DVERTEXELEMENT9 *pDeclaration, LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXMESH* ppCloneMesh) PURE; STDMETHOD(GetVertexBuffer)(THIS_ LPDIRECT3DVERTEXBUFFER9* ppVB) PURE; STDMETHOD(GetIndexBuffer)(THIS_ LPDIRECT3DINDEXBUFFER9* ppIB) PURE; @@ -368,9 +368,9 @@ DECLARE_INTERFACE_(ID3DXPMesh, ID3DXBaseMesh) STDMETHOD(UpdateSemantics)(THIS_ D3DVERTEXELEMENT9 Declaration[MAX_FVF_DECL_SIZE]) PURE; // ID3DXPMesh - STDMETHOD(ClonePMeshFVF)(THIS_ DWORD Options, + STDMETHOD(ClonePMeshFVF)(THIS_ DWORD Options, DWORD FVF, LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXPMESH* ppCloneMesh) PURE; - STDMETHOD(ClonePMesh)(THIS_ DWORD Options, + STDMETHOD(ClonePMesh)(THIS_ DWORD Options, CONST D3DVERTEXELEMENT9 *pDeclaration, LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXPMESH* ppCloneMesh) PURE; STDMETHOD(SetNumFaces)(THIS_ DWORD Faces) PURE; STDMETHOD(SetNumVertices)(THIS_ DWORD Vertices) PURE; @@ -380,8 +380,8 @@ DECLARE_INTERFACE_(ID3DXPMesh, ID3DXBaseMesh) STDMETHOD_(DWORD, GetMinVertices)(THIS) PURE; STDMETHOD(Save)(THIS_ IStream *pStream, CONST D3DXMATERIAL* pMaterials, CONST D3DXEFFECTINSTANCE* pEffectInstances, DWORD NumMaterials) PURE; - STDMETHOD(Optimize)(THIS_ DWORD Flags, DWORD* pAdjacencyOut, - DWORD* pFaceRemap, LPD3DXBUFFER *ppVertexRemap, + STDMETHOD(Optimize)(THIS_ DWORD Flags, DWORD* pAdjacencyOut, + DWORD* pFaceRemap, LPD3DXBUFFER *ppVertexRemap, LPD3DXMESH* ppOptMesh) PURE; STDMETHOD(OptimizeBaseLOD)(THIS_ DWORD Flags, DWORD* pFaceRemap) PURE; @@ -413,13 +413,13 @@ DECLARE_INTERFACE_(ID3DXSPMesh, IUnknown) STDMETHOD(GetDeclaration)(THIS_ D3DVERTEXELEMENT9 Declaration[MAX_FVF_DECL_SIZE]) PURE; STDMETHOD_(DWORD, GetOptions)(THIS) PURE; STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9* ppDevice) PURE; - STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options, + STDMETHOD(CloneMeshFVF)(THIS_ DWORD Options, DWORD FVF, LPDIRECT3DDEVICE9 pD3DDevice, DWORD *pAdjacencyOut, DWORD *pVertexRemapOut, LPD3DXMESH* ppCloneMesh) PURE; - STDMETHOD(CloneMesh)(THIS_ DWORD Options, + STDMETHOD(CloneMesh)(THIS_ DWORD Options, CONST D3DVERTEXELEMENT9 *pDeclaration, LPDIRECT3DDEVICE9 pD3DDevice, DWORD *pAdjacencyOut, DWORD *pVertexRemapOut, LPD3DXMESH* ppCloneMesh) PURE; - STDMETHOD(ClonePMeshFVF)(THIS_ DWORD Options, + STDMETHOD(ClonePMeshFVF)(THIS_ DWORD Options, DWORD FVF, LPDIRECT3DDEVICE9 pD3DDevice, DWORD *pVertexRemapOut, FLOAT *pErrorsByFace, LPD3DXPMESH* ppCloneMesh) PURE; - STDMETHOD(ClonePMesh)(THIS_ DWORD Options, + STDMETHOD(ClonePMesh)(THIS_ DWORD Options, CONST D3DVERTEXELEMENT9 *pDeclaration, LPDIRECT3DDEVICE9 pD3DDevice, DWORD *pVertexRemapOut, FLOAT *pErrorsbyFace, LPD3DXPMESH* ppCloneMesh) PURE; STDMETHOD(ReduceFaces)(THIS_ DWORD Faces) PURE; STDMETHOD(ReduceVertices)(THIS_ DWORD Vertices) PURE; @@ -441,7 +441,7 @@ enum _D3DXMESHOPT { D3DXMESHOPT_IGNOREVERTS = 0x10000000, // optimize faces only, don't touch vertices D3DXMESHOPT_DONOTSPLIT = 0x20000000, // do not split vertices shared between attribute groups when attribute sorting D3DXMESHOPT_DEVICEINDEPENDENT = 0x00400000, // Only affects VCache. uses a static known good cache size for all cards - + // D3DXMESHOPT_SHAREVB has been removed, please use D3DXMESH_VB_SHARE instead }; @@ -494,7 +494,7 @@ DECLARE_INTERFACE_(ID3DXPatchMesh, IUnknown) STDMETHOD(GetDevice)(THIS_ LPDIRECT3DDEVICE9 *ppDevice) PURE; STDMETHOD(GetPatchInfo)(THIS_ LPD3DXPATCHINFO PatchInfo) PURE; - // Control mesh access + // Control mesh access STDMETHOD(GetVertexBuffer)(THIS_ LPDIRECT3DVERTEXBUFFER9* ppVB) PURE; STDMETHOD(GetIndexBuffer)(THIS_ LPDIRECT3DINDEXBUFFER9* ppIB) PURE; STDMETHOD(LockVertexBuffer)(THIS_ DWORD flags, LPVOID *ppData) PURE; @@ -507,18 +507,18 @@ DECLARE_INTERFACE_(ID3DXPatchMesh, IUnknown) // This function returns the size of the tessellated mesh given a tessellation level. // This assumes uniform tessellation. For adaptive tessellation the Adaptive parameter must // be set to TRUE and TessellationLevel should be the max tessellation. - // This will result in the max mesh size necessary for adaptive tessellation. + // This will result in the max mesh size necessary for adaptive tessellation. STDMETHOD(GetTessSize)(THIS_ FLOAT fTessLevel,DWORD Adaptive, DWORD *NumTriangles,DWORD *NumVertices) PURE; - + //GenerateAdjacency determines which patches are adjacent with provided tolerance //this information is used internally to optimize tessellation STDMETHOD(GenerateAdjacency)(THIS_ FLOAT Tolerance) PURE; - + //CloneMesh Creates a new patchmesh with the specified decl, and converts the vertex buffer //to the new decl. Entries in the new decl which are new are set to 0. If the current mesh //has adjacency, the new mesh will also have adjacency STDMETHOD(CloneMesh)(THIS_ DWORD Options, CONST D3DVERTEXELEMENT9 *pDecl, LPD3DXPATCHMESH *pMesh) PURE; - + // Optimizes the patchmesh for efficient tessellation. This function is designed // to perform one time optimization for patch meshes that need to be tessellated // repeatedly by calling the Tessellate() method. The optimization performed is @@ -542,8 +542,8 @@ DECLARE_INTERFACE_(ID3DXPatchMesh, IUnknown) D3DTEXTUREFILTERTYPE *MipFilter, D3DTEXTUREADDRESS *Wrap, DWORD *dwLODBias) PURE; - - // Performs the uniform tessellation based on the tessellation level. + + // Performs the uniform tessellation based on the tessellation level. // This function will perform more efficiently if the patch mesh has been optimized using the Optimize() call. STDMETHOD(Tessellate)(THIS_ FLOAT fTessLevel,LPD3DXMESH pMesh) PURE; @@ -553,9 +553,9 @@ DECLARE_INTERFACE_(ID3DXPatchMesh, IUnknown) // at the 2 vertices it connects. // MaxTessLevel specifies the upper limit for adaptive tesselation. // This function will perform more efficiently if the patch mesh has been optimized using the Optimize() call. - STDMETHOD(TessellateAdaptive)(THIS_ + STDMETHOD(TessellateAdaptive)(THIS_ CONST D3DXVECTOR4 *pTrans, - DWORD dwMaxTessLevel, + DWORD dwMaxTessLevel, DWORD dwMinTessLevel, LPD3DXMESH pMesh) PURE; @@ -583,24 +583,24 @@ DECLARE_INTERFACE_(ID3DXSkinInfo, IUnknown) // This gets the max face influences based on a triangle mesh with the specified index buffer STDMETHOD(GetMaxFaceInfluences)(THIS_ LPDIRECT3DINDEXBUFFER9 pIB, DWORD NumFaces, DWORD* maxFaceInfluences) PURE; - + // Set min bone influence. Bone influences that are smaller than this are ignored STDMETHOD(SetMinBoneInfluence)(THIS_ FLOAT MinInfl) PURE; - // Get min bone influence. + // Get min bone influence. STDMETHOD_(FLOAT, GetMinBoneInfluence)(THIS) PURE; - + // Bone names are returned by D3DXLoadSkinMeshFromXof. They are not used by any other method of this object STDMETHOD(SetBoneName)(THIS_ DWORD Bone, LPCSTR pName) PURE; // pName is copied to an internal string buffer STDMETHOD_(LPCSTR, GetBoneName)(THIS_ DWORD Bone) PURE; // A pointer to an internal string buffer is returned. Do not free this. - + // Bone offset matrices are returned by D3DXLoadSkinMeshFromXof. They are not used by any other method of this object STDMETHOD(SetBoneOffsetMatrix)(THIS_ DWORD Bone, CONST D3DXMATRIX *pBoneTransform) PURE; // pBoneTransform is copied to an internal buffer STDMETHOD_(LPD3DXMATRIX, GetBoneOffsetMatrix)(THIS_ DWORD Bone) PURE; // A pointer to an internal matrix is returned. Do not free this. - + // Clone a skin info object STDMETHOD(Clone)(THIS_ LPD3DXSKININFO* ppSkinInfo) PURE; - - // Update bone influence information to match vertices after they are reordered. This should be called + + // Update bone influence information to match vertices after they are reordered. This should be called // if the target vertex buffer has been reordered externally. STDMETHOD(Remap)(THIS_ DWORD NumVertices, DWORD* pVertexRemap) PURE; @@ -611,39 +611,39 @@ DECLARE_INTERFACE_(ID3DXSkinInfo, IUnknown) STDMETHOD(GetDeclaration)(THIS_ D3DVERTEXELEMENT9 Declaration[MAX_FVF_DECL_SIZE]) PURE; // Apply SW skinning based on current pose matrices to the target vertices. - STDMETHOD(UpdateSkinnedMesh)(THIS_ - CONST D3DXMATRIX* pBoneTransforms, - CONST D3DXMATRIX* pBoneInvTransposeTransforms, - LPCVOID pVerticesSrc, + STDMETHOD(UpdateSkinnedMesh)(THIS_ + CONST D3DXMATRIX* pBoneTransforms, + CONST D3DXMATRIX* pBoneInvTransposeTransforms, + LPCVOID pVerticesSrc, PVOID pVerticesDst) PURE; // Takes a mesh and returns a new mesh with per vertex blend weights and a bone combination // table that describes which bones affect which subsets of the mesh - STDMETHOD(ConvertToBlendedMesh)(THIS_ + STDMETHOD(ConvertToBlendedMesh)(THIS_ LPD3DXMESH pMesh, - DWORD Options, - CONST DWORD *pAdjacencyIn, + DWORD Options, + CONST DWORD *pAdjacencyIn, LPDWORD pAdjacencyOut, - DWORD* pFaceRemap, - LPD3DXBUFFER *ppVertexRemap, + DWORD* pFaceRemap, + LPD3DXBUFFER *ppVertexRemap, DWORD* pMaxFaceInfl, - DWORD* pNumBoneCombinations, - LPD3DXBUFFER* ppBoneCombinationTable, + DWORD* pNumBoneCombinations, + LPD3DXBUFFER* ppBoneCombinationTable, LPD3DXMESH* ppMesh) PURE; - // Takes a mesh and returns a new mesh with per vertex blend weights and indices + // Takes a mesh and returns a new mesh with per vertex blend weights and indices // and a bone combination table that describes which bones palettes affect which subsets of the mesh - STDMETHOD(ConvertToIndexedBlendedMesh)(THIS_ + STDMETHOD(ConvertToIndexedBlendedMesh)(THIS_ LPD3DXMESH pMesh, - DWORD Options, - DWORD paletteSize, - CONST DWORD *pAdjacencyIn, - LPDWORD pAdjacencyOut, - DWORD* pFaceRemap, - LPD3DXBUFFER *ppVertexRemap, + DWORD Options, + DWORD paletteSize, + CONST DWORD *pAdjacencyIn, + LPDWORD pAdjacencyOut, + DWORD* pFaceRemap, + LPD3DXBUFFER *ppVertexRemap, DWORD* pMaxVertexInfl, - DWORD* pNumBoneCombinations, - LPD3DXBUFFER* ppBoneCombinationTable, + DWORD* pNumBoneCombinations, + LPD3DXBUFFER* ppBoneCombinationTable, LPD3DXMESH* ppMesh) PURE; }; @@ -652,28 +652,28 @@ extern "C" { #endif //__cplusplus -HRESULT WINAPI +HRESULT WINAPI D3DXCreateMesh( - DWORD NumFaces, - DWORD NumVertices, - DWORD Options, - CONST D3DVERTEXELEMENT9 *pDeclaration, - LPDIRECT3DDEVICE9 pD3DDevice, + DWORD NumFaces, + DWORD NumVertices, + DWORD Options, + CONST D3DVERTEXELEMENT9 *pDeclaration, + LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXMESH* ppMesh); -HRESULT WINAPI +HRESULT WINAPI D3DXCreateMeshFVF( - DWORD NumFaces, - DWORD NumVertices, - DWORD Options, - DWORD FVF, - LPDIRECT3DDEVICE9 pD3DDevice, + DWORD NumFaces, + DWORD NumVertices, + DWORD Options, + DWORD FVF, + LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXMESH* ppMesh); -HRESULT WINAPI +HRESULT WINAPI D3DXCreateSPMesh( - LPD3DXMESH pMesh, - CONST DWORD* pAdjacency, + LPD3DXMESH pMesh, + CONST DWORD* pAdjacency, CONST D3DXATTRIBUTEWEIGHTS *pVertexAttributeWeights, CONST FLOAT *pVertexWeights, LPD3DXSPMESH* ppSMesh); @@ -694,72 +694,72 @@ HRESULT WINAPI CONST DWORD* pAdjacency, LPD3DXBUFFER* ppErrorsAndWarnings); -HRESULT WINAPI +HRESULT WINAPI D3DXGeneratePMesh( - LPD3DXMESH pMesh, - CONST DWORD* pAdjacency, + LPD3DXMESH pMesh, + CONST DWORD* pAdjacency, CONST D3DXATTRIBUTEWEIGHTS *pVertexAttributeWeights, CONST FLOAT *pVertexWeights, - DWORD MinValue, - DWORD Options, + DWORD MinValue, + DWORD Options, LPD3DXPMESH* ppPMesh); -HRESULT WINAPI +HRESULT WINAPI D3DXSimplifyMesh( - LPD3DXMESH pMesh, - CONST DWORD* pAdjacency, + LPD3DXMESH pMesh, + CONST DWORD* pAdjacency, CONST D3DXATTRIBUTEWEIGHTS *pVertexAttributeWeights, CONST FLOAT *pVertexWeights, - DWORD MinValue, - DWORD Options, + DWORD MinValue, + DWORD Options, LPD3DXMESH* ppMesh); -HRESULT WINAPI +HRESULT WINAPI D3DXComputeBoundingSphere( CONST D3DXVECTOR3 *pFirstPosition, // pointer to first position - DWORD NumVertices, + DWORD NumVertices, DWORD dwStride, // count in bytes to subsequent position vectors - D3DXVECTOR3 *pCenter, + D3DXVECTOR3 *pCenter, FLOAT *pRadius); -HRESULT WINAPI +HRESULT WINAPI D3DXComputeBoundingBox( CONST D3DXVECTOR3 *pFirstPosition, // pointer to first position - DWORD NumVertices, + DWORD NumVertices, DWORD dwStride, // count in bytes to subsequent position vectors - D3DXVECTOR3 *pMin, + D3DXVECTOR3 *pMin, D3DXVECTOR3 *pMax); -HRESULT WINAPI +HRESULT WINAPI D3DXComputeNormals( LPD3DXBASEMESH pMesh, CONST DWORD *pAdjacency); -HRESULT WINAPI +HRESULT WINAPI D3DXCreateBuffer( - DWORD NumBytes, + DWORD NumBytes, LPD3DXBUFFER *ppBuffer); HRESULT WINAPI D3DXLoadMeshFromXA( - LPCSTR pFilename, - DWORD Options, - LPDIRECT3DDEVICE9 pD3DDevice, + LPCSTR pFilename, + DWORD Options, + LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXBUFFER *ppAdjacency, - LPD3DXBUFFER *ppMaterials, - LPD3DXBUFFER *ppEffectInstances, + LPD3DXBUFFER *ppMaterials, + LPD3DXBUFFER *ppEffectInstances, DWORD *pNumMaterials, LPD3DXMESH *ppMesh); HRESULT WINAPI D3DXLoadMeshFromXW( - LPCWSTR pFilename, - DWORD Options, - LPDIRECT3DDEVICE9 pD3DDevice, + LPCWSTR pFilename, + DWORD Options, + LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXBUFFER *ppAdjacency, - LPD3DXBUFFER *ppMaterials, - LPD3DXBUFFER *ppEffectInstances, + LPD3DXBUFFER *ppMaterials, + LPD3DXBUFFER *ppEffectInstances, DWORD *pNumMaterials, LPD3DXMESH *ppMesh); @@ -769,67 +769,67 @@ HRESULT WINAPI #define D3DXLoadMeshFromX D3DXLoadMeshFromXA #endif -HRESULT WINAPI +HRESULT WINAPI D3DXLoadMeshFromXInMemory( LPCVOID Memory, DWORD SizeOfMemory, - DWORD Options, - LPDIRECT3DDEVICE9 pD3DDevice, + DWORD Options, + LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXBUFFER *ppAdjacency, - LPD3DXBUFFER *ppMaterials, - LPD3DXBUFFER *ppEffectInstances, + LPD3DXBUFFER *ppMaterials, + LPD3DXBUFFER *ppEffectInstances, DWORD *pNumMaterials, LPD3DXMESH *ppMesh); -HRESULT WINAPI +HRESULT WINAPI D3DXLoadMeshFromXResource( HMODULE Module, LPCSTR Name, LPCSTR Type, - DWORD Options, - LPDIRECT3DDEVICE9 pD3DDevice, + DWORD Options, + LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXBUFFER *ppAdjacency, - LPD3DXBUFFER *ppMaterials, - LPD3DXBUFFER *ppEffectInstances, + LPD3DXBUFFER *ppMaterials, + LPD3DXBUFFER *ppEffectInstances, DWORD *pNumMaterials, LPD3DXMESH *ppMesh); -HRESULT WINAPI +HRESULT WINAPI D3DXSaveMeshToXA( LPCSTR pFilename, LPD3DXMESH pMesh, CONST DWORD* pAdjacency, CONST D3DXMATERIAL* pMaterials, - CONST D3DXEFFECTINSTANCE* pEffectInstances, + CONST D3DXEFFECTINSTANCE* pEffectInstances, DWORD NumMaterials, DWORD Format ); -HRESULT WINAPI +HRESULT WINAPI D3DXSaveMeshToXW( LPCWSTR pFilename, LPD3DXMESH pMesh, CONST DWORD* pAdjacency, CONST D3DXMATERIAL* pMaterials, - CONST D3DXEFFECTINSTANCE* pEffectInstances, + CONST D3DXEFFECTINSTANCE* pEffectInstances, DWORD NumMaterials, DWORD Format ); - + #ifdef UNICODE #define D3DXSaveMeshToX D3DXSaveMeshToXW #else #define D3DXSaveMeshToX D3DXSaveMeshToXA #endif - -HRESULT WINAPI + +HRESULT WINAPI D3DXCreatePMeshFromStream( - IStream *pStream, + IStream *pStream, DWORD Options, - LPDIRECT3DDEVICE9 pD3DDevice, + LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXBUFFER *ppMaterials, - LPD3DXBUFFER *ppEffectInstances, + LPD3DXBUFFER *ppEffectInstances, DWORD* pNumMaterials, LPD3DXPMESH *ppPMesh); @@ -838,10 +838,10 @@ HRESULT WINAPI HRESULT WINAPI D3DXCreateSkinInfo( DWORD NumVertices, - CONST D3DVERTEXELEMENT9 *pDeclaration, + CONST D3DVERTEXELEMENT9 *pDeclaration, DWORD NumBones, LPD3DXSKININFO* ppSkinInfo); - + // Creates a skin info object based on the number of vertices, number of bones, and a FVF describing the vertex layout of the target vertices // The bone names and initial bone transforms are not filled in the skin info object by this method. HRESULT WINAPI @@ -850,34 +850,34 @@ HRESULT WINAPI DWORD FVF, DWORD NumBones, LPD3DXSKININFO* ppSkinInfo); - + #ifdef __cplusplus } extern "C" { #endif //__cplusplus -HRESULT WINAPI +HRESULT WINAPI D3DXLoadMeshFromXof( - LPD3DXFILEDATA pxofMesh, - DWORD Options, - LPDIRECT3DDEVICE9 pD3DDevice, + LPD3DXFILEDATA pxofMesh, + DWORD Options, + LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXBUFFER *ppAdjacency, - LPD3DXBUFFER *ppMaterials, - LPD3DXBUFFER *ppEffectInstances, + LPD3DXBUFFER *ppMaterials, + LPD3DXBUFFER *ppEffectInstances, DWORD *pNumMaterials, LPD3DXMESH *ppMesh); // This similar to D3DXLoadMeshFromXof, except also returns skinning info if present in the file -// If skinning info is not present, ppSkinInfo will be NULL +// If skinning info is not present, ppSkinInfo will be NULL HRESULT WINAPI D3DXLoadSkinMeshFromXof( - LPD3DXFILEDATA pxofMesh, + LPD3DXFILEDATA pxofMesh, DWORD Options, LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXBUFFER* ppAdjacency, LPD3DXBUFFER* ppMaterials, - LPD3DXBUFFER *ppEffectInstances, + LPD3DXBUFFER *ppEffectInstances, DWORD *pMatOut, LPD3DXSKININFO* ppSkinInfo, LPD3DXMESH* ppMesh); @@ -894,12 +894,12 @@ HRESULT WINAPI DWORD NumBones, CONST D3DXBONECOMBINATION *pBoneCombinationTable, LPD3DXSKININFO* ppSkinInfo); - + HRESULT WINAPI D3DXTessellateNPatches( - LPD3DXMESH pMeshIn, - CONST DWORD* pAdjacencyIn, - FLOAT NumSegs, + LPD3DXMESH pMeshIn, + CONST DWORD* pAdjacencyIn, + FLOAT NumSegs, BOOL QuadraticInterpNormals, // if false use linear intrep for normals, if true use quadratic LPD3DXMESH *ppMeshOut, LPD3DXBUFFER *ppAdjacencyOut); @@ -907,7 +907,7 @@ HRESULT WINAPI //generates implied outputdecl from input decl //the decl generated from this should be used to generate the output decl for -//the tessellator subroutines. +//the tessellator subroutines. HRESULT WINAPI D3DXGenerateOutputDecl( @@ -917,14 +917,14 @@ HRESULT WINAPI //loads patches from an XFileData //since an X file can have up to 6 different patch meshes in it, //returns them in an array - pNumPatches will contain the number of -//meshes in the actual file. +//meshes in the actual file. HRESULT WINAPI D3DXLoadPatchMeshFromXof( LPD3DXFILEDATA pXofObjMesh, DWORD Options, LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXBUFFER *ppMaterials, - LPD3DXBUFFER *ppEffectInstances, + LPD3DXBUFFER *ppEffectInstances, PDWORD pNumMaterials, LPD3DXPATCHMESH *ppMesh); @@ -935,10 +935,10 @@ HRESULT WINAPI DWORD *pdwTriangles, //output number of triangles DWORD *pdwVertices); //output number of vertices -//computes the size of a single triangle patch +//computes the size of a single triangle patch HRESULT WINAPI D3DXTriPatchSize( - CONST FLOAT *pfNumSegs, //segments for each edge (3) + CONST FLOAT *pfNumSegs, //segments for each edge (3) DWORD *pdwTriangles, //output number of triangles DWORD *pdwVertices); //output number of vertices @@ -964,25 +964,25 @@ HRESULT WINAPI -//creates an NPatch PatchMesh from a D3DXMESH +//creates an NPatch PatchMesh from a D3DXMESH HRESULT WINAPI D3DXCreateNPatchMesh( LPD3DXMESH pMeshSysMem, LPD3DXPATCHMESH *pPatchMesh); - + //creates a patch mesh HRESULT WINAPI D3DXCreatePatchMesh( CONST D3DXPATCHINFO *pInfo, //patch type DWORD dwNumPatches, //number of patches DWORD dwNumVertices, //number of control vertices - DWORD dwOptions, //options + DWORD dwOptions, //options CONST D3DVERTEXELEMENT9 *pDecl, //format of control vertices - LPDIRECT3DDEVICE9 pD3DDevice, + LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXPATCHMESH *pPatchMesh); - + //returns the number of degenerates in a patch mesh - //text output put in string. HRESULT WINAPI @@ -994,10 +994,10 @@ HRESULT WINAPI UINT WINAPI D3DXGetFVFVertexSize(DWORD FVF); -UINT WINAPI +UINT WINAPI D3DXGetDeclVertexSize(CONST D3DVERTEXELEMENT9 *pDecl,DWORD Stream); -UINT WINAPI +UINT WINAPI D3DXGetDeclLength(CONST D3DVERTEXELEMENT9 *pDecl); HRESULT WINAPI @@ -1010,20 +1010,20 @@ HRESULT WINAPI CONST D3DVERTEXELEMENT9 *pDeclarator, DWORD *pFVF); -HRESULT WINAPI +HRESULT WINAPI D3DXWeldVertices( - LPD3DXMESH pMesh, + LPD3DXMESH pMesh, DWORD Flags, - CONST D3DXWELDEPSILONS *pEpsilons, - CONST DWORD *pAdjacencyIn, + CONST D3DXWELDEPSILONS *pEpsilons, + CONST DWORD *pAdjacencyIn, DWORD *pAdjacencyOut, - DWORD *pFaceRemap, + DWORD *pFaceRemap, LPD3DXBUFFER *ppVertexRemap); typedef struct _D3DXINTERSECTINFO { DWORD FaceIndex; // index of face intersected - FLOAT U; // Barycentric Hit Coordinates + FLOAT U; // Barycentric Hit Coordinates FLOAT V; // Barycentric Hit Coordinates FLOAT Dist; // Ray-Intersection Parameter Distance } D3DXINTERSECTINFO, *LPD3DXINTERSECTINFO; @@ -1033,13 +1033,13 @@ HRESULT WINAPI D3DXIntersect( LPD3DXBASEMESH pMesh, CONST D3DXVECTOR3 *pRayPos, - CONST D3DXVECTOR3 *pRayDir, + CONST D3DXVECTOR3 *pRayDir, BOOL *pHit, // True if any faces were intersected DWORD *pFaceIndex, // index of closest face intersected - FLOAT *pU, // Barycentric Hit Coordinates + FLOAT *pU, // Barycentric Hit Coordinates FLOAT *pV, // Barycentric Hit Coordinates FLOAT *pDist, // Ray-Intersection Parameter Distance - LPD3DXBUFFER *ppAllHits, // Array of D3DXINTERSECTINFOs for all hits (not just closest) + LPD3DXBUFFER *ppAllHits, // Array of D3DXINTERSECTINFOs for all hits (not just closest) DWORD *pCountOfHits); // Number of entries in AllHits array HRESULT WINAPI @@ -1047,20 +1047,20 @@ HRESULT WINAPI LPD3DXBASEMESH pMesh, DWORD AttribId, CONST D3DXVECTOR3 *pRayPos, - CONST D3DXVECTOR3 *pRayDir, + CONST D3DXVECTOR3 *pRayDir, BOOL *pHit, // True if any faces were intersected DWORD *pFaceIndex, // index of closest face intersected - FLOAT *pU, // Barycentric Hit Coordinates + FLOAT *pU, // Barycentric Hit Coordinates FLOAT *pV, // Barycentric Hit Coordinates FLOAT *pDist, // Ray-Intersection Parameter Distance - LPD3DXBUFFER *ppAllHits, // Array of D3DXINTERSECTINFOs for all hits (not just closest) + LPD3DXBUFFER *ppAllHits, // Array of D3DXINTERSECTINFOs for all hits (not just closest) DWORD *pCountOfHits); // Number of entries in AllHits array HRESULT WINAPI D3DXSplitMesh ( - LPD3DXMESH pMeshIn, - CONST DWORD *pAdjacencyIn, + LPD3DXMESH pMeshIn, + CONST DWORD *pAdjacencyIn, CONST DWORD MaxSize, CONST DWORD Options, DWORD *pMeshesOut, @@ -1070,7 +1070,7 @@ HRESULT WINAPI D3DXSplitMesh LPD3DXBUFFER *ppVertRemapArrayOut ); -BOOL WINAPI D3DXIntersectTri +BOOL WINAPI D3DXIntersectTri ( CONST D3DXVECTOR3 *p0, // Triangle vertex 0 position CONST D3DXVECTOR3 *p1, // Triangle vertex 1 position @@ -1088,9 +1088,9 @@ BOOL WINAPI CONST D3DXVECTOR3 *pRayPosition, CONST D3DXVECTOR3 *pRayDirection); -BOOL WINAPI +BOOL WINAPI D3DXBoxBoundProbe( - CONST D3DXVECTOR3 *pMin, + CONST D3DXVECTOR3 *pMin, CONST D3DXVECTOR3 *pMax, CONST D3DXVECTOR3 *pRayPosition, CONST D3DXVECTOR3 *pRayDirection); @@ -1124,11 +1124,11 @@ HRESULT WINAPI D3DXComputeTangentFrameEx(ID3DXMesh *pMesh, //puts the binorm in BINORM[BinormIndex] also specified in the decl. // //If neither the binorm or the tangnet are in the meshes declaration, -//the function will fail. +//the function will fail. // //If a tangent or Binorm field is in the Decl, but the user does not //wish D3DXComputeTangent to replace them, then D3DX_DEFAULT specified -//in the TangentIndex or BinormIndex will cause it to ignore the specified +//in the TangentIndex or BinormIndex will cause it to ignore the specified //semantic. // //Wrap should be specified if the texture coordinates wrap. @@ -1186,7 +1186,7 @@ typedef HRESULT (WINAPI *LPD3DXUVATLASCB)(FLOAT fPercentDone, LPVOID lpUserCont // integrated metric tensor for that face. This lets you control // the way this triangle may be stretched in the atlas. The IMT // passed in will be 3 floats (a,b,c) and specify a symmetric -// matrix (a b) that, given a vector (s,t), specifies the +// matrix (a b) that, given a vector (s,t), specifies the // (b c) // distance between a vector v1 and a vector v2 = v1 + (s,t) as // sqrt((s, t) * M * (s, t)^T). @@ -1202,7 +1202,7 @@ typedef HRESULT (WINAPI *LPD3DXUVATLASCB)(FLOAT fPercentDone, LPVOID lpUserCont // in some 2-D space. For D3DXUVAtlas, this space is created by // letting S be the direction from the first to the second // vertex, and T be the cross product between the normal and S. -// +// // pStatusCallback - Since the atlas creation process can be very CPU intensive, // this allows the programmer to specify a function to be called // periodically, similarly to how it is done in the PRT simulation @@ -1459,7 +1459,7 @@ HRESULT WINAPI LPD3DXBUFFER *ppStripLengths, DWORD *pNumStrips); - + //============================================================================ // // D3DXOptimizeFaces: @@ -1485,17 +1485,17 @@ HRESULT WINAPI //============================================================================ HRESULT WINAPI D3DXOptimizeFaces( - LPCVOID pbIndices, - UINT cFaces, - UINT cVertices, - BOOL b32BitIndices, + LPCVOID pbIndices, + UINT cFaces, + UINT cVertices, + BOOL b32BitIndices, DWORD* pFaceRemap); - + //============================================================================ // // D3DXOptimizeVertices: // -------------------- -// Generate a vertex remapping to optimize for in order use of vertices for +// Generate a vertex remapping to optimize for in order use of vertices for // a given set of indices. This is commonly used after applying the face // remap generated by D3DXOptimizeFaces // @@ -1516,10 +1516,10 @@ HRESULT WINAPI //============================================================================ HRESULT WINAPI D3DXOptimizeVertices( - LPCVOID pbIndices, - UINT cFaces, - UINT cVertices, - BOOL b32BitIndices, + LPCVOID pbIndices, + UINT cFaces, + UINT cVertices, + BOOL b32BitIndices, DWORD* pVertexRemap); #ifdef __cplusplus @@ -1546,8 +1546,8 @@ typedef enum _D3DXSHGPUSIMOPT { D3DXSHGPUSIMOPT_SHADOWRES1024 = 2, D3DXSHGPUSIMOPT_SHADOWRES2048 = 3, - D3DXSHGPUSIMOPT_HIGHQUALITY = 4, - + D3DXSHGPUSIMOPT_HIGHQUALITY = 4, + D3DXSHGPUSIMOPT_FORCE_DWORD = 0x7fffffff } D3DXSHGPUSIMOPT; @@ -1560,7 +1560,7 @@ typedef struct _D3DXSHMATERIAL { BOOL bMirror; // Must be set to FALSE. bMirror == TRUE not currently supported BOOL bSubSurf; // true if the object does subsurface scattering - can't do this and be a mirror - // subsurface scattering parameters + // subsurface scattering parameters FLOAT RelativeIndexOfRefraction; D3DCOLORVALUE Absorption; D3DCOLORVALUE ReducedScattering; @@ -1583,10 +1583,10 @@ typedef struct _D3DXSHPRTSPLITMESHVERTDATA { typedef struct _D3DXSHPRTSPLITMESHCLUSTERDATA { UINT uVertStart; // initial index into remapped vertex array UINT uVertLength; // number of vertices in this super cluster - + UINT uFaceStart; // initial index into face array UINT uFaceLength; // number of faces in this super cluster - + UINT uClusterStart; // initial index into cluster array UINT uClusterLength; // number of clusters in this super cluster } D3DXSHPRTSPLITMESHCLUSTERDATA; @@ -1601,19 +1601,19 @@ typedef HRESULT (WINAPI *LPD3DXSHPRTSIMCB)(float fPercentDone, LPVOID lpUserCon // GUIDs // {F1827E47-00A8-49cd-908C-9D11955F8728} -DEFINE_GUID(IID_ID3DXPRTBuffer, +DEFINE_GUID(IID_ID3DXPRTBuffer, 0xf1827e47, 0xa8, 0x49cd, 0x90, 0x8c, 0x9d, 0x11, 0x95, 0x5f, 0x87, 0x28); // {A758D465-FE8D-45ad-9CF0-D01E56266A07} -DEFINE_GUID(IID_ID3DXPRTCompBuffer, +DEFINE_GUID(IID_ID3DXPRTCompBuffer, 0xa758d465, 0xfe8d, 0x45ad, 0x9c, 0xf0, 0xd0, 0x1e, 0x56, 0x26, 0x6a, 0x7); // {838F01EC-9729-4527-AADB-DF70ADE7FEA9} -DEFINE_GUID(IID_ID3DXTextureGutterHelper, +DEFINE_GUID(IID_ID3DXTextureGutterHelper, 0x838f01ec, 0x9729, 0x4527, 0xaa, 0xdb, 0xdf, 0x70, 0xad, 0xe7, 0xfe, 0xa9); // {683A4278-CD5F-4d24-90AD-C4E1B6855D53} -DEFINE_GUID(IID_ID3DXPRTEngine, +DEFINE_GUID(IID_ID3DXPRTEngine, 0x683a4278, 0xcd5f, 0x4d24, 0x90, 0xad, 0xc4, 0xe1, 0xb6, 0x85, 0x5d, 0x53); // interface defenitions @@ -1654,26 +1654,26 @@ DECLARE_INTERFACE_(ID3DXPRTBuffer, IUnknown) // every scalar in buffer is multiplied by Scale STDMETHOD(ScaleBuffer)(THIS_ FLOAT Scale) PURE; - + // every scalar contains the sum of this and pBuffers values - // pBuffer must have the same storage class/dimensions + // pBuffer must have the same storage class/dimensions STDMETHOD(AddBuffer)(THIS_ LPD3DXPRTBUFFER pBuffer) PURE; // GutterHelper (described below) will fill in the gutter // regions of a texture by interpolating "internal" values STDMETHOD(AttachGH)(THIS_ LPD3DXTEXTUREGUTTERHELPER) PURE; STDMETHOD(ReleaseGH)(THIS) PURE; - + // Evaluates attached gutter helper on the contents of this buffer STDMETHOD(EvalGH)(THIS) PURE; // extracts a given channel into texture pTexture // NumCoefficients starting from StartCoefficient are copied - STDMETHOD(ExtractTexture)(THIS_ UINT Channel, UINT StartCoefficient, + STDMETHOD(ExtractTexture)(THIS_ UINT Channel, UINT StartCoefficient, UINT NumCoefficients, LPDIRECT3DTEXTURE9 pTexture) PURE; // extracts NumCoefficients coefficients into mesh - only applicable on single channel - // buffers, otherwise just lockbuffer and copy data. With SHPRT data NumCoefficients + // buffers, otherwise just lockbuffer and copy data. With SHPRT data NumCoefficients // should be Order^2 STDMETHOD(ExtractToMesh)(THIS_ UINT NumCoefficients, D3DDECLUSAGE Usage, UINT UsageIndexStart, LPD3DXMESH pScene) PURE; @@ -1717,19 +1717,19 @@ DECLARE_INTERFACE_(ID3DXPRTCompBuffer, IUnknown) // copies basis vectors for cluster "Cluster" into pClusterBasis // (NumPCA+1)*NumCoeffs*NumChannels floats STDMETHOD(ExtractBasis)(THIS_ UINT Cluster, FLOAT *pClusterBasis) PURE; - + // UINT per sample - which cluster it belongs to STDMETHOD(ExtractClusterIDs)(THIS_ UINT *pClusterIDs) PURE; - + // copies NumExtract PCA projection coefficients starting at StartPCA // into pPCACoefficients - NumSamples*NumExtract floats copied STDMETHOD(ExtractPCA)(THIS_ UINT StartPCA, UINT NumExtract, FLOAT *pPCACoefficients) PURE; // copies NumPCA projection coefficients starting at StartPCA // into pTexture - should be able to cope with signed formats - STDMETHOD(ExtractTexture)(THIS_ UINT StartPCA, UINT NumpPCA, + STDMETHOD(ExtractTexture)(THIS_ UINT StartPCA, UINT NumpPCA, LPDIRECT3DTEXTURE9 pTexture) PURE; - + // copies NumPCA projection coefficients into mesh pScene // Usage is D3DDECLUSAGE where coefficients are to be stored // UsageIndexStart is starting index @@ -1767,7 +1767,7 @@ DECLARE_INTERFACE_(ID3DXTextureGutterHelper, IUnknown) STDMETHOD_(ULONG, Release)(THIS) PURE; // ID3DXTextureGutterHelper - + // dimensions of texture this is bound too STDMETHOD_(UINT, GetWidth)(THIS) PURE; STDMETHOD_(UINT, GetHeight)(THIS) PURE; @@ -1775,19 +1775,19 @@ DECLARE_INTERFACE_(ID3DXTextureGutterHelper, IUnknown) // Applying gutters recomputes all of the gutter texels of class "2" // based on texels of class "1" or "4" - + // Applies gutters to a raw float buffer - each texel is NumCoeffs floats // Width and Height must match GutterHelper STDMETHOD(ApplyGuttersFloat)(THIS_ FLOAT *pDataIn, UINT NumCoeffs, UINT Width, UINT Height); - + // Applies gutters to pTexture // Dimensions must match GutterHelper STDMETHOD(ApplyGuttersTex)(THIS_ LPDIRECT3DTEXTURE9 pTexture); - + // Applies gutters to a D3DXPRTBuffer // Dimensions must match GutterHelper STDMETHOD(ApplyGuttersPRT)(THIS_ LPD3DXPRTBUFFER pBuffer); - + // Resamples a texture from a mesh onto this gutterhelpers // parameterization. It is assumed that the UV coordinates // for this gutter helper are in TEXTURE 0 (usage/usage index) @@ -1802,63 +1802,63 @@ DECLARE_INTERFACE_(ID3DXTextureGutterHelper, IUnknown) // for pTextureIn // UsageIndex - which index for Usage above for pTextureIn // pTextureOut- Resampled texture - // + // // Usage would generally be D3DDECLUSAGE_TEXCOORD and UsageIndex other than zero STDMETHOD(ResampleTex)(THIS_ LPDIRECT3DTEXTURE9 pTextureIn, LPD3DXMESH pMeshIn, D3DDECLUSAGE Usage, UINT UsageIndex, - LPDIRECT3DTEXTURE9 pTextureOut); - + LPDIRECT3DTEXTURE9 pTextureOut); + // the routines below provide access to the data structures // used by the Apply functions // face map is a UINT per texel that represents the - // face of the mesh that texel belongs too - + // face of the mesh that texel belongs too - // only valid if same texel is valid in pGutterData // pFaceData must be allocated by the user STDMETHOD(GetFaceMap)(THIS_ UINT *pFaceData) PURE; - + // BaryMap is a D3DXVECTOR2 per texel // the 1st two barycentric coordinates for the corresponding // face (3rd weight is always 1-sum of first two) // only valid if same texel is valid in pGutterData // pBaryData must be allocated by the user STDMETHOD(GetBaryMap)(THIS_ D3DXVECTOR2 *pBaryData) PURE; - + // TexelMap is a D3DXVECTOR2 per texel that // stores the location in pixel coordinates where the // corresponding texel is mapped // pTexelData must be allocated by the user STDMETHOD(GetTexelMap)(THIS_ D3DXVECTOR2 *pTexelData) PURE; - + // GutterMap is a BYTE per texel // 0/1/2 for Invalid/Internal/Gutter texels // 4 represents a gutter texel that will be computed // during PRT // pGutterData must be allocated by the user STDMETHOD(GetGutterMap)(THIS_ BYTE *pGutterData) PURE; - + // face map is a UINT per texel that represents the - // face of the mesh that texel belongs too - + // face of the mesh that texel belongs too - // only valid if same texel is valid in pGutterData STDMETHOD(SetFaceMap)(THIS_ UINT *pFaceData) PURE; - + // BaryMap is a D3DXVECTOR2 per texel // the 1st two barycentric coordinates for the corresponding // face (3rd weight is always 1-sum of first two) // only valid if same texel is valid in pGutterData STDMETHOD(SetBaryMap)(THIS_ D3DXVECTOR2 *pBaryData) PURE; - + // TexelMap is a D3DXVECTOR2 per texel that // stores the location in pixel coordinates where the // corresponding texel is mapped STDMETHOD(SetTexelMap)(THIS_ D3DXVECTOR2 *pTexelData) PURE; - + // GutterMap is a BYTE per texel // 0/1/2 for Invalid/Internal/Gutter texels // 4 represents a gutter texel that will be computed // during PRT - STDMETHOD(SetGutterMap)(THIS_ BYTE *pGutterData) PURE; + STDMETHOD(SetGutterMap)(THIS_ BYTE *pGutterData) PURE; }; @@ -1895,7 +1895,7 @@ DECLARE_INTERFACE_(ID3DXPRTEngine, IUnknown) STDMETHOD_(ULONG, Release)(THIS) PURE; // ID3DXPRTEngine - + // This sets a material per attribute in the scene mesh and it is // the only way to specify subsurface scattering parameters. if // bSetAlbedo is FALSE, NumChannels must match the current @@ -1909,53 +1909,53 @@ DECLARE_INTERFACE_(ID3DXPRTEngine, IUnknown) // albedo that might have been set before. FALSE won't clobber. // fLengthScale is used for subsurface scattering - scene is mapped into a 1mm unit cube // and scaled by this amount - STDMETHOD(SetMeshMaterials)(THIS_ CONST D3DXSHMATERIAL **ppMaterials, UINT NumMeshes, + STDMETHOD(SetMeshMaterials)(THIS_ CONST D3DXSHMATERIAL **ppMaterials, UINT NumMeshes, UINT NumChannels, BOOL bSetAlbedo, FLOAT fLengthScale) PURE; - + // setting albedo per-vertex or per-texel over rides the albedos stored per mesh // but it does not over ride any other settings - + // sets an albedo to be used per vertex - the albedo is represented as a float // pDataIn input pointer (pointint to albedo of 1st sample) // NumChannels 1 implies "grayscale" materials, set this to 3 to enable // color bleeding effects // Stride - stride in bytes to get to next samples albedo STDMETHOD(SetPerVertexAlbedo)(THIS_ CONST VOID *pDataIn, UINT NumChannels, UINT Stride) PURE; - + // represents the albedo per-texel instead of per-vertex (even if per-vertex PRT is used) // pAlbedoTexture - texture that stores the albedo (dimension arbitrary) // NumChannels 1 implies "grayscale" materials, set this to 3 to enable // color bleeding effects // pGH - optional gutter helper, otherwise one is constructed in computation routines and // destroyed (if not attached to buffers) - STDMETHOD(SetPerTexelAlbedo)(THIS_ LPDIRECT3DTEXTURE9 pAlbedoTexture, - UINT NumChannels, + STDMETHOD(SetPerTexelAlbedo)(THIS_ LPDIRECT3DTEXTURE9 pAlbedoTexture, + UINT NumChannels, LPD3DXTEXTUREGUTTERHELPER pGH) PURE; - + // gets the per-vertex albedo - STDMETHOD(GetVertexAlbedo)(THIS_ D3DXCOLOR *pVertColors, UINT NumVerts) PURE; - + STDMETHOD(GetVertexAlbedo)(THIS_ D3DXCOLOR *pVertColors, UINT NumVerts) PURE; + // If pixel PRT is being computed normals default to ones that are interpolated // from the vertex normals. This specifies a texture that stores an object // space normal map instead (must use a texture format that can represent signed values) - // pNormalTexture - normal map, must be same dimensions as PRTBuffers, signed + // pNormalTexture - normal map, must be same dimensions as PRTBuffers, signed STDMETHOD(SetPerTexelNormal)(THIS_ LPDIRECT3DTEXTURE9 pNormalTexture) PURE; - + // Copies per-vertex albedo from mesh // pMesh - mesh that represents the scene. It must have the same // properties as the mesh used to create the PRTEngine // Usage - D3DDECLUSAGE to extract albedos from // NumChannels 1 implies "grayscale" materials, set this to 3 to enable // color bleeding effects - STDMETHOD(ExtractPerVertexAlbedo)(THIS_ LPD3DXMESH pMesh, - D3DDECLUSAGE Usage, + STDMETHOD(ExtractPerVertexAlbedo)(THIS_ LPD3DXMESH pMesh, + D3DDECLUSAGE Usage, UINT NumChannels) PURE; // Resamples the input buffer into the output buffer // can be used to move between per-vertex and per-texel buffers. This can also be used // to convert single channel buffers to 3-channel buffers and vice-versa. STDMETHOD(ResampleBuffer)(THIS_ LPD3DXPRTBUFFER pBufferIn, LPD3DXPRTBUFFER pBufferOut) PURE; - + // Returns the scene mesh - including modifications from adaptive spatial sampling // The returned mesh only has positions, normals and texture coordinates (if defined) // pD3DDevice - d3d device that will be used to allocate the mesh @@ -1998,10 +1998,10 @@ DECLARE_INTERFACE_(ID3DXPRTEngine, IUnknown) // Adaptive - if TRUE adaptive sampling (angular) is used // AdaptiveThresh - threshold used to terminate adaptive angular sampling // ignored if adaptive sampling is not set - STDMETHOD(SetSamplingInfo)(THIS_ UINT NumRays, - BOOL UseSphere, - BOOL UseCosine, - BOOL Adaptive, + STDMETHOD(SetSamplingInfo)(THIS_ UINT NumRays, + BOOL UseSphere, + BOOL UseCosine, + BOOL Adaptive, FLOAT AdaptiveThresh) PURE; // Methods that compute the direct lighting contribution for objects @@ -2011,9 +2011,9 @@ DECLARE_INTERFACE_(ID3DXPRTEngine, IUnknown) // // SHOrder - order of SH to use // pDataOut - PRT buffer that is generated. Can be single channel - STDMETHOD(ComputeDirectLightingSH)(THIS_ UINT SHOrder, + STDMETHOD(ComputeDirectLightingSH)(THIS_ UINT SHOrder, LPD3DXPRTBUFFER pDataOut) PURE; - + // Adaptive variant of above function. This will refine the mesh // generating new vertices/faces to approximate the PRT signal // more faithfully. @@ -2023,15 +2023,15 @@ DECLARE_INTERFACE_(ID3DXPRTEngine, IUnknown) // MinEdgeLength - minimum edge length that will be generated // if value is too small a fairly conservative model dependent value // is used - // MaxSubdiv - maximum subdivision level, if 0 is specified it + // MaxSubdiv - maximum subdivision level, if 0 is specified it // will default to 4 // pDataOut - PRT buffer that is generated. Can be single channel. - STDMETHOD(ComputeDirectLightingSHAdaptive)(THIS_ UINT SHOrder, + STDMETHOD(ComputeDirectLightingSHAdaptive)(THIS_ UINT SHOrder, FLOAT AdaptiveThresh, FLOAT MinEdgeLength, UINT MaxSubdiv, LPD3DXPRTBUFFER pDataOut) PURE; - + // Function that computes the direct lighting contribution for objects // light is always represented using spherical harmonics (SH) // This is done on the GPU and is much faster then using the CPU. @@ -2068,7 +2068,7 @@ DECLARE_INTERFACE_(ID3DXPRTEngine, IUnknown) // pDataIn - input data (previous bounce) // pDataOut - result of subsurface scattering simulation // pDataTotal - [optional] results can be summed into this buffer - STDMETHOD(ComputeSS)(THIS_ LPD3DXPRTBUFFER pDataIn, + STDMETHOD(ComputeSS)(THIS_ LPD3DXPRTBUFFER pDataIn, LPD3DXPRTBUFFER pDataOut, LPD3DXPRTBUFFER pDataTotal) PURE; // Adaptive version of ComputeSS. @@ -2079,11 +2079,11 @@ DECLARE_INTERFACE_(ID3DXPRTEngine, IUnknown) // MinEdgeLength - minimum edge length that will be generated // if value is too small a fairly conservative model dependent value // is used - // MaxSubdiv - maximum subdivision level, if 0 is specified it - // will default to 4 + // MaxSubdiv - maximum subdivision level, if 0 is specified it + // will default to 4 // pDataOut - result of subsurface scattering simulation // pDataTotal - [optional] results can be summed into this buffer - STDMETHOD(ComputeSSAdaptive)(THIS_ LPD3DXPRTBUFFER pDataIn, + STDMETHOD(ComputeSSAdaptive)(THIS_ LPD3DXPRTBUFFER pDataIn, FLOAT AdaptiveThresh, FLOAT MinEdgeLength, UINT MaxSubdiv, @@ -2093,7 +2093,7 @@ DECLARE_INTERFACE_(ID3DXPRTEngine, IUnknown) // works for SH based PRT or generic lighting // Albedo is not multiplied by result // - // pDataIn - previous bounces data + // pDataIn - previous bounces data // pDataOut - PRT buffer that is generated // pDataTotal - [optional] can be used to keep a running sum STDMETHOD(ComputeBounce)(THIS_ LPD3DXPRTBUFFER pDataIn, @@ -2102,16 +2102,16 @@ DECLARE_INTERFACE_(ID3DXPRTEngine, IUnknown) // Adaptive version of above function. // - // pDataIn - previous bounces data, can be single channel + // pDataIn - previous bounces data, can be single channel // AdaptiveThresh - threshold for adaptive subdivision (in PRT vector error) // if value is less then 1e-6f, 1e-6f is specified // MinEdgeLength - minimum edge length that will be generated // if value is too small a fairly conservative model dependent value // is used - // MaxSubdiv - maximum subdivision level, if 0 is specified it + // MaxSubdiv - maximum subdivision level, if 0 is specified it // will default to 4 // pDataOut - PRT buffer that is generated - // pDataTotal - [optional] can be used to keep a running sum + // pDataTotal - [optional] can be used to keep a running sum STDMETHOD(ComputeBounceAdaptive)(THIS_ LPD3DXPRTBUFFER pDataIn, FLOAT AdaptiveThresh, FLOAT MinEdgeLength, @@ -2120,7 +2120,7 @@ DECLARE_INTERFACE_(ID3DXPRTEngine, IUnknown) LPD3DXPRTBUFFER pDataTotal) PURE; // Computes projection of distant SH radiance into a local SH radiance - // function. This models how direct lighting is attenuated by the + // function. This models how direct lighting is attenuated by the // scene and is a form of "neighborhood transfer." The result is // a linear operator (matrix) at every sample point, if you multiply // this matrix by the distant SH lighting coefficients you get an @@ -2129,24 +2129,24 @@ DECLARE_INTERFACE_(ID3DXPRTEngine, IUnknown) // than be projected into another basis or used with any rendering // technique that uses spherical harmonics as input. // SetSamplingInfo must be called with TRUE for UseSphere and - // FALSE for UseCosine before this method is called. - // Generates SHOrderIn*SHOrderIn*SHOrderOut*SHOrderOut scalars + // FALSE for UseCosine before this method is called. + // Generates SHOrderIn*SHOrderIn*SHOrderOut*SHOrderOut scalars // per channel at each sample location. // // SHOrderIn - Order of the SH representation of distant lighting // SHOrderOut - Order of the SH representation of local lighting // NumVolSamples - Number of sample locations // pSampleLocs - position of sample locations - // pDataOut - PRT Buffer that will store output results - STDMETHOD(ComputeVolumeSamplesDirectSH)(THIS_ UINT SHOrderIn, - UINT SHOrderOut, + // pDataOut - PRT Buffer that will store output results + STDMETHOD(ComputeVolumeSamplesDirectSH)(THIS_ UINT SHOrderIn, + UINT SHOrderOut, UINT NumVolSamples, CONST D3DXVECTOR3 *pSampleLocs, LPD3DXPRTBUFFER pDataOut) PURE; - + // At each sample location computes a linear operator (matrix) that maps // the representation of source radiance (NumCoeffs in pSurfDataIn) - // into a local incident radiance function approximated with spherical + // into a local incident radiance function approximated with spherical // harmonics. For example if a light map data is specified in pSurfDataIn // the result is an SH representation of the flow of light at each sample // point. If PRT data for an outdoor scene is used, each sample point @@ -2155,7 +2155,7 @@ DECLARE_INTERFACE_(ID3DXPRTEngine, IUnknown) // ComputeVolumeSamplesDirectSH this gives the complete representation for // how light arrives at each sample point parameterized by distant lighting. // SetSamplingInfo must be called with TRUE for UseSphere and - // FALSE for UseCosine before this method is called. + // FALSE for UseCosine before this method is called. // Generates pSurfDataIn->NumCoeffs()*SHOrder*SHOrder scalars // per channel at each sample location. // @@ -2164,8 +2164,8 @@ DECLARE_INTERFACE_(ID3DXPRTEngine, IUnknown) // NumVolSamples - Number of sample locations // pSampleLocs - position of sample locations // pDataOut - PRT Buffer that will store output results - STDMETHOD(ComputeVolumeSamples)(THIS_ LPD3DXPRTBUFFER pSurfDataIn, - UINT SHOrder, + STDMETHOD(ComputeVolumeSamples)(THIS_ LPD3DXPRTBUFFER pSurfDataIn, + UINT SHOrder, UINT NumVolSamples, CONST D3DXVECTOR3 *pSampleLocs, LPD3DXPRTBUFFER pDataOut) PURE; @@ -2185,7 +2185,7 @@ DECLARE_INTERFACE_(ID3DXPRTEngine, IUnknown) LPD3DXPRTBUFFER pDataOut) PURE; - // given the solution for PRT or light maps, computes transfer vector at arbitrary + // given the solution for PRT or light maps, computes transfer vector at arbitrary // position/normal pairs in space // // pSurfDataIn - input data @@ -2204,21 +2204,21 @@ DECLARE_INTERFACE_(ID3DXPRTEngine, IUnknown) // Frees temporary data structures that can be created for subsurface scattering // this data is freed when the PRTComputeEngine is freed and is lazily created STDMETHOD(FreeSSData)(THIS) PURE; - + // Frees temporary data structures that can be created for bounce simulations // this data is freed when the PRTComputeEngine is freed and is lazily created STDMETHOD(FreeBounceData)(THIS) PURE; - // This computes the Local Deformable PRT (LDPRT) coefficients relative to the - // per sample normals that minimize error in a least squares sense with respect - // to the input PRT data set. These coefficients can be used with skinned/transformed - // normals to model global effects with dynamic objects. Shading normals can + // This computes the Local Deformable PRT (LDPRT) coefficients relative to the + // per sample normals that minimize error in a least squares sense with respect + // to the input PRT data set. These coefficients can be used with skinned/transformed + // normals to model global effects with dynamic objects. Shading normals can // optionally be solved for - these normals (along with the LDPRT coefficients) can // more accurately represent the PRT signal. The coefficients are for zonal // harmonics oriented in the normal/shading normal direction. // // pDataIn - SH PRT dataset that is input - // SHOrder - Order of SH to compute conv coefficients for + // SHOrder - Order of SH to compute conv coefficients for // pNormOut - Optional array of vectors (passed in) that will be filled with // "shading normals", LDPRT coefficients are optimized for // these normals. This array must be the same size as the number of @@ -2233,7 +2233,7 @@ DECLARE_INTERFACE_(ID3DXPRTEngine, IUnknown) // can be useful when using subsurface scattering // fScale - value to scale each vector in submesh by STDMETHOD(ScaleMeshChunk)(THIS_ UINT uMeshChunk, FLOAT fScale, LPD3DXPRTBUFFER pDataOut) PURE; - + // mutliplies each PRT vector by the albedo - can be used if you want to have the albedo // burned into the dataset, often better not to do this. If this is not done the user // must mutliply the albedo themselves when rendering - just multiply the albedo times @@ -2245,7 +2245,7 @@ DECLARE_INTERFACE_(ID3DXPRTEngine, IUnknown) // // pDataOut - dataset that will get albedo pushed into it STDMETHOD(MultiplyAlbedo)(THIS_ LPD3DXPRTBUFFER pDataOut) PURE; - + // Sets a pointer to an optional call back function that reports back to the // user percentage done and gives them the option of quitting // pCB - pointer to call back function, return S_OK for the simulation @@ -2254,16 +2254,16 @@ DECLARE_INTERFACE_(ID3DXPRTEngine, IUnknown) // will be invoked // lpUserContext - will be passed back to the users call back STDMETHOD(SetCallBack)(THIS_ LPD3DXSHPRTSIMCB pCB, FLOAT Frequency, LPVOID lpUserContext) PURE; - + // Returns TRUE if the ray intersects the mesh, FALSE if it does not. This function // takes into account settings from SetMinMaxIntersection. If the closest intersection // is not needed this function is more efficient compared to the ClosestRayIntersection // method. // pRayPos - origin of ray // pRayDir - normalized ray direction (normalization required for SetMinMax to be meaningful) - + STDMETHOD_(BOOL, ShadowRayIntersects)(THIS_ CONST D3DXVECTOR3 *pRayPos, CONST D3DXVECTOR3 *pRayDir) PURE; - + // Returns TRUE if the ray intersects the mesh, FALSE if it does not. If there is an // intersection the closest face that was intersected and its first two barycentric coordinates // are returned. This function takes into account settings from SetMinMaxIntersection. @@ -2276,7 +2276,7 @@ DECLARE_INTERFACE_(ID3DXPRTEngine, IUnknown) // pU - Barycentric coordinate for vertex 0 // pV - Barycentric coordinate for vertex 1 // pDist - Distance along ray where the intersection occured - + STDMETHOD_(BOOL, ClosestRayIntersects)(THIS_ CONST D3DXVECTOR3 *pRayPos, CONST D3DXVECTOR3 *pRayDir, DWORD *pFaceIndex, FLOAT *pU, FLOAT *pV, FLOAT *pDist) PURE; }; @@ -2308,8 +2308,8 @@ extern "C" { // //============================================================================ -HRESULT WINAPI - D3DXCreatePRTBuffer( +HRESULT WINAPI + D3DXCreatePRTBuffer( UINT NumSamples, UINT NumCoeffs, UINT NumChannels, @@ -2338,7 +2338,7 @@ HRESULT WINAPI //============================================================================ HRESULT WINAPI - D3DXCreatePRTBufferTex( + D3DXCreatePRTBufferTex( UINT Width, UINT Height, UINT NumCoeffs, @@ -2361,12 +2361,12 @@ HRESULT WINAPI HRESULT WINAPI D3DXLoadPRTBufferFromFileA( - LPCSTR pFilename, + LPCSTR pFilename, LPD3DXPRTBUFFER* ppBuffer); - + HRESULT WINAPI D3DXLoadPRTBufferFromFileW( - LPCWSTR pFilename, + LPCWSTR pFilename, LPD3DXPRTBUFFER* ppBuffer); #ifdef UNICODE @@ -2394,7 +2394,7 @@ HRESULT WINAPI D3DXSavePRTBufferToFileA( LPCSTR pFileName, LPD3DXPRTBUFFER pBuffer); - + HRESULT WINAPI D3DXSavePRTBufferToFileW( LPCWSTR pFileName, @@ -2404,7 +2404,7 @@ HRESULT WINAPI #define D3DXSavePRTBufferToFile D3DXSavePRTBufferToFileW #else #define D3DXSavePRTBufferToFile D3DXSavePRTBufferToFileA -#endif +#endif //============================================================================ @@ -2423,12 +2423,12 @@ HRESULT WINAPI HRESULT WINAPI D3DXLoadPRTCompBufferFromFileA( - LPCSTR pFilename, + LPCSTR pFilename, LPD3DXPRTCOMPBUFFER* ppBuffer); - + HRESULT WINAPI D3DXLoadPRTCompBufferFromFileW( - LPCWSTR pFilename, + LPCWSTR pFilename, LPD3DXPRTCOMPBUFFER* ppBuffer); #ifdef UNICODE @@ -2455,7 +2455,7 @@ HRESULT WINAPI D3DXSavePRTCompBufferToFileA( LPCSTR pFileName, LPD3DXPRTCOMPBUFFER pBuffer); - + HRESULT WINAPI D3DXSavePRTCompBufferToFileW( LPCWSTR pFileName, @@ -2465,7 +2465,7 @@ HRESULT WINAPI #define D3DXSavePRTCompBufferToFile D3DXSavePRTCompBufferToFileW #else #define D3DXSavePRTCompBufferToFile D3DXSavePRTCompBufferToFileA -#endif +#endif //============================================================================ // @@ -2496,10 +2496,10 @@ HRESULT WINAPI HRESULT WINAPI D3DXCreatePRTCompBuffer( D3DXSHCOMPRESSQUALITYTYPE Quality, - UINT NumClusters, + UINT NumClusters, UINT NumPCA, LPD3DXSHPRTSIMCB pCB, - LPVOID lpUserContext, + LPVOID lpUserContext, LPD3DXPRTBUFFER pBufferIn, LPD3DXPRTCOMPBUFFER *ppBufferOut ); @@ -2527,11 +2527,11 @@ HRESULT WINAPI //============================================================================ -HRESULT WINAPI - D3DXCreateTextureGutterHelper( +HRESULT WINAPI + D3DXCreateTextureGutterHelper( UINT Width, UINT Height, - LPD3DXMESH pMesh, + LPD3DXMESH pMesh, FLOAT GutterSize, LPD3DXTEXTUREGUTTERHELPER* ppBuffer); @@ -2560,12 +2560,12 @@ HRESULT WINAPI //============================================================================ -HRESULT WINAPI - D3DXCreatePRTEngine( +HRESULT WINAPI + D3DXCreatePRTEngine( LPD3DXMESH pMesh, DWORD *pAdjacency, BOOL ExtractUVs, - LPD3DXMESH pBlockerMesh, + LPD3DXMESH pBlockerMesh, LPD3DXPRTENGINE* ppEngine); //============================================================================ @@ -2602,15 +2602,15 @@ HRESULT WINAPI //============================================================================ -HRESULT WINAPI +HRESULT WINAPI D3DXConcatenateMeshes( - LPD3DXMESH *ppMeshes, - UINT NumMeshes, - DWORD Options, - CONST D3DXMATRIX *pGeomXForms, - CONST D3DXMATRIX *pTextureXForms, + LPD3DXMESH *ppMeshes, + UINT NumMeshes, + DWORD Options, + CONST D3DXMATRIX *pGeomXForms, + CONST D3DXMATRIX *pTextureXForms, CONST D3DVERTEXELEMENT9 *pDecl, - LPDIRECT3DDEVICE9 pD3DDevice, + LPDIRECT3DDEVICE9 pD3DDevice, LPD3DXMESH *ppMeshOut); //============================================================================ @@ -2636,16 +2636,16 @@ HRESULT WINAPI // that corresponding cluster was assigned to // pNumSuperClusters // Returns the number of super clusters allocated -// +// //============================================================================ -HRESULT WINAPI +HRESULT WINAPI D3DXSHPRTCompSuperCluster( - UINT *pClusterIDs, - LPD3DXMESH pScene, - UINT MaxNumClusters, + UINT *pClusterIDs, + LPD3DXMESH pScene, + UINT MaxNumClusters, UINT NumClusters, - UINT *pSuperClusterIDs, + UINT *pSuperClusterIDs, UINT *pNumSuperClusters); //============================================================================ @@ -2657,7 +2657,7 @@ HRESULT WINAPI // to split the mesh into a group of faces/vertices per super cluster. // Each super cluster contains all of the faces that contain any vertex // classified in one of its clusters. All of the vertices connected to this -// set of faces are also included with the returned array ppVertStatus +// set of faces are also included with the returned array ppVertStatus // indicating whether or not the vertex belongs to the supercluster. // // Parameters: @@ -2680,12 +2680,12 @@ HRESULT WINAPI // NumFaces // Number of faces in the original mesh (pInputIB is 3 times this length) // ppIBData -// LPD3DXBUFFER holds raw index buffer that will contain the resulting split faces. +// LPD3DXBUFFER holds raw index buffer that will contain the resulting split faces. // Format determined by bIBIs32Bit. Allocated by function // pIBDataLength // Length of ppIBData, assigned in function // OutputIBIs32Bit -// Indicates whether the output index buffer is to be 32-bit (otherwise +// Indicates whether the output index buffer is to be 32-bit (otherwise // 16-bit is assumed) // ppFaceRemap // LPD3DXBUFFER mapping of each face in ppIBData to original faces. Length is @@ -2703,33 +2703,33 @@ HRESULT WINAPI // //============================================================================ -HRESULT WINAPI +HRESULT WINAPI D3DXSHPRTCompSplitMeshSC( - UINT *pClusterIDs, - UINT NumVertices, - UINT NumClusters, - UINT *pSuperClusterIDs, + UINT *pClusterIDs, + UINT NumVertices, + UINT NumClusters, + UINT *pSuperClusterIDs, UINT NumSuperClusters, - LPVOID pInputIB, - BOOL InputIBIs32Bit, + LPVOID pInputIB, + BOOL InputIBIs32Bit, UINT NumFaces, - LPD3DXBUFFER *ppIBData, - UINT *pIBDataLength, - BOOL OutputIBIs32Bit, - LPD3DXBUFFER *ppFaceRemap, - LPD3DXBUFFER *ppVertData, - UINT *pVertDataLength, + LPD3DXBUFFER *ppIBData, + UINT *pIBDataLength, + BOOL OutputIBIs32Bit, + LPD3DXBUFFER *ppFaceRemap, + LPD3DXBUFFER *ppVertData, + UINT *pVertDataLength, UINT *pSCClusterList, D3DXSHPRTSPLITMESHCLUSTERDATA *pSCData); - - + + #ifdef __cplusplus } #endif //__cplusplus ////////////////////////////////////////////////////////////////////////////// // -// Definitions of .X file templates used by mesh load/save functions +// Definitions of .X file templates used by mesh load/save functions // that are not RM standard // ////////////////////////////////////////////////////////////////////////////// @@ -2739,35 +2739,35 @@ DEFINE_GUID(DXFILEOBJ_XSkinMeshHeader, 0x3cf169ce, 0xff7c, 0x44ab, 0x93, 0xc0, 0xf7, 0x8f, 0x62, 0xd1, 0x72, 0xe2); // {B8D65549-D7C9-4995-89CF-53A9A8B031E3} -DEFINE_GUID(DXFILEOBJ_VertexDuplicationIndices, +DEFINE_GUID(DXFILEOBJ_VertexDuplicationIndices, 0xb8d65549, 0xd7c9, 0x4995, 0x89, 0xcf, 0x53, 0xa9, 0xa8, 0xb0, 0x31, 0xe3); // {A64C844A-E282-4756-8B80-250CDE04398C} -DEFINE_GUID(DXFILEOBJ_FaceAdjacency, +DEFINE_GUID(DXFILEOBJ_FaceAdjacency, 0xa64c844a, 0xe282, 0x4756, 0x8b, 0x80, 0x25, 0xc, 0xde, 0x4, 0x39, 0x8c); // {6F0D123B-BAD2-4167-A0D0-80224F25FABB} -DEFINE_GUID(DXFILEOBJ_SkinWeights, +DEFINE_GUID(DXFILEOBJ_SkinWeights, 0x6f0d123b, 0xbad2, 0x4167, 0xa0, 0xd0, 0x80, 0x22, 0x4f, 0x25, 0xfa, 0xbb); // {A3EB5D44-FC22-429d-9AFB-3221CB9719A6} -DEFINE_GUID(DXFILEOBJ_Patch, +DEFINE_GUID(DXFILEOBJ_Patch, 0xa3eb5d44, 0xfc22, 0x429d, 0x9a, 0xfb, 0x32, 0x21, 0xcb, 0x97, 0x19, 0xa6); // {D02C95CC-EDBA-4305-9B5D-1820D7704BBF} -DEFINE_GUID(DXFILEOBJ_PatchMesh, +DEFINE_GUID(DXFILEOBJ_PatchMesh, 0xd02c95cc, 0xedba, 0x4305, 0x9b, 0x5d, 0x18, 0x20, 0xd7, 0x70, 0x4b, 0xbf); // {B9EC94E1-B9A6-4251-BA18-94893F02C0EA} -DEFINE_GUID(DXFILEOBJ_PatchMesh9, +DEFINE_GUID(DXFILEOBJ_PatchMesh9, 0xb9ec94e1, 0xb9a6, 0x4251, 0xba, 0x18, 0x94, 0x89, 0x3f, 0x2, 0xc0, 0xea); // {B6C3E656-EC8B-4b92-9B62-681659522947} -DEFINE_GUID(DXFILEOBJ_PMInfo, +DEFINE_GUID(DXFILEOBJ_PMInfo, 0xb6c3e656, 0xec8b, 0x4b92, 0x9b, 0x62, 0x68, 0x16, 0x59, 0x52, 0x29, 0x47); // {917E0427-C61E-4a14-9C64-AFE65F9E9844} -DEFINE_GUID(DXFILEOBJ_PMAttributeRange, +DEFINE_GUID(DXFILEOBJ_PMAttributeRange, 0x917e0427, 0xc61e, 0x4a14, 0x9c, 0x64, 0xaf, 0xe6, 0x5f, 0x9e, 0x98, 0x44); // {574CCC14-F0B3-4333-822D-93E8A8A08E4C} @@ -2775,35 +2775,35 @@ DEFINE_GUID(DXFILEOBJ_PMVSplitRecord, 0x574ccc14, 0xf0b3, 0x4333, 0x82, 0x2d, 0x93, 0xe8, 0xa8, 0xa0, 0x8e, 0x4c); // {B6E70A0E-8EF9-4e83-94AD-ECC8B0C04897} -DEFINE_GUID(DXFILEOBJ_FVFData, +DEFINE_GUID(DXFILEOBJ_FVFData, 0xb6e70a0e, 0x8ef9, 0x4e83, 0x94, 0xad, 0xec, 0xc8, 0xb0, 0xc0, 0x48, 0x97); // {F752461C-1E23-48f6-B9F8-8350850F336F} -DEFINE_GUID(DXFILEOBJ_VertexElement, +DEFINE_GUID(DXFILEOBJ_VertexElement, 0xf752461c, 0x1e23, 0x48f6, 0xb9, 0xf8, 0x83, 0x50, 0x85, 0xf, 0x33, 0x6f); // {BF22E553-292C-4781-9FEA-62BD554BDD93} -DEFINE_GUID(DXFILEOBJ_DeclData, +DEFINE_GUID(DXFILEOBJ_DeclData, 0xbf22e553, 0x292c, 0x4781, 0x9f, 0xea, 0x62, 0xbd, 0x55, 0x4b, 0xdd, 0x93); // {F1CFE2B3-0DE3-4e28-AFA1-155A750A282D} -DEFINE_GUID(DXFILEOBJ_EffectFloats, +DEFINE_GUID(DXFILEOBJ_EffectFloats, 0xf1cfe2b3, 0xde3, 0x4e28, 0xaf, 0xa1, 0x15, 0x5a, 0x75, 0xa, 0x28, 0x2d); // {D55B097E-BDB6-4c52-B03D-6051C89D0E42} -DEFINE_GUID(DXFILEOBJ_EffectString, +DEFINE_GUID(DXFILEOBJ_EffectString, 0xd55b097e, 0xbdb6, 0x4c52, 0xb0, 0x3d, 0x60, 0x51, 0xc8, 0x9d, 0xe, 0x42); // {622C0ED0-956E-4da9-908A-2AF94F3CE716} -DEFINE_GUID(DXFILEOBJ_EffectDWord, +DEFINE_GUID(DXFILEOBJ_EffectDWord, 0x622c0ed0, 0x956e, 0x4da9, 0x90, 0x8a, 0x2a, 0xf9, 0x4f, 0x3c, 0xe7, 0x16); // {3014B9A0-62F5-478c-9B86-E4AC9F4E418B} -DEFINE_GUID(DXFILEOBJ_EffectParamFloats, +DEFINE_GUID(DXFILEOBJ_EffectParamFloats, 0x3014b9a0, 0x62f5, 0x478c, 0x9b, 0x86, 0xe4, 0xac, 0x9f, 0x4e, 0x41, 0x8b); // {1DBC4C88-94C1-46ee-9076-2C28818C9481} -DEFINE_GUID(DXFILEOBJ_EffectParamString, +DEFINE_GUID(DXFILEOBJ_EffectParamString, 0x1dbc4c88, 0x94c1, 0x46ee, 0x90, 0x76, 0x2c, 0x28, 0x81, 0x8c, 0x94, 0x81); // {E13963BC-AE51-4c5d-B00F-CFA3A9D97CE5} @@ -2811,15 +2811,15 @@ DEFINE_GUID(DXFILEOBJ_EffectParamDWord, 0xe13963bc, 0xae51, 0x4c5d, 0xb0, 0xf, 0xcf, 0xa3, 0xa9, 0xd9, 0x7c, 0xe5); // {E331F7E4-0559-4cc2-8E99-1CEC1657928F} -DEFINE_GUID(DXFILEOBJ_EffectInstance, +DEFINE_GUID(DXFILEOBJ_EffectInstance, 0xe331f7e4, 0x559, 0x4cc2, 0x8e, 0x99, 0x1c, 0xec, 0x16, 0x57, 0x92, 0x8f); // {9E415A43-7BA6-4a73-8743-B73D47E88476} -DEFINE_GUID(DXFILEOBJ_AnimTicksPerSecond, +DEFINE_GUID(DXFILEOBJ_AnimTicksPerSecond, 0x9e415a43, 0x7ba6, 0x4a73, 0x87, 0x43, 0xb7, 0x3d, 0x47, 0xe8, 0x84, 0x76); // {7F9B00B3-F125-4890-876E-1CFFBF697C4D} -DEFINE_GUID(DXFILEOBJ_CompressedAnimationSet, +DEFINE_GUID(DXFILEOBJ_CompressedAnimationSet, 0x7f9b00b3, 0xf125, 0x4890, 0x87, 0x6e, 0x1c, 0x42, 0xbf, 0x69, 0x7c, 0x4d); #pragma pack(push, 1) @@ -3001,5 +3001,5 @@ typedef struct _XFILECOMPRESSEDANIMATIONSET DWORD nAttributeMispredicts; \ array DWORD attributeMispredicts[nAttributeMispredicts]; \ } " - + #endif //__D3DX9MESH_H__ diff --git a/gfx/include/d3d9/d3dx9shader.h b/gfx/include/d3d9/d3dx9shader.h index 74e40cfc80..174ec6667b 100644 --- a/gfx/include/d3d9/d3dx9shader.h +++ b/gfx/include/d3d9/d3dx9shader.h @@ -187,7 +187,7 @@ typedef interface ID3DXConstantTable ID3DXConstantTable; typedef interface ID3DXConstantTable *LPD3DXCONSTANTTABLE; // {AB3C758F-093E-4356-B762-4DB18F1B3A01} -DEFINE_GUID(IID_ID3DXConstantTable, +DEFINE_GUID(IID_ID3DXConstantTable, 0xab3c758f, 0x93e, 0x4356, 0xb7, 0x62, 0x4d, 0xb1, 0x8f, 0x1b, 0x3a, 0x1); @@ -243,7 +243,7 @@ typedef interface ID3DXTextureShader ID3DXTextureShader; typedef interface ID3DXTextureShader *LPD3DXTEXTURESHADER; // {3E3D67F8-AA7A-405d-A857-BA01D4758426} -DEFINE_GUID(IID_ID3DXTextureShader, +DEFINE_GUID(IID_ID3DXTextureShader, 0x3e3d67f8, 0xaa7a, 0x405d, 0xa8, 0x57, 0xba, 0x1, 0xd4, 0x75, 0x84, 0x26); #undef INTERFACE @@ -460,9 +460,9 @@ HRESULT WINAPI HRESULT WINAPI D3DXDisassembleShader( - CONST DWORD* pShader, - BOOL EnableColorCode, - LPCSTR pComments, + CONST DWORD* pShader, + BOOL EnableColorCode, + LPCSTR pComments, LPD3DXBUFFER* ppDisassembly); LPCSTR WINAPI @@ -519,18 +519,18 @@ HRESULT WINAPI HRESULT WINAPI D3DXCreateTextureShader( - CONST DWORD* pFunction, + CONST DWORD* pFunction, LPD3DXTEXTURESHADER* ppTextureShader); -HRESULT WINAPI +HRESULT WINAPI D3DXPreprocessShaderFromFileA( LPCSTR pSrcFile, CONST D3DXMACRO* pDefines, LPD3DXINCLUDE pInclude, LPD3DXBUFFER* ppShaderText, LPD3DXBUFFER* ppErrorMsgs); - -HRESULT WINAPI + +HRESULT WINAPI D3DXPreprocessShaderFromFileW( LPCWSTR pSrcFile, CONST D3DXMACRO* pDefines, @@ -543,8 +543,8 @@ HRESULT WINAPI #else #define D3DXPreprocessShaderFromFile D3DXPreprocessShaderFromFileA #endif - -HRESULT WINAPI + +HRESULT WINAPI D3DXPreprocessShaderFromResourceA( HMODULE hSrcModule, LPCSTR pSrcResource, @@ -553,7 +553,7 @@ HRESULT WINAPI LPD3DXBUFFER* ppShaderText, LPD3DXBUFFER* ppErrorMsgs); -HRESULT WINAPI +HRESULT WINAPI D3DXPreprocessShaderFromResourceW( HMODULE hSrcModule, LPCWSTR pSrcResource, @@ -568,7 +568,7 @@ HRESULT WINAPI #define D3DXPreprocessShaderFromResource D3DXPreprocessShaderFromResourceA #endif -HRESULT WINAPI +HRESULT WINAPI D3DXPreprocessShader( LPCSTR pSrcData, UINT SrcDataSize, @@ -603,7 +603,7 @@ typedef struct _D3DXSHADER_CONSTANTTABLE DWORD Constants; // number of constants DWORD ConstantInfo; // D3DXSHADER_CONSTANTINFO[Constants] offset DWORD Flags; // flags shader was compiled with - DWORD Target; // LPCSTR offset + DWORD Target; // LPCSTR offset } D3DXSHADER_CONSTANTTABLE, *LPD3DXSHADER_CONSTANTTABLE; diff --git a/gfx/include/d3d9/d3dx9shape.h b/gfx/include/d3d9/d3dx9shape.h index 9d1ff52e7f..cc0c618c5a 100644 --- a/gfx/include/d3d9/d3dx9shape.h +++ b/gfx/include/d3d9/d3dx9shape.h @@ -16,39 +16,39 @@ extern "C" { #endif -HRESULT WINAPI +HRESULT WINAPI D3DXCreatePolygon( LPDIRECT3DDEVICE9 pDevice, - FLOAT Length, - UINT Sides, + FLOAT Length, + UINT Sides, LPD3DXMESH* ppMesh, LPD3DXBUFFER* ppAdjacency); -HRESULT WINAPI +HRESULT WINAPI D3DXCreateBox( - LPDIRECT3DDEVICE9 pDevice, + LPDIRECT3DDEVICE9 pDevice, FLOAT Width, FLOAT Height, FLOAT Depth, LPD3DXMESH* ppMesh, LPD3DXBUFFER* ppAdjacency); -HRESULT WINAPI +HRESULT WINAPI D3DXCreateCylinder( LPDIRECT3DDEVICE9 pDevice, - FLOAT Radius1, - FLOAT Radius2, - FLOAT Length, - UINT Slices, - UINT Stacks, + FLOAT Radius1, + FLOAT Radius2, + FLOAT Length, + UINT Slices, + UINT Stacks, LPD3DXMESH* ppMesh, LPD3DXBUFFER* ppAdjacency); HRESULT WINAPI D3DXCreateSphere( - LPDIRECT3DDEVICE9 pDevice, - FLOAT Radius, - UINT Slices, + LPDIRECT3DDEVICE9 pDevice, + FLOAT Radius, + UINT Slices, UINT Stacks, LPD3DXMESH* ppMesh, LPD3DXBUFFER* ppAdjacency); @@ -57,9 +57,9 @@ HRESULT WINAPI D3DXCreateTorus( LPDIRECT3DDEVICE9 pDevice, FLOAT InnerRadius, - FLOAT OuterRadius, + FLOAT OuterRadius, UINT Sides, - UINT Rings, + UINT Rings, LPD3DXMESH* ppMesh, LPD3DXBUFFER* ppAdjacency); diff --git a/gfx/include/d3d9/d3dx9tex.h b/gfx/include/d3d9/d3dx9tex.h index ec29c0187a..4de1ead96c 100644 --- a/gfx/include/d3d9/d3dx9tex.h +++ b/gfx/include/d3d9/d3dx9tex.h @@ -61,12 +61,12 @@ typedef enum _D3DXIMAGE_FILEFORMAT } D3DXIMAGE_FILEFORMAT; -typedef VOID (WINAPI *LPD3DXFILL2D)(D3DXVECTOR4 *pOut, +typedef VOID (WINAPI *LPD3DXFILL2D)(D3DXVECTOR4 *pOut, CONST D3DXVECTOR2 *pTexCoord, CONST D3DXVECTOR2 *pTexelSize, LPVOID pData); -typedef VOID (WINAPI *LPD3DXFILL3D)(D3DXVECTOR4 *pOut, +typedef VOID (WINAPI *LPD3DXFILL3D)(D3DXVECTOR4 *pOut, CONST D3DXVECTOR3 *pTexCoord, CONST D3DXVECTOR3 *pTexelSize, LPVOID pData); - + typedef struct _D3DXIMAGE_INFO { UINT Width; @@ -974,7 +974,7 @@ HRESULT WINAPI LPD3DXFILL3D pFunction, LPVOID pData); -HRESULT WINAPI +HRESULT WINAPI D3DXFillTextureTX( LPDIRECT3DTEXTURE9 pTexture, LPD3DXTEXTURESHADER pTextureShader); @@ -984,9 +984,9 @@ HRESULT WINAPI D3DXFillCubeTextureTX( LPDIRECT3DCUBETEXTURE9 pCubeTexture, LPD3DXTEXTURESHADER pTextureShader); - - -HRESULT WINAPI + + +HRESULT WINAPI D3DXFillVolumeTextureTX( LPDIRECT3DVOLUMETEXTURE9 pVolumeTexture, LPD3DXTEXTURESHADER pTextureShader); diff --git a/gfx/include/d3d9/d3dx9xof.h b/gfx/include/d3d9/d3dx9xof.h index 6b47acd273..0ad3a1250f 100644 --- a/gfx/include/d3d9/d3dx9xof.h +++ b/gfx/include/d3d9/d3dx9xof.h @@ -58,23 +58,23 @@ typedef struct _D3DXF_FILELOADMEMORY #if defined( _WIN32 ) && !defined( _NO_COM ) // {cef08cf9-7b4f-4429-9624-2a690a933201} -DEFINE_GUID( IID_ID3DXFile, +DEFINE_GUID( IID_ID3DXFile, 0xcef08cf9, 0x7b4f, 0x4429, 0x96, 0x24, 0x2a, 0x69, 0x0a, 0x93, 0x32, 0x01 ); // {cef08cfa-7b4f-4429-9624-2a690a933201} -DEFINE_GUID( IID_ID3DXFileSaveObject, +DEFINE_GUID( IID_ID3DXFileSaveObject, 0xcef08cfa, 0x7b4f, 0x4429, 0x96, 0x24, 0x2a, 0x69, 0x0a, 0x93, 0x32, 0x01 ); // {cef08cfb-7b4f-4429-9624-2a690a933201} -DEFINE_GUID( IID_ID3DXFileSaveData, +DEFINE_GUID( IID_ID3DXFileSaveData, 0xcef08cfb, 0x7b4f, 0x4429, 0x96, 0x24, 0x2a, 0x69, 0x0a, 0x93, 0x32, 0x01 ); // {cef08cfc-7b4f-4429-9624-2a690a933201} -DEFINE_GUID( IID_ID3DXFileEnumObject, +DEFINE_GUID( IID_ID3DXFileEnumObject, 0xcef08cfc, 0x7b4f, 0x4429, 0x96, 0x24, 0x2a, 0x69, 0x0a, 0x93, 0x32, 0x01 ); // {cef08cfd-7b4f-4429-9624-2a690a933201} -DEFINE_GUID( IID_ID3DXFileData, +DEFINE_GUID( IID_ID3DXFileData, 0xcef08cfd, 0x7b4f, 0x4429, 0x96, 0x24, 0x2a, 0x69, 0x0a, 0x93, 0x32, 0x01 ); #endif // defined( _WIN32 ) && !defined( _NO_COM ) @@ -131,7 +131,7 @@ DECLARE_INTERFACE_( ID3DXFile, IUnknown ) STDMETHOD( QueryInterface )( THIS_ REFIID, LPVOID* ) PURE; STDMETHOD_( ULONG, AddRef )( THIS ) PURE; STDMETHOD_( ULONG, Release )( THIS ) PURE; - + STDMETHOD( CreateEnumObject )( THIS_ LPCVOID, D3DXF_FILELOADOPTIONS, ID3DXFileEnumObject** ) PURE; STDMETHOD( CreateSaveObject )( THIS_ LPCVOID, D3DXF_FILESAVEOPTIONS, @@ -152,7 +152,7 @@ DECLARE_INTERFACE_( ID3DXFileSaveObject, IUnknown ) STDMETHOD( QueryInterface )( THIS_ REFIID, LPVOID* ) PURE; STDMETHOD_( ULONG, AddRef )( THIS ) PURE; STDMETHOD_( ULONG, Release )( THIS ) PURE; - + STDMETHOD( GetFile )( THIS_ ID3DXFile** ) PURE; STDMETHOD( AddDataObject )( THIS_ REFGUID, LPCSTR, CONST GUID*, SIZE_T, LPCVOID, ID3DXFileSaveData** ) PURE; @@ -171,7 +171,7 @@ DECLARE_INTERFACE_( ID3DXFileSaveData, IUnknown ) STDMETHOD( QueryInterface )( THIS_ REFIID, LPVOID* ) PURE; STDMETHOD_( ULONG, AddRef )( THIS ) PURE; STDMETHOD_( ULONG, Release )( THIS ) PURE; - + STDMETHOD( GetSave )( THIS_ ID3DXFileSaveObject** ) PURE; STDMETHOD( GetName )( THIS_ LPSTR, SIZE_T* ) PURE; STDMETHOD( GetId )( THIS_ LPGUID ) PURE; @@ -193,7 +193,7 @@ DECLARE_INTERFACE_( ID3DXFileEnumObject, IUnknown ) STDMETHOD( QueryInterface )( THIS_ REFIID, LPVOID* ) PURE; STDMETHOD_( ULONG, AddRef )( THIS ) PURE; STDMETHOD_( ULONG, Release )( THIS ) PURE; - + STDMETHOD( GetFile )( THIS_ ID3DXFile** ) PURE; STDMETHOD( GetChildren )( THIS_ SIZE_T* ) PURE; STDMETHOD( GetChild )( THIS_ SIZE_T, ID3DXFileData** ) PURE; @@ -213,7 +213,7 @@ DECLARE_INTERFACE_( ID3DXFileData, IUnknown ) STDMETHOD( QueryInterface )( THIS_ REFIID, LPVOID* ) PURE; STDMETHOD_( ULONG, AddRef )( THIS ) PURE; STDMETHOD_( ULONG, Release )( THIS ) PURE; - + STDMETHOD( GetEnum )( THIS_ ID3DXFileEnumObject** ) PURE; STDMETHOD( GetName )( THIS_ LPSTR, SIZE_T* ) PURE; STDMETHOD( GetId )( THIS_ LPGUID ) PURE; diff --git a/gfx/include/d3d9caps.h b/gfx/include/d3d9caps.h index adc3fb1f8d..cd89f29450 100644 --- a/gfx/include/d3d9caps.h +++ b/gfx/include/d3d9caps.h @@ -107,14 +107,14 @@ typedef struct _D3DCONTENTPROTECTIONCAPS #define D3DCPCAPS_SEQUENTIAL_CTR_IV 0x00000100 #define D3DCPCAPS_ENCRYPTSLICEDATAONLY 0x00000200 -DEFINE_GUID(D3DCRYPTOTYPE_AES128_CTR, +DEFINE_GUID(D3DCRYPTOTYPE_AES128_CTR, 0x9b6bd711, 0x4f74, 0x41c9, 0x9e, 0x7b, 0xb, 0xe2, 0xd7, 0xd9, 0x3b, 0x4f); -DEFINE_GUID(D3DCRYPTOTYPE_PROPRIETARY, +DEFINE_GUID(D3DCRYPTOTYPE_PROPRIETARY, 0xab4e9afd, 0x1d1c, 0x46e6, 0xa7, 0x2f, 0x8, 0x69, 0x91, 0x7b, 0xd, 0xe8); -DEFINE_GUID(D3DKEYEXCHANGE_RSAES_OAEP, +DEFINE_GUID(D3DKEYEXCHANGE_RSAES_OAEP, 0xc1949895, 0xd72a, 0x4a1d, 0x8e, 0x5d, 0xed, 0x85, 0x7d, 0x17, 0x15, 0x20); -DEFINE_GUID(D3DKEYEXCHANGE_DXVA, +DEFINE_GUID(D3DKEYEXCHANGE_DXVA, 0x43d3775c, 0x38e5, 0x4924, 0x8d, 0x86, 0xd3, 0xfc, 0xcf, 0x15, 0x3e, 0x9b); #endif /* !D3D_DISABLE_9EX */ @@ -211,7 +211,7 @@ typedef struct _D3DCAPS9 DWORD VertexTextureFilterCaps; /* D3DPTFILTERCAPS for IDirect3DTexture9's for texture, used in vertex shaders */ DWORD MaxVShaderInstructionsExecuted; /* maximum number of vertex shader instructions that can be executed */ DWORD MaxPShaderInstructionsExecuted; /* maximum number of pixel shader instructions that can be executed */ - DWORD MaxVertexShader30InstructionSlots; + DWORD MaxVertexShader30InstructionSlots; DWORD MaxPixelShader30InstructionSlots; } D3DCAPS9; @@ -250,7 +250,7 @@ typedef struct _D3DCAPS9 */ #define D3DCAPS3_ALPHA_FULLSCREEN_FLIP_OR_DISCARD 0x00000020L -/* Indicates that the device can perform a gamma correction from +/* Indicates that the device can perform a gamma correction from * a windowed back buffer containing linear content to the sRGB desktop. */ #define D3DCAPS3_LINEAR_TO_SRGB_PRESENTATION 0x00000080L @@ -354,7 +354,7 @@ typedef struct _D3DCAPS9 #define D3DPRASTERCAPS_COLORPERSPECTIVE 0x00400000L /* Device iterates colors perspective correct */ #define D3DPRASTERCAPS_SCISSORTEST 0x01000000L #define D3DPRASTERCAPS_SLOPESCALEDEPTHBIAS 0x02000000L -#define D3DPRASTERCAPS_DEPTHBIAS 0x04000000L +#define D3DPRASTERCAPS_DEPTHBIAS 0x04000000L #define D3DPRASTERCAPS_MULTISAMPLE_TOGGLE 0x08000000L /* @@ -428,7 +428,7 @@ typedef struct _D3DCAPS9 #define D3DPTEXTURECAPS_MIPCUBEMAP 0x00010000L /* Device can do mipmapped cube maps */ #define D3DPTEXTURECAPS_CUBEMAP_POW2 0x00020000L /* Device requires that cubemaps be power-of-2 dimension */ #define D3DPTEXTURECAPS_VOLUMEMAP_POW2 0x00040000L /* Device requires that volume maps be power-of-2 dimension */ -#define D3DPTEXTURECAPS_NOPROJECTEDBUMPENV 0x00200000L /* Device does not support projected bump env lookup operation +#define D3DPTEXTURECAPS_NOPROJECTEDBUMPENV 0x00200000L /* Device does not support projected bump env lookup operation in programmable and fixed function pixel shaders */ /* diff --git a/gfx/include/d3d9types.h b/gfx/include/d3d9types.h index b4b9a94ddf..ef96fda496 100644 --- a/gfx/include/d3d9types.h +++ b/gfx/include/d3d9types.h @@ -1173,7 +1173,7 @@ typedef enum _D3DSHADER_MIN_PRECISION } D3DSHADER_MIN_PRECISION; // If the older D3DSPDM_PARTIALPRECISION is set, // that is equivalent to the whole operation specifying -// D3DMP_16 (on all operands). The two encodings are not +// D3DMP_16 (on all operands). The two encodings are not // used together however. @@ -1451,7 +1451,7 @@ typedef enum _D3DFORMAT /* Binary format indicating that the data has no inherent type */ D3DFMT_BINARYBUFFER = 199, - + #endif // !D3D_DISABLE_9EX /* -- D3D9Ex only */ @@ -1632,7 +1632,7 @@ typedef enum _D3DRESOURCETYPE { #define D3DUSAGE_TEXTAPI (0x10000000L) #define D3DUSAGE_RESTRICTED_CONTENT (0x00000800L) #define D3DUSAGE_RESTRICT_SHARED_RESOURCE (0x00002000L) -#define D3DUSAGE_RESTRICT_SHARED_RESOURCE_DRIVER (0x00001000L) +#define D3DUSAGE_RESTRICT_SHARED_RESOURCE_DRIVER (0x00001000L) #endif /* !D3D_DISABLE_9EX */ /* -- D3D9Ex only */ @@ -1657,7 +1657,7 @@ typedef enum _D3DCUBEMAP_FACES #define D3DLOCK_DISCARD 0x00002000L #define D3DLOCK_NOOVERWRITE 0x00001000L #define D3DLOCK_NOSYSLOCK 0x00000800L -#define D3DLOCK_DONOTWAIT 0x00004000L +#define D3DLOCK_DONOTWAIT 0x00004000L #define D3DLOCK_NO_DIRTY_UPDATE 0x00008000L @@ -1984,7 +1984,7 @@ typedef struct _D3DPRESENTSTATS { typedef enum D3DSCANLINEORDERING { - D3DSCANLINEORDERING_UNKNOWN = 0, + D3DSCANLINEORDERING_UNKNOWN = 0, D3DSCANLINEORDERING_PROGRESSIVE = 1, D3DSCANLINEORDERING_INTERLACED = 2, } D3DSCANLINEORDERING; @@ -2046,14 +2046,14 @@ typedef struct _D3DAUTHENTICATEDCHANNEL_QUERY_INPUT typedef struct _D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT { - D3D_OMAC omac; + D3D_OMAC omac; GUID QueryType; HANDLE hChannel; UINT SequenceNumber; HRESULT ReturnCode; } D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT; -DEFINE_GUID(D3DAUTHENTICATEDQUERY_PROTECTION, +DEFINE_GUID(D3DAUTHENTICATEDQUERY_PROTECTION, 0xa84eb584, 0xc495, 0x48aa, 0xb9, 0x4d, 0x8b, 0xd2, 0xd6, 0xfb, 0xce, 0x5); typedef struct _D3DAUTHENTICATEDCHANNEL_PROTECTION_FLAGS @@ -2062,7 +2062,7 @@ typedef struct _D3DAUTHENTICATEDCHANNEL_PROTECTION_FLAGS { struct { - UINT ProtectionEnabled : 1; + UINT ProtectionEnabled : 1; UINT OverlayOrFullscreenRequired : 1; UINT Reserved : 30; }; @@ -2080,7 +2080,7 @@ typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYPROTECTION_OUTPUT } D3DAUTHENTICATEDCHANNEL_QUERYPROTECTION_OUTPUT; -DEFINE_GUID(D3DAUTHENTICATEDQUERY_CHANNELTYPE, +DEFINE_GUID(D3DAUTHENTICATEDQUERY_CHANNELTYPE, 0xbc1b18a5, 0xb1fb, 0x42ab, 0xbd, 0x94, 0xb5, 0x82, 0x8b, 0x4b, 0xf7, 0xbe); typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYCHANNELTYPE_OUTPUT @@ -2092,7 +2092,7 @@ typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYCHANNELTYPE_OUTPUT } D3DAUTHENTICATEDCHANNEL_QUERYCHANNELTYPE_OUTPUT; -DEFINE_GUID(D3DAUTHENTICATEDQUERY_DEVICEHANDLE, +DEFINE_GUID(D3DAUTHENTICATEDQUERY_DEVICEHANDLE, 0xec1c539d, 0x8cff, 0x4e2a, 0xbc, 0xc4, 0xf5, 0x69, 0x2f, 0x99, 0xf4, 0x80); typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYDEVICEHANDLE_OUTPUT @@ -2104,7 +2104,7 @@ typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYDEVICEHANDLE_OUTPUT } D3DAUTHENTICATEDCHANNEL_QUERYDEVICEHANDLE_OUTPUT; -DEFINE_GUID(D3DAUTHENTICATEDQUERY_CRYPTOSESSION, +DEFINE_GUID(D3DAUTHENTICATEDQUERY_CRYPTOSESSION, 0x2634499e, 0xd018, 0x4d74, 0xac, 0x17, 0x7f, 0x72, 0x40, 0x59, 0x52, 0x8d); typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYCRYPTOSESSION_INPUT @@ -2126,7 +2126,7 @@ typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYCRYPTOSESSION_OUTPUT } D3DAUTHENTICATEDCHANNEL_QUERYCRYPTOSESSION_OUTPUT; -DEFINE_GUID(D3DAUTHENTICATEDQUERY_RESTRICTEDSHAREDRESOURCEPROCESSCOUNT, +DEFINE_GUID(D3DAUTHENTICATEDQUERY_RESTRICTEDSHAREDRESOURCEPROCESSCOUNT, 0xdb207b3, 0x9450, 0x46a6, 0x82, 0xde, 0x1b, 0x96, 0xd4, 0x4f, 0x9c, 0xf2); typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYRESTRICTEDSHAREDRESOURCEPROCESSCOUNT_OUTPUT @@ -2138,7 +2138,7 @@ typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYRESTRICTEDSHAREDRESOURCEPROCESSCOUN } D3DAUTHENTICATEDCHANNEL_QUERYRESTRICTEDSHAREDRESOURCEPROCESSCOUNT_OUTPUT; -DEFINE_GUID(D3DAUTHENTICATEDQUERY_RESTRICTEDSHAREDRESOURCEPROCESS, +DEFINE_GUID(D3DAUTHENTICATEDQUERY_RESTRICTEDSHAREDRESOURCEPROCESS, 0x649bbadb, 0xf0f4, 0x4639, 0xa1, 0x5b, 0x24, 0x39, 0x3f, 0xc3, 0xab, 0xac); typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYRESTRICTEDSHAREDRESOURCEPROCESS_INPUT @@ -2167,7 +2167,7 @@ typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYRESTRICTEDSHAREDRESOURCEPROCESS_OUT } D3DAUTHENTICATEDCHANNEL_QUERYRESTRICTEDSHAREDRESOURCEPROCESS_OUTPUT; -DEFINE_GUID(D3DAUTHENTICATEDQUERY_UNRESTRICTEDPROTECTEDSHAREDRESOURCECOUNT, +DEFINE_GUID(D3DAUTHENTICATEDQUERY_UNRESTRICTEDPROTECTEDSHAREDRESOURCECOUNT, 0x12f0bd6, 0xe662, 0x4474, 0xbe, 0xfd, 0xaa, 0x53, 0xe5, 0x14, 0x3c, 0x6d); typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYUNRESTRICTEDPROTECTEDSHAREDRESOURCECOUNT_OUTPUT @@ -2179,7 +2179,7 @@ typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYUNRESTRICTEDPROTECTEDSHAREDRESOURCE } D3DAUTHENTICATEDCHANNEL_QUERYUNRESTRICTEDPROTECTEDSHAREDRESOURCECOUNT_OUTPUT; -DEFINE_GUID(D3DAUTHENTICATEDQUERY_OUTPUTIDCOUNT, +DEFINE_GUID(D3DAUTHENTICATEDQUERY_OUTPUTIDCOUNT, 0x2c042b5e, 0x8c07, 0x46d5, 0xaa, 0xbe, 0x8f, 0x75, 0xcb, 0xad, 0x4c, 0x31); typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTIDCOUNT_INPUT @@ -2187,7 +2187,7 @@ typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTIDCOUNT_INPUT D3DAUTHENTICATEDCHANNEL_QUERY_INPUT Input; HANDLE DeviceHandle; - HANDLE CryptoSessionHandle; + HANDLE CryptoSessionHandle; } D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTIDCOUNT_INPUT; @@ -2196,13 +2196,13 @@ typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTIDCOUNT_OUTPUT D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT Output; HANDLE DeviceHandle; - HANDLE CryptoSessionHandle; + HANDLE CryptoSessionHandle; UINT NumOutputIDs; } D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTIDCOUNT_OUTPUT; -DEFINE_GUID(D3DAUTHENTICATEDQUERY_OUTPUTID, +DEFINE_GUID(D3DAUTHENTICATEDQUERY_OUTPUTID, 0x839ddca3, 0x9b4e, 0x41e4, 0xb0, 0x53, 0x89, 0x2b, 0xd2, 0xa1, 0x1e, 0xe7); typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTID_INPUT @@ -2210,7 +2210,7 @@ typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTID_INPUT D3DAUTHENTICATEDCHANNEL_QUERY_INPUT Input; HANDLE DeviceHandle; - HANDLE CryptoSessionHandle; + HANDLE CryptoSessionHandle; UINT OutputIDIndex; } D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTID_INPUT; @@ -2220,14 +2220,14 @@ typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTID_OUTPUT D3DAUTHENTICATEDCHANNEL_QUERY_OUTPUT Output; HANDLE DeviceHandle; - HANDLE CryptoSessionHandle; + HANDLE CryptoSessionHandle; UINT OutputIDIndex; UINT64 OutputID; } D3DAUTHENTICATEDCHANNEL_QUERYOUTPUTID_OUTPUT; -DEFINE_GUID(D3DAUTHENTICATEDQUERY_ACCESSIBILITYATTRIBUTES, +DEFINE_GUID(D3DAUTHENTICATEDQUERY_ACCESSIBILITYATTRIBUTES, 0x6214d9d2, 0x432c, 0x4abb, 0x9f, 0xce, 0x21, 0x6e, 0xea, 0x26, 0x9e, 0x3b); typedef enum _D3DBUSTYPE @@ -2241,8 +2241,8 @@ typedef enum _D3DBUSTYPE D3DBUSIMPL_MODIFIER_TRACKS_ON_MOTHER_BOARD_TO_CHIP = 0x00020000, D3DBUSIMPL_MODIFIER_TRACKS_ON_MOTHER_BOARD_TO_SOCKET = 0x00030000, D3DBUSIMPL_MODIFIER_DAUGHTER_BOARD_CONNECTOR = 0x00040000, - D3DBUSIMPL_MODIFIER_DAUGHTER_BOARD_CONNECTOR_INSIDE_OF_NUAE = 0x00050000, - D3DBUSIMPL_MODIFIER_NON_STANDARD = 0x80000000, + D3DBUSIMPL_MODIFIER_DAUGHTER_BOARD_CONNECTOR_INSIDE_OF_NUAE = 0x00050000, + D3DBUSIMPL_MODIFIER_NON_STANDARD = 0x80000000, } D3DBUSTYPE; typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYINFOBUSTYPE_OUTPUT @@ -2256,7 +2256,7 @@ typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYINFOBUSTYPE_OUTPUT } D3DAUTHENTICATEDCHANNEL_QUERYINFOBUSTYPE_OUTPUT; -DEFINE_GUID(D3DAUTHENTICATEDQUERY_ENCRYPTIONWHENACCESSIBLEGUIDCOUNT, +DEFINE_GUID(D3DAUTHENTICATEDQUERY_ENCRYPTIONWHENACCESSIBLEGUIDCOUNT, 0xb30f7066, 0x203c, 0x4b07, 0x93, 0xfc, 0xce, 0xaa, 0xfd, 0x61, 0x24, 0x1e); typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYEVICTIONENCRYPTIONGUIDCOUNT_OUTPUT @@ -2268,7 +2268,7 @@ typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYEVICTIONENCRYPTIONGUIDCOUNT_OUTPUT } D3DAUTHENTICATEDCHANNEL_QUERYEVICTIONENCRYPTIONGUIDCOUNT_OUTPUT; -DEFINE_GUID(D3DAUTHENTICATEDQUERY_ENCRYPTIONWHENACCESSIBLEGUID, +DEFINE_GUID(D3DAUTHENTICATEDQUERY_ENCRYPTIONWHENACCESSIBLEGUID, 0xf83a5958, 0xe986, 0x4bda, 0xbe, 0xb0, 0x41, 0x1f, 0x6a, 0x7a, 0x1, 0xb7); typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYEVICTIONENCRYPTIONGUID_INPUT @@ -2289,7 +2289,7 @@ typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYEVICTIONENCRYPTIONGUID_OUTPUT } D3DAUTHENTICATEDCHANNEL_QUERYEVICTIONENCRYPTIONGUID_OUTPUT; -DEFINE_GUID(D3DAUTHENTICATEDQUERY_CURRENTENCRYPTIONWHENACCESSIBLE, +DEFINE_GUID(D3DAUTHENTICATEDQUERY_CURRENTENCRYPTIONWHENACCESSIBLE, 0xec1791c7, 0xdad3, 0x4f15, 0x9e, 0xc3, 0xfa, 0xa9, 0x3d, 0x60, 0xd4, 0xf0); typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYUNCOMPRESSEDENCRYPTIONLEVEL_OUTPUT @@ -2303,24 +2303,24 @@ typedef struct _D3DAUTHENTICATEDCHANNEL_QUERYUNCOMPRESSEDENCRYPTIONLEVEL_OUTPUT typedef struct _D3DAUTHENTICATEDCHANNEL_CONFIGURE_INPUT { - D3D_OMAC omac; - GUID ConfigureType; - HANDLE hChannel; - UINT SequenceNumber; + D3D_OMAC omac; + GUID ConfigureType; + HANDLE hChannel; + UINT SequenceNumber; } D3DAUTHENTICATEDCHANNEL_CONFIGURE_INPUT; typedef struct _D3DAUTHENTICATEDCHANNEL_CONFIGURE_OUTPUT { - D3D_OMAC omac; - GUID ConfigureType; + D3D_OMAC omac; + GUID ConfigureType; HANDLE hChannel; - UINT SequenceNumber; + UINT SequenceNumber; HRESULT ReturnCode; } D3DAUTHENTICATEDCHANNEL_CONFIGURE_OUTPUT; -DEFINE_GUID(D3DAUTHENTICATEDCONFIGURE_INITIALIZE, +DEFINE_GUID(D3DAUTHENTICATEDCONFIGURE_INITIALIZE, 0x6114bdb, 0x3523, 0x470a, 0x8d, 0xca, 0xfb, 0xc2, 0x84, 0x51, 0x54, 0xf0); typedef struct _D3DAUTHENTICATEDCHANNEL_CONFIGUREINITIALIZE @@ -2333,7 +2333,7 @@ typedef struct _D3DAUTHENTICATEDCHANNEL_CONFIGUREINITIALIZE } D3DAUTHENTICATEDCHANNEL_CONFIGUREINITIALIZE; -DEFINE_GUID(D3DAUTHENTICATEDCONFIGURE_PROTECTION, +DEFINE_GUID(D3DAUTHENTICATEDCONFIGURE_PROTECTION, 0x50455658, 0x3f47, 0x4362, 0xbf, 0x99, 0xbf, 0xdf, 0xcd, 0xe9, 0xed, 0x29); typedef struct _D3DAUTHENTICATEDCHANNEL_CONFIGUREPROTECTION @@ -2345,7 +2345,7 @@ typedef struct _D3DAUTHENTICATEDCHANNEL_CONFIGUREPROTECTION } D3DAUTHENTICATEDCHANNEL_CONFIGUREPROTECTION; -DEFINE_GUID(D3DAUTHENTICATEDCONFIGURE_CRYPTOSESSION, +DEFINE_GUID(D3DAUTHENTICATEDCONFIGURE_CRYPTOSESSION, 0x6346cc54, 0x2cfc, 0x4ad4, 0x82, 0x24, 0xd1, 0x58, 0x37, 0xde, 0x77, 0x0); typedef struct _D3DAUTHENTICATEDCHANNEL_CONFIGURECRYPTOSESSION @@ -2359,7 +2359,7 @@ typedef struct _D3DAUTHENTICATEDCHANNEL_CONFIGURECRYPTOSESSION } D3DAUTHENTICATEDCHANNEL_CONFIGURECRYPTOSESSION; -DEFINE_GUID(D3DAUTHENTICATEDCONFIGURE_SHAREDRESOURCE, +DEFINE_GUID(D3DAUTHENTICATEDCONFIGURE_SHAREDRESOURCE, 0x772d047, 0x1b40, 0x48e8, 0x9c, 0xa6, 0xb5, 0xf5, 0x10, 0xde, 0x9f, 0x1); typedef struct _D3DAUTHENTICATEDCHANNEL_CONFIGURESHAREDRESOURCE @@ -2373,7 +2373,7 @@ typedef struct _D3DAUTHENTICATEDCHANNEL_CONFIGURESHAREDRESOURCE } D3DAUTHENTICATEDCHANNEL_CONFIGURESHAREDRESOURCE; -DEFINE_GUID(D3DAUTHENTICATEDCONFIGURE_ENCRYPTIONWHENACCESSIBLE, +DEFINE_GUID(D3DAUTHENTICATEDCONFIGURE_ENCRYPTIONWHENACCESSIBLE, 0x41fff286, 0x6ae0, 0x4d43, 0x9d, 0x55, 0xa4, 0x6e, 0x9e, 0xfd, 0x15, 0x8a); typedef struct _D3DAUTHENTICATEDCHANNEL_CONFIGUREUNCOMPRESSEDENCRYPTION @@ -2386,7 +2386,7 @@ typedef struct _D3DAUTHENTICATEDCHANNEL_CONFIGUREUNCOMPRESSEDENCRYPTION typedef struct _D3DENCRYPTED_BLOCK_INFO { - UINT NumEncryptedBytesAtBeginning; + UINT NumEncryptedBytesAtBeginning; UINT NumBytesInSkipPattern; UINT NumBytesInEncryptPattern; } D3DENCRYPTED_BLOCK_INFO; diff --git a/gfx/include/vulkan/vulkan.h b/gfx/include/vulkan/vulkan.h index 121738c08f..463e0a1731 100644 --- a/gfx/include/vulkan/vulkan.h +++ b/gfx/include/vulkan/vulkan.h @@ -49,7 +49,7 @@ extern "C" { #define VK_NULL_HANDLE 0 - + #define VK_DEFINE_HANDLE(object) typedef struct object##_T* object; @@ -60,7 +60,7 @@ extern "C" { #else #define VK_DEFINE_NON_DISPATCHABLE_HANDLE(object) typedef uint64_t object; #endif - + typedef uint32_t VkFlags; diff --git a/gfx/video_coord_array.c b/gfx/video_coord_array.c index 835b9ba967..f06a619861 100644 --- a/gfx/video_coord_array.c +++ b/gfx/video_coord_array.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/gfx/video_coord_array.h b/gfx/video_coord_array.h index 9a3ec1e1db..1dee18db50 100644 --- a/gfx/video_coord_array.h +++ b/gfx/video_coord_array.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * copyright (c) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/gfx/video_driver.c b/gfx/video_driver.c index b07d869967..0302d7008b 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -175,7 +175,7 @@ static video_pixel_scaler_t *video_driver_scaler_ptr = NULL; static struct retro_hw_render_callback hw_render; -static const struct +static const struct retro_hw_render_context_negotiation_interface * hw_render_context_negotiation = NULL; @@ -192,7 +192,7 @@ static bool video_driver_active = false; static video_driver_frame_t frame_bak = NULL; /* If set during context deinit, the driver should keep - * graphics context alive to avoid having to reset all + * graphics context alive to avoid having to reset all * context state. */ static bool video_driver_cache_context = false; @@ -212,7 +212,7 @@ static void *video_context_data = NULL; /** * dynamic.c:dynamic_request_hw_context will try to set flag data when the context * is in the middle of being rebuilt; in these cases we will save flag - * data and set this to true. + * data and set this to true. * When the context is reinit, it checks this, reads from * deferred_flag_data and cleans it. * @@ -665,7 +665,7 @@ static void video_driver_filter_free(void) if (video_driver_state_filter) rarch_softfilter_free(video_driver_state_filter); video_driver_state_filter = NULL; - + if (video_driver_state_buffer) { #ifdef _3DS @@ -690,7 +690,7 @@ static void video_driver_init_filter(enum retro_pixel_format colfmt_int) unsigned width = geom->max_width; unsigned height = geom->max_height; /* Deprecated format. Gets pre-converted. */ - enum retro_pixel_format colfmt = + enum retro_pixel_format colfmt = (colfmt_int == RETRO_PIXEL_FORMAT_0RGB1555) ? RETRO_PIXEL_FORMAT_RGB565 : colfmt_int; @@ -718,11 +718,11 @@ static void video_driver_init_filter(enum retro_pixel_format colfmt_int) maxsize = MAX(pow2_x, pow2_y); video_driver_state_scale = maxsize / RARCH_SCALE_BASE; video_driver_state_out_rgb32 = rarch_softfilter_get_output_format( - video_driver_state_filter) == + video_driver_state_filter) == RETRO_PIXEL_FORMAT_XRGB8888; video_driver_state_out_bpp = video_driver_state_out_rgb32 ? - sizeof(uint32_t) : + sizeof(uint32_t) : sizeof(uint16_t); /* TODO: Aligned output. */ @@ -783,7 +783,7 @@ static void video_driver_monitor_compute_fps_statistics(void) double stddev = 0.0; unsigned samples = 0; - if (video_driver_frame_time_count < + if (video_driver_frame_time_count < (2 * MEASURE_FRAME_TIME_SAMPLES_COUNT)) { RARCH_LOG( @@ -838,7 +838,7 @@ static void video_driver_free_internal(void) if ( !video_driver_data_own - && video_driver_data + && video_driver_data && current_video && current_video->free ) current_video->free(video_driver_data); @@ -1057,7 +1057,7 @@ static bool video_driver_init_internal(bool *video_is_threaded) if (current_video->poke_interface) current_video->poke_interface(video_driver_data, &video_driver_poke); - if (current_video->viewport_info && + if (current_video->viewport_info && (!custom_vp->width || !custom_vp->height)) { @@ -1390,7 +1390,7 @@ bool video_driver_cached_frame(void) recording_data = NULL; retro_ctx.frame_cb( - (frame_cache_data != RETRO_HW_FRAME_BUFFER_VALID) + (frame_cache_data != RETRO_HW_FRAME_BUFFER_VALID) ? frame_cache_data : NULL, frame_cache_width, frame_cache_height, frame_cache_pitch); @@ -1625,13 +1625,13 @@ void video_driver_set_viewport_config(void) base_width = 1; if (base_height == 0) base_height = 1; - aspectratio_lut[ASPECT_RATIO_CONFIG].value = + aspectratio_lut[ASPECT_RATIO_CONFIG].value = (float)base_width / base_height; /* 1:1 PAR. */ } } else { - aspectratio_lut[ASPECT_RATIO_CONFIG].value = + aspectratio_lut[ASPECT_RATIO_CONFIG].value = settings->floats.video_aspect_ratio; } } @@ -1676,7 +1676,7 @@ void video_driver_set_viewport_core(void) if (geom->aspect_ratio > 0.0f) aspectratio_lut[ASPECT_RATIO_CORE].value = geom->aspect_ratio; else - aspectratio_lut[ASPECT_RATIO_CORE].value = + aspectratio_lut[ASPECT_RATIO_CORE].value = (float)geom->base_width / geom->base_height; } @@ -1918,10 +1918,10 @@ void video_driver_load_settings(config_file_t *conf) CONFIG_GET_INT_BASE(conf, global, console.screen.soft_filter_index, "soft_filter_index"); - CONFIG_GET_INT_BASE(conf, global, + CONFIG_GET_INT_BASE(conf, global, console.screen.resolutions.current.id, "current_resolution_id"); - CONFIG_GET_INT_BASE(conf, global, + CONFIG_GET_INT_BASE(conf, global, console.screen.flicker_filter_index, "flicker_filter_index"); } @@ -2050,7 +2050,7 @@ bool video_driver_is_active(void) } void video_driver_get_record_status( - bool *has_gpu_record, + bool *has_gpu_record, uint8_t **gpu_buf) { *gpu_buf = video_driver_record_gpu_buffer; @@ -2074,7 +2074,7 @@ void video_driver_gpu_record_deinit(void) bool video_driver_get_current_software_framebuffer(struct retro_framebuffer *fb) { if ( - video_driver_poke + video_driver_poke && video_driver_poke->get_current_software_framebuffer && video_driver_poke->get_current_software_framebuffer( video_driver_data, fb)) @@ -2087,7 +2087,7 @@ bool video_driver_get_hw_render_interface( const struct retro_hw_render_interface **iface) { if ( - video_driver_poke + video_driver_poke && video_driver_poke->get_hw_render_interface && video_driver_poke->get_hw_render_interface( video_driver_data, iface)) @@ -2109,11 +2109,11 @@ void video_driver_set_title_buf(void) struct retro_system_info info; core_get_system_info(&info); - fill_pathname_noext(video_driver_title_buf, + fill_pathname_noext(video_driver_title_buf, msg_hash_to_str(MSG_PROGRAM), " ", sizeof(video_driver_title_buf)); - strlcat(video_driver_title_buf, + strlcat(video_driver_title_buf, info.library_name, sizeof(video_driver_title_buf)); strlcat(video_driver_title_buf, @@ -2131,7 +2131,7 @@ void video_driver_set_title_buf(void) * @aspect_ratio : Aspect ratio (in float). * @keep_aspect : Preserve aspect ratio? * - * Gets viewport scaling dimensions based on + * Gets viewport scaling dimensions based on * scaled integer aspect ratio. **/ void video_viewport_get_scaled_integer(struct video_viewport *vp, @@ -2157,7 +2157,7 @@ void video_viewport_get_scaled_integer(struct video_viewport *vp, else { unsigned base_width; - /* Use system reported sizes as these define the + /* Use system reported sizes as these define the * geometry for the "normal" case. */ unsigned base_height = video_driver_av_info.geometry.base_height; @@ -2168,7 +2168,7 @@ void video_viewport_get_scaled_integer(struct video_viewport *vp, * This is sort of contradictory with the goal of integer scale, * but it is desirable in some cases. * - * If square pixels are used, base_height will be equal to + * If square pixels are used, base_height will be equal to * system->av_info.base_height. */ base_width = (unsigned)roundf(base_height * aspect_ratio); @@ -2244,7 +2244,7 @@ void video_driver_frame(const void *data, unsigned width, unsigned output_height = 0; unsigned output_pitch = 0; const char *msg = NULL; - retro_time_t new_time = + retro_time_t new_time = cpu_features_get_time_usec(); if (!video_driver_active) @@ -2276,8 +2276,8 @@ void video_driver_frame(const void *data, unsigned width, /* Get the amount of frames per seconds. */ if (video_driver_frame_count) { - unsigned write_index = - video_driver_frame_time_count++ & + unsigned write_index = + video_driver_frame_time_count++ & (MEASURE_FRAME_TIME_SAMPLES_COUNT - 1); video_driver_frame_time_samples[write_index] = new_time - fps_time; fps_time = new_time; @@ -2369,7 +2369,7 @@ void video_driver_frame(const void *data, unsigned width, if ( ( !video_driver_state_filter - || !video_info.post_filter_record + || !video_info.post_filter_record || !data || video_driver_record_gpu_buffer ) && recording_data @@ -2504,7 +2504,7 @@ void video_driver_build_info(video_frame_info_t *video_info) settings = config_get_ptr(); custom_vp = &settings->video_viewport_custom; video_info->refresh_rate = settings->floats.video_refresh_rate; - video_info->black_frame_insertion = + video_info->black_frame_insertion = settings->bools.video_black_frame_insertion; video_info->hard_sync = settings->bools.video_hard_sync; video_info->hard_sync_frames = settings->uints.video_hard_sync_frames; @@ -2521,7 +2521,7 @@ void video_driver_build_info(video_frame_info_t *video_info) if (libretro_get_shared_context() && hwr && hwr->context_type != RETRO_HW_CONTEXT_NONE) video_info->shared_context = true; - + video_info->font_enable = settings->bools.video_font_enable; video_info->font_msg_pos_x = settings->floats.video_msg_pos_x; video_info->font_msg_pos_y = settings->floats.video_msg_pos_y; @@ -2879,7 +2879,7 @@ bool video_context_driver_check_window(gfx_ctx_size_t *size_data) bool video_context_driver_init_image_buffer(const video_info_t *data) { - if ( + if ( current_video_context.image_buffer_init && current_video_context.image_buffer_init(video_context_data, data)) return true; @@ -2888,7 +2888,7 @@ bool video_context_driver_init_image_buffer(const video_info_t *data) bool video_context_driver_write_to_image_buffer(gfx_ctx_image_t *img) { - if ( + if ( current_video_context.image_buffer_write && current_video_context.image_buffer_write(video_context_data, img->frame, img->width, img->height, img->pitch, @@ -2978,7 +2978,7 @@ bool video_context_driver_get_proc_address(gfx_ctx_proc_address_t *proc) bool video_context_driver_get_metrics(gfx_ctx_metrics_t *metrics) { - if ( + if ( current_video_context.get_metrics(video_context_data, metrics->type, metrics->value)) @@ -3084,12 +3084,12 @@ bool video_context_driver_set_flags(gfx_ctx_flags_t *flags) { if (!flags) return false; - if (!current_video_context.set_flags) + if (!current_video_context.set_flags) { deferred_flag_data.flags = flags->flags; deferred_video_context_driver_set_flags = true; return false; - } + } current_video_context.set_flags(video_context_data, flags->flags); return true; @@ -3231,12 +3231,12 @@ static struct video_shader *video_shader_driver_get_current_shader_null(void *da static void video_shader_driver_set_params_null(void *data, void *shader_data, - unsigned width, unsigned height, - unsigned tex_width, unsigned tex_height, + unsigned width, unsigned height, + unsigned tex_width, unsigned tex_height, unsigned out_width, unsigned out_height, unsigned frame_count, - const void *info, - const void *prev_info, + const void *info, + const void *prev_info, const void *feedback_info, const void *fbo_info, unsigned fbo_info_cnt) { @@ -3289,7 +3289,7 @@ static void video_shader_driver_reset_to_defaults(void) if (current_shader->use) video_driver_cb_shader_use = current_shader->use; - else + else { current_shader->use = video_shader_driver_use_null; video_driver_cb_shader_use = video_shader_driver_use_null; @@ -3376,7 +3376,7 @@ bool video_shader_driver_info(video_shader_ctx_info_t *shader_info) bool video_shader_driver_filter_type(video_shader_ctx_filter_t *filter) { if (filter) - return current_shader->filter_type(shader_data, + return current_shader->filter_type(shader_data, filter->index, filter->smooth); return false; } diff --git a/gfx/video_driver.h b/gfx/video_driver.h index 43bbef97ca..6abae88e13 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -206,11 +206,11 @@ typedef struct shader_backend /* Set shader parameters. */ void (*set_params)(void *data, void *shader_data, - unsigned width, unsigned height, - unsigned tex_width, unsigned tex_height, + unsigned width, unsigned height, + unsigned tex_width, unsigned tex_height, unsigned out_width, unsigned out_height, unsigned frame_counter, - const void *info, + const void *info, const void *prev_info, const void *feedback_info, const void *fbo_info, unsigned fbo_info_cnt); @@ -340,20 +340,20 @@ typedef struct video_info /* Start with V-Sync enabled. */ bool vsync; - /* If true, the output image should have the aspect ratio + /* If true, the output image should have the aspect ratio * as set in aspect_ratio. */ bool force_aspect; bool font_enable; - /* Width of window. - * If fullscreen mode is requested, - * a width of 0 means the resolution of the + /* Width of window. + * If fullscreen mode is requested, + * a width of 0 means the resolution of the * desktop should be used. */ unsigned width; - /* Height of window. - * If fullscreen mode is requested, + /* Height of window. + * If fullscreen mode is requested, * a height of 0 means the resolutiof the desktop should be used. */ unsigned height; @@ -370,7 +370,7 @@ typedef struct video_info bool is_threaded; - /* Use 32bit RGBA rather than native RGB565/XBGR1555. + /* Use 32bit RGBA rather than native RGB565/XBGR1555. * * XRGB1555 format is 16-bit and has byte ordering: 0RRRRRGGGGGBBBBB, * in native endian. @@ -391,17 +391,17 @@ typedef struct video_info unsigned viwidth; #endif - /* + /* * input_scale defines the maximum size of the picture that will * ever be used with the frame callback. * * The maximum resolution is a multiple of 256x256 size (RARCH_SCALE_BASE), * so an input scale of 2 means you should allocate a texture or of 512x512. * - * Maximum input size: RARCH_SCALE_BASE * input_scale + * Maximum input size: RARCH_SCALE_BASE * input_scale */ unsigned input_scale; - + uintptr_t parent; } video_info_t; @@ -720,7 +720,7 @@ typedef struct video_poke_interface } video_poke_interface_t; -/* msg is for showing a message on the screen +/* msg is for showing a message on the screen * along with the video frame. */ typedef bool (*video_driver_frame_t)(void *data, const void *frame, unsigned width, @@ -737,20 +737,20 @@ typedef struct video_driver const input_driver_t **input, void **input_data); - /* Updates frame on the screen. + /* Updates frame on the screen. * Frame can be either XRGB1555, RGB565 or ARGB32 format - * depending on rgb32 setting in video_info_t. - * Pitch is the distance in bytes between two scanlines in memory. - * - * When msg is non-NULL, + * depending on rgb32 setting in video_info_t. + * Pitch is the distance in bytes between two scanlines in memory. + * + * When msg is non-NULL, * it's a message that should be displayed to the user. */ video_driver_frame_t frame; - /* Should we care about syncing to vblank? Fast forwarding. + /* Should we care about syncing to vblank? Fast forwarding. * - * Requests nonblocking operation. + * Requests nonblocking operation. * - * True = VSync is turned off. + * True = VSync is turned off. * False = VSync is turned on. * */ void (*set_nonblock_state)(void *data, bool toggle); @@ -804,7 +804,7 @@ typedef struct video_driver typedef struct d3d_renderchain_driver { - void (*set_mvp)(void *chain_data, + void (*set_mvp)(void *chain_data, void *data, unsigned vp_width, unsigned vp_height, unsigned rotation); void (*chain_free)(void *data); @@ -840,7 +840,7 @@ typedef struct gl_renderchain_driver void (*set_coords)(void *handle_data, void *chain_data, void *shader_data, const struct video_coords *coords); - void (*set_mvp)(void *data, + void (*set_mvp)(void *data, void *chain_data, void *shader_data, const void *mat_data); @@ -860,7 +860,7 @@ typedef struct gl_renderchain_driver void (*bind_pbo)(unsigned idx); void (*unbind_pbo)(void *data, void *chain_data); void (*copy_frame)( - void *data, + void *data, void *chain_data, video_frame_info_t *video_info, const void *frame, @@ -957,9 +957,9 @@ void video_driver_unset_own_driver(void); bool video_driver_owns_driver(void); bool video_driver_is_hw_context(void); struct retro_hw_render_callback *video_driver_get_hw_context(void); -const struct retro_hw_render_context_negotiation_interface +const struct retro_hw_render_context_negotiation_interface *video_driver_get_context_negotiation_interface(void); -void video_driver_set_context_negotiation_interface(const struct +void video_driver_set_context_negotiation_interface(const struct retro_hw_render_context_negotiation_interface *iface); bool video_driver_is_video_cache_context(void); void video_driver_set_video_cache_context_ack(void); @@ -968,9 +968,9 @@ void video_driver_set_active(void); bool video_driver_is_active(void); bool video_driver_gpu_record_init(unsigned size); void video_driver_gpu_record_deinit(void); -bool video_driver_get_current_software_framebuffer(struct +bool video_driver_get_current_software_framebuffer(struct retro_framebuffer *fb); -bool video_driver_get_hw_render_interface(const struct +bool video_driver_get_hw_render_interface(const struct retro_hw_render_interface **iface); bool video_driver_get_viewport_info(struct video_viewport *viewport); void video_driver_set_title_buf(void); @@ -989,7 +989,7 @@ const void *video_driver_find_handle(int index); * video_driver_find_ident: * @index : index of driver to get handle to. * - * Returns: Human-readable identifier of video driver at index. + * Returns: Human-readable identifier of video driver at index. * Can be NULL if nothing found. **/ const char *video_driver_find_ident(int index); @@ -1092,7 +1092,7 @@ void video_driver_menu_settings(void **list_data, void *list_info_data, * @aspect_ratio : Aspect ratio (in float). * @keep_aspect : Preserve aspect ratio? * - * Gets viewport scaling dimensions based on + * Gets viewport scaling dimensions based on * scaled integer aspect ratio. **/ void video_viewport_get_scaled_integer(struct video_viewport *vp, @@ -1194,7 +1194,7 @@ void video_driver_reinit(void); void video_driver_get_window_title(char *buf, unsigned len); void video_driver_get_record_status( - bool *has_gpu_record, + bool *has_gpu_record, uint8_t **gpu_buf); bool *video_driver_get_threaded(void); diff --git a/gfx/video_filter.c b/gfx/video_filter.c index 9c4f1bf740..86976263a2 100644 --- a/gfx/video_filter.c +++ b/gfx/video_filter.c @@ -165,7 +165,7 @@ static bool create_softfilter_graph(rarch_softfilter_t *filt, userdata.conf = filt->conf; /* Index-specific configs take priority over ident-specific. */ - userdata.prefix[0] = key; + userdata.prefix[0] = key; userdata.prefix[1] = filt->impl->short_ident; /* Simple assumptions. */ @@ -209,7 +209,7 @@ static bool create_softfilter_graph(rarch_softfilter_t *filt, filt->impl_data = filt->impl->create( &softfilter_config, input_fmt, input_fmt, max_width, max_height, - threads != RARCH_SOFTFILTER_THREADS_AUTO ? threads : + threads != RARCH_SOFTFILTER_THREADS_AUTO ? threads : cpu_features_get_core_amount(), cpu_features, &userdata); if (!filt->impl_data) @@ -312,7 +312,7 @@ static bool append_softfilter_plugs(rarch_softfilter_t *filt, RARCH_LOG("[SoftFilter]: Found plug: %s (%s).\n", impl->ident, impl->short_ident); - + filt->plugs = new_plugs; filt->plugs[filt->num_plugs].lib = lib; filt->plugs[filt->num_plugs].impl = impl; @@ -524,7 +524,7 @@ void rarch_softfilter_process(rarch_softfilter_t *filt, if (filt->impl && filt->impl->get_work_packets) filt->impl->get_work_packets(filt->impl_data, filt->packets, output, output_stride, input, width, height, input_stride); - + #ifdef HAVE_THREADS /* Fire off workers */ for (i = 0; i < filt->threads; i++) diff --git a/gfx/video_filters/2xbr.c b/gfx/video_filters/2xbr.c index 4dd94db1d0..ef978ee741 100644 --- a/gfx/video_filters/2xbr.c +++ b/gfx/video_filters/2xbr.c @@ -32,7 +32,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ - + #include "softfilter.h" #include #include @@ -68,17 +68,17 @@ struct filter_data uint16_t tbl_5_to_8[32]; uint16_t tbl_6_to_8[64]; }; - + static unsigned twoxbr_generic_input_fmts(void) { return SOFTFILTER_FMT_RGB565 | SOFTFILTER_FMT_XRGB8888; } - + static unsigned twoxbr_generic_output_fmts(unsigned input_fmts) { return input_fmts; } - + static unsigned twoxbr_generic_threads(void *data) { struct filter_data *filt = (struct filter_data*)data; @@ -218,7 +218,7 @@ static void SetupFormat(void * data) filt->RGBtoYUV[c] = y + u + v; } } - + static void *twoxbr_generic_create(const struct softfilter_config *config, unsigned in_fmt, unsigned out_fmt, unsigned max_width, unsigned max_height, @@ -244,7 +244,7 @@ static void *twoxbr_generic_create(const struct softfilter_config *config, return filt; } - + static void twoxbr_generic_output(void *data, unsigned *out_width, unsigned *out_height, unsigned width, unsigned height) @@ -252,7 +252,7 @@ static void twoxbr_generic_output(void *data, *out_width = width * TWOXBR_SCALE; *out_height = height * TWOXBR_SCALE; } - + static void twoxbr_generic_destroy(void *data) { struct filter_data *filt = (struct filter_data*)data; @@ -263,9 +263,9 @@ static void twoxbr_generic_destroy(void *data) free(filt->workers); free(filt); } - + #define ALPHA_BLEND_128_W(dst, src) dst = ((src & pg_lbmask) >> 1) + ((dst & pg_lbmask) >> 1) - + #define ALPHA_BLEND_32_W(dst, src) \ dst = ( \ (pg_red_mask & ((dst & pg_red_mask) + \ @@ -277,7 +277,7 @@ static void twoxbr_generic_destroy(void *data) (pg_blue_mask & ((dst & pg_blue_mask) + \ ((((src & pg_blue_mask) - \ (dst & pg_blue_mask))) >>3))) ) - + #define ALPHA_BLEND_8888_32_W(dst, src) \ dst = ( \ @@ -304,7 +304,7 @@ static void twoxbr_generic_destroy(void *data) (pg_blue_mask & ((dst & pg_blue_mask) + \ ((((src & pg_blue_mask) - \ (dst & pg_blue_mask))) >>2))) ) - + #define ALPHA_BLEND_8888_64_W(dst, src) \ dst = ( \ (pg_red_mask & ((dst & pg_red_mask) + \ @@ -330,7 +330,7 @@ static void twoxbr_generic_destroy(void *data) (pg_blue_mask & ((dst & pg_blue_mask) + \ ((((src & pg_blue_mask) - \ (dst & pg_blue_mask)) * 192) >>8))) ) - + #define ALPHA_BLEND_8888_192_W(dst, src) \ dst = ( \ @@ -375,44 +375,44 @@ static void twoxbr_generic_destroy(void *data) ALPHA_BLEND_224_W(E[N3], PIXEL); \ ALPHA_BLEND_64_W( E[N2], PIXEL); \ E[N1] = E[N2]; \ - - + + #define LEFT_2_2X(N3, N2, PIXEL)\ ALPHA_BLEND_192_W(E[N3], PIXEL); \ ALPHA_BLEND_64_W( E[N2], PIXEL); \ - + #define UP_2_2X(N3, N1, PIXEL)\ ALPHA_BLEND_192_W(E[N3], PIXEL); \ ALPHA_BLEND_64_W( E[N1], PIXEL); \ - + #define DIA_2X(N3, PIXEL)\ ALPHA_BLEND_128_W(E[N3], PIXEL); \ - + #define LEFT_UP_2_8888_2X(N3, N2, N1, PIXEL)\ ALPHA_BLEND_8888_224_W(E[N3], PIXEL); \ ALPHA_BLEND_8888_64_W( E[N2], PIXEL); \ E[N1] = E[N2]; \ - - + + #define LEFT_2_8888_2X(N3, N2, PIXEL)\ ALPHA_BLEND_8888_192_W(E[N3], PIXEL); \ ALPHA_BLEND_8888_64_W( E[N2], PIXEL); \ - + #define UP_2_8888_2X(N3, N1, PIXEL)\ ALPHA_BLEND_8888_192_W(E[N3], PIXEL); \ ALPHA_BLEND_8888_64_W( E[N1], PIXEL); \ - + #define DIA_8888_2X(N3, PIXEL)\ ALPHA_BLEND_128_W(E[N3], PIXEL); \ #define df(Z, A, B)\ abs(Z->RGBtoYUV[A] - Z->RGBtoYUV[B])\ - + #define eq(Z, A, B)\ (df(Z, A, B) < 155)\ - + float df8(uint32_t A, uint32_t B, @@ -443,7 +443,7 @@ int eq8(uint32_t A, uint32_t B, { uint32_t r, g, b; uint32_t y, u, v; - + #ifdef MSB_FIRST r = abs((int)(((A & pg_red_mask )>>24) - ((B & pg_red_mask )>> 24))); g = abs((int)(((A & pg_green_mask )>>16) - ((B & pg_green_mask )>> 16))); @@ -453,7 +453,7 @@ int eq8(uint32_t A, uint32_t B, g = abs((int)(((A & pg_green_mask)>>8 ) - ((B & pg_green_mask )>> 8))); r = abs((int)(((A & pg_red_mask ) - (B & pg_red_mask )))); #endif - + y = fabs(0.299*r + 0.587*g + 0.114*b); u = fabs(-0.169*r - 0.331*g + 0.500*b); v = fabs(0.500*r - 0.419*g - 0.081*b); @@ -495,7 +495,7 @@ int eq8(uint32_t A, uint32_t B, ALPHA_BLEND_128_W( E[N3], ((df(Z, PE,PF) <= df(Z, PE,PH)) ? PF : PH)); \ }\ }\ - + #define FILTRO_RGB8888(Z, PE, _PI, PH, PF, PG, PC, PD, PB, PA, G5, C4, G0, D0, C1, B1, F4, I4, H5, I5, A0, A1, N0, N1, N2, N3, pg_red_mask, pg_green_mask, pg_blue_mask) \ ex = (PE!=PH && PE!=PF); \ if ( ex )\ @@ -530,8 +530,8 @@ int eq8(uint32_t A, uint32_t B, ALPHA_BLEND_128_W( E[N3], ((df8(PE,PF, pg_red_mask, pg_green_mask, pg_blue_mask) <= df8(PE,PH, pg_red_mask, pg_green_mask, pg_blue_mask)) ? PF : PH)); \ }\ }\ - - + + #ifndef twoxbr_function #define twoxbr_function(FILTRO, Z) \ E[0] = E[1] = E[2] = E[3] = PE;\ @@ -546,8 +546,8 @@ int eq8(uint32_t A, uint32_t B, ++in; \ out += 2 #endif - - + + static void twoxbr_generic_xrgb8888(void *data, unsigned width, unsigned height, int first, int last, uint32_t *src, unsigned src_stride, uint32_t *dst, unsigned dst_stride) @@ -563,12 +563,12 @@ static void twoxbr_generic_xrgb8888(void *data, unsigned width, unsigned height, (void)filt; nextline = (last) ? 0 : src_stride; - + for (; height; height--) { uint32_t *in = (uint32_t*)src; uint32_t *out = (uint32_t*)dst; - + for (finish = width; finish; finish -= 1) { uint32_t E[4]; @@ -594,7 +594,7 @@ static void twoxbr_generic_xrgb8888(void *data, unsigned width, unsigned height, uint32_t G5 = *(in + nextline + nextline - 1); uint32_t H5 = *(in + nextline + nextline); uint32_t I5 = *(in + nextline + nextline + 1); - + /* * Map of the pixels: A1 B1 C1 * A0 PA PB PC C4 @@ -602,15 +602,15 @@ static void twoxbr_generic_xrgb8888(void *data, unsigned width, unsigned height, * G0 PG PH _PI I4 * G5 H5 I5 */ - + twoxbr_function(FILTRO_RGB8888, filt); } - + src += src_stride; dst += 2 * dst_stride; } } - + static void twoxbr_generic_rgb565(void *data, unsigned width, unsigned height, int first, int last, uint16_t *src, unsigned src_stride, uint16_t *dst, unsigned dst_stride) @@ -622,12 +622,12 @@ static void twoxbr_generic_rgb565(void *data, unsigned width, unsigned height, uint16_t pg_blue_mask = BLUE_MASK565; uint16_t pg_lbmask = PG_LBMASK565; unsigned nextline = (last) ? 0 : src_stride; - + for (; height; height--) { uint16_t *in = (uint16_t*)src; uint16_t *out = (uint16_t*)dst; - + for (finish = width; finish; finish -= 1) { uint16_t E[4]; @@ -653,7 +653,7 @@ static void twoxbr_generic_rgb565(void *data, unsigned width, unsigned height, uint16_t G5 = *(in + nextline + nextline - 1); uint16_t H5 = *(in + nextline + nextline); uint16_t I5 = *(in + nextline + nextline + 1); - + /* * Map of the pixels: A1 B1 C1 * A0 PA PB PC C4 @@ -661,47 +661,47 @@ static void twoxbr_generic_rgb565(void *data, unsigned width, unsigned height, * G0 PG PH _PI I4 * G5 H5 I5 */ - + twoxbr_function(FILTRO_RGB565, filt); } - + src += src_stride; dst += 2 * dst_stride; } } - + static void twoxbr_work_cb_rgb565(void *data, void *thread_data) { - struct softfilter_thread_data *thr = + struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data; uint16_t *input = (uint16_t*)thr->in_data; uint16_t *output = (uint16_t*)thr->out_data; unsigned width = thr->width; unsigned height = thr->height; - + twoxbr_generic_rgb565(data, width, height, thr->first, thr->last, input, (unsigned)(thr->in_pitch / SOFTFILTER_BPP_RGB565), output, (unsigned)(thr->out_pitch / SOFTFILTER_BPP_RGB565)); } - + static void twoxbr_work_cb_xrgb8888(void *data, void *thread_data) { - struct softfilter_thread_data *thr = + struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data; uint32_t *input = (uint32_t*)thr->in_data; uint32_t *output = (uint32_t*)thr->out_data; unsigned width = thr->width; unsigned height = thr->height; - + twoxbr_generic_xrgb8888(data, width, height, thr->first, thr->last, input, (unsigned)(thr->in_pitch / SOFTFILTER_BPP_XRGB8888), output, (unsigned)(thr->out_pitch / SOFTFILTER_BPP_XRGB8888)); } - + static void twoxbr_generic_packets(void *data, struct softfilter_work_packet *packets, void *output, size_t output_stride, @@ -713,25 +713,25 @@ static void twoxbr_generic_packets(void *data, for (i = 0; i < filt->threads; i++) { - struct softfilter_thread_data *thr = + struct softfilter_thread_data *thr = (struct softfilter_thread_data*)&filt->workers[i]; - + unsigned y_start = (height * i) / filt->threads; unsigned y_end = (height * (i + 1)) / filt->threads; - thr->out_data = (uint8_t*)output + y_start * + thr->out_data = (uint8_t*)output + y_start * TWOXBR_SCALE * output_stride; thr->in_data = (const uint8_t*)input + y_start * input_stride; thr->out_pitch = output_stride; thr->in_pitch = input_stride; thr->width = width; thr->height = y_end - y_start; - - /* Workers need to know if they can access + + /* Workers need to know if they can access * pixels outside their given buffer. */ thr->first = y_start; thr->last = y_end == height; - + if (filt->in_fmt == SOFTFILTER_FMT_RGB565) packets[i].work = twoxbr_work_cb_rgb565; #if 0 @@ -743,14 +743,14 @@ static void twoxbr_generic_packets(void *data, packets[i].thread_data = thr; } } - + static const struct softfilter_implementation twoxbr_generic = { twoxbr_generic_input_fmts, twoxbr_generic_output_fmts, - + twoxbr_generic_create, twoxbr_generic_destroy, - + twoxbr_generic_threads, twoxbr_generic_output, twoxbr_generic_packets, @@ -758,14 +758,14 @@ static const struct softfilter_implementation twoxbr_generic = { "2xBR", "2xbr", }; - + const struct softfilter_implementation *softfilter_get_implementation( softfilter_simd_mask_t simd) { (void)simd; return &twoxbr_generic; } - + #ifdef RARCH_INTERNAL #undef softfilter_get_implementation #undef softfilter_thread_data diff --git a/gfx/video_filters/2xsai.c b/gfx/video_filters/2xsai.c index 42a005143a..7accb0ae6f 100644 --- a/gfx/video_filters/2xsai.c +++ b/gfx/video_filters/2xsai.c @@ -225,7 +225,7 @@ static void twoxsai_generic_destroy(void *data) #endif static void twoxsai_generic_xrgb8888(unsigned width, unsigned height, - int first, int last, uint32_t *src, + int first, int last, uint32_t *src, unsigned src_stride, uint32_t *dst, unsigned dst_stride) { unsigned finish; @@ -257,7 +257,7 @@ static void twoxsai_generic_xrgb8888(unsigned width, unsigned height, } static void twoxsai_generic_rgb565(unsigned width, unsigned height, - int first, int last, uint16_t *src, + int first, int last, uint16_t *src, unsigned src_stride, uint16_t *dst, unsigned dst_stride) { unsigned finish; @@ -290,7 +290,7 @@ static void twoxsai_generic_rgb565(unsigned width, unsigned height, static void twoxsai_work_cb_rgb565(void *data, void *thread_data) { - struct softfilter_thread_data *thr = + struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data; uint16_t *input = (uint16_t*)thr->in_data; uint16_t *output = (uint16_t*)thr->out_data; @@ -306,7 +306,7 @@ static void twoxsai_work_cb_rgb565(void *data, void *thread_data) static void twoxsai_work_cb_xrgb8888(void *data, void *thread_data) { - struct softfilter_thread_data *thr = + struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data; uint32_t *input = (uint32_t*)thr->in_data; uint32_t *output = (uint32_t*)thr->out_data; @@ -331,12 +331,12 @@ static void twoxsai_generic_packets(void *data, for (i = 0; i < filt->threads; i++) { - struct softfilter_thread_data *thr = + struct softfilter_thread_data *thr = (struct softfilter_thread_data*)&filt->workers[i]; unsigned y_start = (height * i) / filt->threads; unsigned y_end = (height * (i + 1)) / filt->threads; - thr->out_data = (uint8_t*)output + y_start * + thr->out_data = (uint8_t*)output + y_start * TWOXSAI_SCALE * output_stride; thr->in_data = (const uint8_t*)input + y_start * input_stride; thr->out_pitch = output_stride; @@ -344,7 +344,7 @@ static void twoxsai_generic_packets(void *data, thr->width = width; thr->height = y_end - y_start; - /* Workers need to know if they can access pixels + /* Workers need to know if they can access pixels * outside their given buffer. */ thr->first = y_start; diff --git a/gfx/video_filters/blargg_ntsc_snes.c b/gfx/video_filters/blargg_ntsc_snes.c index a8a3ea715a..334885981e 100644 --- a/gfx/video_filters/blargg_ntsc_snes.c +++ b/gfx/video_filters/blargg_ntsc_snes.c @@ -182,7 +182,7 @@ static void blargg_ntsc_snes_render_rgb565(void *data, int width, int height, } static void blargg_ntsc_snes_rgb565(void *data, unsigned width, unsigned height, - int first, int last, uint16_t *src, + int first, int last, uint16_t *src, unsigned src_stride, uint16_t *dst, unsigned dst_stride) { blargg_ntsc_snes_render_rgb565(data, width, height, @@ -194,7 +194,7 @@ static void blargg_ntsc_snes_rgb565(void *data, unsigned width, unsigned height, static void blargg_ntsc_snes_work_cb_rgb565(void *data, void *thread_data) { - struct softfilter_thread_data *thr = + struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data; uint16_t *input = (uint16_t*)thr->in_data; uint16_t *output = (uint16_t*)thr->out_data; @@ -217,7 +217,7 @@ static void blargg_ntsc_snes_generic_packets(void *data, unsigned i; for (i = 0; i < filt->threads; i++) { - struct softfilter_thread_data *thr = + struct softfilter_thread_data *thr = (struct softfilter_thread_data*)&filt->workers[i]; unsigned y_start = (height * i) / filt->threads; @@ -229,7 +229,7 @@ static void blargg_ntsc_snes_generic_packets(void *data, thr->width = width; thr->height = y_end - y_start; - /* Workers need to know if they can + /* Workers need to know if they can * access pixels outside their given buffer. */ thr->first = y_start; thr->last = y_end == height; diff --git a/gfx/video_filters/darken.c b/gfx/video_filters/darken.c index b4b3a573a1..17cdce7334 100644 --- a/gfx/video_filters/darken.c +++ b/gfx/video_filters/darken.c @@ -104,7 +104,7 @@ static void darken_destroy(void *data) static void darken_work_cb_xrgb8888(void *data, void *thread_data) { - struct softfilter_thread_data *thr = + struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data; const uint32_t *input = (const uint32_t*)thr->in_data; uint32_t *output = (uint32_t*)thr->out_data; @@ -120,7 +120,7 @@ static void darken_work_cb_xrgb8888(void *data, void *thread_data) static void darken_work_cb_rgb565(void *data, void *thread_data) { - struct softfilter_thread_data *thr = + struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data; const uint16_t *input = (const uint16_t*)thr->in_data; uint16_t *output = (uint16_t*)thr->out_data; @@ -143,7 +143,7 @@ static void darken_packets(void *data, struct filter_data *filt = (struct filter_data*)data; for (i = 0; i < filt->threads; i++) { - struct softfilter_thread_data *thr = + struct softfilter_thread_data *thr = (struct softfilter_thread_data*)&filt->workers[i]; unsigned y_start = (height * i) / filt->threads; unsigned y_end = (height * (i + 1)) / filt->threads; diff --git a/gfx/video_filters/epx.c b/gfx/video_filters/epx.c index 2fa0407d96..0256f80ca6 100644 --- a/gfx/video_filters/epx.c +++ b/gfx/video_filters/epx.c @@ -196,7 +196,7 @@ static void epx_generic_rgb565 (unsigned width, unsigned height, static void epx_work_cb_rgb565(void *data, void *thread_data) { - struct softfilter_thread_data *thr = + struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data; uint16_t *input = (uint16_t*)thr->in_data; uint16_t *output = (uint16_t*)thr->out_data; @@ -221,7 +221,7 @@ static void epx_generic_packets(void *data, for (i = 0; i < filt->threads; i++) { - struct softfilter_thread_data *thr = + struct softfilter_thread_data *thr = (struct softfilter_thread_data*)&filt->workers[i]; unsigned y_start = (height * i) / filt->threads; @@ -233,7 +233,7 @@ static void epx_generic_packets(void *data, thr->width = width; thr->height = y_end - y_start; - /* Workers need to know if they can + /* Workers need to know if they can * access pixels outside their given buffer. */ thr->first = y_start; thr->last = y_end == height; diff --git a/gfx/video_filters/lq2x.c b/gfx/video_filters/lq2x.c index fc362801ad..e00be0d29b 100644 --- a/gfx/video_filters/lq2x.c +++ b/gfx/video_filters/lq2x.c @@ -104,7 +104,7 @@ static void lq2x_generic_destroy(void *data) } static void lq2x_generic_rgb565(unsigned width, unsigned height, - int first, int last, uint16_t *src, + int first, int last, uint16_t *src, unsigned src_stride, uint16_t *dst, unsigned dst_stride) { unsigned x, y; @@ -149,7 +149,7 @@ static void lq2x_generic_rgb565(unsigned width, unsigned height, } static void lq2x_generic_xrgb8888(unsigned width, unsigned height, - int first, int last, uint32_t *src, + int first, int last, uint32_t *src, unsigned src_stride, uint32_t *dst, unsigned dst_stride) { unsigned x, y; @@ -194,7 +194,7 @@ static void lq2x_generic_xrgb8888(unsigned width, unsigned height, static void lq2x_work_cb_rgb565(void *data, void *thread_data) { - struct softfilter_thread_data *thr = + struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data; uint16_t *input = (uint16_t*)thr->in_data; uint16_t *output = (uint16_t*)thr->out_data; @@ -210,7 +210,7 @@ static void lq2x_work_cb_rgb565(void *data, void *thread_data) static void lq2x_work_cb_xrgb8888(void *data, void *thread_data) { - struct softfilter_thread_data *thr = + struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data; uint32_t *input = (uint32_t*)thr->in_data; uint32_t *output = (uint32_t*)thr->out_data; @@ -236,7 +236,7 @@ static void lq2x_generic_packets(void *data, unsigned i; for (i = 0; i < filt->threads; i++) { - struct softfilter_thread_data *thr = + struct softfilter_thread_data *thr = (struct softfilter_thread_data*)&filt->workers[i]; unsigned y_start = (height * i) / filt->threads; @@ -248,7 +248,7 @@ static void lq2x_generic_packets(void *data, thr->width = width; thr->height = y_end - y_start; - /* Workers need to know if they can access pixels + /* Workers need to know if they can access pixels * outside their given buffer. */ thr->first = y_start; thr->last = y_end == height; diff --git a/gfx/video_filters/phosphor2x.c b/gfx/video_filters/phosphor2x.c index 1d3db0a02c..8ba64afe2a 100644 --- a/gfx/video_filters/phosphor2x.c +++ b/gfx/video_filters/phosphor2x.c @@ -118,7 +118,7 @@ static void blit_linear_line_xrgb8888(uint32_t * out, /* Blend edge pixels against black. */ out[0] = blend_pixels_xrgb8888(out[0], 0); - out[(width << 1) - 1] = + out[(width << 1) - 1] = blend_pixels_xrgb8888(out[(width << 1) - 1], 0); } @@ -133,12 +133,12 @@ static void blit_linear_line_rgb565(uint16_t * out, /* Blend in-between pixels. */ for (i = 1; i < (width << 1) - 1; i += 2) - out[i] = + out[i] = blend_pixels_rgb565(out[i - 1], out[i + 1]); /* Blend edge pixels against black. */ out[0] = blend_pixels_rgb565(out[0], 0); - out[(width << 1) - 1] = + out[(width << 1) - 1] = blend_pixels_rgb565(out[(width << 1) - 1], 0); } @@ -152,7 +152,7 @@ static void bleed_phosphors_xrgb8888(void *data, for (x = 0; x < width; x += 2) { unsigned r = red_xrgb8888(scanline[x]); - unsigned r_set = clamp8(r * filt->phosphor_bleed * + unsigned r_set = clamp8(r * filt->phosphor_bleed * filt->phosphor_bloom_8888[r]); set_red_xrgb8888(scanline[x + 1], r_set); } @@ -161,7 +161,7 @@ static void bleed_phosphors_xrgb8888(void *data, for (x = 0; x < width; x++) { unsigned g = green_xrgb8888(scanline[x]); - unsigned g_set = clamp8((g >> 1) + 0.5 * g * + unsigned g_set = clamp8((g >> 1) + 0.5 * g * filt->phosphor_bleed * filt->phosphor_bloom_8888[g]); set_green_xrgb8888(scanline[x], g_set); } @@ -171,13 +171,13 @@ static void bleed_phosphors_xrgb8888(void *data, for (x = 1; x < width; x += 2) { unsigned b = blue_xrgb8888(scanline[x]); - unsigned b_set = clamp8(b * filt->phosphor_bleed * + unsigned b_set = clamp8(b * filt->phosphor_bleed * filt->phosphor_bloom_8888[b]); set_blue_xrgb8888(scanline[x + 1], b_set); } } -static void bleed_phosphors_rgb565(void *data, +static void bleed_phosphors_rgb565(void *data, uint16_t *scanline, unsigned width) { unsigned x; @@ -187,7 +187,7 @@ static void bleed_phosphors_rgb565(void *data, for (x = 0; x < width; x += 2) { unsigned r = red_rgb565(scanline[x]); - unsigned r_set = clamp6(r * filt->phosphor_bleed * + unsigned r_set = clamp6(r * filt->phosphor_bleed * filt->phosphor_bloom_565[r]); set_red_rgb565(scanline[x + 1], r_set); } @@ -196,7 +196,7 @@ static void bleed_phosphors_rgb565(void *data, for (x = 0; x < width; x++) { unsigned g = green_rgb565(scanline[x]); - unsigned g_set = clamp6((g >> 1) + 0.5 * g * + unsigned g_set = clamp6((g >> 1) + 0.5 * g * filt->phosphor_bleed * filt->phosphor_bloom_565[g]); set_green_rgb565(scanline[x], g_set); } @@ -206,7 +206,7 @@ static void bleed_phosphors_rgb565(void *data, for (x = 1; x < width; x += 2) { unsigned b = blue_rgb565(scanline[x]); - unsigned b_set = clamp6(b * filt->phosphor_bleed * + unsigned b_set = clamp6(b * filt->phosphor_bleed * filt->phosphor_bloom_565[b]); set_blue_rgb565(scanline[x + 1], b_set); } @@ -263,26 +263,26 @@ static void *phosphor2x_generic_create(const struct softfilter_config *config, #if 0 /* Initialize lookup tables: */ - phosphorBloom = (scaleTimes .* + phosphorBloom = (scaleTimes .* linspace(0, 1, 255) .^ (1/2.2)) + scaleAdd; /* Not exactly sure of order of operations here ... */ #endif for (i = 0; i < 256; i++) { - filt->phosphor_bloom_8888[i] = - filt->scale_times * powf((float)i / 255.0f, 1.0f/2.2f) + + filt->phosphor_bloom_8888[i] = + filt->scale_times * powf((float)i / 255.0f, 1.0f/2.2f) + filt->scale_add; - filt->scan_range_8888[i] = - filt->scanrange_low + i * + filt->scan_range_8888[i] = + filt->scanrange_low + i * (filt->scanrange_high - filt->scanrange_low) / 255.0f; } for (i = 0; i < 64; i++) { - filt->phosphor_bloom_565[i] = + filt->phosphor_bloom_565[i] = filt->scale_times * powf((float)i / 31.0f, 1.0f/2.2f) + filt->scale_add; - filt->scan_range_565[i] = - filt->scanrange_low + i * + filt->scan_range_565[i] = + filt->scanrange_low + i * (filt->scanrange_high - filt->scanrange_low) / 31.0f; } @@ -311,7 +311,7 @@ static void phosphor2x_generic_destroy(void *data) static void phosphor2x_generic_xrgb8888(void *data, unsigned width, unsigned height, - int first, int last, uint32_t *src, + int first, int last, uint32_t *src, unsigned src_stride, uint32_t *dst, unsigned dst_stride) { unsigned y; @@ -344,14 +344,14 @@ static void phosphor2x_generic_xrgb8888(void *data, for (x = 0; x < (width << 1); x++) { unsigned max = max_component_xrgb8888(out_line[x]); - set_red_xrgb8888(scan_out[x], - (uint32_t)(filt->scan_range_8888[max] * + set_red_xrgb8888(scan_out[x], + (uint32_t)(filt->scan_range_8888[max] * red_xrgb8888(out_line[x]))); - set_green_xrgb8888(scan_out[x], - (uint32_t)(filt->scan_range_8888[max] * + set_green_xrgb8888(scan_out[x], + (uint32_t)(filt->scan_range_8888[max] * green_xrgb8888(out_line[x]))); - set_blue_xrgb8888(scan_out[x], - (uint32_t)(filt->scan_range_8888[max] * + set_blue_xrgb8888(scan_out[x], + (uint32_t)(filt->scan_range_8888[max] * blue_xrgb8888(out_line[x]))); } } @@ -359,7 +359,7 @@ static void phosphor2x_generic_xrgb8888(void *data, static void phosphor2x_generic_rgb565(void *data, unsigned width, unsigned height, - int first, int last, uint16_t *src, + int first, int last, uint16_t *src, unsigned src_stride, uint16_t *dst, unsigned dst_stride) { unsigned y; @@ -390,14 +390,14 @@ static void phosphor2x_generic_rgb565(void *data, for (x = 0; x < (width << 1); x++) { unsigned max = max_component_rgb565(out_line[x]); - set_red_rgb565(scan_out[x], - (uint16_t)(filt->scan_range_565[max] * + set_red_rgb565(scan_out[x], + (uint16_t)(filt->scan_range_565[max] * red_rgb565(out_line[x]))); - set_green_rgb565(scan_out[x], - (uint16_t)(filt->scan_range_565[max] * + set_green_rgb565(scan_out[x], + (uint16_t)(filt->scan_range_565[max] * green_rgb565(out_line[x]))); - set_blue_rgb565(scan_out[x], - (uint16_t)(filt->scan_range_565[max] * + set_blue_rgb565(scan_out[x], + (uint16_t)(filt->scan_range_565[max] * blue_rgb565(out_line[x]))); } } @@ -405,7 +405,7 @@ static void phosphor2x_generic_rgb565(void *data, static void phosphor2x_work_cb_xrgb8888(void *data, void *thread_data) { - struct softfilter_thread_data *thr = + struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data; uint32_t *input = (uint32_t*)thr->in_data; uint32_t *output = (uint32_t*)thr->out_data; @@ -421,7 +421,7 @@ static void phosphor2x_work_cb_xrgb8888(void *data, void *thread_data) static void phosphor2x_work_cb_rgb565(void *data, void *thread_data) { - struct softfilter_thread_data *thr = + struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data; uint16_t *input = (uint16_t*)thr->in_data; uint16_t *output = (uint16_t*)thr->out_data; @@ -444,7 +444,7 @@ static void phosphor2x_generic_packets(void *data, unsigned i; for (i = 0; i < filt->threads; i++) { - struct softfilter_thread_data *thr = + struct softfilter_thread_data *thr = (struct softfilter_thread_data*)&filt->workers[i]; unsigned y_start = (height * i) / filt->threads; @@ -456,7 +456,7 @@ static void phosphor2x_generic_packets(void *data, thr->width = width; thr->height = y_end - y_start; - /* Workers need to know if they can access pixels + /* Workers need to know if they can access pixels * outside their given buffer. */ thr->first = y_start; thr->last = y_end == height; diff --git a/gfx/video_filters/scale2x.c b/gfx/video_filters/scale2x.c index 34269b236d..e1125be4bc 100644 --- a/gfx/video_filters/scale2x.c +++ b/gfx/video_filters/scale2x.c @@ -168,7 +168,7 @@ static void scale2x_generic_destroy(void *data) static void scale2x_work_cb_xrgb8888(void *data, void *thread_data) { - struct softfilter_thread_data *thr = + struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data; const uint32_t *input = (const uint32_t*)thr->in_data; uint32_t *output = (uint32_t*)thr->out_data; @@ -184,7 +184,7 @@ static void scale2x_work_cb_xrgb8888(void *data, void *thread_data) static void scale2x_work_cb_rgb565(void *data, void *thread_data) { - struct softfilter_thread_data *thr = + struct softfilter_thread_data *thr = (struct softfilter_thread_data*)thread_data; const uint16_t *input = (const uint16_t*)thr->in_data; uint16_t *output = (uint16_t*)thr->out_data; @@ -192,7 +192,7 @@ static void scale2x_work_cb_rgb565(void *data, void *thread_data) unsigned height = thr->height; scale2x_generic_rgb565(width, height, - thr->first, thr->last, input, + thr->first, thr->last, input, (unsigned)(thr->in_pitch / SOFTFILTER_BPP_RGB565), output, (unsigned)(thr->out_pitch / SOFTFILTER_BPP_RGB565)); @@ -207,12 +207,12 @@ static void scale2x_generic_packets(void *data, unsigned i; for (i = 0; i < filt->threads; i++) { - struct softfilter_thread_data *thr = + struct softfilter_thread_data *thr = (struct softfilter_thread_data*)&filt->workers[i]; unsigned y_start = (height * i) / filt->threads; unsigned y_end = (height * (i + 1)) / filt->threads; - thr->out_data = (uint8_t*)output + y_start * + thr->out_data = (uint8_t*)output + y_start * SCALE2X_SCALE * output_stride; thr->in_data = (const uint8_t*)input + y_start * input_stride; thr->out_pitch = output_stride; @@ -220,7 +220,7 @@ static void scale2x_generic_packets(void *data, thr->width = width; thr->height = y_end - y_start; - /* Workers need to know if they can access pixels + /* Workers need to know if they can access pixels * outside their given buffer. */ thr->first = y_start; thr->last = y_end == height; diff --git a/gfx/video_filters/snes_ntsc/snes_ntsc.c b/gfx/video_filters/snes_ntsc/snes_ntsc.c index 8ea1363ba4..bb33031389 100644 --- a/gfx/video_filters/snes_ntsc/snes_ntsc.c +++ b/gfx/video_filters/snes_ntsc/snes_ntsc.c @@ -85,11 +85,11 @@ void snes_ntsc_init( snes_ntsc_t* ntsc, snes_ntsc_setup_t const* setup ) if ( !setup ) setup = &snes_ntsc_composite; init( &impl, setup ); - + merge_fields = setup->merge_fields; if ( setup->artifacts <= -1 && setup->fringing <= -1 ) merge_fields = 1; - + for ( entry = 0; entry < snes_ntsc_palette_size; entry++ ) { /* Reduce number of significant bits of source color. Clearing the @@ -130,41 +130,41 @@ void snes_ntsc_blit( snes_ntsc_t const* ntsc, SNES_NTSC_IN_T const* input, long snes_ntsc_out_t* line_out = (snes_ntsc_out_t*) rgb_out; int n; ++line_in; - + for ( n = chunk_count; n; --n ) { /* order of input and output pixels must not be altered */ SNES_NTSC_COLOR_IN( 0, SNES_NTSC_ADJ_IN( line_in [0] ) ); SNES_NTSC_RGB_OUT( 0, line_out [0], SNES_NTSC_OUT_DEPTH ); SNES_NTSC_RGB_OUT( 1, line_out [1], SNES_NTSC_OUT_DEPTH ); - + SNES_NTSC_COLOR_IN( 1, SNES_NTSC_ADJ_IN( line_in [1] ) ); SNES_NTSC_RGB_OUT( 2, line_out [2], SNES_NTSC_OUT_DEPTH ); SNES_NTSC_RGB_OUT( 3, line_out [3], SNES_NTSC_OUT_DEPTH ); - + SNES_NTSC_COLOR_IN( 2, SNES_NTSC_ADJ_IN( line_in [2] ) ); SNES_NTSC_RGB_OUT( 4, line_out [4], SNES_NTSC_OUT_DEPTH ); SNES_NTSC_RGB_OUT( 5, line_out [5], SNES_NTSC_OUT_DEPTH ); SNES_NTSC_RGB_OUT( 6, line_out [6], SNES_NTSC_OUT_DEPTH ); - + line_in += 3; line_out += 7; } - + /* finish final pixels */ SNES_NTSC_COLOR_IN( 0, snes_ntsc_black ); SNES_NTSC_RGB_OUT( 0, line_out [0], SNES_NTSC_OUT_DEPTH ); SNES_NTSC_RGB_OUT( 1, line_out [1], SNES_NTSC_OUT_DEPTH ); - + SNES_NTSC_COLOR_IN( 1, snes_ntsc_black ); SNES_NTSC_RGB_OUT( 2, line_out [2], SNES_NTSC_OUT_DEPTH ); SNES_NTSC_RGB_OUT( 3, line_out [3], SNES_NTSC_OUT_DEPTH ); - + SNES_NTSC_COLOR_IN( 2, snes_ntsc_black ); SNES_NTSC_RGB_OUT( 4, line_out [4], SNES_NTSC_OUT_DEPTH ); SNES_NTSC_RGB_OUT( 5, line_out [5], SNES_NTSC_OUT_DEPTH ); SNES_NTSC_RGB_OUT( 6, line_out [6], SNES_NTSC_OUT_DEPTH ); - + burst_phase = (burst_phase + 1) % snes_ntsc_burst_count; input += in_row_width; rgb_out = (char*) rgb_out + out_pitch; @@ -185,52 +185,52 @@ void snes_ntsc_blit_hires( snes_ntsc_t const* ntsc, SNES_NTSC_IN_T const* input, snes_ntsc_out_t* line_out = (snes_ntsc_out_t*) rgb_out; int n; line_in += 2; - + for ( n = chunk_count; n; --n ) { /* twice as many input pixels per chunk */ SNES_NTSC_COLOR_IN( 0, SNES_NTSC_ADJ_IN( line_in [0] ) ); SNES_NTSC_HIRES_OUT( 0, line_out [0], SNES_NTSC_OUT_DEPTH ); - + SNES_NTSC_COLOR_IN( 1, SNES_NTSC_ADJ_IN( line_in [1] ) ); SNES_NTSC_HIRES_OUT( 1, line_out [1], SNES_NTSC_OUT_DEPTH ); - + SNES_NTSC_COLOR_IN( 2, SNES_NTSC_ADJ_IN( line_in [2] ) ); SNES_NTSC_HIRES_OUT( 2, line_out [2], SNES_NTSC_OUT_DEPTH ); - + SNES_NTSC_COLOR_IN( 3, SNES_NTSC_ADJ_IN( line_in [3] ) ); SNES_NTSC_HIRES_OUT( 3, line_out [3], SNES_NTSC_OUT_DEPTH ); - + SNES_NTSC_COLOR_IN( 4, SNES_NTSC_ADJ_IN( line_in [4] ) ); SNES_NTSC_HIRES_OUT( 4, line_out [4], SNES_NTSC_OUT_DEPTH ); - + SNES_NTSC_COLOR_IN( 5, SNES_NTSC_ADJ_IN( line_in [5] ) ); SNES_NTSC_HIRES_OUT( 5, line_out [5], SNES_NTSC_OUT_DEPTH ); SNES_NTSC_HIRES_OUT( 6, line_out [6], SNES_NTSC_OUT_DEPTH ); - + line_in += 6; line_out += 7; } - + SNES_NTSC_COLOR_IN( 0, snes_ntsc_black ); SNES_NTSC_HIRES_OUT( 0, line_out [0], SNES_NTSC_OUT_DEPTH ); - + SNES_NTSC_COLOR_IN( 1, snes_ntsc_black ); SNES_NTSC_HIRES_OUT( 1, line_out [1], SNES_NTSC_OUT_DEPTH ); - + SNES_NTSC_COLOR_IN( 2, snes_ntsc_black ); SNES_NTSC_HIRES_OUT( 2, line_out [2], SNES_NTSC_OUT_DEPTH ); - + SNES_NTSC_COLOR_IN( 3, snes_ntsc_black ); SNES_NTSC_HIRES_OUT( 3, line_out [3], SNES_NTSC_OUT_DEPTH ); - + SNES_NTSC_COLOR_IN( 4, snes_ntsc_black ); SNES_NTSC_HIRES_OUT( 4, line_out [4], SNES_NTSC_OUT_DEPTH ); - + SNES_NTSC_COLOR_IN( 5, snes_ntsc_black ); SNES_NTSC_HIRES_OUT( 5, line_out [5], SNES_NTSC_OUT_DEPTH ); SNES_NTSC_HIRES_OUT( 6, line_out [6], SNES_NTSC_OUT_DEPTH ); - + burst_phase = (burst_phase + 1) % snes_ntsc_burst_count; input += in_row_width; rgb_out = (char*) rgb_out + out_pitch; diff --git a/gfx/video_filters/snes_ntsc/snes_ntsc.h b/gfx/video_filters/snes_ntsc/snes_ntsc.h index 82205e0115..d9aa710e27 100644 --- a/gfx/video_filters/snes_ntsc/snes_ntsc.h +++ b/gfx/video_filters/snes_ntsc/snes_ntsc.h @@ -20,7 +20,7 @@ typedef struct snes_ntsc_setup_t double contrast; /* -1 = dark (0.5) +1 = light (1.5) */ double brightness; /* -1 = dark (0.5) +1 = light (1.5) */ double sharpness; /* edge contrast enhancement/blurring */ - + /* Advanced parameters */ double gamma; /* -1 = dark (1.5) +1 = light (0.5) */ double resolution; /* image resolution */ @@ -29,7 +29,7 @@ typedef struct snes_ntsc_setup_t double bleed; /* color bleed (color resolution reduction) */ int merge_fields; /* if 1, merges even and odd fields together to reduce flicker */ float const* decoder_matrix; /* optional RGB decoder matrix, 6 elements */ - + unsigned long const* bsnes_colortbl; /* undocumented; set to 0 */ } snes_ntsc_setup_t; diff --git a/gfx/video_filters/snes_ntsc/snes_ntsc_impl.h b/gfx/video_filters/snes_ntsc/snes_ntsc_impl.h index 2d3c654589..fc9be63739 100644 --- a/gfx/video_filters/snes_ntsc/snes_ntsc_impl.h +++ b/gfx/video_filters/snes_ntsc/snes_ntsc_impl.h @@ -87,7 +87,7 @@ static void init_filters( init_t* impl, snes_ntsc_setup_t const* setup ) /* quadratic mapping to reduce negative (blurring) range */ float to_angle = (float) setup->resolution + 1; to_angle = PI / maxh * (float) LUMA_CUTOFF * (to_angle * to_angle + 1); - + kernels [kernel_size * 3 / 2] = maxh; /* default center value */ for ( i = 0; i < kernel_half * 2 + 1; i++ ) { @@ -105,7 +105,7 @@ static void init_filters( init_t* impl, snes_ntsc_setup_t const* setup ) kernels [kernel_size * 3 / 2 - kernel_half + i] = dsf - (float) 0.5; } } - + /* apply blackman window and find sum */ sum = 0; for ( i = 0; i < kernel_half * 2 + 1; i++ ) @@ -114,7 +114,7 @@ static void init_filters( init_t* impl, snes_ntsc_setup_t const* setup ) float blackman = 0.42f - 0.5f * (float) cos( x ) + 0.08f * (float) cos( x * 2 ); sum += (kernels [kernel_size * 3 / 2 - kernel_half + i] *= blackman); } - + /* normalize kernel */ sum = 1.0f / sum; for ( i = 0; i < kernel_half * 2 + 1; i++ ) @@ -130,7 +130,7 @@ static void init_filters( init_t* impl, snes_ntsc_setup_t const* setup ) float const cutoff_factor = -0.03125f; float cutoff = (float) setup->bleed; int i; - + if ( cutoff < 0 ) { /* keep extreme value accessible only near upper end of scale (1.0) */ @@ -140,10 +140,10 @@ static void init_filters( init_t* impl, snes_ntsc_setup_t const* setup ) cutoff *= -30.0f / 0.65f; } cutoff = cutoff_factor - 0.65f * cutoff_factor * cutoff; - + for ( i = -kernel_half; i <= kernel_half; i++ ) kernels [kernel_size / 2 + i] = (float) exp( i * i * cutoff ); - + /* normalize even and odd phases separately */ for ( i = 0; i < 2; i++ ) { @@ -151,7 +151,7 @@ static void init_filters( init_t* impl, snes_ntsc_setup_t const* setup ) int x; for ( x = i; x < kernel_size; x += 2 ) sum += kernels [x]; - + sum = 1.0f / sum; for ( x = i; x < kernel_size; x += 2 ) { @@ -160,7 +160,7 @@ static void init_filters( init_t* impl, snes_ntsc_setup_t const* setup ) } } } - + /* printf( "luma:\n" ); for ( i = kernel_size; i < kernel_size * 2; i++ ) @@ -169,7 +169,7 @@ static void init_filters( init_t* impl, snes_ntsc_setup_t const* setup ) for ( i = 0; i < kernel_size; i++ ) printf( "%f\n", kernels [i] ); */ - + /* generate linear rescale kernels */ #if rescale_out > 1 { @@ -205,7 +205,7 @@ static void init( init_t* impl, snes_ntsc_setup_t const* setup ) if ( !setup->palette ) impl->contrast *= default_palette_contrast; #endif - + impl->artifacts = (float) setup->artifacts; if ( impl->artifacts > 0 ) impl->artifacts *= artifacts_max - artifacts_mid; @@ -215,9 +215,9 @@ static void init( init_t* impl, snes_ntsc_setup_t const* setup ) if ( impl->fringing > 0 ) impl->fringing *= fringing_max - fringing_mid; impl->fringing = impl->fringing * fringing_mid + fringing_mid; - + init_filters( impl, setup ); - + /* generate gamma table */ if ( gamma_size > 1 ) { @@ -229,7 +229,7 @@ static void init( init_t* impl, snes_ntsc_setup_t const* setup ) impl->to_float [i] = (float) pow( i * to_float, gamma ) * impl->contrast + impl->brightness; } - + /* setup decoder matricies */ { float hue = (float) setup->hue * PI + PI / 180 * ext_decoder_hue; @@ -241,13 +241,13 @@ static void init( init_t* impl, snes_ntsc_setup_t const* setup ) if ( STD_HUE_CONDITION( setup ) ) hue += PI / 180 * (std_decoder_hue - ext_decoder_hue); } - + { float s = (float) sin( hue ) * sat; float c = (float) cos( hue ) * sat; float* out = impl->to_rgb; int n; - + n = burst_count; do { @@ -336,16 +336,16 @@ static void gen_kernel( init_t* impl, float y, float i, float q, snes_ntsc_rgb_t float const qc1 = (q + yy) * pixel->kernel [1]; float const ic2 = (i - yy) * pixel->kernel [2]; float const qc3 = (q - yy) * pixel->kernel [3]; - + float const factor = impl->artifacts * pixel->negate; float const ii = i * factor; float const yc0 = (y + ii) * pixel->kernel [0]; float const yc2 = (y - ii) * pixel->kernel [2]; - + float const qq = q * factor; float const yc1 = (y + qq) * pixel->kernel [1]; float const yc3 = (y - qq) * pixel->kernel [3]; - + float const* k = &impl->kernel [pixel->offset]; int n; ++pixel; @@ -368,12 +368,12 @@ static void gen_kernel( init_t* impl, float y, float i, float q, snes_ntsc_rgb_t } } while ( alignment_count > 1 && --alignment_remain ); - + if ( burst_count <= 1 ) break; - + to_rgb += 6; - + ROTATE_IQ( i, q, -0.866025f, -0.5f ); /* -120 degrees */ } while ( --burst_remain ); diff --git a/gfx/video_filters/softfilter.h b/gfx/video_filters/softfilter.h index 937e3fba8d..99cd10eedc 100644 --- a/gfx/video_filters/softfilter.h +++ b/gfx/video_filters/softfilter.h @@ -41,20 +41,20 @@ extern "C" { #define SOFTFILTER_SIMD_PS (1 << 14) /* A bit-mask of all supported SIMD instruction sets. - * Allows an implementation to pick different + * Allows an implementation to pick different * softfilter_implementation structs. */ typedef unsigned softfilter_simd_mask_t; -/* Returns true if config key was found. Otherwise, returns false, +/* Returns true if config key was found. Otherwise, returns false, * and sets value to default value. */ -typedef int (*softfilter_config_get_float_t)(void *userdata, +typedef int (*softfilter_config_get_float_t)(void *userdata, const char *key, float *value, float default_value); typedef int (*softfilter_config_get_int_t)(void *userdata, const char *key, int *value, int default_value); /* Allocates an array with values. free() with softfilter_config_free_t. */ -typedef int (*softfilter_config_get_float_array_t)(void *userdata, +typedef int (*softfilter_config_get_float_array_t)(void *userdata, const char *key, float **values, unsigned *out_num_values, const float *default_values, unsigned num_default_values); @@ -79,16 +79,16 @@ struct softfilter_config softfilter_config_get_int_array_t get_int_array; softfilter_config_get_string_t get_string; - /* Avoid problems where softfilter plug and + /* Avoid problems where softfilter plug and * host are linked against different C runtimes. */ softfilter_config_free_t free; }; /* Dynamic library entrypoint. */ -typedef const struct softfilter_implementation +typedef const struct softfilter_implementation *(*softfilter_get_implementation_t)(softfilter_simd_mask_t); -/* The same SIMD mask argument is forwarded to create() callback +/* The same SIMD mask argument is forwarded to create() callback * as well to avoid having to keep lots of state around. */ const struct softfilter_implementation *softfilter_get_implementation( softfilter_simd_mask_t simd); @@ -111,11 +111,11 @@ const struct softfilter_implementation *softfilter_get_implementation( * Returns a bitmask of supported input formats. */ typedef unsigned (*softfilter_query_input_formats_t)(void); -/* Returns a bitmask of supported output formats +/* Returns a bitmask of supported output formats * for a given input format. */ typedef unsigned (*softfilter_query_output_formats_t)(unsigned input_format); -/* In softfilter_process_t, the softfilter implementation +/* In softfilter_process_t, the softfilter implementation * submits work units to a worker thread pool. */ typedef void (*softfilter_work_t)(void *data, void *thread_data); struct softfilter_work_packet @@ -124,10 +124,10 @@ struct softfilter_work_packet void *thread_data; }; -/* Create a filter with given input and output formats as well as +/* Create a filter with given input and output formats as well as * maximum possible input size. * - * Input sizes can very per call to softfilter_process_t, but they + * Input sizes can very per call to softfilter_process_t, but they * will never be larger than the maximum. */ typedef void *(*softfilter_create_t)(const struct softfilter_config *config, unsigned in_fmt, unsigned out_fmt, @@ -137,13 +137,13 @@ typedef void *(*softfilter_create_t)(const struct softfilter_config *config, typedef void (*softfilter_destroy_t)(void *data); /* Given an input size, query the output size of the filter. - * If width and height == max_width/max_height, no other combination + * If width and height == max_width/max_height, no other combination * of width/height must return a larger size in any dimension. */ typedef void (*softfilter_query_output_size_t)(void *data, unsigned *out_width, unsigned *out_height, unsigned width, unsigned height); -/* First step of processing a frame. The filter submits work by +/* First step of processing a frame. The filter submits work by * filling in the packets array. * * The number of elements in the array is as returned by query_num_threads. @@ -155,8 +155,8 @@ typedef void (*softfilter_get_work_packets_t)(void *data, const void *input, unsigned width, unsigned height, size_t input_stride); /* Returns the number of worker threads the filter will use. - * This can differ from the value passed to create() instead the filter - * cannot be parallelized, etc. The number of threads must be less-or-equal + * This can differ from the value passed to create() instead the filter + * cannot be parallelized, etc. The number of threads must be less-or-equal * compared to the value passed to create(). */ typedef unsigned (*softfilter_query_num_threads_t)(void *data); diff --git a/gfx/video_filters/super2xsai.c b/gfx/video_filters/super2xsai.c index 1d5c2bf309..f9dc321a9c 100644 --- a/gfx/video_filters/super2xsai.c +++ b/gfx/video_filters/super2xsai.c @@ -201,7 +201,7 @@ static void supertwoxsai_generic_destroy(void *data) #endif static void supertwoxsai_generic_xrgb8888(unsigned width, unsigned height, - int first, int last, uint32_t *src, + int first, int last, uint32_t *src, unsigned src_stride, uint32_t *dst, unsigned dst_stride) { unsigned finish; @@ -221,7 +221,7 @@ static void supertwoxsai_generic_xrgb8888(unsigned width, unsigned height, // 1 2 3 S1 // A1 A2 //-------------------------------------- - + supertwoxsai_function(supertwoxsai_result, supertwoxsai_interpolate_xrgb8888, supertwoxsai_interpolate2_xrgb8888); } @@ -231,7 +231,7 @@ static void supertwoxsai_generic_xrgb8888(unsigned width, unsigned height, } static void supertwoxsai_generic_rgb565(unsigned width, unsigned height, - int first, int last, uint16_t *src, + int first, int last, uint16_t *src, unsigned src_stride, uint16_t *dst, unsigned dst_stride) { unsigned finish; @@ -251,7 +251,7 @@ static void supertwoxsai_generic_rgb565(unsigned width, unsigned height, // 1 2 3 S1 // A1 A2 //-------------------------------------- - + supertwoxsai_function(supertwoxsai_result, supertwoxsai_interpolate_rgb565, supertwoxsai_interpolate2_rgb565); } diff --git a/gfx/video_filters/supereagle.c b/gfx/video_filters/supereagle.c index 06b7c4c8c1..a191d104c3 100644 --- a/gfx/video_filters/supereagle.c +++ b/gfx/video_filters/supereagle.c @@ -215,7 +215,7 @@ static void supereagle_generic_destroy(void *data) #endif static void supereagle_generic_xrgb8888(unsigned width, unsigned height, - int first, int last, uint32_t *src, + int first, int last, uint32_t *src, unsigned src_stride, uint32_t *dst, unsigned dst_stride) { unsigned finish; @@ -239,7 +239,7 @@ static void supereagle_generic_xrgb8888(unsigned width, unsigned height, } static void supereagle_generic_rgb565(unsigned width, unsigned height, - int first, int last, uint16_t *src, + int first, int last, uint16_t *src, unsigned src_stride, uint16_t *dst, unsigned dst_stride) { unsigned finish; diff --git a/gfx/video_shader_parse.c b/gfx/video_shader_parse.c index e8f18968a7..3194beb4c8 100644 --- a/gfx/video_shader_parse.c +++ b/gfx/video_shader_parse.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -79,7 +79,7 @@ static const char *wrap_mode_to_str(enum gfx_wrap_type type) return "???"; } -/** +/** * wrap_str_to_mode: * @type : Wrap type in human-readable string format. * @@ -108,7 +108,7 @@ static enum gfx_wrap_type wrap_str_to_mode(const char *wrap_mode) return RARCH_WRAP_DEFAULT; } -/** +/** * video_shader_parse_pass: * @conf : Preset file to read from. * @pass : Shader passes handle. @@ -144,10 +144,10 @@ static bool video_shader_parse_pass(config_file_t *conf, float fattr = 0.0f; int iattr = 0; - fp_fbo_buf[0] = mipmap_buf[0] = alias_buf[0] = + fp_fbo_buf[0] = mipmap_buf[0] = alias_buf[0] = scale_name_buf[0] = attr_name_buf[0] = scale_type[0] = scale_type_x[0] = scale_type_y[0] = frame_count_mod[0] = - tmp_str[0] = shader_name[0] = filter_name_buf[0] = + tmp_str[0] = shader_name[0] = filter_name_buf[0] = wrap_name_buf[0] = wrap_mode[0] = frame_count_mod_buf[0] = '\0'; srgb_output_buf[0] = '\0'; @@ -332,7 +332,7 @@ error: return false; } -/** +/** * video_shader_parse_textures: * @conf : Preset file to read from. * @shader : Shader pass handle. @@ -385,7 +385,7 @@ static bool video_shader_parse_textures(config_file_t *conf, if (path_file_exists(tmp_path)) { - strlcpy(shader->lut[shader->luts].path, + strlcpy(shader->lut[shader->luts].path, tmp_path, sizeof(shader->lut[shader->luts].path)); } @@ -394,7 +394,7 @@ static bool video_shader_parse_textures(config_file_t *conf, snprintf(id_filter, sizeof(id_filter), "%s_linear", id); if (config_get_bool(conf, id_filter, &smooth)) - shader->lut[shader->luts].filter = smooth ? + shader->lut[shader->luts].filter = smooth ? RARCH_FILTER_LINEAR : RARCH_FILTER_NEAREST; else shader->lut[shader->luts].filter = RARCH_FILTER_UNSPEC; @@ -420,7 +420,7 @@ error: return false; } -/** +/** * video_shader_parse_find_parameter: * @params : Shader parameter handle. * @num_params : Number of shader params in @params. @@ -445,7 +445,7 @@ static struct video_shader_parameter *video_shader_parse_find_parameter( return NULL; } -/** +/** * video_shader_set_current_parameters: * @conf : Preset file to read from. * @shader : Shader passes handle. @@ -478,10 +478,10 @@ bool video_shader_resolve_current_parameters(config_file_t *conf, return true; } - for (id = strtok_r(parameters, ";", &save); id; + for (id = strtok_r(parameters, ";", &save); id; id = strtok_r(NULL, ";", &save)) { - struct video_shader_parameter *parameter = + struct video_shader_parameter *parameter = (struct video_shader_parameter*) video_shader_parse_find_parameter( shader->parameters, shader->num_parameters, id); @@ -500,12 +500,12 @@ bool video_shader_resolve_current_parameters(config_file_t *conf, return true; } -/** +/** * video_shader_resolve_parameters: * @conf : Preset file to read from. * @shader : Shader passes handle. * - * Resolves all shader parameters belonging to shaders. + * Resolves all shader parameters belonging to shaders. * * Returns: true (1) if successful, otherwise false (0). **/ @@ -595,12 +595,12 @@ bool video_shader_resolve_parameters(config_file_t *conf, return true; } -/** +/** * video_shader_parse_imports: * @conf : Preset file to read from. * @shader : Shader passes handle. * - * Resolves import parameters belonging to shaders. + * Resolves import parameters belonging to shaders. * * Returns: true (1) if successful, otherwise false (0). **/ @@ -615,7 +615,7 @@ static bool video_shader_parse_imports(config_file_t *conf, imports[0] = tmp_str[0] = '\0'; - if (!config_get_array(conf, "imports", imports, + if (!config_get_array(conf, "imports", imports, 1024 * sizeof(char))) { free(imports); @@ -637,10 +637,10 @@ static bool video_shader_parse_imports(config_file_t *conf, unsigned addr = 0; unsigned mask = 0; unsigned equal = 0; - struct state_tracker_uniform_info *var = + struct state_tracker_uniform_info *var = &shader->variable[shader->variables]; - semantic_buf[0] = wram_buf[0] = input_slot_buf[0] = + semantic_buf[0] = wram_buf[0] = input_slot_buf[0] = mask_buf[0] = equal_buf[0] = semantic[0] = '\0'; strlcpy(var->id, id, sizeof(var->id)); @@ -739,13 +739,13 @@ error: return false; } -/** +/** * video_shader_read_conf_cgp: * @conf : Preset file to read from. * @shader : Shader passes handle. * * Loads preset file and all associated state (passes, - * textures, imports, etc). + * textures, imports, etc). * * Returns: true (1) if successful, otherwise false (0). **/ @@ -925,13 +925,13 @@ static void shader_write_variable(config_file_t *conf, } } -/** +/** * video_shader_write_conf_cgp: * @conf : Preset file to read from. * @shader : Shader passes handle. * * Saves preset and all associated state (passes, - * textures, imports, etc) to disk. + * textures, imports, etc) to disk. **/ void video_shader_write_conf_cgp(config_file_t *conf, struct video_shader *shader) @@ -1001,7 +1001,7 @@ void video_shader_write_conf_cgp(config_file_t *conf, } config_set_string(conf, "parameters", parameters); - + for (i = 0; i < shader->num_parameters; i++) config_set_float(conf, shader->parameters[i].id, shader->parameters[i].current); @@ -1038,7 +1038,7 @@ void video_shader_write_conf_cgp(config_file_t *conf, if (shader->lut[i].filter != RARCH_FILTER_UNSPEC) { snprintf(key, sizeof(key), "%s_linear", shader->lut[i].id); - config_set_bool(conf, key, + config_set_bool(conf, key, shader->lut[i].filter == RARCH_FILTER_LINEAR); } @@ -1087,7 +1087,7 @@ void video_shader_write_conf_cgp(config_file_t *conf, * Parses type of shader. * * Returns: value of shader type on success, otherwise will return - * user-supplied @fallback value. + * user-supplied @fallback value. **/ enum rarch_shader_type video_shader_parse_type(const char *path, enum rarch_shader_type fallback) @@ -1127,7 +1127,7 @@ enum rarch_shader_type video_shader_parse_type(const char *path, { case GFX_CTX_OPENGL_API: case GFX_CTX_OPENGL_ES_API: - if (shader_type == RARCH_SHADER_GLSL + if (shader_type == RARCH_SHADER_GLSL || (cg_supported && shader_type == RARCH_SHADER_CG)) return shader_type; break; @@ -1165,7 +1165,7 @@ void video_shader_resolve_relative(struct video_shader *shader, unsigned i; size_t tmp_path_size = 4096 * sizeof(char); char *tmp_path = (char*)malloc(4096 * sizeof(char)); - + tmp_path[0] = '\0'; for (i = 0; i < shader->passes; i++) diff --git a/gfx/video_shader_parse.h b/gfx/video_shader_parse.h index 4dcbabfcf7..cb79c1f09c 100644 --- a/gfx/video_shader_parse.h +++ b/gfx/video_shader_parse.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -67,7 +67,7 @@ enum enum gfx_wrap_type { - RARCH_WRAP_BORDER = 0, /* Kinda deprecated, but keep as default. + RARCH_WRAP_BORDER = 0, /* Kinda deprecated, but keep as default. Will be translated to EDGE in GLES. */ RARCH_WRAP_DEFAULT = RARCH_WRAP_BORDER, RARCH_WRAP_EDGE, @@ -157,26 +157,26 @@ struct video_shader struct state_tracker_uniform_info variable[GFX_MAX_VARIABLES]; }; -/** +/** * video_shader_read_conf_cgp: * @conf : Preset file to read from. * @shader : Shader passes handle. * * Loads preset file and all associated state (passes, - * textures, imports, etc). + * textures, imports, etc). * * Returns: true (1) if successful, otherwise false (0). **/ bool video_shader_read_conf_cgp(config_file_t *conf, struct video_shader *shader); -/** +/** * video_shader_write_conf_cgp: * @conf : Preset file to read from. * @shader : Shader passes handle. * * Saves preset and all associated state (passes, - * textures, imports, etc) to disk. + * textures, imports, etc) to disk. **/ void video_shader_write_conf_cgp(config_file_t *conf, struct video_shader *shader); @@ -192,7 +192,7 @@ void video_shader_write_conf_cgp(config_file_t *conf, void video_shader_resolve_relative(struct video_shader *shader, const char *ref_path); -/** +/** * video_shader_resolve_parameters: * @conf : Preset file to read from. * @shader : Shader passes handle. @@ -204,12 +204,12 @@ void video_shader_resolve_relative(struct video_shader *shader, bool video_shader_resolve_current_parameters(config_file_t *conf, struct video_shader *shader); -/** +/** * video_shader_resolve_parameters: * @conf : Preset file to read from. * @shader : Shader passes handle. * - * Resolves all shader parameters belonging to shaders. + * Resolves all shader parameters belonging to shaders. * * Returns: true (1) if successful, otherwise false (0). **/ @@ -225,7 +225,7 @@ bool video_shader_resolve_parameters(config_file_t *conf, * Parses type of shader. * * Returns: value of shader type on success, otherwise will return - * user-supplied @fallback value. + * user-supplied @fallback value. **/ enum rarch_shader_type video_shader_parse_type(const char *path, enum rarch_shader_type fallback); diff --git a/gfx/video_state_tracker.c b/gfx/video_state_tracker.c index 8cebede20f..a36a50f8fb 100644 --- a/gfx/video_state_tracker.c +++ b/gfx/video_state_tracker.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -54,7 +54,7 @@ struct state_tracker_internal uint32_t prev[2]; int frame_count; int frame_count_prev; - uint32_t old_value; + uint32_t old_value; int transition_count; }; @@ -121,7 +121,7 @@ state_tracker_t* state_tracker_init(const struct state_tracker_info *info) tracker->info[i].addr = info->info[i].addr; tracker->info[i].type = info->info[i].type; - tracker->info[i].mask = (info->info[i].mask == 0) + tracker->info[i].mask = (info->info[i].mask == 0) ? 0xffff : info->info[i].mask; tracker->info[i].equal = info->info[i].equal; @@ -250,13 +250,13 @@ static void state_tracker_update_element( } uniform->value = info->frame_count_prev; break; - + #ifdef HAVE_PYTHON case RARCH_STATE_PYTHON: uniform->value = py_state_get(info->py, info->id, frame_count); break; #endif - + default: break; } @@ -282,7 +282,7 @@ unsigned state_tracker_get_uniform(state_tracker_t *tracker, unsigned elem, unsigned frame_count) { unsigned i, elems = elem; - + if (tracker->info_elem < elem) elems = tracker->info_elem; diff --git a/gfx/video_state_tracker.h b/gfx/video_state_tracker.h index abcd2e27e8..649f48e420 100644 --- a/gfx/video_state_tracker.h +++ b/gfx/video_state_tracker.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/gfx/video_thread_wrapper.c b/gfx/video_thread_wrapper.c index 59739117f4..3fc697d260 100644 --- a/gfx/video_thread_wrapper.c +++ b/gfx/video_thread_wrapper.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -590,7 +590,7 @@ static void video_thread_loop(void *data) if (thr->frame.updated) updated = true; - /* To avoid race condition where send_cmd is updated + /* To avoid race condition where send_cmd is updated * right after the switch is checked. */ pkt = thr->cmd_data; @@ -721,7 +721,7 @@ static bool video_thread_frame(void *data, const void *frame_, uint8_t *dst = NULL; thread_video_t *thr = (thread_video_t*)data; - /* If called from within read_viewport, we're actually in the + /* If called from within read_viewport, we're actually in the * driver thread, so just render directly. */ if (thr->frame.within_thread) { @@ -733,7 +733,7 @@ static bool video_thread_frame(void *data, const void *frame_, return false; } - copy_stride = width * (thr->info.rgb32 + copy_stride = width * (thr->info.rgb32 ? sizeof(uint32_t) : sizeof(uint16_t)); src = (const uint8_t*)frame_; @@ -762,7 +762,7 @@ static bool video_thread_frame(void *data, const void *frame_, } } - /* Drop frame if updated flag is still set, as thread is + /* Drop frame if updated flag is still set, as thread is * still working on last frame. */ if (!thr->frame.updated) { @@ -875,13 +875,13 @@ static void video_thread_set_viewport(void *data, unsigned width, thread_video_t *thr = (thread_video_t*)data; if (!thr) return; - + slock_lock(thr->lock); if (thr->driver && thr->driver->set_viewport) thr->driver->set_viewport(thr->driver_data, width, height, force_full, allow_rotate); - + slock_unlock(thr->lock); } @@ -898,10 +898,10 @@ static void video_thread_set_rotation(void *data, unsigned rotation) video_thread_send_and_wait_user_to_thread(thr, &pkt); } -/* This value is set async as stalling on the video driver for +/* This value is set async as stalling on the video driver for * every query is too slow. * - * This means this value might not be correct, so viewport + * This means this value might not be correct, so viewport * reads are not supported for now. */ static void video_thread_viewport_info(void *data, struct video_viewport *vp) { @@ -983,7 +983,7 @@ static bool thread_overlay_load(void *data, { thread_video_t *thr = (thread_video_t*)data; thread_packet_t pkt = { CMD_OVERLAY_LOAD }; - const struct texture_image *images = + const struct texture_image *images = (const struct texture_image*)image_data; if (!thr) @@ -1162,7 +1162,7 @@ static void thread_set_texture_frame(void *data, const void *frame, thread_video_t *thr = (thread_video_t*)data; slock_lock(thr->frame.lock); - required = width * height * + required = width * height * (rgb32 ? sizeof(uint32_t) : sizeof(uint16_t)); if (required > thr->texture.frame_cap) @@ -1246,7 +1246,7 @@ static void thread_apply_state_changes(void *data) slock_unlock(thr->frame.lock); } -/* This is read-only state which should not +/* This is read-only state which should not * have any kind of race condition. */ static struct video_shader *thread_get_current_shader(void *data) { @@ -1352,7 +1352,7 @@ static void video_thread_set_callbacks( * @out_driver : Output video driver * @out_data : Output video data * @input : Input input driver - * @input_data : Input input data + * @input_data : Input input data * @driver : Input Video driver * @info : Video info handle. * @@ -1381,7 +1381,7 @@ bool video_init_thread(const video_driver_t **out_driver, * video_thread_get_ptr: * @drv : Found driver. * - * Gets the underlying video driver associated with the + * Gets the underlying video driver associated with the * threaded video wrapper. Sets @drv to the found * video driver. * diff --git a/gfx/video_thread_wrapper.h b/gfx/video_thread_wrapper.h index 31c2010cff..3fd306590a 100644 --- a/gfx/video_thread_wrapper.h +++ b/gfx/video_thread_wrapper.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -43,7 +43,7 @@ typedef struct thread_video thread_video_t; * @out_driver : Output video driver * @out_data : Output video data * @input : Input input driver - * @input_data : Input input data + * @input_data : Input input data * @driver : Input Video driver * @info : Video info handle. * @@ -61,7 +61,7 @@ bool video_init_thread( * video_thread_get_ptr: * @drv : Found driver. * - * Gets the underlying video driver associated with the + * Gets the underlying video driver associated with the * threaded video wrapper. Sets @drv to the found * video driver. * diff --git a/input/common/input_x11_common.c b/input/common/input_x11_common.c index d9598496e0..dbbe53fc43 100644 --- a/input/common/input_x11_common.c +++ b/input/common/input_x11_common.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/input/common/input_x11_common.h b/input/common/input_x11_common.h index 4d325e4525..a0cd0342d5 100644 --- a/input/common/input_x11_common.h +++ b/input/common/input_x11_common.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/input/common/linux_common.c b/input/common/linux_common.c index 17825654a3..0d35611db1 100644 --- a/input/common/linux_common.c +++ b/input/common/linux_common.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -77,9 +77,9 @@ bool linux_terminal_init(void) void linux_terminal_claim_stdin(void) { - /* We need to disable use of stdin command interface if + /* We need to disable use of stdin command interface if * stdin is supposed to be used for input. */ - linux_stdin_claimed = true; + linux_stdin_claimed = true; } bool linux_terminal_grab_stdin(void *data) @@ -114,7 +114,7 @@ bool linux_terminal_disable_input(void) sa.sa_flags = SA_RESTART | SA_RESETHAND; sigemptyset(&sa.sa_mask); - /* Trap some standard termination codes so we + /* Trap some standard termination codes so we * can restore the keyboard before we lose control. */ sigaction(SIGABRT, &sa, NULL); sigaction(SIGBUS, &sa, NULL); diff --git a/input/common/linux_common.h b/input/common/linux_common.h index b924b7246d..701adbbd88 100644 --- a/input/common/linux_common.h +++ b/input/common/linux_common.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/input/connect/connect_ps4.c b/input/connect/connect_ps4.c index dcdd88a41e..ee5ead5c32 100644 --- a/input/connect/connect_ps4.c +++ b/input/connect/connect_ps4.c @@ -188,7 +188,7 @@ static bool hidpad_ps4_check_dpad(struct ps4 *rpt, unsigned id) static void hidpad_ps4_get_buttons(void *data, retro_bits_t* state) { struct hidpad_ps4_data *device = (struct hidpad_ps4_data*)data; - struct ps4 *rpt = device ? + struct ps4 *rpt = device ? (struct ps4*)&device->data : NULL; if (!device || !rpt) diff --git a/input/connect/connect_wiiupro.c b/input/connect/connect_wiiupro.c index 6356fc94fa..c3787bbe3c 100644 --- a/input/connect/connect_wiiupro.c +++ b/input/connect/connect_wiiupro.c @@ -121,7 +121,7 @@ static void hidpad_wiiupro_deinit(void *data) static void hidpad_wiiupro_get_buttons(void *data, retro_bits_t *state) { struct hidpad_wiiupro_data *device = (struct hidpad_wiiupro_data*)data; - struct wiiupro *rpt = device ? + struct wiiupro *rpt = device ? (struct wiiupro*)&device->data : NULL; if (!device || !rpt) diff --git a/input/drivers/android_input.c b/input/drivers/android_input.c index f25477e372..2eb4884bce 100644 --- a/input/drivers/android_input.c +++ b/input/drivers/android_input.c @@ -150,7 +150,7 @@ static void *libandroid_handle; static bool android_input_lookup_name_prekitkat(char *buf, int *vendorId, int *productId, size_t size, int id) -{ +{ jobject name = NULL; jmethodID getName = NULL; jobject device = NULL; @@ -502,9 +502,9 @@ static void *android_input_init(const char *joypad_driver) android->pads_connected = 0; android->quick_tap_time = 0; android->joypad = input_joypad_init_driver(joypad_driver, android); - + input_keymaps_init_keyboard_lut(rarch_key_map_android); - + frontend_android_get_version_sdk(&sdk); RARCH_LOG("sdk version: %d\n", sdk); @@ -528,7 +528,7 @@ static void *android_input_init(const char *joypad_driver) static int android_check_quick_tap(android_input_t *android) { - /* Check if the touch screen has been been quick tapped + /* Check if the touch screen has been been quick tapped * and then not touched again for 200ms * If so then return true and deactivate quick tap timer */ retro_time_t now = cpu_features_get_time_usec(); @@ -604,7 +604,7 @@ static int16_t android_lightgun_device_state(android_input_t *android, unsigned static INLINE void android_mouse_calculate_deltas(android_input_t *android, AInputEvent *event,size_t motion_ptr) { - /* Adjust mouse speed based on ratio + /* Adjust mouse speed based on ratio * between core resolution and system resolution */ float x, y; float x_scale = 1; @@ -663,7 +663,7 @@ static INLINE int android_input_poll_event_type_motion( (source == AINPUT_SOURCE_MOUSE && action != AMOTION_EVENT_ACTION_DOWN); - /* If source is mouse then calculate button state + /* If source is mouse then calculate button state * and mouse deltas and don't process as touchscreen event */ if (source == AINPUT_SOURCE_MOUSE) { @@ -677,7 +677,7 @@ static INLINE int android_input_poll_event_type_motion( } else { - /* If getButtonState is not available + /* If getButtonState is not available * then treat all MotionEvent.ACTION_DOWN as left button presses */ if (action == AMOTION_EVENT_ACTION_DOWN) android->mouse_l = 1; @@ -694,7 +694,7 @@ static INLINE int android_input_poll_event_type_motion( { if(action == AMOTION_EVENT_ACTION_UP && ENABLE_TOUCH_SCREEN_MOUSE) { - /* If touchscreen was pressed for less than 200ms + /* If touchscreen was pressed for less than 200ms * then register time stamp of a quick tap */ if((AMotionEvent_getEventTime(event)-AMotionEvent_getDownTime(event))/1000000 < 200) android->quick_tap_time = AMotionEvent_getEventTime(event); @@ -713,14 +713,14 @@ static INLINE int android_input_poll_event_type_motion( if(action == AMOTION_EVENT_ACTION_DOWN && ENABLE_TOUCH_SCREEN_MOUSE) { - /* When touch screen is pressed, set mouse + /* When touch screen is pressed, set mouse * previous position to current position * before starting to calculate mouse movement deltas. */ android->mouse_x_prev = AMotionEvent_getX(event, motion_ptr); android->mouse_y_prev = AMotionEvent_getY(event, motion_ptr); - /* If another touch happened within 200ms after a quick tap - * then cancel the quick tap and register left mouse button + /* If another touch happened within 200ms after a quick tap + * then cancel the quick tap and register left mouse button * as being held down */ if((AMotionEvent_getEventTime(event) - android->quick_tap_time)/1000000 < 200) { @@ -759,7 +759,7 @@ static INLINE int android_input_poll_event_type_motion( } } - /* If more than one pointer detected + /* If more than one pointer detected * then count it as a mouse right click */ if (ENABLE_TOUCH_SCREEN_MOUSE) android->mouse_r = (android->pointer_count == 2); @@ -920,7 +920,7 @@ static void handle_hotplug(android_input_t *android, android->pads_connected, device_name, id, pad_id1, pad_id2); #endif /* remove the remote or virtual controller device if it is mapped */ - if (strstr(android->pad_states[0].name,"SHIELD Remote") || + if (strstr(android->pad_states[0].name,"SHIELD Remote") || strstr(android->pad_states[0].name,"SHIELD Virtual Controller")) { pad_id1 = -1; @@ -930,7 +930,7 @@ static void handle_hotplug(android_input_t *android, strlcpy(name_buf, device_name, sizeof(name_buf)); } - /* if the actual controller has not been mapped yet, + /* if the actual controller has not been mapped yet, * then configure Virtual device for now */ if (strstr(device_name, "Virtual") && android->pads_connected==0) strlcpy (name_buf, "SHIELD Virtual Controller", sizeof(name_buf)); @@ -940,7 +940,7 @@ static void handle_hotplug(android_input_t *android, /* apply the hack only for the first controller * store the id for later use */ - if (strstr(device_name, "NVIDIA Corporation NVIDIA Controller v01.03") + if (strstr(device_name, "NVIDIA Corporation NVIDIA Controller v01.03") && android->pads_connected==0) pad_id1 = id; else if (strstr(device_name, "Virtual") && pad_id1 != -1) @@ -969,7 +969,7 @@ static void handle_hotplug(android_input_t *android, strlcpy (name_buf, "NVIDIA SHIELD Portable", sizeof(name_buf)); } } - + else if(strstr(device_model, "SHIELD") && ( strstr(device_name, "Virtual") || strstr(device_name, "gpio") || strstr(device_name, "NVIDIA Corporation NVIDIA Controller v01.03"))) @@ -1025,9 +1025,9 @@ static void handle_hotplug(android_input_t *android, * This device is composed of two hid devices * We make it look like one device */ - else if(strstr(device_model, "R800") && + else if(strstr(device_model, "R800") && ( - strstr(device_name, "keypad-game-zeus") || + strstr(device_name, "keypad-game-zeus") || strstr(device_name, "keypad-zeus") ) ) @@ -1199,7 +1199,7 @@ static void android_input_poll_input(void *data) if (port < 0 && !is_keyboard_id(id)) handle_hotplug(android, android_app, &port, id, source); - + switch (type_event) { case AINPUT_EVENT_TYPE_MOTION: @@ -1267,28 +1267,28 @@ static void android_input_poll_memcpy(void *data) } } -static bool android_input_key_pressed(void *data, int key) -{ +static bool android_input_key_pressed(void *data, int key) +{ rarch_joypad_info_t joypad_info; - android_input_t *android = (android_input_t*)data; + android_input_t *android = (android_input_t*)data; const struct retro_keybind *keyptr = (const struct retro_keybind*) &input_config_binds[0][key]; - if( keyptr->valid + if( keyptr->valid && android_keyboard_port_input_pressed(input_config_binds[0], - key)) - return true; + key)) + return true; joypad_info.joy_idx = 0; joypad_info.auto_binds = input_autoconf_binds[0]; joypad_info.axis_threshold = *(input_driver_get_float(INPUT_ACTION_AXIS_THRESHOLD)); - if (keyptr->valid && + if (keyptr->valid && input_joypad_pressed(android->joypad, joypad_info, - 0, input_config_binds[0], key)) - return true; + 0, input_config_binds[0], key)) + return true; - return false; + return false; } /* Handle all events. If our activity is in pause state, @@ -1317,7 +1317,7 @@ static void android_input_poll(void *data) android_input_poll_main_cmd(); break; } - + if (android_app->destroyRequested != 0) { rarch_ctl(RARCH_CTL_SET_SHUTDOWN, NULL); diff --git a/input/drivers/cocoa_input.h b/input/drivers/cocoa_input.h index 33194837f5..62f21b4904 100644 --- a/input/drivers/cocoa_input.h +++ b/input/drivers/cocoa_input.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2011-2017 - Daniel De Matteis * Copyright (C) 2013-2014 - Jason Fetters - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/input/drivers/ctr_input.c b/input/drivers/ctr_input.c index 9871a9669d..359dc9f5eb 100644 --- a/input/drivers/ctr_input.c +++ b/input/drivers/ctr_input.c @@ -45,7 +45,7 @@ static void ctr_input_poll(void *data) ctr->joypad->poll(); } -static int16_t ctr_input_state(void *data, +static int16_t ctr_input_state(void *data, rarch_joypad_info_t joypad_info, const struct retro_keybind **binds, unsigned port, unsigned device, diff --git a/input/drivers/gx_input.c b/input/drivers/gx_input.c index b4daff900d..cecbc92643 100644 --- a/input/drivers/gx_input.c +++ b/input/drivers/gx_input.c @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis * Copyright (C) 2012-2015 - Michael Lelli - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/input/drivers/linuxraw_input.c b/input/drivers/linuxraw_input.c index eee4a70cd6..5c2b780e9a 100644 --- a/input/drivers/linuxraw_input.c +++ b/input/drivers/linuxraw_input.c @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis * Copyright (C) 2012-2015 - Michael Lelli - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -113,7 +113,7 @@ static int16_t linuxraw_input_state(void *data, linuxraw->state[rarch_keysym_lut[(enum retro_key)binds[port][id].key]] ); if (!ret) - ret = input_joypad_pressed(linuxraw->joypad, + ret = input_joypad_pressed(linuxraw->joypad, joypad_info, port, binds[port], id); return ret; case RETRO_DEVICE_ANALOG: diff --git a/input/drivers/nullinput.c b/input/drivers/nullinput.c index 78498f88dc..edb3c93e3e 100644 --- a/input/drivers/nullinput.c +++ b/input/drivers/nullinput.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/input/drivers/ps3_input.c b/input/drivers/ps3_input.c index b5e2037027..8edc841960 100644 --- a/input/drivers/ps3_input.c +++ b/input/drivers/ps3_input.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -76,7 +76,7 @@ static int16_t ps3_mouse_device_state(ps3_input_t *ps3, { CellMouseData mouse_state; cellMouseGetData(id, &mouse_state); - + if (!ps3->mice_connected) return 0; @@ -205,8 +205,8 @@ static bool ps3_input_set_sensor_state(void *data, unsigned port, { case RETRO_SENSOR_ACCELEROMETER_ENABLE: cellPadGetInfo2(&pad_info); - if ((pad_info.device_capability[port] - & CELL_PAD_CAPABILITY_SENSOR_MODE) + if ((pad_info.device_capability[port] + & CELL_PAD_CAPABILITY_SENSOR_MODE) != CELL_PAD_CAPABILITY_SENSOR_MODE) return false; diff --git a/input/drivers/rwebinput_input.c b/input/drivers/rwebinput_input.c index 9d2fde4d96..3506b7e029 100644 --- a/input/drivers/rwebinput_input.c +++ b/input/drivers/rwebinput_input.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2015 - Michael Lelli * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -71,7 +71,7 @@ static bool rwebinput_key_pressed_internal(void *data, int key) unsigned sym; bool ret; rwebinput_input_t *rwebinput = (rwebinput_input_t*)data; - + if (key >= RETROK_LAST) return false; @@ -95,7 +95,7 @@ static bool rwebinput_is_pressed(rwebinput_input_t *rwebinput, { const struct retro_keybind *bind = &binds[id]; int key = binds[id].key; - return bind->valid && (key < RETROK_LAST) + return bind->valid && (key < RETROK_LAST) && rwebinput_key_pressed_internal(rwebinput, key); } diff --git a/input/drivers/sdl_input.c b/input/drivers/sdl_input.c index 5b462d55ff..5376f2b9ce 100644 --- a/input/drivers/sdl_input.c +++ b/input/drivers/sdl_input.c @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis * Copyright (C) 2014-2015 - Higor Euripedes - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -96,7 +96,7 @@ static bool sdl_input_meta_key_pressed(void *data, int key) static int16_t sdl_joypad_device_state(sdl_input_t *sdl, rarch_joypad_info_t joypad_info, - const struct retro_keybind *binds, + const struct retro_keybind *binds, unsigned port, unsigned id, enum input_device_type *device) { if ((binds[id].key < RETROK_LAST) && sdl_key_pressed(binds[id].key)) @@ -200,9 +200,9 @@ static int16_t sdl_lightgun_device_state(sdl_input_t *sdl, unsigned id) case RETRO_DEVICE_ID_LIGHTGUN_TURBO: return sdl->mouse_r; case RETRO_DEVICE_ID_LIGHTGUN_START: - return sdl->mouse_m && sdl->mouse_r; + return sdl->mouse_m && sdl->mouse_r; case RETRO_DEVICE_ID_LIGHTGUN_PAUSE: - return sdl->mouse_m && sdl->mouse_l; + return sdl->mouse_m && sdl->mouse_l; } return 0; diff --git a/input/drivers/wayland_input.c b/input/drivers/wayland_input.c index 21ff484568..6fab41d99f 100644 --- a/input/drivers/wayland_input.c +++ b/input/drivers/wayland_input.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2015 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -87,9 +87,9 @@ static int16_t input_wl_lightgun_state(input_ctx_wayland_data_t *wl, unsigned id case RETRO_DEVICE_ID_LIGHTGUN_TURBO: return wl->mouse.right; case RETRO_DEVICE_ID_LIGHTGUN_START: - return wl->mouse.middle && wl->mouse.right; + return wl->mouse.middle && wl->mouse.right; case RETRO_DEVICE_ID_LIGHTGUN_PAUSE: - return wl->mouse.middle && wl->mouse.left; + return wl->mouse.middle && wl->mouse.left; } return 0; @@ -129,14 +129,14 @@ static int16_t input_wl_analog_pressed(input_ctx_wayland_data_t *wl, input_conv_analog_id_to_bind_id(idx, id, &id_minus, &id_plus); - if (binds - && binds[id_minus].valid + if (binds + && binds[id_minus].valid && (id_minus < RARCH_BIND_LIST_END) && BIT_GET(wl->key_state, rarch_keysym_lut[binds[id_minus].key]) ) pressed_minus = -0x7fff; - if (binds - && binds[id_plus].valid + if (binds + && binds[id_plus].valid && (id_plus < RARCH_BIND_LIST_END) && BIT_GET(wl->key_state, rarch_keysym_lut[binds[id_plus].key]) ) diff --git a/input/drivers/winraw_input.c b/input/drivers/winraw_input.c index fa6011291d..2b15c53c1b 100644 --- a/input/drivers/winraw_input.c +++ b/input/drivers/winraw_input.c @@ -1,857 +1,857 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2011-2017 - Daniel De Matteis - * - * RetroArch 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 Found- - * ation, either version 3 of the License, or (at your option) any later version. - * - * RetroArch 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 RetroArch. - * If not, see . - */ - -#include - -#include "../input_driver.h" -#include "../input_keymaps.h" - -#include "../../configuration.h" -#include "../../gfx/video_driver.h" -#include "../../verbosity.h" - -typedef struct -{ - uint8_t keys[256]; -} winraw_keyboard_t; - -typedef struct -{ - HANDLE hnd; - LONG x, y, dlt_x, dlt_y; - LONG whl_u, whl_d; - bool btn_l, btn_m, btn_r, btn_b4, btn_b5; -} winraw_mouse_t; - -typedef struct -{ - bool kbd_mapp_block; - bool mouse_grab; - winraw_keyboard_t keyboard; - HWND window; - winraw_mouse_t *mice; - const input_device_driver_t *joypad; -} winraw_input_t; - -static winraw_keyboard_t *g_keyboard = NULL; -static winraw_mouse_t *g_mice = NULL; -static unsigned g_mouse_cnt = 0; -static bool g_mouse_xy_mapping_ready = false; -static double g_view_abs_ratio_x = 0.0; -static double g_view_abs_ratio_y = 0.0; - -static HWND winraw_create_window(WNDPROC wnd_proc) -{ - HWND wnd; - WNDCLASSA wc = {0}; - - wc.hInstance = GetModuleHandleA(NULL); - - if (!wc.hInstance) - { - RARCH_ERR("[WINRAW]: GetModuleHandleA failed with error %lu.\n", GetLastError()); - return NULL; - } - - wc.lpfnWndProc = wnd_proc; - wc.lpszClassName = "winraw-input"; - if (!RegisterClassA(&wc) && GetLastError() != ERROR_CLASS_ALREADY_EXISTS) - { - RARCH_ERR("[WINRAW]: RegisterClassA failed with error %lu.\n", GetLastError()); - return NULL; - } - - wnd = CreateWindowExA(0, wc.lpszClassName, NULL, 0, 0, 0, 0, 0, - HWND_MESSAGE, NULL, NULL, NULL); - if (!wnd) - { - RARCH_ERR("[WINRAW]: CreateWindowExA failed with error %lu.\n", GetLastError()); - goto error; - } - - return wnd; - -error: - UnregisterClassA(wc.lpszClassName, NULL); - return NULL; -} - -static void winraw_destroy_window(HWND wnd) -{ - BOOL r; - - if (!wnd) - return; - - r = DestroyWindow(wnd); - - if (!r) - { - RARCH_WARN("[WINRAW]: DestroyWindow failed with error %lu.\n", GetLastError()); - } - - r = UnregisterClassA("winraw-input", NULL); - - if (!r) - { - RARCH_WARN("[WINRAW]: UnregisterClassA failed with error %lu.\n", GetLastError()); - } -} - -static bool winraw_set_keyboard_input(HWND window) -{ - RAWINPUTDEVICE rid; - BOOL r; - - rid.dwFlags = window ? 0 : RIDEV_REMOVE; - rid.hwndTarget = window; - rid.usUsagePage = 0x01; /* generic desktop */ - rid.usUsage = 0x06; /* keyboard */ - - r = RegisterRawInputDevices(&rid, 1, sizeof(RAWINPUTDEVICE)); - - if (!r) - { - RARCH_ERR("[WINRAW]: RegisterRawInputDevices failed with error %lu.\n", GetLastError()); - return false; - } - - return true; -} - -static void winraw_log_mice_info(winraw_mouse_t *mice, unsigned mouse_cnt) -{ - UINT r; - unsigned i; - char name[256]; - UINT name_size = sizeof(name); - - for (i = 0; i < mouse_cnt; ++i) - { - r = GetRawInputDeviceInfoA(mice[i].hnd, RIDI_DEVICENAME, name, &name_size); - if (r == (UINT)-1 || r == 0) - name[0] = '\0'; - RARCH_LOG("[WINRAW]: Mouse #%u %s.\n", i, name); - } -} - -static bool winraw_init_devices(winraw_mouse_t **mice, unsigned *mouse_cnt) -{ - UINT i; - POINT crs_pos; - winraw_mouse_t *mice_r = NULL; - unsigned mouse_cnt_r = 0; - RAWINPUTDEVICELIST *devs = NULL; - UINT dev_cnt = 0; - UINT r = GetRawInputDeviceList( - NULL, &dev_cnt, sizeof(RAWINPUTDEVICELIST)); - - if (r == (UINT)-1) - { - RARCH_ERR("[WINRAW]: GetRawInputDeviceList failed with error %lu.\n", GetLastError()); - goto error; - } - - devs = (RAWINPUTDEVICELIST*)malloc(dev_cnt * sizeof(RAWINPUTDEVICELIST)); - if (!devs) - goto error; - - dev_cnt = GetRawInputDeviceList(devs, &dev_cnt, sizeof(RAWINPUTDEVICELIST)); - if (dev_cnt == (UINT)-1) - { - RARCH_ERR("[WINRAW]: GetRawInputDeviceList failed with error %lu.\n", GetLastError()); - goto error; - } - - for (i = 0; i < dev_cnt; ++i) - mouse_cnt_r += devs[i].dwType == RIM_TYPEMOUSE ? 1 : 0; - - if (mouse_cnt_r) - { - mice_r = (winraw_mouse_t*)calloc(1, mouse_cnt_r * sizeof(winraw_mouse_t)); - if (!mice_r) - goto error; - - if (!GetCursorPos(&crs_pos)) - goto error; - - for (i = 0; i < mouse_cnt_r; ++i) - { - mice_r[i].x = crs_pos.x; - mice_r[i].y = crs_pos.y; - } - } - - /* count is already checked, so this is safe */ - for (i = mouse_cnt_r = 0; i < dev_cnt; ++i) - { - if (devs[i].dwType == RIM_TYPEMOUSE) - mice_r[mouse_cnt_r++].hnd = devs[i].hDevice; - } - - winraw_log_mice_info(mice_r, mouse_cnt_r); - - *mice = mice_r; - *mouse_cnt = mouse_cnt_r; - - return true; - -error: - free(devs); - free(mice_r); - *mice = NULL; - *mouse_cnt = 0; - return false; -} - -static bool winraw_set_mouse_input(HWND window, bool grab) -{ - RAWINPUTDEVICE rid; - BOOL r; - - if (window) - rid.dwFlags = grab ? RIDEV_CAPTUREMOUSE : 0; - else - rid.dwFlags = RIDEV_REMOVE; - - rid.hwndTarget = window; - rid.usUsagePage = 0x01; /* generic desktop */ - rid.usUsage = 0x02; /* mouse */ - - r = RegisterRawInputDevices(&rid, 1, sizeof(RAWINPUTDEVICE)); - - if (!r) - { - RARCH_ERR("[WINRAW]: RegisterRawInputDevice failed with error %lu.\n", GetLastError()); - return false; - } - - return true; -} - -static int16_t winraw_lightgun_aiming_state(winraw_input_t *wr, - unsigned port, unsigned id) -{ - const int edge_detect = 32700; - struct video_viewport vp; - bool inside = false; - unsigned i; - settings_t *settings = config_get_ptr(); - winraw_mouse_t *mouse = NULL; - int16_t res_x = 0; - int16_t res_y = 0; - int16_t res_screen_x = 0; - int16_t res_screen_y = 0; - - if (port >= MAX_USERS) - return 0; - - for (i = 0; i < g_mouse_cnt; ++i) - { - if (i == settings->uints.input_mouse_index[port]) - { - mouse = &wr->mice[i]; - break; - } - } - - if (!mouse) - return 0; - - vp.x = 0; - vp.y = 0; - vp.width = 0; - vp.height = 0; - vp.full_width = 0; - vp.full_height = 0; - - if ( !( video_driver_translate_coord_viewport_wrap( - &vp, mouse->x, mouse->y, &res_x, &res_y, &res_screen_x, &res_screen_y ) ) ) - { - return 0; - } - - inside = (res_x >= -edge_detect) && (res_y >= -edge_detect) && (res_x <= edge_detect) && (res_y <= edge_detect); - - switch ( id ) - { - case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X: - return inside ? res_x : 0; - case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y: - return inside ? res_y : 0; - case RETRO_DEVICE_ID_LIGHTGUN_IS_OFFSCREEN: - return !inside; - default: - break; - } - - return 0; -} - -static int16_t winraw_mouse_state(winraw_input_t *wr, - unsigned port, bool abs, unsigned id) -{ - unsigned i; - settings_t *settings = config_get_ptr(); - winraw_mouse_t *mouse = NULL; - - if (port >= MAX_USERS) - return 0; - - for (i = 0; i < g_mouse_cnt; ++i) - { - if (i == settings->uints.input_mouse_index[port]) - { - mouse = &wr->mice[i]; - break; - } - } - - if (!mouse) - return 0; - - switch (id) - { - case RETRO_DEVICE_ID_MOUSE_X: - return abs ? mouse->x : mouse->dlt_x; - case RETRO_DEVICE_ID_MOUSE_Y: - return abs ? mouse->y : mouse->dlt_y; - case RETRO_DEVICE_ID_MOUSE_LEFT: - return mouse->btn_l ? 1 : 0; - case RETRO_DEVICE_ID_MOUSE_RIGHT: - return mouse->btn_r ? 1 : 0; - case RETRO_DEVICE_ID_MOUSE_WHEELUP: - return mouse->whl_u ? 1 : 0; - case RETRO_DEVICE_ID_MOUSE_WHEELDOWN: - return mouse->whl_d ? 1 : 0; - case RETRO_DEVICE_ID_MOUSE_MIDDLE: - return mouse->btn_m ? 1 : 0; - case RETRO_DEVICE_ID_MOUSE_BUTTON_4: - return mouse->btn_b4 ? 1 : 0; - case RETRO_DEVICE_ID_MOUSE_BUTTON_5: - return mouse->btn_b5 ? 1 : 0; - } - - return 0; -} - -static bool winraw_keyboard_pressed(winraw_input_t *wr, unsigned key) -{ - unsigned k = rarch_keysym_lut[(enum retro_key)key]; - return wr->keyboard.keys[k]; -} - -static bool winraw_mbutton_pressed(winraw_input_t *wr, unsigned port, unsigned key) -{ - unsigned i; - winraw_mouse_t *mouse = NULL; - settings_t *settings = config_get_ptr(); - - if (port >= MAX_USERS) - return false; - - for (i = 0; i < g_mouse_cnt; ++i) - { - if (i == settings->uints.input_mouse_index[port]) - { - mouse = &wr->mice[i]; - break; - } - } - - if (!mouse) - return false; - - switch ( key ) - { - - case RETRO_DEVICE_ID_MOUSE_LEFT: - return mouse->btn_l; - case RETRO_DEVICE_ID_MOUSE_RIGHT: - return mouse->btn_r; - case RETRO_DEVICE_ID_MOUSE_MIDDLE: - return mouse->btn_m; - case RETRO_DEVICE_ID_MOUSE_BUTTON_4: - return mouse->btn_b4; - case RETRO_DEVICE_ID_MOUSE_BUTTON_5: - return mouse->btn_b5; - case RETRO_DEVICE_ID_MOUSE_WHEELUP: - return mouse->whl_u; - case RETRO_DEVICE_ID_MOUSE_WHEELDOWN: - return mouse->whl_d; - } - - return false; -} - -static bool winraw_is_pressed(winraw_input_t *wr, - rarch_joypad_info_t joypad_info, - const struct retro_keybind *binds, - unsigned port, unsigned id) -{ - const struct retro_keybind *bind = &binds[id]; - - if (!wr->kbd_mapp_block && (bind->key < RETROK_LAST) && winraw_keyboard_pressed(wr, bind->key)) - return true; - if (binds && binds[id].valid) - { - if (winraw_mbutton_pressed(wr, port, bind->mbutton)) - return true; - if (input_joypad_pressed(wr->joypad, joypad_info, port, binds, id)) - return true; - } - - return false; -} - -static void winraw_init_mouse_xy_mapping() -{ - struct video_viewport viewport; - int center_x; - int center_y; - unsigned i; - - if (video_driver_get_viewport_info(&viewport)) - { - center_x = viewport.x + viewport.width / 2; - center_y = viewport.y + viewport.height / 2; - - for (i = 0; i < g_mouse_cnt; ++i) - { - g_mice[i].x = center_x; - g_mice[i].y = center_y; - } - - g_view_abs_ratio_x = (double)viewport.full_width / 65535.0; - g_view_abs_ratio_y = (double)viewport.full_height / 65535.0; - - g_mouse_xy_mapping_ready = true; - } -} - -static int16_t winraw_deprecated_lightgun_state(winraw_input_t *wr, - unsigned port, unsigned id) -{ - unsigned i; - settings_t *settings = config_get_ptr(); - winraw_mouse_t *mouse = NULL; - - if (port >= MAX_USERS) - return 0; - - for (i = 0; i < g_mouse_cnt; ++i) - { - if (i == settings->uints.input_mouse_index[port]) - { - mouse = &wr->mice[i]; - break; - } - } - - if (!mouse) - return 0; - - switch (id) - { - case RETRO_DEVICE_ID_LIGHTGUN_X: - return mouse->dlt_x; - case RETRO_DEVICE_ID_LIGHTGUN_Y: - return mouse->dlt_y; - } - - return 0; -} - -static void winraw_update_mouse_state(winraw_mouse_t *mouse, RAWMOUSE *state) -{ - POINT crs_pos; - - if (state->usFlags & MOUSE_MOVE_ABSOLUTE) - { - if (g_mouse_xy_mapping_ready) - { - state->lLastX = (LONG)(g_view_abs_ratio_x * state->lLastX); - state->lLastY = (LONG)(g_view_abs_ratio_y * state->lLastY); - InterlockedExchangeAdd(&mouse->dlt_x, state->lLastX - mouse->x); - InterlockedExchangeAdd(&mouse->dlt_y, state->lLastY - mouse->y); - mouse->x = state->lLastX; - mouse->y = state->lLastY; - } - else - winraw_init_mouse_xy_mapping(); - } - else if (state->lLastX || state->lLastY) - { - InterlockedExchangeAdd(&mouse->dlt_x, state->lLastX); - InterlockedExchangeAdd(&mouse->dlt_y, state->lLastY); - - if (!GetCursorPos(&crs_pos)) - { - RARCH_WARN("[WINRAW]: GetCursorPos failed with error %lu.\n", GetLastError()); - } - else if (!ScreenToClient((HWND)video_driver_window_get(), &crs_pos)) - { - RARCH_WARN("[WINRAW]: ScreenToClient failed with error %lu.\n", GetLastError()); - } - else - { - mouse->x = crs_pos.x; - mouse->y = crs_pos.y; - } - } - - if (state->usButtonFlags & RI_MOUSE_LEFT_BUTTON_DOWN) - mouse->btn_l = true; - else if (state->usButtonFlags & RI_MOUSE_LEFT_BUTTON_UP) - mouse->btn_l = false; - - if (state->usButtonFlags & RI_MOUSE_MIDDLE_BUTTON_DOWN) - mouse->btn_m = true; - else if (state->usButtonFlags & RI_MOUSE_MIDDLE_BUTTON_UP) - mouse->btn_m = false; - - if (state->usButtonFlags & RI_MOUSE_RIGHT_BUTTON_DOWN) - mouse->btn_r = true; - else if (state->usButtonFlags & RI_MOUSE_RIGHT_BUTTON_UP) - mouse->btn_r = false; - - if (state->usButtonFlags & RI_MOUSE_BUTTON_4_DOWN) - mouse->btn_b4 = true; - else if (state->usButtonFlags & RI_MOUSE_BUTTON_4_UP) - mouse->btn_b4 = false; - - if (state->usButtonFlags & RI_MOUSE_BUTTON_5_DOWN) - mouse->btn_b5 = true; - else if (state->usButtonFlags & RI_MOUSE_BUTTON_5_UP) - mouse->btn_b5 = false; - - if (state->usButtonFlags & RI_MOUSE_WHEEL) - { - if ((SHORT)state->usButtonData > 0) - InterlockedExchange(&mouse->whl_u, 1); - else if ((SHORT)state->usButtonData < 0) - InterlockedExchange(&mouse->whl_d, 1); - } -} - -static LRESULT CALLBACK winraw_callback(HWND wnd, UINT msg, WPARAM wpar, LPARAM lpar) -{ - static uint8_t data[1024]; - UINT r; - unsigned i; - RAWINPUT *ri = (RAWINPUT*)data; - UINT size = sizeof(data); - - if (msg != WM_INPUT) - return DefWindowProcA(wnd, msg, wpar, lpar); - - /* app is in the background */ - if (GET_RAWINPUT_CODE_WPARAM(wpar) != RIM_INPUT) - goto end; - - r = GetRawInputData((HRAWINPUT)lpar, RID_INPUT, - data, &size, sizeof(RAWINPUTHEADER)); - if (r == (UINT)-1) - { - RARCH_WARN("[WINRAW]: GetRawInputData failed with error %lu.\n", - GetLastError()); - goto end; - } - - if (ri->header.dwType == RIM_TYPEKEYBOARD) - { - if (ri->data.keyboard.Message == WM_KEYDOWN) - g_keyboard->keys[ri->data.keyboard.VKey] = 1; - else if (ri->data.keyboard.Message == WM_KEYUP) - g_keyboard->keys[ri->data.keyboard.VKey] = 0; - } - else if (ri->header.dwType == RIM_TYPEMOUSE) - { - for (i = 0; i < g_mouse_cnt; ++i) - { - if (g_mice[i].hnd == ri->header.hDevice) - { - winraw_update_mouse_state(&g_mice[i], &ri->data.mouse); - break; - } - } - } - -end: - DefWindowProcA(wnd, msg, wpar, lpar); - return 0; -} - -static void *winraw_init(const char *joypad_driver) -{ - bool r; - winraw_input_t *wr = (winraw_input_t *) - calloc(1, sizeof(winraw_input_t)); - g_keyboard = (winraw_keyboard_t*) - calloc(1, sizeof(winraw_keyboard_t)); - - if (!wr || !g_keyboard) - goto error; - - RARCH_LOG("[WINRAW]: Initializing input driver... \n"); - - input_keymaps_init_keyboard_lut(rarch_key_map_winraw); - - wr->window = winraw_create_window(winraw_callback); - if (!wr->window) - goto error; - - r = winraw_init_devices(&g_mice, &g_mouse_cnt); - if (!r) - goto error; - - if (!g_mouse_cnt) - { - RARCH_LOG("[WINRAW]: Mouse unavailable.\n"); - } - else - { - wr->mice = (winraw_mouse_t*) - malloc(g_mouse_cnt * sizeof(winraw_mouse_t)); - if (!wr->mice) - goto error; - - memcpy(wr->mice, g_mice, g_mouse_cnt * sizeof(winraw_mouse_t)); - } - - r = winraw_set_keyboard_input(wr->window); - if (!r) - goto error; - - r = winraw_set_mouse_input(wr->window, false); - if (!r) - goto error; - - wr->joypad = input_joypad_init_driver(joypad_driver, wr); - - return wr; - -error: - if (wr && wr->window) - { - winraw_set_mouse_input(NULL, false); - winraw_set_keyboard_input(NULL); - winraw_destroy_window(wr->window); - } - free(g_keyboard); - free(g_mice); - if (wr) - free(wr->mice); - free(wr); - return NULL; -} - -static void winraw_poll(void *d) -{ - unsigned i; - winraw_input_t *wr = (winraw_input_t*)d; - - memcpy(&wr->keyboard, g_keyboard, sizeof(winraw_keyboard_t)); - - /* following keys are not handled by windows raw input api */ - wr->keyboard.keys[VK_LCONTROL] = GetAsyncKeyState(VK_LCONTROL) >> 1 ? 1 : 0; - wr->keyboard.keys[VK_RCONTROL] = GetAsyncKeyState(VK_RCONTROL) >> 1 ? 1 : 0; - wr->keyboard.keys[VK_LMENU] = GetAsyncKeyState(VK_LMENU) >> 1 ? 1 : 0; - wr->keyboard.keys[VK_RMENU] = GetAsyncKeyState(VK_RMENU) >> 1 ? 1 : 0; - wr->keyboard.keys[VK_LSHIFT] = GetAsyncKeyState(VK_LSHIFT) >> 1 ? 1 : 0; - wr->keyboard.keys[VK_RSHIFT] = GetAsyncKeyState(VK_RSHIFT) >> 1 ? 1 : 0; - - for (i = 0; i < g_mouse_cnt; ++i) - { - wr->mice[i].x = g_mice[i].x; - wr->mice[i].y = g_mice[i].y; - wr->mice[i].dlt_x = InterlockedExchange(&g_mice[i].dlt_x, 0); - wr->mice[i].dlt_y = InterlockedExchange(&g_mice[i].dlt_y, 0); - wr->mice[i].whl_u = InterlockedExchange(&g_mice[i].whl_u, 0); - wr->mice[i].whl_d = InterlockedExchange(&g_mice[i].whl_d, 0); - wr->mice[i].btn_l = g_mice[i].btn_l; - wr->mice[i].btn_m = g_mice[i].btn_m; - wr->mice[i].btn_r = g_mice[i].btn_r; - wr->mice[i].btn_b4 = g_mice[i].btn_b4; - wr->mice[i].btn_b5 = g_mice[i].btn_b5; - } - - if (wr->joypad) - wr->joypad->poll(); -} - -static int16_t winraw_input_state(void *d, - rarch_joypad_info_t joypad_info, - const struct retro_keybind **binds, - unsigned port, unsigned device, unsigned index, unsigned id) -{ - winraw_input_t *wr = (winraw_input_t*)d; - - switch (device) - { - case RETRO_DEVICE_JOYPAD: - if (id < RARCH_BIND_LIST_END) - return winraw_is_pressed(wr, joypad_info, binds[port], port, id); - break; - case RETRO_DEVICE_KEYBOARD: - return (id < RETROK_LAST) && winraw_keyboard_pressed(wr, id); - case RETRO_DEVICE_MOUSE: - return winraw_mouse_state(wr, port, false, id); - case RARCH_DEVICE_MOUSE_SCREEN: - return winraw_mouse_state(wr, port, true, id); - case RETRO_DEVICE_ANALOG: - if (binds[port]) - return input_joypad_analog(wr->joypad, joypad_info, - port, index, id, binds[port]); - break; - case RETRO_DEVICE_LIGHTGUN: - switch ( id ) - { - /*aiming*/ - case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X: - case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y: - case RETRO_DEVICE_ID_LIGHTGUN_IS_OFFSCREEN: - return winraw_lightgun_aiming_state( wr, port, id ); - - /*buttons*/ - case RETRO_DEVICE_ID_LIGHTGUN_TRIGGER: - return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_TRIGGER); - case RETRO_DEVICE_ID_LIGHTGUN_RELOAD: - return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_RELOAD); - case RETRO_DEVICE_ID_LIGHTGUN_AUX_A: - return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_AUX_A); - case RETRO_DEVICE_ID_LIGHTGUN_AUX_B: - return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_AUX_B); - case RETRO_DEVICE_ID_LIGHTGUN_AUX_C: - return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_AUX_C); - case RETRO_DEVICE_ID_LIGHTGUN_START: - return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_START); - case RETRO_DEVICE_ID_LIGHTGUN_SELECT: - return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_SELECT); - case RETRO_DEVICE_ID_LIGHTGUN_DPAD_UP: - return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_DPAD_UP); - case RETRO_DEVICE_ID_LIGHTGUN_DPAD_DOWN: - return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_DPAD_DOWN); - case RETRO_DEVICE_ID_LIGHTGUN_DPAD_LEFT: - return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_DPAD_LEFT); - case RETRO_DEVICE_ID_LIGHTGUN_DPAD_RIGHT: - return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_DPAD_RIGHT); - - /*deprecated*/ - case RETRO_DEVICE_ID_LIGHTGUN_X: - case RETRO_DEVICE_ID_LIGHTGUN_Y: - return winraw_deprecated_lightgun_state(wr, port, id); - case RETRO_DEVICE_ID_LIGHTGUN_PAUSE: - return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_START); - } - break; - } - - return 0; -} - -static bool winraw_meta_key_pressed(void *u1, int u2) -{ - return false; -} - -static void winraw_free(void *d) -{ - winraw_input_t *wr = (winraw_input_t*)d; - - if (wr->joypad) - wr->joypad->destroy(); - winraw_set_mouse_input(NULL, false); - winraw_set_keyboard_input(NULL); - winraw_destroy_window(wr->window); - free(g_mice); - free(g_keyboard); - free(wr->mice); - free(wr); - - g_mouse_xy_mapping_ready = false; -} - -static uint64_t winraw_get_capabilities(void *u) -{ - return (1 << RETRO_DEVICE_KEYBOARD) | - (1 << RETRO_DEVICE_MOUSE) | - (1 << RETRO_DEVICE_JOYPAD) | - (1 << RETRO_DEVICE_ANALOG) | - (1 << RETRO_DEVICE_LIGHTGUN); -} - -static void winraw_grab_mouse(void *d, bool grab) -{ - bool r = false; - winraw_input_t *wr = (winraw_input_t*)d; - - if (grab == wr->mouse_grab) - return; - - r = winraw_set_mouse_input(wr->window, grab); - if (!r) - return; - - wr->mouse_grab = grab; -} - -static bool winraw_set_rumble(void *d, unsigned port, - enum retro_rumble_effect effect, uint16_t strength) -{ - winraw_input_t *wr = (winraw_input_t*)d; - - return input_joypad_set_rumble(wr->joypad, port, effect, strength); -} - -static const input_device_driver_t *winraw_get_joypad_driver(void *d) -{ - winraw_input_t *wr = (winraw_input_t*)d; - - return wr->joypad; -} - -static bool winraw_keyboard_mapping_is_blocked(void *d) -{ - winraw_input_t *wr = (winraw_input_t*)d; - - return wr->kbd_mapp_block; -} - -static void winraw_keyboard_mapping_set_block(void *d, bool block) -{ - winraw_input_t *wr = (winraw_input_t*)d; - - wr->kbd_mapp_block = block; -} - -input_driver_t input_winraw = { - winraw_init, - winraw_poll, - winraw_input_state, - winraw_meta_key_pressed, - winraw_free, - NULL, - NULL, - winraw_get_capabilities, - "raw", - winraw_grab_mouse, - NULL, - winraw_set_rumble, - winraw_get_joypad_driver, - NULL, - winraw_keyboard_mapping_is_blocked, - winraw_keyboard_mapping_set_block, -}; +/* RetroArch - A frontend for libretro. + * Copyright (C) 2011-2017 - Daniel De Matteis + * + * RetroArch 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 Found- + * ation, either version 3 of the License, or (at your option) any later version. + * + * RetroArch 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 RetroArch. + * If not, see . + */ + +#include + +#include "../input_driver.h" +#include "../input_keymaps.h" + +#include "../../configuration.h" +#include "../../gfx/video_driver.h" +#include "../../verbosity.h" + +typedef struct +{ + uint8_t keys[256]; +} winraw_keyboard_t; + +typedef struct +{ + HANDLE hnd; + LONG x, y, dlt_x, dlt_y; + LONG whl_u, whl_d; + bool btn_l, btn_m, btn_r, btn_b4, btn_b5; +} winraw_mouse_t; + +typedef struct +{ + bool kbd_mapp_block; + bool mouse_grab; + winraw_keyboard_t keyboard; + HWND window; + winraw_mouse_t *mice; + const input_device_driver_t *joypad; +} winraw_input_t; + +static winraw_keyboard_t *g_keyboard = NULL; +static winraw_mouse_t *g_mice = NULL; +static unsigned g_mouse_cnt = 0; +static bool g_mouse_xy_mapping_ready = false; +static double g_view_abs_ratio_x = 0.0; +static double g_view_abs_ratio_y = 0.0; + +static HWND winraw_create_window(WNDPROC wnd_proc) +{ + HWND wnd; + WNDCLASSA wc = {0}; + + wc.hInstance = GetModuleHandleA(NULL); + + if (!wc.hInstance) + { + RARCH_ERR("[WINRAW]: GetModuleHandleA failed with error %lu.\n", GetLastError()); + return NULL; + } + + wc.lpfnWndProc = wnd_proc; + wc.lpszClassName = "winraw-input"; + if (!RegisterClassA(&wc) && GetLastError() != ERROR_CLASS_ALREADY_EXISTS) + { + RARCH_ERR("[WINRAW]: RegisterClassA failed with error %lu.\n", GetLastError()); + return NULL; + } + + wnd = CreateWindowExA(0, wc.lpszClassName, NULL, 0, 0, 0, 0, 0, + HWND_MESSAGE, NULL, NULL, NULL); + if (!wnd) + { + RARCH_ERR("[WINRAW]: CreateWindowExA failed with error %lu.\n", GetLastError()); + goto error; + } + + return wnd; + +error: + UnregisterClassA(wc.lpszClassName, NULL); + return NULL; +} + +static void winraw_destroy_window(HWND wnd) +{ + BOOL r; + + if (!wnd) + return; + + r = DestroyWindow(wnd); + + if (!r) + { + RARCH_WARN("[WINRAW]: DestroyWindow failed with error %lu.\n", GetLastError()); + } + + r = UnregisterClassA("winraw-input", NULL); + + if (!r) + { + RARCH_WARN("[WINRAW]: UnregisterClassA failed with error %lu.\n", GetLastError()); + } +} + +static bool winraw_set_keyboard_input(HWND window) +{ + RAWINPUTDEVICE rid; + BOOL r; + + rid.dwFlags = window ? 0 : RIDEV_REMOVE; + rid.hwndTarget = window; + rid.usUsagePage = 0x01; /* generic desktop */ + rid.usUsage = 0x06; /* keyboard */ + + r = RegisterRawInputDevices(&rid, 1, sizeof(RAWINPUTDEVICE)); + + if (!r) + { + RARCH_ERR("[WINRAW]: RegisterRawInputDevices failed with error %lu.\n", GetLastError()); + return false; + } + + return true; +} + +static void winraw_log_mice_info(winraw_mouse_t *mice, unsigned mouse_cnt) +{ + UINT r; + unsigned i; + char name[256]; + UINT name_size = sizeof(name); + + for (i = 0; i < mouse_cnt; ++i) + { + r = GetRawInputDeviceInfoA(mice[i].hnd, RIDI_DEVICENAME, name, &name_size); + if (r == (UINT)-1 || r == 0) + name[0] = '\0'; + RARCH_LOG("[WINRAW]: Mouse #%u %s.\n", i, name); + } +} + +static bool winraw_init_devices(winraw_mouse_t **mice, unsigned *mouse_cnt) +{ + UINT i; + POINT crs_pos; + winraw_mouse_t *mice_r = NULL; + unsigned mouse_cnt_r = 0; + RAWINPUTDEVICELIST *devs = NULL; + UINT dev_cnt = 0; + UINT r = GetRawInputDeviceList( + NULL, &dev_cnt, sizeof(RAWINPUTDEVICELIST)); + + if (r == (UINT)-1) + { + RARCH_ERR("[WINRAW]: GetRawInputDeviceList failed with error %lu.\n", GetLastError()); + goto error; + } + + devs = (RAWINPUTDEVICELIST*)malloc(dev_cnt * sizeof(RAWINPUTDEVICELIST)); + if (!devs) + goto error; + + dev_cnt = GetRawInputDeviceList(devs, &dev_cnt, sizeof(RAWINPUTDEVICELIST)); + if (dev_cnt == (UINT)-1) + { + RARCH_ERR("[WINRAW]: GetRawInputDeviceList failed with error %lu.\n", GetLastError()); + goto error; + } + + for (i = 0; i < dev_cnt; ++i) + mouse_cnt_r += devs[i].dwType == RIM_TYPEMOUSE ? 1 : 0; + + if (mouse_cnt_r) + { + mice_r = (winraw_mouse_t*)calloc(1, mouse_cnt_r * sizeof(winraw_mouse_t)); + if (!mice_r) + goto error; + + if (!GetCursorPos(&crs_pos)) + goto error; + + for (i = 0; i < mouse_cnt_r; ++i) + { + mice_r[i].x = crs_pos.x; + mice_r[i].y = crs_pos.y; + } + } + + /* count is already checked, so this is safe */ + for (i = mouse_cnt_r = 0; i < dev_cnt; ++i) + { + if (devs[i].dwType == RIM_TYPEMOUSE) + mice_r[mouse_cnt_r++].hnd = devs[i].hDevice; + } + + winraw_log_mice_info(mice_r, mouse_cnt_r); + + *mice = mice_r; + *mouse_cnt = mouse_cnt_r; + + return true; + +error: + free(devs); + free(mice_r); + *mice = NULL; + *mouse_cnt = 0; + return false; +} + +static bool winraw_set_mouse_input(HWND window, bool grab) +{ + RAWINPUTDEVICE rid; + BOOL r; + + if (window) + rid.dwFlags = grab ? RIDEV_CAPTUREMOUSE : 0; + else + rid.dwFlags = RIDEV_REMOVE; + + rid.hwndTarget = window; + rid.usUsagePage = 0x01; /* generic desktop */ + rid.usUsage = 0x02; /* mouse */ + + r = RegisterRawInputDevices(&rid, 1, sizeof(RAWINPUTDEVICE)); + + if (!r) + { + RARCH_ERR("[WINRAW]: RegisterRawInputDevice failed with error %lu.\n", GetLastError()); + return false; + } + + return true; +} + +static int16_t winraw_lightgun_aiming_state(winraw_input_t *wr, + unsigned port, unsigned id) +{ + const int edge_detect = 32700; + struct video_viewport vp; + bool inside = false; + unsigned i; + settings_t *settings = config_get_ptr(); + winraw_mouse_t *mouse = NULL; + int16_t res_x = 0; + int16_t res_y = 0; + int16_t res_screen_x = 0; + int16_t res_screen_y = 0; + + if (port >= MAX_USERS) + return 0; + + for (i = 0; i < g_mouse_cnt; ++i) + { + if (i == settings->uints.input_mouse_index[port]) + { + mouse = &wr->mice[i]; + break; + } + } + + if (!mouse) + return 0; + + vp.x = 0; + vp.y = 0; + vp.width = 0; + vp.height = 0; + vp.full_width = 0; + vp.full_height = 0; + + if ( !( video_driver_translate_coord_viewport_wrap( + &vp, mouse->x, mouse->y, &res_x, &res_y, &res_screen_x, &res_screen_y ) ) ) + { + return 0; + } + + inside = (res_x >= -edge_detect) && (res_y >= -edge_detect) && (res_x <= edge_detect) && (res_y <= edge_detect); + + switch ( id ) + { + case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X: + return inside ? res_x : 0; + case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y: + return inside ? res_y : 0; + case RETRO_DEVICE_ID_LIGHTGUN_IS_OFFSCREEN: + return !inside; + default: + break; + } + + return 0; +} + +static int16_t winraw_mouse_state(winraw_input_t *wr, + unsigned port, bool abs, unsigned id) +{ + unsigned i; + settings_t *settings = config_get_ptr(); + winraw_mouse_t *mouse = NULL; + + if (port >= MAX_USERS) + return 0; + + for (i = 0; i < g_mouse_cnt; ++i) + { + if (i == settings->uints.input_mouse_index[port]) + { + mouse = &wr->mice[i]; + break; + } + } + + if (!mouse) + return 0; + + switch (id) + { + case RETRO_DEVICE_ID_MOUSE_X: + return abs ? mouse->x : mouse->dlt_x; + case RETRO_DEVICE_ID_MOUSE_Y: + return abs ? mouse->y : mouse->dlt_y; + case RETRO_DEVICE_ID_MOUSE_LEFT: + return mouse->btn_l ? 1 : 0; + case RETRO_DEVICE_ID_MOUSE_RIGHT: + return mouse->btn_r ? 1 : 0; + case RETRO_DEVICE_ID_MOUSE_WHEELUP: + return mouse->whl_u ? 1 : 0; + case RETRO_DEVICE_ID_MOUSE_WHEELDOWN: + return mouse->whl_d ? 1 : 0; + case RETRO_DEVICE_ID_MOUSE_MIDDLE: + return mouse->btn_m ? 1 : 0; + case RETRO_DEVICE_ID_MOUSE_BUTTON_4: + return mouse->btn_b4 ? 1 : 0; + case RETRO_DEVICE_ID_MOUSE_BUTTON_5: + return mouse->btn_b5 ? 1 : 0; + } + + return 0; +} + +static bool winraw_keyboard_pressed(winraw_input_t *wr, unsigned key) +{ + unsigned k = rarch_keysym_lut[(enum retro_key)key]; + return wr->keyboard.keys[k]; +} + +static bool winraw_mbutton_pressed(winraw_input_t *wr, unsigned port, unsigned key) +{ + unsigned i; + winraw_mouse_t *mouse = NULL; + settings_t *settings = config_get_ptr(); + + if (port >= MAX_USERS) + return false; + + for (i = 0; i < g_mouse_cnt; ++i) + { + if (i == settings->uints.input_mouse_index[port]) + { + mouse = &wr->mice[i]; + break; + } + } + + if (!mouse) + return false; + + switch ( key ) + { + + case RETRO_DEVICE_ID_MOUSE_LEFT: + return mouse->btn_l; + case RETRO_DEVICE_ID_MOUSE_RIGHT: + return mouse->btn_r; + case RETRO_DEVICE_ID_MOUSE_MIDDLE: + return mouse->btn_m; + case RETRO_DEVICE_ID_MOUSE_BUTTON_4: + return mouse->btn_b4; + case RETRO_DEVICE_ID_MOUSE_BUTTON_5: + return mouse->btn_b5; + case RETRO_DEVICE_ID_MOUSE_WHEELUP: + return mouse->whl_u; + case RETRO_DEVICE_ID_MOUSE_WHEELDOWN: + return mouse->whl_d; + } + + return false; +} + +static bool winraw_is_pressed(winraw_input_t *wr, + rarch_joypad_info_t joypad_info, + const struct retro_keybind *binds, + unsigned port, unsigned id) +{ + const struct retro_keybind *bind = &binds[id]; + + if (!wr->kbd_mapp_block && (bind->key < RETROK_LAST) && winraw_keyboard_pressed(wr, bind->key)) + return true; + if (binds && binds[id].valid) + { + if (winraw_mbutton_pressed(wr, port, bind->mbutton)) + return true; + if (input_joypad_pressed(wr->joypad, joypad_info, port, binds, id)) + return true; + } + + return false; +} + +static void winraw_init_mouse_xy_mapping() +{ + struct video_viewport viewport; + int center_x; + int center_y; + unsigned i; + + if (video_driver_get_viewport_info(&viewport)) + { + center_x = viewport.x + viewport.width / 2; + center_y = viewport.y + viewport.height / 2; + + for (i = 0; i < g_mouse_cnt; ++i) + { + g_mice[i].x = center_x; + g_mice[i].y = center_y; + } + + g_view_abs_ratio_x = (double)viewport.full_width / 65535.0; + g_view_abs_ratio_y = (double)viewport.full_height / 65535.0; + + g_mouse_xy_mapping_ready = true; + } +} + +static int16_t winraw_deprecated_lightgun_state(winraw_input_t *wr, + unsigned port, unsigned id) +{ + unsigned i; + settings_t *settings = config_get_ptr(); + winraw_mouse_t *mouse = NULL; + + if (port >= MAX_USERS) + return 0; + + for (i = 0; i < g_mouse_cnt; ++i) + { + if (i == settings->uints.input_mouse_index[port]) + { + mouse = &wr->mice[i]; + break; + } + } + + if (!mouse) + return 0; + + switch (id) + { + case RETRO_DEVICE_ID_LIGHTGUN_X: + return mouse->dlt_x; + case RETRO_DEVICE_ID_LIGHTGUN_Y: + return mouse->dlt_y; + } + + return 0; +} + +static void winraw_update_mouse_state(winraw_mouse_t *mouse, RAWMOUSE *state) +{ + POINT crs_pos; + + if (state->usFlags & MOUSE_MOVE_ABSOLUTE) + { + if (g_mouse_xy_mapping_ready) + { + state->lLastX = (LONG)(g_view_abs_ratio_x * state->lLastX); + state->lLastY = (LONG)(g_view_abs_ratio_y * state->lLastY); + InterlockedExchangeAdd(&mouse->dlt_x, state->lLastX - mouse->x); + InterlockedExchangeAdd(&mouse->dlt_y, state->lLastY - mouse->y); + mouse->x = state->lLastX; + mouse->y = state->lLastY; + } + else + winraw_init_mouse_xy_mapping(); + } + else if (state->lLastX || state->lLastY) + { + InterlockedExchangeAdd(&mouse->dlt_x, state->lLastX); + InterlockedExchangeAdd(&mouse->dlt_y, state->lLastY); + + if (!GetCursorPos(&crs_pos)) + { + RARCH_WARN("[WINRAW]: GetCursorPos failed with error %lu.\n", GetLastError()); + } + else if (!ScreenToClient((HWND)video_driver_window_get(), &crs_pos)) + { + RARCH_WARN("[WINRAW]: ScreenToClient failed with error %lu.\n", GetLastError()); + } + else + { + mouse->x = crs_pos.x; + mouse->y = crs_pos.y; + } + } + + if (state->usButtonFlags & RI_MOUSE_LEFT_BUTTON_DOWN) + mouse->btn_l = true; + else if (state->usButtonFlags & RI_MOUSE_LEFT_BUTTON_UP) + mouse->btn_l = false; + + if (state->usButtonFlags & RI_MOUSE_MIDDLE_BUTTON_DOWN) + mouse->btn_m = true; + else if (state->usButtonFlags & RI_MOUSE_MIDDLE_BUTTON_UP) + mouse->btn_m = false; + + if (state->usButtonFlags & RI_MOUSE_RIGHT_BUTTON_DOWN) + mouse->btn_r = true; + else if (state->usButtonFlags & RI_MOUSE_RIGHT_BUTTON_UP) + mouse->btn_r = false; + + if (state->usButtonFlags & RI_MOUSE_BUTTON_4_DOWN) + mouse->btn_b4 = true; + else if (state->usButtonFlags & RI_MOUSE_BUTTON_4_UP) + mouse->btn_b4 = false; + + if (state->usButtonFlags & RI_MOUSE_BUTTON_5_DOWN) + mouse->btn_b5 = true; + else if (state->usButtonFlags & RI_MOUSE_BUTTON_5_UP) + mouse->btn_b5 = false; + + if (state->usButtonFlags & RI_MOUSE_WHEEL) + { + if ((SHORT)state->usButtonData > 0) + InterlockedExchange(&mouse->whl_u, 1); + else if ((SHORT)state->usButtonData < 0) + InterlockedExchange(&mouse->whl_d, 1); + } +} + +static LRESULT CALLBACK winraw_callback(HWND wnd, UINT msg, WPARAM wpar, LPARAM lpar) +{ + static uint8_t data[1024]; + UINT r; + unsigned i; + RAWINPUT *ri = (RAWINPUT*)data; + UINT size = sizeof(data); + + if (msg != WM_INPUT) + return DefWindowProcA(wnd, msg, wpar, lpar); + + /* app is in the background */ + if (GET_RAWINPUT_CODE_WPARAM(wpar) != RIM_INPUT) + goto end; + + r = GetRawInputData((HRAWINPUT)lpar, RID_INPUT, + data, &size, sizeof(RAWINPUTHEADER)); + if (r == (UINT)-1) + { + RARCH_WARN("[WINRAW]: GetRawInputData failed with error %lu.\n", + GetLastError()); + goto end; + } + + if (ri->header.dwType == RIM_TYPEKEYBOARD) + { + if (ri->data.keyboard.Message == WM_KEYDOWN) + g_keyboard->keys[ri->data.keyboard.VKey] = 1; + else if (ri->data.keyboard.Message == WM_KEYUP) + g_keyboard->keys[ri->data.keyboard.VKey] = 0; + } + else if (ri->header.dwType == RIM_TYPEMOUSE) + { + for (i = 0; i < g_mouse_cnt; ++i) + { + if (g_mice[i].hnd == ri->header.hDevice) + { + winraw_update_mouse_state(&g_mice[i], &ri->data.mouse); + break; + } + } + } + +end: + DefWindowProcA(wnd, msg, wpar, lpar); + return 0; +} + +static void *winraw_init(const char *joypad_driver) +{ + bool r; + winraw_input_t *wr = (winraw_input_t *) + calloc(1, sizeof(winraw_input_t)); + g_keyboard = (winraw_keyboard_t*) + calloc(1, sizeof(winraw_keyboard_t)); + + if (!wr || !g_keyboard) + goto error; + + RARCH_LOG("[WINRAW]: Initializing input driver... \n"); + + input_keymaps_init_keyboard_lut(rarch_key_map_winraw); + + wr->window = winraw_create_window(winraw_callback); + if (!wr->window) + goto error; + + r = winraw_init_devices(&g_mice, &g_mouse_cnt); + if (!r) + goto error; + + if (!g_mouse_cnt) + { + RARCH_LOG("[WINRAW]: Mouse unavailable.\n"); + } + else + { + wr->mice = (winraw_mouse_t*) + malloc(g_mouse_cnt * sizeof(winraw_mouse_t)); + if (!wr->mice) + goto error; + + memcpy(wr->mice, g_mice, g_mouse_cnt * sizeof(winraw_mouse_t)); + } + + r = winraw_set_keyboard_input(wr->window); + if (!r) + goto error; + + r = winraw_set_mouse_input(wr->window, false); + if (!r) + goto error; + + wr->joypad = input_joypad_init_driver(joypad_driver, wr); + + return wr; + +error: + if (wr && wr->window) + { + winraw_set_mouse_input(NULL, false); + winraw_set_keyboard_input(NULL); + winraw_destroy_window(wr->window); + } + free(g_keyboard); + free(g_mice); + if (wr) + free(wr->mice); + free(wr); + return NULL; +} + +static void winraw_poll(void *d) +{ + unsigned i; + winraw_input_t *wr = (winraw_input_t*)d; + + memcpy(&wr->keyboard, g_keyboard, sizeof(winraw_keyboard_t)); + + /* following keys are not handled by windows raw input api */ + wr->keyboard.keys[VK_LCONTROL] = GetAsyncKeyState(VK_LCONTROL) >> 1 ? 1 : 0; + wr->keyboard.keys[VK_RCONTROL] = GetAsyncKeyState(VK_RCONTROL) >> 1 ? 1 : 0; + wr->keyboard.keys[VK_LMENU] = GetAsyncKeyState(VK_LMENU) >> 1 ? 1 : 0; + wr->keyboard.keys[VK_RMENU] = GetAsyncKeyState(VK_RMENU) >> 1 ? 1 : 0; + wr->keyboard.keys[VK_LSHIFT] = GetAsyncKeyState(VK_LSHIFT) >> 1 ? 1 : 0; + wr->keyboard.keys[VK_RSHIFT] = GetAsyncKeyState(VK_RSHIFT) >> 1 ? 1 : 0; + + for (i = 0; i < g_mouse_cnt; ++i) + { + wr->mice[i].x = g_mice[i].x; + wr->mice[i].y = g_mice[i].y; + wr->mice[i].dlt_x = InterlockedExchange(&g_mice[i].dlt_x, 0); + wr->mice[i].dlt_y = InterlockedExchange(&g_mice[i].dlt_y, 0); + wr->mice[i].whl_u = InterlockedExchange(&g_mice[i].whl_u, 0); + wr->mice[i].whl_d = InterlockedExchange(&g_mice[i].whl_d, 0); + wr->mice[i].btn_l = g_mice[i].btn_l; + wr->mice[i].btn_m = g_mice[i].btn_m; + wr->mice[i].btn_r = g_mice[i].btn_r; + wr->mice[i].btn_b4 = g_mice[i].btn_b4; + wr->mice[i].btn_b5 = g_mice[i].btn_b5; + } + + if (wr->joypad) + wr->joypad->poll(); +} + +static int16_t winraw_input_state(void *d, + rarch_joypad_info_t joypad_info, + const struct retro_keybind **binds, + unsigned port, unsigned device, unsigned index, unsigned id) +{ + winraw_input_t *wr = (winraw_input_t*)d; + + switch (device) + { + case RETRO_DEVICE_JOYPAD: + if (id < RARCH_BIND_LIST_END) + return winraw_is_pressed(wr, joypad_info, binds[port], port, id); + break; + case RETRO_DEVICE_KEYBOARD: + return (id < RETROK_LAST) && winraw_keyboard_pressed(wr, id); + case RETRO_DEVICE_MOUSE: + return winraw_mouse_state(wr, port, false, id); + case RARCH_DEVICE_MOUSE_SCREEN: + return winraw_mouse_state(wr, port, true, id); + case RETRO_DEVICE_ANALOG: + if (binds[port]) + return input_joypad_analog(wr->joypad, joypad_info, + port, index, id, binds[port]); + break; + case RETRO_DEVICE_LIGHTGUN: + switch ( id ) + { + /*aiming*/ + case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_X: + case RETRO_DEVICE_ID_LIGHTGUN_SCREEN_Y: + case RETRO_DEVICE_ID_LIGHTGUN_IS_OFFSCREEN: + return winraw_lightgun_aiming_state( wr, port, id ); + + /*buttons*/ + case RETRO_DEVICE_ID_LIGHTGUN_TRIGGER: + return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_TRIGGER); + case RETRO_DEVICE_ID_LIGHTGUN_RELOAD: + return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_RELOAD); + case RETRO_DEVICE_ID_LIGHTGUN_AUX_A: + return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_AUX_A); + case RETRO_DEVICE_ID_LIGHTGUN_AUX_B: + return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_AUX_B); + case RETRO_DEVICE_ID_LIGHTGUN_AUX_C: + return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_AUX_C); + case RETRO_DEVICE_ID_LIGHTGUN_START: + return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_START); + case RETRO_DEVICE_ID_LIGHTGUN_SELECT: + return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_SELECT); + case RETRO_DEVICE_ID_LIGHTGUN_DPAD_UP: + return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_DPAD_UP); + case RETRO_DEVICE_ID_LIGHTGUN_DPAD_DOWN: + return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_DPAD_DOWN); + case RETRO_DEVICE_ID_LIGHTGUN_DPAD_LEFT: + return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_DPAD_LEFT); + case RETRO_DEVICE_ID_LIGHTGUN_DPAD_RIGHT: + return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_DPAD_RIGHT); + + /*deprecated*/ + case RETRO_DEVICE_ID_LIGHTGUN_X: + case RETRO_DEVICE_ID_LIGHTGUN_Y: + return winraw_deprecated_lightgun_state(wr, port, id); + case RETRO_DEVICE_ID_LIGHTGUN_PAUSE: + return winraw_is_pressed(wr, joypad_info, binds[port], port, RARCH_LIGHTGUN_START); + } + break; + } + + return 0; +} + +static bool winraw_meta_key_pressed(void *u1, int u2) +{ + return false; +} + +static void winraw_free(void *d) +{ + winraw_input_t *wr = (winraw_input_t*)d; + + if (wr->joypad) + wr->joypad->destroy(); + winraw_set_mouse_input(NULL, false); + winraw_set_keyboard_input(NULL); + winraw_destroy_window(wr->window); + free(g_mice); + free(g_keyboard); + free(wr->mice); + free(wr); + + g_mouse_xy_mapping_ready = false; +} + +static uint64_t winraw_get_capabilities(void *u) +{ + return (1 << RETRO_DEVICE_KEYBOARD) | + (1 << RETRO_DEVICE_MOUSE) | + (1 << RETRO_DEVICE_JOYPAD) | + (1 << RETRO_DEVICE_ANALOG) | + (1 << RETRO_DEVICE_LIGHTGUN); +} + +static void winraw_grab_mouse(void *d, bool grab) +{ + bool r = false; + winraw_input_t *wr = (winraw_input_t*)d; + + if (grab == wr->mouse_grab) + return; + + r = winraw_set_mouse_input(wr->window, grab); + if (!r) + return; + + wr->mouse_grab = grab; +} + +static bool winraw_set_rumble(void *d, unsigned port, + enum retro_rumble_effect effect, uint16_t strength) +{ + winraw_input_t *wr = (winraw_input_t*)d; + + return input_joypad_set_rumble(wr->joypad, port, effect, strength); +} + +static const input_device_driver_t *winraw_get_joypad_driver(void *d) +{ + winraw_input_t *wr = (winraw_input_t*)d; + + return wr->joypad; +} + +static bool winraw_keyboard_mapping_is_blocked(void *d) +{ + winraw_input_t *wr = (winraw_input_t*)d; + + return wr->kbd_mapp_block; +} + +static void winraw_keyboard_mapping_set_block(void *d, bool block) +{ + winraw_input_t *wr = (winraw_input_t*)d; + + wr->kbd_mapp_block = block; +} + +input_driver_t input_winraw = { + winraw_init, + winraw_poll, + winraw_input_state, + winraw_meta_key_pressed, + winraw_free, + NULL, + NULL, + winraw_get_capabilities, + "raw", + winraw_grab_mouse, + NULL, + winraw_set_rumble, + winraw_get_joypad_driver, + NULL, + winraw_keyboard_mapping_is_blocked, + winraw_keyboard_mapping_set_block, +}; diff --git a/input/drivers/x11_input.c b/input/drivers/x11_input.c index e21e9a100e..9e357870bf 100644 --- a/input/drivers/x11_input.c +++ b/input/drivers/x11_input.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2015 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -156,7 +156,7 @@ static int16_t x_pressed_analog(x11_input_t *x11, int id_plus_key = 0; unsigned sym = 0; int keycode = 0; - + input_conv_analog_id_to_bind_id(idx, id, &id_minus, &id_plus); id_minus_key = binds[id_minus].key; @@ -164,15 +164,15 @@ static int16_t x_pressed_analog(x11_input_t *x11, sym = rarch_keysym_lut[(enum retro_key)id_minus_key]; keycode = XKeysymToKeycode(x11->display, sym); - if ( binds[id_minus].valid + if ( binds[id_minus].valid && (id_minus_key < RETROK_LAST) && (x11->state[keycode >> 3] & (1 << (keycode & 7)))) pressed_minus = -0x7fff; sym = rarch_keysym_lut[(enum retro_key)id_plus_key]; keycode = XKeysymToKeycode(x11->display, sym); - if ( binds[id_plus].valid - && (id_plus_key < RETROK_LAST) + if ( binds[id_plus].valid + && (id_plus_key < RETROK_LAST) && (x11->state[keycode >> 3] & (1 << (keycode & 7)))) pressed_plus = 0x7fff; @@ -421,9 +421,9 @@ static void x_input_poll_mouse(x11_input_t *x11) { x11->mouse_x = win_x; x11->mouse_y = win_y; - x11->mouse_l = mask & Button1Mask; - x11->mouse_m = mask & Button2Mask; - x11->mouse_r = mask & Button3Mask; + x11->mouse_l = mask & Button1Mask; + x11->mouse_m = mask & Button2Mask; + x11->mouse_r = mask & Button3Mask; /* Somewhat hacky, but seem to do the job. */ if (x11->grab_mouse && video_driver_cb_has_focus()) diff --git a/input/drivers/xdk_xinput_input.c b/input/drivers/xdk_xinput_input.c index d6c45a6d8a..a603d0ae62 100644 --- a/input/drivers/xdk_xinput_input.c +++ b/input/drivers/xdk_xinput_input.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -106,7 +106,7 @@ static uint64_t xdk_input_get_capabilities(void *data) return (1 << RETRO_DEVICE_JOYPAD) | (1 << RETRO_DEVICE_ANALOG); } -/* FIXME - are we sure about treating low frequency motor as the +/* FIXME - are we sure about treating low frequency motor as the * "strong" motor? Does it apply for Xbox too? */ static bool xdk_input_set_rumble(void *data, unsigned port, @@ -119,9 +119,9 @@ static bool xdk_input_set_rumble(void *data, unsigned port, #endif xdk_input_t *xdk = (xdk_input_t*)data; bool val = false; - + (void)xdk; - + #if 0 #if defined(_XBOX360) if (effect == RETRO_RUMBLE_STRONG) diff --git a/input/drivers/xenon360_input.c b/input/drivers/xenon360_input.c index e1d1142bb9..f1c933a68e 100644 --- a/input/drivers/xenon360_input.c +++ b/input/drivers/xenon360_input.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/input/drivers_hid/libusb_hid.c b/input/drivers_hid/libusb_hid.c index f2fd6d0bca..c03004b395 100644 --- a/input/drivers_hid/libusb_hid.c +++ b/input/drivers_hid/libusb_hid.c @@ -94,13 +94,13 @@ static void adapter_thread(void *data) int size = 0; slock_lock(adapter->send_control_lock); - if (fifo_read_avail(adapter->send_control_buffer) + if (fifo_read_avail(adapter->send_control_buffer) >= sizeof(send_command_size)) { fifo_read(adapter->send_control_buffer, &send_command_size, sizeof(send_command_size)); - if (fifo_read_avail(adapter->send_control_buffer) + if (fifo_read_avail(adapter->send_control_buffer) >= sizeof(send_command_size)) { fifo_read(adapter->send_control_buffer, @@ -180,7 +180,7 @@ static void libusb_get_description(struct libusb_device *device, for(j = 0; j < inter->num_altsetting; j++) { - const struct libusb_interface_descriptor *interdesc = + const struct libusb_interface_descriptor *interdesc = &inter->altsetting[j]; #if 0 @@ -191,13 +191,13 @@ static void libusb_get_description(struct libusb_device *device, for(k = 0; k < (int)interdesc->bNumEndpoints; k++) { - const struct libusb_endpoint_descriptor *epdesc = + const struct libusb_endpoint_descriptor *epdesc = &interdesc->endpoint[k]; - bool is_int = (epdesc->bmAttributes & LIBUSB_TRANSFER_TYPE_MASK) + bool is_int = (epdesc->bmAttributes & LIBUSB_TRANSFER_TYPE_MASK) == LIBUSB_TRANSFER_TYPE_INTERRUPT; - bool is_out = (epdesc->bEndpointAddress & LIBUSB_ENDPOINT_DIR_MASK) + bool is_out = (epdesc->bEndpointAddress & LIBUSB_ENDPOINT_DIR_MASK) == LIBUSB_ENDPOINT_OUT; - bool is_in = (epdesc->bEndpointAddress & LIBUSB_ENDPOINT_DIR_MASK) + bool is_in = (epdesc->bEndpointAddress & LIBUSB_ENDPOINT_DIR_MASK) == LIBUSB_ENDPOINT_IN; if (is_int) diff --git a/input/drivers_joypad/dinput_joypad.c b/input/drivers_joypad/dinput_joypad.c index b04e739790..c92d9179ad 100644 --- a/input/drivers_joypad/dinput_joypad.c +++ b/input/drivers_joypad/dinput_joypad.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -141,11 +141,11 @@ static bool guid_is_xinput_device(const GUID* product_guid) unsigned i, num_raw_devs = 0; PRAWINPUTDEVICELIST raw_devs = NULL; - /* Check for well known XInput device GUIDs, + /* Check for well known XInput device GUIDs, * thereby removing the need for the IG_ check. - * This lets us skip RAWINPUT for popular devices. + * This lets us skip RAWINPUT for popular devices. * - * Also, we need to do this for the Valve Streaming Gamepad + * Also, we need to do this for the Valve Streaming Gamepad * because it's virtualized and doesn't show up in the device list. */ for (i = 0; i < ARRAY_SIZE(common_xinput_guids); ++i) diff --git a/input/drivers_joypad/sdl_joypad.c b/input/drivers_joypad/sdl_joypad.c index fa141059e0..05ccfad1a5 100644 --- a/input/drivers_joypad/sdl_joypad.c +++ b/input/drivers_joypad/sdl_joypad.c @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis * Copyright (C) 2014-2017 - Higor Euripedes - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/input/drivers_joypad/xinput_joypad.c b/input/drivers_joypad/xinput_joypad.c index f7eb8bd347..77a9680d52 100644 --- a/input/drivers_joypad/xinput_joypad.c +++ b/input/drivers_joypad/xinput_joypad.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2013-2015 - pinumbernumber * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -96,8 +96,8 @@ typedef struct #define ERROR_DEVICE_NOT_CONNECTED 1167 #endif -/* Due to 360 pads showing up under both XInput and DirectInput, - * and since we are going to have to pass through unhandled +/* Due to 360 pads showing up under both XInput and DirectInput, + * and since we are going to have to pass through unhandled * joypad numbers to DirectInput, a slightly ugly * hack is required here. dinput_joypad_init will fill this. * @@ -191,7 +191,7 @@ static bool xinput_joypad_init(void *data) * success anyway. */ - g_xinput_dll = dylib_load("xinput1_4.dll"); + g_xinput_dll = dylib_load("xinput1_4.dll"); if (!g_xinput_dll) { g_xinput_dll = dylib_load("xinput1_3.dll"); @@ -255,7 +255,7 @@ static bool xinput_joypad_init(void *data) (!g_xinput_states[3].connected)) return false; - RARCH_LOG("[XInput]: Pads connected: %d\n", g_xinput_states[0].connected + + RARCH_LOG("[XInput]: Pads connected: %d\n", g_xinput_states[0].connected + g_xinput_states[1].connected + g_xinput_states[2].connected + g_xinput_states[3].connected); g_xinput_block_pads = true; @@ -350,7 +350,7 @@ static const uint16_t button_index_to_bitmap_code[] = { XINPUT_GAMEPAD_BACK, XINPUT_GAMEPAD_LEFT_THUMB, XINPUT_GAMEPAD_RIGHT_THUMB, - XINPUT_GAMEPAD_GUIDE + XINPUT_GAMEPAD_GUIDE }; static bool xinput_joypad_button(unsigned port_num, uint16_t joykey) @@ -420,7 +420,7 @@ static int16_t xinput_joypad_axis (unsigned port_num, uint32_t joyaxis) return 0; /* triggers (axes 4,5) cannot be negative */ - if (AXIS_NEG_GET(joyaxis) <= 3) + if (AXIS_NEG_GET(joyaxis) <= 3) { axis = AXIS_NEG_GET(joyaxis); is_neg = true; @@ -475,8 +475,8 @@ static void xinput_joypad_poll(void) { if (g_xinput_states[i].connected) { - if (g_XInputGetStateEx(i, - &(g_xinput_states[i].xstate)) + if (g_XInputGetStateEx(i, + &(g_xinput_states[i].xstate)) == ERROR_DEVICE_NOT_CONNECTED) g_xinput_states[i].connected = false; } @@ -507,7 +507,7 @@ static bool xinput_joypad_rumble(unsigned pad, else if (effect == RETRO_RUMBLE_WEAK) g_xinput_rumble_states[xuser].wRightMotorSpeed = strength; - return (g_XInputSetState(xuser, &g_xinput_rumble_states[xuser]) + return (g_XInputSetState(xuser, &g_xinput_rumble_states[xuser]) == 0); } diff --git a/input/drivers_keyboard/keyboard_event_android.c b/input/drivers_keyboard/keyboard_event_android.c index cd7b7e27dd..6c2f95bec8 100644 --- a/input/drivers_keyboard/keyboard_event_android.c +++ b/input/drivers_keyboard/keyboard_event_android.c @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -19,7 +19,7 @@ #define AKEYCODE_ASSIST 219 -#define LAST_KEYCODE AKEYCODE_ASSIST +#define LAST_KEYCODE AKEYCODE_ASSIST #define MAX_KEYS ((LAST_KEYCODE + 7) / 8) diff --git a/input/drivers_keyboard/keyboard_event_android.h b/input/drivers_keyboard/keyboard_event_android.h index d80fb2f606..27e77f78a4 100644 --- a/input/drivers_keyboard/keyboard_event_android.h +++ b/input/drivers_keyboard/keyboard_event_android.h @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/input/drivers_keyboard/keyboard_event_dos.c b/input/drivers_keyboard/keyboard_event_dos.c index f9b76ad4a6..62f23feff9 100644 --- a/input/drivers_keyboard/keyboard_event_dos.c +++ b/input/drivers_keyboard/keyboard_event_dos.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2011-2017 - Daniel De Matteis * Copyright (C) 2016-2017 - Brad Parker - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/input/drivers_keyboard/keyboard_event_dos.h b/input/drivers_keyboard/keyboard_event_dos.h index 0cecb85576..0239f5087d 100644 --- a/input/drivers_keyboard/keyboard_event_dos.h +++ b/input/drivers_keyboard/keyboard_event_dos.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2011-2017 - Daniel De Matteis * Copyright (C) 2016-2017 - Brad Parker - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/input/drivers_keyboard/keyboard_event_xkb.c b/input/drivers_keyboard/keyboard_event_xkb.c index eae2f1e4c0..b406d12e73 100644 --- a/input/drivers_keyboard/keyboard_event_xkb.c +++ b/input/drivers_keyboard/keyboard_event_xkb.c @@ -152,7 +152,7 @@ void handle_xkb_state_mask(uint32_t depressed, xkb_state_update_mask(xkb_state, depressed, latched, locked, 0, 0, group); } -/* FIXME: Don't handle composed and dead-keys properly. +/* FIXME: Don't handle composed and dead-keys properly. * Waiting for support in libxkbcommon ... */ int handle_xkb(int code, int value) { diff --git a/input/include/GameController/GCController.h b/input/include/GameController/GCController.h index 5eab6264ce..7a7980338e 100644 --- a/input/include/GameController/GCController.h +++ b/input/include/GameController/GCController.h @@ -9,23 +9,23 @@ /** Use these constants with NSNotificationCenter to listen to connection and disconnection events. - + Use GCControllerDidConnectNotification for observing connections of controllers. Use GCControllerDidDisconnectNotification for observing disconnections of controllers. - + Connections and disconnections of controllers will also be reflected in the controllers array of the GCController class. - + The 'object' property of the notification will contain the GCController that was connected or disconnected. For example: - + - (void)controllerDidConnect:(NSNotification *)note { - + GCController *controller = note.object; - + .... } - + @see NSNotificationCenter @see GCController.controllers */ @@ -44,10 +44,10 @@ enum { /** Controllers are available to an application that links to GameController.framework. There are 2 ways to access controllers paired to the system, adopt both to ensure the best user experience: - + 1: Querying for the the current array or controllers using [GCController controllers]. 2: Registering for Connection/Disconnection notifications from NSNotificationCenter. - + Only controllers that support one of the allowed profiles, such as GCGamepad, will be enumerated. Check for the profile supported before using a controller in your application. Ignore a controller that doesn't support a profile that suits your application, as the user will expect their controller to either be fully supported or not supported at all. @@ -59,11 +59,11 @@ GAMECONTROLLER_EXPORT Set this block to be notified when a user intendeds to suspend or resume the current game state. A controller will have a button dedicated to suspending and resuming play and invoking context sensitive actions. During event handling the system will notify the application using this block such that the application can handle the suspension and resumption from the given controller. - + Use this to implement your canonical transition to a pause menu for example if that is your application's desired handling of suspension in play. You may pause and resume base don game state as well so the event is only called each time the pause/resume button is pressed. - + @param controller the controller that is suspending or resuming play. */ @property (copy) void (^controllerPausedHandler)(GCController *controller); @@ -84,29 +84,29 @@ GAMECONTROLLER_EXPORT /** A player index for the controller, defaults to GCControllerPlayerIndexUnset, unless the controller previously had a player index assigned to it on the current user's system. - + This can be set both for the application to keep track of controllers and as a signal to make a controller display a player index on a set of LEDs or some other mechanism. - + A controller is not guranteed to have a visual display of the playerIndex, but the API will keep track of the playerIndex for a controller while connected and in between being disconnected and connected again. Thus playerIndex persists for a controller with regards to a system. This makes it useful for persisting player-controller assignments across game sessions. - + Negative values less than GCControllerPlayerIndexUnset will just map back to GCControllerPlayerIndexUnset when read back. */ @property (nonatomic) NSInteger playerIndex; /** Gets the profile for the controller that suits current application. - + There are only two supported profiles. Each controller may be able to map its inputs into all profiles or just one kind of profile. Query for the controller profile that suits your game, the simplest kind will be supported by the broadest variety of controllers. A controller supporting the Extended Gamepad profile for example supports the Gamepad profile and more. As such it can always be used just in the Gamepad profile if that suits the game. - + A physical controller that supports a profile must support it completely. That means that all buttons and axis inputs must be valid inputs that a developer can utilize. - + If a controller does not support the given profile the returned value will be nil. Use this to filter controllers if the application requires a specific kind of profile. */ @@ -115,7 +115,7 @@ GAMECONTROLLER_EXPORT /** Get a list of controllers currently attached to the system. - + @see GCControllerDidConnectNotification @see GCControllerDidDisconnectNotification */ @@ -126,21 +126,21 @@ GAMECONTROLLER_EXPORT will get called once no more devices can be found. If there are already multiple controllers available for use, there may be little reason to automatically start discovery of new wireless controllers. In this situation it may be best to allow the user to start discovery manually via in-game UI. - + Once discovery has started new controllers will notify themselves as connected via GCControllerDidConnectNotification. As the notification arrives the controller is also available in the controllers array. The completionHandler could be used to update UI and/or game state to indicate that no more controllers will be found and the current set of controllers is what is available for use in the game. - + If a completionHandler was provided, it will be called once when discovery stops. Either from an explicit call to stopWirelessControllerDiscovery or from timing out or stopping in its natural course of operation. Thus the completionHandler will at most be called once per call to startWirelessControllerDiscoveryWithCompletionHandler:. - + The completionHandler may also not get called at all, if for example startWirelessControllerDiscoveryWithCompletionHandler: is called multiple times during dicovery. For this case the net effect is that the completionHandler is replaced with each call and only the last one set before discovery stops will be called. - + @param completionHandler an optional handler that is called when discovery stops. (may be nil, in which case you will not be notified when discovery stops) @see stopWirelessControllerDiscovery @see controllers @@ -152,7 +152,7 @@ GAMECONTROLLER_EXPORT process can be stopped. Calling stopWirelessControllerDiscovery when no discovery is currently in progress will return immediately without any effect, thus it is safe to call even if the completionHandler of startWirelessControllerDiscoveryWithCompletionHandler: has been called. - + @see startWirelessControllerDiscoveryWithCompletionHandler: */ + (void)stopWirelessControllerDiscovery; diff --git a/input/include/GameController/GCControllerAxisInput.h b/input/include/GameController/GCControllerAxisInput.h index 1bb95f3003..7fab120c55 100644 --- a/input/include/GameController/GCControllerAxisInput.h +++ b/input/include/GameController/GCControllerAxisInput.h @@ -12,7 +12,7 @@ GAMECONTROLLER_EXPORT /** Set this block if you want to be notified when the value on this axis changes. - + @param axis the element that has been modified. @param value the value the axis was set to at the time the valueChangedHandler fired. */ diff --git a/input/include/GameController/GCControllerButtonInput.h b/input/include/GameController/GCControllerButtonInput.h index 65e977cee4..735bceb9f3 100644 --- a/input/include/GameController/GCControllerButtonInput.h +++ b/input/include/GameController/GCControllerButtonInput.h @@ -12,7 +12,7 @@ GAMECONTROLLER_EXPORT /** Set this block if you want to be notified when the value on this button changes. - + @param button the element that has been modified. @param value the value the button was set to at the time the valueChangedHandler fired. @param pressed the pressed state of the button at the time the valueChangedHandler fired. @@ -28,7 +28,7 @@ typedef void (^GCControllerButtonValueChangedHandler)(GCControllerButtonInput *b /** Buttons are mostly used in a digital sense, thus we have a recommended method for checking for pressed state instead of interpreting the value. - + As a general guideline a button is pressed if the value exceeds 25%. However there may be hysterisis applied to counter noisy input values, thus incidental values around the threshold value may not trigger a change in pressed state. diff --git a/input/include/GameController/GCControllerDirectionPad.h b/input/include/GameController/GCControllerDirectionPad.h index afb15b3c6d..5bb1398d15 100644 --- a/input/include/GameController/GCControllerDirectionPad.h +++ b/input/include/GameController/GCControllerDirectionPad.h @@ -16,7 +16,7 @@ GAMECONTROLLER_EXPORT /** Set this block if you want to be notified when the value on this axis changes. - + @param dpad the direction pad collection whose axis have been modified. @param xValue the value the x axis was set to at the time the valueChangedHandler fired. @param yValue the value the y axis was set to at the time the valueChangedHandler fired. diff --git a/input/include/GameController/GCExtendedGamepad.h b/input/include/GameController/GCExtendedGamepad.h index 00e4fcb0de..e293ce24e8 100644 --- a/input/include/GameController/GCExtendedGamepad.h +++ b/input/include/GameController/GCExtendedGamepad.h @@ -12,12 +12,12 @@ /** Extended Gamepad profile. Has all the physical features of a Standard Gamepad and more. - + In comparison to the Standard gamepad, The directional pad on an Extended gamepad is optionally analog as the two thumbsticks provided are required to be analog. - + All controller profiles provide a base level of information about the controller they belong to. - + A profile maps the hardware notion of a controller into a logical controller. One that a developer can design for and depend on, no matter the underlying hardware. */ @@ -37,7 +37,7 @@ GAMECONTROLLER_EXPORT Set this block if you want to be notified when a value on a element changed. If multiple elements have changed this block will be called for each element that changed. As elements in a collection, such as the axis in a dpad, tend to change at the same time and thus will only call this once with the collection as the element. - + @param gamepad this gamepad that is being used to map the raw input data into logical values on controller elements such as the dpad or the buttons. @param element the element that has been modified. */ @@ -48,7 +48,7 @@ typedef void (^GCExtendedGamepadValueChangedHandler)(GCExtendedGamepad *gamepad, Polls the state vector of the controller and saves it to a snapshot. The snapshot is stored in a device independent format that can be serialized and used at a later date. This is useful for features such as quality assurance, save game or replay functionality among many. - + If your application is heavily multithreaded this may also be useful to guarantee atomicity of input handling as a snapshot will not change based on user input once it is taken. */ @@ -62,13 +62,13 @@ typedef void (^GCExtendedGamepadValueChangedHandler)(GCExtendedGamepad *gamepad, /** All face buttons are required to be analog in the Extended profile. These must be arranged in the diamond pattern given below: - + Y / \ X B \ / A - + */ @property (readonly) GCControllerButtonInput *buttonA; @property (readonly) GCControllerButtonInput *buttonB; diff --git a/input/include/GameController/GCExtendedGamepadSnapshot.h b/input/include/GameController/GCExtendedGamepadSnapshot.h index 8f6cd125f1..e8500d25fb 100644 --- a/input/include/GameController/GCExtendedGamepadSnapshot.h +++ b/input/include/GameController/GCExtendedGamepadSnapshot.h @@ -10,10 +10,10 @@ /** A GCExtendedGamepadSnapshot snapshot is a concrete GCExtendedGamepad implementation. It can be used directly in an application to implement controller input replays. It is also returned as the result of polling a controller. - + The current snapshotData is readily available to access as NSData. A developer can serialize this to any destination necessary using the NSData API. - + The data contains some version of a GCExtendedGamepadSnapShotData structure. @see -[GCExtendedGamepad saveSnapshot] @@ -32,12 +32,12 @@ typedef struct { // Standard information uint16_t version; //0x0100 uint16_t size; //sizeof(GCExtendedGamepadSnapShotDataV100) or larger - + // Extended gamepad data // Axes in the range [-1.0, 1.0] float_t dpadX; float_t dpadY; - + // Buttons in the range [0.0, 1.0] float_t buttonA; float_t buttonB; @@ -51,7 +51,7 @@ typedef struct { float_t leftThumbstickY; float_t rightThumbstickX; float_t rightThumbstickY; - + // Buttons in the range [0.0, 1.0] float_t leftTrigger; float_t rightTrigger; @@ -60,7 +60,7 @@ typedef struct { #pragma pack(pop) /**Fills out a v100 snapshot from any compatible NSData source - + @return NO if data is nil, snapshotData is nil or the contents of data does not contain a compatible snapshot. YES for all other cases. */ GAMECONTROLLER_EXPORT @@ -68,7 +68,7 @@ BOOL GCExtendedGamepadSnapShotDataV100FromNSData(GCExtendedGamepadSnapShotDataV1 /**Creates an NSData object from a v100 snapshot. If the version and size is not set in the snapshot the data will automatically have version 0x100 and sizeof(GCExtendedGamepadSnapShotDataV100) set as the values implicitly. - + @return nil if the snapshot is NULL, otherwise an NSData instance compatible with GCExtendedGamepadSnapshot.snapshotData */ GAMECONTROLLER_EXPORT diff --git a/input/include/GameController/GCGamepad.h b/input/include/GameController/GCGamepad.h index 74de5c3558..2c318fcb69 100644 --- a/input/include/GameController/GCGamepad.h +++ b/input/include/GameController/GCGamepad.h @@ -12,9 +12,9 @@ /** Standard Gamepad profile. - + All controller profiles provide a base level of information about the controller they belong to. - + A profile maps the hardware notion of a controller into a logical controller. One that a developer can design for and depend on, no matter the underlying hardware. */ @@ -34,7 +34,7 @@ GAMECONTROLLER_EXPORT Set this block if you want to be notified when a value on a element changed. If multiple elements have changed this block will be called for each element that changed. As elements in a collection, such as the axis in a dpad, tend to change at the same time and thus will only call this once with the collection as the element. - + @param gamepad this gamepad that is being used to map the raw input data into logical values on controller elements such as the dpad or the buttons. @param element the element that has been modified. */ @@ -45,7 +45,7 @@ typedef void (^GCGamepadValueChangedHandler)(GCGamepad *gamepad, GCControllerEle Polls the state vector of the controller and saves it to a snapshot. The snapshot is stored in a device independent format that can be serialized and used at a later date. This is useful for features such as quality assurance, save game or replay functionality among many. - + If your application is heavily multithreaded this may also be useful to guarantee atomicity of input handling as a snapshot will not change based on user input once it is taken. */ @@ -59,13 +59,13 @@ typedef void (^GCGamepadValueChangedHandler)(GCGamepad *gamepad, GCControllerEle /** All face buttons are required to be analog in the Standard profile. These must be arranged in the diamond pattern given below: - + Y / \ X B \ / A - + */ @property (readonly) GCControllerButtonInput *buttonA; @property (readonly) GCControllerButtonInput *buttonB; diff --git a/input/include/GameController/GCGamepadSnapshot.h b/input/include/GameController/GCGamepadSnapshot.h index b81922483c..117efdc9c5 100644 --- a/input/include/GameController/GCGamepadSnapshot.h +++ b/input/include/GameController/GCGamepadSnapshot.h @@ -11,12 +11,12 @@ A GCGamepadSnapshot snapshot is a concrete GCGamepad implementation. It can be used directly in an application to implement controller input replays. It is also returned as the result of polling a controller. - + The current snapshotData is readily available to access as NSData. A developer can serialize this to any destination necessary using the NSData API. - + The data contains some version of a GCGamepadSnapShotData structure. - + @see -[GCGamepad saveSnapshot] */ GAMECONTROLLER_EXPORT @@ -33,12 +33,12 @@ typedef struct { // Standard information uint16_t version; //0x0100 uint16_t size; //sizeof(GCGamepadSnapShotDataV100) or larger - + // Standard gamepad data // Axes in the range [-1.0, 1.0] float_t dpadX; float_t dpadY; - + // Buttons in the range [0.0, 1.0] float_t buttonA; float_t buttonB; @@ -46,12 +46,12 @@ typedef struct { float_t buttonY; float_t leftShoulder; float_t rightShoulder; - + } GCGamepadSnapShotDataV100; #pragma pack(pop) /**Fills out a v100 snapshot from any compatible NSData source - + @return NO if data is nil, snapshotData is nil or the contents of data does not contain a compatible snapshot. YES for all other cases. */ GAMECONTROLLER_EXPORT @@ -59,7 +59,7 @@ BOOL GCGamepadSnapShotDataV100FromNSData(GCGamepadSnapShotDataV100 *snapshotData /**Creates an NSData object from a v100 snapshot. If the version and size is not set in the snapshot the data will automatically have version 0x100 and sizeof(GCGamepadSnapShotDataV100) set as the values implicitly. - + @return nil if the snapshot is NULL, otherwise an NSData instance compatible with GCGamepadSnapshot.snapshotData */ GAMECONTROLLER_EXPORT diff --git a/input/input_driver.c b/input/input_driver.c index bbd4ed099b..3765d39916 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -336,8 +336,8 @@ struct input_keyboard_line size_t ptr; size_t size; - /** Line complete callback. - * Calls back after return is + /** Line complete callback. + * Calls back after return is * pressed with the completed line. * Line can be NULL. **/ @@ -557,7 +557,7 @@ void input_poll(void) { input_driver_turbo_btns.frame_enable[i] = 0; - if (!input_driver_block_libretro_input && + if (!input_driver_block_libretro_input && libretro_input_binds[i][RARCH_TURBO_ENABLE].valid) { rarch_joypad_info_t joypad_info; @@ -608,7 +608,7 @@ void input_poll(void) * * Input state callback function. * - * Returns: Non-zero if the given key (identified by @id) + * Returns: Non-zero if the given key (identified by @id) * was pressed by the user (assigned to @port). **/ int16_t input_state(unsigned port, unsigned device, @@ -627,7 +627,7 @@ int16_t input_state(unsigned port, unsigned device, bsv_movie_ctl(BSV_MOVIE_CTL_SET_END, NULL); } - if ( !input_driver_flushing_input + if ( !input_driver_flushing_input && !input_driver_block_libretro_input) { settings_t *settings = config_get_ptr(); @@ -695,8 +695,8 @@ int16_t input_state(unsigned port, unsigned device, * * If turbo button is held, all buttons pressed except * for D-pad will go into a turbo mode. Until the button is - * released again, the input state will be modulated by a - * periodic pulse defined by the configured duty cycle. + * released again, the input state will be modulated by a + * periodic pulse defined by the configured duty cycle. */ if (res && input_driver_turbo_btns.frame_enable[port]) input_driver_turbo_btns.enable[port] |= (1 << id); @@ -706,7 +706,7 @@ int16_t input_state(unsigned port, unsigned device, if (input_driver_turbo_btns.enable[port] & (1 << id)) { /* if turbo button is enabled for this key ID */ - res = res && ((input_driver_turbo_btns.count + res = res && ((input_driver_turbo_btns.count % settings->uints.input_turbo_period) < settings->uints.input_turbo_duty_cycle); } @@ -803,10 +803,10 @@ void input_menu_keys_pressed(void *data, retro_bits_t* p_new_state) const struct retro_keybind *binds_norm = NULL; const struct retro_keybind *binds_auto = NULL; uint8_t max_users = (uint8_t)input_driver_max_users; - uint8_t port_max = - settings->bools.input_all_users_control_menu + uint8_t port_max = + settings->bools.input_all_users_control_menu ? max_users : 1; - + joypad_info.joy_idx = 0; joypad_info.auto_binds = NULL; @@ -815,7 +815,7 @@ void input_menu_keys_pressed(void *data, retro_bits_t* p_new_state) input_driver_block_libretro_input = false; input_driver_block_hotkey = false; - if (current_input->keyboard_mapping_is_blocked + if (current_input->keyboard_mapping_is_blocked && current_input->keyboard_mapping_is_blocked(current_input_data)) input_driver_block_hotkey = true; @@ -840,7 +840,7 @@ void input_menu_keys_pressed(void *data, retro_bits_t* p_new_state) joypad_info.auto_binds = input_autoconf_binds[joypad_info.joy_idx]; joypad_info.axis_threshold = input_driver_axis_threshold; - if (htkey->valid + if (htkey->valid && current_input->input_state(current_input_data, joypad_info, &binds[0], port, RETRO_DEVICE_JOYPAD, 0, RARCH_ENABLE_HOTKEY)) { @@ -862,9 +862,9 @@ void input_menu_keys_pressed(void *data, retro_bits_t* p_new_state) || !input_driver_block_hotkey)) ) { - const input_device_driver_t *first = current_input->get_joypad_driver + const input_device_driver_t *first = current_input->get_joypad_driver ? current_input->get_joypad_driver(current_input_data) : NULL; - const input_device_driver_t *sec = current_input->get_sec_joypad_driver + const input_device_driver_t *sec = current_input->get_sec_joypad_driver ? current_input->get_sec_joypad_driver(current_input_data) : NULL; for (port = 0; port < port_max; port++) @@ -883,7 +883,7 @@ void input_menu_keys_pressed(void *data, retro_bits_t* p_new_state) joykey = (input_config_binds[port][i].joykey != NO_BTN) ? input_config_binds[port][i].joykey : joypad_info.auto_binds[i].joykey; - joyaxis = (input_config_binds[port][i].joyaxis != AXIS_NONE) + joyaxis = (input_config_binds[port][i].joyaxis != AXIS_NONE) ? input_config_binds[port][i].joyaxis : joypad_info.auto_binds[i].joyaxis; if (sec) @@ -1048,7 +1048,7 @@ void input_keys_pressed(void *data, retro_bits_t* p_new_state) input_driver_block_libretro_input = false; input_driver_block_hotkey = false; - if ( current_input->keyboard_mapping_is_blocked + if ( current_input->keyboard_mapping_is_blocked && current_input->keyboard_mapping_is_blocked(current_input_data)) input_driver_block_hotkey = true; @@ -1065,7 +1065,7 @@ void input_keys_pressed(void *data, retro_bits_t* p_new_state) game_focus_toggle_valid = binds[RARCH_GAME_FOCUS_TOGGLE].valid; - /* Allows rarch_focus_toggle hotkey to still work + /* Allows rarch_focus_toggle hotkey to still work * even though every hotkey is blocked */ if (check_input_driver_block_hotkey( focus_normal, focus_binds_auto) && game_focus_toggle_valid) @@ -1098,7 +1098,7 @@ void input_keys_pressed(void *data, retro_bits_t* p_new_state) } #ifdef HAVE_OVERLAY - if (overlay_ptr && + if (overlay_ptr && input_overlay_key_pressed(overlay_ptr, i)) { BIT256_SET_PTR(p_new_state, i); @@ -1123,7 +1123,7 @@ void input_keys_pressed(void *data, retro_bits_t* p_new_state) #endif #ifdef HAVE_NETWORKGAMEPAD - if (input_driver_remote && + if (input_driver_remote && input_remote_key_pressed(i, 0)) { BIT256_SET_PTR(p_new_state, i); @@ -1503,7 +1503,7 @@ const char* config_get_joypad_driver_options(void) * * Initialize a joypad driver of name @ident. * - * If ident points to NULL or a zero-length string, + * If ident points to NULL or a zero-length string, * equivalent to calling input_joypad_init_first(). * * Returns: joypad driver if found, otherwise NULL. @@ -1554,7 +1554,7 @@ const input_device_driver_t *input_joypad_init_first(void *data) } /** - * input_joypad_name: + * input_joypad_name: * @drv : Input device driver handle. * @port : Joystick number. * @@ -1600,7 +1600,7 @@ bool input_joypad_set_rumble(const input_device_driver_t *drv, * @drv : Input device driver handle. * @port : User number. * @idx : Analog key index. - * E.g.: + * E.g.: * - RETRO_DEVICE_INDEX_ANALOG_LEFT * - RETRO_DEVICE_INDEX_ANALOG_RIGHT * @ident : Analog key identifier. @@ -1715,12 +1715,12 @@ int16_t input_joypad_analog(const input_device_driver_t *drv, } /** - * input_joypad_axis_raw: + * input_joypad_axis_raw: * @drv : Input device driver handle. * @port : Joystick number. * @axis : Identifier of axis. * - * Checks if axis (@axis) was being pressed by user + * Checks if axis (@axis) was being pressed by user * with joystick number @port. * * Returns: true (1) if axis was pressed, otherwise @@ -1799,7 +1799,7 @@ bool input_mouse_button_raw(unsigned port, unsigned id) /** * input_conv_analog_id_to_bind_id: * @idx : Analog key index. - * E.g.: + * E.g.: * - RETRO_DEVICE_INDEX_ANALOG_LEFT * - RETRO_DEVICE_INDEX_ANALOG_RIGHT * @ident : Analog key identifier. @@ -1955,7 +1955,7 @@ static bool input_keyboard_line_event( const char *word = NULL; char c = character >= 128 ? '?' : character; - /* Treat extended chars as ? as we cannot support + /* Treat extended chars as ? as we cannot support * printable characters for unicode stuff. */ if (c == '\r' || c == '\n') @@ -2069,8 +2069,8 @@ bool input_keyboard_line_append(const char *word) * * Sets function pointer for keyboard line handle. * - * The underlying buffer can be reallocated at any time - * (or be NULL), but the pointer to it remains constant + * The underlying buffer can be reallocated at any time + * (or be NULL), but the pointer to it remains constant * throughout the objects lifetime. * * Returns: underlying buffer of the keyboard line. @@ -2213,7 +2213,7 @@ static const void *input_config_bind_map_get(unsigned i) bool input_config_bind_map_get_valid(unsigned i) { - const struct input_bind_map *keybind = + const struct input_bind_map *keybind = (const struct input_bind_map*)input_config_bind_map_get(i); if (!keybind) return false; @@ -2222,7 +2222,7 @@ bool input_config_bind_map_get_valid(unsigned i) unsigned input_config_bind_map_get_meta(unsigned i) { - const struct input_bind_map *keybind = + const struct input_bind_map *keybind = (const struct input_bind_map*)input_config_bind_map_get(i); if (!keybind) return 0; @@ -2231,7 +2231,7 @@ unsigned input_config_bind_map_get_meta(unsigned i) const char *input_config_bind_map_get_base(unsigned i) { - const struct input_bind_map *keybind = + const struct input_bind_map *keybind = (const struct input_bind_map*)input_config_bind_map_get(i); if (!keybind) return NULL; @@ -2240,7 +2240,7 @@ const char *input_config_bind_map_get_base(unsigned i) const char *input_config_bind_map_get_desc(unsigned i) { - const struct input_bind_map *keybind = + const struct input_bind_map *keybind = (const struct input_bind_map*)input_config_bind_map_get(i); if (!keybind) return NULL; @@ -2286,7 +2286,7 @@ const char *input_config_get_prefix(unsigned user, bool meta) const char *prefix = bind_user_prefix[user]; if (user == 0) - return meta ? "input" : prefix; + return meta ? "input" : prefix; if (!meta) return prefix; @@ -2330,7 +2330,7 @@ enum retro_key input_config_translate_str_to_rk(const char *str) * * Translate string representation to bind ID. * - * Returns: Bind ID value on success, otherwise + * Returns: Bind ID value on success, otherwise * RARCH_BIND_LIST_END on not found. **/ unsigned input_config_translate_str_to_bind_id(const char *str) @@ -2585,7 +2585,7 @@ static void input_config_get_bind_string_joyaxis(char *buf, const char *prefix, settings_t *settings = config_get_ptr(); if (bind->joyaxis_label && - !string_is_empty(bind->joyaxis_label) + !string_is_empty(bind->joyaxis_label) && settings->bools.input_descriptor_label_show) snprintf(buf, size, "%s%s (axis) ", prefix, bind->joyaxis_label); else @@ -2719,7 +2719,7 @@ void input_config_set_device_name(unsigned port, const char *name) strlcpy(input_device_names[port], name, sizeof(input_device_names[port])); - + input_autoconfigure_joypad_reindex_devices(); } } diff --git a/input/input_keymaps.c b/input/input_keymaps.c index ddd900a45f..ef4345e8c3 100644 --- a/input/input_keymaps.c +++ b/input/input_keymaps.c @@ -250,7 +250,7 @@ const struct input_key_map input_config_key_map[] = { { "rctrl", RETROK_RCTRL }, { "ralt", RETROK_RALT }, - /* Keys not referenced in any keyboard mapping + /* Keys not referenced in any keyboard mapping * (except perhaps rarch_key_map_apple_hid) */ { "caret", RETROK_CARET }, { "underscore", RETROK_UNDERSCORE }, @@ -932,7 +932,7 @@ const struct rarch_key_map rarch_key_map_x11[] = { /*{ ?, RETROK_POWER },*/ { XK_EuroSign, RETROK_EURO }, { XK_Undo, RETROK_UNDO }, - /* FIXME(shizeeg): RetroArch can't handle these buttons atm. + /* FIXME(shizeeg): RetroArch can't handle these buttons atm. * Do we really need RETROK_KP_INSERT, RETROK_KP_END, * RETROK_KP_DOWN, RETROK_KP_PAGEDOWN ??? * @@ -1681,7 +1681,7 @@ enum retro_key input_keymaps_translate_keysym_to_rk(unsigned sym) * @buf : Buffer. * @size : Size of @buf. * - * Translates a retro key identifier to a human-readable + * Translates a retro key identifier to a human-readable * identifier string. **/ void input_keymaps_translate_rk_to_str(enum retro_key key, char *buf, size_t size) diff --git a/input/input_keymaps.h b/input/input_keymaps.h index 1950436454..11757f2f68 100644 --- a/input/input_keymaps.h +++ b/input/input_keymaps.h @@ -42,7 +42,7 @@ struct apple_key_name_map_entry const char* const keyname; const uint32_t hid_id; }; - + extern const struct apple_key_name_map_entry apple_key_name_map[]; #endif @@ -86,7 +86,7 @@ enum retro_key input_keymaps_translate_keysym_to_rk(unsigned sym); * @buf : Buffer. * @size : Size of @buf. * - * Translates a retro key identifier to a human-readable + * Translates a retro key identifier to a human-readable * identifier string. **/ void input_keymaps_translate_rk_to_str(enum retro_key key, char *buf, size_t size); diff --git a/input/input_mapper.c b/input/input_mapper.c index 0cfd365c30..decfea1716 100644 --- a/input/input_mapper.c +++ b/input/input_mapper.c @@ -127,9 +127,9 @@ void input_mapper_state( if (id < RETROK_LAST) { /* - RARCH_LOG("State: UDLR %u %u %u %u\n", - MAPPER_GET_KEY(handle, RETROK_UP), - MAPPER_GET_KEY(handle, RETROK_DOWN), + RARCH_LOG("State: UDLR %u %u %u %u\n", + MAPPER_GET_KEY(handle, RETROK_UP), + MAPPER_GET_KEY(handle, RETROK_DOWN), MAPPER_GET_KEY(handle, RETROK_LEFT), MAPPER_GET_KEY(handle, RETROK_RIGHT) );*/ diff --git a/input/input_mapper.h b/input/input_mapper.h index 500faab4a0..c50519acd8 100644 --- a/input/input_mapper.h +++ b/input/input_mapper.h @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis * Copyright (C) 2016-2017 - Andrés Suárez - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/input/input_overlay.c b/input/input_overlay.c index 01bea5f40c..384d589015 100644 --- a/input/input_overlay.c +++ b/input/input_overlay.c @@ -40,7 +40,7 @@ typedef struct input_overlay_state { /* Left X, Left Y, Right X, Right Y */ - int16_t analog[4]; + int16_t analog[4]; uint32_t keys[RETROK_LAST / 32 + 1]; /* This is a bitmask of (1 << key_bind_id). */ uint64_t buttons; @@ -144,7 +144,7 @@ static void input_overlay_set_vertex_geom(input_overlay_t *ol) void input_overlay_set_scale_factor(input_overlay_t *ol, float scale) { size_t i; - + if (!ol) return; @@ -231,7 +231,7 @@ static void input_overlay_enable(input_overlay_t *ol, bool enable) * Check whether the given @x and @y coordinates of the overlay * descriptor @desc is inside the overlay descriptor's hitbox. * - * Returns: true (1) if X, Y coordinates are inside a hitbox, otherwise false (0). + * Returns: true (1) if X, Y coordinates are inside a hitbox, otherwise false (0). **/ static bool inside_hitbox(const struct overlay_desc *desc, float x, float y) { @@ -250,7 +250,7 @@ static bool inside_hitbox(const struct overlay_desc *desc, float x, float y) } case OVERLAY_HITBOX_RECT: - return + return (fabs(x - desc->x) <= desc->range_x_mod) && (fabs(y - desc->y) <= desc->range_y_mod); } @@ -348,7 +348,7 @@ static void input_overlay_poll( * input_overlay_update_desc_geom: * @ol : overlay handle. * @desc : overlay descriptors handle. - * + * * Update input overlay descriptors' vertex geometry. **/ static void input_overlay_update_desc_geom(input_overlay_t *ol, @@ -735,9 +735,9 @@ void input_state_overlay(input_overlay_t *ol, int16_t *ret, case RETRO_DEVICE_KEYBOARD: if (id < RETROK_LAST) { - /*RARCH_LOG("UDLR %u %u %u %u\n", - OVERLAY_GET_KEY(ol_state, RETROK_UP), - OVERLAY_GET_KEY(ol_state, RETROK_DOWN), + /*RARCH_LOG("UDLR %u %u %u %u\n", + OVERLAY_GET_KEY(ol_state, RETROK_UP), + OVERLAY_GET_KEY(ol_state, RETROK_DOWN), OVERLAY_GET_KEY(ol_state, RETROK_LEFT), OVERLAY_GET_KEY(ol_state, RETROK_RIGHT) );*/ @@ -765,7 +765,7 @@ void input_state_overlay(input_overlay_t *ol, int16_t *ret, * @port : the user to show the inputs of * * Adds inputs from current_input to the overlay, so it's displayed - * returns true if an input that is pressed will change the overlay + * returns true if an input that is pressed will change the overlay */ static bool input_overlay_add_inputs(input_overlay_t *ol, unsigned port, unsigned analog_dpad_mode) @@ -788,7 +788,7 @@ static bool input_overlay_add_inputs(input_overlay_t *ol, case OVERLAY_TYPE_BUTTONS: mask = desc->key_mask; id = RETRO_DEVICE_ID_JOYPAD_B; - /* Need to check all bits in the mask, + /* Need to check all bits in the mask, * multiple ones can be pressed */ current_button_pressed = false; while(mask) @@ -823,7 +823,7 @@ static bool input_overlay_add_inputs(input_overlay_t *ol, { float analog_x, analog_y; float dx, dy; - unsigned int index = (desc->type == OVERLAY_TYPE_ANALOG_RIGHT) ? + unsigned int index = (desc->type == OVERLAY_TYPE_ANALOG_RIGHT) ? RETRO_DEVICE_INDEX_ANALOG_RIGHT : RETRO_DEVICE_INDEX_ANALOG_LEFT; analog_x = input_state(port, RETRO_DEVICE_ANALOG, index, RETRO_DEVICE_ID_ANALOG_X); diff --git a/input/input_overlay.h b/input/input_overlay.h index ba81955f38..cac2269388 100644 --- a/input/input_overlay.h +++ b/input/input_overlay.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. @@ -34,13 +34,13 @@ RETRO_BEGIN_DECLS #define KEY_ANALOG_LEFT 0x56b92e81U #define KEY_ANALOG_RIGHT 0x2e4dc654U -/* Overlay driver acts as a medium between input drivers +/* Overlay driver acts as a medium between input drivers * and video driver. * - * Coordinates are fetched from input driver, and an + * Coordinates are fetched from input driver, and an * overlay with pressable actions are displayed on-screen. * - * This interface requires that the video driver has support + * This interface requires that the video driver has support * for the overlay interface. */ @@ -236,7 +236,7 @@ void input_overlay_next(input_overlay_t *ol, float opacity); /* * input_poll_overlay: - * @ol : pointer to overlay + * @ol : pointer to overlay * * Poll pressed buttons/keys on currently active overlay. **/ diff --git a/input/input_remapping.c b/input/input_remapping.c index 68e0d7363e..1493368454 100644 --- a/input/input_remapping.c +++ b/input/input_remapping.c @@ -90,15 +90,15 @@ bool input_remapping_load_file(void *data, const char *path) if (config_get_int(conf, keymapper_ident[j], &key_remap)) { settings->uints.input_keymapper_ids[j] = key_remap; -#if 0 +#if 0 RARCH_LOG ("%s: %u\n", keymapper_ident[j], settings->uints.input_keymapper_ids[j]); #endif } - else + else settings->uints.input_keymapper_ids[j] = RETROK_UNKNOWN; } - - + + } for (j = 0; j < 4; j++) @@ -244,7 +244,7 @@ bool input_remapping_remove_file(const char *path) ret = path_file_remove(remap_file) == 0 ? true : false;; free(buf); free(remap_file); - return ret; + return ret; } void input_remapping_set_defaults(bool deinit) @@ -252,7 +252,7 @@ void input_remapping_set_defaults(bool deinit) unsigned i, j; settings_t *settings = config_get_ptr(); global_t *global = global_get_ptr(); - + if (!global) return; @@ -273,7 +273,7 @@ void input_remapping_set_defaults(bool deinit) if (keybind) settings->uints.input_remap_ids[i][j] = keybind->id; settings->uints.input_keymapper_ids[j] = RETROK_UNKNOWN; - + } for (j = 0; j < 4; j++) settings->uints.input_remap_ids[i][RARCH_FIRST_CUSTOM_BIND + j] = j; diff --git a/input/input_remote.c b/input/input_remote.c index e66b8f5ae0..d74529c7d2 100644 --- a/input/input_remote.c +++ b/input/input_remote.c @@ -66,7 +66,7 @@ struct input_remote typedef struct input_remote_state { /* Left X, Left Y, Right X, Right Y */ - int16_t analog[4][MAX_USERS]; + int16_t analog[4][MAX_USERS]; /* This is a bitmask of (1 << key_bind_id). */ uint64_t buttons[MAX_USERS]; } input_remote_state_t; @@ -230,7 +230,7 @@ void input_remote_poll(input_remote_t *handle, unsigned max_users) unsigned user; settings_t *settings = config_get_ptr(); input_remote_state_t *input_state = input_remote_get_state_ptr(); - + for(user = 0; user < max_users; user++) { if (settings->bools.network_remote_enable_user[user]) diff --git a/input/input_remote.h b/input/input_remote.h index 861cea9149..a80185a724 100644 --- a/input/input_remote.h +++ b/input/input_remote.h @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2017 - Daniel De Matteis - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/intl/msg_hash_pt_br.c b/intl/msg_hash_pt_br.c index 37f690c57d..3f60fba684 100644 --- a/intl/msg_hash_pt_br.c +++ b/intl/msg_hash_pt_br.c @@ -28,7 +28,7 @@ int menu_hash_get_help_pt_br_enum(enum msg_hash_enums msg, char *s, size_t len) { uint32_t driver_hash = 0; settings_t *settings = config_get_ptr(); - + if (msg == MENU_ENUM_LABEL_CONNECT_NETPLAY_ROOM) { snprintf(s, len, @@ -36,7 +36,7 @@ int menu_hash_get_help_pt_br_enum(enum msg_hash_enums msg, char *s, size_t len) ); return 0; } - + if (msg <= MENU_ENUM_LABEL_INPUT_HOTKEY_BIND_END && msg >= MENU_ENUM_LABEL_INPUT_HOTKEY_BIND_BEGIN) { unsigned idx = msg - MENU_ENUM_LABEL_INPUT_HOTKEY_BIND_BEGIN; @@ -1069,7 +1069,7 @@ int menu_hash_get_help_pt_br_enum(enum msg_hash_enums msg, char *s, size_t len) case MENU_ENUM_LABEL_LIBRETRO_LOG_LEVEL: snprintf(s, len, "Define o nível de registro de eventos dos \n" - "núcleos libretro. (GET_LOG_INTERFACE) \n" + "núcleos libretro. (GET_LOG_INTERFACE) \n" " \n" " Se o nível do registro de evento emitido \n" " pelo núcleo libretro for abaixo do nível \n" @@ -1491,7 +1491,7 @@ int menu_hash_get_help_pt_br_enum(enum msg_hash_enums msg, char *s, size_t len) case MENU_ENUM_LABEL_VIDEO_SWAP_INTERVAL: snprintf(s, len, "Intervalo de Troca da Sincronia Vertical \n" - "(V-Sync). \n" + "(V-Sync). \n" " \n" "Usa um intervalo de troca personalizado \n" "para V-Sync. Defina para reduzir \n" @@ -1583,7 +1583,7 @@ int menu_hash_get_help_pt_br_enum(enum msg_hash_enums msg, char *s, size_t len) snprintf(s, len, "Habilitar controle do menu por toque."); break; case MENU_ENUM_LABEL_MENU_WALLPAPER: - snprintf(s, len, + snprintf(s, len, "Selecionar uma imagem para definir como \n" "plano de fundo."); break; @@ -2059,7 +2059,7 @@ int menu_hash_get_help_pt_br_enum(enum msg_hash_enums msg, char *s, size_t len) snprintf(s, len, "Você pode alterar a transparência de \n" "gamepad virtual indo em \n" - "'%s' -> '%s'. \n" + "'%s' -> '%s'. \n" " \n" "De lá você pode alterar a transparência, \n" "mudar o tamanho e opacidade dos botões, etc. \n" diff --git a/lakka.h b/lakka.h index f1659d2ef8..60d117cbdb 100644 --- a/lakka.h +++ b/lakka.h @@ -2,7 +2,7 @@ * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2016 - Daniel De Matteis * Copyright (C) 2014-2016 - Jean-André Santoni - * + * * RetroArch 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 Found- * ation, either version 3 of the License, or (at your option) any later version. diff --git a/libretro-common/audio/audio_mix.c b/libretro-common/audio/audio_mix.c index ac1dc1e25d..bd40ccb63c 100644 --- a/libretro-common/audio/audio_mix.c +++ b/libretro-common/audio/audio_mix.c @@ -56,7 +56,7 @@ void audio_mix_volume_SSE2(float *out, const float *in, float vol, size_t sample unsigned j; __m128 input[4]; __m128 additive[4]; - + input[0] = _mm_loadu_ps(out + 0); input[1] = _mm_loadu_ps(out + 4); input[2] = _mm_loadu_ps(out + 8); @@ -132,7 +132,7 @@ audio_chunk_t* audio_mix_load_wav_file(const char *path, int sample_rate) goto error; } - /* numsamples does not know or care about + /* numsamples does not know or care about * multiple channels, but we need space for 2 */ chunk->upsample_buf = (int16_t*)memalign_alloc(128, chunk->rwav->numsamples * 2 * sizeof(int16_t)); @@ -204,7 +204,7 @@ audio_chunk_t* audio_mix_load_wav_file(const char *path, int sample_rate) info.data_in = (const float*)chunk->float_buf; info.data_out = chunk->float_resample_buf; - /* a 'frame' consists of two channels, so we set this + /* a 'frame' consists of two channels, so we set this * to the number of samples irrespective of channel count */ info.input_frames = chunk->rwav->numsamples; info.output_frames = 0; diff --git a/libretro-common/audio/audio_mixer.c b/libretro-common/audio/audio_mixer.c index e6bc09eff2..3e912cb974 100644 --- a/libretro-common/audio/audio_mixer.c +++ b/libretro-common/audio/audio_mixer.c @@ -57,7 +57,7 @@ struct audio_mixer_sound { enum audio_mixer_type type; - + union { struct @@ -66,7 +66,7 @@ struct audio_mixer_sound unsigned frames; const float* pcm; } wav; - + #ifdef HAVE_STB_VORBIS struct { @@ -94,14 +94,14 @@ struct audio_mixer_voice float volume; audio_mixer_sound_t *sound; audio_mixer_stop_cb_t stop_cb; - + union { struct { unsigned position; } wav; - + #ifdef HAVE_STB_VORBIS struct { @@ -142,12 +142,12 @@ static bool wav2float(const rwav_t* wav, float** pcm, size_t samples_out) /* Allocate on a 16-byte boundary, and pad to a multiple of 16 bytes */ float *f = (float*)memalign_alloc(16, ((samples_out + 15) & ~15) * sizeof(float)); - + if (!f) return false; - + *pcm = f; - + if (wav->bitspersample == 8) { float sample = 0.0f; @@ -221,7 +221,7 @@ static bool one_shot_resample(const float* in, size_t samples_in, if (!retro_resampler_realloc(&data, &resampler, NULL, ratio)) return false; - + /* * Allocate on a 16-byte boundary, and pad to a multiple of 16 bytes. We * add four more samples in the formula below just as safeguard, because @@ -233,7 +233,7 @@ static bool one_shot_resample(const float* in, size_t samples_in, *samples_out = samples_in * ratio + 4; *out = (float*)memalign_alloc(16, ((*samples_out + 15) & ~15) * sizeof(float)); - + if (*out == NULL) return false; @@ -251,12 +251,12 @@ static bool one_shot_resample(const float* in, size_t samples_in, void audio_mixer_init(unsigned rate) { unsigned i; - + s_rate = rate; - + for (i = 0; i < AUDIO_MIXER_MAX_VOICES; i++) s_voices[i].type = AUDIO_MIXER_TYPE_NONE; - + #ifdef HAVE_THREADS s_locker = slock_new(); #endif @@ -265,13 +265,13 @@ void audio_mixer_init(unsigned rate) void audio_mixer_done(void) { unsigned i; - + #ifdef HAVE_THREADS /* Dont call audio mixer functions after this point */ slock_free(s_locker); s_locker = NULL; #endif - + for (i = 0; i < AUDIO_MIXER_MAX_VOICES; i++) s_voices[i].type = AUDIO_MIXER_TYPE_NONE; } @@ -289,12 +289,12 @@ audio_mixer_sound_t* audio_mixer_load_wav(void *buffer, int32_t size) if (rwav_ret != RWAV_ITERATE_DONE) return NULL; - + samples = wav.numsamples * 2; - + if (!wav2float(&wav, &pcm, samples)) return NULL; - + if (wav.samplerate != s_rate) { float* resampled = NULL; @@ -302,23 +302,23 @@ audio_mixer_sound_t* audio_mixer_load_wav(void *buffer, int32_t size) if (!one_shot_resample(pcm, samples, wav.samplerate, &resampled, &samples)) return NULL; - + memalign_free((void*)pcm); pcm = resampled; } - + sound = (audio_mixer_sound_t*)calloc(1, sizeof(*sound)); - + if (!sound) { memalign_free((void*)pcm); return NULL; } - + sound->type = AUDIO_MIXER_TYPE_WAV; sound->types.wav.frames = (unsigned)(samples / 2); sound->types.wav.pcm = pcm; - + rwav_free(&wav); return sound; @@ -328,14 +328,14 @@ audio_mixer_sound_t* audio_mixer_load_ogg(void *buffer, int32_t size) { #ifdef HAVE_STB_VORBIS audio_mixer_sound_t* sound = (audio_mixer_sound_t*)calloc(1, sizeof(*sound)); - + if (!sound) return NULL; sound->type = AUDIO_MIXER_TYPE_OGG; sound->types.ogg.size = size; sound->types.ogg.data = buffer; - + return sound; #else return NULL; @@ -390,7 +390,7 @@ void audio_mixer_destroy(audio_mixer_sound_t* sound) case AUDIO_MIXER_TYPE_NONE: break; } - + free(sound); } @@ -424,11 +424,11 @@ static bool audio_mixer_play_ogg( return false; info = stb_vorbis_get_info(stb_vorbis); - + if (info.sample_rate != s_rate) { ratio = (double)s_rate / (double)info.sample_rate; - + if (!retro_resampler_realloc(&resampler_data, &resamp, NULL, ratio)) goto error; @@ -538,7 +538,7 @@ audio_mixer_voice_t* audio_mixer_play(audio_mixer_sound_t* sound, bool repeat, if (!sound) return NULL; - + #ifdef HAVE_THREADS slock_lock(s_locker); #endif @@ -569,7 +569,7 @@ audio_mixer_voice_t* audio_mixer_play(audio_mixer_sound_t* sound, bool repeat, break; } - + if (res) { voice->type = sound->type; @@ -592,22 +592,22 @@ void audio_mixer_stop(audio_mixer_voice_t* voice) { audio_mixer_stop_cb_t stop_cb = NULL; audio_mixer_sound_t* sound = NULL; - + if (voice) { stop_cb = voice->stop_cb; sound = voice->sound; - + #ifdef HAVE_THREADS slock_lock(s_locker); #endif voice->type = AUDIO_MIXER_TYPE_NONE; - + #ifdef HAVE_THREADS slock_unlock(s_locker); #endif - + if (stop_cb) stop_cb(sound, AUDIO_MIXER_SOUND_STOPPED); } @@ -620,11 +620,11 @@ static void audio_mixer_mix_wav(float* buffer, size_t num_frames, int i; unsigned buf_free = (unsigned)(num_frames * 2); const audio_mixer_sound_t* sound = voice->sound; - unsigned pcm_available = sound->types.wav.frames + unsigned pcm_available = sound->types.wav.frames * 2 - voice->types.wav.position; - const float* pcm = sound->types.wav.pcm + + const float* pcm = sound->types.wav.pcm + voice->types.wav.position; - + again: if (pcm_available < buf_free) { @@ -668,7 +668,7 @@ static void audio_mixer_mix_ogg(float* buffer, size_t num_frames, unsigned buf_free = num_frames * 2; unsigned temp_samples = 0; float* pcm = NULL; - + if (voice->types.ogg.position == voice->types.ogg.samples) { again: @@ -790,7 +790,7 @@ again: else { int i; - for (i = buf_free; i != 0; --i ) + for (i = buf_free; i != 0; --i ) { samplei = *pcm++ * volume; samplef = (float)((int)samplei + 32768) / 65535.0f; @@ -810,11 +810,11 @@ void audio_mixer_mix(float* buffer, size_t num_frames, float volume_override, bo size_t j = 0; float* sample = NULL; audio_mixer_voice_t* voice = s_voices; - + #ifdef HAVE_THREADS slock_lock(s_locker); #endif - + for (i = 0; i < AUDIO_MIXER_MAX_VOICES; i++, voice++) { float volume = (override) ? volume_override : voice->volume; @@ -838,11 +838,11 @@ void audio_mixer_mix(float* buffer, size_t num_frames, float volume_override, bo break; } } - + #ifdef HAVE_THREADS slock_unlock(s_locker); #endif - + for (j = 0, sample = buffer; j < num_frames; j++, sample++) { if (*sample < -1.0f) diff --git a/libretro-common/audio/conversion/float_to_s16.c b/libretro-common/audio/conversion/float_to_s16.c index 3010cb798a..bb97945971 100644 --- a/libretro-common/audio/conversion/float_to_s16.c +++ b/libretro-common/audio/conversion/float_to_s16.c @@ -42,7 +42,7 @@ void convert_float_s16_asm(int16_t *out, const float *in, size_t samples); * @in : input buffer * @samples : size of samples to be converted * - * Converts floating point + * Converts floating point * to signed integer 16-bit. * * C implementation callback function. @@ -72,7 +72,7 @@ void convert_float_to_s16(int16_t *out, #elif defined(__ALTIVEC__) int samples_in = samples; - /* Unaligned loads/store is a bit expensive, + /* Unaligned loads/store is a bit expensive, * so we optimize for the good path (very likely). */ if (((uintptr_t)out & 15) + ((uintptr_t)in & 15) == 0) { @@ -106,7 +106,7 @@ void convert_float_to_s16(int16_t *out, #elif defined(_MIPS_ARCH_ALLEGREX) #ifdef DEBUG - /* Make sure the buffers are 16 byte aligned, this should be + /* Make sure the buffers are 16 byte aligned, this should be * the default behaviour of malloc in the PSPSDK. * Assume alignment. */ retro_assert(((uintptr_t)in & 0xf) == 0); diff --git a/libretro-common/audio/conversion/s16_to_float.c b/libretro-common/audio/conversion/s16_to_float.c index ff727913d3..814ddd8261 100644 --- a/libretro-common/audio/conversion/s16_to_float.c +++ b/libretro-common/audio/conversion/s16_to_float.c @@ -73,7 +73,7 @@ void convert_s16_to_float(float *out, #elif defined(__ALTIVEC__) size_t samples_in = samples; - /* Unaligned loads/store is a bit expensive, so we + /* Unaligned loads/store is a bit expensive, so we * optimize for the good path (very likely). */ if (((uintptr_t)out & 15) + ((uintptr_t)in & 15) == 0) { @@ -115,7 +115,7 @@ void convert_s16_to_float(float *out, #elif defined(_MIPS_ARCH_ALLEGREX) #ifdef DEBUG - /* Make sure the buffer is 16 byte aligned, this should be the + /* Make sure the buffer is 16 byte aligned, this should be the * default behaviour of malloc in the PSPSDK. * Only the output buffer can be assumed to be 16-byte aligned. */ retro_assert(((uintptr_t)out & 0xf) == 0); @@ -169,7 +169,7 @@ void convert_s16_to_float(float *out, gain = gain / 0x8000; for (; i < samples; i++) - out[i] = (float)in[i] * gain; + out[i] = (float)in[i] * gain; } /** diff --git a/libretro-common/audio/dsp_filter.c b/libretro-common/audio/dsp_filter.c index 0b695ec87e..7f428eee12 100644 --- a/libretro-common/audio/dsp_filter.c +++ b/libretro-common/audio/dsp_filter.c @@ -186,7 +186,7 @@ static bool append_plugs(retro_dsp_filter_t *dsp, struct string_list *list) dspfilter_get_implementation_t cb; const struct dspfilter_implementation *impl = NULL; struct retro_dsp_plug *new_plugs = NULL; - dylib_t lib = + dylib_t lib = dylib_load(list->elems[i].data); if (!lib) @@ -221,7 +221,7 @@ static bool append_plugs(retro_dsp_filter_t *dsp, struct string_list *list) } /* Found plug. */ - + dsp->plugs = new_plugs; dsp->plugs[dsp->num_plugs].lib = lib; dsp->plugs[dsp->num_plugs].impl = impl; @@ -233,7 +233,7 @@ static bool append_plugs(retro_dsp_filter_t *dsp, struct string_list *list) #endif retro_dsp_filter_t *retro_dsp_filter_new( - const char *filter_config, + const char *filter_config, void *string_data, float sample_rate) { diff --git a/libretro-common/audio/dsp_filters/chorus.c b/libretro-common/audio/dsp_filters/chorus.c index d48c346fb0..54d9aa715a 100644 --- a/libretro-common/audio/dsp_filters/chorus.c +++ b/libretro-common/audio/dsp_filters/chorus.c @@ -88,7 +88,7 @@ static void chorus_process(void *data, struct dspfilter_output *output, r_a = ch->old[1][(ch->old_ptr - delay_int - 0) & CHORUS_DELAY_MASK]; r_b = ch->old[1][(ch->old_ptr - delay_int - 1) & CHORUS_DELAY_MASK]; - /* Lerp introduces aliasing of the chorus component, + /* Lerp introduces aliasing of the chorus component, * but doing full polyphase here is probably overkill. */ chorus_l = l_a * (1.0f - delay_frac) + l_b * delay_frac; chorus_r = r_a * (1.0f - delay_frac) + r_b * delay_frac; diff --git a/libretro-common/audio/dsp_filters/eq.c b/libretro-common/audio/dsp_filters/eq.c index 4033aa6512..a3defe77e1 100644 --- a/libretro-common/audio/dsp_filters/eq.c +++ b/libretro-common/audio/dsp_filters/eq.c @@ -149,7 +149,7 @@ static void generate_response(fft_complex_t *response, gains++; } - /* Create a response by linear interpolation between + /* Create a response by linear interpolation between * known frequency sample points. */ for (i = 0; i <= samples; i++) { @@ -213,9 +213,9 @@ static void create_filter(struct eq_data *eq, unsigned size_log2, fft_process_inverse(fft, time_filter, eq->filter, 1); /* ifftshift() to create the correct linear phase filter. - * The filter response was designed with zero phase, which + * The filter response was designed with zero phase, which * won't work unless we compensate - * for the repeating property of the FFT here + * for the repeating property of the FFT here * by flipping left and right blocks. */ for (i = 0; i < half_block_size; i++) { diff --git a/libretro-common/audio/dsp_filters/iir.c b/libretro-common/audio/dsp_filters/iir.c index 801e908569..748d0b8c1e 100644 --- a/libretro-common/audio/dsp_filters/iir.c +++ b/libretro-common/audio/dsp_filters/iir.c @@ -212,7 +212,7 @@ static void iir_filter_init(struct iir_data *iir, a1 = -2.0 * cs; a2 = 1.0 - a1pha; break; - case NOTCH: + case NOTCH: b0 = 1.0; b1 = -2.0 * cs; b2 = 1.0; @@ -253,7 +253,7 @@ static void iir_filter_init(struct iir_data *iir, make_poly_from_roots(zeros, 2, b); make_poly_from_roots(poles, 2, a); } - + b0 = b[0]; b1 = b[1]; b2 = b[2]; @@ -272,15 +272,15 @@ static void iir_filter_init(struct iir_data *iir, b0 *= g; b1 *= g; b2 *= g; break; } - case PEQ: + case PEQ: b0 = 1.0 + a1pha * A; b1 = -2.0 * cs; b2 = 1.0 - a1pha * A; a0 = 1.0 + a1pha / A; a1 = -2.0 * cs; a2 = 1.0 - a1pha / A; - break; - case BBOOST: + break; + case BBOOST: beta = sqrt((A * A + 1) / 1.0 - (pow((A - 1), 2))); b0 = A * ((A + 1) - (A - 1) * cs + beta * sn); b1 = 2 * A * ((A - 1) - (A + 1) * cs); diff --git a/libretro-common/audio/dsp_filters/panning.c b/libretro-common/audio/dsp_filters/panning.c index 52935bb88e..da1cbc3d10 100644 --- a/libretro-common/audio/dsp_filters/panning.c +++ b/libretro-common/audio/dsp_filters/panning.c @@ -76,7 +76,7 @@ static void *panning_init(const struct dspfilter_info *info, config->get_float_array(userdata, "right_mix", &right, &num_right, default_right, 2); - memcpy(pan->left, (num_left == 2) ? + memcpy(pan->left, (num_left == 2) ? left : default_left, sizeof(pan->left)); memcpy(pan->right, (num_right == 2) ? right : default_right, sizeof(pan->right)); diff --git a/libretro-common/audio/resampler/audio_resampler.c b/libretro-common/audio/resampler/audio_resampler.c index a7cc0c2f47..0a4b8b3ff8 100644 --- a/libretro-common/audio/resampler/audio_resampler.c +++ b/libretro-common/audio/resampler/audio_resampler.c @@ -146,7 +146,7 @@ static bool resampler_append_plugs(void **re, * @ident : Identifier name for resampler we want. * @bw_ratio : Bandwidth ratio. * - * Reallocates resampler. Will free previous handle before + * Reallocates resampler. Will free previous handle before * allocating a new one. If ident is NULL, first resampler will be used. * * Returns: true (1) if successful, otherwise false (0). diff --git a/libretro-common/audio/resampler/drivers/nearest_resampler.c b/libretro-common/audio/resampler/drivers/nearest_resampler.c index c5244851a6..65ced854f6 100644 --- a/libretro-common/audio/resampler/drivers/nearest_resampler.c +++ b/libretro-common/audio/resampler/drivers/nearest_resampler.c @@ -23,14 +23,14 @@ #include #include #include - + #include