From 712803767086fb4ec1f179eed35a7f5da48396ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Fri, 29 Apr 2016 10:20:39 +0700 Subject: [PATCH 001/498] (Lakka) Use a faster mirror for the firmware upgrades --- menu/cbs/menu_cbs_ok.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 2298384e70..9e24af9812 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -1439,7 +1439,7 @@ static int action_ok_download_generic(const char *path, else if (string_is_equal(type_msg, "cb_lakka_download")) { /* TODO unhardcode this path*/ - fill_pathname_join(s, "http://sources.lakka.tv/nightly", + fill_pathname_join(s, "http://mirror.lakka.tv/nightly", LAKKA_PROJECT, sizeof(s)); } #endif @@ -1728,7 +1728,7 @@ static int generic_action_ok_network(const char *path, #ifdef HAVE_LAKKA case ACTION_OK_NETWORK_LAKKA_LIST: /* TODO unhardcode this path */ - fill_pathname_join(url_path, "http://sources.lakka.tv/nightly", + fill_pathname_join(url_path, "http://mirror.lakka.tv/nightly", LAKKA_PROJECT, sizeof(url_path)); fill_pathname_join(url_path, url_path, ".index", sizeof(url_path)); From 7b8c108b5fd4e0721f70dc7f140ef3cfe171973a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Sat, 30 Apr 2016 14:33:57 +0700 Subject: [PATCH 002/498] (OSX) Add a default path for the thumbnails dir. May fix #2924 --- frontend/drivers/platform_darwin.m | 2 ++ 1 file changed, 2 insertions(+) diff --git a/frontend/drivers/platform_darwin.m b/frontend/drivers/platform_darwin.m index a155bd961f..87f0e6ccd5 100644 --- a/frontend/drivers/platform_darwin.m +++ b/frontend/drivers/platform_darwin.m @@ -365,6 +365,7 @@ static void frontend_darwin_get_environment_settings(int *argc, char *argv[], fill_pathname_join(g_defaults.dir.database, home_dir_buf, "database/rdb", sizeof(g_defaults.dir.database)); fill_pathname_join(g_defaults.dir.cursor, home_dir_buf, "database/cursors", sizeof(g_defaults.dir.cursor)); fill_pathname_join(g_defaults.dir.cheats, home_dir_buf, "cht", sizeof(g_defaults.dir.cheats)); + fill_pathname_join(g_defaults.dir.thumbnails, home_dir_buf, "thumbnails", sizeof(g_defaults.dir.thumbnails)); fill_pathname_join(g_defaults.dir.sram, home_dir_buf, "saves", sizeof(g_defaults.dir.sram)); fill_pathname_join(g_defaults.dir.savestate, home_dir_buf, "states", sizeof(g_defaults.dir.savestate)); fill_pathname_join(g_defaults.dir.remap, home_dir_buf, "remaps", sizeof(g_defaults.dir.remap)); @@ -390,6 +391,7 @@ static void frontend_darwin_get_environment_settings(int *argc, char *argv[], fill_pathname_join(g_defaults.dir.database, bundle_path_buf, "Contents/Resources/database/rdb", sizeof(g_defaults.dir.database)); fill_pathname_join(g_defaults.dir.cursor, bundle_path_buf, "Contents/Resources/database/cursors", sizeof(g_defaults.dir.cursor)); fill_pathname_join(g_defaults.dir.cheats, bundle_path_buf, "Contents/Resources/cht", sizeof(g_defaults.dir.cheats)); + fill_pathname_join(g_defaults.dir.thumbnails, bundle_path_buf, "Contents/Resources/thumbnails", sizeof(g_defaults.dir.thumbnails)); #endif #endif From 92985a440589c7cbc0d5023c0dc16b80607e2541 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Sat, 30 Apr 2016 17:11:03 +0700 Subject: [PATCH 003/498] Use autoconfig everywhere instead of autoconf --- frontend/drivers/platform_linux.c | 2 +- frontend/drivers/platform_win32.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/frontend/drivers/platform_linux.c b/frontend/drivers/platform_linux.c index ed31c21330..8381108181 100644 --- a/frontend/drivers/platform_linux.c +++ b/frontend/drivers/platform_linux.c @@ -1987,7 +1987,7 @@ static void frontend_linux_get_env(int *argc, fill_pathname_join(g_defaults.dir.core_info, base_path, "cores", sizeof(g_defaults.dir.core_info)); fill_pathname_join(g_defaults.dir.autoconfig, base_path, - "autoconf", sizeof(g_defaults.dir.autoconfig)); + "autoconfig", sizeof(g_defaults.dir.autoconfig)); fill_pathname_join(g_defaults.dir.assets, base_path, "assets", sizeof(g_defaults.dir.assets)); fill_pathname_join(g_defaults.dir.remap, base_path, diff --git a/frontend/drivers/platform_win32.c b/frontend/drivers/platform_win32.c index d75235e1d6..a04119cd04 100644 --- a/frontend/drivers/platform_win32.c +++ b/frontend/drivers/platform_win32.c @@ -251,7 +251,7 @@ static void frontend_win32_environment_get(int *argc, char *argv[], strlcpy(g_defaults.dir.osk_overlay, ":\\overlays", sizeof(g_defaults.dir.osk_overlay)); strlcpy(g_defaults.dir.core, ":\\cores", sizeof(g_defaults.dir.core)); strlcpy(g_defaults.dir.core_info, ":\\info", sizeof(g_defaults.dir.core_info)); - strlcpy(g_defaults.dir.autoconfig, ":\\autoconf", sizeof(g_defaults.dir.autoconfig)); + strlcpy(g_defaults.dir.autoconfig, ":\\autoconfig", sizeof(g_defaults.dir.autoconfig)); strlcpy(g_defaults.dir.system, ":\\system", sizeof(g_defaults.dir.system)); strlcpy(g_defaults.dir.sram, ":\\saves", sizeof(g_defaults.dir.sram)); strlcpy(g_defaults.dir.savestate, ":\\states", sizeof(g_defaults.dir.savestate)); From 928767c5f3f74d739f1c9e6861cdee7117318722 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 30 Apr 2016 16:10:52 +0200 Subject: [PATCH 004/498] (Win32) If built with OpenGL support, default to XMB menu driver --- frontend/drivers/platform_win32.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/frontend/drivers/platform_win32.c b/frontend/drivers/platform_win32.c index d75235e1d6..26c31df014 100644 --- a/frontend/drivers/platform_win32.c +++ b/frontend/drivers/platform_win32.c @@ -259,6 +259,10 @@ static void frontend_win32_environment_get(int *argc, char *argv[], strlcpy(g_defaults.dir.shader, ":\\shaders", sizeof(g_defaults.dir.shader)); strlcpy(g_defaults.dir.core_assets, ":\\downloads", sizeof(g_defaults.dir.core_assets)); strlcpy(g_defaults.dir.screenshot, ":\\screenshots", sizeof(g_defaults.dir.screenshot)); + +#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) + snprintf(g_defaults.settings.menu, sizeof(g_defaults.settings.menu), "xmb"); +#endif } frontend_ctx_driver_t frontend_ctx_win32 = { From 9a4eb1b3d1bd0e361fc1c5909f2cbc99eaadf674 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 30 Apr 2016 16:11:28 +0200 Subject: [PATCH 005/498] Add HAVE_MENU ifdef --- frontend/drivers/platform_win32.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/frontend/drivers/platform_win32.c b/frontend/drivers/platform_win32.c index 26c31df014..311b9e6304 100644 --- a/frontend/drivers/platform_win32.c +++ b/frontend/drivers/platform_win32.c @@ -260,9 +260,11 @@ static void frontend_win32_environment_get(int *argc, char *argv[], strlcpy(g_defaults.dir.core_assets, ":\\downloads", sizeof(g_defaults.dir.core_assets)); strlcpy(g_defaults.dir.screenshot, ":\\screenshots", sizeof(g_defaults.dir.screenshot)); +#ifdef HAVE_MENU #if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) snprintf(g_defaults.settings.menu, sizeof(g_defaults.settings.menu), "xmb"); #endif +#endif } frontend_ctx_driver_t frontend_ctx_win32 = { From 865e5b78dcc81a6dbd65f9da44c9a2b771539609 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 30 Apr 2016 16:12:37 +0200 Subject: [PATCH 006/498] (platform_linux.c) Cleanup --- frontend/drivers/platform_linux.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/frontend/drivers/platform_linux.c b/frontend/drivers/platform_linux.c index ed31c21330..af25d15abe 100644 --- a/frontend/drivers/platform_linux.c +++ b/frontend/drivers/platform_linux.c @@ -1964,9 +1964,7 @@ static void frontend_linux_get_env(int *argc, * for gamepad-like/console devices. */ if (device_is_game_console(device_model)) - { snprintf(g_defaults.settings.menu, sizeof(g_defaults.settings.menu), "xmb"); - } #else char base_path[PATH_MAX]; From 0ef416970c1e0360250e59fb9ed5792589ec56fa Mon Sep 17 00:00:00 2001 From: radius Date: Sat, 30 Apr 2016 10:04:04 -0500 Subject: [PATCH 007/498] use relative paths whenever possible in the windows platform driver --- frontend/drivers/platform_win32.c | 64 ++++++++++++++++++++----------- 1 file changed, 42 insertions(+), 22 deletions(-) diff --git a/frontend/drivers/platform_win32.c b/frontend/drivers/platform_win32.c index a11b566b57..64196bd05d 100644 --- a/frontend/drivers/platform_win32.c +++ b/frontend/drivers/platform_win32.c @@ -21,6 +21,7 @@ #include #include #include +#include #include "../frontend_driver.h" #include "../../general.h" @@ -237,34 +238,53 @@ static void frontend_win32_environment_get(int *argc, char *argv[], { gfx_set_dwm(); - strlcpy(g_defaults.dir.assets, ":\\assets", sizeof(g_defaults.dir.assets)); - strlcpy(g_defaults.dir.audio_filter, ":\\filters\\audio", sizeof(g_defaults.dir.audio_filter)); - strlcpy(g_defaults.dir.video_filter, ":\\filters\\video", sizeof(g_defaults.dir.video_filter)); - strlcpy(g_defaults.dir.cheats, ":\\cheats", sizeof(g_defaults.dir.cheats)); - strlcpy(g_defaults.dir.database, ":\\database\\rdb", sizeof(g_defaults.dir.database)); - strlcpy(g_defaults.dir.cursor, ":\\database\\cursors", sizeof(g_defaults.dir.cursor)); - strlcpy(g_defaults.dir.playlist, ":\\playlists", sizeof(g_defaults.dir.playlist)); - strlcpy(g_defaults.dir.remap, ":\\config\\remap", sizeof(g_defaults.dir.remap)); - strlcpy(g_defaults.dir.wallpapers, ":\\wallpapers", sizeof(g_defaults.dir.wallpapers)); - strlcpy(g_defaults.dir.thumbnails, ":\\thumbnails", sizeof(g_defaults.dir.thumbnails)); - strlcpy(g_defaults.dir.overlay, ":\\overlays", sizeof(g_defaults.dir.overlay)); - strlcpy(g_defaults.dir.osk_overlay, ":\\overlays", sizeof(g_defaults.dir.osk_overlay)); - strlcpy(g_defaults.dir.core, ":\\cores", sizeof(g_defaults.dir.core)); - strlcpy(g_defaults.dir.core_info, ":\\info", sizeof(g_defaults.dir.core_info)); - strlcpy(g_defaults.dir.autoconfig, ":\\autoconfig", sizeof(g_defaults.dir.autoconfig)); - strlcpy(g_defaults.dir.system, ":\\system", sizeof(g_defaults.dir.system)); - strlcpy(g_defaults.dir.sram, ":\\saves", sizeof(g_defaults.dir.sram)); - strlcpy(g_defaults.dir.savestate, ":\\states", sizeof(g_defaults.dir.savestate)); - strlcpy(g_defaults.dir.menu_config, ":\\config", sizeof(g_defaults.dir.menu_config)); - strlcpy(g_defaults.dir.shader, ":\\shaders", sizeof(g_defaults.dir.shader)); - strlcpy(g_defaults.dir.core_assets, ":\\downloads", sizeof(g_defaults.dir.core_assets)); - strlcpy(g_defaults.dir.screenshot, ":\\screenshots", sizeof(g_defaults.dir.screenshot)); + fill_pathname_expand_special(g_defaults.dir.assets, + ":/assets", sizeof(g_defaults.dir.assets)); + fill_pathname_expand_special(g_defaults.dir.audio_filter, + ":/filters/audio", sizeof(g_defaults.dir.audio_filter)); + fill_pathname_expand_special(g_defaults.dir.video_filter, + ":/filters/video", sizeof(g_defaults.dir.video_filter)); + fill_pathname_expand_special(g_defaults.dir.cheats, + ":/cheats", sizeof(g_defaults.dir.cheats)); + fill_pathname_expand_special(g_defaults.dir.database, + ":/database/rdb", sizeof(g_defaults.dir.database)); + fill_pathname_expand_special(g_defaults.dir.cursor, + ":/database/cursors", sizeof(g_defaults.dir.cursor)); + fill_pathname_expand_special(g_defaults.dir.playlist, + ":/playlists", sizeof(g_defaults.dir.assets)); + fill_pathname_expand_special(g_defaults.dir.remap, + ":/config/remap", sizeof(g_defaults.dir.remap)); + fill_pathname_expand_special(g_defaults.dir.wallpapers, + ":/wallpapers", sizeof(g_defaults.dir.wallpapers)); + fill_pathname_expand_special(g_defaults.dir.thumbnails, + ":/thumbnails", sizeof(g_defaults.dir.thumbnails)); + fill_pathname_expand_special(g_defaults.dir.overlay, + ":/overlays", sizeof(g_defaults.dir.overlay)); + fill_pathname_expand_special(g_defaults.dir.osk_overlay, + ":/overlays", sizeof(g_defaults.dir.osk_overlay)); + fill_pathname_expand_special(g_defaults.dir.osk_overlay, + ":/overlays", sizeof(g_defaults.dir.osk_overlay)); + fill_pathname_expand_special(g_defaults.dir.core, + ":/cores", sizeof(g_defaults.dir.core)); + fill_pathname_expand_special(g_defaults.dir.core_info, + ":/info", sizeof(g_defaults.dir.core_info)); + fill_pathname_expand_special(g_defaults.dir.autoconfig, + ":/autoconfig", sizeof(g_defaults.dir.autoconfig)); + fill_pathname_expand_special(g_defaults.dir.menu_config, + ":/config", sizeof(g_defaults.dir.menu_config)); + fill_pathname_expand_special(g_defaults.dir.shader, + ":/shaders", sizeof(g_defaults.dir.shader)); + fill_pathname_expand_special(g_defaults.dir.core_assets, + ":/downloads", sizeof(g_defaults.dir.core_assets)); + fill_pathname_expand_special(g_defaults.dir.screenshot, + ":/screenshots", sizeof(g_defaults.dir.screenshot)); #ifdef HAVE_MENU #if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) snprintf(g_defaults.settings.menu, sizeof(g_defaults.settings.menu), "xmb"); #endif #endif + } frontend_ctx_driver_t frontend_ctx_win32 = { From cc215061fc962a6126dba949444f13b5ed77ad53 Mon Sep 17 00:00:00 2001 From: radius Date: Sat, 30 Apr 2016 10:10:22 -0500 Subject: [PATCH 008/498] fix wallpapers dir --- 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 64196bd05d..65887e3eec 100644 --- a/frontend/drivers/platform_win32.c +++ b/frontend/drivers/platform_win32.c @@ -255,9 +255,9 @@ static void frontend_win32_environment_get(int *argc, char *argv[], fill_pathname_expand_special(g_defaults.dir.remap, ":/config/remap", sizeof(g_defaults.dir.remap)); fill_pathname_expand_special(g_defaults.dir.wallpapers, - ":/wallpapers", sizeof(g_defaults.dir.wallpapers)); + ":/assets/wallpapers", sizeof(g_defaults.dir.wallpapers)); fill_pathname_expand_special(g_defaults.dir.thumbnails, - ":/thumbnails", sizeof(g_defaults.dir.thumbnails)); + ":/assets/thumbnails", sizeof(g_defaults.dir.thumbnails)); fill_pathname_expand_special(g_defaults.dir.overlay, ":/overlays", sizeof(g_defaults.dir.overlay)); fill_pathname_expand_special(g_defaults.dir.osk_overlay, From ec9aea1189f15821ab27a35259ee048f6080b419 Mon Sep 17 00:00:00 2001 From: radius Date: Sat, 30 Apr 2016 10:12:28 -0500 Subject: [PATCH 009/498] bump up version --- dist-scripts/dist-cores.sh | 2 +- general.h | 2 +- pkg/android/phoenix/AndroidManifest.xml | 2 +- pkg/apple/OSX/Info.plist | 4 +- pkg/apple/RetroArch_iOS9-Info.plist | 4 +- pkg/apple/iOS/Info.plist | 4 +- pkg/wii/meta.xml | 2 +- retroarch.cfg | 2382 +++++++++++++++-------- 8 files changed, 1609 insertions(+), 793 deletions(-) diff --git a/dist-scripts/dist-cores.sh b/dist-scripts/dist-cores.sh index 03e6bd4c5c..a1d7fbb1d4 100755 --- a/dist-scripts/dist-cores.sh +++ b/dist-scripts/dist-cores.sh @@ -1,6 +1,6 @@ #!/bin/sh -RARCH_VERSION=1.3.3 +RARCH_VERSION=1.3.4 PLATFORM=$1 SALAMANDER=no MAKEFILE_GRIFFIN=no diff --git a/general.h b/general.h index 60c53d1c52..e84aa78a5e 100644 --- a/general.h +++ b/general.h @@ -30,7 +30,7 @@ #endif #ifndef PACKAGE_VERSION -#define PACKAGE_VERSION "1.3.3" +#define PACKAGE_VERSION "1.3.4" #endif #endif diff --git a/pkg/android/phoenix/AndroidManifest.xml b/pkg/android/phoenix/AndroidManifest.xml index 5e2a12f253..33bcbea248 100644 --- a/pkg/android/phoenix/AndroidManifest.xml +++ b/pkg/android/phoenix/AndroidManifest.xml @@ -1,7 +1,7 @@ diff --git a/pkg/apple/OSX/Info.plist b/pkg/apple/OSX/Info.plist index 93a50c91af..87e914724a 100644 --- a/pkg/apple/OSX/Info.plist +++ b/pkg/apple/OSX/Info.plist @@ -30,11 +30,11 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.3.3 + 1.3.4 CFBundleSignature ???? CFBundleVersion - 1.3.3 + 1.3.4 LSMinimumSystemVersion ${MACOSX_DEPLOYMENT_TARGET} NSHighResolutionCapable diff --git a/pkg/apple/RetroArch_iOS9-Info.plist b/pkg/apple/RetroArch_iOS9-Info.plist index 815fdf1960..f635e445d2 100644 --- a/pkg/apple/RetroArch_iOS9-Info.plist +++ b/pkg/apple/RetroArch_iOS9-Info.plist @@ -33,11 +33,11 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.3.3 + 1.3.4 CFBundleSignature ???? CFBundleVersion - 1.3.3 + 1.3.4 LSRequiresIPhoneOS UIApplicationExitsOnSuspend diff --git a/pkg/apple/iOS/Info.plist b/pkg/apple/iOS/Info.plist index 55339615f9..2a782afa53 100644 --- a/pkg/apple/iOS/Info.plist +++ b/pkg/apple/iOS/Info.plist @@ -33,11 +33,11 @@ CFBundlePackageType APPL CFBundleShortVersionString - 1.3.3 + 1.3.4 CFBundleSignature ???? CFBundleVersion - 1.3.3 + 1.3.4 LSRequiresIPhoneOS UIApplicationExitsOnSuspend diff --git a/pkg/wii/meta.xml b/pkg/wii/meta.xml index 4e4508dcc4..496560e2a4 100644 --- a/pkg/wii/meta.xml +++ b/pkg/wii/meta.xml @@ -2,7 +2,7 @@ RetroArch Libretro - 1.3.3 + 1.3.4 2012-2016 The cross-platform entertainment system A port of RetroArch to the GameCube/Wii. diff --git a/retroarch.cfg b/retroarch.cfg index eed7864bbb..92783b49ec 100644 --- a/retroarch.cfg +++ b/retroarch.cfg @@ -1,783 +1,1599 @@ -## Skeleton config file for RetroArch - -# Save all save files (*.srm) to this directory. This includes related files like .bsv, .rtc, .psrm, etc ... -# This will be overridden by explicit command line options. -# savefile_directory = - -# Save all save states (*.state) to this directory. -# This will be overridden by explicit command line options. -# savestate_directory = - -# If set to a directory, Content which is temporarily extracted -# will be extracted to this directory. -# cache_directory = - -# Save all input remapping files to this directory. -# input_remapping_directory = - -# Save all playlist files to this directory. -# playlist_directory = - -# If set to a directory, the content history playlist will be saved -# to this directory. -# content_history_dir = - -# Automatically saves a savestate at the end of RetroArch's lifetime. -# The path is $SRAM_PATH.auto. -# RetroArch will automatically load any savestate with this path on startup if savestate_auto_load is set. -# savestate_auto_save = false -# savestate_auto_load = true - -# Load libretro from a dynamic location for dynamically built RetroArch. -# This option is mandatory. - -# Path to a libretro implementation. -# libretro_path = "/path/to/libretro.so" - -# A directory for where to search for libretro core implementations. -# libretro_directory = - -# A directory for where to search for libretro core information. -# libretro_info_path = - -# Sets log level for libretro cores (GET_LOG_INTERFACE). -# If a log level issued by a libretro core is below libretro_log_level, it is ignored. -# DEBUG logs are always ignored unless verbose mode is activated (--verbose). -# DEBUG = 0, INFO = 1, WARN = 2, ERROR = 3. -# libretro_log_level = 0 - -# Enable or disable verbosity level of frontend. -# log_verbosity = false - -# If this option is enabled, every content file loaded in RetroArch will be -# automatically added to a history list. -# history_list_enable = true - -# Enable or disable RetroArch performance counters -# perfcnt_enable = false - -# Path to core options config file. -# This config file is used to expose core-specific options. -# It will be written to by RetroArch. -# A default path will be assigned if not set. -# core_options_path = - -# Path to content load history file. -# RetroArch keeps track of all content loaded in the menu and from CLI directly for convenient quick loading. -# A default path will be assigned if not set. -# content_history_path = - -# Number of entries that will be kept in content history file. -# content_history_size = 100 - -# Sets the "system" directory. -# Implementations can query for this directory to load BIOSes, system-specific configs, etc. -# system_directory = - -# Sets start directory for menu content browser. -# rgui_browser_directory = - -# Content directory. Interacts with RETRO_ENVIRONMENT_GET_CONTENT_DIRECTORY. -# Usually set by developers who bundle libretro/RetroArch apps to point to assets. -# content_directory = - -# Assets directory. This location is queried by default when menu interfaces try to look for -# loadable assets, etc. -# assets_directory = - -# Dynamic wallpapers directory. The place to store the wallpapers dynamically -# loaded by the menu depending on context. -# dynamic_wallpapers_directory = - -# Thumbnails directory. To store thumbnail PNG files. -# thumbnails_directory = - -# Sets start directory for menu config browser. -# rgui_config_directory = - -# Show startup screen in menu. -# Is automatically set to false when seen for the first time. -# This is only updated in config if config_save_on_exit is set to true, however. -# rgui_show_start_screen = true - -# Flushes config to disk on exit. Useful for menu as settings can be modified. -# Overwrites the config. #include's and comments are not preserved. -# config_save_on_exit = true - -# Load up a specific config file based on the core being used. -# core_specific_config = false - -#### Video - -# Video driver to use. "gl", "xvideo", "sdl" -# video_driver = "gl" - -# Which OpenGL context implementation to use. -# Possible ones for desktop are: glx, x-egl, kms-egl, sdl-gl, wgl. -# By default, tries to use first suitable driver. -# video_context_driver = - -# Windowed x resolution scale and y resolution scale -# (Real x res: base_size * xscale * aspect_ratio, real y res: base_size * yscale) -# video_scale = 3.0 - -# Fullscreen resolution. Resolution of 0 uses the resolution of the desktop. -# video_fullscreen_x = 0 -# video_fullscreen_y = 0 - -# Start in fullscreen. Can be changed at runtime. -# video_fullscreen = false - -# If fullscreen, prefer using a windowed fullscreen mode. -# video_windowed_fullscreen = true - -# Which monitor to prefer. 0 (default) means no particular monitor is preferred, 1 and up (1 being first monitor), -# suggests RetroArch to use that particular monitor. -# video_monitor_index = 0 - -# Forcibly disable composition. Only works in Windows Vista/7 for now. -# video_disable_composition = false - -# Video vsync. -# video_vsync = true - -# Forcibly disable sRGB FBO support. Some Intel OpenGL drivers on Windows -# have video problems with sRGB FBO support enabled. -# video_force_srgb_disable = false - -# Attempts to hard-synchronize CPU and GPU. Can reduce latency at cost of performance. -# video_hard_sync = false - -# Sets how many frames CPU can run ahead of GPU when using video_hard_sync. -# Maximum is 3. -# video_hard_sync_frames = 0 - -# Sets how many milliseconds to delay after VSync before running the core. -# Can reduce latency at cost of higher risk of stuttering. -# Maximum is 15. -# video_frame_delay = 0 - -# Inserts a black frame inbetween frames. -# Useful for 120 Hz monitors who want to play 60 Hz material with eliminated ghosting. -# video_refresh_rate should still be configured as if it is a 60 Hz monitor (divide refresh rate by 2). -# video_black_frame_insertion = false - -# Use threaded video driver. Using this might improve performance at possible cost of latency and more video stuttering. -# video_threaded = false - -# Use a shared context for HW rendered libretro cores. -# Avoids having to assume HW state changes inbetween frames. -# video_shared_context = false - -# Smoothens picture with bilinear filtering. Should be disabled if using pixel shaders. -# video_smooth = true - -# Forces rendering area to stay equal to content aspect ratio or as defined in video_aspect_ratio. -# video_force_aspect = true - -# Only scales video in integer steps. -# The base size depends on system-reported geometry and aspect ratio. -# If video_force_aspect is not set, X/Y will be integer scaled independently. -# video_scale_integer = false - -# A floating point value for video aspect ratio (width / height). -# If this is not set, aspect ratio is assumed to be automatic. -# Behavior then is defined by video_aspect_ratio_auto. -# video_aspect_ratio = - -# If this is true and video_aspect_ratio is not set, -# aspect ratio is decided by libretro implementation. -# If this is false, 1:1 PAR will always be assumed if video_aspect_ratio is not set. -# video_aspect_ratio_auto = false - -# Forces cropping of overscanned frames. -# Exact behavior of this option is implementation specific. -# video_crop_overscan = true - -# Path to shader. Shader can be either Cg, CGP (Cg preset) or GLSL, GLSLP (GLSL preset) -# video_shader = "/path/to/shader.{cg,cgp,glsl,glslp}" - -# Load video_shader on startup. -# Other shaders can still be loaded later in runtime. -# video_shader_enable = false - -# Defines a directory where shaders (Cg, CGP, GLSL) are kept for easy access. -# video_shader_dir = - -# CPU-based video filter. Path to a dynamic library. -# video_filter = - -# Defines a directory where CPU-based video filters are kept. -# video_filter_dir = - -# Path to a font used for rendering messages. This path must be defined to enable fonts. -# Do note that the _full_ path of the font is necessary! -# video_font_path = - -# Size of the font rendered. -# video_font_size = 32 - -# Enable usage of OSD messages. -# video_font_enable = true - -# Offset for where messages will be placed on screen. Values are in range 0.0 to 1.0 for both x and y values. -# [0.0, 0.0] maps to the lower left corner of the screen. -# video_message_pos_x = 0.05 -# video_message_pos_y = 0.05 - -# Color for message. The value is treated as a hexadecimal value. -# It is a regular RGB hex number, i.e. red is "ff0000". -# video_message_color = ffffff - -# Video refresh rate of your monitor. -# Used to calculate a suitable audio input rate. -# video_refresh_rate = 59.95 - -# Allows libretro cores to set rotation modes. -# Setting this to false will honor, but ignore this request. -# This is useful for vertically oriented content where one manually rotates the monitor. -# video_allow_rotate = true - -# Forces a certain rotation of the screen. -# The rotation is added to rotations which the libretro core sets (see video_allow_rotate). -# The angle is * 90 degrees counter-clockwise. -# video_rotation = 0 - -#### Audio - -# Enable audio. -# audio_enable = true - -# Mutes audio. -# audio_mute_enable = false - -# Audio output samplerate. -# audio_out_rate = 48000 - -# Audio resampler backend. Which audio resampler to use. -# Default will use "sinc". -# audio_resampler = - -# Audio driver backend. Depending on configuration possible candidates are: alsa, pulse, oss, jack, rsound, roar, openal, sdl, xaudio. -# audio_driver = - -# Override the default audio device the audio_driver uses. This is driver dependant. E.g. ALSA wants a PCM device, OSS wants a path (e.g. /dev/dsp), Jack wants portnames (e.g. system:playback1,system:playback_2), and so on ... -# audio_device = - -# Audio DSP plugin that processes audio before it's sent to the driver. Path to a dynamic library. -# audio_dsp_plugin = - -# Directory where DSP plugins are kept. -# audio_filter_dir = - -# Will sync (block) on audio. Recommended. -# audio_sync = true - -# Desired audio latency in milliseconds. Might not be honored if driver can't provide given latency. -# audio_latency = 64 - -# Enable audio rate control. -# audio_rate_control = true - -# Controls audio rate control delta. Defines how much input rate can be adjusted dynamically. -# Input rate = in_rate * (1.0 +/- audio_rate_control_delta) -# audio_rate_control_delta = 0.005 - -# Controls maximum audio timing skew. Defines the maximum change in input rate. -# Input rate = in_rate * (1.0 +/- max_timing_skew) -# audio_max_timing_skew = 0.05 - -# Audio volume. Volume is expressed in dB. -# 0 dB is normal volume. No gain will be applied. -# Gain can be controlled in runtime with input_volume_up/input_volume_down. -# audio_volume = 0.0 - -#### Overlay - -# Defines a directory where overlays are kept for easy access. -# overlay_directory = - -# Enable or disable the current overlay. -# input_overlay_enable = true - -# Hide the current overlay from appearing in menu screens. -# input_overlay_hide_in_menu = true - -# Path to input overlay -# input_overlay = - -# Overlay opacity -# input_overlay_opacity = 1.0 - -# Overlay scale -# input_overlay_scale = 1.0 - -#### OSK (Onscreen Keyboard) Overlay - -# Defines a directory where overlays are kept for easy access. -# osk_overlay_directory = - -# Enable OSK overlay. -# input_osk_overlay_enable = true - -# Path to OSK overlay -# input_osk_overlay = - -# OSK Overlay opacity -# input_osk_overlay_opacity = 1.0 - -# OSK Overlay scale -# input_osk_overlay_scale = 1.0 - -#### Input - -# Input driver. Depending on video driver, it might force a different input driver. -# input_driver = sdl - -# Input device driver. (Valid: linuxraw, sdl, dinput) -# input_joypad_driver = - -# Path to input remapping file. -# input_remapping_path = - -# If enabled, overrides the input binds with the remapped binds set for the current core. -# input_remap_binds_enable = true - -# Maximum amount of users supported by RetroArch. -# input_max_users = 16 - -# Keyboard layout for input driver if applicable (udev/evdev for now). -# Syntax is either just layout (e.g. "no"), or a layout and variant separated with colon ("no:nodeadkeys"). -# input_keyboard_layout = - -# Defines axis threshold. Possible values are [0.0, 1.0] -# input_axis_threshold = 0.5 - -# Enable input auto-detection. Will attempt to autoconfigure -# joypads, Plug-and-Play style. -# input_autodetect_enable = true - -# Show the input descriptors set by the core instead of the -# default ones. -# input_descriptor_label_show = true - -# Hide input descriptors that were not set by the core. -# input_descriptor_hide_unbound = false - -# Influence how input polling is done inside RetroArch. -# 0 : Early - Input polling is performed before call to retro_run. -# 1 : Normal - Input polling is performend when retro_input_poll is -# requested. -# 2 : Late - Input polling is performed on first call to retro_input_state -# per frame -# -# Setting it to 0 or 2 can result in less latency depending on -# your configuration. -# -# When netplay is enabled, the default polling behavior (1) will -# be used regardless of the value set here. -# input_poll_type_behavior = 1 - -# Directory for joypad autoconfigs. -# If a joypad is plugged in, that joypad will be autoconfigured if a config file -# corresponding to that joypad is present in joypad_autoconfig_dir. -# Input binds which are made explicit (input_playerN_*_btn/axis) will take priority over autoconfigs. -# Autoconfigs can be created with retroarch-joyconfig, manually, or with a frontend. -# Requires input_autodetect_enable to be enabled. -# joypad_autoconfig_dir = - -# Sets which libretro device is used for a user. -# Devices are indentified with a number. -# This is normally saved by the menu. -# Device IDs are found in libretro.h. -# These settings are overridden by explicit command-line arguments which refer to input devices. -# None: 0 -# Joypad (RetroPad): 1 -# Mouse: 2 -# Keyboard: 3 -# Generic Lightgun: 4 -# Joypad w/ Analog (RetroPad + Analog sticks): 5 -# Multitap (SNES specific): 257 -# Super Scope (SNES specific): 260 -# Justifier (SNES specific): 516 -# Justifiers (SNES specific): 772 - -# input_libretro_device_p1 = -# input_libretro_device_p2 = -# input_libretro_device_p3 = -# input_libretro_device_p4 = -# input_libretro_device_p5 = -# input_libretro_device_p6 = -# input_libretro_device_p7 = -# input_libretro_device_p8 = - -# Keyboard input. Will recognize letters ("a" to "z") and the following special keys (where "kp_" -# is for keypad keys): -# -# left, right, up, down, enter, kp_enter, tab, insert, del, end, home, -# rshift, shift, ctrl, alt, space, escape, add, subtract, kp_plus, kp_minus, -# f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, -# num0, num1, num2, num3, num4, num5, num6, num7, num8, num9, pageup, pagedown, -# keypad0, keypad1, keypad2, keypad3, keypad4, keypad5, keypad6, keypad7, keypad8, keypad9, -# period, capslock, numlock, backspace, multiply, divide, print_screen, scroll_lock, -# tilde, backquote, pause, quote, comma, minus, slash, semicolon, equals, leftbracket, -# backslash, rightbracket, kp_period, kp_equals, rctrl, ralt -# -# Keyboard input, Joypad and Joyaxis will all obey the "nul" bind, which disables the bind completely, -# rather than relying on a default. -# input_player1_a = "x" -# input_player1_b = "z" -# input_player1_y = "a" -# input_player1_x = "s" -# input_player1_start = "enter" -# input_player1_select = "rshift" -# input_player1_l = "q" -# input_player1_r = "w" -# input_player1_left = "left" -# input_player1_right = "right" -# input_player1_up = "up" -# input_player1_down = "down" -# input_player1_l2 = -# input_player1_r2 = -# input_player1_l3 = -# input_player1_r3 = - -# Two analog sticks (DualShock-esque). -# Bound as usual, however, if a real analog axis is bound, -# it can be read as a true analog. -# Positive X axis is right, Positive Y axis is down. -# input_player1_l_x_plus = -# input_player1_l_x_minus = -# input_player1_l_y_plus = -# input_player1_l_y_minus = -# input_player1_r_x_plus = -# input_player1_r_x_minus = -# input_player1_r_y_plus = -# input_player1_r_y_minus = - -# If desired, it is possible to override which joypads are being used for user 1 through 8. -# First joypad available is 0. -# input_player1_joypad_index = 0 -# input_player2_joypad_index = 1 -# input_player3_joypad_index = 2 -# input_player4_joypad_index = 3 -# input_player5_joypad_index = 4 -# input_player6_joypad_index = 5 -# input_player7_joypad_index = 6 -# input_player8_joypad_index = 7 - -# Input device buttons. -# Figure these out by using RetroArch-Phoenix or retroarch-joyconfig. -# You can use joypad hats with hnxx, where n is the hat, and xx is a string representing direction. -# E.g. "h0up" -# input_player1_a_btn = -# input_player1_b_btn = -# input_player1_y_btn = -# input_player1_x_btn = -# input_player1_start_btn = -# input_player1_select_btn = -# input_player1_l_btn = -# input_player1_r_btn = -# input_player1_left_btn = -# input_player1_right_btn = -# input_player1_up_btn = -# input_player1_down_btn = -# input_player1_l2_btn = -# input_player1_r2_btn = -# input_player1_l3_btn = -# input_player1_r3_btn = - -# Menu buttons. -# menu_ok_btn = -# menu_cancel_btn = -# menu_search_btn = -# menu_info_btn = -# menu_default_btn = -# menu_scroll_down_btn = -# menu_scroll_up_btn = - -# Axis for RetroArch D-Pad. -# Needs to be either '+' or '-' in the first character signaling either positive or negative direction of the axis, then the axis number. -# Do note that every other input option has the corresponding _btn and _axis binds as well; they are omitted here for clarity. -# input_player1_left_axis = -# input_player1_right_axis = -# input_player1_up_axis = -# input_player1_down_axis = - -# Holding the turbo while pressing another button will let the button enter a turbo mode -# where the button state is modulated with a periodic signal. -# The modulation stops when the button itself (not turbo button) is released. -# input_player1_turbo = - -# Describes the period and how long of that period a turbo-enabled button should behave. -# Numbers are described in frames. -# input_turbo_period = 6 -# input_turbo_duty_cycle = 3 - -# This goes all the way to user 8 (*_player2_*, *_player3_*, etc), but omitted for clarity. -# All input binds have corresponding binds for keyboard (none), joykeys (_btn) and joyaxes (_axis) as well. - -# Toggles fullscreen. -# input_toggle_fullscreen = f - -# Saves state. -# input_save_state = f2 -# Loads state. -# input_load_state = f4 - -# State slots. With slot set to 0, save state name is *.state (or whatever defined on commandline). -# When slot is != 0, path will be $path%d, where %d is slot number. -# input_state_slot_increase = f7 -# input_state_slot_decrease = f6 - -# Toggles between fast-forwarding and normal speed. -# input_toggle_fast_forward = space - -# Hold for fast-forward. Releasing button disables fast-forward. -# input_hold_fast_forward = l - -# Key to exit RetroArch cleanly. -# Killing it in any hard way (SIGKILL, etc) will terminate RetroArch without saving RAM, etc. -# On Unix-likes, SIGINT/SIGTERM allows a clean deinitialization. -# input_exit_emulator = escape - - -# Applies next and previous shader in directory. -# input_shader_next = m -# input_shader_prev = n - -# Hold button down to rewind. Rewinding must be enabled. -# input_rewind = r - -# Toggle between recording and not. -# input_movie_record_toggle = o - -# Toggle between paused and non-paused state -# input_pause_toggle = p - -# Frame advance when content is paused -# input_frame_advance = k - -# Reset the content. -# input_reset = h - -# Cheats. -# input_cheat_index_plus = y -# input_cheat_index_minus = t -# input_cheat_toggle = u - -# Mute/unmute audio -# input_audio_mute = f9 - -# Take screenshot -# input_screenshot = f8 - -# Netplay flip users. -# input_netplay_flip_players = i - -# Hold for slowmotion. -# input_slowmotion = e - -# Enable other hotkeys. -# If this hotkey is bound to either keyboard, joybutton or joyaxis, -# all other hotkeys will be disabled unless this hotkey is also held at the same time. -# This is useful for RETRO_KEYBOARD centric implementations -# which query a large area of the keyboard, where it is not desirable -# that hotkeys get in the way. - -# Alternatively, all hotkeys for keyboard could be disabled by the user. -# input_enable_hotkey_btn = - -# Increases audio volume. -# input_volume_up = kp_plus -# Decreases audio volume. -# input_volume_down = kp_minus - -# Toggles to next overlay. Wraps around. -# input_overlay_next = - -# Toggles eject for disks. Used for multiple-disk content. -# input_disk_eject_toggle = - -# Cycles through disk images. Use after ejecting. -# Complete by toggling eject again. -# input_disk_next = - -# Toggles menu. -# input_menu_toggle = f1 - -# RetroPad button combination to toggle menu -# 0 = none, 1 = L + R + Y + D-Pad Down, 2 = L3 + R3 -# input_menu_toggle_gamepad_combo = 0 - -# Toggles mouse grab. When mouse is grabbed, RetroArch hides the mouse, -# and keeps the mouse pointer inside the window to allow relative mouse input -# to work better. -# input_grab_mouse_toggle = f11 - -#### Menu - -# Menu driver to use. "rgui", "lakka", etc. -# menu_driver = "rgui" - -# If enabled, the libretro core will keep running in the background when we -# are in the menu. -# menu_pause_libretro = false - -# Enable mouse input inside the menu. -# menu_mouse_enable = false - -# Enable touch input inside the menu. -# menu_pointer_enable = false - -# Shows current date and/or time inside menu. -# menu_timedate_enable = true - -# Shows current core inside menu. -# menu_core_enable = true - -# Path to a .png image to set as menu wallpaper. -# menu_wallpaper = - -# Dynamically load a new wallpaper depending on context. -# menu_dynamic_wallpaper_enable = false - -# Type of thumbnail to display. 0 = none, 1 = snaps, 2 = titles, 3 = boxarts -# menu_thumbnails = 0 - -# Wrap-around toe beginning and/or end if boundary of list reached horizontally -# menu_navigation_wraparound_horizontal_enable = false - -# Wrap-around to beginning and/or end if boundary of list reached vertically -# menu_navigation_wraparound_vertical_enable = false - -# Filter files being show in 'Load Content' by supported extensions -# menu_navigation_browser_filter_supported_extensions_enable = true - -# Collapse subgroup settings into main group to create one big listing of settings -# per category. -# menu_collapse_subgroups_enable = false - -#### UI - -# Suspends the screensaver if set to true. Is a hint that does not necessarily have to be honored -# by video driver. -# suspend_screensaver_enable = true - -# Start UI companion driver's interface on boot (if available). -# ui_companion_start_on_boot = true - -#### Camera - -# Override the default camera device the camera driver uses. This is driver dependant. -# camera_device = - -# Override the default privacy permission for cores that want to access camera services. Is "false" by default. -# camera_allow = false - -#### Location - -# Override the default privacy permission for cores that want to access location services. Is "false" by default. -# location_allow = false - -#### Core Updater - -# URL to core update directory on buildbot. -# core_updater_buildbot_url = "http://buildbot.libretro.com" - -# URL to assets update directory on buildbot. -# core_updater_buildbot_assets_url = "http://buildbot.libretro.com/assets/" - -# Automatically extract archives that the cores are contained in to the libretro cores directory. -# core_updater_auto_extract_archive = true - -#### Network - -# When being client over netplay, use keybinds for user 1. -# netplay_client_swap_input = false - -# The username of the person running RetroArch. This will be used for playing online, for instance. -# netplay_nickname = - -# The amount of delay frames to use for netplay. Increasing this value will increase -# performance, but introduce more latency. -# netplay_delay_frames = 0 - -# Netplay mode for the current user. -# false is Server, true is Client. -# netplay_mode = false - -# Enable or disable spectator mode for the user during netplay. -# netplay_spectator_mode_enable = false - -# The IP Address of the host to connect to. -# netplay_ip_address = - -# The port of the host IP Address. Can be either a TCP or an UDP port. -# netplay_ip_port = 55435 - -#### Misc - -# Enable rewinding. This will take a performance hit when playing, so it is disabled by default. -# rewind_enable = false - -# Rewinding buffer size in megabytes. Bigger rewinding buffer means you can rewind longer. -# The buffer should be approx. 20MB per minute of buffer time. -# rewind_buffer_size = 20 - -# Rewind granularity. When rewinding defined number of frames, you can rewind several frames at a time, increasing the rewinding speed. -# rewind_granularity = 1 - -# Pause gameplay when window focus is lost. -# pause_nonactive = true - -# Autosaves the non-volatile SRAM at a regular interval. This is disabled by default unless set otherwise. -# The interval is measured in seconds. A value of 0 disables autosave. -# autosave_interval = - -# Path to content database directory. -# content_database_path = - -# Path to cheat database directory. -# cheat_database_path = - -# Path to XML cheat config, a file which keeps track of which -# cheat settings are used for individual games. -# If the file does not exist, it will be created. -# cheat_settings_path = - -# Directory to dump screenshots to. -# screenshot_directory = - -# Records video after CPU video filter. -# video_post_filter_record = false - -# Records output of GPU shaded material if available. -# video_gpu_record = false - -# Screenshots output of GPU shaded material if available. -# video_gpu_screenshot = true - -# Block SRAM from being overwritten when loading save states. -# Might potentially lead to buggy games. -# block_sram_overwrite = false - -# When saving a savestate, save state index is automatically increased before -# it is saved. -# Also, when loading content, the index will be set to the highest existing index. -# There is no upper bound on the index. -# savestate_auto_index = false - -# Slowmotion ratio. When slowmotion, content will slow down by factor. -# slowmotion_ratio = 3.0 - -# The maximum rate at which content will be run when using fast forward. (E.g. 5.0 for 60 fps content => 300 fps cap). -# RetroArch will go to sleep to ensure that the maximum rate will not be exceeded. -# Do not rely on this cap to be perfectly accurate. -# If this is set at 0, then fastforward ratio is unlimited (no FPS cap) -# fastforward_ratio = 0.0 - -# Enable stdin/network command interface. -# network_cmd_enable = false -# network_cmd_port = 55355 -# stdin_cmd_enable = false +config_save_on_exit = "true" +input_turbo_period = "6" +input_duty_cycle = "3" +input_max_users = "5" +input_menu_toggle_gamepad_combo = "0" +input_axis_threshold = "0.500000" +ui_companion_start_on_boot = "true" +ui_companion_enable = "false" +video_gpu_record = "false" +input_remap_binds_enable = "true" +back_as_menu_toggle_enable = "true" +netplay_client_swap_input = "true" +input_descriptor_label_show = "true" +input_descriptor_hide_unbound = "false" +load_dummy_on_core_shutdown = "true" +builtin_mediaplayer_enable = "true" +builtin_imageviewer_enable = "true" +fps_show = "false" +ui_menubar_enable = "true" +suspend_screensaver_enable = "true" +libretro_directory = ":\cores" +libretro_info_path = ":\info" +content_database_path = ":\database/rdb" +cheat_database_path = ":\cheats" +content_history_path = ":\content_history.lpl" +cursor_directory = ":\database/cursors" +rewind_enable = "false" +audio_latency = "64" +audio_sync = "true" +audio_block_frames = "0" +rewind_granularity = "1" +video_shader_enable = "false" +video_aspect_ratio = "-1.000000" +video_aspect_ratio_auto = "false" +video_windowed_fullscreen = "true" +video_scale = "3.000000" +autosave_interval = "0" +video_crop_overscan = "true" +video_scale_integer = "false" +video_smooth = "true" +video_threaded = "false" +video_shared_context = "false" +video_force_srgb_disable = "false" +video_fullscreen = "false" +bundle_assets_extract_enable = "false" +bundle_assets_extract_version_current = "0" +bundle_assets_extract_last_version = "0" +video_refresh_rate = "59.950001" +video_monitor_index = "0" +video_fullscreen_x = "0" +video_fullscreen_y = "0" +video_driver = "gl" +record_driver = "ffmpeg" +camera_driver = "null" +location_driver = "null" +threaded_data_runloop_enable = "true" +menu_throttle_framerate = "true" +menu_linear_filter = "true" +dpi_override_enable = "true" +dpi_override_value = "200" +menu_driver = "xmb" +menu_pause_libretro = "true" +menu_mouse_enable = "false" +menu_pointer_enable = "false" +menu_timedate_enable = "true" +menu_core_enable = "true" +menu_dynamic_wallpaper_enable = "false" +menu_thumbnails = "0" +video_vsync = "true" +video_hard_sync = "false" +video_hard_sync_frames = "0" +video_frame_delay = "0" +video_black_frame_insertion = "false" +video_disable_composition = "false" +pause_nonactive = "true" +video_swap_interval = "1" +video_gpu_screenshot = "true" +video_rotation = "0" +screenshot_directory = ":\screenshots" +auto_screenshot_filename = "true" +aspect_ratio_index = "21" +core_updater_buildbot_url = "http://buildbot.libretro.com/nightly/win-x86_64/latest/" +core_updater_buildbot_assets_url = "http://buildbot.libretro.com/assets/" +core_updater_auto_extract_archive = "true" +camera_allow = "false" +cheevos_enable = "false" +cheevos_test_unofficial = "false" +cheevos_hardcore_mode_enable = "false" +audio_rate_control = "true" +audio_rate_control_delta = "0.005000" +audio_max_timing_skew = "0.050000" +audio_volume = "0.000000" +audio_driver = "xaudio" +audio_enable = "true" +audio_mute_enable = "false" +audio_out_rate = "48000" +location_allow = "false" +video_font_size = "32.000000" +video_font_enable = "true" +video_message_color = "ffff00" +ups_pref = "false" +bps_pref = "false" +ips_pref = "false" +system_directory = "default" +input_remapping_directory = ":\config/remap" +video_shader_dir = ":\shaders" +video_filter_dir = ":\filters/video" +core_assets_directory = ":\downloads" +assets_directory = ":\assets" +dynamic_wallpapers_directory = ":\assets/wallpapers" +thumbnails_directory = ":\assets/thumbnails" +playlist_directory = ":\playlists" +rgui_browser_directory = "default" +rgui_config_directory = ":\config" +joypad_autoconfig_dir = ":\autoconfig" +overlay_directory = ":\overlays" +audio_filter_dir = ":\filters/audio" +audio_resampler = "sinc" +savefile_directory = "default" +savestate_directory = "default" +xmb_scale_factor = "100" +xmb_alpha_factor = "75" +xmb_theme = "0" +xmb_gradient = "0" +xmb_shadows_enable = "false" +xmb_ribbon_enable = "0" +rgui_show_start_screen = "false" +menu_navigation_wraparound_enable = "true" +menu_navigation_browser_filter_supported_extensions_enable = "true" +menu_show_advanced_settings = "true" +menu_entry_normal_color = "ffffffff" +menu_entry_hover_color = "ff64ff64" +menu_title_color = "ff64ff64" +content_history_size = "100" +input_autodetect_enable = "true" +input_overlay_enable = "true" +input_overlay_enable_autopreferred = "true" +input_overlay_hide_in_menu = "true" +input_overlay_opacity = "0.700000" +input_overlay_scale = "1.000000" +osk_overlay_directory = ":\overlays" +input_osk_overlay_enable = "true" +video_message_pos_x = "0.050000" +video_message_pos_y = "0.050000" +custom_viewport_width = "960" +custom_viewport_height = "720" +custom_viewport_x = "0" +custom_viewport_y = "0" +gamma_correction = "false" +flicker_filter_enable = "false" +soft_filter_enable = "false" +soft_filter_index = "0" +current_resolution_id = "0" +flicker_filter_index = "0" +video_font_size = "32.000000" +block_sram_overwrite = "false" +savestate_auto_index = "false" +savestate_auto_save = "false" +savestate_auto_load = "false" +history_list_enable = "true" +network_cmd_enable = "false" +stdin_cmd_enable = "false" +network_cmd_port = "55355" +fastforward_ratio = "0.000000" +slowmotion_ratio = "3.000000" +state_slot = "0" +netplay_spectator_mode_enable = "false" +netplay_mode = "false" +netplay_ip_port = "0" +netplay_delay_frames = "0" +user_language = "0" +custom_bgm_enable = "false" +input_driver = "dinput" +input_joypad_driver = "xinput" +input_device_p1 = "0" +input_player1_joypad_index = "0" +input_libretro_device_p1 = "1" +input_player1_analog_dpad_mode = "0" +input_device_p2 = "0" +input_player2_joypad_index = "1" +input_libretro_device_p2 = "1" +input_player2_analog_dpad_mode = "0" +input_device_p3 = "0" +input_player3_joypad_index = "2" +input_libretro_device_p3 = "1" +input_player3_analog_dpad_mode = "0" +input_device_p4 = "0" +input_player4_joypad_index = "3" +input_libretro_device_p4 = "1" +input_player4_analog_dpad_mode = "0" +input_device_p5 = "0" +input_player5_joypad_index = "4" +input_libretro_device_p5 = "1" +input_player5_analog_dpad_mode = "0" +input_device_p6 = "0" +input_player6_joypad_index = "5" +input_libretro_device_p6 = "1" +input_player6_analog_dpad_mode = "0" +input_device_p7 = "0" +input_player7_joypad_index = "6" +input_libretro_device_p7 = "1" +input_player7_analog_dpad_mode = "0" +input_device_p8 = "0" +input_player8_joypad_index = "7" +input_libretro_device_p8 = "1" +input_player8_analog_dpad_mode = "0" +input_device_p9 = "0" +input_player9_joypad_index = "8" +input_libretro_device_p9 = "1" +input_player9_analog_dpad_mode = "0" +input_device_p10 = "0" +input_player10_joypad_index = "9" +input_libretro_device_p10 = "1" +input_player10_analog_dpad_mode = "0" +input_device_p11 = "0" +input_player11_joypad_index = "10" +input_libretro_device_p11 = "1" +input_player11_analog_dpad_mode = "0" +input_device_p12 = "0" +input_player12_joypad_index = "11" +input_libretro_device_p12 = "1" +input_player12_analog_dpad_mode = "0" +input_device_p13 = "0" +input_player13_joypad_index = "12" +input_libretro_device_p13 = "1" +input_player13_analog_dpad_mode = "0" +input_device_p14 = "0" +input_player14_joypad_index = "13" +input_libretro_device_p14 = "1" +input_player14_analog_dpad_mode = "0" +input_device_p15 = "0" +input_player15_joypad_index = "14" +input_libretro_device_p15 = "1" +input_player15_analog_dpad_mode = "0" +input_device_p16 = "0" +input_player16_joypad_index = "15" +input_libretro_device_p16 = "1" +input_player16_analog_dpad_mode = "0" +network_remote_enable_user_p1 = "false" +network_remote_enable_user_p2 = "false" +network_remote_enable_user_p3 = "false" +network_remote_enable_user_p4 = "false" +network_remote_enable_user_p5 = "false" +network_remote_enable_user_p6 = "false" +network_remote_enable_user_p7 = "false" +network_remote_enable_user_p8 = "false" +network_remote_enable_user_p9 = "false" +network_remote_enable_user_p10 = "false" +network_remote_enable_user_p11 = "false" +network_remote_enable_user_p12 = "false" +network_remote_enable_user_p13 = "false" +network_remote_enable_user_p14 = "false" +network_remote_enable_user_p15 = "false" +network_remote_enable_user_p16 = "false" +network_remote_enable = "false" +network_remote_base_port = "55400" +input_player1_b = "z" +input_player1_b_btn = "nul" +input_player1_b_axis = "nul" +input_player1_y = "a" +input_player1_y_btn = "nul" +input_player1_y_axis = "nul" +input_player1_select = "rshift" +input_player1_select_btn = "nul" +input_player1_select_axis = "nul" +input_player1_start = "enter" +input_player1_start_btn = "nul" +input_player1_start_axis = "nul" +input_player1_up = "up" +input_player1_up_btn = "nul" +input_player1_up_axis = "nul" +input_player1_down = "down" +input_player1_down_btn = "nul" +input_player1_down_axis = "nul" +input_player1_left = "left" +input_player1_left_btn = "nul" +input_player1_left_axis = "nul" +input_player1_right = "right" +input_player1_right_btn = "nul" +input_player1_right_axis = "nul" +input_player1_a = "x" +input_player1_a_btn = "nul" +input_player1_a_axis = "nul" +input_player1_x = "s" +input_player1_x_btn = "nul" +input_player1_x_axis = "nul" +input_player1_l = "q" +input_player1_l_btn = "nul" +input_player1_l_axis = "nul" +input_player1_r = "w" +input_player1_r_btn = "nul" +input_player1_r_axis = "nul" +input_player1_l2 = "nul" +input_player1_l2_btn = "nul" +input_player1_l2_axis = "nul" +input_player1_r2 = "nul" +input_player1_r2_btn = "nul" +input_player1_r2_axis = "nul" +input_player1_l3 = "nul" +input_player1_l3_btn = "nul" +input_player1_l3_axis = "nul" +input_player1_r3 = "nul" +input_player1_r3_btn = "nul" +input_player1_r3_axis = "nul" +input_player1_l_x_plus = "nul" +input_player1_l_x_plus_btn = "nul" +input_player1_l_x_plus_axis = "nul" +input_player1_l_x_minus = "nul" +input_player1_l_x_minus_btn = "nul" +input_player1_l_x_minus_axis = "nul" +input_player1_l_y_plus = "nul" +input_player1_l_y_plus_btn = "nul" +input_player1_l_y_plus_axis = "nul" +input_player1_l_y_minus = "nul" +input_player1_l_y_minus_btn = "nul" +input_player1_l_y_minus_axis = "nul" +input_player1_r_x_plus = "nul" +input_player1_r_x_plus_btn = "nul" +input_player1_r_x_plus_axis = "nul" +input_player1_r_x_minus = "nul" +input_player1_r_x_minus_btn = "nul" +input_player1_r_x_minus_axis = "nul" +input_player1_r_y_plus = "nul" +input_player1_r_y_plus_btn = "nul" +input_player1_r_y_plus_axis = "nul" +input_player1_r_y_minus = "nul" +input_player1_r_y_minus_btn = "nul" +input_player1_r_y_minus_axis = "nul" +input_player1_turbo = "nul" +input_player1_turbo_btn = "nul" +input_player1_turbo_axis = "nul" +input_toggle_fast_forward = "space" +input_toggle_fast_forward_btn = "nul" +input_toggle_fast_forward_axis = "nul" +input_hold_fast_forward = "l" +input_hold_fast_forward_btn = "nul" +input_hold_fast_forward_axis = "nul" +input_load_state = "f4" +input_load_state_btn = "nul" +input_load_state_axis = "nul" +input_save_state = "f2" +input_save_state_btn = "nul" +input_save_state_axis = "nul" +input_toggle_fullscreen = "f" +input_toggle_fullscreen_btn = "nul" +input_toggle_fullscreen_axis = "nul" +input_exit_emulator = "escape" +input_exit_emulator_btn = "nul" +input_exit_emulator_axis = "nul" +input_state_slot_increase = "f7" +input_state_slot_increase_btn = "nul" +input_state_slot_increase_axis = "nul" +input_state_slot_decrease = "f6" +input_state_slot_decrease_btn = "nul" +input_state_slot_decrease_axis = "nul" +input_rewind = "r" +input_rewind_btn = "nul" +input_rewind_axis = "nul" +input_movie_record_toggle = "o" +input_movie_record_toggle_btn = "nul" +input_movie_record_toggle_axis = "nul" +input_pause_toggle = "p" +input_pause_toggle_btn = "nul" +input_pause_toggle_axis = "nul" +input_frame_advance = "k" +input_frame_advance_btn = "nul" +input_frame_advance_axis = "nul" +input_reset = "h" +input_reset_btn = "nul" +input_reset_axis = "nul" +input_shader_next = "m" +input_shader_next_btn = "nul" +input_shader_next_axis = "nul" +input_shader_prev = "n" +input_shader_prev_btn = "nul" +input_shader_prev_axis = "nul" +input_cheat_index_plus = "y" +input_cheat_index_plus_btn = "nul" +input_cheat_index_plus_axis = "nul" +input_cheat_index_minus = "t" +input_cheat_index_minus_btn = "nul" +input_cheat_index_minus_axis = "nul" +input_cheat_toggle = "u" +input_cheat_toggle_btn = "nul" +input_cheat_toggle_axis = "nul" +input_screenshot = "f8" +input_screenshot_btn = "nul" +input_screenshot_axis = "nul" +input_audio_mute = "f9" +input_audio_mute_btn = "nul" +input_audio_mute_axis = "nul" +input_osk_toggle = "f12" +input_osk_toggle_btn = "nul" +input_osk_toggle_axis = "nul" +input_netplay_flip_players = "i" +input_netplay_flip_players_btn = "nul" +input_netplay_flip_players_axis = "nul" +input_slowmotion = "e" +input_slowmotion_btn = "nul" +input_slowmotion_axis = "nul" +input_enable_hotkey = "nul" +input_enable_hotkey_btn = "nul" +input_enable_hotkey_axis = "nul" +input_volume_up = "add" +input_volume_up_btn = "nul" +input_volume_up_axis = "nul" +input_volume_down = "subtract" +input_volume_down_btn = "nul" +input_volume_down_axis = "nul" +input_overlay_next = "nul" +input_overlay_next_btn = "nul" +input_overlay_next_axis = "nul" +input_disk_eject_toggle = "nul" +input_disk_eject_toggle_btn = "nul" +input_disk_eject_toggle_axis = "nul" +input_disk_next = "nul" +input_disk_next_btn = "nul" +input_disk_next_axis = "nul" +input_disk_prev = "nul" +input_disk_prev_btn = "nul" +input_disk_prev_axis = "nul" +input_grab_mouse_toggle = "f11" +input_grab_mouse_toggle_btn = "nul" +input_grab_mouse_toggle_axis = "nul" +input_menu_toggle = "f1" +input_menu_toggle_btn = "nul" +input_menu_toggle_axis = "nul" +input_player2_b = "nul" +input_player2_b_btn = "nul" +input_player2_b_axis = "nul" +input_player2_y = "nul" +input_player2_y_btn = "nul" +input_player2_y_axis = "nul" +input_player2_select = "nul" +input_player2_select_btn = "nul" +input_player2_select_axis = "nul" +input_player2_start = "nul" +input_player2_start_btn = "nul" +input_player2_start_axis = "nul" +input_player2_up = "nul" +input_player2_up_btn = "nul" +input_player2_up_axis = "nul" +input_player2_down = "nul" +input_player2_down_btn = "nul" +input_player2_down_axis = "nul" +input_player2_left = "nul" +input_player2_left_btn = "nul" +input_player2_left_axis = "nul" +input_player2_right = "nul" +input_player2_right_btn = "nul" +input_player2_right_axis = "nul" +input_player2_a = "nul" +input_player2_a_btn = "nul" +input_player2_a_axis = "nul" +input_player2_x = "nul" +input_player2_x_btn = "nul" +input_player2_x_axis = "nul" +input_player2_l = "nul" +input_player2_l_btn = "nul" +input_player2_l_axis = "nul" +input_player2_r = "nul" +input_player2_r_btn = "nul" +input_player2_r_axis = "nul" +input_player2_l2 = "nul" +input_player2_l2_btn = "nul" +input_player2_l2_axis = "nul" +input_player2_r2 = "nul" +input_player2_r2_btn = "nul" +input_player2_r2_axis = "nul" +input_player2_l3 = "nul" +input_player2_l3_btn = "nul" +input_player2_l3_axis = "nul" +input_player2_r3 = "nul" +input_player2_r3_btn = "nul" +input_player2_r3_axis = "nul" +input_player2_l_x_plus = "nul" +input_player2_l_x_plus_btn = "nul" +input_player2_l_x_plus_axis = "nul" +input_player2_l_x_minus = "nul" +input_player2_l_x_minus_btn = "nul" +input_player2_l_x_minus_axis = "nul" +input_player2_l_y_plus = "nul" +input_player2_l_y_plus_btn = "nul" +input_player2_l_y_plus_axis = "nul" +input_player2_l_y_minus = "nul" +input_player2_l_y_minus_btn = "nul" +input_player2_l_y_minus_axis = "nul" +input_player2_r_x_plus = "nul" +input_player2_r_x_plus_btn = "nul" +input_player2_r_x_plus_axis = "nul" +input_player2_r_x_minus = "nul" +input_player2_r_x_minus_btn = "nul" +input_player2_r_x_minus_axis = "nul" +input_player2_r_y_plus = "nul" +input_player2_r_y_plus_btn = "nul" +input_player2_r_y_plus_axis = "nul" +input_player2_r_y_minus = "nul" +input_player2_r_y_minus_btn = "nul" +input_player2_r_y_minus_axis = "nul" +input_player2_turbo = "nul" +input_player2_turbo_btn = "nul" +input_player2_turbo_axis = "nul" +input_player3_b = "nul" +input_player3_b_btn = "nul" +input_player3_b_axis = "nul" +input_player3_y = "nul" +input_player3_y_btn = "nul" +input_player3_y_axis = "nul" +input_player3_select = "nul" +input_player3_select_btn = "nul" +input_player3_select_axis = "nul" +input_player3_start = "nul" +input_player3_start_btn = "nul" +input_player3_start_axis = "nul" +input_player3_up = "nul" +input_player3_up_btn = "nul" +input_player3_up_axis = "nul" +input_player3_down = "nul" +input_player3_down_btn = "nul" +input_player3_down_axis = "nul" +input_player3_left = "nul" +input_player3_left_btn = "nul" +input_player3_left_axis = "nul" +input_player3_right = "nul" +input_player3_right_btn = "nul" +input_player3_right_axis = "nul" +input_player3_a = "nul" +input_player3_a_btn = "nul" +input_player3_a_axis = "nul" +input_player3_x = "nul" +input_player3_x_btn = "nul" +input_player3_x_axis = "nul" +input_player3_l = "nul" +input_player3_l_btn = "nul" +input_player3_l_axis = "nul" +input_player3_r = "nul" +input_player3_r_btn = "nul" +input_player3_r_axis = "nul" +input_player3_l2 = "nul" +input_player3_l2_btn = "nul" +input_player3_l2_axis = "nul" +input_player3_r2 = "nul" +input_player3_r2_btn = "nul" +input_player3_r2_axis = "nul" +input_player3_l3 = "nul" +input_player3_l3_btn = "nul" +input_player3_l3_axis = "nul" +input_player3_r3 = "nul" +input_player3_r3_btn = "nul" +input_player3_r3_axis = "nul" +input_player3_l_x_plus = "nul" +input_player3_l_x_plus_btn = "nul" +input_player3_l_x_plus_axis = "nul" +input_player3_l_x_minus = "nul" +input_player3_l_x_minus_btn = "nul" +input_player3_l_x_minus_axis = "nul" +input_player3_l_y_plus = "nul" +input_player3_l_y_plus_btn = "nul" +input_player3_l_y_plus_axis = "nul" +input_player3_l_y_minus = "nul" +input_player3_l_y_minus_btn = "nul" +input_player3_l_y_minus_axis = "nul" +input_player3_r_x_plus = "nul" +input_player3_r_x_plus_btn = "nul" +input_player3_r_x_plus_axis = "nul" +input_player3_r_x_minus = "nul" +input_player3_r_x_minus_btn = "nul" +input_player3_r_x_minus_axis = "nul" +input_player3_r_y_plus = "nul" +input_player3_r_y_plus_btn = "nul" +input_player3_r_y_plus_axis = "nul" +input_player3_r_y_minus = "nul" +input_player3_r_y_minus_btn = "nul" +input_player3_r_y_minus_axis = "nul" +input_player3_turbo = "nul" +input_player3_turbo_btn = "nul" +input_player3_turbo_axis = "nul" +input_player4_b = "nul" +input_player4_b_btn = "nul" +input_player4_b_axis = "nul" +input_player4_y = "nul" +input_player4_y_btn = "nul" +input_player4_y_axis = "nul" +input_player4_select = "nul" +input_player4_select_btn = "nul" +input_player4_select_axis = "nul" +input_player4_start = "nul" +input_player4_start_btn = "nul" +input_player4_start_axis = "nul" +input_player4_up = "nul" +input_player4_up_btn = "nul" +input_player4_up_axis = "nul" +input_player4_down = "nul" +input_player4_down_btn = "nul" +input_player4_down_axis = "nul" +input_player4_left = "nul" +input_player4_left_btn = "nul" +input_player4_left_axis = "nul" +input_player4_right = "nul" +input_player4_right_btn = "nul" +input_player4_right_axis = "nul" +input_player4_a = "nul" +input_player4_a_btn = "nul" +input_player4_a_axis = "nul" +input_player4_x = "nul" +input_player4_x_btn = "nul" +input_player4_x_axis = "nul" +input_player4_l = "nul" +input_player4_l_btn = "nul" +input_player4_l_axis = "nul" +input_player4_r = "nul" +input_player4_r_btn = "nul" +input_player4_r_axis = "nul" +input_player4_l2 = "nul" +input_player4_l2_btn = "nul" +input_player4_l2_axis = "nul" +input_player4_r2 = "nul" +input_player4_r2_btn = "nul" +input_player4_r2_axis = "nul" +input_player4_l3 = "nul" +input_player4_l3_btn = "nul" +input_player4_l3_axis = "nul" +input_player4_r3 = "nul" +input_player4_r3_btn = "nul" +input_player4_r3_axis = "nul" +input_player4_l_x_plus = "nul" +input_player4_l_x_plus_btn = "nul" +input_player4_l_x_plus_axis = "nul" +input_player4_l_x_minus = "nul" +input_player4_l_x_minus_btn = "nul" +input_player4_l_x_minus_axis = "nul" +input_player4_l_y_plus = "nul" +input_player4_l_y_plus_btn = "nul" +input_player4_l_y_plus_axis = "nul" +input_player4_l_y_minus = "nul" +input_player4_l_y_minus_btn = "nul" +input_player4_l_y_minus_axis = "nul" +input_player4_r_x_plus = "nul" +input_player4_r_x_plus_btn = "nul" +input_player4_r_x_plus_axis = "nul" +input_player4_r_x_minus = "nul" +input_player4_r_x_minus_btn = "nul" +input_player4_r_x_minus_axis = "nul" +input_player4_r_y_plus = "nul" +input_player4_r_y_plus_btn = "nul" +input_player4_r_y_plus_axis = "nul" +input_player4_r_y_minus = "nul" +input_player4_r_y_minus_btn = "nul" +input_player4_r_y_minus_axis = "nul" +input_player4_turbo = "nul" +input_player4_turbo_btn = "nul" +input_player4_turbo_axis = "nul" +input_player5_b = "nul" +input_player5_b_btn = "nul" +input_player5_b_axis = "nul" +input_player5_y = "nul" +input_player5_y_btn = "nul" +input_player5_y_axis = "nul" +input_player5_select = "nul" +input_player5_select_btn = "nul" +input_player5_select_axis = "nul" +input_player5_start = "nul" +input_player5_start_btn = "nul" +input_player5_start_axis = "nul" +input_player5_up = "nul" +input_player5_up_btn = "nul" +input_player5_up_axis = "nul" +input_player5_down = "nul" +input_player5_down_btn = "nul" +input_player5_down_axis = "nul" +input_player5_left = "nul" +input_player5_left_btn = "nul" +input_player5_left_axis = "nul" +input_player5_right = "nul" +input_player5_right_btn = "nul" +input_player5_right_axis = "nul" +input_player5_a = "nul" +input_player5_a_btn = "nul" +input_player5_a_axis = "nul" +input_player5_x = "nul" +input_player5_x_btn = "nul" +input_player5_x_axis = "nul" +input_player5_l = "nul" +input_player5_l_btn = "nul" +input_player5_l_axis = "nul" +input_player5_r = "nul" +input_player5_r_btn = "nul" +input_player5_r_axis = "nul" +input_player5_l2 = "nul" +input_player5_l2_btn = "nul" +input_player5_l2_axis = "nul" +input_player5_r2 = "nul" +input_player5_r2_btn = "nul" +input_player5_r2_axis = "nul" +input_player5_l3 = "nul" +input_player5_l3_btn = "nul" +input_player5_l3_axis = "nul" +input_player5_r3 = "nul" +input_player5_r3_btn = "nul" +input_player5_r3_axis = "nul" +input_player5_l_x_plus = "nul" +input_player5_l_x_plus_btn = "nul" +input_player5_l_x_plus_axis = "nul" +input_player5_l_x_minus = "nul" +input_player5_l_x_minus_btn = "nul" +input_player5_l_x_minus_axis = "nul" +input_player5_l_y_plus = "nul" +input_player5_l_y_plus_btn = "nul" +input_player5_l_y_plus_axis = "nul" +input_player5_l_y_minus = "nul" +input_player5_l_y_minus_btn = "nul" +input_player5_l_y_minus_axis = "nul" +input_player5_r_x_plus = "nul" +input_player5_r_x_plus_btn = "nul" +input_player5_r_x_plus_axis = "nul" +input_player5_r_x_minus = "nul" +input_player5_r_x_minus_btn = "nul" +input_player5_r_x_minus_axis = "nul" +input_player5_r_y_plus = "nul" +input_player5_r_y_plus_btn = "nul" +input_player5_r_y_plus_axis = "nul" +input_player5_r_y_minus = "nul" +input_player5_r_y_minus_btn = "nul" +input_player5_r_y_minus_axis = "nul" +input_player5_turbo = "nul" +input_player5_turbo_btn = "nul" +input_player5_turbo_axis = "nul" +input_player6_b = "nul" +input_player6_b_btn = "nul" +input_player6_b_axis = "nul" +input_player6_y = "nul" +input_player6_y_btn = "nul" +input_player6_y_axis = "nul" +input_player6_select = "nul" +input_player6_select_btn = "nul" +input_player6_select_axis = "nul" +input_player6_start = "nul" +input_player6_start_btn = "nul" +input_player6_start_axis = "nul" +input_player6_up = "nul" +input_player6_up_btn = "nul" +input_player6_up_axis = "nul" +input_player6_down = "nul" +input_player6_down_btn = "nul" +input_player6_down_axis = "nul" +input_player6_left = "nul" +input_player6_left_btn = "nul" +input_player6_left_axis = "nul" +input_player6_right = "nul" +input_player6_right_btn = "nul" +input_player6_right_axis = "nul" +input_player6_a = "nul" +input_player6_a_btn = "nul" +input_player6_a_axis = "nul" +input_player6_x = "nul" +input_player6_x_btn = "nul" +input_player6_x_axis = "nul" +input_player6_l = "nul" +input_player6_l_btn = "nul" +input_player6_l_axis = "nul" +input_player6_r = "nul" +input_player6_r_btn = "nul" +input_player6_r_axis = "nul" +input_player6_l2 = "nul" +input_player6_l2_btn = "nul" +input_player6_l2_axis = "nul" +input_player6_r2 = "nul" +input_player6_r2_btn = "nul" +input_player6_r2_axis = "nul" +input_player6_l3 = "nul" +input_player6_l3_btn = "nul" +input_player6_l3_axis = "nul" +input_player6_r3 = "nul" +input_player6_r3_btn = "nul" +input_player6_r3_axis = "nul" +input_player6_l_x_plus = "nul" +input_player6_l_x_plus_btn = "nul" +input_player6_l_x_plus_axis = "nul" +input_player6_l_x_minus = "nul" +input_player6_l_x_minus_btn = "nul" +input_player6_l_x_minus_axis = "nul" +input_player6_l_y_plus = "nul" +input_player6_l_y_plus_btn = "nul" +input_player6_l_y_plus_axis = "nul" +input_player6_l_y_minus = "nul" +input_player6_l_y_minus_btn = "nul" +input_player6_l_y_minus_axis = "nul" +input_player6_r_x_plus = "nul" +input_player6_r_x_plus_btn = "nul" +input_player6_r_x_plus_axis = "nul" +input_player6_r_x_minus = "nul" +input_player6_r_x_minus_btn = "nul" +input_player6_r_x_minus_axis = "nul" +input_player6_r_y_plus = "nul" +input_player6_r_y_plus_btn = "nul" +input_player6_r_y_plus_axis = "nul" +input_player6_r_y_minus = "nul" +input_player6_r_y_minus_btn = "nul" +input_player6_r_y_minus_axis = "nul" +input_player6_turbo = "nul" +input_player6_turbo_btn = "nul" +input_player6_turbo_axis = "nul" +input_player7_b = "nul" +input_player7_b_btn = "nul" +input_player7_b_axis = "nul" +input_player7_y = "nul" +input_player7_y_btn = "nul" +input_player7_y_axis = "nul" +input_player7_select = "nul" +input_player7_select_btn = "nul" +input_player7_select_axis = "nul" +input_player7_start = "nul" +input_player7_start_btn = "nul" +input_player7_start_axis = "nul" +input_player7_up = "nul" +input_player7_up_btn = "nul" +input_player7_up_axis = "nul" +input_player7_down = "nul" +input_player7_down_btn = "nul" +input_player7_down_axis = "nul" +input_player7_left = "nul" +input_player7_left_btn = "nul" +input_player7_left_axis = "nul" +input_player7_right = "nul" +input_player7_right_btn = "nul" +input_player7_right_axis = "nul" +input_player7_a = "nul" +input_player7_a_btn = "nul" +input_player7_a_axis = "nul" +input_player7_x = "nul" +input_player7_x_btn = "nul" +input_player7_x_axis = "nul" +input_player7_l = "nul" +input_player7_l_btn = "nul" +input_player7_l_axis = "nul" +input_player7_r = "nul" +input_player7_r_btn = "nul" +input_player7_r_axis = "nul" +input_player7_l2 = "nul" +input_player7_l2_btn = "nul" +input_player7_l2_axis = "nul" +input_player7_r2 = "nul" +input_player7_r2_btn = "nul" +input_player7_r2_axis = "nul" +input_player7_l3 = "nul" +input_player7_l3_btn = "nul" +input_player7_l3_axis = "nul" +input_player7_r3 = "nul" +input_player7_r3_btn = "nul" +input_player7_r3_axis = "nul" +input_player7_l_x_plus = "nul" +input_player7_l_x_plus_btn = "nul" +input_player7_l_x_plus_axis = "nul" +input_player7_l_x_minus = "nul" +input_player7_l_x_minus_btn = "nul" +input_player7_l_x_minus_axis = "nul" +input_player7_l_y_plus = "nul" +input_player7_l_y_plus_btn = "nul" +input_player7_l_y_plus_axis = "nul" +input_player7_l_y_minus = "nul" +input_player7_l_y_minus_btn = "nul" +input_player7_l_y_minus_axis = "nul" +input_player7_r_x_plus = "nul" +input_player7_r_x_plus_btn = "nul" +input_player7_r_x_plus_axis = "nul" +input_player7_r_x_minus = "nul" +input_player7_r_x_minus_btn = "nul" +input_player7_r_x_minus_axis = "nul" +input_player7_r_y_plus = "nul" +input_player7_r_y_plus_btn = "nul" +input_player7_r_y_plus_axis = "nul" +input_player7_r_y_minus = "nul" +input_player7_r_y_minus_btn = "nul" +input_player7_r_y_minus_axis = "nul" +input_player7_turbo = "nul" +input_player7_turbo_btn = "nul" +input_player7_turbo_axis = "nul" +input_player8_b = "nul" +input_player8_b_btn = "nul" +input_player8_b_axis = "nul" +input_player8_y = "nul" +input_player8_y_btn = "nul" +input_player8_y_axis = "nul" +input_player8_select = "nul" +input_player8_select_btn = "nul" +input_player8_select_axis = "nul" +input_player8_start = "nul" +input_player8_start_btn = "nul" +input_player8_start_axis = "nul" +input_player8_up = "nul" +input_player8_up_btn = "nul" +input_player8_up_axis = "nul" +input_player8_down = "nul" +input_player8_down_btn = "nul" +input_player8_down_axis = "nul" +input_player8_left = "nul" +input_player8_left_btn = "nul" +input_player8_left_axis = "nul" +input_player8_right = "nul" +input_player8_right_btn = "nul" +input_player8_right_axis = "nul" +input_player8_a = "nul" +input_player8_a_btn = "nul" +input_player8_a_axis = "nul" +input_player8_x = "nul" +input_player8_x_btn = "nul" +input_player8_x_axis = "nul" +input_player8_l = "nul" +input_player8_l_btn = "nul" +input_player8_l_axis = "nul" +input_player8_r = "nul" +input_player8_r_btn = "nul" +input_player8_r_axis = "nul" +input_player8_l2 = "nul" +input_player8_l2_btn = "nul" +input_player8_l2_axis = "nul" +input_player8_r2 = "nul" +input_player8_r2_btn = "nul" +input_player8_r2_axis = "nul" +input_player8_l3 = "nul" +input_player8_l3_btn = "nul" +input_player8_l3_axis = "nul" +input_player8_r3 = "nul" +input_player8_r3_btn = "nul" +input_player8_r3_axis = "nul" +input_player8_l_x_plus = "nul" +input_player8_l_x_plus_btn = "nul" +input_player8_l_x_plus_axis = "nul" +input_player8_l_x_minus = "nul" +input_player8_l_x_minus_btn = "nul" +input_player8_l_x_minus_axis = "nul" +input_player8_l_y_plus = "nul" +input_player8_l_y_plus_btn = "nul" +input_player8_l_y_plus_axis = "nul" +input_player8_l_y_minus = "nul" +input_player8_l_y_minus_btn = "nul" +input_player8_l_y_minus_axis = "nul" +input_player8_r_x_plus = "nul" +input_player8_r_x_plus_btn = "nul" +input_player8_r_x_plus_axis = "nul" +input_player8_r_x_minus = "nul" +input_player8_r_x_minus_btn = "nul" +input_player8_r_x_minus_axis = "nul" +input_player8_r_y_plus = "nul" +input_player8_r_y_plus_btn = "nul" +input_player8_r_y_plus_axis = "nul" +input_player8_r_y_minus = "nul" +input_player8_r_y_minus_btn = "nul" +input_player8_r_y_minus_axis = "nul" +input_player8_turbo = "nul" +input_player8_turbo_btn = "nul" +input_player8_turbo_axis = "nul" +input_player9_b = "nul" +input_player9_b_btn = "nul" +input_player9_b_axis = "nul" +input_player9_y = "nul" +input_player9_y_btn = "nul" +input_player9_y_axis = "nul" +input_player9_select = "nul" +input_player9_select_btn = "nul" +input_player9_select_axis = "nul" +input_player9_start = "nul" +input_player9_start_btn = "nul" +input_player9_start_axis = "nul" +input_player9_up = "nul" +input_player9_up_btn = "nul" +input_player9_up_axis = "nul" +input_player9_down = "nul" +input_player9_down_btn = "nul" +input_player9_down_axis = "nul" +input_player9_left = "nul" +input_player9_left_btn = "nul" +input_player9_left_axis = "nul" +input_player9_right = "nul" +input_player9_right_btn = "nul" +input_player9_right_axis = "nul" +input_player9_a = "nul" +input_player9_a_btn = "nul" +input_player9_a_axis = "nul" +input_player9_x = "nul" +input_player9_x_btn = "nul" +input_player9_x_axis = "nul" +input_player9_l = "nul" +input_player9_l_btn = "nul" +input_player9_l_axis = "nul" +input_player9_r = "nul" +input_player9_r_btn = "nul" +input_player9_r_axis = "nul" +input_player9_l2 = "nul" +input_player9_l2_btn = "nul" +input_player9_l2_axis = "nul" +input_player9_r2 = "nul" +input_player9_r2_btn = "nul" +input_player9_r2_axis = "nul" +input_player9_l3 = "nul" +input_player9_l3_btn = "nul" +input_player9_l3_axis = "nul" +input_player9_r3 = "nul" +input_player9_r3_btn = "nul" +input_player9_r3_axis = "nul" +input_player9_l_x_plus = "nul" +input_player9_l_x_plus_btn = "nul" +input_player9_l_x_plus_axis = "nul" +input_player9_l_x_minus = "nul" +input_player9_l_x_minus_btn = "nul" +input_player9_l_x_minus_axis = "nul" +input_player9_l_y_plus = "nul" +input_player9_l_y_plus_btn = "nul" +input_player9_l_y_plus_axis = "nul" +input_player9_l_y_minus = "nul" +input_player9_l_y_minus_btn = "nul" +input_player9_l_y_minus_axis = "nul" +input_player9_r_x_plus = "nul" +input_player9_r_x_plus_btn = "nul" +input_player9_r_x_plus_axis = "nul" +input_player9_r_x_minus = "nul" +input_player9_r_x_minus_btn = "nul" +input_player9_r_x_minus_axis = "nul" +input_player9_r_y_plus = "nul" +input_player9_r_y_plus_btn = "nul" +input_player9_r_y_plus_axis = "nul" +input_player9_r_y_minus = "nul" +input_player9_r_y_minus_btn = "nul" +input_player9_r_y_minus_axis = "nul" +input_player9_turbo = "nul" +input_player9_turbo_btn = "nul" +input_player9_turbo_axis = "nul" +input_player10_b = "nul" +input_player10_b_btn = "nul" +input_player10_b_axis = "nul" +input_player10_y = "nul" +input_player10_y_btn = "nul" +input_player10_y_axis = "nul" +input_player10_select = "nul" +input_player10_select_btn = "nul" +input_player10_select_axis = "nul" +input_player10_start = "nul" +input_player10_start_btn = "nul" +input_player10_start_axis = "nul" +input_player10_up = "nul" +input_player10_up_btn = "nul" +input_player10_up_axis = "nul" +input_player10_down = "nul" +input_player10_down_btn = "nul" +input_player10_down_axis = "nul" +input_player10_left = "nul" +input_player10_left_btn = "nul" +input_player10_left_axis = "nul" +input_player10_right = "nul" +input_player10_right_btn = "nul" +input_player10_right_axis = "nul" +input_player10_a = "nul" +input_player10_a_btn = "nul" +input_player10_a_axis = "nul" +input_player10_x = "nul" +input_player10_x_btn = "nul" +input_player10_x_axis = "nul" +input_player10_l = "nul" +input_player10_l_btn = "nul" +input_player10_l_axis = "nul" +input_player10_r = "nul" +input_player10_r_btn = "nul" +input_player10_r_axis = "nul" +input_player10_l2 = "nul" +input_player10_l2_btn = "nul" +input_player10_l2_axis = "nul" +input_player10_r2 = "nul" +input_player10_r2_btn = "nul" +input_player10_r2_axis = "nul" +input_player10_l3 = "nul" +input_player10_l3_btn = "nul" +input_player10_l3_axis = "nul" +input_player10_r3 = "nul" +input_player10_r3_btn = "nul" +input_player10_r3_axis = "nul" +input_player10_l_x_plus = "nul" +input_player10_l_x_plus_btn = "nul" +input_player10_l_x_plus_axis = "nul" +input_player10_l_x_minus = "nul" +input_player10_l_x_minus_btn = "nul" +input_player10_l_x_minus_axis = "nul" +input_player10_l_y_plus = "nul" +input_player10_l_y_plus_btn = "nul" +input_player10_l_y_plus_axis = "nul" +input_player10_l_y_minus = "nul" +input_player10_l_y_minus_btn = "nul" +input_player10_l_y_minus_axis = "nul" +input_player10_r_x_plus = "nul" +input_player10_r_x_plus_btn = "nul" +input_player10_r_x_plus_axis = "nul" +input_player10_r_x_minus = "nul" +input_player10_r_x_minus_btn = "nul" +input_player10_r_x_minus_axis = "nul" +input_player10_r_y_plus = "nul" +input_player10_r_y_plus_btn = "nul" +input_player10_r_y_plus_axis = "nul" +input_player10_r_y_minus = "nul" +input_player10_r_y_minus_btn = "nul" +input_player10_r_y_minus_axis = "nul" +input_player10_turbo = "nul" +input_player10_turbo_btn = "nul" +input_player10_turbo_axis = "nul" +input_player11_b = "nul" +input_player11_b_btn = "nul" +input_player11_b_axis = "nul" +input_player11_y = "nul" +input_player11_y_btn = "nul" +input_player11_y_axis = "nul" +input_player11_select = "nul" +input_player11_select_btn = "nul" +input_player11_select_axis = "nul" +input_player11_start = "nul" +input_player11_start_btn = "nul" +input_player11_start_axis = "nul" +input_player11_up = "nul" +input_player11_up_btn = "nul" +input_player11_up_axis = "nul" +input_player11_down = "nul" +input_player11_down_btn = "nul" +input_player11_down_axis = "nul" +input_player11_left = "nul" +input_player11_left_btn = "nul" +input_player11_left_axis = "nul" +input_player11_right = "nul" +input_player11_right_btn = "nul" +input_player11_right_axis = "nul" +input_player11_a = "nul" +input_player11_a_btn = "nul" +input_player11_a_axis = "nul" +input_player11_x = "nul" +input_player11_x_btn = "nul" +input_player11_x_axis = "nul" +input_player11_l = "nul" +input_player11_l_btn = "nul" +input_player11_l_axis = "nul" +input_player11_r = "nul" +input_player11_r_btn = "nul" +input_player11_r_axis = "nul" +input_player11_l2 = "nul" +input_player11_l2_btn = "nul" +input_player11_l2_axis = "nul" +input_player11_r2 = "nul" +input_player11_r2_btn = "nul" +input_player11_r2_axis = "nul" +input_player11_l3 = "nul" +input_player11_l3_btn = "nul" +input_player11_l3_axis = "nul" +input_player11_r3 = "nul" +input_player11_r3_btn = "nul" +input_player11_r3_axis = "nul" +input_player11_l_x_plus = "nul" +input_player11_l_x_plus_btn = "nul" +input_player11_l_x_plus_axis = "nul" +input_player11_l_x_minus = "nul" +input_player11_l_x_minus_btn = "nul" +input_player11_l_x_minus_axis = "nul" +input_player11_l_y_plus = "nul" +input_player11_l_y_plus_btn = "nul" +input_player11_l_y_plus_axis = "nul" +input_player11_l_y_minus = "nul" +input_player11_l_y_minus_btn = "nul" +input_player11_l_y_minus_axis = "nul" +input_player11_r_x_plus = "nul" +input_player11_r_x_plus_btn = "nul" +input_player11_r_x_plus_axis = "nul" +input_player11_r_x_minus = "nul" +input_player11_r_x_minus_btn = "nul" +input_player11_r_x_minus_axis = "nul" +input_player11_r_y_plus = "nul" +input_player11_r_y_plus_btn = "nul" +input_player11_r_y_plus_axis = "nul" +input_player11_r_y_minus = "nul" +input_player11_r_y_minus_btn = "nul" +input_player11_r_y_minus_axis = "nul" +input_player11_turbo = "nul" +input_player11_turbo_btn = "nul" +input_player11_turbo_axis = "nul" +input_player12_b = "nul" +input_player12_b_btn = "nul" +input_player12_b_axis = "nul" +input_player12_y = "nul" +input_player12_y_btn = "nul" +input_player12_y_axis = "nul" +input_player12_select = "nul" +input_player12_select_btn = "nul" +input_player12_select_axis = "nul" +input_player12_start = "nul" +input_player12_start_btn = "nul" +input_player12_start_axis = "nul" +input_player12_up = "nul" +input_player12_up_btn = "nul" +input_player12_up_axis = "nul" +input_player12_down = "nul" +input_player12_down_btn = "nul" +input_player12_down_axis = "nul" +input_player12_left = "nul" +input_player12_left_btn = "nul" +input_player12_left_axis = "nul" +input_player12_right = "nul" +input_player12_right_btn = "nul" +input_player12_right_axis = "nul" +input_player12_a = "nul" +input_player12_a_btn = "nul" +input_player12_a_axis = "nul" +input_player12_x = "nul" +input_player12_x_btn = "nul" +input_player12_x_axis = "nul" +input_player12_l = "nul" +input_player12_l_btn = "nul" +input_player12_l_axis = "nul" +input_player12_r = "nul" +input_player12_r_btn = "nul" +input_player12_r_axis = "nul" +input_player12_l2 = "nul" +input_player12_l2_btn = "nul" +input_player12_l2_axis = "nul" +input_player12_r2 = "nul" +input_player12_r2_btn = "nul" +input_player12_r2_axis = "nul" +input_player12_l3 = "nul" +input_player12_l3_btn = "nul" +input_player12_l3_axis = "nul" +input_player12_r3 = "nul" +input_player12_r3_btn = "nul" +input_player12_r3_axis = "nul" +input_player12_l_x_plus = "nul" +input_player12_l_x_plus_btn = "nul" +input_player12_l_x_plus_axis = "nul" +input_player12_l_x_minus = "nul" +input_player12_l_x_minus_btn = "nul" +input_player12_l_x_minus_axis = "nul" +input_player12_l_y_plus = "nul" +input_player12_l_y_plus_btn = "nul" +input_player12_l_y_plus_axis = "nul" +input_player12_l_y_minus = "nul" +input_player12_l_y_minus_btn = "nul" +input_player12_l_y_minus_axis = "nul" +input_player12_r_x_plus = "nul" +input_player12_r_x_plus_btn = "nul" +input_player12_r_x_plus_axis = "nul" +input_player12_r_x_minus = "nul" +input_player12_r_x_minus_btn = "nul" +input_player12_r_x_minus_axis = "nul" +input_player12_r_y_plus = "nul" +input_player12_r_y_plus_btn = "nul" +input_player12_r_y_plus_axis = "nul" +input_player12_r_y_minus = "nul" +input_player12_r_y_minus_btn = "nul" +input_player12_r_y_minus_axis = "nul" +input_player12_turbo = "nul" +input_player12_turbo_btn = "nul" +input_player12_turbo_axis = "nul" +input_player13_b = "nul" +input_player13_b_btn = "nul" +input_player13_b_axis = "nul" +input_player13_y = "nul" +input_player13_y_btn = "nul" +input_player13_y_axis = "nul" +input_player13_select = "nul" +input_player13_select_btn = "nul" +input_player13_select_axis = "nul" +input_player13_start = "nul" +input_player13_start_btn = "nul" +input_player13_start_axis = "nul" +input_player13_up = "nul" +input_player13_up_btn = "nul" +input_player13_up_axis = "nul" +input_player13_down = "nul" +input_player13_down_btn = "nul" +input_player13_down_axis = "nul" +input_player13_left = "nul" +input_player13_left_btn = "nul" +input_player13_left_axis = "nul" +input_player13_right = "nul" +input_player13_right_btn = "nul" +input_player13_right_axis = "nul" +input_player13_a = "nul" +input_player13_a_btn = "nul" +input_player13_a_axis = "nul" +input_player13_x = "nul" +input_player13_x_btn = "nul" +input_player13_x_axis = "nul" +input_player13_l = "nul" +input_player13_l_btn = "nul" +input_player13_l_axis = "nul" +input_player13_r = "nul" +input_player13_r_btn = "nul" +input_player13_r_axis = "nul" +input_player13_l2 = "nul" +input_player13_l2_btn = "nul" +input_player13_l2_axis = "nul" +input_player13_r2 = "nul" +input_player13_r2_btn = "nul" +input_player13_r2_axis = "nul" +input_player13_l3 = "nul" +input_player13_l3_btn = "nul" +input_player13_l3_axis = "nul" +input_player13_r3 = "nul" +input_player13_r3_btn = "nul" +input_player13_r3_axis = "nul" +input_player13_l_x_plus = "nul" +input_player13_l_x_plus_btn = "nul" +input_player13_l_x_plus_axis = "nul" +input_player13_l_x_minus = "nul" +input_player13_l_x_minus_btn = "nul" +input_player13_l_x_minus_axis = "nul" +input_player13_l_y_plus = "nul" +input_player13_l_y_plus_btn = "nul" +input_player13_l_y_plus_axis = "nul" +input_player13_l_y_minus = "nul" +input_player13_l_y_minus_btn = "nul" +input_player13_l_y_minus_axis = "nul" +input_player13_r_x_plus = "nul" +input_player13_r_x_plus_btn = "nul" +input_player13_r_x_plus_axis = "nul" +input_player13_r_x_minus = "nul" +input_player13_r_x_minus_btn = "nul" +input_player13_r_x_minus_axis = "nul" +input_player13_r_y_plus = "nul" +input_player13_r_y_plus_btn = "nul" +input_player13_r_y_plus_axis = "nul" +input_player13_r_y_minus = "nul" +input_player13_r_y_minus_btn = "nul" +input_player13_r_y_minus_axis = "nul" +input_player13_turbo = "nul" +input_player13_turbo_btn = "nul" +input_player13_turbo_axis = "nul" +input_player14_b = "nul" +input_player14_b_btn = "nul" +input_player14_b_axis = "nul" +input_player14_y = "nul" +input_player14_y_btn = "nul" +input_player14_y_axis = "nul" +input_player14_select = "nul" +input_player14_select_btn = "nul" +input_player14_select_axis = "nul" +input_player14_start = "nul" +input_player14_start_btn = "nul" +input_player14_start_axis = "nul" +input_player14_up = "nul" +input_player14_up_btn = "nul" +input_player14_up_axis = "nul" +input_player14_down = "nul" +input_player14_down_btn = "nul" +input_player14_down_axis = "nul" +input_player14_left = "nul" +input_player14_left_btn = "nul" +input_player14_left_axis = "nul" +input_player14_right = "nul" +input_player14_right_btn = "nul" +input_player14_right_axis = "nul" +input_player14_a = "nul" +input_player14_a_btn = "nul" +input_player14_a_axis = "nul" +input_player14_x = "nul" +input_player14_x_btn = "nul" +input_player14_x_axis = "nul" +input_player14_l = "nul" +input_player14_l_btn = "nul" +input_player14_l_axis = "nul" +input_player14_r = "nul" +input_player14_r_btn = "nul" +input_player14_r_axis = "nul" +input_player14_l2 = "nul" +input_player14_l2_btn = "nul" +input_player14_l2_axis = "nul" +input_player14_r2 = "nul" +input_player14_r2_btn = "nul" +input_player14_r2_axis = "nul" +input_player14_l3 = "nul" +input_player14_l3_btn = "nul" +input_player14_l3_axis = "nul" +input_player14_r3 = "nul" +input_player14_r3_btn = "nul" +input_player14_r3_axis = "nul" +input_player14_l_x_plus = "nul" +input_player14_l_x_plus_btn = "nul" +input_player14_l_x_plus_axis = "nul" +input_player14_l_x_minus = "nul" +input_player14_l_x_minus_btn = "nul" +input_player14_l_x_minus_axis = "nul" +input_player14_l_y_plus = "nul" +input_player14_l_y_plus_btn = "nul" +input_player14_l_y_plus_axis = "nul" +input_player14_l_y_minus = "nul" +input_player14_l_y_minus_btn = "nul" +input_player14_l_y_minus_axis = "nul" +input_player14_r_x_plus = "nul" +input_player14_r_x_plus_btn = "nul" +input_player14_r_x_plus_axis = "nul" +input_player14_r_x_minus = "nul" +input_player14_r_x_minus_btn = "nul" +input_player14_r_x_minus_axis = "nul" +input_player14_r_y_plus = "nul" +input_player14_r_y_plus_btn = "nul" +input_player14_r_y_plus_axis = "nul" +input_player14_r_y_minus = "nul" +input_player14_r_y_minus_btn = "nul" +input_player14_r_y_minus_axis = "nul" +input_player14_turbo = "nul" +input_player14_turbo_btn = "nul" +input_player14_turbo_axis = "nul" +input_player15_b = "nul" +input_player15_b_btn = "nul" +input_player15_b_axis = "nul" +input_player15_y = "nul" +input_player15_y_btn = "nul" +input_player15_y_axis = "nul" +input_player15_select = "nul" +input_player15_select_btn = "nul" +input_player15_select_axis = "nul" +input_player15_start = "nul" +input_player15_start_btn = "nul" +input_player15_start_axis = "nul" +input_player15_up = "nul" +input_player15_up_btn = "nul" +input_player15_up_axis = "nul" +input_player15_down = "nul" +input_player15_down_btn = "nul" +input_player15_down_axis = "nul" +input_player15_left = "nul" +input_player15_left_btn = "nul" +input_player15_left_axis = "nul" +input_player15_right = "nul" +input_player15_right_btn = "nul" +input_player15_right_axis = "nul" +input_player15_a = "nul" +input_player15_a_btn = "nul" +input_player15_a_axis = "nul" +input_player15_x = "nul" +input_player15_x_btn = "nul" +input_player15_x_axis = "nul" +input_player15_l = "nul" +input_player15_l_btn = "nul" +input_player15_l_axis = "nul" +input_player15_r = "nul" +input_player15_r_btn = "nul" +input_player15_r_axis = "nul" +input_player15_l2 = "nul" +input_player15_l2_btn = "nul" +input_player15_l2_axis = "nul" +input_player15_r2 = "nul" +input_player15_r2_btn = "nul" +input_player15_r2_axis = "nul" +input_player15_l3 = "nul" +input_player15_l3_btn = "nul" +input_player15_l3_axis = "nul" +input_player15_r3 = "nul" +input_player15_r3_btn = "nul" +input_player15_r3_axis = "nul" +input_player15_l_x_plus = "nul" +input_player15_l_x_plus_btn = "nul" +input_player15_l_x_plus_axis = "nul" +input_player15_l_x_minus = "nul" +input_player15_l_x_minus_btn = "nul" +input_player15_l_x_minus_axis = "nul" +input_player15_l_y_plus = "nul" +input_player15_l_y_plus_btn = "nul" +input_player15_l_y_plus_axis = "nul" +input_player15_l_y_minus = "nul" +input_player15_l_y_minus_btn = "nul" +input_player15_l_y_minus_axis = "nul" +input_player15_r_x_plus = "nul" +input_player15_r_x_plus_btn = "nul" +input_player15_r_x_plus_axis = "nul" +input_player15_r_x_minus = "nul" +input_player15_r_x_minus_btn = "nul" +input_player15_r_x_minus_axis = "nul" +input_player15_r_y_plus = "nul" +input_player15_r_y_plus_btn = "nul" +input_player15_r_y_plus_axis = "nul" +input_player15_r_y_minus = "nul" +input_player15_r_y_minus_btn = "nul" +input_player15_r_y_minus_axis = "nul" +input_player15_turbo = "nul" +input_player15_turbo_btn = "nul" +input_player15_turbo_axis = "nul" +input_player16_b = "nul" +input_player16_b_btn = "nul" +input_player16_b_axis = "nul" +input_player16_y = "nul" +input_player16_y_btn = "nul" +input_player16_y_axis = "nul" +input_player16_select = "nul" +input_player16_select_btn = "nul" +input_player16_select_axis = "nul" +input_player16_start = "nul" +input_player16_start_btn = "nul" +input_player16_start_axis = "nul" +input_player16_up = "nul" +input_player16_up_btn = "nul" +input_player16_up_axis = "nul" +input_player16_down = "nul" +input_player16_down_btn = "nul" +input_player16_down_axis = "nul" +input_player16_left = "nul" +input_player16_left_btn = "nul" +input_player16_left_axis = "nul" +input_player16_right = "nul" +input_player16_right_btn = "nul" +input_player16_right_axis = "nul" +input_player16_a = "nul" +input_player16_a_btn = "nul" +input_player16_a_axis = "nul" +input_player16_x = "nul" +input_player16_x_btn = "nul" +input_player16_x_axis = "nul" +input_player16_l = "nul" +input_player16_l_btn = "nul" +input_player16_l_axis = "nul" +input_player16_r = "nul" +input_player16_r_btn = "nul" +input_player16_r_axis = "nul" +input_player16_l2 = "nul" +input_player16_l2_btn = "nul" +input_player16_l2_axis = "nul" +input_player16_r2 = "nul" +input_player16_r2_btn = "nul" +input_player16_r2_axis = "nul" +input_player16_l3 = "nul" +input_player16_l3_btn = "nul" +input_player16_l3_axis = "nul" +input_player16_r3 = "nul" +input_player16_r3_btn = "nul" +input_player16_r3_axis = "nul" +input_player16_l_x_plus = "nul" +input_player16_l_x_plus_btn = "nul" +input_player16_l_x_plus_axis = "nul" +input_player16_l_x_minus = "nul" +input_player16_l_x_minus_btn = "nul" +input_player16_l_x_minus_axis = "nul" +input_player16_l_y_plus = "nul" +input_player16_l_y_plus_btn = "nul" +input_player16_l_y_plus_axis = "nul" +input_player16_l_y_minus = "nul" +input_player16_l_y_minus_btn = "nul" +input_player16_l_y_minus_axis = "nul" +input_player16_r_x_plus = "nul" +input_player16_r_x_plus_btn = "nul" +input_player16_r_x_plus_axis = "nul" +input_player16_r_x_minus = "nul" +input_player16_r_x_minus_btn = "nul" +input_player16_r_x_minus_axis = "nul" +input_player16_r_y_plus = "nul" +input_player16_r_y_plus_btn = "nul" +input_player16_r_y_plus_axis = "nul" +input_player16_r_y_minus = "nul" +input_player16_r_y_minus_btn = "nul" +input_player16_r_y_minus_axis = "nul" +input_player16_turbo = "nul" +input_player16_turbo_btn = "nul" +input_player16_turbo_axis = "nul" +core_specific_config = "false" +game_specific_options = "false" +auto_overrides_enable = "true" +auto_remaps_enable = "true" +sort_savefiles_enable = "false" +sort_savestates_enable = "false" +libretro_log_level = "0" +log_verbosity = "false" +perfcnt_enable = "false" +keyboard_gamepad_enable = "true" +keyboard_gamepad_mapping_type = "1" +input_poll_type_behavior = "2" +core_set_supports_no_game_enable = "true" +menu_ok_btn = "8" +menu_cancel_btn = "0" +menu_search_btn = "9" +menu_info_btn = "2" +menu_default_btn = "3" +menu_scroll_down_btn = "11" +menu_scroll_up_btn = "10" +recording_output_directory = "" +recording_config_directory = "" +core_options_path = "" +video_shader = "" +bundle_assets_src_path = "" +bundle_assets_dst_path = "" +bundle_assets_dst_path_subdir = "" +menu_wallpaper = "" +video_filter = "" +audio_dsp_plugin = "" +input_overlay = "" +input_osk_overlay = "" +video_font_path = "" +content_history_dir = "" +playlist_names = "" +playlist_cores = "" +audio_device = "" +camera_device = "" +cheevos_username = "" +cheevos_password = "" +video_context_driver = "" +cache_directory = "" +resampler_directory = "" +xmb_font = "" +netplay_ip_address = "" +netplay_nickname = "" +input_keyboard_layout = "" From 0c09050760a5416121ac68c27ed595e27e778b6c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Sun, 1 May 2016 02:03:17 +0700 Subject: [PATCH 010/498] Keep thumbnails at the root, since they have their own repo, for the sake of consistency with libretro-fetch --- frontend/drivers/platform_win32.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/drivers/platform_win32.c b/frontend/drivers/platform_win32.c index 65887e3eec..6b49180bb5 100644 --- a/frontend/drivers/platform_win32.c +++ b/frontend/drivers/platform_win32.c @@ -257,7 +257,7 @@ static void frontend_win32_environment_get(int *argc, char *argv[], fill_pathname_expand_special(g_defaults.dir.wallpapers, ":/assets/wallpapers", sizeof(g_defaults.dir.wallpapers)); fill_pathname_expand_special(g_defaults.dir.thumbnails, - ":/assets/thumbnails", sizeof(g_defaults.dir.thumbnails)); + ":/thumbnails", sizeof(g_defaults.dir.thumbnails)); fill_pathname_expand_special(g_defaults.dir.overlay, ":/overlays", sizeof(g_defaults.dir.overlay)); fill_pathname_expand_special(g_defaults.dir.osk_overlay, From c0a97eeb6016533dec36c6949e7f5942ac6592eb Mon Sep 17 00:00:00 2001 From: radius Date: Sat, 30 Apr 2016 14:33:02 -0500 Subject: [PATCH 011/498] Modified android: - save thumbnails on the sdcard if writable - save cheats on the sdcard if writable - save remaps on the sdcard if writable - save playlists on the sdcard if writable windows: - stub out defaults for save/state/system --- frontend/drivers/platform_linux.c | 52 ++++++++++++++++++++++++------- frontend/drivers/platform_win32.c | 10 ++++++ 2 files changed, 50 insertions(+), 12 deletions(-) diff --git a/frontend/drivers/platform_linux.c b/frontend/drivers/platform_linux.c index 5aff18c892..6e508d4847 100644 --- a/frontend/drivers/platform_linux.c +++ b/frontend/drivers/platform_linux.c @@ -1829,16 +1829,8 @@ static void frontend_linux_get_env(int *argc, app_dir, "database/rdb", sizeof(g_defaults.dir.database)); fill_pathname_join(g_defaults.dir.cursor, app_dir, "database/cursors", sizeof(g_defaults.dir.cursor)); - fill_pathname_join(g_defaults.dir.cheats, - app_dir, "cheats", sizeof(g_defaults.dir.cheats)); - fill_pathname_join(g_defaults.dir.playlist, - app_dir, "playlists", sizeof(g_defaults.dir.playlist)); - fill_pathname_join(g_defaults.dir.remap, - app_dir, "remaps", sizeof(g_defaults.dir.remap)); fill_pathname_join(g_defaults.dir.wallpapers, - app_dir, "wallpapers", sizeof(g_defaults.dir.wallpapers)); - fill_pathname_join(g_defaults.dir.thumbnails, - app_dir, "thumbnails", sizeof(g_defaults.dir.thumbnails)); + app_dir, "assets/wallpapers", sizeof(g_defaults.dir.wallpapers)); if(*downloads_dir && test_permissions(downloads_dir)) { fill_pathname_join(g_defaults.dir.core_assets, @@ -1873,11 +1865,9 @@ static void frontend_linux_get_env(int *argc, fill_pathname_join(g_defaults.dir.sram, ext_dir, "saves", sizeof(g_defaults.dir.sram)); path_mkdir(g_defaults.dir.sram); - fill_pathname_join(g_defaults.dir.savestate, ext_dir, "states", sizeof(g_defaults.dir.savestate)); path_mkdir(g_defaults.dir.savestate); - fill_pathname_join(g_defaults.dir.system, ext_dir, "system", sizeof(g_defaults.dir.system)); path_mkdir(g_defaults.dir.system); @@ -1885,7 +1875,18 @@ static void frontend_linux_get_env(int *argc, fill_pathname_join(g_defaults.dir.menu_config, ext_dir, "config", sizeof(g_defaults.dir.menu_config)); path_mkdir(g_defaults.dir.menu_config); - + fill_pathname_join(g_defaults.dir.remap, + ext_dir, "config/remap", sizeof(g_defaults.dir.remap)); + path_mkdir(g_defaults.dir.remap); + fill_pathname_join(g_defaults.dir.thumbnails, + ext_dir, "thumbnails", sizeof(g_defaults.dir.thumbnails)); + path_mkdir(g_defaults.dir.thumbnails); + fill_pathname_join(g_defaults.dir.playlist, + ext_dir, "playlists", sizeof(g_defaults.dir.playlist)); + path_mkdir(g_defaults.dir.playlist); + fill_pathname_join(g_defaults.dir.cheats, + ext_dir, "cheats", sizeof(g_defaults.dir.cheats)); + path_mkdir(g_defaults.dir.cheats); break; case SDCARD_NOT_WRITABLE: fill_pathname_join(g_defaults.dir.sram, @@ -1901,8 +1902,35 @@ static void frontend_linux_get_env(int *argc, fill_pathname_join(g_defaults.dir.menu_config, app_dir, "config", sizeof(g_defaults.dir.menu_config)); path_mkdir(g_defaults.dir.menu_config); + fill_pathname_join(g_defaults.dir.remap, + app_dir, "config/remap", sizeof(g_defaults.dir.remap)); + path_mkdir(g_defaults.dir.remap); + fill_pathname_join(g_defaults.dir.thumbnails, + app_dir, "thumbnails", sizeof(g_defaults.dir.thumbnails)); + path_mkdir(g_defaults.dir.thumbnails); + fill_pathname_join(g_defaults.dir.playlist, + app_dir, "playlists", sizeof(g_defaults.dir.playlist)); + path_mkdir(g_defaults.dir.playlist); + fill_pathname_join(g_defaults.dir.cheats, + app_dir, "cheats", sizeof(g_defaults.dir.cheats)); + path_mkdir(g_defaults.dir.cheats); break; case SDCARD_ROOT_WRITABLE: + fill_pathname_join(g_defaults.dir.menu_config, + sdcard_dir, "config", sizeof(g_defaults.dir.menu_config)); + path_mkdir(g_defaults.dir.menu_config); + fill_pathname_join(g_defaults.dir.remap, + sdcard_dir, "config/remap", sizeof(g_defaults.dir.remap)); + path_mkdir(g_defaults.dir.remap); + fill_pathname_join(g_defaults.dir.thumbnails, + sdcard_dir, "thumbnails", sizeof(g_defaults.dir.thumbnails)); + path_mkdir(g_defaults.dir.thumbnails); + fill_pathname_join(g_defaults.dir.playlist, + sdcard_dir, "playlists", sizeof(g_defaults.dir.playlist)); + path_mkdir(g_defaults.dir.playlist); + fill_pathname_join(g_defaults.dir.cheats, + sdcard_dir, "cheats", sizeof(g_defaults.dir.cheats)); + path_mkdir(g_defaults.dir.cheats); default: break; } diff --git a/frontend/drivers/platform_win32.c b/frontend/drivers/platform_win32.c index 6b49180bb5..d93f0db471 100644 --- a/frontend/drivers/platform_win32.c +++ b/frontend/drivers/platform_win32.c @@ -279,6 +279,16 @@ static void frontend_win32_environment_get(int *argc, char *argv[], fill_pathname_expand_special(g_defaults.dir.screenshot, ":/screenshots", sizeof(g_defaults.dir.screenshot)); +/* don't force this in the driver anymore, these will be handled by + a dummy config file so they can be reset to content dir + + fill_pathname_expand_special(g_defaults.dir.sram, + ":/saves", sizeof(g_defaults.dir.sram)); + fill_pathname_expand_special(g_defaults.dir.savestate, + ":/states", sizeof(g_defaults.dir.savestate)); + fill_pathname_expand_special(g_defaults.dir.system, + ":/system", sizeof(g_defaults.dir.system)); +*/ #ifdef HAVE_MENU #if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) snprintf(g_defaults.settings.menu, sizeof(g_defaults.settings.menu), "xmb"); From 96bc0111c8f5b3075ea5590c7dad0030bf1ba642 Mon Sep 17 00:00:00 2001 From: radius Date: Sat, 30 Apr 2016 14:34:48 -0500 Subject: [PATCH 012/498] revert the default config --- retroarch.cfg | 2382 ++++++++++++++++--------------------------------- 1 file changed, 783 insertions(+), 1599 deletions(-) diff --git a/retroarch.cfg b/retroarch.cfg index 92783b49ec..eed7864bbb 100644 --- a/retroarch.cfg +++ b/retroarch.cfg @@ -1,1599 +1,783 @@ -config_save_on_exit = "true" -input_turbo_period = "6" -input_duty_cycle = "3" -input_max_users = "5" -input_menu_toggle_gamepad_combo = "0" -input_axis_threshold = "0.500000" -ui_companion_start_on_boot = "true" -ui_companion_enable = "false" -video_gpu_record = "false" -input_remap_binds_enable = "true" -back_as_menu_toggle_enable = "true" -netplay_client_swap_input = "true" -input_descriptor_label_show = "true" -input_descriptor_hide_unbound = "false" -load_dummy_on_core_shutdown = "true" -builtin_mediaplayer_enable = "true" -builtin_imageviewer_enable = "true" -fps_show = "false" -ui_menubar_enable = "true" -suspend_screensaver_enable = "true" -libretro_directory = ":\cores" -libretro_info_path = ":\info" -content_database_path = ":\database/rdb" -cheat_database_path = ":\cheats" -content_history_path = ":\content_history.lpl" -cursor_directory = ":\database/cursors" -rewind_enable = "false" -audio_latency = "64" -audio_sync = "true" -audio_block_frames = "0" -rewind_granularity = "1" -video_shader_enable = "false" -video_aspect_ratio = "-1.000000" -video_aspect_ratio_auto = "false" -video_windowed_fullscreen = "true" -video_scale = "3.000000" -autosave_interval = "0" -video_crop_overscan = "true" -video_scale_integer = "false" -video_smooth = "true" -video_threaded = "false" -video_shared_context = "false" -video_force_srgb_disable = "false" -video_fullscreen = "false" -bundle_assets_extract_enable = "false" -bundle_assets_extract_version_current = "0" -bundle_assets_extract_last_version = "0" -video_refresh_rate = "59.950001" -video_monitor_index = "0" -video_fullscreen_x = "0" -video_fullscreen_y = "0" -video_driver = "gl" -record_driver = "ffmpeg" -camera_driver = "null" -location_driver = "null" -threaded_data_runloop_enable = "true" -menu_throttle_framerate = "true" -menu_linear_filter = "true" -dpi_override_enable = "true" -dpi_override_value = "200" -menu_driver = "xmb" -menu_pause_libretro = "true" -menu_mouse_enable = "false" -menu_pointer_enable = "false" -menu_timedate_enable = "true" -menu_core_enable = "true" -menu_dynamic_wallpaper_enable = "false" -menu_thumbnails = "0" -video_vsync = "true" -video_hard_sync = "false" -video_hard_sync_frames = "0" -video_frame_delay = "0" -video_black_frame_insertion = "false" -video_disable_composition = "false" -pause_nonactive = "true" -video_swap_interval = "1" -video_gpu_screenshot = "true" -video_rotation = "0" -screenshot_directory = ":\screenshots" -auto_screenshot_filename = "true" -aspect_ratio_index = "21" -core_updater_buildbot_url = "http://buildbot.libretro.com/nightly/win-x86_64/latest/" -core_updater_buildbot_assets_url = "http://buildbot.libretro.com/assets/" -core_updater_auto_extract_archive = "true" -camera_allow = "false" -cheevos_enable = "false" -cheevos_test_unofficial = "false" -cheevos_hardcore_mode_enable = "false" -audio_rate_control = "true" -audio_rate_control_delta = "0.005000" -audio_max_timing_skew = "0.050000" -audio_volume = "0.000000" -audio_driver = "xaudio" -audio_enable = "true" -audio_mute_enable = "false" -audio_out_rate = "48000" -location_allow = "false" -video_font_size = "32.000000" -video_font_enable = "true" -video_message_color = "ffff00" -ups_pref = "false" -bps_pref = "false" -ips_pref = "false" -system_directory = "default" -input_remapping_directory = ":\config/remap" -video_shader_dir = ":\shaders" -video_filter_dir = ":\filters/video" -core_assets_directory = ":\downloads" -assets_directory = ":\assets" -dynamic_wallpapers_directory = ":\assets/wallpapers" -thumbnails_directory = ":\assets/thumbnails" -playlist_directory = ":\playlists" -rgui_browser_directory = "default" -rgui_config_directory = ":\config" -joypad_autoconfig_dir = ":\autoconfig" -overlay_directory = ":\overlays" -audio_filter_dir = ":\filters/audio" -audio_resampler = "sinc" -savefile_directory = "default" -savestate_directory = "default" -xmb_scale_factor = "100" -xmb_alpha_factor = "75" -xmb_theme = "0" -xmb_gradient = "0" -xmb_shadows_enable = "false" -xmb_ribbon_enable = "0" -rgui_show_start_screen = "false" -menu_navigation_wraparound_enable = "true" -menu_navigation_browser_filter_supported_extensions_enable = "true" -menu_show_advanced_settings = "true" -menu_entry_normal_color = "ffffffff" -menu_entry_hover_color = "ff64ff64" -menu_title_color = "ff64ff64" -content_history_size = "100" -input_autodetect_enable = "true" -input_overlay_enable = "true" -input_overlay_enable_autopreferred = "true" -input_overlay_hide_in_menu = "true" -input_overlay_opacity = "0.700000" -input_overlay_scale = "1.000000" -osk_overlay_directory = ":\overlays" -input_osk_overlay_enable = "true" -video_message_pos_x = "0.050000" -video_message_pos_y = "0.050000" -custom_viewport_width = "960" -custom_viewport_height = "720" -custom_viewport_x = "0" -custom_viewport_y = "0" -gamma_correction = "false" -flicker_filter_enable = "false" -soft_filter_enable = "false" -soft_filter_index = "0" -current_resolution_id = "0" -flicker_filter_index = "0" -video_font_size = "32.000000" -block_sram_overwrite = "false" -savestate_auto_index = "false" -savestate_auto_save = "false" -savestate_auto_load = "false" -history_list_enable = "true" -network_cmd_enable = "false" -stdin_cmd_enable = "false" -network_cmd_port = "55355" -fastforward_ratio = "0.000000" -slowmotion_ratio = "3.000000" -state_slot = "0" -netplay_spectator_mode_enable = "false" -netplay_mode = "false" -netplay_ip_port = "0" -netplay_delay_frames = "0" -user_language = "0" -custom_bgm_enable = "false" -input_driver = "dinput" -input_joypad_driver = "xinput" -input_device_p1 = "0" -input_player1_joypad_index = "0" -input_libretro_device_p1 = "1" -input_player1_analog_dpad_mode = "0" -input_device_p2 = "0" -input_player2_joypad_index = "1" -input_libretro_device_p2 = "1" -input_player2_analog_dpad_mode = "0" -input_device_p3 = "0" -input_player3_joypad_index = "2" -input_libretro_device_p3 = "1" -input_player3_analog_dpad_mode = "0" -input_device_p4 = "0" -input_player4_joypad_index = "3" -input_libretro_device_p4 = "1" -input_player4_analog_dpad_mode = "0" -input_device_p5 = "0" -input_player5_joypad_index = "4" -input_libretro_device_p5 = "1" -input_player5_analog_dpad_mode = "0" -input_device_p6 = "0" -input_player6_joypad_index = "5" -input_libretro_device_p6 = "1" -input_player6_analog_dpad_mode = "0" -input_device_p7 = "0" -input_player7_joypad_index = "6" -input_libretro_device_p7 = "1" -input_player7_analog_dpad_mode = "0" -input_device_p8 = "0" -input_player8_joypad_index = "7" -input_libretro_device_p8 = "1" -input_player8_analog_dpad_mode = "0" -input_device_p9 = "0" -input_player9_joypad_index = "8" -input_libretro_device_p9 = "1" -input_player9_analog_dpad_mode = "0" -input_device_p10 = "0" -input_player10_joypad_index = "9" -input_libretro_device_p10 = "1" -input_player10_analog_dpad_mode = "0" -input_device_p11 = "0" -input_player11_joypad_index = "10" -input_libretro_device_p11 = "1" -input_player11_analog_dpad_mode = "0" -input_device_p12 = "0" -input_player12_joypad_index = "11" -input_libretro_device_p12 = "1" -input_player12_analog_dpad_mode = "0" -input_device_p13 = "0" -input_player13_joypad_index = "12" -input_libretro_device_p13 = "1" -input_player13_analog_dpad_mode = "0" -input_device_p14 = "0" -input_player14_joypad_index = "13" -input_libretro_device_p14 = "1" -input_player14_analog_dpad_mode = "0" -input_device_p15 = "0" -input_player15_joypad_index = "14" -input_libretro_device_p15 = "1" -input_player15_analog_dpad_mode = "0" -input_device_p16 = "0" -input_player16_joypad_index = "15" -input_libretro_device_p16 = "1" -input_player16_analog_dpad_mode = "0" -network_remote_enable_user_p1 = "false" -network_remote_enable_user_p2 = "false" -network_remote_enable_user_p3 = "false" -network_remote_enable_user_p4 = "false" -network_remote_enable_user_p5 = "false" -network_remote_enable_user_p6 = "false" -network_remote_enable_user_p7 = "false" -network_remote_enable_user_p8 = "false" -network_remote_enable_user_p9 = "false" -network_remote_enable_user_p10 = "false" -network_remote_enable_user_p11 = "false" -network_remote_enable_user_p12 = "false" -network_remote_enable_user_p13 = "false" -network_remote_enable_user_p14 = "false" -network_remote_enable_user_p15 = "false" -network_remote_enable_user_p16 = "false" -network_remote_enable = "false" -network_remote_base_port = "55400" -input_player1_b = "z" -input_player1_b_btn = "nul" -input_player1_b_axis = "nul" -input_player1_y = "a" -input_player1_y_btn = "nul" -input_player1_y_axis = "nul" -input_player1_select = "rshift" -input_player1_select_btn = "nul" -input_player1_select_axis = "nul" -input_player1_start = "enter" -input_player1_start_btn = "nul" -input_player1_start_axis = "nul" -input_player1_up = "up" -input_player1_up_btn = "nul" -input_player1_up_axis = "nul" -input_player1_down = "down" -input_player1_down_btn = "nul" -input_player1_down_axis = "nul" -input_player1_left = "left" -input_player1_left_btn = "nul" -input_player1_left_axis = "nul" -input_player1_right = "right" -input_player1_right_btn = "nul" -input_player1_right_axis = "nul" -input_player1_a = "x" -input_player1_a_btn = "nul" -input_player1_a_axis = "nul" -input_player1_x = "s" -input_player1_x_btn = "nul" -input_player1_x_axis = "nul" -input_player1_l = "q" -input_player1_l_btn = "nul" -input_player1_l_axis = "nul" -input_player1_r = "w" -input_player1_r_btn = "nul" -input_player1_r_axis = "nul" -input_player1_l2 = "nul" -input_player1_l2_btn = "nul" -input_player1_l2_axis = "nul" -input_player1_r2 = "nul" -input_player1_r2_btn = "nul" -input_player1_r2_axis = "nul" -input_player1_l3 = "nul" -input_player1_l3_btn = "nul" -input_player1_l3_axis = "nul" -input_player1_r3 = "nul" -input_player1_r3_btn = "nul" -input_player1_r3_axis = "nul" -input_player1_l_x_plus = "nul" -input_player1_l_x_plus_btn = "nul" -input_player1_l_x_plus_axis = "nul" -input_player1_l_x_minus = "nul" -input_player1_l_x_minus_btn = "nul" -input_player1_l_x_minus_axis = "nul" -input_player1_l_y_plus = "nul" -input_player1_l_y_plus_btn = "nul" -input_player1_l_y_plus_axis = "nul" -input_player1_l_y_minus = "nul" -input_player1_l_y_minus_btn = "nul" -input_player1_l_y_minus_axis = "nul" -input_player1_r_x_plus = "nul" -input_player1_r_x_plus_btn = "nul" -input_player1_r_x_plus_axis = "nul" -input_player1_r_x_minus = "nul" -input_player1_r_x_minus_btn = "nul" -input_player1_r_x_minus_axis = "nul" -input_player1_r_y_plus = "nul" -input_player1_r_y_plus_btn = "nul" -input_player1_r_y_plus_axis = "nul" -input_player1_r_y_minus = "nul" -input_player1_r_y_minus_btn = "nul" -input_player1_r_y_minus_axis = "nul" -input_player1_turbo = "nul" -input_player1_turbo_btn = "nul" -input_player1_turbo_axis = "nul" -input_toggle_fast_forward = "space" -input_toggle_fast_forward_btn = "nul" -input_toggle_fast_forward_axis = "nul" -input_hold_fast_forward = "l" -input_hold_fast_forward_btn = "nul" -input_hold_fast_forward_axis = "nul" -input_load_state = "f4" -input_load_state_btn = "nul" -input_load_state_axis = "nul" -input_save_state = "f2" -input_save_state_btn = "nul" -input_save_state_axis = "nul" -input_toggle_fullscreen = "f" -input_toggle_fullscreen_btn = "nul" -input_toggle_fullscreen_axis = "nul" -input_exit_emulator = "escape" -input_exit_emulator_btn = "nul" -input_exit_emulator_axis = "nul" -input_state_slot_increase = "f7" -input_state_slot_increase_btn = "nul" -input_state_slot_increase_axis = "nul" -input_state_slot_decrease = "f6" -input_state_slot_decrease_btn = "nul" -input_state_slot_decrease_axis = "nul" -input_rewind = "r" -input_rewind_btn = "nul" -input_rewind_axis = "nul" -input_movie_record_toggle = "o" -input_movie_record_toggle_btn = "nul" -input_movie_record_toggle_axis = "nul" -input_pause_toggle = "p" -input_pause_toggle_btn = "nul" -input_pause_toggle_axis = "nul" -input_frame_advance = "k" -input_frame_advance_btn = "nul" -input_frame_advance_axis = "nul" -input_reset = "h" -input_reset_btn = "nul" -input_reset_axis = "nul" -input_shader_next = "m" -input_shader_next_btn = "nul" -input_shader_next_axis = "nul" -input_shader_prev = "n" -input_shader_prev_btn = "nul" -input_shader_prev_axis = "nul" -input_cheat_index_plus = "y" -input_cheat_index_plus_btn = "nul" -input_cheat_index_plus_axis = "nul" -input_cheat_index_minus = "t" -input_cheat_index_minus_btn = "nul" -input_cheat_index_minus_axis = "nul" -input_cheat_toggle = "u" -input_cheat_toggle_btn = "nul" -input_cheat_toggle_axis = "nul" -input_screenshot = "f8" -input_screenshot_btn = "nul" -input_screenshot_axis = "nul" -input_audio_mute = "f9" -input_audio_mute_btn = "nul" -input_audio_mute_axis = "nul" -input_osk_toggle = "f12" -input_osk_toggle_btn = "nul" -input_osk_toggle_axis = "nul" -input_netplay_flip_players = "i" -input_netplay_flip_players_btn = "nul" -input_netplay_flip_players_axis = "nul" -input_slowmotion = "e" -input_slowmotion_btn = "nul" -input_slowmotion_axis = "nul" -input_enable_hotkey = "nul" -input_enable_hotkey_btn = "nul" -input_enable_hotkey_axis = "nul" -input_volume_up = "add" -input_volume_up_btn = "nul" -input_volume_up_axis = "nul" -input_volume_down = "subtract" -input_volume_down_btn = "nul" -input_volume_down_axis = "nul" -input_overlay_next = "nul" -input_overlay_next_btn = "nul" -input_overlay_next_axis = "nul" -input_disk_eject_toggle = "nul" -input_disk_eject_toggle_btn = "nul" -input_disk_eject_toggle_axis = "nul" -input_disk_next = "nul" -input_disk_next_btn = "nul" -input_disk_next_axis = "nul" -input_disk_prev = "nul" -input_disk_prev_btn = "nul" -input_disk_prev_axis = "nul" -input_grab_mouse_toggle = "f11" -input_grab_mouse_toggle_btn = "nul" -input_grab_mouse_toggle_axis = "nul" -input_menu_toggle = "f1" -input_menu_toggle_btn = "nul" -input_menu_toggle_axis = "nul" -input_player2_b = "nul" -input_player2_b_btn = "nul" -input_player2_b_axis = "nul" -input_player2_y = "nul" -input_player2_y_btn = "nul" -input_player2_y_axis = "nul" -input_player2_select = "nul" -input_player2_select_btn = "nul" -input_player2_select_axis = "nul" -input_player2_start = "nul" -input_player2_start_btn = "nul" -input_player2_start_axis = "nul" -input_player2_up = "nul" -input_player2_up_btn = "nul" -input_player2_up_axis = "nul" -input_player2_down = "nul" -input_player2_down_btn = "nul" -input_player2_down_axis = "nul" -input_player2_left = "nul" -input_player2_left_btn = "nul" -input_player2_left_axis = "nul" -input_player2_right = "nul" -input_player2_right_btn = "nul" -input_player2_right_axis = "nul" -input_player2_a = "nul" -input_player2_a_btn = "nul" -input_player2_a_axis = "nul" -input_player2_x = "nul" -input_player2_x_btn = "nul" -input_player2_x_axis = "nul" -input_player2_l = "nul" -input_player2_l_btn = "nul" -input_player2_l_axis = "nul" -input_player2_r = "nul" -input_player2_r_btn = "nul" -input_player2_r_axis = "nul" -input_player2_l2 = "nul" -input_player2_l2_btn = "nul" -input_player2_l2_axis = "nul" -input_player2_r2 = "nul" -input_player2_r2_btn = "nul" -input_player2_r2_axis = "nul" -input_player2_l3 = "nul" -input_player2_l3_btn = "nul" -input_player2_l3_axis = "nul" -input_player2_r3 = "nul" -input_player2_r3_btn = "nul" -input_player2_r3_axis = "nul" -input_player2_l_x_plus = "nul" -input_player2_l_x_plus_btn = "nul" -input_player2_l_x_plus_axis = "nul" -input_player2_l_x_minus = "nul" -input_player2_l_x_minus_btn = "nul" -input_player2_l_x_minus_axis = "nul" -input_player2_l_y_plus = "nul" -input_player2_l_y_plus_btn = "nul" -input_player2_l_y_plus_axis = "nul" -input_player2_l_y_minus = "nul" -input_player2_l_y_minus_btn = "nul" -input_player2_l_y_minus_axis = "nul" -input_player2_r_x_plus = "nul" -input_player2_r_x_plus_btn = "nul" -input_player2_r_x_plus_axis = "nul" -input_player2_r_x_minus = "nul" -input_player2_r_x_minus_btn = "nul" -input_player2_r_x_minus_axis = "nul" -input_player2_r_y_plus = "nul" -input_player2_r_y_plus_btn = "nul" -input_player2_r_y_plus_axis = "nul" -input_player2_r_y_minus = "nul" -input_player2_r_y_minus_btn = "nul" -input_player2_r_y_minus_axis = "nul" -input_player2_turbo = "nul" -input_player2_turbo_btn = "nul" -input_player2_turbo_axis = "nul" -input_player3_b = "nul" -input_player3_b_btn = "nul" -input_player3_b_axis = "nul" -input_player3_y = "nul" -input_player3_y_btn = "nul" -input_player3_y_axis = "nul" -input_player3_select = "nul" -input_player3_select_btn = "nul" -input_player3_select_axis = "nul" -input_player3_start = "nul" -input_player3_start_btn = "nul" -input_player3_start_axis = "nul" -input_player3_up = "nul" -input_player3_up_btn = "nul" -input_player3_up_axis = "nul" -input_player3_down = "nul" -input_player3_down_btn = "nul" -input_player3_down_axis = "nul" -input_player3_left = "nul" -input_player3_left_btn = "nul" -input_player3_left_axis = "nul" -input_player3_right = "nul" -input_player3_right_btn = "nul" -input_player3_right_axis = "nul" -input_player3_a = "nul" -input_player3_a_btn = "nul" -input_player3_a_axis = "nul" -input_player3_x = "nul" -input_player3_x_btn = "nul" -input_player3_x_axis = "nul" -input_player3_l = "nul" -input_player3_l_btn = "nul" -input_player3_l_axis = "nul" -input_player3_r = "nul" -input_player3_r_btn = "nul" -input_player3_r_axis = "nul" -input_player3_l2 = "nul" -input_player3_l2_btn = "nul" -input_player3_l2_axis = "nul" -input_player3_r2 = "nul" -input_player3_r2_btn = "nul" -input_player3_r2_axis = "nul" -input_player3_l3 = "nul" -input_player3_l3_btn = "nul" -input_player3_l3_axis = "nul" -input_player3_r3 = "nul" -input_player3_r3_btn = "nul" -input_player3_r3_axis = "nul" -input_player3_l_x_plus = "nul" -input_player3_l_x_plus_btn = "nul" -input_player3_l_x_plus_axis = "nul" -input_player3_l_x_minus = "nul" -input_player3_l_x_minus_btn = "nul" -input_player3_l_x_minus_axis = "nul" -input_player3_l_y_plus = "nul" -input_player3_l_y_plus_btn = "nul" -input_player3_l_y_plus_axis = "nul" -input_player3_l_y_minus = "nul" -input_player3_l_y_minus_btn = "nul" -input_player3_l_y_minus_axis = "nul" -input_player3_r_x_plus = "nul" -input_player3_r_x_plus_btn = "nul" -input_player3_r_x_plus_axis = "nul" -input_player3_r_x_minus = "nul" -input_player3_r_x_minus_btn = "nul" -input_player3_r_x_minus_axis = "nul" -input_player3_r_y_plus = "nul" -input_player3_r_y_plus_btn = "nul" -input_player3_r_y_plus_axis = "nul" -input_player3_r_y_minus = "nul" -input_player3_r_y_minus_btn = "nul" -input_player3_r_y_minus_axis = "nul" -input_player3_turbo = "nul" -input_player3_turbo_btn = "nul" -input_player3_turbo_axis = "nul" -input_player4_b = "nul" -input_player4_b_btn = "nul" -input_player4_b_axis = "nul" -input_player4_y = "nul" -input_player4_y_btn = "nul" -input_player4_y_axis = "nul" -input_player4_select = "nul" -input_player4_select_btn = "nul" -input_player4_select_axis = "nul" -input_player4_start = "nul" -input_player4_start_btn = "nul" -input_player4_start_axis = "nul" -input_player4_up = "nul" -input_player4_up_btn = "nul" -input_player4_up_axis = "nul" -input_player4_down = "nul" -input_player4_down_btn = "nul" -input_player4_down_axis = "nul" -input_player4_left = "nul" -input_player4_left_btn = "nul" -input_player4_left_axis = "nul" -input_player4_right = "nul" -input_player4_right_btn = "nul" -input_player4_right_axis = "nul" -input_player4_a = "nul" -input_player4_a_btn = "nul" -input_player4_a_axis = "nul" -input_player4_x = "nul" -input_player4_x_btn = "nul" -input_player4_x_axis = "nul" -input_player4_l = "nul" -input_player4_l_btn = "nul" -input_player4_l_axis = "nul" -input_player4_r = "nul" -input_player4_r_btn = "nul" -input_player4_r_axis = "nul" -input_player4_l2 = "nul" -input_player4_l2_btn = "nul" -input_player4_l2_axis = "nul" -input_player4_r2 = "nul" -input_player4_r2_btn = "nul" -input_player4_r2_axis = "nul" -input_player4_l3 = "nul" -input_player4_l3_btn = "nul" -input_player4_l3_axis = "nul" -input_player4_r3 = "nul" -input_player4_r3_btn = "nul" -input_player4_r3_axis = "nul" -input_player4_l_x_plus = "nul" -input_player4_l_x_plus_btn = "nul" -input_player4_l_x_plus_axis = "nul" -input_player4_l_x_minus = "nul" -input_player4_l_x_minus_btn = "nul" -input_player4_l_x_minus_axis = "nul" -input_player4_l_y_plus = "nul" -input_player4_l_y_plus_btn = "nul" -input_player4_l_y_plus_axis = "nul" -input_player4_l_y_minus = "nul" -input_player4_l_y_minus_btn = "nul" -input_player4_l_y_minus_axis = "nul" -input_player4_r_x_plus = "nul" -input_player4_r_x_plus_btn = "nul" -input_player4_r_x_plus_axis = "nul" -input_player4_r_x_minus = "nul" -input_player4_r_x_minus_btn = "nul" -input_player4_r_x_minus_axis = "nul" -input_player4_r_y_plus = "nul" -input_player4_r_y_plus_btn = "nul" -input_player4_r_y_plus_axis = "nul" -input_player4_r_y_minus = "nul" -input_player4_r_y_minus_btn = "nul" -input_player4_r_y_minus_axis = "nul" -input_player4_turbo = "nul" -input_player4_turbo_btn = "nul" -input_player4_turbo_axis = "nul" -input_player5_b = "nul" -input_player5_b_btn = "nul" -input_player5_b_axis = "nul" -input_player5_y = "nul" -input_player5_y_btn = "nul" -input_player5_y_axis = "nul" -input_player5_select = "nul" -input_player5_select_btn = "nul" -input_player5_select_axis = "nul" -input_player5_start = "nul" -input_player5_start_btn = "nul" -input_player5_start_axis = "nul" -input_player5_up = "nul" -input_player5_up_btn = "nul" -input_player5_up_axis = "nul" -input_player5_down = "nul" -input_player5_down_btn = "nul" -input_player5_down_axis = "nul" -input_player5_left = "nul" -input_player5_left_btn = "nul" -input_player5_left_axis = "nul" -input_player5_right = "nul" -input_player5_right_btn = "nul" -input_player5_right_axis = "nul" -input_player5_a = "nul" -input_player5_a_btn = "nul" -input_player5_a_axis = "nul" -input_player5_x = "nul" -input_player5_x_btn = "nul" -input_player5_x_axis = "nul" -input_player5_l = "nul" -input_player5_l_btn = "nul" -input_player5_l_axis = "nul" -input_player5_r = "nul" -input_player5_r_btn = "nul" -input_player5_r_axis = "nul" -input_player5_l2 = "nul" -input_player5_l2_btn = "nul" -input_player5_l2_axis = "nul" -input_player5_r2 = "nul" -input_player5_r2_btn = "nul" -input_player5_r2_axis = "nul" -input_player5_l3 = "nul" -input_player5_l3_btn = "nul" -input_player5_l3_axis = "nul" -input_player5_r3 = "nul" -input_player5_r3_btn = "nul" -input_player5_r3_axis = "nul" -input_player5_l_x_plus = "nul" -input_player5_l_x_plus_btn = "nul" -input_player5_l_x_plus_axis = "nul" -input_player5_l_x_minus = "nul" -input_player5_l_x_minus_btn = "nul" -input_player5_l_x_minus_axis = "nul" -input_player5_l_y_plus = "nul" -input_player5_l_y_plus_btn = "nul" -input_player5_l_y_plus_axis = "nul" -input_player5_l_y_minus = "nul" -input_player5_l_y_minus_btn = "nul" -input_player5_l_y_minus_axis = "nul" -input_player5_r_x_plus = "nul" -input_player5_r_x_plus_btn = "nul" -input_player5_r_x_plus_axis = "nul" -input_player5_r_x_minus = "nul" -input_player5_r_x_minus_btn = "nul" -input_player5_r_x_minus_axis = "nul" -input_player5_r_y_plus = "nul" -input_player5_r_y_plus_btn = "nul" -input_player5_r_y_plus_axis = "nul" -input_player5_r_y_minus = "nul" -input_player5_r_y_minus_btn = "nul" -input_player5_r_y_minus_axis = "nul" -input_player5_turbo = "nul" -input_player5_turbo_btn = "nul" -input_player5_turbo_axis = "nul" -input_player6_b = "nul" -input_player6_b_btn = "nul" -input_player6_b_axis = "nul" -input_player6_y = "nul" -input_player6_y_btn = "nul" -input_player6_y_axis = "nul" -input_player6_select = "nul" -input_player6_select_btn = "nul" -input_player6_select_axis = "nul" -input_player6_start = "nul" -input_player6_start_btn = "nul" -input_player6_start_axis = "nul" -input_player6_up = "nul" -input_player6_up_btn = "nul" -input_player6_up_axis = "nul" -input_player6_down = "nul" -input_player6_down_btn = "nul" -input_player6_down_axis = "nul" -input_player6_left = "nul" -input_player6_left_btn = "nul" -input_player6_left_axis = "nul" -input_player6_right = "nul" -input_player6_right_btn = "nul" -input_player6_right_axis = "nul" -input_player6_a = "nul" -input_player6_a_btn = "nul" -input_player6_a_axis = "nul" -input_player6_x = "nul" -input_player6_x_btn = "nul" -input_player6_x_axis = "nul" -input_player6_l = "nul" -input_player6_l_btn = "nul" -input_player6_l_axis = "nul" -input_player6_r = "nul" -input_player6_r_btn = "nul" -input_player6_r_axis = "nul" -input_player6_l2 = "nul" -input_player6_l2_btn = "nul" -input_player6_l2_axis = "nul" -input_player6_r2 = "nul" -input_player6_r2_btn = "nul" -input_player6_r2_axis = "nul" -input_player6_l3 = "nul" -input_player6_l3_btn = "nul" -input_player6_l3_axis = "nul" -input_player6_r3 = "nul" -input_player6_r3_btn = "nul" -input_player6_r3_axis = "nul" -input_player6_l_x_plus = "nul" -input_player6_l_x_plus_btn = "nul" -input_player6_l_x_plus_axis = "nul" -input_player6_l_x_minus = "nul" -input_player6_l_x_minus_btn = "nul" -input_player6_l_x_minus_axis = "nul" -input_player6_l_y_plus = "nul" -input_player6_l_y_plus_btn = "nul" -input_player6_l_y_plus_axis = "nul" -input_player6_l_y_minus = "nul" -input_player6_l_y_minus_btn = "nul" -input_player6_l_y_minus_axis = "nul" -input_player6_r_x_plus = "nul" -input_player6_r_x_plus_btn = "nul" -input_player6_r_x_plus_axis = "nul" -input_player6_r_x_minus = "nul" -input_player6_r_x_minus_btn = "nul" -input_player6_r_x_minus_axis = "nul" -input_player6_r_y_plus = "nul" -input_player6_r_y_plus_btn = "nul" -input_player6_r_y_plus_axis = "nul" -input_player6_r_y_minus = "nul" -input_player6_r_y_minus_btn = "nul" -input_player6_r_y_minus_axis = "nul" -input_player6_turbo = "nul" -input_player6_turbo_btn = "nul" -input_player6_turbo_axis = "nul" -input_player7_b = "nul" -input_player7_b_btn = "nul" -input_player7_b_axis = "nul" -input_player7_y = "nul" -input_player7_y_btn = "nul" -input_player7_y_axis = "nul" -input_player7_select = "nul" -input_player7_select_btn = "nul" -input_player7_select_axis = "nul" -input_player7_start = "nul" -input_player7_start_btn = "nul" -input_player7_start_axis = "nul" -input_player7_up = "nul" -input_player7_up_btn = "nul" -input_player7_up_axis = "nul" -input_player7_down = "nul" -input_player7_down_btn = "nul" -input_player7_down_axis = "nul" -input_player7_left = "nul" -input_player7_left_btn = "nul" -input_player7_left_axis = "nul" -input_player7_right = "nul" -input_player7_right_btn = "nul" -input_player7_right_axis = "nul" -input_player7_a = "nul" -input_player7_a_btn = "nul" -input_player7_a_axis = "nul" -input_player7_x = "nul" -input_player7_x_btn = "nul" -input_player7_x_axis = "nul" -input_player7_l = "nul" -input_player7_l_btn = "nul" -input_player7_l_axis = "nul" -input_player7_r = "nul" -input_player7_r_btn = "nul" -input_player7_r_axis = "nul" -input_player7_l2 = "nul" -input_player7_l2_btn = "nul" -input_player7_l2_axis = "nul" -input_player7_r2 = "nul" -input_player7_r2_btn = "nul" -input_player7_r2_axis = "nul" -input_player7_l3 = "nul" -input_player7_l3_btn = "nul" -input_player7_l3_axis = "nul" -input_player7_r3 = "nul" -input_player7_r3_btn = "nul" -input_player7_r3_axis = "nul" -input_player7_l_x_plus = "nul" -input_player7_l_x_plus_btn = "nul" -input_player7_l_x_plus_axis = "nul" -input_player7_l_x_minus = "nul" -input_player7_l_x_minus_btn = "nul" -input_player7_l_x_minus_axis = "nul" -input_player7_l_y_plus = "nul" -input_player7_l_y_plus_btn = "nul" -input_player7_l_y_plus_axis = "nul" -input_player7_l_y_minus = "nul" -input_player7_l_y_minus_btn = "nul" -input_player7_l_y_minus_axis = "nul" -input_player7_r_x_plus = "nul" -input_player7_r_x_plus_btn = "nul" -input_player7_r_x_plus_axis = "nul" -input_player7_r_x_minus = "nul" -input_player7_r_x_minus_btn = "nul" -input_player7_r_x_minus_axis = "nul" -input_player7_r_y_plus = "nul" -input_player7_r_y_plus_btn = "nul" -input_player7_r_y_plus_axis = "nul" -input_player7_r_y_minus = "nul" -input_player7_r_y_minus_btn = "nul" -input_player7_r_y_minus_axis = "nul" -input_player7_turbo = "nul" -input_player7_turbo_btn = "nul" -input_player7_turbo_axis = "nul" -input_player8_b = "nul" -input_player8_b_btn = "nul" -input_player8_b_axis = "nul" -input_player8_y = "nul" -input_player8_y_btn = "nul" -input_player8_y_axis = "nul" -input_player8_select = "nul" -input_player8_select_btn = "nul" -input_player8_select_axis = "nul" -input_player8_start = "nul" -input_player8_start_btn = "nul" -input_player8_start_axis = "nul" -input_player8_up = "nul" -input_player8_up_btn = "nul" -input_player8_up_axis = "nul" -input_player8_down = "nul" -input_player8_down_btn = "nul" -input_player8_down_axis = "nul" -input_player8_left = "nul" -input_player8_left_btn = "nul" -input_player8_left_axis = "nul" -input_player8_right = "nul" -input_player8_right_btn = "nul" -input_player8_right_axis = "nul" -input_player8_a = "nul" -input_player8_a_btn = "nul" -input_player8_a_axis = "nul" -input_player8_x = "nul" -input_player8_x_btn = "nul" -input_player8_x_axis = "nul" -input_player8_l = "nul" -input_player8_l_btn = "nul" -input_player8_l_axis = "nul" -input_player8_r = "nul" -input_player8_r_btn = "nul" -input_player8_r_axis = "nul" -input_player8_l2 = "nul" -input_player8_l2_btn = "nul" -input_player8_l2_axis = "nul" -input_player8_r2 = "nul" -input_player8_r2_btn = "nul" -input_player8_r2_axis = "nul" -input_player8_l3 = "nul" -input_player8_l3_btn = "nul" -input_player8_l3_axis = "nul" -input_player8_r3 = "nul" -input_player8_r3_btn = "nul" -input_player8_r3_axis = "nul" -input_player8_l_x_plus = "nul" -input_player8_l_x_plus_btn = "nul" -input_player8_l_x_plus_axis = "nul" -input_player8_l_x_minus = "nul" -input_player8_l_x_minus_btn = "nul" -input_player8_l_x_minus_axis = "nul" -input_player8_l_y_plus = "nul" -input_player8_l_y_plus_btn = "nul" -input_player8_l_y_plus_axis = "nul" -input_player8_l_y_minus = "nul" -input_player8_l_y_minus_btn = "nul" -input_player8_l_y_minus_axis = "nul" -input_player8_r_x_plus = "nul" -input_player8_r_x_plus_btn = "nul" -input_player8_r_x_plus_axis = "nul" -input_player8_r_x_minus = "nul" -input_player8_r_x_minus_btn = "nul" -input_player8_r_x_minus_axis = "nul" -input_player8_r_y_plus = "nul" -input_player8_r_y_plus_btn = "nul" -input_player8_r_y_plus_axis = "nul" -input_player8_r_y_minus = "nul" -input_player8_r_y_minus_btn = "nul" -input_player8_r_y_minus_axis = "nul" -input_player8_turbo = "nul" -input_player8_turbo_btn = "nul" -input_player8_turbo_axis = "nul" -input_player9_b = "nul" -input_player9_b_btn = "nul" -input_player9_b_axis = "nul" -input_player9_y = "nul" -input_player9_y_btn = "nul" -input_player9_y_axis = "nul" -input_player9_select = "nul" -input_player9_select_btn = "nul" -input_player9_select_axis = "nul" -input_player9_start = "nul" -input_player9_start_btn = "nul" -input_player9_start_axis = "nul" -input_player9_up = "nul" -input_player9_up_btn = "nul" -input_player9_up_axis = "nul" -input_player9_down = "nul" -input_player9_down_btn = "nul" -input_player9_down_axis = "nul" -input_player9_left = "nul" -input_player9_left_btn = "nul" -input_player9_left_axis = "nul" -input_player9_right = "nul" -input_player9_right_btn = "nul" -input_player9_right_axis = "nul" -input_player9_a = "nul" -input_player9_a_btn = "nul" -input_player9_a_axis = "nul" -input_player9_x = "nul" -input_player9_x_btn = "nul" -input_player9_x_axis = "nul" -input_player9_l = "nul" -input_player9_l_btn = "nul" -input_player9_l_axis = "nul" -input_player9_r = "nul" -input_player9_r_btn = "nul" -input_player9_r_axis = "nul" -input_player9_l2 = "nul" -input_player9_l2_btn = "nul" -input_player9_l2_axis = "nul" -input_player9_r2 = "nul" -input_player9_r2_btn = "nul" -input_player9_r2_axis = "nul" -input_player9_l3 = "nul" -input_player9_l3_btn = "nul" -input_player9_l3_axis = "nul" -input_player9_r3 = "nul" -input_player9_r3_btn = "nul" -input_player9_r3_axis = "nul" -input_player9_l_x_plus = "nul" -input_player9_l_x_plus_btn = "nul" -input_player9_l_x_plus_axis = "nul" -input_player9_l_x_minus = "nul" -input_player9_l_x_minus_btn = "nul" -input_player9_l_x_minus_axis = "nul" -input_player9_l_y_plus = "nul" -input_player9_l_y_plus_btn = "nul" -input_player9_l_y_plus_axis = "nul" -input_player9_l_y_minus = "nul" -input_player9_l_y_minus_btn = "nul" -input_player9_l_y_minus_axis = "nul" -input_player9_r_x_plus = "nul" -input_player9_r_x_plus_btn = "nul" -input_player9_r_x_plus_axis = "nul" -input_player9_r_x_minus = "nul" -input_player9_r_x_minus_btn = "nul" -input_player9_r_x_minus_axis = "nul" -input_player9_r_y_plus = "nul" -input_player9_r_y_plus_btn = "nul" -input_player9_r_y_plus_axis = "nul" -input_player9_r_y_minus = "nul" -input_player9_r_y_minus_btn = "nul" -input_player9_r_y_minus_axis = "nul" -input_player9_turbo = "nul" -input_player9_turbo_btn = "nul" -input_player9_turbo_axis = "nul" -input_player10_b = "nul" -input_player10_b_btn = "nul" -input_player10_b_axis = "nul" -input_player10_y = "nul" -input_player10_y_btn = "nul" -input_player10_y_axis = "nul" -input_player10_select = "nul" -input_player10_select_btn = "nul" -input_player10_select_axis = "nul" -input_player10_start = "nul" -input_player10_start_btn = "nul" -input_player10_start_axis = "nul" -input_player10_up = "nul" -input_player10_up_btn = "nul" -input_player10_up_axis = "nul" -input_player10_down = "nul" -input_player10_down_btn = "nul" -input_player10_down_axis = "nul" -input_player10_left = "nul" -input_player10_left_btn = "nul" -input_player10_left_axis = "nul" -input_player10_right = "nul" -input_player10_right_btn = "nul" -input_player10_right_axis = "nul" -input_player10_a = "nul" -input_player10_a_btn = "nul" -input_player10_a_axis = "nul" -input_player10_x = "nul" -input_player10_x_btn = "nul" -input_player10_x_axis = "nul" -input_player10_l = "nul" -input_player10_l_btn = "nul" -input_player10_l_axis = "nul" -input_player10_r = "nul" -input_player10_r_btn = "nul" -input_player10_r_axis = "nul" -input_player10_l2 = "nul" -input_player10_l2_btn = "nul" -input_player10_l2_axis = "nul" -input_player10_r2 = "nul" -input_player10_r2_btn = "nul" -input_player10_r2_axis = "nul" -input_player10_l3 = "nul" -input_player10_l3_btn = "nul" -input_player10_l3_axis = "nul" -input_player10_r3 = "nul" -input_player10_r3_btn = "nul" -input_player10_r3_axis = "nul" -input_player10_l_x_plus = "nul" -input_player10_l_x_plus_btn = "nul" -input_player10_l_x_plus_axis = "nul" -input_player10_l_x_minus = "nul" -input_player10_l_x_minus_btn = "nul" -input_player10_l_x_minus_axis = "nul" -input_player10_l_y_plus = "nul" -input_player10_l_y_plus_btn = "nul" -input_player10_l_y_plus_axis = "nul" -input_player10_l_y_minus = "nul" -input_player10_l_y_minus_btn = "nul" -input_player10_l_y_minus_axis = "nul" -input_player10_r_x_plus = "nul" -input_player10_r_x_plus_btn = "nul" -input_player10_r_x_plus_axis = "nul" -input_player10_r_x_minus = "nul" -input_player10_r_x_minus_btn = "nul" -input_player10_r_x_minus_axis = "nul" -input_player10_r_y_plus = "nul" -input_player10_r_y_plus_btn = "nul" -input_player10_r_y_plus_axis = "nul" -input_player10_r_y_minus = "nul" -input_player10_r_y_minus_btn = "nul" -input_player10_r_y_minus_axis = "nul" -input_player10_turbo = "nul" -input_player10_turbo_btn = "nul" -input_player10_turbo_axis = "nul" -input_player11_b = "nul" -input_player11_b_btn = "nul" -input_player11_b_axis = "nul" -input_player11_y = "nul" -input_player11_y_btn = "nul" -input_player11_y_axis = "nul" -input_player11_select = "nul" -input_player11_select_btn = "nul" -input_player11_select_axis = "nul" -input_player11_start = "nul" -input_player11_start_btn = "nul" -input_player11_start_axis = "nul" -input_player11_up = "nul" -input_player11_up_btn = "nul" -input_player11_up_axis = "nul" -input_player11_down = "nul" -input_player11_down_btn = "nul" -input_player11_down_axis = "nul" -input_player11_left = "nul" -input_player11_left_btn = "nul" -input_player11_left_axis = "nul" -input_player11_right = "nul" -input_player11_right_btn = "nul" -input_player11_right_axis = "nul" -input_player11_a = "nul" -input_player11_a_btn = "nul" -input_player11_a_axis = "nul" -input_player11_x = "nul" -input_player11_x_btn = "nul" -input_player11_x_axis = "nul" -input_player11_l = "nul" -input_player11_l_btn = "nul" -input_player11_l_axis = "nul" -input_player11_r = "nul" -input_player11_r_btn = "nul" -input_player11_r_axis = "nul" -input_player11_l2 = "nul" -input_player11_l2_btn = "nul" -input_player11_l2_axis = "nul" -input_player11_r2 = "nul" -input_player11_r2_btn = "nul" -input_player11_r2_axis = "nul" -input_player11_l3 = "nul" -input_player11_l3_btn = "nul" -input_player11_l3_axis = "nul" -input_player11_r3 = "nul" -input_player11_r3_btn = "nul" -input_player11_r3_axis = "nul" -input_player11_l_x_plus = "nul" -input_player11_l_x_plus_btn = "nul" -input_player11_l_x_plus_axis = "nul" -input_player11_l_x_minus = "nul" -input_player11_l_x_minus_btn = "nul" -input_player11_l_x_minus_axis = "nul" -input_player11_l_y_plus = "nul" -input_player11_l_y_plus_btn = "nul" -input_player11_l_y_plus_axis = "nul" -input_player11_l_y_minus = "nul" -input_player11_l_y_minus_btn = "nul" -input_player11_l_y_minus_axis = "nul" -input_player11_r_x_plus = "nul" -input_player11_r_x_plus_btn = "nul" -input_player11_r_x_plus_axis = "nul" -input_player11_r_x_minus = "nul" -input_player11_r_x_minus_btn = "nul" -input_player11_r_x_minus_axis = "nul" -input_player11_r_y_plus = "nul" -input_player11_r_y_plus_btn = "nul" -input_player11_r_y_plus_axis = "nul" -input_player11_r_y_minus = "nul" -input_player11_r_y_minus_btn = "nul" -input_player11_r_y_minus_axis = "nul" -input_player11_turbo = "nul" -input_player11_turbo_btn = "nul" -input_player11_turbo_axis = "nul" -input_player12_b = "nul" -input_player12_b_btn = "nul" -input_player12_b_axis = "nul" -input_player12_y = "nul" -input_player12_y_btn = "nul" -input_player12_y_axis = "nul" -input_player12_select = "nul" -input_player12_select_btn = "nul" -input_player12_select_axis = "nul" -input_player12_start = "nul" -input_player12_start_btn = "nul" -input_player12_start_axis = "nul" -input_player12_up = "nul" -input_player12_up_btn = "nul" -input_player12_up_axis = "nul" -input_player12_down = "nul" -input_player12_down_btn = "nul" -input_player12_down_axis = "nul" -input_player12_left = "nul" -input_player12_left_btn = "nul" -input_player12_left_axis = "nul" -input_player12_right = "nul" -input_player12_right_btn = "nul" -input_player12_right_axis = "nul" -input_player12_a = "nul" -input_player12_a_btn = "nul" -input_player12_a_axis = "nul" -input_player12_x = "nul" -input_player12_x_btn = "nul" -input_player12_x_axis = "nul" -input_player12_l = "nul" -input_player12_l_btn = "nul" -input_player12_l_axis = "nul" -input_player12_r = "nul" -input_player12_r_btn = "nul" -input_player12_r_axis = "nul" -input_player12_l2 = "nul" -input_player12_l2_btn = "nul" -input_player12_l2_axis = "nul" -input_player12_r2 = "nul" -input_player12_r2_btn = "nul" -input_player12_r2_axis = "nul" -input_player12_l3 = "nul" -input_player12_l3_btn = "nul" -input_player12_l3_axis = "nul" -input_player12_r3 = "nul" -input_player12_r3_btn = "nul" -input_player12_r3_axis = "nul" -input_player12_l_x_plus = "nul" -input_player12_l_x_plus_btn = "nul" -input_player12_l_x_plus_axis = "nul" -input_player12_l_x_minus = "nul" -input_player12_l_x_minus_btn = "nul" -input_player12_l_x_minus_axis = "nul" -input_player12_l_y_plus = "nul" -input_player12_l_y_plus_btn = "nul" -input_player12_l_y_plus_axis = "nul" -input_player12_l_y_minus = "nul" -input_player12_l_y_minus_btn = "nul" -input_player12_l_y_minus_axis = "nul" -input_player12_r_x_plus = "nul" -input_player12_r_x_plus_btn = "nul" -input_player12_r_x_plus_axis = "nul" -input_player12_r_x_minus = "nul" -input_player12_r_x_minus_btn = "nul" -input_player12_r_x_minus_axis = "nul" -input_player12_r_y_plus = "nul" -input_player12_r_y_plus_btn = "nul" -input_player12_r_y_plus_axis = "nul" -input_player12_r_y_minus = "nul" -input_player12_r_y_minus_btn = "nul" -input_player12_r_y_minus_axis = "nul" -input_player12_turbo = "nul" -input_player12_turbo_btn = "nul" -input_player12_turbo_axis = "nul" -input_player13_b = "nul" -input_player13_b_btn = "nul" -input_player13_b_axis = "nul" -input_player13_y = "nul" -input_player13_y_btn = "nul" -input_player13_y_axis = "nul" -input_player13_select = "nul" -input_player13_select_btn = "nul" -input_player13_select_axis = "nul" -input_player13_start = "nul" -input_player13_start_btn = "nul" -input_player13_start_axis = "nul" -input_player13_up = "nul" -input_player13_up_btn = "nul" -input_player13_up_axis = "nul" -input_player13_down = "nul" -input_player13_down_btn = "nul" -input_player13_down_axis = "nul" -input_player13_left = "nul" -input_player13_left_btn = "nul" -input_player13_left_axis = "nul" -input_player13_right = "nul" -input_player13_right_btn = "nul" -input_player13_right_axis = "nul" -input_player13_a = "nul" -input_player13_a_btn = "nul" -input_player13_a_axis = "nul" -input_player13_x = "nul" -input_player13_x_btn = "nul" -input_player13_x_axis = "nul" -input_player13_l = "nul" -input_player13_l_btn = "nul" -input_player13_l_axis = "nul" -input_player13_r = "nul" -input_player13_r_btn = "nul" -input_player13_r_axis = "nul" -input_player13_l2 = "nul" -input_player13_l2_btn = "nul" -input_player13_l2_axis = "nul" -input_player13_r2 = "nul" -input_player13_r2_btn = "nul" -input_player13_r2_axis = "nul" -input_player13_l3 = "nul" -input_player13_l3_btn = "nul" -input_player13_l3_axis = "nul" -input_player13_r3 = "nul" -input_player13_r3_btn = "nul" -input_player13_r3_axis = "nul" -input_player13_l_x_plus = "nul" -input_player13_l_x_plus_btn = "nul" -input_player13_l_x_plus_axis = "nul" -input_player13_l_x_minus = "nul" -input_player13_l_x_minus_btn = "nul" -input_player13_l_x_minus_axis = "nul" -input_player13_l_y_plus = "nul" -input_player13_l_y_plus_btn = "nul" -input_player13_l_y_plus_axis = "nul" -input_player13_l_y_minus = "nul" -input_player13_l_y_minus_btn = "nul" -input_player13_l_y_minus_axis = "nul" -input_player13_r_x_plus = "nul" -input_player13_r_x_plus_btn = "nul" -input_player13_r_x_plus_axis = "nul" -input_player13_r_x_minus = "nul" -input_player13_r_x_minus_btn = "nul" -input_player13_r_x_minus_axis = "nul" -input_player13_r_y_plus = "nul" -input_player13_r_y_plus_btn = "nul" -input_player13_r_y_plus_axis = "nul" -input_player13_r_y_minus = "nul" -input_player13_r_y_minus_btn = "nul" -input_player13_r_y_minus_axis = "nul" -input_player13_turbo = "nul" -input_player13_turbo_btn = "nul" -input_player13_turbo_axis = "nul" -input_player14_b = "nul" -input_player14_b_btn = "nul" -input_player14_b_axis = "nul" -input_player14_y = "nul" -input_player14_y_btn = "nul" -input_player14_y_axis = "nul" -input_player14_select = "nul" -input_player14_select_btn = "nul" -input_player14_select_axis = "nul" -input_player14_start = "nul" -input_player14_start_btn = "nul" -input_player14_start_axis = "nul" -input_player14_up = "nul" -input_player14_up_btn = "nul" -input_player14_up_axis = "nul" -input_player14_down = "nul" -input_player14_down_btn = "nul" -input_player14_down_axis = "nul" -input_player14_left = "nul" -input_player14_left_btn = "nul" -input_player14_left_axis = "nul" -input_player14_right = "nul" -input_player14_right_btn = "nul" -input_player14_right_axis = "nul" -input_player14_a = "nul" -input_player14_a_btn = "nul" -input_player14_a_axis = "nul" -input_player14_x = "nul" -input_player14_x_btn = "nul" -input_player14_x_axis = "nul" -input_player14_l = "nul" -input_player14_l_btn = "nul" -input_player14_l_axis = "nul" -input_player14_r = "nul" -input_player14_r_btn = "nul" -input_player14_r_axis = "nul" -input_player14_l2 = "nul" -input_player14_l2_btn = "nul" -input_player14_l2_axis = "nul" -input_player14_r2 = "nul" -input_player14_r2_btn = "nul" -input_player14_r2_axis = "nul" -input_player14_l3 = "nul" -input_player14_l3_btn = "nul" -input_player14_l3_axis = "nul" -input_player14_r3 = "nul" -input_player14_r3_btn = "nul" -input_player14_r3_axis = "nul" -input_player14_l_x_plus = "nul" -input_player14_l_x_plus_btn = "nul" -input_player14_l_x_plus_axis = "nul" -input_player14_l_x_minus = "nul" -input_player14_l_x_minus_btn = "nul" -input_player14_l_x_minus_axis = "nul" -input_player14_l_y_plus = "nul" -input_player14_l_y_plus_btn = "nul" -input_player14_l_y_plus_axis = "nul" -input_player14_l_y_minus = "nul" -input_player14_l_y_minus_btn = "nul" -input_player14_l_y_minus_axis = "nul" -input_player14_r_x_plus = "nul" -input_player14_r_x_plus_btn = "nul" -input_player14_r_x_plus_axis = "nul" -input_player14_r_x_minus = "nul" -input_player14_r_x_minus_btn = "nul" -input_player14_r_x_minus_axis = "nul" -input_player14_r_y_plus = "nul" -input_player14_r_y_plus_btn = "nul" -input_player14_r_y_plus_axis = "nul" -input_player14_r_y_minus = "nul" -input_player14_r_y_minus_btn = "nul" -input_player14_r_y_minus_axis = "nul" -input_player14_turbo = "nul" -input_player14_turbo_btn = "nul" -input_player14_turbo_axis = "nul" -input_player15_b = "nul" -input_player15_b_btn = "nul" -input_player15_b_axis = "nul" -input_player15_y = "nul" -input_player15_y_btn = "nul" -input_player15_y_axis = "nul" -input_player15_select = "nul" -input_player15_select_btn = "nul" -input_player15_select_axis = "nul" -input_player15_start = "nul" -input_player15_start_btn = "nul" -input_player15_start_axis = "nul" -input_player15_up = "nul" -input_player15_up_btn = "nul" -input_player15_up_axis = "nul" -input_player15_down = "nul" -input_player15_down_btn = "nul" -input_player15_down_axis = "nul" -input_player15_left = "nul" -input_player15_left_btn = "nul" -input_player15_left_axis = "nul" -input_player15_right = "nul" -input_player15_right_btn = "nul" -input_player15_right_axis = "nul" -input_player15_a = "nul" -input_player15_a_btn = "nul" -input_player15_a_axis = "nul" -input_player15_x = "nul" -input_player15_x_btn = "nul" -input_player15_x_axis = "nul" -input_player15_l = "nul" -input_player15_l_btn = "nul" -input_player15_l_axis = "nul" -input_player15_r = "nul" -input_player15_r_btn = "nul" -input_player15_r_axis = "nul" -input_player15_l2 = "nul" -input_player15_l2_btn = "nul" -input_player15_l2_axis = "nul" -input_player15_r2 = "nul" -input_player15_r2_btn = "nul" -input_player15_r2_axis = "nul" -input_player15_l3 = "nul" -input_player15_l3_btn = "nul" -input_player15_l3_axis = "nul" -input_player15_r3 = "nul" -input_player15_r3_btn = "nul" -input_player15_r3_axis = "nul" -input_player15_l_x_plus = "nul" -input_player15_l_x_plus_btn = "nul" -input_player15_l_x_plus_axis = "nul" -input_player15_l_x_minus = "nul" -input_player15_l_x_minus_btn = "nul" -input_player15_l_x_minus_axis = "nul" -input_player15_l_y_plus = "nul" -input_player15_l_y_plus_btn = "nul" -input_player15_l_y_plus_axis = "nul" -input_player15_l_y_minus = "nul" -input_player15_l_y_minus_btn = "nul" -input_player15_l_y_minus_axis = "nul" -input_player15_r_x_plus = "nul" -input_player15_r_x_plus_btn = "nul" -input_player15_r_x_plus_axis = "nul" -input_player15_r_x_minus = "nul" -input_player15_r_x_minus_btn = "nul" -input_player15_r_x_minus_axis = "nul" -input_player15_r_y_plus = "nul" -input_player15_r_y_plus_btn = "nul" -input_player15_r_y_plus_axis = "nul" -input_player15_r_y_minus = "nul" -input_player15_r_y_minus_btn = "nul" -input_player15_r_y_minus_axis = "nul" -input_player15_turbo = "nul" -input_player15_turbo_btn = "nul" -input_player15_turbo_axis = "nul" -input_player16_b = "nul" -input_player16_b_btn = "nul" -input_player16_b_axis = "nul" -input_player16_y = "nul" -input_player16_y_btn = "nul" -input_player16_y_axis = "nul" -input_player16_select = "nul" -input_player16_select_btn = "nul" -input_player16_select_axis = "nul" -input_player16_start = "nul" -input_player16_start_btn = "nul" -input_player16_start_axis = "nul" -input_player16_up = "nul" -input_player16_up_btn = "nul" -input_player16_up_axis = "nul" -input_player16_down = "nul" -input_player16_down_btn = "nul" -input_player16_down_axis = "nul" -input_player16_left = "nul" -input_player16_left_btn = "nul" -input_player16_left_axis = "nul" -input_player16_right = "nul" -input_player16_right_btn = "nul" -input_player16_right_axis = "nul" -input_player16_a = "nul" -input_player16_a_btn = "nul" -input_player16_a_axis = "nul" -input_player16_x = "nul" -input_player16_x_btn = "nul" -input_player16_x_axis = "nul" -input_player16_l = "nul" -input_player16_l_btn = "nul" -input_player16_l_axis = "nul" -input_player16_r = "nul" -input_player16_r_btn = "nul" -input_player16_r_axis = "nul" -input_player16_l2 = "nul" -input_player16_l2_btn = "nul" -input_player16_l2_axis = "nul" -input_player16_r2 = "nul" -input_player16_r2_btn = "nul" -input_player16_r2_axis = "nul" -input_player16_l3 = "nul" -input_player16_l3_btn = "nul" -input_player16_l3_axis = "nul" -input_player16_r3 = "nul" -input_player16_r3_btn = "nul" -input_player16_r3_axis = "nul" -input_player16_l_x_plus = "nul" -input_player16_l_x_plus_btn = "nul" -input_player16_l_x_plus_axis = "nul" -input_player16_l_x_minus = "nul" -input_player16_l_x_minus_btn = "nul" -input_player16_l_x_minus_axis = "nul" -input_player16_l_y_plus = "nul" -input_player16_l_y_plus_btn = "nul" -input_player16_l_y_plus_axis = "nul" -input_player16_l_y_minus = "nul" -input_player16_l_y_minus_btn = "nul" -input_player16_l_y_minus_axis = "nul" -input_player16_r_x_plus = "nul" -input_player16_r_x_plus_btn = "nul" -input_player16_r_x_plus_axis = "nul" -input_player16_r_x_minus = "nul" -input_player16_r_x_minus_btn = "nul" -input_player16_r_x_minus_axis = "nul" -input_player16_r_y_plus = "nul" -input_player16_r_y_plus_btn = "nul" -input_player16_r_y_plus_axis = "nul" -input_player16_r_y_minus = "nul" -input_player16_r_y_minus_btn = "nul" -input_player16_r_y_minus_axis = "nul" -input_player16_turbo = "nul" -input_player16_turbo_btn = "nul" -input_player16_turbo_axis = "nul" -core_specific_config = "false" -game_specific_options = "false" -auto_overrides_enable = "true" -auto_remaps_enable = "true" -sort_savefiles_enable = "false" -sort_savestates_enable = "false" -libretro_log_level = "0" -log_verbosity = "false" -perfcnt_enable = "false" -keyboard_gamepad_enable = "true" -keyboard_gamepad_mapping_type = "1" -input_poll_type_behavior = "2" -core_set_supports_no_game_enable = "true" -menu_ok_btn = "8" -menu_cancel_btn = "0" -menu_search_btn = "9" -menu_info_btn = "2" -menu_default_btn = "3" -menu_scroll_down_btn = "11" -menu_scroll_up_btn = "10" -recording_output_directory = "" -recording_config_directory = "" -core_options_path = "" -video_shader = "" -bundle_assets_src_path = "" -bundle_assets_dst_path = "" -bundle_assets_dst_path_subdir = "" -menu_wallpaper = "" -video_filter = "" -audio_dsp_plugin = "" -input_overlay = "" -input_osk_overlay = "" -video_font_path = "" -content_history_dir = "" -playlist_names = "" -playlist_cores = "" -audio_device = "" -camera_device = "" -cheevos_username = "" -cheevos_password = "" -video_context_driver = "" -cache_directory = "" -resampler_directory = "" -xmb_font = "" -netplay_ip_address = "" -netplay_nickname = "" -input_keyboard_layout = "" +## Skeleton config file for RetroArch + +# Save all save files (*.srm) to this directory. This includes related files like .bsv, .rtc, .psrm, etc ... +# This will be overridden by explicit command line options. +# savefile_directory = + +# Save all save states (*.state) to this directory. +# This will be overridden by explicit command line options. +# savestate_directory = + +# If set to a directory, Content which is temporarily extracted +# will be extracted to this directory. +# cache_directory = + +# Save all input remapping files to this directory. +# input_remapping_directory = + +# Save all playlist files to this directory. +# playlist_directory = + +# If set to a directory, the content history playlist will be saved +# to this directory. +# content_history_dir = + +# Automatically saves a savestate at the end of RetroArch's lifetime. +# The path is $SRAM_PATH.auto. +# RetroArch will automatically load any savestate with this path on startup if savestate_auto_load is set. +# savestate_auto_save = false +# savestate_auto_load = true + +# Load libretro from a dynamic location for dynamically built RetroArch. +# This option is mandatory. + +# Path to a libretro implementation. +# libretro_path = "/path/to/libretro.so" + +# A directory for where to search for libretro core implementations. +# libretro_directory = + +# A directory for where to search for libretro core information. +# libretro_info_path = + +# Sets log level for libretro cores (GET_LOG_INTERFACE). +# If a log level issued by a libretro core is below libretro_log_level, it is ignored. +# DEBUG logs are always ignored unless verbose mode is activated (--verbose). +# DEBUG = 0, INFO = 1, WARN = 2, ERROR = 3. +# libretro_log_level = 0 + +# Enable or disable verbosity level of frontend. +# log_verbosity = false + +# If this option is enabled, every content file loaded in RetroArch will be +# automatically added to a history list. +# history_list_enable = true + +# Enable or disable RetroArch performance counters +# perfcnt_enable = false + +# Path to core options config file. +# This config file is used to expose core-specific options. +# It will be written to by RetroArch. +# A default path will be assigned if not set. +# core_options_path = + +# Path to content load history file. +# RetroArch keeps track of all content loaded in the menu and from CLI directly for convenient quick loading. +# A default path will be assigned if not set. +# content_history_path = + +# Number of entries that will be kept in content history file. +# content_history_size = 100 + +# Sets the "system" directory. +# Implementations can query for this directory to load BIOSes, system-specific configs, etc. +# system_directory = + +# Sets start directory for menu content browser. +# rgui_browser_directory = + +# Content directory. Interacts with RETRO_ENVIRONMENT_GET_CONTENT_DIRECTORY. +# Usually set by developers who bundle libretro/RetroArch apps to point to assets. +# content_directory = + +# Assets directory. This location is queried by default when menu interfaces try to look for +# loadable assets, etc. +# assets_directory = + +# Dynamic wallpapers directory. The place to store the wallpapers dynamically +# loaded by the menu depending on context. +# dynamic_wallpapers_directory = + +# Thumbnails directory. To store thumbnail PNG files. +# thumbnails_directory = + +# Sets start directory for menu config browser. +# rgui_config_directory = + +# Show startup screen in menu. +# Is automatically set to false when seen for the first time. +# This is only updated in config if config_save_on_exit is set to true, however. +# rgui_show_start_screen = true + +# Flushes config to disk on exit. Useful for menu as settings can be modified. +# Overwrites the config. #include's and comments are not preserved. +# config_save_on_exit = true + +# Load up a specific config file based on the core being used. +# core_specific_config = false + +#### Video + +# Video driver to use. "gl", "xvideo", "sdl" +# video_driver = "gl" + +# Which OpenGL context implementation to use. +# Possible ones for desktop are: glx, x-egl, kms-egl, sdl-gl, wgl. +# By default, tries to use first suitable driver. +# video_context_driver = + +# Windowed x resolution scale and y resolution scale +# (Real x res: base_size * xscale * aspect_ratio, real y res: base_size * yscale) +# video_scale = 3.0 + +# Fullscreen resolution. Resolution of 0 uses the resolution of the desktop. +# video_fullscreen_x = 0 +# video_fullscreen_y = 0 + +# Start in fullscreen. Can be changed at runtime. +# video_fullscreen = false + +# If fullscreen, prefer using a windowed fullscreen mode. +# video_windowed_fullscreen = true + +# Which monitor to prefer. 0 (default) means no particular monitor is preferred, 1 and up (1 being first monitor), +# suggests RetroArch to use that particular monitor. +# video_monitor_index = 0 + +# Forcibly disable composition. Only works in Windows Vista/7 for now. +# video_disable_composition = false + +# Video vsync. +# video_vsync = true + +# Forcibly disable sRGB FBO support. Some Intel OpenGL drivers on Windows +# have video problems with sRGB FBO support enabled. +# video_force_srgb_disable = false + +# Attempts to hard-synchronize CPU and GPU. Can reduce latency at cost of performance. +# video_hard_sync = false + +# Sets how many frames CPU can run ahead of GPU when using video_hard_sync. +# Maximum is 3. +# video_hard_sync_frames = 0 + +# Sets how many milliseconds to delay after VSync before running the core. +# Can reduce latency at cost of higher risk of stuttering. +# Maximum is 15. +# video_frame_delay = 0 + +# Inserts a black frame inbetween frames. +# Useful for 120 Hz monitors who want to play 60 Hz material with eliminated ghosting. +# video_refresh_rate should still be configured as if it is a 60 Hz monitor (divide refresh rate by 2). +# video_black_frame_insertion = false + +# Use threaded video driver. Using this might improve performance at possible cost of latency and more video stuttering. +# video_threaded = false + +# Use a shared context for HW rendered libretro cores. +# Avoids having to assume HW state changes inbetween frames. +# video_shared_context = false + +# Smoothens picture with bilinear filtering. Should be disabled if using pixel shaders. +# video_smooth = true + +# Forces rendering area to stay equal to content aspect ratio or as defined in video_aspect_ratio. +# video_force_aspect = true + +# Only scales video in integer steps. +# The base size depends on system-reported geometry and aspect ratio. +# If video_force_aspect is not set, X/Y will be integer scaled independently. +# video_scale_integer = false + +# A floating point value for video aspect ratio (width / height). +# If this is not set, aspect ratio is assumed to be automatic. +# Behavior then is defined by video_aspect_ratio_auto. +# video_aspect_ratio = + +# If this is true and video_aspect_ratio is not set, +# aspect ratio is decided by libretro implementation. +# If this is false, 1:1 PAR will always be assumed if video_aspect_ratio is not set. +# video_aspect_ratio_auto = false + +# Forces cropping of overscanned frames. +# Exact behavior of this option is implementation specific. +# video_crop_overscan = true + +# Path to shader. Shader can be either Cg, CGP (Cg preset) or GLSL, GLSLP (GLSL preset) +# video_shader = "/path/to/shader.{cg,cgp,glsl,glslp}" + +# Load video_shader on startup. +# Other shaders can still be loaded later in runtime. +# video_shader_enable = false + +# Defines a directory where shaders (Cg, CGP, GLSL) are kept for easy access. +# video_shader_dir = + +# CPU-based video filter. Path to a dynamic library. +# video_filter = + +# Defines a directory where CPU-based video filters are kept. +# video_filter_dir = + +# Path to a font used for rendering messages. This path must be defined to enable fonts. +# Do note that the _full_ path of the font is necessary! +# video_font_path = + +# Size of the font rendered. +# video_font_size = 32 + +# Enable usage of OSD messages. +# video_font_enable = true + +# Offset for where messages will be placed on screen. Values are in range 0.0 to 1.0 for both x and y values. +# [0.0, 0.0] maps to the lower left corner of the screen. +# video_message_pos_x = 0.05 +# video_message_pos_y = 0.05 + +# Color for message. The value is treated as a hexadecimal value. +# It is a regular RGB hex number, i.e. red is "ff0000". +# video_message_color = ffffff + +# Video refresh rate of your monitor. +# Used to calculate a suitable audio input rate. +# video_refresh_rate = 59.95 + +# Allows libretro cores to set rotation modes. +# Setting this to false will honor, but ignore this request. +# This is useful for vertically oriented content where one manually rotates the monitor. +# video_allow_rotate = true + +# Forces a certain rotation of the screen. +# The rotation is added to rotations which the libretro core sets (see video_allow_rotate). +# The angle is * 90 degrees counter-clockwise. +# video_rotation = 0 + +#### Audio + +# Enable audio. +# audio_enable = true + +# Mutes audio. +# audio_mute_enable = false + +# Audio output samplerate. +# audio_out_rate = 48000 + +# Audio resampler backend. Which audio resampler to use. +# Default will use "sinc". +# audio_resampler = + +# Audio driver backend. Depending on configuration possible candidates are: alsa, pulse, oss, jack, rsound, roar, openal, sdl, xaudio. +# audio_driver = + +# Override the default audio device the audio_driver uses. This is driver dependant. E.g. ALSA wants a PCM device, OSS wants a path (e.g. /dev/dsp), Jack wants portnames (e.g. system:playback1,system:playback_2), and so on ... +# audio_device = + +# Audio DSP plugin that processes audio before it's sent to the driver. Path to a dynamic library. +# audio_dsp_plugin = + +# Directory where DSP plugins are kept. +# audio_filter_dir = + +# Will sync (block) on audio. Recommended. +# audio_sync = true + +# Desired audio latency in milliseconds. Might not be honored if driver can't provide given latency. +# audio_latency = 64 + +# Enable audio rate control. +# audio_rate_control = true + +# Controls audio rate control delta. Defines how much input rate can be adjusted dynamically. +# Input rate = in_rate * (1.0 +/- audio_rate_control_delta) +# audio_rate_control_delta = 0.005 + +# Controls maximum audio timing skew. Defines the maximum change in input rate. +# Input rate = in_rate * (1.0 +/- max_timing_skew) +# audio_max_timing_skew = 0.05 + +# Audio volume. Volume is expressed in dB. +# 0 dB is normal volume. No gain will be applied. +# Gain can be controlled in runtime with input_volume_up/input_volume_down. +# audio_volume = 0.0 + +#### Overlay + +# Defines a directory where overlays are kept for easy access. +# overlay_directory = + +# Enable or disable the current overlay. +# input_overlay_enable = true + +# Hide the current overlay from appearing in menu screens. +# input_overlay_hide_in_menu = true + +# Path to input overlay +# input_overlay = + +# Overlay opacity +# input_overlay_opacity = 1.0 + +# Overlay scale +# input_overlay_scale = 1.0 + +#### OSK (Onscreen Keyboard) Overlay + +# Defines a directory where overlays are kept for easy access. +# osk_overlay_directory = + +# Enable OSK overlay. +# input_osk_overlay_enable = true + +# Path to OSK overlay +# input_osk_overlay = + +# OSK Overlay opacity +# input_osk_overlay_opacity = 1.0 + +# OSK Overlay scale +# input_osk_overlay_scale = 1.0 + +#### Input + +# Input driver. Depending on video driver, it might force a different input driver. +# input_driver = sdl + +# Input device driver. (Valid: linuxraw, sdl, dinput) +# input_joypad_driver = + +# Path to input remapping file. +# input_remapping_path = + +# If enabled, overrides the input binds with the remapped binds set for the current core. +# input_remap_binds_enable = true + +# Maximum amount of users supported by RetroArch. +# input_max_users = 16 + +# Keyboard layout for input driver if applicable (udev/evdev for now). +# Syntax is either just layout (e.g. "no"), or a layout and variant separated with colon ("no:nodeadkeys"). +# input_keyboard_layout = + +# Defines axis threshold. Possible values are [0.0, 1.0] +# input_axis_threshold = 0.5 + +# Enable input auto-detection. Will attempt to autoconfigure +# joypads, Plug-and-Play style. +# input_autodetect_enable = true + +# Show the input descriptors set by the core instead of the +# default ones. +# input_descriptor_label_show = true + +# Hide input descriptors that were not set by the core. +# input_descriptor_hide_unbound = false + +# Influence how input polling is done inside RetroArch. +# 0 : Early - Input polling is performed before call to retro_run. +# 1 : Normal - Input polling is performend when retro_input_poll is +# requested. +# 2 : Late - Input polling is performed on first call to retro_input_state +# per frame +# +# Setting it to 0 or 2 can result in less latency depending on +# your configuration. +# +# When netplay is enabled, the default polling behavior (1) will +# be used regardless of the value set here. +# input_poll_type_behavior = 1 + +# Directory for joypad autoconfigs. +# If a joypad is plugged in, that joypad will be autoconfigured if a config file +# corresponding to that joypad is present in joypad_autoconfig_dir. +# Input binds which are made explicit (input_playerN_*_btn/axis) will take priority over autoconfigs. +# Autoconfigs can be created with retroarch-joyconfig, manually, or with a frontend. +# Requires input_autodetect_enable to be enabled. +# joypad_autoconfig_dir = + +# Sets which libretro device is used for a user. +# Devices are indentified with a number. +# This is normally saved by the menu. +# Device IDs are found in libretro.h. +# These settings are overridden by explicit command-line arguments which refer to input devices. +# None: 0 +# Joypad (RetroPad): 1 +# Mouse: 2 +# Keyboard: 3 +# Generic Lightgun: 4 +# Joypad w/ Analog (RetroPad + Analog sticks): 5 +# Multitap (SNES specific): 257 +# Super Scope (SNES specific): 260 +# Justifier (SNES specific): 516 +# Justifiers (SNES specific): 772 + +# input_libretro_device_p1 = +# input_libretro_device_p2 = +# input_libretro_device_p3 = +# input_libretro_device_p4 = +# input_libretro_device_p5 = +# input_libretro_device_p6 = +# input_libretro_device_p7 = +# input_libretro_device_p8 = + +# Keyboard input. Will recognize letters ("a" to "z") and the following special keys (where "kp_" +# is for keypad keys): +# +# left, right, up, down, enter, kp_enter, tab, insert, del, end, home, +# rshift, shift, ctrl, alt, space, escape, add, subtract, kp_plus, kp_minus, +# f1, f2, f3, f4, f5, f6, f7, f8, f9, f10, f11, f12, +# num0, num1, num2, num3, num4, num5, num6, num7, num8, num9, pageup, pagedown, +# keypad0, keypad1, keypad2, keypad3, keypad4, keypad5, keypad6, keypad7, keypad8, keypad9, +# period, capslock, numlock, backspace, multiply, divide, print_screen, scroll_lock, +# tilde, backquote, pause, quote, comma, minus, slash, semicolon, equals, leftbracket, +# backslash, rightbracket, kp_period, kp_equals, rctrl, ralt +# +# Keyboard input, Joypad and Joyaxis will all obey the "nul" bind, which disables the bind completely, +# rather than relying on a default. +# input_player1_a = "x" +# input_player1_b = "z" +# input_player1_y = "a" +# input_player1_x = "s" +# input_player1_start = "enter" +# input_player1_select = "rshift" +# input_player1_l = "q" +# input_player1_r = "w" +# input_player1_left = "left" +# input_player1_right = "right" +# input_player1_up = "up" +# input_player1_down = "down" +# input_player1_l2 = +# input_player1_r2 = +# input_player1_l3 = +# input_player1_r3 = + +# Two analog sticks (DualShock-esque). +# Bound as usual, however, if a real analog axis is bound, +# it can be read as a true analog. +# Positive X axis is right, Positive Y axis is down. +# input_player1_l_x_plus = +# input_player1_l_x_minus = +# input_player1_l_y_plus = +# input_player1_l_y_minus = +# input_player1_r_x_plus = +# input_player1_r_x_minus = +# input_player1_r_y_plus = +# input_player1_r_y_minus = + +# If desired, it is possible to override which joypads are being used for user 1 through 8. +# First joypad available is 0. +# input_player1_joypad_index = 0 +# input_player2_joypad_index = 1 +# input_player3_joypad_index = 2 +# input_player4_joypad_index = 3 +# input_player5_joypad_index = 4 +# input_player6_joypad_index = 5 +# input_player7_joypad_index = 6 +# input_player8_joypad_index = 7 + +# Input device buttons. +# Figure these out by using RetroArch-Phoenix or retroarch-joyconfig. +# You can use joypad hats with hnxx, where n is the hat, and xx is a string representing direction. +# E.g. "h0up" +# input_player1_a_btn = +# input_player1_b_btn = +# input_player1_y_btn = +# input_player1_x_btn = +# input_player1_start_btn = +# input_player1_select_btn = +# input_player1_l_btn = +# input_player1_r_btn = +# input_player1_left_btn = +# input_player1_right_btn = +# input_player1_up_btn = +# input_player1_down_btn = +# input_player1_l2_btn = +# input_player1_r2_btn = +# input_player1_l3_btn = +# input_player1_r3_btn = + +# Menu buttons. +# menu_ok_btn = +# menu_cancel_btn = +# menu_search_btn = +# menu_info_btn = +# menu_default_btn = +# menu_scroll_down_btn = +# menu_scroll_up_btn = + +# Axis for RetroArch D-Pad. +# Needs to be either '+' or '-' in the first character signaling either positive or negative direction of the axis, then the axis number. +# Do note that every other input option has the corresponding _btn and _axis binds as well; they are omitted here for clarity. +# input_player1_left_axis = +# input_player1_right_axis = +# input_player1_up_axis = +# input_player1_down_axis = + +# Holding the turbo while pressing another button will let the button enter a turbo mode +# where the button state is modulated with a periodic signal. +# The modulation stops when the button itself (not turbo button) is released. +# input_player1_turbo = + +# Describes the period and how long of that period a turbo-enabled button should behave. +# Numbers are described in frames. +# input_turbo_period = 6 +# input_turbo_duty_cycle = 3 + +# This goes all the way to user 8 (*_player2_*, *_player3_*, etc), but omitted for clarity. +# All input binds have corresponding binds for keyboard (none), joykeys (_btn) and joyaxes (_axis) as well. + +# Toggles fullscreen. +# input_toggle_fullscreen = f + +# Saves state. +# input_save_state = f2 +# Loads state. +# input_load_state = f4 + +# State slots. With slot set to 0, save state name is *.state (or whatever defined on commandline). +# When slot is != 0, path will be $path%d, where %d is slot number. +# input_state_slot_increase = f7 +# input_state_slot_decrease = f6 + +# Toggles between fast-forwarding and normal speed. +# input_toggle_fast_forward = space + +# Hold for fast-forward. Releasing button disables fast-forward. +# input_hold_fast_forward = l + +# Key to exit RetroArch cleanly. +# Killing it in any hard way (SIGKILL, etc) will terminate RetroArch without saving RAM, etc. +# On Unix-likes, SIGINT/SIGTERM allows a clean deinitialization. +# input_exit_emulator = escape + + +# Applies next and previous shader in directory. +# input_shader_next = m +# input_shader_prev = n + +# Hold button down to rewind. Rewinding must be enabled. +# input_rewind = r + +# Toggle between recording and not. +# input_movie_record_toggle = o + +# Toggle between paused and non-paused state +# input_pause_toggle = p + +# Frame advance when content is paused +# input_frame_advance = k + +# Reset the content. +# input_reset = h + +# Cheats. +# input_cheat_index_plus = y +# input_cheat_index_minus = t +# input_cheat_toggle = u + +# Mute/unmute audio +# input_audio_mute = f9 + +# Take screenshot +# input_screenshot = f8 + +# Netplay flip users. +# input_netplay_flip_players = i + +# Hold for slowmotion. +# input_slowmotion = e + +# Enable other hotkeys. +# If this hotkey is bound to either keyboard, joybutton or joyaxis, +# all other hotkeys will be disabled unless this hotkey is also held at the same time. +# This is useful for RETRO_KEYBOARD centric implementations +# which query a large area of the keyboard, where it is not desirable +# that hotkeys get in the way. + +# Alternatively, all hotkeys for keyboard could be disabled by the user. +# input_enable_hotkey_btn = + +# Increases audio volume. +# input_volume_up = kp_plus +# Decreases audio volume. +# input_volume_down = kp_minus + +# Toggles to next overlay. Wraps around. +# input_overlay_next = + +# Toggles eject for disks. Used for multiple-disk content. +# input_disk_eject_toggle = + +# Cycles through disk images. Use after ejecting. +# Complete by toggling eject again. +# input_disk_next = + +# Toggles menu. +# input_menu_toggle = f1 + +# RetroPad button combination to toggle menu +# 0 = none, 1 = L + R + Y + D-Pad Down, 2 = L3 + R3 +# input_menu_toggle_gamepad_combo = 0 + +# Toggles mouse grab. When mouse is grabbed, RetroArch hides the mouse, +# and keeps the mouse pointer inside the window to allow relative mouse input +# to work better. +# input_grab_mouse_toggle = f11 + +#### Menu + +# Menu driver to use. "rgui", "lakka", etc. +# menu_driver = "rgui" + +# If enabled, the libretro core will keep running in the background when we +# are in the menu. +# menu_pause_libretro = false + +# Enable mouse input inside the menu. +# menu_mouse_enable = false + +# Enable touch input inside the menu. +# menu_pointer_enable = false + +# Shows current date and/or time inside menu. +# menu_timedate_enable = true + +# Shows current core inside menu. +# menu_core_enable = true + +# Path to a .png image to set as menu wallpaper. +# menu_wallpaper = + +# Dynamically load a new wallpaper depending on context. +# menu_dynamic_wallpaper_enable = false + +# Type of thumbnail to display. 0 = none, 1 = snaps, 2 = titles, 3 = boxarts +# menu_thumbnails = 0 + +# Wrap-around toe beginning and/or end if boundary of list reached horizontally +# menu_navigation_wraparound_horizontal_enable = false + +# Wrap-around to beginning and/or end if boundary of list reached vertically +# menu_navigation_wraparound_vertical_enable = false + +# Filter files being show in 'Load Content' by supported extensions +# menu_navigation_browser_filter_supported_extensions_enable = true + +# Collapse subgroup settings into main group to create one big listing of settings +# per category. +# menu_collapse_subgroups_enable = false + +#### UI + +# Suspends the screensaver if set to true. Is a hint that does not necessarily have to be honored +# by video driver. +# suspend_screensaver_enable = true + +# Start UI companion driver's interface on boot (if available). +# ui_companion_start_on_boot = true + +#### Camera + +# Override the default camera device the camera driver uses. This is driver dependant. +# camera_device = + +# Override the default privacy permission for cores that want to access camera services. Is "false" by default. +# camera_allow = false + +#### Location + +# Override the default privacy permission for cores that want to access location services. Is "false" by default. +# location_allow = false + +#### Core Updater + +# URL to core update directory on buildbot. +# core_updater_buildbot_url = "http://buildbot.libretro.com" + +# URL to assets update directory on buildbot. +# core_updater_buildbot_assets_url = "http://buildbot.libretro.com/assets/" + +# Automatically extract archives that the cores are contained in to the libretro cores directory. +# core_updater_auto_extract_archive = true + +#### Network + +# When being client over netplay, use keybinds for user 1. +# netplay_client_swap_input = false + +# The username of the person running RetroArch. This will be used for playing online, for instance. +# netplay_nickname = + +# The amount of delay frames to use for netplay. Increasing this value will increase +# performance, but introduce more latency. +# netplay_delay_frames = 0 + +# Netplay mode for the current user. +# false is Server, true is Client. +# netplay_mode = false + +# Enable or disable spectator mode for the user during netplay. +# netplay_spectator_mode_enable = false + +# The IP Address of the host to connect to. +# netplay_ip_address = + +# The port of the host IP Address. Can be either a TCP or an UDP port. +# netplay_ip_port = 55435 + +#### Misc + +# Enable rewinding. This will take a performance hit when playing, so it is disabled by default. +# rewind_enable = false + +# Rewinding buffer size in megabytes. Bigger rewinding buffer means you can rewind longer. +# The buffer should be approx. 20MB per minute of buffer time. +# rewind_buffer_size = 20 + +# Rewind granularity. When rewinding defined number of frames, you can rewind several frames at a time, increasing the rewinding speed. +# rewind_granularity = 1 + +# Pause gameplay when window focus is lost. +# pause_nonactive = true + +# Autosaves the non-volatile SRAM at a regular interval. This is disabled by default unless set otherwise. +# The interval is measured in seconds. A value of 0 disables autosave. +# autosave_interval = + +# Path to content database directory. +# content_database_path = + +# Path to cheat database directory. +# cheat_database_path = + +# Path to XML cheat config, a file which keeps track of which +# cheat settings are used for individual games. +# If the file does not exist, it will be created. +# cheat_settings_path = + +# Directory to dump screenshots to. +# screenshot_directory = + +# Records video after CPU video filter. +# video_post_filter_record = false + +# Records output of GPU shaded material if available. +# video_gpu_record = false + +# Screenshots output of GPU shaded material if available. +# video_gpu_screenshot = true + +# Block SRAM from being overwritten when loading save states. +# Might potentially lead to buggy games. +# block_sram_overwrite = false + +# When saving a savestate, save state index is automatically increased before +# it is saved. +# Also, when loading content, the index will be set to the highest existing index. +# There is no upper bound on the index. +# savestate_auto_index = false + +# Slowmotion ratio. When slowmotion, content will slow down by factor. +# slowmotion_ratio = 3.0 + +# The maximum rate at which content will be run when using fast forward. (E.g. 5.0 for 60 fps content => 300 fps cap). +# RetroArch will go to sleep to ensure that the maximum rate will not be exceeded. +# Do not rely on this cap to be perfectly accurate. +# If this is set at 0, then fastforward ratio is unlimited (no FPS cap) +# fastforward_ratio = 0.0 + +# Enable stdin/network command interface. +# network_cmd_enable = false +# network_cmd_port = 55355 +# stdin_cmd_enable = false From 1a9206ea51bc1f00a09b0899983be8809f157bbc Mon Sep 17 00:00:00 2001 From: radius Date: Sat, 30 Apr 2016 16:39:29 -0500 Subject: [PATCH 013/498] android platform driver refinement --- frontend/drivers/platform_linux.c | 105 +++++++++++++++--------------- 1 file changed, 54 insertions(+), 51 deletions(-) diff --git a/frontend/drivers/platform_linux.c b/frontend/drivers/platform_linux.c index 6e508d4847..26cead732f 100644 --- a/frontend/drivers/platform_linux.c +++ b/frontend/drivers/platform_linux.c @@ -56,7 +56,7 @@ * * See http://www.kernel.org/doc/Documentation/cputopology.txt * - * For now, we don't expect more than 32 cores on mobile devices, + * For now, we don't expect more than 32 cores on mobile devices, * so keep everything simple. */ typedef struct @@ -100,7 +100,7 @@ static char *extract_cpuinfo_field(char* buffer, int fieldlen = strlen(field); char* bufend = buffer + length; char* result = NULL; - /* Look for first field occurrence, + /* Look for first field occurrence, * and ensures it starts the line. */ const char *p = buffer; @@ -140,7 +140,7 @@ static char *extract_cpuinfo_field(char* buffer, return result; } -/* Checks that a space-separated list of items +/* Checks that a space-separated list of items * contains one given 'item'. * Returns 1 if found, 0 otherwise. */ @@ -484,19 +484,22 @@ error: } #ifdef ANDROID -#define SDCARD_ROOT_WRITABLE 1 -#define SDCARD_EXT_DIR_WRITABLE 2 -#define SDCARD_NOT_WRITABLE 3 +/* Internal SDCARD writable */ +#define INT_SD_WRITABLE 1 +/* Internal SDCARD not writable but the private app dir is */ +#define INT_SD_APPDIR_WRITABLE 2 +/* Internal SDCARD not writable at all */ +#define INT_SD_NOT_WRITABLE 3 struct android_app *g_android; static pthread_key_t thread_key; char screenshot_dir[PATH_MAX_LENGTH]; char downloads_dir[PATH_MAX_LENGTH]; -char apk_path[PATH_MAX_LENGTH]; -char sdcard_dir[PATH_MAX_LENGTH]; +char apk_dir[PATH_MAX_LENGTH]; +char int_sd_dir[PATH_MAX_LENGTH]; char app_dir[PATH_MAX_LENGTH]; -char ext_dir[PATH_MAX_LENGTH]; +char int_sd_app_dir[PATH_MAX_LENGTH]; /* forward declaration */ @@ -753,7 +756,7 @@ static struct android_app* android_app_create(ANativeActivity* activity, void* savedState, size_t savedStateSize) { int msgpipe[2]; - struct android_app *android_app = + struct android_app *android_app = (struct android_app*)calloc(1, sizeof(*android_app)); if (!android_app) @@ -1671,15 +1674,15 @@ static void frontend_linux_get_env(int *argc, { const char *argv = (*env)->GetStringUTFChars(env, jstr, 0); - *sdcard_dir = '\0'; + *int_sd_dir = '\0'; if (argv && *argv) - strlcpy(sdcard_dir, argv, sizeof(sdcard_dir)); + strlcpy(int_sd_dir, argv, sizeof(int_sd_dir)); (*env)->ReleaseStringUTFChars(env, jstr, argv); - if (*sdcard_dir) + if (*int_sd_dir) { - RARCH_LOG("External storage location [%s]\n", sdcard_dir); + RARCH_LOG("External storage location [%s]\n", int_sd_dir); /* TODO base dir handler */ } } @@ -1733,15 +1736,15 @@ static void frontend_linux_get_env(int *argc, { const char *argv = (*env)->GetStringUTFChars(env, jstr, 0); - *apk_path = '\0'; + *apk_dir = '\0'; if (argv && *argv) - strlcpy(apk_path, argv, sizeof(apk_path)); + strlcpy(apk_dir, argv, sizeof(apk_dir)); (*env)->ReleaseStringUTFChars(env, jstr, argv); - if (*apk_path) + if (*apk_dir) { - RARCH_LOG("APK location [%s].\n", apk_path); + RARCH_LOG("APK location [%s].\n", apk_dir); } } @@ -1752,15 +1755,15 @@ static void frontend_linux_get_env(int *argc, { const char *argv = (*env)->GetStringUTFChars(env, jstr, 0); - *ext_dir = '\0'; + *int_sd_app_dir = '\0'; if (argv && *argv) - strlcpy(ext_dir, argv, sizeof(ext_dir)); + strlcpy(int_sd_app_dir, argv, sizeof(int_sd_app_dir)); (*env)->ReleaseStringUTFChars(env, jstr, argv); - if (*ext_dir) + if (*int_sd_app_dir) { - RARCH_LOG("External files location [%s]\n", ext_dir); + RARCH_LOG("External files location [%s]\n", int_sd_app_dir); } } @@ -1779,20 +1782,20 @@ static void frontend_linux_get_env(int *argc, strlcpy(app_dir, argv, sizeof(app_dir)); (*env)->ReleaseStringUTFChars(env, jstr, argv); - //set paths depending on the ability to write to sdcard_dir + //set paths depending on the ability to write to int_sd_dir - if(*sdcard_dir) + if(*int_sd_dir) { - if(test_permissions(sdcard_dir)) - perms = SDCARD_ROOT_WRITABLE; + if(test_permissions(int_sd_dir)) + perms = INT_SD_WRITABLE; } - else if(*ext_dir) + else if(*int_sd_app_dir) { - if(test_permissions(ext_dir)) - perms = SDCARD_EXT_DIR_WRITABLE; + if(test_permissions(int_sd_app_dir)) + perms = INT_SD_APPDIR_WRITABLE; } else - perms = SDCARD_NOT_WRITABLE; + perms = INT_SD_NOT_WRITABLE; RARCH_LOG("SD permissions: %d",perms); @@ -1861,34 +1864,34 @@ static void frontend_linux_get_env(int *argc, switch (perms) { - case SDCARD_EXT_DIR_WRITABLE: + case INT_SD_APPDIR_WRITABLE: fill_pathname_join(g_defaults.dir.sram, - ext_dir, "saves", sizeof(g_defaults.dir.sram)); + int_sd_app_dir, "saves", sizeof(g_defaults.dir.sram)); path_mkdir(g_defaults.dir.sram); fill_pathname_join(g_defaults.dir.savestate, - ext_dir, "states", sizeof(g_defaults.dir.savestate)); + int_sd_app_dir, "states", sizeof(g_defaults.dir.savestate)); path_mkdir(g_defaults.dir.savestate); fill_pathname_join(g_defaults.dir.system, - ext_dir, "system", sizeof(g_defaults.dir.system)); + int_sd_app_dir, "system", sizeof(g_defaults.dir.system)); path_mkdir(g_defaults.dir.system); fill_pathname_join(g_defaults.dir.menu_config, - ext_dir, "config", sizeof(g_defaults.dir.menu_config)); + int_sd_app_dir, "config", sizeof(g_defaults.dir.menu_config)); path_mkdir(g_defaults.dir.menu_config); fill_pathname_join(g_defaults.dir.remap, - ext_dir, "config/remap", sizeof(g_defaults.dir.remap)); + int_sd_app_dir, "config/remap", sizeof(g_defaults.dir.remap)); path_mkdir(g_defaults.dir.remap); fill_pathname_join(g_defaults.dir.thumbnails, - ext_dir, "thumbnails", sizeof(g_defaults.dir.thumbnails)); + int_sd_app_dir, "thumbnails", sizeof(g_defaults.dir.thumbnails)); path_mkdir(g_defaults.dir.thumbnails); fill_pathname_join(g_defaults.dir.playlist, - ext_dir, "playlists", sizeof(g_defaults.dir.playlist)); + int_sd_app_dir, "playlists", sizeof(g_defaults.dir.playlist)); path_mkdir(g_defaults.dir.playlist); fill_pathname_join(g_defaults.dir.cheats, - ext_dir, "cheats", sizeof(g_defaults.dir.cheats)); + int_sd_app_dir, "cheats", sizeof(g_defaults.dir.cheats)); path_mkdir(g_defaults.dir.cheats); break; - case SDCARD_NOT_WRITABLE: + case INT_SD_NOT_WRITABLE: fill_pathname_join(g_defaults.dir.sram, app_dir, "saves", sizeof(g_defaults.dir.sram)); path_mkdir(g_defaults.dir.sram); @@ -1915,21 +1918,21 @@ static void frontend_linux_get_env(int *argc, app_dir, "cheats", sizeof(g_defaults.dir.cheats)); path_mkdir(g_defaults.dir.cheats); break; - case SDCARD_ROOT_WRITABLE: + case INT_SD_WRITABLE: fill_pathname_join(g_defaults.dir.menu_config, - sdcard_dir, "config", sizeof(g_defaults.dir.menu_config)); + int_sd_dir, "RetroArch/config", sizeof(g_defaults.dir.menu_config)); path_mkdir(g_defaults.dir.menu_config); fill_pathname_join(g_defaults.dir.remap, - sdcard_dir, "config/remap", sizeof(g_defaults.dir.remap)); + int_sd_dir, "RetroArch/config/remap", sizeof(g_defaults.dir.remap)); path_mkdir(g_defaults.dir.remap); fill_pathname_join(g_defaults.dir.thumbnails, - sdcard_dir, "thumbnails", sizeof(g_defaults.dir.thumbnails)); + int_sd_dir, "RetroArch/thumbnails", sizeof(g_defaults.dir.thumbnails)); path_mkdir(g_defaults.dir.thumbnails); fill_pathname_join(g_defaults.dir.playlist, - sdcard_dir, "playlists", sizeof(g_defaults.dir.playlist)); + int_sd_dir, "RetroArch/playlists", sizeof(g_defaults.dir.playlist)); path_mkdir(g_defaults.dir.playlist); fill_pathname_join(g_defaults.dir.cheats, - sdcard_dir, "cheats", sizeof(g_defaults.dir.cheats)); + int_sd_dir, "RetroArch/cheats", sizeof(g_defaults.dir.cheats)); path_mkdir(g_defaults.dir.cheats); default: break; @@ -1950,15 +1953,15 @@ static void frontend_linux_get_env(int *argc, /* create save and system directories in the internal sd too */ fill_pathname_join(buf, - ext_dir, "saves", sizeof(buf)); + int_sd_app_dir, "saves", sizeof(buf)); path_mkdir(buf); fill_pathname_join(buf, - ext_dir, "states", sizeof(buf)); + int_sd_app_dir, "states", sizeof(buf)); path_mkdir(buf); fill_pathname_join(buf, - ext_dir, "system", sizeof(buf)); + int_sd_app_dir, "system", sizeof(buf)); path_mkdir(buf); RARCH_LOG("Default savefile folder: [%s]", g_defaults.dir.sram); @@ -2170,9 +2173,9 @@ static int frontend_android_parse_drive_list(void *data) menu_entries_add(list, app_dir, "Application Dir", MENU_FILE_DIRECTORY, 0, 0); menu_entries_add(list, - ext_dir, "External Application Dir", MENU_FILE_DIRECTORY, 0, 0); + int_sd_app_dir, "External Application Dir", MENU_FILE_DIRECTORY, 0, 0); menu_entries_add(list, - sdcard_dir, "Internal Memory", MENU_FILE_DIRECTORY, 0, 0); + int_sd_dir, "Internal Memory", MENU_FILE_DIRECTORY, 0, 0); menu_entries_add(list, "/", "", MENU_FILE_DIRECTORY, 0, 0); From 6d720ff3374c5340b4ec43ff064dba28c4b13fdb Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 1 May 2016 04:40:20 +0200 Subject: [PATCH 014/498] (XMB/Shader pipeline) Rename some variables and enable ribbon by default --- config.def.h | 4 ++-- configuration.c | 6 +++--- configuration.h | 2 +- menu/cbs/menu_cbs_get_value.c | 2 +- menu/drivers/xmb.c | 4 ++-- menu/menu_setting.c | 4 ++-- 6 files changed, 11 insertions(+), 11 deletions(-) diff --git a/config.def.h b/config.def.h index 1b3953f4d6..00995cc75a 100644 --- a/config.def.h +++ b/config.def.h @@ -516,9 +516,9 @@ static unsigned xmb_gradient = 0; static bool xmb_shadows_enable = false; #if defined(HAVE_OPENGLES2) -static unsigned xmb_ribbon_enable = 1; +static unsigned menu_shader_pipeline = 1; #else -static unsigned xmb_ribbon_enable = 0; +static unsigned menu_shader_pipeline = 2; #endif static bool show_advanced_settings = true; diff --git a/configuration.c b/configuration.c index 29db74cc39..c1d9188c94 100644 --- a/configuration.c +++ b/configuration.c @@ -487,7 +487,7 @@ static void config_set_defaults(void) settings->menu.xmb_theme = xmb_theme; settings->menu.xmb_gradient = xmb_gradient; settings->menu.xmb_shadows_enable = xmb_shadows_enable; - settings->menu.xmb_ribbon_enable = xmb_ribbon_enable; + settings->menu.shader_pipeline = menu_shader_pipeline; settings->menu.xmb_font[0] = '\0'; settings->menu.throttle_framerate = true; settings->menu.linear_filter = true; @@ -1551,7 +1551,7 @@ static bool config_load_file(const char *path, bool set_defaults) CONFIG_GET_INT_BASE(conf, settings, menu.xmb_theme, "xmb_theme"); CONFIG_GET_INT_BASE(conf, settings, menu.xmb_gradient, "xmb_gradient"); CONFIG_GET_BOOL_BASE(conf, settings, menu.xmb_shadows_enable, "xmb_shadows_enable"); - CONFIG_GET_INT_BASE(conf, settings, menu.xmb_ribbon_enable, "xmb_ribbon_enable"); + CONFIG_GET_INT_BASE(conf, settings, menu.shader_pipeline, "menu_shader_pipeline"); config_get_path(conf, "xmb_font", settings->menu.xmb_font, sizeof(settings->menu.xmb_font)); #endif config_get_array(conf, "video_context_driver", settings->video.context_driver, sizeof(settings->video.context_driver)); @@ -2819,7 +2819,7 @@ bool config_save_file(const char *path) config_set_int(conf, "xmb_theme", settings->menu.xmb_theme); config_set_int(conf, "xmb_gradient", settings->menu.xmb_gradient); config_set_bool(conf, "xmb_shadows_enable", settings->menu.xmb_shadows_enable); - config_set_int(conf, "xmb_ribbon_enable", settings->menu.xmb_ribbon_enable); + config_set_int(conf, "menu_shader_pipeline", settings->menu.shader_pipeline); config_set_path(conf, "xmb_font", !string_is_empty(settings->menu.xmb_font) ? settings->menu.xmb_font : ""); config_set_bool(conf, "rgui_show_start_screen", diff --git a/configuration.h b/configuration.h index 012f86378a..84274e2a2f 100644 --- a/configuration.h +++ b/configuration.h @@ -163,7 +163,7 @@ typedef struct settings unsigned xmb_theme; unsigned xmb_gradient; bool xmb_shadows_enable; - unsigned xmb_ribbon_enable; + unsigned shader_pipeline; char xmb_font[PATH_MAX_LENGTH]; bool throttle_framerate; bool linear_filter; diff --git a/menu/cbs/menu_cbs_get_value.c b/menu/cbs/menu_cbs_get_value.c index 1a17059a67..6d0a66442a 100644 --- a/menu/cbs/menu_cbs_get_value.c +++ b/menu/cbs/menu_cbs_get_value.c @@ -180,7 +180,7 @@ static void menu_action_setting_disp_set_label_pipeline( *s = '\0'; *w = 19; - switch (settings->menu.xmb_ribbon_enable) + switch (settings->menu.shader_pipeline) { case 0: snprintf(s, len, "%s", "OFF"); diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 9470482ecf..fad8c74efd 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -1947,7 +1947,7 @@ static void xmb_draw_bg( menu_display_ctl(MENU_DISPLAY_CTL_BLEND_BEGIN, NULL); menu_display_ctl(MENU_DISPLAY_CTL_SET_VIEWPORT, NULL); - if (settings->menu.xmb_ribbon_enable > 0) + if (settings->menu.shader_pipeline > 0) { draw.color = xmb_gradient_ident(); @@ -1957,7 +1957,7 @@ static void xmb_draw_bg( menu_display_set_alpha(draw.color, coord_white[3]); draw.pipeline.id = VIDEO_SHADER_MENU_SEC; - if (settings->menu.xmb_ribbon_enable == 2) + if (settings->menu.shader_pipeline == 2) draw.pipeline.id = VIDEO_SHADER_MENU; menu_display_ctl(MENU_DISPLAY_CTL_DRAW_GRADIENT, &draw); diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 81511abeb0..ee7e0ab8b7 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -5970,10 +5970,10 @@ static bool setting_append_list( CONFIG_UINT( list, list_info, - &settings->menu.xmb_ribbon_enable, + &settings->menu.shader_pipeline, menu_hash_to_str(MENU_LABEL_XMB_RIBBON_ENABLE), menu_hash_to_str(MENU_LABEL_VALUE_XMB_RIBBON_ENABLE), - xmb_ribbon_enable, + menu_shader_pipeline, &group_info, &subgroup_info, parent_group, From 729b1bf64ba46599ba32bf348781bc7a5cd6d621 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 1 May 2016 04:46:16 +0200 Subject: [PATCH 015/498] (Menu) Rename more xmb_ variables --- config.def.h | 7 ++++--- configuration.c | 6 +++--- configuration.h | 2 +- menu/cbs/menu_cbs_get_value.c | 2 +- menu/drivers/xmb.c | 2 +- menu/menu_setting.c | 4 ++-- 6 files changed, 12 insertions(+), 11 deletions(-) diff --git a/config.def.h b/config.def.h index 00995cc75a..7a4bf13379 100644 --- a/config.def.h +++ b/config.def.h @@ -511,9 +511,10 @@ static bool default_block_config_read = true; static unsigned xmb_scale_factor = 100; static unsigned xmb_alpha_factor = 75; -static unsigned xmb_theme = 0; -static unsigned xmb_gradient = 0; -static bool xmb_shadows_enable = false; +static unsigned xmb_theme = 0; +static bool xmb_shadows_enable = false; + +static unsigned menu_background_gradient = 4; #if defined(HAVE_OPENGLES2) static unsigned menu_shader_pipeline = 1; diff --git a/configuration.c b/configuration.c index c1d9188c94..4a013258d3 100644 --- a/configuration.c +++ b/configuration.c @@ -485,7 +485,7 @@ static void config_set_defaults(void) settings->menu.xmb_scale_factor = xmb_scale_factor; settings->menu.xmb_alpha_factor = xmb_alpha_factor; settings->menu.xmb_theme = xmb_theme; - settings->menu.xmb_gradient = xmb_gradient; + settings->menu.background_gradient= menu_background_gradient; settings->menu.xmb_shadows_enable = xmb_shadows_enable; settings->menu.shader_pipeline = menu_shader_pipeline; settings->menu.xmb_font[0] = '\0'; @@ -1549,7 +1549,7 @@ static bool config_load_file(const char *path, bool set_defaults) CONFIG_GET_INT_BASE(conf, settings, menu.xmb_scale_factor, "xmb_scale_factor"); CONFIG_GET_INT_BASE(conf, settings, menu.xmb_alpha_factor, "xmb_alpha_factor"); CONFIG_GET_INT_BASE(conf, settings, menu.xmb_theme, "xmb_theme"); - CONFIG_GET_INT_BASE(conf, settings, menu.xmb_gradient, "xmb_gradient"); + CONFIG_GET_INT_BASE(conf, settings, menu.background_gradient, "menu_background_gradient"); CONFIG_GET_BOOL_BASE(conf, settings, menu.xmb_shadows_enable, "xmb_shadows_enable"); CONFIG_GET_INT_BASE(conf, settings, menu.shader_pipeline, "menu_shader_pipeline"); config_get_path(conf, "xmb_font", settings->menu.xmb_font, sizeof(settings->menu.xmb_font)); @@ -2817,7 +2817,7 @@ bool config_save_file(const char *path) config_set_int(conf, "xmb_scale_factor", settings->menu.xmb_scale_factor); config_set_int(conf, "xmb_alpha_factor", settings->menu.xmb_alpha_factor); config_set_int(conf, "xmb_theme", settings->menu.xmb_theme); - config_set_int(conf, "xmb_gradient", settings->menu.xmb_gradient); + config_set_int(conf, "menu_background_gradient", settings->menu.background_gradient); config_set_bool(conf, "xmb_shadows_enable", settings->menu.xmb_shadows_enable); config_set_int(conf, "menu_shader_pipeline", settings->menu.shader_pipeline); config_set_path(conf, "xmb_font", diff --git a/configuration.h b/configuration.h index 84274e2a2f..f651384222 100644 --- a/configuration.h +++ b/configuration.h @@ -161,7 +161,7 @@ typedef struct settings unsigned xmb_scale_factor; unsigned xmb_alpha_factor; unsigned xmb_theme; - unsigned xmb_gradient; + unsigned background_gradient; bool xmb_shadows_enable; unsigned shader_pipeline; char xmb_font[PATH_MAX_LENGTH]; diff --git a/menu/cbs/menu_cbs_get_value.c b/menu/cbs/menu_cbs_get_value.c index 6d0a66442a..9669054084 100644 --- a/menu/cbs/menu_cbs_get_value.c +++ b/menu/cbs/menu_cbs_get_value.c @@ -666,7 +666,7 @@ static void menu_action_setting_disp_set_label_xmb_gradient( strlcpy(s2, path, len2); *w = 19; - switch (settings->menu.xmb_gradient) + switch (settings->menu.background_gradient) { case 0: snprintf(s, len, "%s", "Legacy Red"); diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index fad8c74efd..65377e2ba6 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -338,7 +338,7 @@ static float *xmb_gradient_ident(void) { settings_t *settings = config_get_ptr(); - switch (settings->menu.xmb_gradient) + switch (settings->menu.background_gradient) { case 1: return &gradient_dark_purple[0]; diff --git a/menu/menu_setting.c b/menu/menu_setting.c index ee7e0ab8b7..4a6245c138 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -5983,10 +5983,10 @@ static bool setting_append_list( CONFIG_UINT( list, list_info, - &settings->menu.xmb_gradient, + &settings->menu.background_gradient, menu_hash_to_str(MENU_LABEL_XMB_GRADIENT), menu_hash_to_str(MENU_LABEL_VALUE_XMB_GRADIENT), - xmb_gradient, + menu_background_gradient, &group_info, &subgroup_info, parent_group, From dd2bb5a17b649b3139e095028dcf16bca03ffa68 Mon Sep 17 00:00:00 2001 From: radius Date: Sat, 30 Apr 2016 22:42:50 -0500 Subject: [PATCH 016/498] add basic retropad remote --- cores/retropad/Makefile | 141 ++++++++++++++++ cores/retropad/jni/Android.mk | 25 +++ cores/retropad/jni/Application.mk | 1 + cores/retropad/link.T | 5 + cores/retropad/retropad.c | 257 ++++++++++++++++++++++++++++++ 5 files changed, 429 insertions(+) create mode 100644 cores/retropad/Makefile create mode 100644 cores/retropad/jni/Android.mk create mode 100644 cores/retropad/jni/Application.mk create mode 100644 cores/retropad/link.T create mode 100644 cores/retropad/retropad.c diff --git a/cores/retropad/Makefile b/cores/retropad/Makefile new file mode 100644 index 0000000000..fefae26434 --- /dev/null +++ b/cores/retropad/Makefile @@ -0,0 +1,141 @@ +STATIC_LINKING := 0 +AR := ar + +ifeq ($(platform),) +platform = unix +ifeq ($(shell uname -a),) + platform = win +else ifneq ($(findstring MINGW,$(shell uname -a)),) + platform = win +else ifneq ($(findstring Darwin,$(shell uname -a)),) + platform = osx +else ifneq ($(findstring win,$(shell uname -a)),) + platform = win +endif +endif + +# system platform +system_platform = unix +ifeq ($(shell uname -a),) + EXE_EXT = .exe + system_platform = win +else ifneq ($(findstring Darwin,$(shell uname -a)),) + system_platform = osx + arch = intel +ifeq ($(shell uname -p),powerpc) + arch = ppc +endif +else ifneq ($(findstring MINGW,$(shell uname -a)),) + system_platform = win +endif + +TARGET_NAME := retropad +LIBM = -lm + +ifeq ($(ARCHFLAGS),) +ifeq ($(archs),ppc) + ARCHFLAGS = -arch ppc -arch ppc64 +else + ARCHFLAGS = -arch i386 -arch x86_64 +endif +endif + +ifeq ($(platform), osx) +ifndef ($(NOUNIVERSAL)) + CFLAGS += $(ARCHFLAGS) + LFLAGS += $(ARCHFLAGS) +endif +endif + +ifeq ($(STATIC_LINKING), 1) +EXT := a +endif + +ifeq ($(platform), unix) + EXT ?= so + TARGET := $(TARGET_NAME)_libretro.$(EXT) + fpic := -fPIC + SHARED := -shared -Wl,--version-script=link.T -Wl,--no-undefined +else ifeq ($(platform), linux-portable) + TARGET := $(TARGET_NAME)_libretro.$(EXT) + fpic := -fPIC -nostdlib + SHARED := -shared -Wl,--version-script=link.T + LIBM := +else ifneq (,$(findstring osx,$(platform))) + TARGET := $(TARGET_NAME)_libretro.dylib + fpic := -fPIC + SHARED := -dynamiclib +else ifneq (,$(findstring ios,$(platform))) + TARGET := $(TARGET_NAME)_libretro_ios.dylib + fpic := -fPIC + SHARED := -dynamiclib + +ifeq ($(IOSSDK),) + IOSSDK := $(shell xcodebuild -version -sdk iphoneos Path) +endif + + DEFINES := -DIOS + CC = cc -arch armv7 -isysroot $(IOSSDK) +ifeq ($(platform),ios9) +CC += -miphoneos-version-min=8.0 +CFLAGS += -miphoneos-version-min=8.0 +else +CC += -miphoneos-version-min=5.0 +CFLAGS += -miphoneos-version-min=5.0 +endif +else ifneq (,$(findstring qnx,$(platform))) + TARGET := $(TARGET_NAME)_libretro_qnx.so + fpic := -fPIC + SHARED := -shared -Wl,--version-script=link.T -Wl,--no-undefined +else ifeq ($(platform), emscripten) + TARGET := $(TARGET_NAME)_libretro_emscripten.bc + fpic := -fPIC + SHARED := -shared -Wl,--version-script=link.T -Wl,--no-undefined +else ifeq ($(platform), vita) + TARGET := $(TARGET_NAME)_vita.a + CC = arm-vita-eabi-gcc + AR = arm-vita-eabi-ar + CFLAGS += -Wl,-q -Wall -O3 + STATIC_LINKING = 1 +else + CC = gcc + TARGET := $(TARGET_NAME)_libretro.dll + SHARED := -shared -static-libgcc -static-libstdc++ -s -Wl,--version-script=link.T -Wl,--no-undefined +endif + +LDFLAGS += $(LIBM) -lws2_32 + +ifeq ($(DEBUG), 1) + CFLAGS += -O0 -g +else + CFLAGS += -O3 +endif + +OBJECTS := retropad.o +CFLAGS += -I../../libretro-common/include -Wall -pedantic $(fpic) + +ifneq (,$(findstring qnx,$(platform))) +CFLAGS += -Wc,-std=c99 +else +CFLAGS += -std=gnu99 +endif + +CFLAGS += -I../../libretro-common/include + +all: $(TARGET) + +$(TARGET): $(OBJECTS) +ifeq ($(STATIC_LINKING), 1) + $(AR) rcs $@ $(OBJECTS) +else + $(CC) $(fpic) $(SHARED) $(INCLUDES) -o $@ $(OBJECTS) $(LDFLAGS) +endif + +%.o: %.c + $(CC) $(CFLAGS) -c -o $@ $< + +clean: + rm -f $(OBJECTS) $(TARGET) + +.PHONY: clean + diff --git a/cores/retropad/jni/Android.mk b/cores/retropad/jni/Android.mk new file mode 100644 index 0000000000..5131c65220 --- /dev/null +++ b/cores/retropad/jni/Android.mk @@ -0,0 +1,25 @@ +LOCAL_PATH := $(call my-dir) + +include $(CLEAR_VARS) + +APP_DIR := ../../src + +LOCAL_MODULE := retro + +ifeq ($(TARGET_ARCH),arm) +LOCAL_CFLAGS += -DANDROID_ARM +endif + +ifeq ($(TARGET_ARCH),x86) +LOCAL_CFLAGS += -DANDROID_X86 +endif + +ifeq ($(TARGET_ARCH),mips) +LOCAL_CFLAGS += -DANDROID_MIPS -D__mips__ -D__MIPSEL__ +endif + +LOCAL_SRC_FILES += ../libretro-test.c +LOCAL_CFLAGS += -O3 -std=gnu99 -ffast-math -funroll-loops + + +include $(BUILD_SHARED_LIBRARY) diff --git a/cores/retropad/jni/Application.mk b/cores/retropad/jni/Application.mk new file mode 100644 index 0000000000..a252a72d72 --- /dev/null +++ b/cores/retropad/jni/Application.mk @@ -0,0 +1 @@ +APP_ABI := all diff --git a/cores/retropad/link.T b/cores/retropad/link.T new file mode 100644 index 0000000000..b0c262db9e --- /dev/null +++ b/cores/retropad/link.T @@ -0,0 +1,5 @@ +{ + global: retro_*; + local: *; +}; + diff --git a/cores/retropad/retropad.c b/cores/retropad/retropad.c new file mode 100644 index 0000000000..6c59da0155 --- /dev/null +++ b/cores/retropad/retropad.c @@ -0,0 +1,257 @@ +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2014 - Hans-Kristian Arntzen + * Copyright (C) 2011-2015 - 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 . + */ + + #include + #include + #include + #include + #include + #include + + #include + #include + #include + + #include + +#include "../../libretro.h" + +#define SERVER "127.0.0.1" +#define PORT 55400 + +struct retro_log_callback logger; +retro_log_printf_t log_cb; +static uint16_t *frame_buf; +struct sockaddr_in si_other; +int s, slen=sizeof(si_other); +char message[64]; +WSADATA wsa; +int input_state = 0; + +void retro_init(void) +{ + frame_buf = (uint16_t*)calloc(320 * 240, sizeof(uint16_t)); + //Initialise winsock + log_cb(RETRO_LOG_INFO, "Initialising sockets\n"); + if (WSAStartup(MAKEWORD(2,2),&wsa) != 0) + { + log_cb(RETRO_LOG_INFO, "Failed. Error Code : %d",WSAGetLastError()); + } + log_cb(RETRO_LOG_INFO, "Sockets initialised.\n"); + + //create socket + if ( (s=socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == SOCKET_ERROR) + { + log_cb(RETRO_LOG_INFO, "socket() failed with error code : %d" , WSAGetLastError()); + } + //setup address structure + memset((char *) &si_other, 0, sizeof(si_other)); + si_other.sin_family = AF_INET; + si_other.sin_port = htons(PORT); + si_other.sin_addr.S_un.S_addr = inet_addr(SERVER); +} + +void retro_deinit(void) +{ + if (frame_buf) + free(frame_buf); + frame_buf = NULL; +} + +unsigned retro_api_version(void) +{ + return RETRO_API_VERSION; +} + +void retro_set_controller_port_device( + unsigned port, unsigned device) +{ + (void)port; + (void)device; +} + +void retro_get_system_info( + struct retro_system_info *info) +{ + memset(info, 0, sizeof(*info)); + info->library_name = "RetroPad Remote"; + info->library_version = "0.01"; + info->need_fullpath = false; + info->valid_extensions = ""; /* Nothing. */ +} + +/* Doesn't really matter, but need something sane. */ +void retro_get_system_av_info( + struct retro_system_av_info *info) +{ + info->timing.fps = 60.0; + info->timing.sample_rate = 30000.0; + + info->geometry.base_width = 320; + info->geometry.base_height = 240; + info->geometry.max_width = 320; + info->geometry.max_height = 240; + info->geometry.aspect_ratio = 4.0 / 3.0; +} + +static retro_video_refresh_t video_cb; +static retro_audio_sample_t audio_cb; +static retro_audio_sample_batch_t audio_batch_cb; +static retro_environment_t environ_cb; +static retro_input_poll_t input_poll_cb; +static retro_input_state_t input_state_cb; + +void update_input() +{ + input_state = 0; + input_poll_cb(); + if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP)) + input_state += pow(2, 4); + if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN)) + input_state += pow(2, 5); + if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_LEFT)) + input_state += pow(2, 6); + if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT)) + input_state += pow(2, 7); +} + +void retro_set_environment(retro_environment_t cb) +{ + enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_RGB565; + + environ_cb = cb; + bool no_content = true; + cb(RETRO_ENVIRONMENT_SET_SUPPORT_NO_GAME, &no_content); + + environ_cb(RETRO_ENVIRONMENT_SET_PIXEL_FORMAT, &fmt); + + if (cb(RETRO_ENVIRONMENT_GET_LOG_INTERFACE, &logger)) + log_cb = logger.log; +} + +void retro_set_audio_sample(retro_audio_sample_t cb) +{ + audio_cb = cb; +} + +void retro_set_audio_sample_batch( + retro_audio_sample_batch_t cb) +{ + audio_batch_cb = cb; +} + +void retro_set_input_poll(retro_input_poll_t cb) +{ + input_poll_cb = cb; +} + +void retro_set_input_state(retro_input_state_t cb) +{ + input_state_cb = cb; +} + +void retro_set_video_refresh(retro_video_refresh_t cb) +{ + video_cb = cb; +} + +void retro_reset(void) +{} + +void retro_run(void) +{ + unsigned i; + update_input(); + itoa(input_state, message, 10); + //send the message + if (sendto(s, message, strlen(message) , 0 , (struct sockaddr *) &si_other, slen)==-1) + { + log_cb(RETRO_LOG_INFO, "Error sending data"); + } + for (i = 0; i < 320 * 240; i++) + frame_buf[i] = 4 << 5; + video_cb(frame_buf, 320, 240, 640); +} + +/* This should never be called, it's only used as a placeholder. */ +bool retro_load_game(const struct retro_game_info *info) +{ + (void)info; + return true; +} + +void retro_unload_game(void) +{} + +unsigned retro_get_region(void) +{ + return RETRO_REGION_NTSC; +} + +bool retro_load_game_special(unsigned type, + const struct retro_game_info *info, size_t num) +{ + (void)type; + (void)info; + (void)num; + return false; +} + +size_t retro_serialize_size(void) +{ + return 0; +} + +bool retro_serialize(void *data, size_t size) +{ + (void)data; + (void)size; + return false; +} + +bool retro_unserialize(const void *data, + size_t size) +{ + (void)data; + (void)size; + return false; +} + +void *retro_get_memory_data(unsigned id) +{ + (void)id; + return NULL; +} + +size_t retro_get_memory_size(unsigned id) +{ + (void)id; + return 0; +} + +void retro_cheat_reset(void) +{} + +void retro_cheat_set(unsigned idx, + bool enabled, const char *code) +{ + (void)idx; + (void)enabled; + (void)code; +} + + From 7f004aee71fb49c00e7f823576e66f42cc245c40 Mon Sep 17 00:00:00 2001 From: radius Date: Sat, 30 Apr 2016 22:49:51 -0500 Subject: [PATCH 017/498] Complete basic implementation of retropad remote (windows only atm) --- cores/retropad/retropad.c | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/cores/retropad/retropad.c b/cores/retropad/retropad.c index 6c59da0155..900fb86805 100644 --- a/cores/retropad/retropad.c +++ b/cores/retropad/retropad.c @@ -1,7 +1,7 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen * Copyright (C) 2011-2015 - Daniel De Matteis - * Copyright (C) 2012-2015 - Michael Lelli + * Copyright (C) 2016 - 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- @@ -15,6 +15,15 @@ * If not, see . */ +/* + * To-do: + * - Analog support + * - Some sort of connection control, it only sends packets + * but there is no acknoledgement of a connection o keepalives + * - Send player name + * - Render something on-screen +*/ + #include #include #include @@ -94,7 +103,6 @@ void retro_get_system_info( info->valid_extensions = ""; /* Nothing. */ } -/* Doesn't really matter, but need something sane. */ void retro_get_system_av_info( struct retro_system_av_info *info) { @@ -119,6 +127,14 @@ void update_input() { input_state = 0; input_poll_cb(); + if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_B)) + input_state += 1; + if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_A)) + input_state += 2; + if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_SELECT)) + input_state += pow(2, 2); + if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_START)) + input_state += pow(2, 3); if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_UP)) input_state += pow(2, 4); if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_DOWN)) @@ -127,6 +143,14 @@ void update_input() input_state += pow(2, 6); if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_RIGHT)) input_state += pow(2, 7); + if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_Y)) + input_state += pow(2, 8); + if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_X)) + input_state += pow(2, 9); + if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_L)) + input_state += pow(2, 10); + if (input_state_cb(0, RETRO_DEVICE_JOYPAD, 0, RETRO_DEVICE_ID_JOYPAD_R)) + input_state += pow(2, 11); } void retro_set_environment(retro_environment_t cb) @@ -187,7 +211,6 @@ void retro_run(void) video_cb(frame_buf, 320, 240, 640); } -/* This should never be called, it's only used as a placeholder. */ bool retro_load_game(const struct retro_game_info *info) { (void)info; From a1ac5af8af4fa492d629d4f191002fc77ecc09a3 Mon Sep 17 00:00:00 2001 From: radius Date: Sat, 30 Apr 2016 23:23:56 -0500 Subject: [PATCH 018/498] allow configuration of port & IP --- cores/retropad/retropad.c | 69 ++++++++++++++++++++++++++++++--------- 1 file changed, 54 insertions(+), 15 deletions(-) diff --git a/cores/retropad/retropad.c b/cores/retropad/retropad.c index 900fb86805..799bf1b817 100644 --- a/cores/retropad/retropad.c +++ b/cores/retropad/retropad.c @@ -21,7 +21,10 @@ * - Some sort of connection control, it only sends packets * but there is no acknoledgement of a connection o keepalives * - Send player name - * - Render something on-screen + * - Render something on-screen maybe a gui to configure IP and port + instead of the ridiculously long strings we're using now + * - Allow changing IP address and port in runtime + * - Support other platforms */ #include @@ -39,15 +42,14 @@ #include "../../libretro.h" -#define SERVER "127.0.0.1" -#define PORT 55400 - struct retro_log_callback logger; retro_log_printf_t log_cb; static uint16_t *frame_buf; struct sockaddr_in si_other; int s, slen=sizeof(si_other); char message[64]; +char server[64]; +int port; WSADATA wsa; int input_state = 0; @@ -61,17 +63,6 @@ void retro_init(void) log_cb(RETRO_LOG_INFO, "Failed. Error Code : %d",WSAGetLastError()); } log_cb(RETRO_LOG_INFO, "Sockets initialised.\n"); - - //create socket - if ( (s=socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == SOCKET_ERROR) - { - log_cb(RETRO_LOG_INFO, "socket() failed with error code : %d" , WSAGetLastError()); - } - //setup address structure - memset((char *) &si_other, 0, sizeof(si_other)); - si_other.sin_family = AF_INET; - si_other.sin_port = htons(PORT); - si_other.sin_addr.S_un.S_addr = inet_addr(SERVER); } void retro_deinit(void) @@ -155,6 +146,17 @@ void update_input() void retro_set_environment(retro_environment_t cb) { + static const struct retro_variable vars[] = { + { "port", "Port; 55400|55401|55402|55403|55404|55405|55406|55407|55409|55409" }, + { "ip_octet1", "IP address part 1; 0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|35|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59|60|61|62|63|64|65|66|67|68|69|70|71|72|73|74|75|76|77|78|79|80|81|82|83|84|85|86|87|88|89|90|91|92|93|94|95|96|97|98|99|100|101|102|103|104|105|106|107|108|109|110|111|112|113|114|115|116|117|118|119|120|121|122|123|124|125|126|127|128|129|130|131|132|133|135|135|136|137|138|139|140|141|142|143|144|145|146|147|148|149|150|151|152|153|154|155|156|157|158|159|160|161|162|163|164|165|166|167|168|169|170|171|172|173|174|175|176|177|178|179|180|181|182|183|184|185|186|187|188|189|190|191|192|193|194|195|196|197|198|199|200|201|202|203|204|205|206|207|208|209|210|211|212|213|214|215|216|217|218|219|220|221|222|223|224|225|226|227|228|229|230|231|232|233|235|235|236|237|238|239|240|241|242|243|244|245|246|247|248|249|250|251|252|253|254|255" }, + { "ip_octet2", "IP address part 2; 0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|35|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59|60|61|62|63|64|65|66|67|68|69|70|71|72|73|74|75|76|77|78|79|80|81|82|83|84|85|86|87|88|89|90|91|92|93|94|95|96|97|98|99|100|101|102|103|104|105|106|107|108|109|110|111|112|113|114|115|116|117|118|119|120|121|122|123|124|125|126|127|128|129|130|131|132|133|135|135|136|137|138|139|140|141|142|143|144|145|146|147|148|149|150|151|152|153|154|155|156|157|158|159|160|161|162|163|164|165|166|167|168|169|170|171|172|173|174|175|176|177|178|179|180|181|182|183|184|185|186|187|188|189|190|191|192|193|194|195|196|197|198|199|200|201|202|203|204|205|206|207|208|209|210|211|212|213|214|215|216|217|218|219|220|221|222|223|224|225|226|227|228|229|230|231|232|233|235|235|236|237|238|239|240|241|242|243|244|245|246|247|248|249|250|251|252|253|254|255" }, + { "ip_octet3", "IP address part 3; 0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|35|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59|60|61|62|63|64|65|66|67|68|69|70|71|72|73|74|75|76|77|78|79|80|81|82|83|84|85|86|87|88|89|90|91|92|93|94|95|96|97|98|99|100|101|102|103|104|105|106|107|108|109|110|111|112|113|114|115|116|117|118|119|120|121|122|123|124|125|126|127|128|129|130|131|132|133|135|135|136|137|138|139|140|141|142|143|144|145|146|147|148|149|150|151|152|153|154|155|156|157|158|159|160|161|162|163|164|165|166|167|168|169|170|171|172|173|174|175|176|177|178|179|180|181|182|183|184|185|186|187|188|189|190|191|192|193|194|195|196|197|198|199|200|201|202|203|204|205|206|207|208|209|210|211|212|213|214|215|216|217|218|219|220|221|222|223|224|225|226|227|228|229|230|231|232|233|235|235|236|237|238|239|240|241|242|243|244|245|246|247|248|249|250|251|252|253|254|255" }, + { "ip_octet4", "IP address part 4; 0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|35|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59|60|61|62|63|64|65|66|67|68|69|70|71|72|73|74|75|76|77|78|79|80|81|82|83|84|85|86|87|88|89|90|91|92|93|94|95|96|97|98|99|100|101|102|103|104|105|106|107|108|109|110|111|112|113|114|115|116|117|118|119|120|121|122|123|124|125|126|127|128|129|130|131|132|133|135|135|136|137|138|139|140|141|142|143|144|145|146|147|148|149|150|151|152|153|154|155|156|157|158|159|160|161|162|163|164|165|166|167|168|169|170|171|172|173|174|175|176|177|178|179|180|181|182|183|184|185|186|187|188|189|190|191|192|193|194|195|196|197|198|199|200|201|202|203|204|205|206|207|208|209|210|211|212|213|214|215|216|217|218|219|220|221|222|223|224|225|226|227|228|229|230|231|232|233|235|235|236|237|238|239|240|241|242|243|244|245|246|247|248|249|250|251|252|253|254|255" }, + + { NULL, NULL }, + }; + cb(RETRO_ENVIRONMENT_SET_VARIABLES, (void*)vars); + enum retro_pixel_format fmt = RETRO_PIXEL_FORMAT_RGB565; environ_cb = cb; @@ -167,6 +169,30 @@ void retro_set_environment(retro_environment_t cb) log_cb = logger.log; } +static void check_variables(void) +{ + struct retro_variable var; + var.key = "ip_octet1"; + environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var); + snprintf(server, sizeof(server), "%s", var.value); + + var.key = "ip_octet2"; + environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var); + snprintf(server, sizeof(server), "%s.%s", server, var.value); + + var.key = "ip_octet3"; + environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var); + snprintf(server, sizeof(server), "%s.%s", server, var.value); + + var.key = "ip_octet4"; + environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var); + snprintf(server, sizeof(server), "%s.%s", server, var.value); + + var.key = "port"; + environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var); + port = atoi(var.value); + +} void retro_set_audio_sample(retro_audio_sample_t cb) { audio_cb = cb; @@ -214,6 +240,19 @@ void retro_run(void) bool retro_load_game(const struct retro_game_info *info) { (void)info; + check_variables(); + //create socket + if ( (s=socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == SOCKET_ERROR) + { + log_cb(RETRO_LOG_INFO, "socket() failed with error code : %d" , WSAGetLastError()); + } + //setup address structure + memset((char *) &si_other, 0, sizeof(si_other)); + si_other.sin_family = AF_INET; + si_other.sin_port = htons(port); + si_other.sin_addr.S_un.S_addr = inet_addr(server); + log_cb(RETRO_LOG_INFO, "Server : %s" , server); + return true; } From 2931ae3d173e55873b6c190f121b1823fe811ffa Mon Sep 17 00:00:00 2001 From: radius Date: Sat, 30 Apr 2016 23:33:32 -0500 Subject: [PATCH 019/498] add a few more ports --- cores/retropad/retropad.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cores/retropad/retropad.c b/cores/retropad/retropad.c index 799bf1b817..87e8f1cfa4 100644 --- a/cores/retropad/retropad.c +++ b/cores/retropad/retropad.c @@ -25,6 +25,7 @@ instead of the ridiculously long strings we're using now * - Allow changing IP address and port in runtime * - Support other platforms + * - Input recording / Combos */ #include @@ -147,7 +148,7 @@ void update_input() void retro_set_environment(retro_environment_t cb) { static const struct retro_variable vars[] = { - { "port", "Port; 55400|55401|55402|55403|55404|55405|55406|55407|55409|55409" }, + { "port", "Port; 55400|55401|55402|55403|55404|55405|55406|55407|55408|55409|55410|55411|55412|55413|55414|55415|55416|55417|55418|55419|55420" }, { "ip_octet1", "IP address part 1; 0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|35|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59|60|61|62|63|64|65|66|67|68|69|70|71|72|73|74|75|76|77|78|79|80|81|82|83|84|85|86|87|88|89|90|91|92|93|94|95|96|97|98|99|100|101|102|103|104|105|106|107|108|109|110|111|112|113|114|115|116|117|118|119|120|121|122|123|124|125|126|127|128|129|130|131|132|133|135|135|136|137|138|139|140|141|142|143|144|145|146|147|148|149|150|151|152|153|154|155|156|157|158|159|160|161|162|163|164|165|166|167|168|169|170|171|172|173|174|175|176|177|178|179|180|181|182|183|184|185|186|187|188|189|190|191|192|193|194|195|196|197|198|199|200|201|202|203|204|205|206|207|208|209|210|211|212|213|214|215|216|217|218|219|220|221|222|223|224|225|226|227|228|229|230|231|232|233|235|235|236|237|238|239|240|241|242|243|244|245|246|247|248|249|250|251|252|253|254|255" }, { "ip_octet2", "IP address part 2; 0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|35|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59|60|61|62|63|64|65|66|67|68|69|70|71|72|73|74|75|76|77|78|79|80|81|82|83|84|85|86|87|88|89|90|91|92|93|94|95|96|97|98|99|100|101|102|103|104|105|106|107|108|109|110|111|112|113|114|115|116|117|118|119|120|121|122|123|124|125|126|127|128|129|130|131|132|133|135|135|136|137|138|139|140|141|142|143|144|145|146|147|148|149|150|151|152|153|154|155|156|157|158|159|160|161|162|163|164|165|166|167|168|169|170|171|172|173|174|175|176|177|178|179|180|181|182|183|184|185|186|187|188|189|190|191|192|193|194|195|196|197|198|199|200|201|202|203|204|205|206|207|208|209|210|211|212|213|214|215|216|217|218|219|220|221|222|223|224|225|226|227|228|229|230|231|232|233|235|235|236|237|238|239|240|241|242|243|244|245|246|247|248|249|250|251|252|253|254|255" }, { "ip_octet3", "IP address part 3; 0|1|2|3|4|5|6|7|8|9|10|11|12|13|14|15|16|17|18|19|20|21|22|23|24|25|26|27|28|29|30|31|32|33|35|35|36|37|38|39|40|41|42|43|44|45|46|47|48|49|50|51|52|53|54|55|56|57|58|59|60|61|62|63|64|65|66|67|68|69|70|71|72|73|74|75|76|77|78|79|80|81|82|83|84|85|86|87|88|89|90|91|92|93|94|95|96|97|98|99|100|101|102|103|104|105|106|107|108|109|110|111|112|113|114|115|116|117|118|119|120|121|122|123|124|125|126|127|128|129|130|131|132|133|135|135|136|137|138|139|140|141|142|143|144|145|146|147|148|149|150|151|152|153|154|155|156|157|158|159|160|161|162|163|164|165|166|167|168|169|170|171|172|173|174|175|176|177|178|179|180|181|182|183|184|185|186|187|188|189|190|191|192|193|194|195|196|197|198|199|200|201|202|203|204|205|206|207|208|209|210|211|212|213|214|215|216|217|218|219|220|221|222|223|224|225|226|227|228|229|230|231|232|233|235|235|236|237|238|239|240|241|242|243|244|245|246|247|248|249|250|251|252|253|254|255" }, From 8dd4333e16b5cf4e6ee745b86ac0ec9fecf29d41 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 1 May 2016 14:38:10 +0200 Subject: [PATCH 020/498] (net_http) Comment out debug logging --- libretro-common/net/net_http.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/libretro-common/net/net_http.c b/libretro-common/net/net_http.c index a4a1b78f73..ed386be69e 100644 --- a/libretro-common/net/net_http.c +++ b/libretro-common/net/net_http.c @@ -124,6 +124,7 @@ error: return -1; } +#if 0 static void net_http_send(int fd, bool * error, const char * data, size_t len) { @@ -147,11 +148,18 @@ static void net_http_send(int fd, bool * error, len -= thislen; } } +#endif static void net_http_send_str(int fd, bool *error, const char *text) { -printf("%s",text); +#if 0 + printf("%s",text); net_http_send(fd, error, text, strlen(text)); +#else + (void)fd; + (void)error; + (void)text; +#endif } static ssize_t net_http_recv(int fd, bool *error, From 5032c677e61f6acd13e71941541f08c2ba05ae6b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 1 May 2016 14:44:12 +0200 Subject: [PATCH 021/498] (Net) Only comment out printf --- libretro-common/net/net_http.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/libretro-common/net/net_http.c b/libretro-common/net/net_http.c index ed386be69e..0ea58eecd7 100644 --- a/libretro-common/net/net_http.c +++ b/libretro-common/net/net_http.c @@ -124,7 +124,6 @@ error: return -1; } -#if 0 static void net_http_send(int fd, bool * error, const char * data, size_t len) { @@ -148,18 +147,13 @@ static void net_http_send(int fd, bool * error, len -= thislen; } } -#endif static void net_http_send_str(int fd, bool *error, const char *text) { #if 0 printf("%s",text); - net_http_send(fd, error, text, strlen(text)); -#else - (void)fd; - (void)error; - (void)text; #endif + net_http_send(fd, error, text, strlen(text)); } static ssize_t net_http_recv(int fd, bool *error, From 7d99e7cd510eb33bf8361818ad7541c57e4d5cab Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 1 May 2016 15:07:45 +0200 Subject: [PATCH 022/498] Create fill_pathname_application_data --- configuration.c | 138 +++++++++++++++++--------------------------- file_path_special.c | 47 +++++++++++++++ file_path_special.h | 29 ++++++++++ 3 files changed, 130 insertions(+), 84 deletions(-) create mode 100644 file_path_special.h diff --git a/configuration.c b/configuration.c index 4a013258d3..6b4f0e50f7 100644 --- a/configuration.c +++ b/configuration.c @@ -24,6 +24,7 @@ #include #include +#include "file_path_special.h" #include "audio/audio_driver.h" #include "configuration.h" #include "config.def.h" @@ -950,20 +951,13 @@ static void config_set_defaults(void) **/ static config_file_t *open_default_config_file(void) { + char application_data[PATH_MAX_LENGTH]; char conf_path[PATH_MAX_LENGTH] = {0}; char app_path[PATH_MAX_LENGTH] = {0}; - const char *xdg = NULL; - const char *home = NULL; config_file_t *conf = NULL; bool saved = false; global_t *global = global_get_ptr(); - (void)conf_path; - (void)app_path; - (void)saved; - (void)xdg; - (void)home; - #if defined(_WIN32) && !defined(_XBOX) fill_pathname_application_path(app_path, sizeof(app_path)); fill_pathname_resolve_relative(conf_path, app_path, @@ -973,11 +967,10 @@ static config_file_t *open_default_config_file(void) if (!conf) { - const char *appdata = getenv("APPDATA"); - - if (appdata) + if (fill_pathname_application_data(application_data, + sizeof(application_data))) { - fill_pathname_join(conf_path, appdata, + fill_pathname_join(conf_path, application_data, "retroarch.cfg", sizeof(conf_path)); conf = config_file_new(conf_path); } @@ -1010,13 +1003,12 @@ static config_file_t *open_default_config_file(void) RARCH_WARN("Created new config file in: \"%s\".\n", conf_path); } #elif defined(OSX) - home = getenv("HOME"); - - if (!home) + if (!fill_pathname_application_data(application_data, + sizeof(application_data))) return NULL; - fill_pathname_join(conf_path, home, - "Library/Application Support/RetroArch", sizeof(conf_path)); + fill_pathname_join(conf_path, application_data, + "RetroArch", sizeof(conf_path)); path_mkdir(conf_path); fill_pathname_join(conf_path, conf_path, @@ -1046,99 +1038,77 @@ static config_file_t *open_default_config_file(void) RARCH_WARN("Created new config file in: \"%s\".\n", conf_path); } #elif !defined(__CELLOS_LV2__) && !defined(_XBOX) - xdg = getenv("XDG_CONFIG_HOME"); - home = getenv("HOME"); + bool has_application_data = fill_pathname_application_data(application_data, + sizeof(application_data)); - /* XDG_CONFIG_HOME falls back to $HOME/.config. */ - if (xdg) - fill_pathname_join(conf_path, xdg, - "retroarch/retroarch.cfg", sizeof(conf_path)); - else if (home) -#ifdef __HAIKU__ - fill_pathname_join(conf_path, home, - "config/settings/retroarch/retroarch.cfg", sizeof(conf_path)); -#else - fill_pathname_join(conf_path, home, - ".config/retroarch/retroarch.cfg", sizeof(conf_path)); -#endif - - if (xdg || home) + if (has_application_data) { + fill_pathname_join(conf_path, application_data, + "retroarch.cfg", sizeof(conf_path)); RARCH_LOG("Looking for config in: \"%s\".\n", conf_path); conf = config_file_new(conf_path); } /* Fallback to $HOME/.retroarch.cfg. */ - if (!conf && home) + if (!conf && getenv("HOME")) { - fill_pathname_join(conf_path, home, + fill_pathname_join(conf_path, getenv("HOME"), ".retroarch.cfg", sizeof(conf_path)); RARCH_LOG("Looking for config in: \"%s\".\n", conf_path); conf = config_file_new(conf_path); } - if (!conf) + if (!conf && has_application_data) { - if (home || xdg) + char basedir[PATH_MAX_LENGTH] = {0}; + + /* Try to create a new config file. */ + + strlcpy(conf_path, application_data, sizeof(conf_path)); + fill_pathname_basedir(basedir, conf_path, sizeof(basedir)); + + if (path_mkdir(basedir)) { - char basedir[PATH_MAX_LENGTH] = {0}; + char skeleton_conf[PATH_MAX_LENGTH] = {0}; - /* Try to create a new config file. */ + fill_pathname_join(skeleton_conf, GLOBAL_CONFIG_DIR, + "retroarch.cfg", sizeof(skeleton_conf)); + conf = config_file_new(skeleton_conf); + if (conf) + RARCH_WARN("Config: using skeleton config \"%s\" as base for a new config file.\n", skeleton_conf); + else + conf = config_file_new(NULL); - /* XDG_CONFIG_HOME falls back to $HOME/.config. */ - if (xdg) - fill_pathname_join(conf_path, xdg, - "retroarch/retroarch.cfg", sizeof(conf_path)); - else if (home) -#ifdef __HAIKU__ - fill_pathname_join(conf_path, home, - "config/settings/retroarch/retroarch.cfg", sizeof(conf_path)); -#else - fill_pathname_join(conf_path, home, - ".config/retroarch/retroarch.cfg", sizeof(conf_path)); -#endif - - fill_pathname_basedir(basedir, conf_path, sizeof(basedir)); - - if (path_mkdir(basedir)) + if (conf) { - char skeleton_conf[PATH_MAX_LENGTH] = {0}; - - fill_pathname_join(skeleton_conf, GLOBAL_CONFIG_DIR, - "retroarch.cfg", sizeof(skeleton_conf)); - conf = config_file_new(skeleton_conf); - if (conf) - RARCH_WARN("Config: using skeleton config \"%s\" as base for a new config file.\n", skeleton_conf); - else - conf = config_file_new(NULL); - - if (conf) - { - /* Since this is a clean config file, we can safely use config_save_on_exit. */ - config_set_bool(conf, "config_save_on_exit", true); - saved = config_file_write(conf, conf_path); - } - - if (!saved) - { - /* WARN here to make sure user has a good chance of seeing it. */ - RARCH_ERR("Failed to create new config file in: \"%s\".\n", conf_path); - config_file_free(conf); - - return NULL; - } - - RARCH_WARN("Config: Created new config file in: \"%s\".\n", conf_path); + /* Since this is a clean config file, we can safely use config_save_on_exit. */ + config_set_bool(conf, "config_save_on_exit", true); + saved = config_file_write(conf, conf_path); } + + if (!saved) + { + /* WARN here to make sure user has a good chance of seeing it. */ + RARCH_ERR("Failed to create new config file in: \"%s\".\n", conf_path); + config_file_free(conf); + + return NULL; + } + + RARCH_WARN("Config: Created new config file in: \"%s\".\n", conf_path); } } #endif + (void)application_data; + (void)conf_path; + (void)app_path; + (void)saved; + if (!conf) return NULL; - strlcpy(global->path.config, conf_path, - sizeof(global->path.config)); + strlcpy(global->path.config, conf_path, sizeof(global->path.config)); return conf; } diff --git a/file_path_special.c b/file_path_special.c index 450b71d4cc..f7812d6e09 100644 --- a/file_path_special.c +++ b/file_path_special.c @@ -138,6 +138,53 @@ void fill_pathname_abbreviate_special(char *out_path, } #if !defined(RARCH_CONSOLE) +bool fill_pathname_application_data(char *s, size_t len) +{ +#if defined(_WIN32) && !defined(_XBOX) + const char *appdata = getenv("APPDATA"); + + if (appdata) + { + strlcpy(s, appdata, len); + return true; + } + +#elif defined(OSX) + const char *appdata = getenv("HOME"); + + if (appdata) + { + fill_pathname_join(s, appdata, + "Library/Application Support", len); + return true; + } +#elif !defined(__CELLOS_LV2__) && !defined(_XBOX) + const char *xdg = getenv("XDG_CONFIG_HOME"); + const char *appdata = getenv("HOME"); + + /* XDG_CONFIG_HOME falls back to $HOME/.config. */ + if (xdg) + { + fill_pathname_join(s, xdg, "retroarch", len); + return true; + } + + if (appdata) + { +#ifdef __HAIKU__ + fill_pathname_join(s, appdata, + "config/settings/retroarch", len); +#else + fill_pathname_join(s, appdata, + ".config/retroarch", len); +#endif + return true; + } +#endif + + return false; +} + void fill_pathname_application_path(char *s, size_t len) { #ifdef __APPLE__ diff --git a/file_path_special.h b/file_path_special.h new file mode 100644 index 0000000000..239058984d --- /dev/null +++ b/file_path_special.h @@ -0,0 +1,29 @@ +/* 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. + * + * 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 _FILE_PATH_SPECIAL_H +#define _FILE_PATH_SPECIAL_H + +#include +#include + +#include + +#if !defined(RARCH_CONSOLE) +bool fill_pathname_application_data(char *s, size_t len); +#endif + +#endif From e9f0ff08feecbf0f645375ca77a182a882d6e2ea Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 1 May 2016 15:08:31 +0200 Subject: [PATCH 023/498] (file_path_special.c) Add config.h --- file_path_special.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/file_path_special.c b/file_path_special.c index f7812d6e09..5b9851b557 100644 --- a/file_path_special.c +++ b/file_path_special.c @@ -13,6 +13,10 @@ * If not, see . */ +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #include #include #include From 65dfddd910afb91e51102132cd3ea50294b3c86f Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Sun, 1 May 2016 15:28:45 +0200 Subject: [PATCH 024/498] (OSX) Start using Library/Application Support for config file settings --- frontend/drivers/platform_darwin.m | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/frontend/drivers/platform_darwin.m b/frontend/drivers/platform_darwin.m index 87f0e6ccd5..7f14fcbce5 100644 --- a/frontend/drivers/platform_darwin.m +++ b/frontend/drivers/platform_darwin.m @@ -46,6 +46,7 @@ #include #include "../frontend_driver.h" +#include "../../file_path_special.h" #include "../../defaults.h" #include "../../general.h" #include "../../verbosity.h" @@ -370,28 +371,35 @@ static void frontend_darwin_get_environment_settings(int *argc, char *argv[], fill_pathname_join(g_defaults.dir.savestate, home_dir_buf, "states", sizeof(g_defaults.dir.savestate)); fill_pathname_join(g_defaults.dir.remap, home_dir_buf, "remaps", sizeof(g_defaults.dir.remap)); #if defined(OSX) + char application_data_root_dir[PATH_MAX_LENGTH]; + char application_data[PATH_MAX_LENGTH]; + + fill_pathname_application_data(application_data, sizeof(application_data)); + fill_pathname_join(application_data_root_dir, + application_data, "RetroArch", sizeof(application_data_root_dir)); + #ifdef HAVE_CG fill_pathname_join(g_defaults.dir.shader, home_dir_buf, "shaders_cg", sizeof(g_defaults.dir.shader)); #endif fill_pathname_join(g_defaults.dir.audio_filter, home_dir_buf, "audio_filters", sizeof(g_defaults.dir.audio_filter)); fill_pathname_join(g_defaults.dir.video_filter, home_dir_buf, "video_filters", sizeof(g_defaults.dir.video_filter)); - fill_pathname_join(g_defaults.dir.playlist, home_dir_buf, "playlists", sizeof(g_defaults.dir.playlist)); + fill_pathname_join(g_defaults.dir.playlist, application_data_root_dir, "playlists", sizeof(g_defaults.dir.playlist)); + fill_pathname_join(g_defaults.dir.menu_config, application_data_root_dir, "configs", sizeof(g_defaults.dir.menu_config)); + fill_pathname_join(g_defaults.path.config, g_defaults.dir.menu_config, "retroarch.cfg", sizeof(g_defaults.path.config)); + fill_pathname_join(g_defaults.dir.thumbnails, application_data_root_dir, "thumbnails", sizeof(g_defaults.dir.thumbnails)); + fill_pathname_join(g_defaults.dir.remap, application_data_root_dir, "remaps", sizeof(g_defaults.dir.remap)); + fill_pathname_join(g_defaults.dir.core_assets, application_data_root_dir, "downloads", sizeof(g_defaults.dir.core_assets)); + fill_pathname_join(g_defaults.dir.screenshot, application_data_root_dir, "screenshots", sizeof(g_defaults.dir.screenshot)); #if defined(RELEASE_BUILD) - fill_pathname_join(g_defaults.dir.remap, bundle_path_buf, "Contents/Resources/remaps", sizeof(g_defaults.dir.remap)); - fill_pathname_join(g_defaults.dir.playlist, bundle_path_buf, "Contents/Resources/playlists", sizeof(g_defaults.dir.playlist)); fill_pathname_join(g_defaults.dir.shader, bundle_path_buf, "Contents/Resources/shaders", sizeof(g_defaults.dir.shader)); fill_pathname_join(g_defaults.dir.core, bundle_path_buf, "Contents/Resources/cores", sizeof(g_defaults.dir.core)); fill_pathname_join(g_defaults.dir.core_info, bundle_path_buf, "Contents/Resources/info", sizeof(g_defaults.dir.core_info)); fill_pathname_join(g_defaults.dir.overlay, bundle_path_buf, "Contents/Resources/overlays", sizeof(g_defaults.dir.overlay)); fill_pathname_join(g_defaults.dir.autoconfig, bundle_path_buf, "Contents/Resources/autoconfig", sizeof(g_defaults.dir.autoconfig)); - fill_pathname_join(g_defaults.dir.core_assets, bundle_path_buf, "Contents/Resources/downloads", sizeof(g_defaults.dir.core_assets)); fill_pathname_join(g_defaults.dir.assets, bundle_path_buf, "Contents/Resources/assets", sizeof(g_defaults.dir.assets)); - fill_pathname_join(g_defaults.dir.menu_config, bundle_path_buf, "Contents/Resources/configs", sizeof(g_defaults.dir.menu_config)); - fill_pathname_join(g_defaults.path.config, g_defaults.dir.menu_config, "retroarch.cfg", sizeof(g_defaults.path.config)); fill_pathname_join(g_defaults.dir.database, bundle_path_buf, "Contents/Resources/database/rdb", sizeof(g_defaults.dir.database)); fill_pathname_join(g_defaults.dir.cursor, bundle_path_buf, "Contents/Resources/database/cursors", sizeof(g_defaults.dir.cursor)); fill_pathname_join(g_defaults.dir.cheats, bundle_path_buf, "Contents/Resources/cht", sizeof(g_defaults.dir.cheats)); - fill_pathname_join(g_defaults.dir.thumbnails, bundle_path_buf, "Contents/Resources/thumbnails", sizeof(g_defaults.dir.thumbnails)); #endif #endif From e135f0b209f1150cb1fbfb7d46ba46f64c6ec027 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Sun, 1 May 2016 15:30:25 +0200 Subject: [PATCH 025/498] (iOS) Add default directory for playlists --- frontend/drivers/platform_darwin.m | 3 +++ 1 file changed, 3 insertions(+) diff --git a/frontend/drivers/platform_darwin.m b/frontend/drivers/platform_darwin.m index 7f14fcbce5..8f5b062689 100644 --- a/frontend/drivers/platform_darwin.m +++ b/frontend/drivers/platform_darwin.m @@ -370,6 +370,9 @@ static void frontend_darwin_get_environment_settings(int *argc, char *argv[], fill_pathname_join(g_defaults.dir.sram, home_dir_buf, "saves", sizeof(g_defaults.dir.sram)); fill_pathname_join(g_defaults.dir.savestate, home_dir_buf, "states", sizeof(g_defaults.dir.savestate)); fill_pathname_join(g_defaults.dir.remap, home_dir_buf, "remaps", sizeof(g_defaults.dir.remap)); +#if defined(IOS) + fill_pathname_join(g_defaults.dir.playlist, home_dir_buf, "playlists", sizeof(g_defaults.dir.playlist)); +#endif #if defined(OSX) char application_data_root_dir[PATH_MAX_LENGTH]; char application_data[PATH_MAX_LENGTH]; From 09f5ccf0502e77fbd164a179511092479b78e627 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 1 May 2016 15:33:48 +0200 Subject: [PATCH 026/498] open_default_config_file - cleanup --- configuration.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/configuration.c b/configuration.c index 6b4f0e50f7..362670a742 100644 --- a/configuration.c +++ b/configuration.c @@ -955,8 +955,6 @@ static config_file_t *open_default_config_file(void) char conf_path[PATH_MAX_LENGTH] = {0}; char app_path[PATH_MAX_LENGTH] = {0}; config_file_t *conf = NULL; - bool saved = false; - global_t *global = global_get_ptr(); #if defined(_WIN32) && !defined(_XBOX) fill_pathname_application_path(app_path, sizeof(app_path)); @@ -978,6 +976,8 @@ static config_file_t *open_default_config_file(void) if (!conf) { + bool saved = false; + /* Try to create a new config file. */ conf = config_file_new(NULL); @@ -1017,6 +1017,8 @@ static config_file_t *open_default_config_file(void) if (!conf) { + bool saved = false; + conf = config_file_new(NULL); if (conf) @@ -1069,6 +1071,7 @@ static config_file_t *open_default_config_file(void) if (path_mkdir(basedir)) { + bool saved = false; char skeleton_conf[PATH_MAX_LENGTH] = {0}; fill_pathname_join(skeleton_conf, GLOBAL_CONFIG_DIR, @@ -1103,14 +1106,15 @@ static config_file_t *open_default_config_file(void) (void)application_data; (void)conf_path; (void)app_path; - (void)saved; - if (!conf) - return NULL; + if (conf) + { + global_t *global = global_get_ptr(); + strlcpy(global->path.config, conf_path, sizeof(global->path.config)); + return conf; + } - strlcpy(global->path.config, conf_path, sizeof(global->path.config)); - - return conf; + return NULL; } static void read_keybinds_keyboard(config_file_t *conf, unsigned user, From be7da8d626aedc7c407f0ce8f7dd3fc18c52e9ad Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 1 May 2016 15:46:42 +0200 Subject: [PATCH 027/498] (menu_setting.c) Add config.h --- menu/menu_setting.c | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 4a6245c138..4ee69539f1 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -23,6 +23,12 @@ #endif +#ifdef _WIN32 +#include +#else +#include +#endif + #include #include #include @@ -58,10 +64,9 @@ #include "../tasks/tasks_internal.h" -#ifdef _WIN32 -#include -#else -#include + +#ifdef HAVE_CONFIG_H +#include "config.h" #endif struct rarch_setting_info From 3a23afcaa99c4383e203f6389a4b81877f08bc8b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 1 May 2016 15:59:55 +0200 Subject: [PATCH 028/498] Buildfix for consoles --- file_path_special.c | 4 ++-- file_path_special.h | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/file_path_special.c b/file_path_special.c index 5b9851b557..16a7927573 100644 --- a/file_path_special.c +++ b/file_path_special.c @@ -141,7 +141,6 @@ void fill_pathname_abbreviate_special(char *out_path, retro_assert(strlcpy(out_path, in_path, size) < size); } -#if !defined(RARCH_CONSOLE) bool fill_pathname_application_data(char *s, size_t len) { #if defined(_WIN32) && !defined(_XBOX) @@ -162,7 +161,7 @@ bool fill_pathname_application_data(char *s, size_t len) "Library/Application Support", len); return true; } -#elif !defined(__CELLOS_LV2__) && !defined(_XBOX) +#elif !defined(RARCH_CONSOLE) const char *xdg = getenv("XDG_CONFIG_HOME"); const char *appdata = getenv("HOME"); @@ -189,6 +188,7 @@ bool fill_pathname_application_data(char *s, size_t len) return false; } +#if !defined(RARCH_CONSOLE) void fill_pathname_application_path(char *s, size_t len) { #ifdef __APPLE__ diff --git a/file_path_special.h b/file_path_special.h index 239058984d..6d10b466e4 100644 --- a/file_path_special.h +++ b/file_path_special.h @@ -22,8 +22,6 @@ #include -#if !defined(RARCH_CONSOLE) bool fill_pathname_application_data(char *s, size_t len); -#endif #endif From 4372d55325a3a24248928a0ee057154cbd004f88 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 1 May 2016 16:01:03 +0200 Subject: [PATCH 029/498] Change ifdef to ifndef RARCH_CONSOLE --- configuration.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configuration.c b/configuration.c index 362670a742..2627628e3d 100644 --- a/configuration.c +++ b/configuration.c @@ -1039,7 +1039,7 @@ static config_file_t *open_default_config_file(void) RARCH_WARN("Created new config file in: \"%s\".\n", conf_path); } -#elif !defined(__CELLOS_LV2__) && !defined(_XBOX) +#elif !defined(RARCH_CONSOLE) bool has_application_data = fill_pathname_application_data(application_data, sizeof(application_data)); From f59420094a8cda5347dbdb7f8024d900452189f5 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 1 May 2016 16:05:07 +0200 Subject: [PATCH 030/498] Simplify dump_to_file_desperate --- content.c | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/content.c b/content.c index 2618b77ccb..a508a2c510 100644 --- a/content.c +++ b/content.c @@ -62,6 +62,7 @@ #include "system.h" #include "retroarch.h" #include "command_event.h" +#include "file_path_special.h" #include "libretro_version_1.h" #include "verbosity.h" @@ -978,19 +979,15 @@ static bool dump_to_file_desperate(const void *data, { time_t time_; char timebuf[256]; + char application_data[PATH_MAX_LENGTH]; char path[PATH_MAX_LENGTH]; -#if defined(_WIN32) && !defined(_XBOX) - const char *base = getenv("APPDATA"); -#elif defined(__CELLOS_LV2__) || defined(_XBOX) - const char *base = NULL; -#else - const char *base = getenv("HOME"); -#endif - if (!base) + if (!fill_pathname_application_data(application_data, + sizeof(application_data))) return false; - snprintf(path, sizeof(path), "%s/RetroArch-recovery-%u", base, type); + snprintf(path, sizeof(path), "%s/RetroArch-recovery-%u", + application_data, type); time(&time_); From f9462ed56288673850076560e784ff6f29e419bd Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 1 May 2016 16:09:46 +0200 Subject: [PATCH 031/498] Update autoconfig path --- menu/cbs/menu_cbs_ok.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 979f1a8180..2123756b7a 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -1437,27 +1437,18 @@ static int action_ok_download_generic(const char *path, fill_pathname_join(s, settings->network.buildbot_assets_url, "frontend", sizeof(s)); if (string_is_equal(type_msg, "cb_core_content_download")) - { fill_pathname_join(s, settings->network.buildbot_assets_url, "cores/gw", sizeof(s)); - } #ifdef HAVE_LAKKA + /* TODO unhardcode this path*/ else if (string_is_equal(type_msg, "cb_lakka_download")) - { - /* TODO unhardcode this path*/ fill_pathname_join(s, "http://mirror.lakka.tv/nightly", LAKKA_PROJECT, sizeof(s)); - } #endif else if (string_is_equal(type_msg, "cb_update_assets")) path = "assets.zip"; else if (string_is_equal(type_msg, "cb_update_autoconfig_profiles")) - path = "autoconf.zip"; - -#ifdef HAVE_HID - else if (string_is_equal(type_msg, "cb_update_autoconfig_profiles_hid")) - path = "autoconf_hid.zip"; -#endif + path = "autoconfig.zip"; else if (string_is_equal(type_msg, "cb_update_core_info_files")) path = "info.zip"; else if (string_is_equal(type_msg, "cb_update_cheats")) @@ -1471,9 +1462,7 @@ static int action_ok_download_generic(const char *path, else if (string_is_equal(type_msg, "cb_update_shaders_cg")) path = "shaders_cg.zip"; else if (string_is_equal(type_msg, "cb_core_thumbnails_download")) - { strlcpy(s, "http://thumbnailpacks.libretro.com", sizeof(s)); - } else strlcpy(s, settings->network.buildbot_url, sizeof(s)); From bede7cfe2b4145c3c829584453e9dfb492b2439d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Sun, 1 May 2016 21:33:31 +0700 Subject: [PATCH 032/498] (Lakka) Fix samba and bluetooth service management --- menu/menu_setting.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 4ee69539f1..1314c4d0d0 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -3164,7 +3164,7 @@ static void samba_enable_toggle_change_handler(void *data) { bool enable = false; settings_t *settings = config_get_ptr(); - if (settings && settings->ssh_enable) + if (settings && settings->samba_enable) enable = true; systemd_service_toggle(LAKKA_SAMBA_PATH, (char*)"smbd.service", @@ -3175,7 +3175,7 @@ static void bluetooth_enable_toggle_change_handler(void *data) { bool enable = false; settings_t *settings = config_get_ptr(); - if (settings && settings->ssh_enable) + if (settings && settings->bluetooth_enable) enable = true; systemd_service_toggle(LAKKA_BLUETOOTH_PATH, (char*)"bluetooth.service", From d4d2f7fa6b481d950df987d908cd28ba85d6f705 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 1 May 2016 16:49:13 +0200 Subject: [PATCH 033/498] Set default thumbnails setting to 1 --- config.def.h | 2 ++ configuration.c | 2 +- menu/menu_setting.c | 2 +- 3 files changed, 4 insertions(+), 2 deletions(-) diff --git a/config.def.h b/config.def.h index 7a4bf13379..1f8e0222db 100644 --- a/config.def.h +++ b/config.def.h @@ -775,6 +775,8 @@ static const unsigned input_max_users = 5; static const unsigned input_poll_type_behavior = 2; +static const unsigned menu_thumbnails_default = 1; + #ifdef IOS static const bool ui_companion_start_on_boot = false; #else diff --git a/configuration.c b/configuration.c index 2627628e3d..062168d98e 100644 --- a/configuration.c +++ b/configuration.c @@ -622,7 +622,7 @@ static void config_set_defaults(void) settings->menu.timedate_enable = true; settings->menu.core_enable = true; settings->menu.dynamic_wallpaper_enable = false; - settings->menu.thumbnails = 0; + settings->menu.thumbnails = menu_thumbnails_default; settings->menu.show_advanced_settings = show_advanced_settings; settings->menu.entry_normal_color = menu_entry_normal_color; settings->menu.entry_hover_color = menu_entry_hover_color; diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 1314c4d0d0..436a4e17c1 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -6019,7 +6019,7 @@ static bool setting_append_list( &settings->menu.thumbnails, menu_hash_to_str(MENU_LABEL_THUMBNAILS), menu_hash_to_str(MENU_LABEL_VALUE_THUMBNAILS), - 0, + menu_thumbnails_default, &group_info, &subgroup_info, parent_group, From 73d198ed7f2439fdeda752923338b2f39ea80b84 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 1 May 2016 16:56:15 +0200 Subject: [PATCH 034/498] Set default thumbnail setting to 'boxart' --- config.def.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.def.h b/config.def.h index 1f8e0222db..4756ec2f9d 100644 --- a/config.def.h +++ b/config.def.h @@ -775,7 +775,7 @@ static const unsigned input_max_users = 5; static const unsigned input_poll_type_behavior = 2; -static const unsigned menu_thumbnails_default = 1; +static const unsigned menu_thumbnails_default = 3; #ifdef IOS static const bool ui_companion_start_on_boot = false; From d6443431c6ced6546ebfed55dd682bcefc38cf64 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 1 May 2016 17:30:16 +0200 Subject: [PATCH 035/498] Ability to press left/right for Thumbnail Updater --- menu/cbs/menu_cbs_left.c | 1 + menu/cbs/menu_cbs_right.c | 1 + 2 files changed, 2 insertions(+) diff --git a/menu/cbs/menu_cbs_left.c b/menu/cbs/menu_cbs_left.c index 0cbcbf842a..1f0c044087 100644 --- a/menu/cbs/menu_cbs_left.c +++ b/menu/cbs/menu_cbs_left.c @@ -523,6 +523,7 @@ static int menu_cbs_init_bind_left_compare_type(menu_file_list_cbs_t *cbs, case MENU_FILE_IMAGEVIEWER: case MENU_FILE_PLAYLIST_COLLECTION: case MENU_FILE_DOWNLOAD_CORE_CONTENT: + case MENU_FILE_DOWNLOAD_THUMBNAIL_CONTENT: case MENU_FILE_SCAN_DIRECTORY: case MENU_SETTING_GROUP: switch (menu_label_hash) diff --git a/menu/cbs/menu_cbs_right.c b/menu/cbs/menu_cbs_right.c index cb89eb05c3..85e4c4ac4c 100644 --- a/menu/cbs/menu_cbs_right.c +++ b/menu/cbs/menu_cbs_right.c @@ -471,6 +471,7 @@ static int menu_cbs_init_bind_right_compare_type(menu_file_list_cbs_t *cbs, case MENU_FILE_IMAGEVIEWER: case MENU_FILE_PLAYLIST_COLLECTION: case MENU_FILE_DOWNLOAD_CORE_CONTENT: + case MENU_FILE_DOWNLOAD_THUMBNAIL_CONTENT: case MENU_FILE_SCAN_DIRECTORY: case MENU_SETTING_GROUP: switch (menu_label_hash) From 1b9d9647b0d5a5f8df49c06b046fcc83a3787b7d Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Sun, 1 May 2016 17:36:40 +0200 Subject: [PATCH 036/498] Add 'Download Core' entry in 'Load Core' list --- menu/menu_displaylist.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 25b4cb5f94..95b69f7465 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -2650,6 +2650,15 @@ static int menu_displaylist_parse_generic( dir_list_sort(str_list, true); list_size = str_list->size; + +#ifdef HAVE_NETWORKING + if (hash_label == MENU_LABEL_CORE_LIST) + menu_entries_add(info->list, + "Download Core...", + menu_hash_to_str(MENU_LABEL_CORE_UPDATER_LIST), + MENU_SETTING_ACTION, 0, 0); +#endif + if (list_size == 0) { From 07e1f6e7485f49a22db053049e58839e9a227df9 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 1 May 2016 17:43:37 +0200 Subject: [PATCH 037/498] Only show 'Download Core' so far when no core is yet added --- menu/menu_displaylist.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 95b69f7465..a019b1c277 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -2651,13 +2651,6 @@ static int menu_displaylist_parse_generic( list_size = str_list->size; -#ifdef HAVE_NETWORKING - if (hash_label == MENU_LABEL_CORE_LIST) - menu_entries_add(info->list, - "Download Core...", - menu_hash_to_str(MENU_LABEL_CORE_UPDATER_LIST), - MENU_SETTING_ACTION, 0, 0); -#endif if (list_size == 0) @@ -2667,6 +2660,13 @@ static int menu_displaylist_parse_generic( menu_entries_add(info->list, menu_hash_to_str(MENU_LABEL_VALUE_NO_ITEMS), "", MENU_SETTING_NO_ITEM, 0, 0); +#ifdef HAVE_NETWORKING + if (hash_label == MENU_LABEL_CORE_LIST) + menu_entries_add(info->list, + "Download Core...", + menu_hash_to_str(MENU_LABEL_CORE_UPDATER_LIST), + MENU_SETTING_ACTION, 0, 0); +#endif } string_list_free(str_list); From 16a61425774584d851d872413cb9a3bcd3460e7e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 1 May 2016 17:47:10 +0200 Subject: [PATCH 038/498] (Menu) Turn on XMB shadows for non-Lakka --- config.def.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/config.def.h b/config.def.h index 4756ec2f9d..9489b966a3 100644 --- a/config.def.h +++ b/config.def.h @@ -512,7 +512,12 @@ static bool default_block_config_read = true; static unsigned xmb_scale_factor = 100; static unsigned xmb_alpha_factor = 75; static unsigned xmb_theme = 0; + +#ifdef HAVE_LAKKA static bool xmb_shadows_enable = false; +#else +static bool xmb_shadows_enable = true; +#endif static unsigned menu_background_gradient = 4; From f1098d8f6a465a5500030cc20e160c2aa6b9640b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 1 May 2016 20:50:26 +0200 Subject: [PATCH 039/498] Style nit --- input/input_autodetect.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/input/input_autodetect.c b/input/input_autodetect.c index 3c6fd271f3..04bf746b6a 100644 --- a/input/input_autodetect.c +++ b/input/input_autodetect.c @@ -36,10 +36,10 @@ static void input_reindex_devices(void) unsigned i; settings_t *settings = config_get_ptr(); - for(i=0; i < settings->input.max_users; i++) + for(i = 0; i < settings->input.max_users; i++) settings->input.device_name_index[i]=0; - for(i=0; i < settings->input.max_users; i++) + for(i = 0; i < settings->input.max_users; i++) { unsigned j; const char *tmp = settings->input.device_names[i]; From b7447b1dfcff3b59895ff50b02d3b7e435030ca2 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 1 May 2016 20:54:30 +0200 Subject: [PATCH 040/498] Cleanup --- netplay/netplay.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/netplay/netplay.c b/netplay/netplay.c index b7dc3f33e1..8de27d093b 100644 --- a/netplay/netplay.c +++ b/netplay/netplay.c @@ -706,9 +706,8 @@ static bool init_tcp_socket(netplay_t *netplay, const char *server, char port_buf[16] = {0}; bool ret = false; const struct addrinfo *tmp_info = NULL; - struct addrinfo hints, *res = NULL; - - memset(&hints, 0, sizeof(hints)); + struct addrinfo *res = NULL; + struct addrinfo hints = {0}; #if defined(_WIN32) || defined(HAVE_SOCKET_LEGACY) hints.ai_family = AF_INET; From ad71c56ea43f09f53fb1c7b5f55d84e0859e1ab6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 1 May 2016 21:05:09 +0200 Subject: [PATCH 041/498] Create socket_init --- netplay/netplay.c | 40 +++++++++++++++++++++++++++++----------- 1 file changed, 29 insertions(+), 11 deletions(-) diff --git a/netplay/netplay.c b/netplay/netplay.c index 8de27d093b..d55bf5d2e8 100644 --- a/netplay/netplay.c +++ b/netplay/netplay.c @@ -758,13 +758,18 @@ static bool init_tcp_socket(netplay_t *netplay, const char *server, return ret; } -static bool init_udp_socket(netplay_t *netplay, const char *server, - uint16_t port) +static int socket_init(void *address, int *fd, uint16_t port, const char *server) { char port_buf[16] = {0}; struct addrinfo hints = {0}; + struct addrinfo *addr = (struct addrinfo*)address; + + if (!fd) + goto error; + + if (!network_init()) + goto error; - memset(&hints, 0, sizeof(hints)); #if defined(_WIN32) || defined(HAVE_SOCKET_LEGACY) hints.ai_family = AF_INET; #else @@ -776,16 +781,29 @@ static bool init_udp_socket(netplay_t *netplay, const char *server, snprintf(port_buf, sizeof(port_buf), "%hu", (unsigned short)port); - if (getaddrinfo_retro(server, port_buf, &hints, &netplay->addr) < 0) + if (getaddrinfo_retro(server, port_buf, &hints, &addr) < 0) + goto error; + + if (!addr) + goto error; + + *fd = socket(addr->ai_family, addr->ai_socktype, addr->ai_protocol); + + return true; + +error: + RARCH_ERR("Failed to initialize socket.\n"); + return false; +} + +static bool init_udp_socket(netplay_t *netplay, const char *server, + uint16_t port) +{ + int *file_desc = (int*)&netplay->udp_fd; + if (!socket_init(&netplay->addr, file_desc, port, server)) return false; - if (!netplay->addr) - return false; - - netplay->udp_fd = socket(netplay->addr->ai_family, - netplay->addr->ai_socktype, netplay->addr->ai_protocol); - - if (netplay->udp_fd < 0) + if (*file_desc < 0) { RARCH_ERR("Failed to initialize socket.\n"); return false; From a7b856b65f3f30556360bf1fa3cac2fdfa425ce0 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 1 May 2016 21:18:45 +0200 Subject: [PATCH 042/498] (libretro-common) Create net_socket --- Makefile.common | 1 + command.c | 29 +++-------- griffin/griffin.c | 1 + libretro-common/include/net/net_socket.h | 38 +++++++++++++++ libretro-common/net/net_socket.c | 62 ++++++++++++++++++++++++ netplay/netplay.c | 39 +-------------- 6 files changed, 110 insertions(+), 60 deletions(-) create mode 100644 libretro-common/include/net/net_socket.h create mode 100644 libretro-common/net/net_socket.c diff --git a/Makefile.common b/Makefile.common index 34dd5ee7b6..2dd16838ca 100644 --- a/Makefile.common +++ b/Makefile.common @@ -952,6 +952,7 @@ ifeq ($(HAVE_NETWORKING), 1) DEFINES += -DHAVE_NETWORKING OBJ += libretro-common/net/net_compat.o \ libretro-common/net/net_http.o \ + libretro-common/net/net_socket.o \ net_http_special.o \ tasks/task_http.o diff --git a/command.c b/command.c index 880ebf4407..81e8443521 100644 --- a/command.c +++ b/command.c @@ -26,6 +26,7 @@ #include #include #include +#include #include #include "msg_hash.h" @@ -122,41 +123,25 @@ static const struct cmd_map map[] = { #if defined(HAVE_NETWORK_CMD) && defined(HAVE_NETPLAY) static bool cmd_init_network(rarch_cmd_t *handle, uint16_t port) { - struct addrinfo hints = {0}; - char port_buf[16] = {0}; + int *file_desc = (int*)&handle->net_fd; struct addrinfo *res = NULL; int yes = 1; - if (!network_init()) - return false; - RARCH_LOG("Bringing up command interface on port %hu.\n", (unsigned short)port); -#if defined(_WIN32) || defined(HAVE_SOCKET_LEGACY) - hints.ai_family = AF_INET; -#else - hints.ai_family = AF_UNSPEC; -#endif - hints.ai_socktype = SOCK_DGRAM; - hints.ai_flags = AI_PASSIVE; - - - snprintf(port_buf, sizeof(port_buf), "%hu", (unsigned short)port); - if (getaddrinfo_retro(NULL, port_buf, &hints, &res) < 0) + if (!socket_init(res, file_desc, port, NULL)) goto error; - handle->net_fd = socket(res->ai_family, - res->ai_socktype, res->ai_protocol); - if (handle->net_fd < 0) + if (*file_desc < 0) goto error; - if (!socket_nonblock(handle->net_fd)) + if (!socket_nonblock(*file_desc)) goto error; - setsockopt(handle->net_fd, SOL_SOCKET, + setsockopt(*file_desc, SOL_SOCKET, SO_REUSEADDR, (const char*)&yes, sizeof(int)); - if (bind(handle->net_fd, res->ai_addr, res->ai_addrlen) < 0) + if (bind(*file_desc, res->ai_addr, res->ai_addrlen) < 0) { RARCH_ERR("Failed to bind socket.\n"); goto error; diff --git a/griffin/griffin.c b/griffin/griffin.c index 4750ff58ed..372ed7e00b 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -789,6 +789,7 @@ NETPLAY #include "../netplay/netplay_common.c" #include "../netplay/netplay.c" #include "../libretro-common/net/net_compat.c" +#include "../libretro-common/net/net_socket.c" #include "../libretro-common/net/net_http.c" #ifndef HAVE_SOCKET_LEGACY #include "../libretro-common/net/net_ifinfo.c" diff --git a/libretro-common/include/net/net_socket.h b/libretro-common/include/net/net_socket.h new file mode 100644 index 0000000000..871625d633 --- /dev/null +++ b/libretro-common/include/net/net_socket.h @@ -0,0 +1,38 @@ +/* Copyright (C) 2010-2016 The RetroArch team + * + * --------------------------------------------------------------------------------------- + * The following license statement only applies to this file (net_socket.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_NET_SOCKET_H +#define _LIBRETRO_SDK_NET_SOCKET_H + +#include +#include +#include + +#include + +RETRO_BEGIN_DECLS + +bool socket_init(void *address, int *fd, uint16_t port, const char *server); + +RETRO_END_DECLS + +#endif diff --git a/libretro-common/net/net_socket.c b/libretro-common/net/net_socket.c new file mode 100644 index 0000000000..760aff4b99 --- /dev/null +++ b/libretro-common/net/net_socket.c @@ -0,0 +1,62 @@ +/* Copyright (C) 2010-2016 The RetroArch team + * + * --------------------------------------------------------------------------------------- + * The following license statement only applies to this file (net_socket.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 + +bool socket_init(void *address, int *fd, uint16_t port, const char *server) +{ + char port_buf[16] = {0}; + struct addrinfo hints = {0}; + struct addrinfo *addr = (struct addrinfo*)address; + + if (!fd) + goto error; + + if (!network_init()) + goto error; + +#if defined(_WIN32) || defined(HAVE_SOCKET_LEGACY) + hints.ai_family = AF_INET; +#else + hints.ai_family = AF_UNSPEC; +#endif + hints.ai_socktype = SOCK_DGRAM; + if (!server) + hints.ai_flags = AI_PASSIVE; + + snprintf(port_buf, sizeof(port_buf), "%hu", (unsigned short)port); + + if (getaddrinfo_retro(server, port_buf, &hints, &addr) < 0) + goto error; + + if (!addr) + goto error; + + *fd = socket(addr->ai_family, addr->ai_socktype, addr->ai_protocol); + + return true; + +error: + return false; +} diff --git a/netplay/netplay.c b/netplay/netplay.c index d55bf5d2e8..785baf205a 100644 --- a/netplay/netplay.c +++ b/netplay/netplay.c @@ -23,6 +23,7 @@ #include #include +#include #include #include "netplay_private.h" @@ -758,44 +759,6 @@ static bool init_tcp_socket(netplay_t *netplay, const char *server, return ret; } -static int socket_init(void *address, int *fd, uint16_t port, const char *server) -{ - char port_buf[16] = {0}; - struct addrinfo hints = {0}; - struct addrinfo *addr = (struct addrinfo*)address; - - if (!fd) - goto error; - - if (!network_init()) - goto error; - -#if defined(_WIN32) || defined(HAVE_SOCKET_LEGACY) - hints.ai_family = AF_INET; -#else - hints.ai_family = AF_UNSPEC; -#endif - hints.ai_socktype = SOCK_DGRAM; - if (!server) - hints.ai_flags = AI_PASSIVE; - - snprintf(port_buf, sizeof(port_buf), "%hu", (unsigned short)port); - - if (getaddrinfo_retro(server, port_buf, &hints, &addr) < 0) - goto error; - - if (!addr) - goto error; - - *fd = socket(addr->ai_family, addr->ai_socktype, addr->ai_protocol); - - return true; - -error: - RARCH_ERR("Failed to initialize socket.\n"); - return false; -} - static bool init_udp_socket(netplay_t *netplay, const char *server, uint16_t port) { From 0268212d4079f25dc3ba6cacf5abb1b50740e567 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 1 May 2016 21:36:28 +0200 Subject: [PATCH 043/498] Move socket code to net_socket.c --- libretro-common/include/net/net_compat.h | 11 --- libretro-common/include/net/net_socket.h | 11 +++ libretro-common/net/net_compat.c | 85 ------------------------ libretro-common/net/net_socket.c | 85 ++++++++++++++++++++++++ 4 files changed, 96 insertions(+), 96 deletions(-) diff --git a/libretro-common/include/net/net_compat.h b/libretro-common/include/net/net_compat.h index 89cf4142c6..e8dd2ef372 100644 --- a/libretro-common/include/net/net_compat.h +++ b/libretro-common/include/net/net_compat.h @@ -217,17 +217,6 @@ int getaddrinfo_retro(const char *node, const char *service, void freeaddrinfo_retro(struct addrinfo *res); -bool socket_nonblock(int fd); - -int socket_close(int fd); - -int socket_select(int nfds, fd_set *readfs, fd_set *writefds, - fd_set *errorfds, struct timeval *timeout); - -int socket_send_all_blocking(int fd, const void *data_, size_t size); - -int socket_receive_all_blocking(int fd, void *data_, size_t size); - /** * network_init: * diff --git a/libretro-common/include/net/net_socket.h b/libretro-common/include/net/net_socket.h index 871625d633..d0dfac95e4 100644 --- a/libretro-common/include/net/net_socket.h +++ b/libretro-common/include/net/net_socket.h @@ -33,6 +33,17 @@ RETRO_BEGIN_DECLS bool socket_init(void *address, int *fd, uint16_t port, const char *server); +int socket_close(int fd); + +bool socket_nonblock(int fd); + +int socket_select(int nfds, fd_set *readfs, fd_set *writefds, + fd_set *errorfds, struct timeval *timeout); + +int socket_send_all_blocking(int fd, const void *data_, size_t size); + +int socket_receive_all_blocking(int fd, void *data_, size_t size); + RETRO_END_DECLS #endif diff --git a/libretro-common/net/net_compat.c b/libretro-common/net/net_compat.c index db6c644881..20106999b7 100644 --- a/libretro-common/net/net_compat.c +++ b/libretro-common/net/net_compat.c @@ -160,91 +160,6 @@ void freeaddrinfo_retro(struct addrinfo *res) #endif } -bool socket_nonblock(int fd) -{ -#if defined(__CELLOS_LV2__) || defined(VITA) - int i = 1; - setsockopt(fd, SOL_SOCKET, SO_NBIO, &i, sizeof(int)); - return true; -#elif defined(_WIN32) - u_long mode = 1; - return ioctlsocket(fd, FIONBIO, &mode) == 0; -#else - return fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK) == 0; -#endif -} - -int socket_close(int fd) -{ -#if defined(_WIN32) && !defined(_XBOX360) - /* WinSock has headers from the stone age. */ - return closesocket(fd); -#elif defined(__CELLOS_LV2__) - return socketclose(fd); -#elif defined(VITA) - return sceNetSocketClose(fd); -#else - return close(fd); -#endif -} - -int socket_select(int nfds, fd_set *readfs, fd_set *writefds, - fd_set *errorfds, struct timeval *timeout) -{ -#if defined(__CELLOS_LV2__) - return socketselect(nfds, readfs, writefds, errorfds, timeout); -#elif defined(VITA) - SceNetEpollEvent ev = {0}; - - ev.events = PSP2_NET_EPOLLIN | PSP2_NET_EPOLLHUP; - ev.data.fd = nfds; - - if((sceNetEpollControl(retro_epoll_fd, PSP2_NET_EPOLL_CTL_ADD, nfds, &ev))) - { - int ret = sceNetEpollWait(retro_epoll_fd, &ev, 1, 0); - sceNetEpollControl(retro_epoll_fd, PSP2_NET_EPOLL_CTL_DEL, nfds, NULL); - return ret; - } - return 0; -#else - return select(nfds, readfs, writefds, errorfds, timeout); -#endif -} - -int socket_send_all_blocking(int fd, const void *data_, size_t size) -{ - const uint8_t *data = (const uint8_t*)data_; - - while (size) - { - ssize_t ret = send(fd, (const char*)data, size, 0); - if (ret <= 0) - return false; - - data += ret; - size -= ret; - } - - return true; -} - -int socket_receive_all_blocking(int fd, void *data_, size_t size) -{ - const uint8_t *data = (const uint8_t*)data_; - - while (size) - { - ssize_t ret = recv(fd, (char*)data, size, 0); - if (ret <= 0) - return false; - - data += ret; - size -= ret; - } - - return true; -} - /** * network_init: * diff --git a/libretro-common/net/net_socket.c b/libretro-common/net/net_socket.c index 760aff4b99..ce02827a46 100644 --- a/libretro-common/net/net_socket.c +++ b/libretro-common/net/net_socket.c @@ -60,3 +60,88 @@ bool socket_init(void *address, int *fd, uint16_t port, const char *server) error: return false; } + +int socket_receive_all_blocking(int fd, void *data_, size_t size) +{ + const uint8_t *data = (const uint8_t*)data_; + + while (size) + { + ssize_t ret = recv(fd, (char*)data, size, 0); + if (ret <= 0) + return false; + + data += ret; + size -= ret; + } + + return true; +} + +bool socket_nonblock(int fd) +{ +#if defined(__CELLOS_LV2__) || defined(VITA) + int i = 1; + setsockopt(fd, SOL_SOCKET, SO_NBIO, &i, sizeof(int)); + return true; +#elif defined(_WIN32) + u_long mode = 1; + return ioctlsocket(fd, FIONBIO, &mode) == 0; +#else + return fcntl(fd, F_SETFL, fcntl(fd, F_GETFL) | O_NONBLOCK) == 0; +#endif +} + +int socket_close(int fd) +{ +#if defined(_WIN32) && !defined(_XBOX360) + /* WinSock has headers from the stone age. */ + return closesocket(fd); +#elif defined(__CELLOS_LV2__) + return socketclose(fd); +#elif defined(VITA) + return sceNetSocketClose(fd); +#else + return close(fd); +#endif +} + +int socket_select(int nfds, fd_set *readfs, fd_set *writefds, + fd_set *errorfds, struct timeval *timeout) +{ +#if defined(__CELLOS_LV2__) + return socketselect(nfds, readfs, writefds, errorfds, timeout); +#elif defined(VITA) + SceNetEpollEvent ev = {0}; + + ev.events = PSP2_NET_EPOLLIN | PSP2_NET_EPOLLHUP; + ev.data.fd = nfds; + + if((sceNetEpollControl(retro_epoll_fd, PSP2_NET_EPOLL_CTL_ADD, nfds, &ev))) + { + int ret = sceNetEpollWait(retro_epoll_fd, &ev, 1, 0); + sceNetEpollControl(retro_epoll_fd, PSP2_NET_EPOLL_CTL_DEL, nfds, NULL); + return ret; + } + return 0; +#else + return select(nfds, readfs, writefds, errorfds, timeout); +#endif +} + +int socket_send_all_blocking(int fd, const void *data_, size_t size) +{ + const uint8_t *data = (const uint8_t*)data_; + + while (size) + { + ssize_t ret = send(fd, (const char*)data, size, 0); + if (ret <= 0) + return false; + + data += ret; + size -= ret; + } + + return true; +} From d2a80e26dbfb3a8c6d14b42811b25a2ebb6e11ed Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Sun, 1 May 2016 21:38:19 +0200 Subject: [PATCH 044/498] Buildfixes --- libretro-common/net/net_compat.c | 1 + netplay/netplay_spectate.c | 1 + 2 files changed, 2 insertions(+) diff --git a/libretro-common/net/net_compat.c b/libretro-common/net/net_compat.c index 20106999b7..078d1d6589 100644 --- a/libretro-common/net/net_compat.c +++ b/libretro-common/net/net_compat.c @@ -26,6 +26,7 @@ #include #include +#include #include #if defined(VITA) diff --git a/netplay/netplay_spectate.c b/netplay/netplay_spectate.c index 6ea9fca99f..b6d4411259 100644 --- a/netplay/netplay_spectate.c +++ b/netplay/netplay_spectate.c @@ -19,6 +19,7 @@ #include #include +#include #include #include "netplay_private.h" From 8b9456f4191cae585f1e322f3c0d03bcd7e93074 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 1 May 2016 22:25:23 +0200 Subject: [PATCH 045/498] Add socket_type to socket_init --- command.c | 2 +- libretro-common/include/net/net_socket.h | 8 +++++++- libretro-common/net/net_socket.c | 13 +++++++++++-- netplay/netplay.c | 2 +- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/command.c b/command.c index 81e8443521..2fdcef7b13 100644 --- a/command.c +++ b/command.c @@ -130,7 +130,7 @@ static bool cmd_init_network(rarch_cmd_t *handle, uint16_t port) RARCH_LOG("Bringing up command interface on port %hu.\n", (unsigned short)port); - if (!socket_init(res, file_desc, port, NULL)) + if (!socket_init(res, file_desc, port, NULL, SOCKET_TYPE_DATAGRAM)) goto error; if (*file_desc < 0) diff --git a/libretro-common/include/net/net_socket.h b/libretro-common/include/net/net_socket.h index d0dfac95e4..742c973315 100644 --- a/libretro-common/include/net/net_socket.h +++ b/libretro-common/include/net/net_socket.h @@ -31,7 +31,13 @@ RETRO_BEGIN_DECLS -bool socket_init(void *address, int *fd, uint16_t port, const char *server); +enum socket_type +{ + SOCKET_TYPE_DATAGRAM = 0, + SOCKET_TYPE_STREAM +}; + +bool socket_init(void *address, int *fd, uint16_t port, const char *server, enum socket_type type); int socket_close(int fd); diff --git a/libretro-common/net/net_socket.c b/libretro-common/net/net_socket.c index ce02827a46..fd0f640f66 100644 --- a/libretro-common/net/net_socket.c +++ b/libretro-common/net/net_socket.c @@ -24,7 +24,7 @@ #include #include -bool socket_init(void *address, int *fd, uint16_t port, const char *server) +bool socket_init(void *address, int *fd, uint16_t port, const char *server, enum socket_type type) { char port_buf[16] = {0}; struct addrinfo hints = {0}; @@ -41,7 +41,16 @@ bool socket_init(void *address, int *fd, uint16_t port, const char *server) #else hints.ai_family = AF_UNSPEC; #endif - hints.ai_socktype = SOCK_DGRAM; + + switch (type) + { + case SOCKET_TYPE_DATAGRAM: + hints.ai_socktype = SOCK_DGRAM; + break; + case SOCKET_TYPE_STREAM: + hints.ai_socktype = SOCK_STREAM; + break; + } if (!server) hints.ai_flags = AI_PASSIVE; diff --git a/netplay/netplay.c b/netplay/netplay.c index 785baf205a..0c660976d7 100644 --- a/netplay/netplay.c +++ b/netplay/netplay.c @@ -763,7 +763,7 @@ static bool init_udp_socket(netplay_t *netplay, const char *server, uint16_t port) { int *file_desc = (int*)&netplay->udp_fd; - if (!socket_init(&netplay->addr, file_desc, port, server)) + if (!socket_init(&netplay->addr, file_desc, port, server, SOCKET_TYPE_DATAGRAM)) return false; if (*file_desc < 0) From 78bb85e2f3cc5138b3bc3d2d275f2e75a2c26850 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 1 May 2016 22:45:32 +0200 Subject: [PATCH 046/498] Reuse socket_init for net_http code --- command.c | 14 ++++++------- libretro-common/include/net/net_socket.h | 2 +- libretro-common/net/net_http.c | 25 +++++------------------- libretro-common/net/net_socket.c | 20 +++++++++---------- netplay/netplay.c | 6 ++---- 5 files changed, 24 insertions(+), 43 deletions(-) diff --git a/command.c b/command.c index 2fdcef7b13..23ececc44e 100644 --- a/command.c +++ b/command.c @@ -123,25 +123,23 @@ static const struct cmd_map map[] = { #if defined(HAVE_NETWORK_CMD) && defined(HAVE_NETPLAY) static bool cmd_init_network(rarch_cmd_t *handle, uint16_t port) { - int *file_desc = (int*)&handle->net_fd; struct addrinfo *res = NULL; int yes = 1; RARCH_LOG("Bringing up command interface on port %hu.\n", (unsigned short)port); - if (!socket_init(res, file_desc, port, NULL, SOCKET_TYPE_DATAGRAM)) + handle->net_fd = socket_init((void**)&res, port, NULL, SOCKET_TYPE_DATAGRAM); + + if (handle->net_fd < 0) goto error; - if (*file_desc < 0) + if (!socket_nonblock(handle->net_fd)) goto error; - if (!socket_nonblock(*file_desc)) - goto error; - - setsockopt(*file_desc, SOL_SOCKET, + setsockopt(handle->net_fd, SOL_SOCKET, SO_REUSEADDR, (const char*)&yes, sizeof(int)); - if (bind(*file_desc, res->ai_addr, res->ai_addrlen) < 0) + if (bind(handle->net_fd, res->ai_addr, res->ai_addrlen) < 0) { RARCH_ERR("Failed to bind socket.\n"); goto error; diff --git a/libretro-common/include/net/net_socket.h b/libretro-common/include/net/net_socket.h index 742c973315..b58fd0c4dc 100644 --- a/libretro-common/include/net/net_socket.h +++ b/libretro-common/include/net/net_socket.h @@ -37,7 +37,7 @@ enum socket_type SOCKET_TYPE_STREAM }; -bool socket_init(void *address, int *fd, uint16_t port, const char *server, enum socket_type type); +int socket_init(void **address, uint16_t port, const char *server, enum socket_type type); int socket_close(int fd); diff --git a/libretro-common/net/net_http.c b/libretro-common/net/net_http.c index 0ea58eecd7..7052520b17 100644 --- a/libretro-common/net/net_http.c +++ b/libretro-common/net/net_http.c @@ -26,6 +26,7 @@ #include #include +#include #include enum @@ -72,34 +73,17 @@ struct http_connection_t static int net_http_new_socket(const char *domain, int port) { - int fd; int ret; #ifndef _WIN32 #ifndef VITA struct timeval timeout; #endif #endif - struct addrinfo hints, *addr = NULL; - char portstr[16] = {0}; - - /* Initialize the network. */ - if (!network_init()) + struct addrinfo *addr = NULL; + int fd = socket_init((void**)&addr, port, domain, SOCKET_TYPE_STREAM); + if (fd == -1) return -1; - snprintf(portstr, sizeof(portstr), "%i", port); - - memset(&hints, 0, sizeof(hints)); - hints.ai_family = AF_UNSPEC; - hints.ai_socktype = SOCK_STREAM; - hints.ai_flags = 0; - - if (getaddrinfo_retro(domain, portstr, &hints, &addr) < 0) - return -1; - if (!addr) - return -1; - - fd = socket(addr->ai_family, addr->ai_socktype, addr->ai_protocol); - #ifndef _WIN32 #ifndef VITA timeout.tv_sec=4; @@ -107,6 +91,7 @@ static int net_http_new_socket(const char *domain, int port) setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, (char*)&timeout, sizeof timeout); #endif #endif + ret = connect(fd, addr->ai_addr, addr->ai_addrlen); freeaddrinfo_retro(addr); diff --git a/libretro-common/net/net_socket.c b/libretro-common/net/net_socket.c index fd0f640f66..5fd0ff67b9 100644 --- a/libretro-common/net/net_socket.c +++ b/libretro-common/net/net_socket.c @@ -24,14 +24,13 @@ #include #include -bool socket_init(void *address, int *fd, uint16_t port, const char *server, enum socket_type type) +int socket_init(void **address, uint16_t port, const char *server, enum socket_type type) { char port_buf[16] = {0}; struct addrinfo hints = {0}; - struct addrinfo *addr = (struct addrinfo*)address; - - if (!fd) - goto error; + struct addrinfo **addrinfo = (struct addrinfo**)address; + struct addrinfo *addr = NULL; + if (!network_init()) goto error; @@ -51,23 +50,24 @@ bool socket_init(void *address, int *fd, uint16_t port, const char *server, enum hints.ai_socktype = SOCK_STREAM; break; } + if (!server) hints.ai_flags = AI_PASSIVE; snprintf(port_buf, sizeof(port_buf), "%hu", (unsigned short)port); - if (getaddrinfo_retro(server, port_buf, &hints, &addr) < 0) + if (getaddrinfo_retro(server, port_buf, &hints, addrinfo) < 0) goto error; + addr = (struct addrinfo*)*addrinfo; + if (!addr) goto error; - *fd = socket(addr->ai_family, addr->ai_socktype, addr->ai_protocol); - - return true; + return socket(addr->ai_family, addr->ai_socktype, addr->ai_protocol); error: - return false; + return -1; } int socket_receive_all_blocking(int fd, void *data_, size_t size) diff --git a/netplay/netplay.c b/netplay/netplay.c index 0c660976d7..7cbdc835c2 100644 --- a/netplay/netplay.c +++ b/netplay/netplay.c @@ -762,11 +762,9 @@ static bool init_tcp_socket(netplay_t *netplay, const char *server, static bool init_udp_socket(netplay_t *netplay, const char *server, uint16_t port) { - int *file_desc = (int*)&netplay->udp_fd; - if (!socket_init(&netplay->addr, file_desc, port, server, SOCKET_TYPE_DATAGRAM)) - return false; + netplay->udp_fd = socket_init((void**)&netplay->addr, port, server, SOCKET_TYPE_DATAGRAM); - if (*file_desc < 0) + if (netplay->udp_fd < 0) { RARCH_ERR("Failed to initialize socket.\n"); return false; From 004d9a613c395a0b510aafc4e5270e3a82b6c6b5 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 1 May 2016 22:57:44 +0200 Subject: [PATCH 047/498] Create socket_bind --- command.c | 5 +---- libretro-common/include/net/net_socket.h | 2 ++ libretro-common/net/net_socket.c | 11 +++++++++++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/command.c b/command.c index 23ececc44e..083ac124b0 100644 --- a/command.c +++ b/command.c @@ -124,7 +124,6 @@ static const struct cmd_map map[] = { static bool cmd_init_network(rarch_cmd_t *handle, uint16_t port) { struct addrinfo *res = NULL; - int yes = 1; RARCH_LOG("Bringing up command interface on port %hu.\n", (unsigned short)port); @@ -137,9 +136,7 @@ static bool cmd_init_network(rarch_cmd_t *handle, uint16_t port) if (!socket_nonblock(handle->net_fd)) goto error; - setsockopt(handle->net_fd, SOL_SOCKET, - SO_REUSEADDR, (const char*)&yes, sizeof(int)); - if (bind(handle->net_fd, res->ai_addr, res->ai_addrlen) < 0) + if (!socket_bind(handle->net_fd, res)) { RARCH_ERR("Failed to bind socket.\n"); goto error; diff --git a/libretro-common/include/net/net_socket.h b/libretro-common/include/net/net_socket.h index b58fd0c4dc..d5929ff0ea 100644 --- a/libretro-common/include/net/net_socket.h +++ b/libretro-common/include/net/net_socket.h @@ -50,6 +50,8 @@ int socket_send_all_blocking(int fd, const void *data_, size_t size); int socket_receive_all_blocking(int fd, void *data_, size_t size); +bool socket_bind(int fd, void *data); + RETRO_END_DECLS #endif diff --git a/libretro-common/net/net_socket.c b/libretro-common/net/net_socket.c index 5fd0ff67b9..e236d915c6 100644 --- a/libretro-common/net/net_socket.c +++ b/libretro-common/net/net_socket.c @@ -154,3 +154,14 @@ int socket_send_all_blocking(int fd, const void *data_, size_t size) return true; } + +bool socket_bind(int fd, void *data) +{ + int yes = 1; + struct addrinfo *res = (struct addrinfo*)data; + setsockopt(fd, SOL_SOCKET, + SO_REUSEADDR, (const char*)&yes, sizeof(int)); + if (bind(fd, res->ai_addr, res->ai_addrlen) < 0) + return false; + return true; +} From f4762f6f33b4f192205e201fad279928f79a4c25 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 1 May 2016 22:59:35 +0200 Subject: [PATCH 048/498] (netplay.c) Use socket_bind --- command.c | 2 +- netplay/netplay.c | 5 +---- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/command.c b/command.c index 083ac124b0..0994d77652 100644 --- a/command.c +++ b/command.c @@ -136,7 +136,7 @@ static bool cmd_init_network(rarch_cmd_t *handle, uint16_t port) if (!socket_nonblock(handle->net_fd)) goto error; - if (!socket_bind(handle->net_fd, res)) + if (!socket_bind(handle->net_fd, (void*)res)) { RARCH_ERR("Failed to bind socket.\n"); goto error; diff --git a/netplay/netplay.c b/netplay/netplay.c index 7cbdc835c2..cbf9113929 100644 --- a/netplay/netplay.c +++ b/netplay/netplay.c @@ -667,10 +667,7 @@ static int init_tcp_connection(const struct addrinfo *res, } else { - int yes = 1; - setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (const char*)&yes, sizeof(int)); - - if (bind(fd, res->ai_addr, res->ai_addrlen) < 0 || + if ( !socket_bind(fd, (void*)res) || listen(fd, spectate ? MAX_SPECTATORS : 1) < 0) { ret = false; From b979af0a8c352df3be5136d00ca83d5c1af2cf88 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 1 May 2016 23:00:54 +0200 Subject: [PATCH 049/498] (netplay.c) Reuse it another time --- netplay/netplay.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/netplay/netplay.c b/netplay/netplay.c index cbf9113929..579f796a0f 100644 --- a/netplay/netplay.c +++ b/netplay/netplay.c @@ -770,13 +770,7 @@ static bool init_udp_socket(netplay_t *netplay, const char *server, if (!server) { /* Not sure if we have to do this for UDP, but hey :) */ - int yes = 1; - - setsockopt(netplay->udp_fd, SOL_SOCKET, SO_REUSEADDR, - (const char*)&yes, sizeof(int)); - - if (bind(netplay->udp_fd, netplay->addr->ai_addr, - netplay->addr->ai_addrlen) < 0) + if (!socket_bind(netplay->udp_fd, (void*)netplay->addr)) { RARCH_ERR("Failed to bind socket.\n"); socket_close(netplay->udp_fd); From 3d7b7f6afa0ee9c0f9377714b8f2e0337935e18a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 1 May 2016 23:01:41 +0200 Subject: [PATCH 050/498] init_udp_socket - cleanups --- netplay/netplay.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/netplay/netplay.c b/netplay/netplay.c index 579f796a0f..bed296d9f5 100644 --- a/netplay/netplay.c +++ b/netplay/netplay.c @@ -762,10 +762,7 @@ static bool init_udp_socket(netplay_t *netplay, const char *server, netplay->udp_fd = socket_init((void**)&netplay->addr, port, server, SOCKET_TYPE_DATAGRAM); if (netplay->udp_fd < 0) - { - RARCH_ERR("Failed to initialize socket.\n"); - return false; - } + goto error; if (!server) { @@ -782,6 +779,10 @@ static bool init_udp_socket(netplay_t *netplay, const char *server, } return true; + +error: + RARCH_ERR("Failed to initialize socket.\n"); + return false; } static bool init_socket(netplay_t *netplay, const char *server, uint16_t port) From bd9dd06dddb19a83eb446284fc321945b1ce89be Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 1 May 2016 23:17:17 +0200 Subject: [PATCH 051/498] Get rid of duplicate function net_http_send --- libretro-common/include/net/net_socket.h | 2 +- libretro-common/net/net_http.c | 32 +++++------------------- libretro-common/net/net_socket.c | 11 ++++++-- netplay/netplay.c | 8 +++--- netplay/netplay_spectate.c | 5 ++-- 5 files changed, 23 insertions(+), 35 deletions(-) diff --git a/libretro-common/include/net/net_socket.h b/libretro-common/include/net/net_socket.h index d5929ff0ea..15b0785a14 100644 --- a/libretro-common/include/net/net_socket.h +++ b/libretro-common/include/net/net_socket.h @@ -46,7 +46,7 @@ bool socket_nonblock(int fd); int socket_select(int nfds, fd_set *readfs, fd_set *writefds, fd_set *errorfds, struct timeval *timeout); -int socket_send_all_blocking(int fd, const void *data_, size_t size); +int socket_send_all_blocking(int fd, const void *data_, size_t size, bool no_signal); int socket_receive_all_blocking(int fd, void *data_, size_t size); diff --git a/libretro-common/net/net_http.c b/libretro-common/net/net_http.c index 7052520b17..df0eb39d26 100644 --- a/libretro-common/net/net_http.c +++ b/libretro-common/net/net_http.c @@ -109,36 +109,16 @@ error: return -1; } -static void net_http_send(int fd, bool * error, - const char * data, size_t len) -{ - if (*error) - return; - - while (len) - { - ssize_t thislen = send(fd, data, len, MSG_NOSIGNAL); - - if (thislen <= 0) - { - if (!isagain(thislen)) - continue; - - *error=true; - return; - } - - data += thislen; - len -= thislen; - } -} - static void net_http_send_str(int fd, bool *error, const char *text) { #if 0 printf("%s",text); #endif - net_http_send(fd, error, text, strlen(text)); + if (!*error) + { + if (!socket_send_all_blocking(fd, text, strlen(text), true)) + *error = true; + } } static ssize_t net_http_recv(int fd, bool *error, @@ -298,7 +278,7 @@ struct http_t *net_http_new(struct http_connection_t *conn) if (fd == -1) goto error; - error=false; + error = false; /* This is a bit lazy, but it works. */ net_http_send_str(fd, &error, "GET /"); diff --git a/libretro-common/net/net_socket.c b/libretro-common/net/net_socket.c index e236d915c6..45f7724276 100644 --- a/libretro-common/net/net_socket.c +++ b/libretro-common/net/net_socket.c @@ -138,15 +138,22 @@ int socket_select(int nfds, fd_set *readfs, fd_set *writefds, #endif } -int socket_send_all_blocking(int fd, const void *data_, size_t size) +int socket_send_all_blocking(int fd, const void *data_, size_t size, + bool no_signal) { const uint8_t *data = (const uint8_t*)data_; while (size) { - ssize_t ret = send(fd, (const char*)data, size, 0); + ssize_t ret = send(fd, (const char*)data, size, + no_signal ? MSG_NOSIGNAL : 0); if (ret <= 0) + { + if (!isagain(ret)) + continue; + return false; + } data += ret; size -= ret; diff --git a/netplay/netplay.c b/netplay/netplay.c index bed296d9f5..b6fc9feb96 100644 --- a/netplay/netplay.c +++ b/netplay/netplay.c @@ -200,13 +200,13 @@ static bool get_self_input_state(netplay_t *netplay) static bool netplay_cmd_ack(netplay_t *netplay) { uint32_t cmd = htonl(NETPLAY_CMD_ACK); - return socket_send_all_blocking(netplay->fd, &cmd, sizeof(cmd)); + return socket_send_all_blocking(netplay->fd, &cmd, sizeof(cmd), false); } static bool netplay_cmd_nak(netplay_t *netplay) { uint32_t cmd = htonl(NETPLAY_CMD_NAK); - return socket_send_all_blocking(netplay->fd, &cmd, sizeof(cmd)); + return socket_send_all_blocking(netplay->fd, &cmd, sizeof(cmd), false); } static bool netplay_get_response(netplay_t *netplay) @@ -866,10 +866,10 @@ static bool netplay_send_raw_cmd(netplay_t *netplay, uint32_t cmd, cmd = (cmd << 16) | (size & 0xffff); cmd = htonl(cmd); - if (!socket_send_all_blocking(netplay->fd, &cmd, sizeof(cmd))) + if (!socket_send_all_blocking(netplay->fd, &cmd, sizeof(cmd), false)) return false; - if (!socket_send_all_blocking(netplay->fd, data, size)) + if (!socket_send_all_blocking(netplay->fd, data, size, false)) return false; return true; diff --git a/netplay/netplay_spectate.c b/netplay/netplay_spectate.c index b6d4411259..d257c61212 100644 --- a/netplay/netplay_spectate.c +++ b/netplay/netplay_spectate.c @@ -106,7 +106,7 @@ static void netplay_spectate_pre_frame(netplay_t *netplay) setsockopt(new_fd, SOL_SOCKET, SO_SNDBUF, (const char*)&bufsize, sizeof(int)); - if (!socket_send_all_blocking(new_fd, header, header_size)) + if (!socket_send_all_blocking(new_fd, header, header_size, false)) { RARCH_ERR("Failed to send header to client.\n"); socket_close(new_fd); @@ -145,7 +145,8 @@ static void netplay_spectate_post_frame(netplay_t *netplay) if (socket_send_all_blocking(netplay->spectate.fds[i], netplay->spectate.input, - netplay->spectate.input_ptr * sizeof(int16_t))) + netplay->spectate.input_ptr * sizeof(int16_t), + false)) continue; RARCH_LOG("Client (#%u) disconnected ...\n", i); From d0708fc8321f997812b67b3659bb12d4d8a2e05e Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Sun, 1 May 2016 23:21:30 +0200 Subject: [PATCH 052/498] (Netplay) Buildfixes --- netplay/netplay_common.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/netplay/netplay_common.c b/netplay/netplay_common.c index 247ab4d852..1589fd41f6 100644 --- a/netplay/netplay_common.c +++ b/netplay/netplay_common.c @@ -45,13 +45,13 @@ bool np_send_nickname(netplay_t *netplay, int fd) { uint8_t nick_size = strlen(netplay->nick); - if (!socket_send_all_blocking(fd, &nick_size, sizeof(nick_size))) + if (!socket_send_all_blocking(fd, &nick_size, sizeof(nick_size), false)) { RARCH_ERR("Failed to send nick size.\n"); return false; } - if (!socket_send_all_blocking(fd, netplay->nick, nick_size)) + if (!socket_send_all_blocking(fd, netplay->nick, nick_size, false)) { RARCH_ERR("Failed to send nick.\n"); return false; @@ -210,7 +210,7 @@ bool np_send_info(netplay_t *netplay) header[1] = htonl(np_impl_magic()); header[2] = htonl(mem_info.size); - if (!socket_send_all_blocking(netplay->fd, header, sizeof(header))) + if (!socket_send_all_blocking(netplay->fd, header, sizeof(header), false)) return false; if (!np_send_nickname(netplay, netplay->fd)) @@ -291,7 +291,7 @@ bool np_get_info(netplay_t *netplay) sram = mem_info.data; sram_size = mem_info.size; - if (!socket_send_all_blocking(netplay->fd, sram, sram_size)) + if (!socket_send_all_blocking(netplay->fd, sram, sram_size, false)) { RARCH_ERR("Failed to send SRAM data to client.\n"); return false; From 2b3eeef2fabd19d8cc80957f3a7434f1f38f6fc8 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 1 May 2016 23:37:49 +0200 Subject: [PATCH 053/498] Avoid warnings --- netplay/netplay_common.c | 1 + 1 file changed, 1 insertion(+) diff --git a/netplay/netplay_common.c b/netplay/netplay_common.c index 1589fd41f6..b27f8de36b 100644 --- a/netplay/netplay_common.c +++ b/netplay/netplay_common.c @@ -15,6 +15,7 @@ */ #include "netplay_private.h" +#include #include "../content.h" bool np_get_nickname(netplay_t *netplay, int fd) From 2e1fa648b8ad7969ab16bf4dd75a86ea978d786b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 1 May 2016 23:45:59 +0200 Subject: [PATCH 054/498] Create socket_connect --- libretro-common/include/net/net_socket.h | 2 ++ libretro-common/net/net_http.c | 15 +-------------- libretro-common/net/net_socket.c | 20 ++++++++++++++++++++ netplay/netplay.c | 2 +- 4 files changed, 24 insertions(+), 15 deletions(-) diff --git a/libretro-common/include/net/net_socket.h b/libretro-common/include/net/net_socket.h index 15b0785a14..31960cd96e 100644 --- a/libretro-common/include/net/net_socket.h +++ b/libretro-common/include/net/net_socket.h @@ -52,6 +52,8 @@ int socket_receive_all_blocking(int fd, void *data_, size_t size); bool socket_bind(int fd, void *data); +int socket_connect(int fd, void *data, bool timeout_enable); + RETRO_END_DECLS #endif diff --git a/libretro-common/net/net_http.c b/libretro-common/net/net_http.c index df0eb39d26..46d2a462b2 100644 --- a/libretro-common/net/net_http.c +++ b/libretro-common/net/net_http.c @@ -74,25 +74,12 @@ struct http_connection_t static int net_http_new_socket(const char *domain, int port) { int ret; -#ifndef _WIN32 -#ifndef VITA - struct timeval timeout; -#endif -#endif struct addrinfo *addr = NULL; int fd = socket_init((void**)&addr, port, domain, SOCKET_TYPE_STREAM); if (fd == -1) return -1; -#ifndef _WIN32 -#ifndef VITA - timeout.tv_sec=4; - timeout.tv_usec=0; - setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, (char*)&timeout, sizeof timeout); -#endif -#endif - - ret = connect(fd, addr->ai_addr, addr->ai_addrlen); + ret = socket_connect(fd, (void*)addr, true); freeaddrinfo_retro(addr); diff --git a/libretro-common/net/net_socket.c b/libretro-common/net/net_socket.c index 45f7724276..b1e827775d 100644 --- a/libretro-common/net/net_socket.c +++ b/libretro-common/net/net_socket.c @@ -172,3 +172,23 @@ bool socket_bind(int fd, void *data) return false; return true; } + +int socket_connect(int fd, void *data, bool timeout_enable) +{ + struct addrinfo *addr = (struct addrinfo*)data; + +#ifndef _WIN32 +#ifndef VITA + if (timeout_enable) + { + struct timeval timeout; + timeout.tv_sec = 4; + timeout.tv_usec = 0; + + setsockopt(fd, SOL_SOCKET, SO_SNDTIMEO, (char*)&timeout, sizeof timeout); + } +#endif +#endif + + return connect(fd, addr->ai_addr, addr->ai_addrlen); +} diff --git a/netplay/netplay.c b/netplay/netplay.c index b6fc9feb96..e12f95bce7 100644 --- a/netplay/netplay.c +++ b/netplay/netplay.c @@ -659,7 +659,7 @@ static int init_tcp_connection(const struct addrinfo *res, if (server) { - if (connect(fd, res->ai_addr, res->ai_addrlen) < 0) + if (socket_connect(fd, (void*)res, false) < 0) { ret = false; goto end; From f11a24019094e8746db4e208ed74b1e1cf16596e Mon Sep 17 00:00:00 2001 From: Alcaro Date: Sun, 1 May 2016 23:48:04 +0200 Subject: [PATCH 055/498] Clean up the error handlers around here. --- libretro-common/net/net_http.c | 97 ++++++++++++++++------------------ 1 file changed, 47 insertions(+), 50 deletions(-) diff --git a/libretro-common/net/net_http.c b/libretro-common/net/net_http.c index 46d2a462b2..350fc30015 100644 --- a/libretro-common/net/net_http.c +++ b/libretro-common/net/net_http.c @@ -48,17 +48,17 @@ enum struct http_t { - int fd; - int status; - - char part; - char bodytype; - bool error; - - size_t pos; - size_t len; - size_t buflen; - char * data; + int fd; + int status; + + char part; + char bodytype; + bool error; + + size_t pos; + size_t len; + size_t buflen; + char * data; }; struct http_connection_t @@ -76,14 +76,14 @@ static int net_http_new_socket(const char *domain, int port) int ret; struct addrinfo *addr = NULL; int fd = socket_init((void**)&addr, port, domain, SOCKET_TYPE_STREAM); - if (fd == -1) + if (fd < 0) return -1; ret = socket_connect(fd, (void*)addr, true); freeaddrinfo_retro(addr); - if (ret != 0) + if (ret < 0) goto error; if (!socket_nonblock(fd)) @@ -98,9 +98,6 @@ error: static void net_http_send_str(int fd, bool *error, const char *text) { -#if 0 - printf("%s",text); -#endif if (!*error) { if (!socket_send_all_blocking(fd, text, strlen(text), true)) @@ -131,36 +128,36 @@ static ssize_t net_http_recv(int fd, bool *error, static char* urlencode(const char* url) { - unsigned i; - int outpos = 0; - int outlen = 0; + unsigned i; + unsigned outpos = 0; + unsigned outlen = 0; char *ret = NULL; - for (i = 0; url[i] != '\0'; i++) - { - outlen++; - if (url[i] == ' ') + for (i = 0; url[i] != '\0'; i++) + { + outlen++; + if (url[i] == ' ') outlen += 2; - } - - ret = (char*)malloc(outlen + 1); - if (!ret) + } + + ret = (char*)malloc(outlen + 1); + if (!ret) return NULL; - - for (i = 0; url[i]; i++) - { - if (url[i] == ' ') - { - ret[outpos++] = '%'; - ret[outpos++] = '2'; - ret[outpos++] = '0'; - } - else + + for (i = 0; url[i]; i++) + { + if (url[i] == ' ') + { + ret[outpos++] = '%'; + ret[outpos++] = '2'; + ret[outpos++] = '0'; + } + else ret[outpos++] = url[i]; - } - ret[outpos] = '\0'; - - return ret; + } + ret[outpos] = '\0'; + + return ret; } struct http_connection_t *net_http_connection_new(const char *url) @@ -262,7 +259,7 @@ struct http_t *net_http_new(struct http_connection_t *conn) goto error; fd = net_http_new_socket(conn->domain, conn->port); - if (fd == -1) + if (fd < 0) goto error; error = false; @@ -308,7 +305,7 @@ struct http_t *net_http_new(struct http_connection_t *conn) return state; error: - if (fd != -1) + if (fd >= 0) socket_close(fd); return NULL; } @@ -316,7 +313,7 @@ error: int net_http_fd(struct http_t *state) { if (!state) - return 0; + return -1; return state->fd; } @@ -432,8 +429,8 @@ parse_again: */ char *fullend = state->data + state->pos; - char *end = (char*)memchr(state->data + state->len + 2, - '\n', state->pos - state->len - 2); + char *end = (char*)memchr(state->data + state->len + 2, '\n', + state->pos - state->len - 2); if (end) { @@ -520,9 +517,9 @@ fail: int net_http_status(struct http_t *state) { - if (state) - return state->status; - return -1; + if (!state) + return -1; + return state->status; } uint8_t* net_http_data(struct http_t *state, size_t* len, bool accept_error) @@ -548,7 +545,7 @@ void net_http_delete(struct http_t *state) if (!state) return; - if (state->fd != -1) + if (state->fd >= 0) socket_close(state->fd); free(state); } From c2d6ecdc8622e87b40146cadfeafc21d22293357 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 1 May 2016 23:52:55 +0200 Subject: [PATCH 056/498] Include header --- remote.c | 1 + 1 file changed, 1 insertion(+) diff --git a/remote.c b/remote.c index 48f2539c81..69fe782c4b 100644 --- a/remote.c +++ b/remote.c @@ -27,6 +27,7 @@ #include #include #include +#include #include "remote.h" From 3adbbc0bdeeba162e7ed99d84f2d13b6b286b8a6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 2 May 2016 00:05:33 +0200 Subject: [PATCH 057/498] (netlogger.c) Start using net_socket --- Makefile.ps3.salamander | 4 +++- Makefile.wii.salamander | 4 +++- netlogger.c | 22 ++++++++-------------- 3 files changed, 14 insertions(+), 16 deletions(-) diff --git a/Makefile.ps3.salamander b/Makefile.ps3.salamander index 67c7b99bee..2ace35ff76 100644 --- a/Makefile.ps3.salamander +++ b/Makefile.ps3.salamander @@ -37,7 +37,9 @@ PPU_SRCS = frontend/frontend_salamander.c \ ifeq ($(HAVE_LOGGER), 1) PPU_CFLAGS += -DHAVE_LOGGER -PPU_SRCS += netlogger.c +PPU_SRCS += netlogger.c \ + libretro-common/net/net_compat.c \ + libretro-common/net/net_socket.c endif PPU_TARGET = retroarch-salamander_ps3.elf diff --git a/Makefile.wii.salamander b/Makefile.wii.salamander index e5c8ba96be..5601f19455 100644 --- a/Makefile.wii.salamander +++ b/Makefile.wii.salamander @@ -60,7 +60,9 @@ OBJ = frontend/frontend_salamander.o \ ifeq ($(HAVE_LOGGER), 1) CFLAGS += -DHAVE_LOGGER CFLAGS += -DPC_DEVELOPMENT_IP_ADDRESS=\"$(PC_DEVELOPMENT_IP_ADDRESS)\" -DPC_DEVELOPMENT_UDP_PORT=$(PC_DEVELOPMENT_UDP_PORT) -OBJ += logger/netlogger.o +OBJ += logger/netlogger.o \ + libretro-common/net/net_compat.o \ + libretro-common/net/net_socket.o endif ifeq ($(HAVE_FILE_LOGGER), 1) diff --git a/netlogger.c b/netlogger.c index ce04dc0476..3ac05fdd87 100644 --- a/netlogger.c +++ b/netlogger.c @@ -25,6 +25,7 @@ #include #include +#include #include "verbosity.h" @@ -40,9 +41,9 @@ static int g_sid; static struct sockaddr_in target; static char sendbuf[4096]; #ifdef VITA -static void *net_memory = NULL; #define NET_INIT_SIZE 512*1024 #endif +static void *net_memory = NULL; static int network_interface_up(struct sockaddr_in *target, int index, const char *ip_address, unsigned udp_port, int *s) @@ -113,24 +114,17 @@ static int network_interface_up(struct sockaddr_in *target, int index, static int network_interface_down(struct sockaddr_in *target, int *s) { - int ret = 0; -#if defined(_WIN32) && !defined(_XBOX360) - /* WinSock has headers from the stone age. */ - ret = closesocket(*s); -#elif defined(__CELLOS_LV2__) - ret = socketclose(*s); -#elif defined(VITA) - if (net_memory) - free(net_memory); - sceNetSocketClose(*s); -#else - ret = close(*s); -#endif + int ret = socket_close(*s); + #if defined(__CELLOS_LV2__) && !defined(__PSL1GHT__) cellNetCtlTerm(); #elif defined(GEKKO) && !defined(HW_DOL) net_deinit(); #endif + + if (net_memory) + free(net_memory); + return ret; } From e29b915536f0d8e4fca5b4691582b7bfabf1a0be Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 2 May 2016 00:18:39 +0200 Subject: [PATCH 058/498] Cleanups --- libretro-common/net/net_compat.c | 18 +++++++----------- netlogger.c | 9 ++------- 2 files changed, 9 insertions(+), 18 deletions(-) diff --git a/libretro-common/net/net_compat.c b/libretro-common/net/net_compat.c index 078d1d6589..15f9385f5c 100644 --- a/libretro-common/net/net_compat.c +++ b/libretro-common/net/net_compat.c @@ -188,28 +188,21 @@ bool network_init(void) sys_net_initialize_network(); #elif defined(VITA) SceNetInitParam initparam; - /* Init Net */ + if (sceNetShowNetstat() == PSP2_NET_ERROR_ENOTINIT) { _net_compat_net_memory = malloc(COMPAT_NET_INIT_SIZE); - initparam.memory = _net_compat_net_memory; - initparam.size = COMPAT_NET_INIT_SIZE; - initparam.flags = 0; + initparam.memory = _net_compat_net_memory; + initparam.size = COMPAT_NET_INIT_SIZE; + initparam.flags = 0; sceNetInit(&initparam); - //printf("sceNetInit(): 0x%08X\n", ret); - /* Init NetCtl */ sceNetCtlInit(); } - else - { - //printf("Net is already initialized.\n"); - } retro_epoll_fd = sceNetEpollCreate("epoll", 0); - //printf("Epoll %x\n",retro_epoll_fd); #else signal(SIGPIPE, SIG_IGN); /* Do not like SIGPIPE killing our app. */ #endif @@ -228,6 +221,7 @@ void network_deinit(void) #if defined(_WIN32) WSACleanup(); #elif defined(__CELLOS_LV2__) && !defined(__PSL1GHT__) + cellNetCtlTerm(); sys_net_finalize_network(); cellSysmoduleUnloadModule(CELL_SYSMODULE_NET); #elif defined(VITA) @@ -239,5 +233,7 @@ void network_deinit(void) free(_net_compat_net_memory); _net_compat_net_memory = NULL; } +#elif defined(GEKKO) && !defined(HW_DOL) + net_deinit(); #endif } diff --git a/netlogger.c b/netlogger.c index 3ac05fdd87..61b387b30d 100644 --- a/netlogger.c +++ b/netlogger.c @@ -65,8 +65,7 @@ static int network_interface_up(struct sockaddr_in *target, int index, *s = sceNetSocket("RA_netlogger", PSP2_NET_AF_INET, PSP2_NET_SOCK_DGRAM, 0); target->sin_family = PSP2_NET_AF_INET; target->sin_port = sceNetHtons(udp_port); - - sceNetInetPton(PSP2_NET_AF_INET, ip_address, &target->sin_addr); + target->sin_addr = inet_aton(ip_address); #else #if defined(__CELLOS_LV2__) && !defined(__PSL1GHT__) @@ -116,11 +115,7 @@ static int network_interface_down(struct sockaddr_in *target, int *s) { int ret = socket_close(*s); -#if defined(__CELLOS_LV2__) && !defined(__PSL1GHT__) - cellNetCtlTerm(); -#elif defined(GEKKO) && !defined(HW_DOL) - net_deinit(); -#endif + network_deinit(); if (net_memory) free(net_memory); From e00de48e92a29f6fed9b5764066c0f8dfaa9bf8b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 2 May 2016 00:21:13 +0200 Subject: [PATCH 059/498] Cleanups --- netlogger.c | 40 ++++++++++++++++++++++------------------ 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/netlogger.c b/netlogger.c index 61b387b30d..b18b8ba015 100644 --- a/netlogger.c +++ b/netlogger.c @@ -54,15 +54,18 @@ static int network_interface_up(struct sockaddr_in *target, int index, if (sceNetShowNetstat() == PSP2_NET_ERROR_ENOTINIT) { SceNetInitParam initparam; - net_memory = malloc(NET_INIT_SIZE); + net_memory = malloc(NET_INIT_SIZE); initparam.memory = net_memory; - initparam.size = NET_INIT_SIZE; - initparam.flags = 0; + initparam.size = NET_INIT_SIZE; + initparam.flags = 0; sceNetInit(&initparam); } - *s = sceNetSocket("RA_netlogger", PSP2_NET_AF_INET, PSP2_NET_SOCK_DGRAM, 0); + + *s = sceNetSocket("RA_netlogger", + PSP2_NET_AF_INET, PSP2_NET_SOCK_DGRAM, 0); + target->sin_family = PSP2_NET_AF_INET; target->sin_port = sceNetHtons(udp_port); target->sin_addr = inet_aton(ip_address); @@ -111,18 +114,6 @@ static int network_interface_up(struct sockaddr_in *target, int index, return 0; } -static int network_interface_down(struct sockaddr_in *target, int *s) -{ - int ret = socket_close(*s); - - network_deinit(); - - if (net_memory) - free(net_memory); - - return ret; -} - void logger_init (void) { if (network_interface_up(&target, 1, @@ -132,7 +123,14 @@ void logger_init (void) void logger_shutdown (void) { - if (network_interface_down(&target, &g_sid) < 0) + int ret = socket_close(g_sid); + + network_deinit(); + + if (net_memory) + free(net_memory); + + if (ret < 0) printf("Could not deinitialize network logger interface.\n"); } @@ -150,5 +148,11 @@ void logger_send_v(const char *__format, va_list args) int len; vsnprintf(sendbuf,4000,__format, args); len = strlen(sendbuf); - sendto(g_sid,sendbuf,len,MSG_DONTWAIT,(struct sockaddr*)&target,sizeof(target)); + + sendto(g_sid, + sendbuf, + len, + MSG_DONTWAIT, + (struct sockaddr*)&target, + sizeof(target)); } From 8c28ec0867da37dd7bcd9040a849e8afde04a61a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 2 May 2016 01:13:25 +0200 Subject: [PATCH 060/498] (remote.c) Refactor code --- remote.c | 23 +++-------------------- 1 file changed, 3 insertions(+), 20 deletions(-) diff --git a/remote.c b/remote.c index 69fe782c4b..68fd94e731 100644 --- a/remote.c +++ b/remote.c @@ -67,10 +67,7 @@ static input_remote_state_t *input_remote_get_state_ptr(void) static bool remote_init_network(rarch_remote_t *handle, uint16_t port, unsigned user) { - struct addrinfo hints = {0}; - char port_buf[16] = {0}; struct addrinfo *res = NULL; - int yes = 1; port = port + user; @@ -80,30 +77,16 @@ static bool remote_init_network(rarch_remote_t *handle, RARCH_LOG("Bringing up remote interface on port %hu.\n", (unsigned short)port); -#if defined(_WIN32) || defined(HAVE_SOCKET_LEGACY) - hints.ai_family = AF_INET; -#else - hints.ai_family = AF_UNSPEC; -#endif - hints.ai_socktype = SOCK_DGRAM; - hints.ai_flags = AI_PASSIVE; + handle->net_fd[user] = socket_init((void*)&res, + port, NULL, SOCKET_TYPE_DATAGRAM); - - snprintf(port_buf, sizeof(port_buf), "%hu", (unsigned short)port); - if (getaddrinfo_retro(NULL, port_buf, &hints, &res) < 0) - goto error; - - handle->net_fd[user] = socket(res->ai_family, - res->ai_socktype, res->ai_protocol); if (handle->net_fd[user] < 0) goto error; if (!socket_nonblock(handle->net_fd[user])) goto error; - setsockopt(handle->net_fd[user], SOL_SOCKET, - SO_REUSEADDR, (const char*)&yes, sizeof(int)); - if (bind(handle->net_fd[user], res->ai_addr, res->ai_addrlen) < 0) + if (!socket_bind(handle->net_fd[user], res)) { RARCH_ERR("Failed to bind socket.\n"); goto error; From 72ec71a71c816d3547de9fd88d8dbd21beb2e8af Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 2 May 2016 01:23:42 +0200 Subject: [PATCH 061/498] Cleanup --- netplay/netplay.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/netplay/netplay.c b/netplay/netplay.c index e12f95bce7..9d40929184 100644 --- a/netplay/netplay.c +++ b/netplay/netplay.c @@ -759,11 +759,13 @@ static bool init_tcp_socket(netplay_t *netplay, const char *server, static bool init_udp_socket(netplay_t *netplay, const char *server, uint16_t port) { - netplay->udp_fd = socket_init((void**)&netplay->addr, port, server, SOCKET_TYPE_DATAGRAM); + int fd = socket_init((void**)&netplay->addr, port, server, SOCKET_TYPE_DATAGRAM); - if (netplay->udp_fd < 0) + if (fd < 0) goto error; + netplay->udp_fd = fd; + if (!server) { /* Not sure if we have to do this for UDP, but hey :) */ From 3dd9a9ff988b349f938cf7d38a155588ac9375b6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 2 May 2016 01:26:19 +0200 Subject: [PATCH 062/498] Cleanup --- remote.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/remote.c b/remote.c index 68fd94e731..45caf0ce21 100644 --- a/remote.c +++ b/remote.c @@ -67,6 +67,7 @@ static input_remote_state_t *input_remote_get_state_ptr(void) static bool remote_init_network(rarch_remote_t *handle, uint16_t port, unsigned user) { + int fd; struct addrinfo *res = NULL; port = port + user; @@ -77,12 +78,13 @@ static bool remote_init_network(rarch_remote_t *handle, RARCH_LOG("Bringing up remote interface on port %hu.\n", (unsigned short)port); - handle->net_fd[user] = socket_init((void*)&res, - port, NULL, SOCKET_TYPE_DATAGRAM); + fd = socket_init((void*)&res, port, NULL, SOCKET_TYPE_DATAGRAM); - if (handle->net_fd[user] < 0) + if (fd < 0) goto error; + handle->net_fd[user] = fd; + if (!socket_nonblock(handle->net_fd[user])) goto error; From 2d348f68f9a72743eb63758093cc1ac6594a85d6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 2 May 2016 01:33:47 +0200 Subject: [PATCH 063/498] Cleanup --- command.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/command.c b/command.c index 0994d77652..60251d732d 100644 --- a/command.c +++ b/command.c @@ -123,16 +123,19 @@ static const struct cmd_map map[] = { #if defined(HAVE_NETWORK_CMD) && defined(HAVE_NETPLAY) static bool cmd_init_network(rarch_cmd_t *handle, uint16_t port) { + int fd; struct addrinfo *res = NULL; RARCH_LOG("Bringing up command interface on port %hu.\n", (unsigned short)port); - handle->net_fd = socket_init((void**)&res, port, NULL, SOCKET_TYPE_DATAGRAM); + fd = socket_init((void**)&res, port, NULL, SOCKET_TYPE_DATAGRAM); - if (handle->net_fd < 0) + if (fd < 0) goto error; + handle->net_fd = fd; + if (!socket_nonblock(handle->net_fd)) goto error; From 0bd38a5e1d912ac1a655efce9a28be8eb85b6c21 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 2 May 2016 01:35:28 +0200 Subject: [PATCH 064/498] Remove some obsolete RARCH_CONSOLE ifdefs --- netplay/netplay_net.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/netplay/netplay_net.c b/netplay/netplay_net.c index 70b67a2486..6f19a5ce22 100644 --- a/netplay/netplay_net.c +++ b/netplay/netplay_net.c @@ -87,11 +87,11 @@ static void netplay_net_post_frame(netplay_t *netplay) core_ctl(CORE_CTL_RETRO_SERIALIZE, &serial_info); -#if defined(HAVE_THREADS) && !defined(RARCH_CONSOLE) +#if defined(HAVE_THREADS) lock_autosave(); #endif core_ctl(CORE_CTL_RETRO_RUN, NULL); -#if defined(HAVE_THREADS) && !defined(RARCH_CONSOLE) +#if defined(HAVE_THREADS) unlock_autosave(); #endif netplay->tmp_ptr = NEXT_PTR(netplay->tmp_ptr); From fe8a50248899442eb762d237a1d1ae66d9b86812 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 2 May 2016 01:39:59 +0200 Subject: [PATCH 065/498] (autosave.c) Cleanups --- autosave.c | 34 ++++++---------------------------- 1 file changed, 6 insertions(+), 28 deletions(-) diff --git a/autosave.c b/autosave.c index ed912b2608..26129b70ed 100644 --- a/autosave.c +++ b/autosave.c @@ -55,28 +55,6 @@ struct autosave static struct autosave_st autosave_state; -/** - * autosave_lock: - * @handle : pointer to autosave object - * - * Locks autosave. - **/ -static void autosave_lock(autosave_t *handle) -{ - slock_lock(handle->lock); -} - -/** - * autosave_unlock: - * @handle : pointer to autosave object - * - * Unlocks autosave. - **/ -static void autosave_unlock(autosave_t *handle) -{ - slock_unlock(handle->lock); -} - /** * autosave_thread: * @data : pointer to autosave object @@ -85,19 +63,19 @@ static void autosave_unlock(autosave_t *handle) **/ static void autosave_thread(void *data) { - bool first_log = true; + bool first_log = true; autosave_t *save = (autosave_t*)data; while (!save->quit) { bool differ; - autosave_lock(save); + slock_lock(save->lock); differ = memcmp(save->buffer, save->retro_buffer, save->bufsize) != 0; if (differ) memcpy(save->buffer, save->retro_buffer, save->bufsize); - autosave_unlock(save); + slock_unlock(save->lock); if (differ) { @@ -153,7 +131,7 @@ static autosave_t *autosave_new(const char *path, const void *data, size_t size, unsigned interval) { - autosave_t *handle = (autosave_t*)calloc(1, sizeof(*handle)); + autosave_t *handle = (autosave_t*)calloc(1, sizeof(*handle)); if (!handle) goto error; @@ -219,7 +197,7 @@ void lock_autosave(void) for (i = 0; i < autosave_state.num; i++) { if (autosave_state.list[i]) - autosave_lock(autosave_state.list[i]); + slock_lock(autosave_state.list[i]->lock); } } @@ -235,7 +213,7 @@ void unlock_autosave(void) for (i = 0; i < autosave_state.num; i++) { if (autosave_state.list[i]) - autosave_unlock(autosave_state.list[i]); + slock_unlock(autosave_state.list[i]->lock); } } From fab90f4b9603ffa94572ff493702fe2edaa175bf Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Mon, 2 May 2016 01:55:02 +0200 Subject: [PATCH 066/498] (iOS) Avoid warning for unhandled CarPlay enum value --- gfx/drivers_context/cocoa_gl_ctx.m | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/gfx/drivers_context/cocoa_gl_ctx.m b/gfx/drivers_context/cocoa_gl_ctx.m index b8a025dbeb..f1bb434328 100644 --- a/gfx/drivers_context/cocoa_gl_ctx.m +++ b/gfx/drivers_context/cocoa_gl_ctx.m @@ -48,6 +48,10 @@ #define UIUserInterfaceIdiomTV 2 #endif +#ifndef UIUserInterfaceIdiomCarPlay +#define UIUserInterfaceIdiomCarPlay 3 +#endif + @interface EAGLContext (OSXCompat) @end @implementation EAGLContext (OSXCompat) + (void)clearCurrentContext { [EAGLContext setCurrentContext:nil]; } @@ -464,6 +468,7 @@ static bool cocoagl_gfx_ctx_get_metrics(void *data, enum display_metric_types ty dpi = 163 * scale; break; case UIUserInterfaceIdiomTV: + case UIUserInterfaceIdiomCarPlay: /* TODO */ break; } From 31f3fc0abb9df4939b9d8e5a76cfc776d136e7d3 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 2 May 2016 02:09:22 +0200 Subject: [PATCH 067/498] Create socket_receive_all_nonblocking --- libretro-common/include/net/net_socket.h | 3 ++ libretro-common/net/net_http.c | 41 ++++++++---------------- libretro-common/net/net_socket.c | 19 +++++++++++ 3 files changed, 36 insertions(+), 27 deletions(-) diff --git a/libretro-common/include/net/net_socket.h b/libretro-common/include/net/net_socket.h index 31960cd96e..a1ab722fa3 100644 --- a/libretro-common/include/net/net_socket.h +++ b/libretro-common/include/net/net_socket.h @@ -50,6 +50,9 @@ int socket_send_all_blocking(int fd, const void *data_, size_t size, bool no_sig int socket_receive_all_blocking(int fd, void *data_, size_t size); +ssize_t socket_receive_all_nonblocking(int fd, bool *error, + void *data_, size_t size); + bool socket_bind(int fd, void *data); int socket_connect(int fd, void *data, bool timeout_enable); diff --git a/libretro-common/net/net_http.c b/libretro-common/net/net_http.c index 350fc30015..e1bca08d30 100644 --- a/libretro-common/net/net_http.c +++ b/libretro-common/net/net_http.c @@ -105,33 +105,12 @@ static void net_http_send_str(int fd, bool *error, const char *text) } } -static ssize_t net_http_recv(int fd, bool *error, - uint8_t *data, size_t maxlen) -{ - ssize_t bytes; - - if (*error) - return -1; - - bytes = recv(fd, (char*)data, maxlen, 0); - - if (bytes > 0) - return bytes; - else if (bytes == 0) - return -1; - else if (isagain(bytes)) - return 0; - - *error=true; - return -1; -} - static char* urlencode(const char* url) { unsigned i; unsigned outpos = 0; unsigned outlen = 0; - char *ret = NULL; + char *ret = NULL; for (i = 0; url[i] != '\0'; i++) { @@ -326,8 +305,11 @@ bool net_http_update(struct http_t *state, size_t* progress, size_t* total) if (state->part < P_BODY) { - newlen = net_http_recv(state->fd, &state->error, - (uint8_t*)state->data + state->pos, state->buflen - state->pos); + if (state->error) + newlen = -1; + else + newlen = socket_receive_all_nonblocking(state->fd, &state->error, + (uint8_t*)state->data + state->pos, state->buflen - state->pos); if (newlen < 0) goto fail; @@ -392,9 +374,14 @@ bool net_http_update(struct http_t *state, size_t* progress, size_t* total) { if (!newlen) { - newlen = net_http_recv(state->fd, &state->error, - (uint8_t*)state->data + state->pos, - state->buflen - state->pos); + if (state->error) + newlen = -1; + else + newlen = socket_receive_all_nonblocking( + state->fd, + &state->error, + (uint8_t*)state->data + state->pos, + state->buflen - state->pos); if (newlen < 0) { diff --git a/libretro-common/net/net_socket.c b/libretro-common/net/net_socket.c index b1e827775d..22e07fb2f9 100644 --- a/libretro-common/net/net_socket.c +++ b/libretro-common/net/net_socket.c @@ -70,6 +70,25 @@ error: return -1; } +ssize_t socket_receive_all_nonblocking(int fd, bool *error, + void *data_, size_t size) +{ + const uint8_t *data = (const uint8_t*)data_; + ssize_t ret = recv(fd, (char*)data, size, 0); + + if (ret > 0) + return ret; + + if (ret == 0) + return -1; + + if (isagain(ret)) + return 0; + + *error = true; + return -1; +} + int socket_receive_all_blocking(int fd, void *data_, size_t size) { const uint8_t *data = (const uint8_t*)data_; From 96723f3a57c6d440dc8f9879e7835546406eb66b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 2 May 2016 02:10:45 +0200 Subject: [PATCH 068/498] Cleanup --- libretro-common/net/net_http.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libretro-common/net/net_http.c b/libretro-common/net/net_http.c index e1bca08d30..97c8285ffc 100644 --- a/libretro-common/net/net_http.c +++ b/libretro-common/net/net_http.c @@ -98,11 +98,11 @@ error: static void net_http_send_str(int fd, bool *error, const char *text) { - if (!*error) - { - if (!socket_send_all_blocking(fd, text, strlen(text), true)) - *error = true; - } + if (*error) + return; + + if (!socket_send_all_blocking(fd, text, strlen(text), true)) + *error = true; } static char* urlencode(const char* url) From 8ff81312ad5901de1d7c27809c605221c9504383 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 2 May 2016 02:48:37 +0200 Subject: [PATCH 069/498] Fix fill_pathname_application_data --- file_path_special.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/file_path_special.c b/file_path_special.c index 16a7927573..125d6bd35c 100644 --- a/file_path_special.c +++ b/file_path_special.c @@ -176,10 +176,10 @@ bool fill_pathname_application_data(char *s, size_t len) { #ifdef __HAIKU__ fill_pathname_join(s, appdata, - "config/settings/retroarch", len); + "config/settings/retroarch/", len); #else fill_pathname_join(s, appdata, - ".config/retroarch", len); + ".config/retroarch/", len); #endif return true; } From 906b94966b0518d5f8cc1f11f1c0fdf39aefe35d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 2 May 2016 03:07:13 +0200 Subject: [PATCH 070/498] Fix default path --- configuration.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/configuration.c b/configuration.c index 062168d98e..d92d098bb0 100644 --- a/configuration.c +++ b/configuration.c @@ -981,6 +981,7 @@ static config_file_t *open_default_config_file(void) /* Try to create a new config file. */ conf = config_file_new(NULL); + if (conf) { /* Since this is a clean config file, we can @@ -1067,8 +1068,11 @@ static config_file_t *open_default_config_file(void) /* Try to create a new config file. */ strlcpy(conf_path, application_data, sizeof(conf_path)); + fill_pathname_basedir(basedir, conf_path, sizeof(basedir)); + fill_pathname_join(conf_path, conf_path, "retroarch.cfg", sizeof(conf_path)); + if (path_mkdir(basedir)) { bool saved = false; From 3be2491232d57e2bbf6f2dfa954d06a6626b122d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 2 May 2016 03:16:46 +0200 Subject: [PATCH 071/498] (Windows 10) Windows 10 should be major number 10 --- frontend/drivers/platform_win32.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/frontend/drivers/platform_win32.c b/frontend/drivers/platform_win32.c index d93f0db471..8c440eedd1 100644 --- a/frontend/drivers/platform_win32.c +++ b/frontend/drivers/platform_win32.c @@ -111,6 +111,9 @@ static void frontend_win32_get_os(char *s, size_t len, int *major, int *minor) switch (*major) { + case 10: + strlcpy(s, "Windows 10", len); + break; case 6: switch (*minor) { From 7f871d6e9a319476bd30a0f2e8238c42bd0c095b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 2 May 2016 04:05:03 +0200 Subject: [PATCH 072/498] (PowerPC Mac) Fall back to shader pipeline 1 for OSX PowerPC - too slow otherwise --- config.def.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config.def.h b/config.def.h index 9489b966a3..673b15a417 100644 --- a/config.def.h +++ b/config.def.h @@ -521,7 +521,7 @@ static bool xmb_shadows_enable = true; static unsigned menu_background_gradient = 4; -#if defined(HAVE_OPENGLES2) +#if defined(HAVE_OPENGLES2) || defined(OSX_PPC) static unsigned menu_shader_pipeline = 1; #else static unsigned menu_shader_pipeline = 2; From c3e9f64bc2ff8074a13831ee168c49ef72aa0dbc Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 2 May 2016 04:24:26 +0200 Subject: [PATCH 073/498] Rename some settings --- menu/intl/menu_hash_us.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/menu/intl/menu_hash_us.c b/menu/intl/menu_hash_us.c index 7ec53dcf38..b8e1c94725 100644 --- a/menu/intl/menu_hash_us.c +++ b/menu/intl/menu_hash_us.c @@ -1069,9 +1069,9 @@ const char *menu_hash_to_str_us(uint32_t hash) case MENU_LABEL_VALUE_XMB_THEME: return "XMB Theme"; case MENU_LABEL_VALUE_XMB_GRADIENT: - return "XMB Gradient"; + return "Background Gradient"; case MENU_LABEL_VALUE_XMB_SHADOWS_ENABLE: - return "XMB Shadows Enable"; + return "Icon Shadows Enable"; case MENU_LABEL_VALUE_XMB_RIBBON_ENABLE: return "Menu Shader Pipeline"; case MENU_LABEL_VALUE_SUSPEND_SCREENSAVER_ENABLE: From 41a731967f9233a579c703c6502f12b7f386153f Mon Sep 17 00:00:00 2001 From: radius Date: Sun, 1 May 2016 21:37:58 -0500 Subject: [PATCH 074/498] remove the winsock2 dependency I guess it should work on linux now --- cores/retropad/Makefile | 9 +++++++-- cores/retropad/retropad.c | 16 +++++----------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/cores/retropad/Makefile b/cores/retropad/Makefile index fefae26434..9c6b54a416 100644 --- a/cores/retropad/Makefile +++ b/cores/retropad/Makefile @@ -103,7 +103,12 @@ else SHARED := -shared -static-libgcc -static-libstdc++ -s -Wl,--version-script=link.T -Wl,--no-undefined endif -LDFLAGS += $(LIBM) -lws2_32 + +LDFLAGS += $(LIBM) + +ifeq ($(platform), win) +LDFLAGS += -lws2_32 +endif ifeq ($(DEBUG), 1) CFLAGS += -O0 -g @@ -111,7 +116,7 @@ else CFLAGS += -O3 endif -OBJECTS := retropad.o +OBJECTS := ../../libretro-common/net/net_compat.o ../../libretro-common/net/net_socket.o retropad.o CFLAGS += -I../../libretro-common/include -Wall -pedantic $(fpic) ifneq (,$(findstring qnx,$(platform))) diff --git a/cores/retropad/retropad.c b/cores/retropad/retropad.c index 87e8f1cfa4..59fee41d8e 100644 --- a/cores/retropad/retropad.c +++ b/cores/retropad/retropad.c @@ -35,9 +35,8 @@ #include #include - #include - #include - #include + #include + #include #include @@ -51,7 +50,6 @@ int s, slen=sizeof(si_other); char message[64]; char server[64]; int port; -WSADATA wsa; int input_state = 0; void retro_init(void) @@ -59,11 +57,7 @@ void retro_init(void) frame_buf = (uint16_t*)calloc(320 * 240, sizeof(uint16_t)); //Initialise winsock log_cb(RETRO_LOG_INFO, "Initialising sockets\n"); - if (WSAStartup(MAKEWORD(2,2),&wsa) != 0) - { - log_cb(RETRO_LOG_INFO, "Failed. Error Code : %d",WSAGetLastError()); - } - log_cb(RETRO_LOG_INFO, "Sockets initialised.\n"); + network_init(); } void retro_deinit(void) @@ -245,14 +239,14 @@ bool retro_load_game(const struct retro_game_info *info) //create socket if ( (s=socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == SOCKET_ERROR) { - log_cb(RETRO_LOG_INFO, "socket() failed with error code : %d" , WSAGetLastError()); + log_cb(RETRO_LOG_INFO, "socket failed"); } //setup address structure memset((char *) &si_other, 0, sizeof(si_other)); si_other.sin_family = AF_INET; si_other.sin_port = htons(port); si_other.sin_addr.S_un.S_addr = inet_addr(server); - log_cb(RETRO_LOG_INFO, "Server : %s" , server); + log_cb(RETRO_LOG_INFO, "Server IP Address: %s\n" , server); return true; } From 74937e4a524486fe8aa5c2466c0cf369a6c48dff Mon Sep 17 00:00:00 2001 From: radius Date: Sun, 1 May 2016 22:00:54 -0500 Subject: [PATCH 075/498] remove itoa dependency and other window specific code --- cores/retropad/retropad.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/cores/retropad/retropad.c b/cores/retropad/retropad.c index 59fee41d8e..feb4083981 100644 --- a/cores/retropad/retropad.c +++ b/cores/retropad/retropad.c @@ -221,7 +221,7 @@ void retro_run(void) { unsigned i; update_input(); - itoa(input_state, message, 10); + snprintf(message, sizeof(message), "%d", input_state); //send the message if (sendto(s, message, strlen(message) , 0 , (struct sockaddr *) &si_other, slen)==-1) { @@ -245,7 +245,11 @@ bool retro_load_game(const struct retro_game_info *info) memset((char *) &si_other, 0, sizeof(si_other)); si_other.sin_family = AF_INET; si_other.sin_port = htons(port); +#if defined(_WIN32) || defined(HAVE_SOCKET_LEGACY) si_other.sin_addr.S_un.S_addr = inet_addr(server); +#else + si_other.sin_addr.s_addr = inet_addr(server); +#endif log_cb(RETRO_LOG_INFO, "Server IP Address: %s\n" , server); return true; From 6534f71238af2c4ce575fd5a0b01d0dbfcf72ac8 Mon Sep 17 00:00:00 2001 From: radius Date: Sun, 1 May 2016 23:07:12 -0500 Subject: [PATCH 076/498] building now on linux, untested --- cores/retropad/retropad.c | 26 ++++++++++++++++---------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/cores/retropad/retropad.c b/cores/retropad/retropad.c index feb4083981..3c079fd0c9 100644 --- a/cores/retropad/retropad.c +++ b/cores/retropad/retropad.c @@ -28,19 +28,24 @@ * - Input recording / Combos */ - #include - #include - #include - #include - #include - #include +#include +#include +#include +#include +#include +#include - #include - #include +#include +#include - #include +#include #include "../../libretro.h" + +#ifndef SOCKET_ERROR +#define SOCKET_ERROR -1 +#endif + struct retro_log_callback logger; retro_log_printf_t log_cb; @@ -225,7 +230,7 @@ void retro_run(void) //send the message if (sendto(s, message, strlen(message) , 0 , (struct sockaddr *) &si_other, slen)==-1) { - log_cb(RETRO_LOG_INFO, "Error sending data"); + log_cb(RETRO_LOG_INFO, "Error sending data\n"); } for (i = 0; i < 320 * 240; i++) frame_buf[i] = 4 << 5; @@ -249,6 +254,7 @@ bool retro_load_game(const struct retro_game_info *info) si_other.sin_addr.S_un.S_addr = inet_addr(server); #else si_other.sin_addr.s_addr = inet_addr(server); + inet_aton(server , &si_other.sin_addr); #endif log_cb(RETRO_LOG_INFO, "Server IP Address: %s\n" , server); From 56180af7271b1731ac88da5aed121076e3651d16 Mon Sep 17 00:00:00 2001 From: gouchi Date: Mon, 2 May 2016 12:11:47 +0200 Subject: [PATCH 077/498] add audio hdmi output --- audio/drivers/alsa.c | 2 +- audio/drivers/alsathread.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/audio/drivers/alsa.c b/audio/drivers/alsa.c index 0b4a359d66..2c875a22b4 100644 --- a/audio/drivers/alsa.c +++ b/audio/drivers/alsa.c @@ -351,7 +351,7 @@ static void *alsa_device_list_new(void *data) /* description of device IOID - input / output identifcation * ("Input" or "Output"), NULL means both) */ - if (io == NULL) + if (!io || !strcmp(io,"Output")) string_list_append(s, name, attr); if (name) diff --git a/audio/drivers/alsathread.c b/audio/drivers/alsathread.c index 83175b3c56..f8a2c53e9f 100644 --- a/audio/drivers/alsathread.c +++ b/audio/drivers/alsathread.c @@ -369,7 +369,7 @@ static void *alsa_device_list_new(void *data) /* description of device IOID - input / output identifcation * ("Input" or "Output"), NULL means both) */ - if (io == NULL) + if (!io || !strcmp(io,"Output")) string_list_append(s, name, attr); if (name) From 6c243ef6fe011af0f83a6c789e8a15c26cf1d09a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 2 May 2016 13:23:47 +0200 Subject: [PATCH 078/498] Cleanups --- configuration.c | 6 ++--- file_path_special.c | 2 +- frontend/drivers/platform_darwin.m | 43 ++++++++++++++---------------- 3 files changed, 23 insertions(+), 28 deletions(-) diff --git a/configuration.c b/configuration.c index d92d098bb0..841051d8b2 100644 --- a/configuration.c +++ b/configuration.c @@ -1008,11 +1008,9 @@ static config_file_t *open_default_config_file(void) sizeof(application_data))) return NULL; - fill_pathname_join(conf_path, application_data, - "RetroArch", sizeof(conf_path)); - path_mkdir(conf_path); + path_mkdir(application_data); - fill_pathname_join(conf_path, conf_path, + fill_pathname_join(conf_path, application_data, "retroarch.cfg", sizeof(conf_path)); conf = config_file_new(conf_path); diff --git a/file_path_special.c b/file_path_special.c index 125d6bd35c..08b74ae809 100644 --- a/file_path_special.c +++ b/file_path_special.c @@ -158,7 +158,7 @@ bool fill_pathname_application_data(char *s, size_t len) if (appdata) { fill_pathname_join(s, appdata, - "Library/Application Support", len); + "Library/Application Support/RetroArch", len); return true; } #elif !defined(RARCH_CONSOLE) diff --git a/frontend/drivers/platform_darwin.m b/frontend/drivers/platform_darwin.m index 8f5b062689..f6a7e409a4 100644 --- a/frontend/drivers/platform_darwin.m +++ b/frontend/drivers/platform_darwin.m @@ -374,35 +374,32 @@ static void frontend_darwin_get_environment_settings(int *argc, char *argv[], fill_pathname_join(g_defaults.dir.playlist, home_dir_buf, "playlists", sizeof(g_defaults.dir.playlist)); #endif #if defined(OSX) - char application_data_root_dir[PATH_MAX_LENGTH]; - char application_data[PATH_MAX_LENGTH]; - - fill_pathname_application_data(application_data, sizeof(application_data)); - fill_pathname_join(application_data_root_dir, - application_data, "RetroArch", sizeof(application_data_root_dir)); - + char application_data[PATH_MAX_LENGTH]; + + fill_pathname_application_data(application_data, sizeof(application_data)); + #ifdef HAVE_CG fill_pathname_join(g_defaults.dir.shader, home_dir_buf, "shaders_cg", sizeof(g_defaults.dir.shader)); #endif fill_pathname_join(g_defaults.dir.audio_filter, home_dir_buf, "audio_filters", sizeof(g_defaults.dir.audio_filter)); fill_pathname_join(g_defaults.dir.video_filter, home_dir_buf, "video_filters", sizeof(g_defaults.dir.video_filter)); - fill_pathname_join(g_defaults.dir.playlist, application_data_root_dir, "playlists", sizeof(g_defaults.dir.playlist)); - fill_pathname_join(g_defaults.dir.menu_config, application_data_root_dir, "configs", sizeof(g_defaults.dir.menu_config)); - fill_pathname_join(g_defaults.path.config, g_defaults.dir.menu_config, "retroarch.cfg", sizeof(g_defaults.path.config)); - fill_pathname_join(g_defaults.dir.thumbnails, application_data_root_dir, "thumbnails", sizeof(g_defaults.dir.thumbnails)); - fill_pathname_join(g_defaults.dir.remap, application_data_root_dir, "remaps", sizeof(g_defaults.dir.remap)); - fill_pathname_join(g_defaults.dir.core_assets, application_data_root_dir, "downloads", sizeof(g_defaults.dir.core_assets)); - fill_pathname_join(g_defaults.dir.screenshot, application_data_root_dir, "screenshots", sizeof(g_defaults.dir.screenshot)); + fill_pathname_join(g_defaults.dir.playlist, application_data, "playlists", sizeof(g_defaults.dir.playlist)); + fill_pathname_join(g_defaults.dir.menu_config, application_data, "configs", sizeof(g_defaults.dir.menu_config)); + fill_pathname_join(g_defaults.path.config, g_defaults.dir.menu_config, "retroarch.cfg", sizeof(g_defaults.path.config)); + fill_pathname_join(g_defaults.dir.thumbnails, application_data, "thumbnails", sizeof(g_defaults.dir.thumbnails)); + fill_pathname_join(g_defaults.dir.remap, application_data, "remaps", sizeof(g_defaults.dir.remap)); + fill_pathname_join(g_defaults.dir.core_assets, application_data, "downloads", sizeof(g_defaults.dir.core_assets)); + fill_pathname_join(g_defaults.dir.screenshot, application_data, "screenshots", sizeof(g_defaults.dir.screenshot)); #if defined(RELEASE_BUILD) - fill_pathname_join(g_defaults.dir.shader, bundle_path_buf, "Contents/Resources/shaders", sizeof(g_defaults.dir.shader)); - fill_pathname_join(g_defaults.dir.core, bundle_path_buf, "Contents/Resources/cores", sizeof(g_defaults.dir.core)); - fill_pathname_join(g_defaults.dir.core_info, bundle_path_buf, "Contents/Resources/info", sizeof(g_defaults.dir.core_info)); - fill_pathname_join(g_defaults.dir.overlay, bundle_path_buf, "Contents/Resources/overlays", sizeof(g_defaults.dir.overlay)); - fill_pathname_join(g_defaults.dir.autoconfig, bundle_path_buf, "Contents/Resources/autoconfig", sizeof(g_defaults.dir.autoconfig)); - fill_pathname_join(g_defaults.dir.assets, bundle_path_buf, "Contents/Resources/assets", sizeof(g_defaults.dir.assets)); - fill_pathname_join(g_defaults.dir.database, bundle_path_buf, "Contents/Resources/database/rdb", sizeof(g_defaults.dir.database)); - fill_pathname_join(g_defaults.dir.cursor, bundle_path_buf, "Contents/Resources/database/cursors", sizeof(g_defaults.dir.cursor)); - fill_pathname_join(g_defaults.dir.cheats, bundle_path_buf, "Contents/Resources/cht", sizeof(g_defaults.dir.cheats)); + fill_pathname_join(g_defaults.dir.shader, bundle_path_buf, "Contents/Resources/shaders", sizeof(g_defaults.dir.shader)); + fill_pathname_join(g_defaults.dir.core, bundle_path_buf, "Contents/Resources/cores", sizeof(g_defaults.dir.core)); + fill_pathname_join(g_defaults.dir.core_info, bundle_path_buf, "Contents/Resources/info", sizeof(g_defaults.dir.core_info)); + fill_pathname_join(g_defaults.dir.overlay, bundle_path_buf, "Contents/Resources/overlays", sizeof(g_defaults.dir.overlay)); + fill_pathname_join(g_defaults.dir.autoconfig, bundle_path_buf, "Contents/Resources/autoconfig", sizeof(g_defaults.dir.autoconfig)); + fill_pathname_join(g_defaults.dir.assets, bundle_path_buf, "Contents/Resources/assets", sizeof(g_defaults.dir.assets)); + fill_pathname_join(g_defaults.dir.database, bundle_path_buf, "Contents/Resources/database/rdb", sizeof(g_defaults.dir.database)); + fill_pathname_join(g_defaults.dir.cursor, bundle_path_buf, "Contents/Resources/database/cursors", sizeof(g_defaults.dir.cursor)); + fill_pathname_join(g_defaults.dir.cheats, bundle_path_buf, "Contents/Resources/cht", sizeof(g_defaults.dir.cheats)); #endif #endif From e62c63cc0e3affc01c44b378ff53ce414190af50 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 2 May 2016 13:53:09 +0200 Subject: [PATCH 079/498] Cleanup --- cores/retropad/retropad.c | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) diff --git a/cores/retropad/retropad.c b/cores/retropad/retropad.c index 3c079fd0c9..1666c8c493 100644 --- a/cores/retropad/retropad.c +++ b/cores/retropad/retropad.c @@ -171,28 +171,23 @@ void retro_set_environment(retro_environment_t cb) static void check_variables(void) { - struct retro_variable var; - var.key = "ip_octet1"; - environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var); - snprintf(server, sizeof(server), "%s", var.value); + struct retro_variable var, var2, var3, var4, port_var; + var.key = "ip_octet1"; + var2.key = "ip_octet2"; + var3.key = "ip_octet3"; + var4.key = "ip_octet4"; + port_var.key = "port"; - var.key = "ip_octet2"; environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var); - snprintf(server, sizeof(server), "%s.%s", server, var.value); - - var.key = "ip_octet3"; - environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var); - snprintf(server, sizeof(server), "%s.%s", server, var.value); - - var.key = "ip_octet4"; - environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var); - snprintf(server, sizeof(server), "%s.%s", server, var.value); - - var.key = "port"; - environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var); - port = atoi(var.value); + environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var2); + environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var3); + environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &var4); + environ_cb(RETRO_ENVIRONMENT_GET_VARIABLE, &port_var); + snprintf(server, sizeof(server), "%s.%s.%s.%s", var.value, var2.value, var3.value, var4.value); + port = atoi(port_var.value); } + void retro_set_audio_sample(retro_audio_sample_t cb) { audio_cb = cb; From fbe43730b85f49682965009d3b209bd05c15da41 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 2 May 2016 14:16:47 +0200 Subject: [PATCH 080/498] (Thumbnails Updater) Fix name string --- menu/cbs/menu_cbs_title.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/menu/cbs/menu_cbs_title.c b/menu/cbs/menu_cbs_title.c index a97924a5b1..3d704f4cd9 100644 --- a/menu/cbs/menu_cbs_title.c +++ b/menu/cbs/menu_cbs_title.c @@ -341,6 +341,13 @@ static int action_get_online_updater_list(const char *path, const char *label, return 0; } +static int action_get_online_thumbnails_updater_list(const char *path, const char *label, + unsigned menu_type, char *s, size_t len) +{ + sanitize_to_string(s, menu_hash_to_str(MENU_LABEL_VALUE_THUMBNAILS_UPDATER_LIST), len); + return 0; +} + static int action_get_core_updater_list(const char *path, const char *label, unsigned menu_type, char *s, size_t len) { @@ -825,6 +832,9 @@ static int menu_cbs_init_bind_title_compare_label(menu_file_list_cbs_t *cbs, case MENU_LABEL_ONLINE_UPDATER: BIND_ACTION_GET_TITLE(cbs, action_get_online_updater_list); break; + case MENU_LABEL_DEFERRED_THUMBNAILS_UPDATER_LIST: + BIND_ACTION_GET_TITLE(cbs, action_get_online_thumbnails_updater_list); + break; case MENU_LABEL_DEFERRED_CORE_UPDATER_LIST: BIND_ACTION_GET_TITLE(cbs, action_get_core_updater_list); break; From da8a9bfeba1c032b3d3fcf00baac8b68fb88e50c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 2 May 2016 14:45:23 +0200 Subject: [PATCH 081/498] Standardize config/remaps directories --- frontend/drivers/platform_ctr.c | 4 +++- frontend/drivers/platform_darwin.m | 9 +++++---- frontend/drivers/platform_win32.c | 6 +++--- 3 files changed, 11 insertions(+), 8 deletions(-) diff --git a/frontend/drivers/platform_ctr.c b/frontend/drivers/platform_ctr.c index 520203cdb6..7ba3ee9447 100644 --- a/frontend/drivers/platform_ctr.c +++ b/frontend/drivers/platform_ctr.c @@ -74,8 +74,10 @@ static void frontend_ctr_get_environment_settings(int *argc, char *argv[], "system", sizeof(g_defaults.dir.system)); fill_pathname_join(g_defaults.dir.playlist, g_defaults.dir.core, "playlists", sizeof(g_defaults.dir.playlist)); + fill_pathname_join(g_defaults.dir.menu_config, g_defaults.dir.port, + "config", sizeof(g_defaults.dir.menu_config)); fill_pathname_join(g_defaults.dir.remap, g_defaults.dir.port, - "remaps", sizeof(g_defaults.dir.remap)); + "config/remaps", sizeof(g_defaults.dir.remap)); fill_pathname_join(g_defaults.dir.video_filter, g_defaults.dir.port, "filters", sizeof(g_defaults.dir.remap)); fill_pathname_join(g_defaults.path.config, g_defaults.dir.port, diff --git a/frontend/drivers/platform_darwin.m b/frontend/drivers/platform_darwin.m index f6a7e409a4..3ff4041f29 100644 --- a/frontend/drivers/platform_darwin.m +++ b/frontend/drivers/platform_darwin.m @@ -361,7 +361,7 @@ static void frontend_darwin_get_environment_settings(int *argc, char *argv[], fill_pathname_join(g_defaults.dir.core_assets, home_dir_buf, "downloads", sizeof(g_defaults.dir.core_assets)); fill_pathname_join(g_defaults.dir.assets, home_dir_buf, "assets", sizeof(g_defaults.dir.assets)); fill_pathname_join(g_defaults.dir.system, home_dir_buf, "system", sizeof(g_defaults.dir.system)); - fill_pathname_join(g_defaults.dir.menu_config, home_dir_buf, "configs", sizeof(g_defaults.dir.menu_config)); + fill_pathname_join(g_defaults.dir.menu_config, home_dir_buf, "config", sizeof(g_defaults.dir.menu_config)); fill_pathname_join(g_defaults.path.config, g_defaults.dir.menu_config, "retroarch.cfg", sizeof(g_defaults.path.config)); fill_pathname_join(g_defaults.dir.database, home_dir_buf, "database/rdb", sizeof(g_defaults.dir.database)); fill_pathname_join(g_defaults.dir.cursor, home_dir_buf, "database/cursors", sizeof(g_defaults.dir.cursor)); @@ -369,7 +369,8 @@ static void frontend_darwin_get_environment_settings(int *argc, char *argv[], fill_pathname_join(g_defaults.dir.thumbnails, home_dir_buf, "thumbnails", sizeof(g_defaults.dir.thumbnails)); fill_pathname_join(g_defaults.dir.sram, home_dir_buf, "saves", sizeof(g_defaults.dir.sram)); fill_pathname_join(g_defaults.dir.savestate, home_dir_buf, "states", sizeof(g_defaults.dir.savestate)); - fill_pathname_join(g_defaults.dir.remap, home_dir_buf, "remaps", sizeof(g_defaults.dir.remap)); + fill_pathname_join(g_defaults.dir.menu_config, application_data, "config", sizeof(g_defaults.dir.menu_config)); + fill_pathname_join(g_defaults.dir.remap, home_dir_buf, "config/remaps", sizeof(g_defaults.dir.remap)); #if defined(IOS) fill_pathname_join(g_defaults.dir.playlist, home_dir_buf, "playlists", sizeof(g_defaults.dir.playlist)); #endif @@ -384,10 +385,10 @@ static void frontend_darwin_get_environment_settings(int *argc, char *argv[], fill_pathname_join(g_defaults.dir.audio_filter, home_dir_buf, "audio_filters", sizeof(g_defaults.dir.audio_filter)); fill_pathname_join(g_defaults.dir.video_filter, home_dir_buf, "video_filters", sizeof(g_defaults.dir.video_filter)); fill_pathname_join(g_defaults.dir.playlist, application_data, "playlists", sizeof(g_defaults.dir.playlist)); - fill_pathname_join(g_defaults.dir.menu_config, application_data, "configs", sizeof(g_defaults.dir.menu_config)); fill_pathname_join(g_defaults.path.config, g_defaults.dir.menu_config, "retroarch.cfg", sizeof(g_defaults.path.config)); fill_pathname_join(g_defaults.dir.thumbnails, application_data, "thumbnails", sizeof(g_defaults.dir.thumbnails)); - fill_pathname_join(g_defaults.dir.remap, application_data, "remaps", sizeof(g_defaults.dir.remap)); + fill_pathname_join(g_defaults.dir.menu_config, application_data, "config", sizeof(g_defaults.dir.menu_config)); + fill_pathname_join(g_defaults.dir.remap, application_data, "config/remaps", sizeof(g_defaults.dir.remap)); fill_pathname_join(g_defaults.dir.core_assets, application_data, "downloads", sizeof(g_defaults.dir.core_assets)); fill_pathname_join(g_defaults.dir.screenshot, application_data, "screenshots", sizeof(g_defaults.dir.screenshot)); #if defined(RELEASE_BUILD) diff --git a/frontend/drivers/platform_win32.c b/frontend/drivers/platform_win32.c index 8c440eedd1..088b14f064 100644 --- a/frontend/drivers/platform_win32.c +++ b/frontend/drivers/platform_win32.c @@ -255,8 +255,10 @@ static void frontend_win32_environment_get(int *argc, char *argv[], ":/database/cursors", sizeof(g_defaults.dir.cursor)); fill_pathname_expand_special(g_defaults.dir.playlist, ":/playlists", sizeof(g_defaults.dir.assets)); + fill_pathname_expand_special(g_defaults.dir.menu_config, + ":/config", sizeof(g_defaults.dir.menu_config)); fill_pathname_expand_special(g_defaults.dir.remap, - ":/config/remap", sizeof(g_defaults.dir.remap)); + ":/config/remaps", sizeof(g_defaults.dir.remap)); fill_pathname_expand_special(g_defaults.dir.wallpapers, ":/assets/wallpapers", sizeof(g_defaults.dir.wallpapers)); fill_pathname_expand_special(g_defaults.dir.thumbnails, @@ -273,8 +275,6 @@ static void frontend_win32_environment_get(int *argc, char *argv[], ":/info", sizeof(g_defaults.dir.core_info)); fill_pathname_expand_special(g_defaults.dir.autoconfig, ":/autoconfig", sizeof(g_defaults.dir.autoconfig)); - fill_pathname_expand_special(g_defaults.dir.menu_config, - ":/config", sizeof(g_defaults.dir.menu_config)); fill_pathname_expand_special(g_defaults.dir.shader, ":/shaders", sizeof(g_defaults.dir.shader)); fill_pathname_expand_special(g_defaults.dir.core_assets, From 5d31e561a2b577546c6645e59e36248a8728b517 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 2 May 2016 14:50:26 +0200 Subject: [PATCH 082/498] Remove 'for further information' line --- menu/intl/menu_hash_us.c | 4 ---- menu/intl/menu_hash_uspseudo.c | 2 -- 2 files changed, 6 deletions(-) diff --git a/menu/intl/menu_hash_us.c b/menu/intl/menu_hash_us.c index b8e1c94725..cc0323ba5f 100644 --- a/menu/intl/menu_hash_us.c +++ b/menu/intl/menu_hash_us.c @@ -1811,15 +1811,11 @@ int menu_hash_get_help_us(uint32_t hash, char *s, size_t len) "\n" "Extracting assets, please wait.\n" "This might take a while...\n" - "\n" - "For further information, go to Help.\n" ); break; case MENU_LABEL_WELCOME_TO_RETROARCH: snprintf(s, len, "Welcome to RetroArch\n" - "\n" - "For further information, go to Help.\n" ); break; case MENU_LABEL_INPUT_DRIVER: diff --git a/menu/intl/menu_hash_uspseudo.c b/menu/intl/menu_hash_uspseudo.c index d6001c7d22..09f971c8a1 100644 --- a/menu/intl/menu_hash_uspseudo.c +++ b/menu/intl/menu_hash_uspseudo.c @@ -1765,8 +1765,6 @@ int menu_hash_get_help_us(uint32_t hash, char *s, size_t len) "\n" "Èxtractìng ásséts, please waìt.\n" "This mïght take a while...\n" - "\n" - "For further infórmätíöñ, go to Hëlp.\n" ); break; case MENU_LABEL_WELCOME_TO_RETROARCH: From 78c13f59d0901b585fae74be4db449b4ee96aca7 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 2 May 2016 14:52:26 +0200 Subject: [PATCH 083/498] (iOS) Build fix --- frontend/drivers/platform_darwin.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/frontend/drivers/platform_darwin.m b/frontend/drivers/platform_darwin.m index 3ff4041f29..31bdf41987 100644 --- a/frontend/drivers/platform_darwin.m +++ b/frontend/drivers/platform_darwin.m @@ -369,7 +369,7 @@ static void frontend_darwin_get_environment_settings(int *argc, char *argv[], fill_pathname_join(g_defaults.dir.thumbnails, home_dir_buf, "thumbnails", sizeof(g_defaults.dir.thumbnails)); fill_pathname_join(g_defaults.dir.sram, home_dir_buf, "saves", sizeof(g_defaults.dir.sram)); fill_pathname_join(g_defaults.dir.savestate, home_dir_buf, "states", sizeof(g_defaults.dir.savestate)); - fill_pathname_join(g_defaults.dir.menu_config, application_data, "config", sizeof(g_defaults.dir.menu_config)); + fill_pathname_join(g_defaults.dir.menu_config, home_dir_buf, "config", sizeof(g_defaults.dir.menu_config)); fill_pathname_join(g_defaults.dir.remap, home_dir_buf, "config/remaps", sizeof(g_defaults.dir.remap)); #if defined(IOS) fill_pathname_join(g_defaults.dir.playlist, home_dir_buf, "playlists", sizeof(g_defaults.dir.playlist)); From 53fc458795b35bb8d88adc8d69d0dc19d9083b15 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 2 May 2016 14:53:23 +0200 Subject: [PATCH 084/498] (Cocoa) Store idiom type inside unsigned variable --- gfx/drivers_context/cocoa_gl_ctx.m | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/gfx/drivers_context/cocoa_gl_ctx.m b/gfx/drivers_context/cocoa_gl_ctx.m index f1bb434328..8d38890fd2 100644 --- a/gfx/drivers_context/cocoa_gl_ctx.m +++ b/gfx/drivers_context/cocoa_gl_ctx.m @@ -455,8 +455,9 @@ static bool cocoagl_gfx_ctx_get_metrics(void *data, enum display_metric_types ty float physical_width = screen_rect.size.width * scale; float physical_height = screen_rect.size.height * scale; float dpi = 160 * scale; + unsigned idiom_type = UI_USER_INTERFACE_IDIOM(); - switch (UI_USER_INTERFACE_IDIOM()) + switch (idiom_type) { case -1: /* UIUserInterfaceIdiomUnspecified */ /* TODO */ From ce5d0650141edb123dd4d87dcdc8b963320bfabd Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 2 May 2016 14:54:08 +0200 Subject: [PATCH 085/498] Cast as NSUInteger --- ui/drivers/cocoa/cocoa_common.m | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/ui/drivers/cocoa/cocoa_common.m b/ui/drivers/cocoa/cocoa_common.m index e68c043e25..e21032eb7a 100644 --- a/ui/drivers/cocoa/cocoa_common.m +++ b/ui/drivers/cocoa/cocoa_common.m @@ -150,7 +150,7 @@ void *glkitview_init(void); /* NOTE: This version runs on iOS6+. */ - (NSUInteger)supportedInterfaceOrientations { - return apple_frontend_settings.orientation_flags; + return (NSUInteger)apple_frontend_settings.orientation_flags; } /* NOTE: This version runs on iOS2-iOS5, but not iOS6+. */ From 84f9a4c1d7727d40185b103df7b8d7bdfae21f48 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Mon, 2 May 2016 15:10:20 +0200 Subject: [PATCH 086/498] (OSX) Path fix --- frontend/drivers/platform_darwin.m | 4 ++-- .../Media.xcassets/AppIcon.appiconset/Contents.json | 10 ++++++---- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/frontend/drivers/platform_darwin.m b/frontend/drivers/platform_darwin.m index 31bdf41987..200ce04832 100644 --- a/frontend/drivers/platform_darwin.m +++ b/frontend/drivers/platform_darwin.m @@ -385,10 +385,10 @@ static void frontend_darwin_get_environment_settings(int *argc, char *argv[], fill_pathname_join(g_defaults.dir.audio_filter, home_dir_buf, "audio_filters", sizeof(g_defaults.dir.audio_filter)); fill_pathname_join(g_defaults.dir.video_filter, home_dir_buf, "video_filters", sizeof(g_defaults.dir.video_filter)); fill_pathname_join(g_defaults.dir.playlist, application_data, "playlists", sizeof(g_defaults.dir.playlist)); - fill_pathname_join(g_defaults.path.config, g_defaults.dir.menu_config, "retroarch.cfg", sizeof(g_defaults.path.config)); fill_pathname_join(g_defaults.dir.thumbnails, application_data, "thumbnails", sizeof(g_defaults.dir.thumbnails)); fill_pathname_join(g_defaults.dir.menu_config, application_data, "config", sizeof(g_defaults.dir.menu_config)); - fill_pathname_join(g_defaults.dir.remap, application_data, "config/remaps", sizeof(g_defaults.dir.remap)); + fill_pathname_join(g_defaults.path.config, g_defaults.dir.menu_config, "retroarch.cfg", sizeof(g_defaults.path.config)); + fill_pathname_join(g_defaults.dir.remap, g_defaults.dir.menu_config, "remaps", sizeof(g_defaults.dir.remap)); fill_pathname_join(g_defaults.dir.core_assets, application_data, "downloads", sizeof(g_defaults.dir.core_assets)); fill_pathname_join(g_defaults.dir.screenshot, application_data, "screenshots", sizeof(g_defaults.dir.screenshot)); #if defined(RELEASE_BUILD) diff --git a/pkg/apple/iOS/Resources/Media.xcassets/AppIcon.appiconset/Contents.json b/pkg/apple/iOS/Resources/Media.xcassets/AppIcon.appiconset/Contents.json index bb49422564..6fa7ead483 100644 --- a/pkg/apple/iOS/Resources/Media.xcassets/AppIcon.appiconset/Contents.json +++ b/pkg/apple/iOS/Resources/Media.xcassets/AppIcon.appiconset/Contents.json @@ -113,13 +113,15 @@ "idiom" : "ipad", "filename" : "Icon-76-2.png", "scale" : "2x" + }, + { + "idiom" : "ipad", + "size" : "83.5x83.5", + "scale" : "2x" } ], "info" : { "version" : 1, "author" : "xcode" - }, - "properties" : { - "pre-rendered" : false } -} +} \ No newline at end of file From da6a301a6e5da243796a0f5f3e034b2bc9e0e91d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 2 May 2016 15:20:20 +0200 Subject: [PATCH 087/498] (Frontend) Cleanups --- frontend/drivers/platform_darwin.m | 2 +- frontend/drivers/platform_linux.c | 54 ++++++++++++++++++------------ 2 files changed, 34 insertions(+), 22 deletions(-) diff --git a/frontend/drivers/platform_darwin.m b/frontend/drivers/platform_darwin.m index 200ce04832..d38fc6f775 100644 --- a/frontend/drivers/platform_darwin.m +++ b/frontend/drivers/platform_darwin.m @@ -363,6 +363,7 @@ static void frontend_darwin_get_environment_settings(int *argc, char *argv[], fill_pathname_join(g_defaults.dir.system, home_dir_buf, "system", sizeof(g_defaults.dir.system)); fill_pathname_join(g_defaults.dir.menu_config, home_dir_buf, "config", sizeof(g_defaults.dir.menu_config)); fill_pathname_join(g_defaults.path.config, g_defaults.dir.menu_config, "retroarch.cfg", sizeof(g_defaults.path.config)); + fill_pathname_join(g_defaults.dir.remap, g_defaults.dir.menu_config, "remaps", sizeof(g_defaults.dir.remap)); fill_pathname_join(g_defaults.dir.database, home_dir_buf, "database/rdb", sizeof(g_defaults.dir.database)); fill_pathname_join(g_defaults.dir.cursor, home_dir_buf, "database/cursors", sizeof(g_defaults.dir.cursor)); fill_pathname_join(g_defaults.dir.cheats, home_dir_buf, "cht", sizeof(g_defaults.dir.cheats)); @@ -370,7 +371,6 @@ static void frontend_darwin_get_environment_settings(int *argc, char *argv[], fill_pathname_join(g_defaults.dir.sram, home_dir_buf, "saves", sizeof(g_defaults.dir.sram)); fill_pathname_join(g_defaults.dir.savestate, home_dir_buf, "states", sizeof(g_defaults.dir.savestate)); fill_pathname_join(g_defaults.dir.menu_config, home_dir_buf, "config", sizeof(g_defaults.dir.menu_config)); - fill_pathname_join(g_defaults.dir.remap, home_dir_buf, "config/remaps", sizeof(g_defaults.dir.remap)); #if defined(IOS) fill_pathname_join(g_defaults.dir.playlist, home_dir_buf, "playlists", sizeof(g_defaults.dir.playlist)); #endif diff --git a/frontend/drivers/platform_linux.c b/frontend/drivers/platform_linux.c index 26cead732f..16a78f7382 100644 --- a/frontend/drivers/platform_linux.c +++ b/frontend/drivers/platform_linux.c @@ -1867,72 +1867,84 @@ static void frontend_linux_get_env(int *argc, case INT_SD_APPDIR_WRITABLE: fill_pathname_join(g_defaults.dir.sram, int_sd_app_dir, "saves", sizeof(g_defaults.dir.sram)); - path_mkdir(g_defaults.dir.sram); fill_pathname_join(g_defaults.dir.savestate, int_sd_app_dir, "states", sizeof(g_defaults.dir.savestate)); - path_mkdir(g_defaults.dir.savestate); fill_pathname_join(g_defaults.dir.system, int_sd_app_dir, "system", sizeof(g_defaults.dir.system)); - path_mkdir(g_defaults.dir.system); fill_pathname_join(g_defaults.dir.menu_config, int_sd_app_dir, "config", sizeof(g_defaults.dir.menu_config)); - path_mkdir(g_defaults.dir.menu_config); fill_pathname_join(g_defaults.dir.remap, - int_sd_app_dir, "config/remap", sizeof(g_defaults.dir.remap)); - path_mkdir(g_defaults.dir.remap); + g_defaults.dir.menu_config, "remaps", sizeof(g_defaults.dir.remap)); fill_pathname_join(g_defaults.dir.thumbnails, int_sd_app_dir, "thumbnails", sizeof(g_defaults.dir.thumbnails)); - path_mkdir(g_defaults.dir.thumbnails); fill_pathname_join(g_defaults.dir.playlist, int_sd_app_dir, "playlists", sizeof(g_defaults.dir.playlist)); - path_mkdir(g_defaults.dir.playlist); fill_pathname_join(g_defaults.dir.cheats, int_sd_app_dir, "cheats", sizeof(g_defaults.dir.cheats)); + + /* TODO/FIXME - Test if this is needed at all, as far as I know, + * every directory we set in g_defaults already gets created if it + * doesn't exist already */ + path_mkdir(g_defaults.dir.sram); + path_mkdir(g_defaults.dir.savestate); + path_mkdir(g_defaults.dir.system); + path_mkdir(g_defaults.dir.menu_config); + path_mkdir(g_defaults.dir.remap); + path_mkdir(g_defaults.dir.thumbnails); + path_mkdir(g_defaults.dir.playlist); path_mkdir(g_defaults.dir.cheats); break; case INT_SD_NOT_WRITABLE: fill_pathname_join(g_defaults.dir.sram, app_dir, "saves", sizeof(g_defaults.dir.sram)); - path_mkdir(g_defaults.dir.sram); fill_pathname_join(g_defaults.dir.savestate, app_dir, "states", sizeof(g_defaults.dir.savestate)); - path_mkdir(g_defaults.dir.savestate); fill_pathname_join(g_defaults.dir.system, app_dir, "system", sizeof(g_defaults.dir.system)); - path_mkdir(g_defaults.dir.system); fill_pathname_join(g_defaults.dir.menu_config, app_dir, "config", sizeof(g_defaults.dir.menu_config)); - path_mkdir(g_defaults.dir.menu_config); fill_pathname_join(g_defaults.dir.remap, - app_dir, "config/remap", sizeof(g_defaults.dir.remap)); - path_mkdir(g_defaults.dir.remap); + g_defaults.dir.menu_config, "remaps", sizeof(g_defaults.dir.remap)); fill_pathname_join(g_defaults.dir.thumbnails, app_dir, "thumbnails", sizeof(g_defaults.dir.thumbnails)); - path_mkdir(g_defaults.dir.thumbnails); fill_pathname_join(g_defaults.dir.playlist, app_dir, "playlists", sizeof(g_defaults.dir.playlist)); - path_mkdir(g_defaults.dir.playlist); fill_pathname_join(g_defaults.dir.cheats, app_dir, "cheats", sizeof(g_defaults.dir.cheats)); + + /* TODO/FIXME - Test if this is needed at all, as far as I know, + * every directory we set in g_defaults already gets created if it + * doesn't exist already */ + path_mkdir(g_defaults.dir.sram); + path_mkdir(g_defaults.dir.savestate); + path_mkdir(g_defaults.dir.system); + path_mkdir(g_defaults.dir.menu_config); + path_mkdir(g_defaults.dir.remap); + path_mkdir(g_defaults.dir.thumbnails); + path_mkdir(g_defaults.dir.playlist); path_mkdir(g_defaults.dir.cheats); break; case INT_SD_WRITABLE: fill_pathname_join(g_defaults.dir.menu_config, int_sd_dir, "RetroArch/config", sizeof(g_defaults.dir.menu_config)); - path_mkdir(g_defaults.dir.menu_config); fill_pathname_join(g_defaults.dir.remap, - int_sd_dir, "RetroArch/config/remap", sizeof(g_defaults.dir.remap)); - path_mkdir(g_defaults.dir.remap); + g_defaults.dir.menu_config, "remaps", sizeof(g_defaults.dir.remap)); fill_pathname_join(g_defaults.dir.thumbnails, int_sd_dir, "RetroArch/thumbnails", sizeof(g_defaults.dir.thumbnails)); - path_mkdir(g_defaults.dir.thumbnails); fill_pathname_join(g_defaults.dir.playlist, int_sd_dir, "RetroArch/playlists", sizeof(g_defaults.dir.playlist)); - path_mkdir(g_defaults.dir.playlist); fill_pathname_join(g_defaults.dir.cheats, int_sd_dir, "RetroArch/cheats", sizeof(g_defaults.dir.cheats)); + + /* TODO/FIXME - Test if this is needed at all, as far as I know, + * every directory we set in g_defaults already gets created if it + * doesn't exist already */ + path_mkdir(g_defaults.dir.menu_config); + path_mkdir(g_defaults.dir.remap); + path_mkdir(g_defaults.dir.thumbnails); + path_mkdir(g_defaults.dir.playlist); path_mkdir(g_defaults.dir.cheats); default: break; From 1e4796142087e841c6f77dde3d2df52bb52138b8 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 2 May 2016 15:21:30 +0200 Subject: [PATCH 088/498] Cleanups --- frontend/drivers/platform_linux.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/frontend/drivers/platform_linux.c b/frontend/drivers/platform_linux.c index 16a78f7382..ff4394ac70 100644 --- a/frontend/drivers/platform_linux.c +++ b/frontend/drivers/platform_linux.c @@ -1951,29 +1951,23 @@ static void frontend_linux_get_env(int *argc, } /* create save and system directories in the internal dir too */ - fill_pathname_join(buf, - app_dir, "saves", sizeof(buf)); + fill_pathname_join(buf, app_dir, "saves", sizeof(buf)); path_mkdir(buf); - fill_pathname_join(buf, - app_dir, "states", sizeof(buf)); + fill_pathname_join(buf, app_dir, "states", sizeof(buf)); path_mkdir(buf); - fill_pathname_join(buf, - app_dir, "system", sizeof(buf)); + fill_pathname_join(buf, app_dir, "system", sizeof(buf)); path_mkdir(buf); /* create save and system directories in the internal sd too */ - fill_pathname_join(buf, - int_sd_app_dir, "saves", sizeof(buf)); + fill_pathname_join(buf, int_sd_app_dir, "saves", sizeof(buf)); path_mkdir(buf); - fill_pathname_join(buf, - int_sd_app_dir, "states", sizeof(buf)); + fill_pathname_join(buf, int_sd_app_dir, "states", sizeof(buf)); path_mkdir(buf); - fill_pathname_join(buf, - int_sd_app_dir, "system", sizeof(buf)); + fill_pathname_join(buf, int_sd_app_dir, "system", sizeof(buf)); path_mkdir(buf); RARCH_LOG("Default savefile folder: [%s]", g_defaults.dir.sram); From c9eac5cdc0e0a2fb2879b9226e16ccce6374af0e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 2 May 2016 15:24:06 +0200 Subject: [PATCH 089/498] (Frontend / Linux) Create config dir by default --- frontend/drivers/platform_linux.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/frontend/drivers/platform_linux.c b/frontend/drivers/platform_linux.c index ff4394ac70..6d45389c3c 100644 --- a/frontend/drivers/platform_linux.c +++ b/frontend/drivers/platform_linux.c @@ -2025,8 +2025,10 @@ static void frontend_linux_get_env(int *argc, "autoconfig", sizeof(g_defaults.dir.autoconfig)); fill_pathname_join(g_defaults.dir.assets, base_path, "assets", sizeof(g_defaults.dir.assets)); - fill_pathname_join(g_defaults.dir.remap, base_path, - "remap", sizeof(g_defaults.dir.remap)); + fill_pathname_join(g_defaults.dir.menu_config, base_path, + "config", sizeof(g_defaults.dir.menu_config)); + fill_pathname_join(g_defaults.dir.remap, g_defaults.dir.menu_config, + "remaps", sizeof(g_defaults.dir.remap)); fill_pathname_join(g_defaults.dir.playlist, base_path, "playlists", sizeof(g_defaults.dir.playlist)); fill_pathname_join(g_defaults.dir.cursor, base_path, From eeeec23c66ffb7b44eac95df8dc2613c3717ce2c Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Mon, 2 May 2016 16:57:28 +0200 Subject: [PATCH 090/498] (OSX) Static code analyzer cleanups --- libretro-common/formats/png/rpng.c | 2 -- libretro-db/libretrodb.c | 12 ------------ libretro-db/rmsgpack.c | 7 +------ libretro-db/rmsgpack_dom.c | 9 +-------- menu/menu_displaylist.c | 4 ---- rewind.c | 5 ++--- 6 files changed, 4 insertions(+), 35 deletions(-) diff --git a/libretro-common/formats/png/rpng.c b/libretro-common/formats/png/rpng.c index fb15c7e221..528d361b58 100644 --- a/libretro-common/formats/png/rpng.c +++ b/libretro-common/formats/png/rpng.c @@ -1056,8 +1056,6 @@ bool rpng_load_image_argb(const char *path, uint32_t **data, if (!handle) goto end; - ptr = nbio_get_ptr(handle, &file_len); - nbio_begin_read(handle); while (!nbio_iterate(handle)); diff --git a/libretro-db/libretrodb.c b/libretro-db/libretrodb.c index 8defc82d33..8733b52b82 100644 --- a/libretro-db/libretrodb.c +++ b/libretro-db/libretrodb.c @@ -461,7 +461,6 @@ static uint64_t libretrodb_tell(libretrodb_t *db) int libretrodb_create_index(libretrodb_t *db, const char *name, const char *field_name) { - int rv; struct node_iter_ctx nictx; struct rmsgpack_dom_value key; libretrodb_index_t idx; @@ -476,10 +475,7 @@ int libretrodb_create_index(libretrodb_t *db, bintree_t *tree = bintree_new(node_compare, &field_size); if (!tree || (libretrodb_cursor_open(db, &cur, NULL) != 0)) - { - rv = -1; goto clean; - } key.type = RDT_STRING; key.val.string.len = strlen(field_name); @@ -491,7 +487,6 @@ int libretrodb_create_index(libretrodb_t *db, { if (item.type != RDT_MAP) { - rv = -EINVAL; printf("Only map keys are supported\n"); goto clean; } @@ -500,21 +495,18 @@ int libretrodb_create_index(libretrodb_t *db, if (!field) { - rv = -EINVAL; printf("field not found in item\n"); goto clean; } if (field->type != RDT_BINARY) { - rv = -EINVAL; printf("field is not binary\n"); goto clean; } if (field->val.binary.len == 0) { - rv = -EINVAL; printf("field is empty\n"); goto clean; } @@ -523,7 +515,6 @@ int libretrodb_create_index(libretrodb_t *db, field_size = field->val.binary.len; else if (field->val.binary.len != field_size) { - rv = -EINVAL; printf("field is not of correct size\n"); goto clean; } @@ -531,7 +522,6 @@ int libretrodb_create_index(libretrodb_t *db, buff = malloc(field_size + sizeof(uint64_t)); if (!buff) { - rv = -ENOMEM; goto clean; } @@ -546,7 +536,6 @@ int libretrodb_create_index(libretrodb_t *db, printf("Value is not unique: "); rmsgpack_dom_value_print(field); printf("\n"); - rv = -EINVAL; goto clean; } buff = NULL; @@ -557,7 +546,6 @@ int libretrodb_create_index(libretrodb_t *db, idx_header_offset = filestream_seek(db->fd, 0, SEEK_END); (void)idx_header_offset; - (void)rv; strncpy(idx.name, name, 50); diff --git a/libretro-db/rmsgpack.c b/libretro-db/rmsgpack.c index 555be5af6d..9290a7b78c 100644 --- a/libretro-db/rmsgpack.c +++ b/libretro-db/rmsgpack.c @@ -223,7 +223,6 @@ int rmsgpack_write_bin(RFILE *fd, const void *s, uint32_t len) { uint16_t tmp_i16; uint32_t tmp_i32; - int written = sizeof(int8_t); if (len == (uint8_t)len) { @@ -231,7 +230,6 @@ int rmsgpack_write_bin(RFILE *fd, const void *s, uint32_t len) goto error; if (filestream_write(fd, &len, sizeof(uint8_t)) == -1) goto error; - written += sizeof(uint8_t); } else if (len == (uint16_t)len) { @@ -240,7 +238,6 @@ int rmsgpack_write_bin(RFILE *fd, const void *s, uint32_t len) tmp_i16 = swap_if_little16(len); if (filestream_write(fd, &tmp_i16, sizeof(uint16_t)) == -1) goto error; - written += sizeof(uint16_t); } else { @@ -249,13 +246,11 @@ int rmsgpack_write_bin(RFILE *fd, const void *s, uint32_t len) tmp_i32 = swap_if_little32(len); if (filestream_write(fd, &tmp_i32, sizeof(uint32_t)) == -1) goto error; - written += sizeof(uint32_t); } + if (filestream_write(fd, s, len) == -1) goto error; - written += len; - return 0; error: diff --git a/libretro-db/rmsgpack_dom.c b/libretro-db/rmsgpack_dom.c index 4772212730..b1add50697 100644 --- a/libretro-db/rmsgpack_dom.c +++ b/libretro-db/rmsgpack_dom.c @@ -162,7 +162,7 @@ static int dom_read_array_start(uint32_t len, void *data) v->val.array.len = len; v->val.array.items = NULL; - items = (struct rmsgpack_dom_value *)calloc(len, sizeof(struct rmsgpack_dom_pair)); + items = (struct rmsgpack_dom_value *)calloc(len, sizeof(*items)); if (!items) return -ENOMEM; @@ -454,20 +454,14 @@ int rmsgpack_dom_read_into(RFILE *fd, ...) } if (map.type != RDT_MAP) - { - rv = -EINVAL; goto clean; - } while (1) { key_name = va_arg(ap, const char *); if (!key_name) - { - rv = 0; goto clean; - } key.type = RDT_STRING; key.val.string.len = strlen(key_name); @@ -508,7 +502,6 @@ int rmsgpack_dom_read_into(RFILE *fd, ...) memcpy(buff_value, value->val.string.buff, (size_t)min_len); break; default: - rv = -1; goto clean; } } diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index a019b1c277..69ccbbe84c 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -1299,15 +1299,12 @@ static int menu_displaylist_parse_playlist(menu_displaylist_info_t *info, { uint32_t core_name_hash; char fill_buf[PATH_MAX_LENGTH], path_copy[PATH_MAX_LENGTH]; - bool core_detected = false; const char *core_name = NULL; const char *db_name = NULL; const char *path = NULL; const char *label = NULL; const char *crc32 = NULL; - (void)core_detected; - strlcpy(path_copy, info->path, sizeof(path_copy)); path = path_copy; @@ -1335,7 +1332,6 @@ static int menu_displaylist_parse_playlist(menu_displaylist_info_t *info, char tmp[PATH_MAX_LENGTH] = {0}; snprintf(tmp, sizeof(tmp), " (%s)", core_name); strlcat(fill_buf, tmp, sizeof(fill_buf)); - core_detected = true; } } } diff --git a/rewind.c b/rewind.c index e59cb643fe..22274aa35f 100644 --- a/rewind.c +++ b/rewind.c @@ -302,8 +302,8 @@ static size_t state_manager_raw_compress(const void *src, if (skip >= num16s) break; - old16 += skip; - new16 += skip; + old16 += skip; + new16 += skip; num16s -= skip; if (skip > UINT16_MAX) @@ -318,7 +318,6 @@ static size_t state_manager_raw_compress(const void *src, *compressed16++ = 0; *compressed16++ = skip; *compressed16++ = skip >> 16; - skip = 0; continue; } From 0fc31d261656cc37d5c9e58c3a95601ef46f2153 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Mon, 2 May 2016 17:02:09 +0200 Subject: [PATCH 091/498] (menu_cbs.c) More cleanups --- menu/menu_cbs.c | 35 +++++++++++++++-------------------- 1 file changed, 15 insertions(+), 20 deletions(-) diff --git a/menu/menu_cbs.c b/menu/menu_cbs.c index e1ae0d439a..48c584988a 100644 --- a/menu/menu_cbs.c +++ b/menu/menu_cbs.c @@ -45,7 +45,6 @@ void menu_cbs_init(void *data, const char *repr_label = NULL; struct string_list *str_list = NULL; const char *menu_label = NULL; - int ret = 0; uint32_t label_hash = 0; uint32_t menu_label_hash = 0; file_list_t *list = (file_list_t*)data; @@ -77,63 +76,63 @@ void menu_cbs_init(void *data, repr_label = (!string_is_empty(label)) ? label : path; - ret = menu_cbs_init_bind_ok(cbs, path, label, type, idx, elem0, elem1, menu_label, label_hash, menu_label_hash); + menu_cbs_init_bind_ok(cbs, path, label, type, idx, elem0, elem1, menu_label, label_hash, menu_label_hash); menu_cbs_init_log(repr_label, "OK", cbs->action_ok_ident); - ret = menu_cbs_init_bind_cancel(cbs, path, label, type, idx, elem0, elem1, label_hash, menu_label_hash); + menu_cbs_init_bind_cancel(cbs, path, label, type, idx, elem0, elem1, label_hash, menu_label_hash); menu_cbs_init_log(repr_label, "CANCEL", cbs->action_cancel_ident); - ret = menu_cbs_init_bind_scan(cbs, path, label, type, idx, elem0, elem1, label_hash, menu_label_hash); + menu_cbs_init_bind_scan(cbs, path, label, type, idx, elem0, elem1, label_hash, menu_label_hash); menu_cbs_init_log(repr_label, "SCAN", cbs->action_scan_ident); - ret = menu_cbs_init_bind_start(cbs, path, label, type, idx, elem0, elem1, label_hash, menu_label_hash); + menu_cbs_init_bind_start(cbs, path, label, type, idx, elem0, elem1, label_hash, menu_label_hash); menu_cbs_init_log(repr_label, "START", cbs->action_start_ident); - ret = menu_cbs_init_bind_select(cbs, path, label, type, idx, elem0, elem1, label_hash, menu_label_hash); + menu_cbs_init_bind_select(cbs, path, label, type, idx, elem0, elem1, label_hash, menu_label_hash); menu_cbs_init_log(repr_label, "SELECT", cbs->action_select_ident); - ret = menu_cbs_init_bind_info(cbs, path, label, type, idx, elem0, elem1, label_hash, menu_label_hash); + menu_cbs_init_bind_info(cbs, path, label, type, idx, elem0, elem1, label_hash, menu_label_hash); menu_cbs_init_log(repr_label, "INFO", cbs->action_info_ident); - ret = menu_cbs_init_bind_content_list_switch(cbs, path, label, type, idx, elem0, elem1, label_hash, menu_label_hash); + menu_cbs_init_bind_content_list_switch(cbs, path, label, type, idx, elem0, elem1, label_hash, menu_label_hash); menu_cbs_init_log(repr_label, "CONTENT SWITCH", cbs->action_content_list_switch_ident); - ret = menu_cbs_init_bind_up(cbs, path, label, type, idx, elem0, elem1, label_hash, menu_label_hash); + menu_cbs_init_bind_up(cbs, path, label, type, idx, elem0, elem1, label_hash, menu_label_hash); menu_cbs_init_log(repr_label, "UP", cbs->action_up_ident); - ret = menu_cbs_init_bind_down(cbs, path, label, type, idx, elem0, elem1, label_hash, menu_label_hash); + menu_cbs_init_bind_down(cbs, path, label, type, idx, elem0, elem1, label_hash, menu_label_hash); menu_cbs_init_log(repr_label, "DOWN", cbs->action_down_ident); - ret = menu_cbs_init_bind_left(cbs, path, label, type, idx, elem0, elem1, menu_label, label_hash, menu_label_hash); + menu_cbs_init_bind_left(cbs, path, label, type, idx, elem0, elem1, menu_label, label_hash, menu_label_hash); menu_cbs_init_log(repr_label, "LEFT", cbs->action_left_ident); - ret = menu_cbs_init_bind_right(cbs, path, label, type, idx, elem0, elem1, menu_label, label_hash, menu_label_hash); + menu_cbs_init_bind_right(cbs, path, label, type, idx, elem0, elem1, menu_label, label_hash, menu_label_hash); menu_cbs_init_log(repr_label, "RIGHT", cbs->action_right_ident); - ret = menu_cbs_init_bind_deferred_push(cbs, path, label, type, idx, elem0, elem1, label_hash, menu_label_hash); + menu_cbs_init_bind_deferred_push(cbs, path, label, type, idx, elem0, elem1, label_hash, menu_label_hash); menu_cbs_init_log(repr_label, "DEFERRED PUSH", cbs->action_deferred_push_ident); - ret = menu_cbs_init_bind_refresh(cbs, path, label, type, idx, elem0, elem1, label_hash, menu_label_hash); + menu_cbs_init_bind_refresh(cbs, path, label, type, idx, elem0, elem1, label_hash, menu_label_hash); menu_cbs_init_log(repr_label, "REFRESH", cbs->action_refresh_ident); - ret = menu_cbs_init_bind_get_string_representation(cbs, path, label, type, idx, elem0, elem1, label_hash, menu_label_hash); + menu_cbs_init_bind_get_string_representation(cbs, path, label, type, idx, elem0, elem1, label_hash, menu_label_hash); menu_cbs_init_log(repr_label, "GET VALUE", cbs->action_get_value_ident); - ret = menu_cbs_init_bind_title(cbs, path, label, type, idx, elem0, elem1, label_hash, menu_label_hash); + menu_cbs_init_bind_title(cbs, path, label, type, idx, elem0, elem1, label_hash, menu_label_hash); menu_cbs_init_log(repr_label, "GET TITLE", cbs->action_get_title_ident); @@ -149,10 +148,6 @@ void menu_cbs_init(void *data, menu_driver_ctl(RARCH_MENU_CTL_BIND_INIT, &bind_info); - ret = bind_info.retcode; - - (void)ret; - error: string_list_free(str_list); str_list = NULL; From 4039bc89d66935565a2f330f6f7fc411932dfdc2 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Mon, 2 May 2016 17:08:40 +0200 Subject: [PATCH 092/498] (gl_raster_font.c) Cleanups --- gfx/drivers_font/gl_raster_font.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/gfx/drivers_font/gl_raster_font.c b/gfx/drivers_font/gl_raster_font.c index 81cc384d93..cc3904a719 100644 --- a/gfx/drivers_font/gl_raster_font.c +++ b/gfx/drivers_font/gl_raster_font.c @@ -60,23 +60,20 @@ static bool gl_raster_font_upload_atlas(gl_raster_t *font, uint8_t *tmp = NULL; struct retro_hw_render_callback *hwr = NULL; bool ancient = false; /* add a check here if needed */ - bool modern = font->gl->core_context; video_driver_ctl(RARCH_DISPLAY_CTL_HW_CONTEXT_GET, &hwr); - modern = modern || - (hwr->context_type == RETRO_HW_CONTEXT_OPENGL && - hwr->version_major >= 3); - if (ancient) { - gl_internal = gl_format = GL_RGBA; + gl_internal = GL_RGBA; + gl_format = GL_RGBA; ncomponents = 4; } -#ifdef HAVE_OPENGLES - (void)modern; -#elif defined(GL_VERSION_3_0) - else if (modern) + +#if defined(GL_VERSION_3_0) + if (font->gl->core_context || + (hwr->context_type == RETRO_HW_CONTEXT_OPENGL && + hwr->version_major >= 3)) { GLint swizzle[] = { GL_ONE, GL_ONE, GL_ONE, GL_RED }; glTexParameteriv(GL_TEXTURE_2D, GL_TEXTURE_SWIZZLE_RGBA, swizzle); From 54427bd3771b3976b2c5ab86b9987cbe894bd75a Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Mon, 2 May 2016 17:10:21 +0200 Subject: [PATCH 093/498] (gl_raster_font.c) Avoid another static code analysis warning --- gfx/drivers_font/gl_raster_font.c | 1 - 1 file changed, 1 deletion(-) diff --git a/gfx/drivers_font/gl_raster_font.c b/gfx/drivers_font/gl_raster_font.c index cc3904a719..89c9259b69 100644 --- a/gfx/drivers_font/gl_raster_font.c +++ b/gfx/drivers_font/gl_raster_font.c @@ -98,7 +98,6 @@ static bool gl_raster_font_upload_atlas(gl_raster_t *font, { case 1: memcpy(dst, src, atlas->width); - src += atlas->width; break; case 2: for (j = 0; j < atlas->width; ++j) From ff5190ac767560e1d41c88c6b7a655ad313475fb Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 2 May 2016 17:28:20 +0200 Subject: [PATCH 094/498] menu_displaylist_ctl - cleanups --- menu/menu_displaylist.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 69ccbbe84c..f57fb1bca0 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -3101,9 +3101,9 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) } if (!info) - return false; + goto error; if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu)) - return false; + goto error; settings = config_get_ptr(); @@ -3299,14 +3299,14 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) (menu_displaylist_ctx_parse_entry_t*)data; if (!entry) - return false; + goto error; if (menu_displaylist_parse_settings(entry->data, entry->info, entry->info_label, entry->parse_type, entry->add_empty_entry) == -1) - return false; + goto error; } return true; @@ -3654,7 +3654,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) struct string_list *str_list = string_split(info->label, "|"); if (!str_list) - return false; + goto error; strlcpy(info->path_b, str_list->elems[1].data, sizeof(info->path_b)); @@ -3722,7 +3722,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) { if (menu_displaylist_ctl(DISPLAYLIST_HISTORY, info)) return menu_displaylist_push_list_process(info); - return false; + goto error; } else { @@ -4068,7 +4068,10 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) } if (ret != 0) - return false; + goto error; return true; + +error: + return false; } From e0c7bd2e575d92285b2d979d5e7d8bbcaaf1819a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 2 May 2016 17:33:29 +0200 Subject: [PATCH 095/498] (menu_displaylist.c) Cleanups --- menu/menu_displaylist.c | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index f57fb1bca0..dd685f2bfd 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -2708,10 +2708,13 @@ static int menu_displaylist_parse_generic( is_dir = (file_type == MENU_FILE_DIRECTORY); - if (push_dir && !is_dir) - continue; - if (hash_label == MENU_LABEL_SCAN_DIRECTORY && !is_dir) - continue; + if (!is_dir) + { + if (push_dir) + continue; + if (hash_label == MENU_LABEL_SCAN_DIRECTORY) + continue; + } /* Need to preserve slash first time. */ path = str_list->elems[i].data; @@ -3865,13 +3868,19 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) { for (i = 0; i < cores_names_size; i++) { - if (type == DISPLAYLIST_CORES_COLLECTION_SUPPORTED) - menu_entries_add(info->list, cores_paths->elems[i].data, "", - MENU_FILE_CORE, 0, 0); - else - menu_entries_add(info->list, cores_paths->elems[i].data, - menu_hash_to_str(MENU_LABEL_DETECT_CORE_LIST_OK), - MENU_FILE_CORE, 0, 0); + switch (type) + { + case DISPLAYLIST_CORES_COLLECTION_SUPPORTED: + menu_entries_add(info->list, cores_paths->elems[i].data, "", + MENU_FILE_CORE, 0, 0); + break; + default: + menu_entries_add(info->list, cores_paths->elems[i].data, + menu_hash_to_str(MENU_LABEL_DETECT_CORE_LIST_OK), + MENU_FILE_CORE, 0, 0); + break; + } + menu_entries_set_alt_at_offset(info->list, i, cores_names->elems[i].data); } From 0badc3ffd22a27f0fd5578248b93713b0a789181 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 2 May 2016 17:48:17 +0200 Subject: [PATCH 096/498] Cleanup --- menu/menu_displaylist.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index dd685f2bfd..751ad7344e 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -2710,9 +2710,7 @@ static int menu_displaylist_parse_generic( if (!is_dir) { - if (push_dir) - continue; - if (hash_label == MENU_LABEL_SCAN_DIRECTORY) + if (push_dir || hash_label == MENU_LABEL_SCAN_DIRECTORY) continue; } From 62508eca779865daa2a733471150d718e3f00072 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 2 May 2016 18:37:08 +0200 Subject: [PATCH 097/498] Create socket_create --- libretro-common/include/net/net_socket.h | 10 +++- libretro-common/net/net_socket.c | 60 ++++++++++++++++++++++++ netlogger.c | 13 +++-- 3 files changed, 79 insertions(+), 4 deletions(-) diff --git a/libretro-common/include/net/net_socket.h b/libretro-common/include/net/net_socket.h index a1ab722fa3..854f307036 100644 --- a/libretro-common/include/net/net_socket.h +++ b/libretro-common/include/net/net_socket.h @@ -31,10 +31,16 @@ RETRO_BEGIN_DECLS +enum socket_domain +{ + SOCKET_DOMAIN_INET = 0 +}; + enum socket_type { SOCKET_TYPE_DATAGRAM = 0, - SOCKET_TYPE_STREAM + SOCKET_TYPE_STREAM, + SOCKET_TYPE_SEQPACKET }; int socket_init(void **address, uint16_t port, const char *server, enum socket_type type); @@ -57,6 +63,8 @@ bool socket_bind(int fd, void *data); int socket_connect(int fd, void *data, bool timeout_enable); +int socket_create(const char *name, enum socket_domain domain_type, enum socket_type socket_type, int protocol); + RETRO_END_DECLS #endif diff --git a/libretro-common/net/net_socket.c b/libretro-common/net/net_socket.c index 22e07fb2f9..189d00cf42 100644 --- a/libretro-common/net/net_socket.c +++ b/libretro-common/net/net_socket.c @@ -49,6 +49,9 @@ int socket_init(void **address, uint16_t port, const char *server, enum socket_t case SOCKET_TYPE_STREAM: hints.ai_socktype = SOCK_STREAM; break; + case SOCKET_TYPE_SEQPACKET: + /* TODO/FIXME - implement? */ + break; } if (!server) @@ -211,3 +214,60 @@ int socket_connect(int fd, void *data, bool timeout_enable) return connect(fd, addr->ai_addr, addr->ai_addrlen); } + +int socket_create( + const char *name, + enum socket_domain domain_type, + enum socket_type socket_type, + int protocol) +{ +#ifdef VITA + int type = 0; + int domain = 0; + + switch (domain_type) + { + case SOCKET_DOMAIN_INET: + domain = PSP2_NET_AF_INET; + break; + } + + switch (socket_type) + { + case SOCKET_TYPE_DATAGRAM: + type = PSP2_NET_SOCK_DGRAM; + break; + case SOCKET_TYPE_STREAM: + type = PSP2_NET_SOCK_STREAM; + break; + case SOCKET_TYPE_SEQPACKET: + /* TODO/FIXME - implement */ + break; + } + return sceNetSocket(name, domain, type, protocol); +#else + int type = 0; + int domain = 0; + + switch (domain_type) + { + case SOCKET_DOMAIN_INET: + domain = AF_INET; + break; + } + + switch (socket_type) + { + case SOCKET_TYPE_DATAGRAM: + type = SOCK_DGRAM; + break; + case SOCKET_TYPE_STREAM: + type = SOCK_STREAM; + break; + case SOCKET_TYPE_SEQPACKET: + /* TODO/FIXME - implement */ + break; + } + return socket(domain, type, protocol); +#endif +} diff --git a/netlogger.c b/netlogger.c index b18b8ba015..06dd34a0b0 100644 --- a/netlogger.c +++ b/netlogger.c @@ -63,8 +63,11 @@ static int network_interface_up(struct sockaddr_in *target, int index, sceNetInit(&initparam); } - *s = sceNetSocket("RA_netlogger", - PSP2_NET_AF_INET, PSP2_NET_SOCK_DGRAM, 0); + *s = socket_create( + "ra_netlogger", + SOCKET_DOMAIN_INET, + SOCKET_TYPE_DATAGRAM, + 0); target->sin_family = PSP2_NET_AF_INET; target->sin_port = sceNetHtons(udp_port); @@ -101,7 +104,11 @@ static int network_interface_up(struct sockaddr_in *target, int index, if (ret < 0) return -1; - *s = socket(AF_INET, SOCK_DGRAM, 0); + *s = socket_create( + "ra_netlogger", + SOCKET_DOMAIN_INET, + SOCKET_TYPE_DATAGRAM, + 0); target->sin_family = AF_INET; target->sin_port = htons(udp_port); From 18f8ded154ca5e085ec3b1a501b98f8f132ff772 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 2 May 2016 18:42:13 +0200 Subject: [PATCH 098/498] Flesh out socket_create some more --- libretro-common/include/net/net_socket.h | 12 +++++++- libretro-common/net/net_socket.c | 38 +++++++++++++++++++----- netlogger.c | 4 +-- 3 files changed, 44 insertions(+), 10 deletions(-) diff --git a/libretro-common/include/net/net_socket.h b/libretro-common/include/net/net_socket.h index 854f307036..8399cf9e03 100644 --- a/libretro-common/include/net/net_socket.h +++ b/libretro-common/include/net/net_socket.h @@ -43,6 +43,12 @@ enum socket_type SOCKET_TYPE_SEQPACKET }; +enum socket_protocol +{ + SOCKET_PROTOCOL_NONE = 0, + SOCKET_PROTOCOL_UDP +}; + int socket_init(void **address, uint16_t port, const char *server, enum socket_type type); int socket_close(int fd); @@ -63,7 +69,11 @@ bool socket_bind(int fd, void *data); int socket_connect(int fd, void *data, bool timeout_enable); -int socket_create(const char *name, enum socket_domain domain_type, enum socket_type socket_type, int protocol); +int socket_create( + const char *name, + enum socket_domain domain_type, + enum socket_type socket_type, + enum socket_protocol protocol_type); RETRO_END_DECLS diff --git a/libretro-common/net/net_socket.c b/libretro-common/net/net_socket.c index 189d00cf42..5a884cf0fa 100644 --- a/libretro-common/net/net_socket.c +++ b/libretro-common/net/net_socket.c @@ -217,13 +217,14 @@ int socket_connect(int fd, void *data, bool timeout_enable) int socket_create( const char *name, - enum socket_domain domain_type, - enum socket_type socket_type, - int protocol) + enum socket_domain domain_type, + enum socket_type socket_type, + enum socket_protocol protocol_type) { #ifdef VITA - int type = 0; - int domain = 0; + int type = 0; + int domain = 0; + int protocol = 0; switch (domain_type) { @@ -244,10 +245,22 @@ int socket_create( /* TODO/FIXME - implement */ break; } + + switch (protocol_type) + { + case SOCKET_PROTOCOL_NONE: + protocol = 0; + break; + case SOCKET_PROTOCOL_UDP: + /* TODO/FIXME - implement */ + break; + } + return sceNetSocket(name, domain, type, protocol); #else - int type = 0; - int domain = 0; + int type = 0; + int domain = 0; + int protocol = 0; switch (domain_type) { @@ -268,6 +281,17 @@ int socket_create( /* TODO/FIXME - implement */ break; } + + switch (protocol_type) + { + case SOCKET_PROTOCOL_NONE: + protocol = 0; + break; + case SOCKET_PROTOCOL_UDP: + /* TODO/FIXME - implement */ + break; + } + return socket(domain, type, protocol); #endif } diff --git a/netlogger.c b/netlogger.c index 06dd34a0b0..3b7b8b6363 100644 --- a/netlogger.c +++ b/netlogger.c @@ -67,7 +67,7 @@ static int network_interface_up(struct sockaddr_in *target, int index, "ra_netlogger", SOCKET_DOMAIN_INET, SOCKET_TYPE_DATAGRAM, - 0); + SOCKET_PROTOCOL_NONE); target->sin_family = PSP2_NET_AF_INET; target->sin_port = sceNetHtons(udp_port); @@ -108,7 +108,7 @@ static int network_interface_up(struct sockaddr_in *target, int index, "ra_netlogger", SOCKET_DOMAIN_INET, SOCKET_TYPE_DATAGRAM, - 0); + SOCKET_PROTOCOL_NONE); target->sin_family = AF_INET; target->sin_port = htons(udp_port); From 317ecabadf644e4a0c21e0a2ca1743b7783cedb0 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 2 May 2016 18:45:05 +0200 Subject: [PATCH 099/498] (Retropad) Use socket_create --- cores/retropad/retropad.c | 17 +++++++++++------ libretro-common/net/net_socket.c | 2 +- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/cores/retropad/retropad.c b/cores/retropad/retropad.c index 1666c8c493..a15ea797c8 100644 --- a/cores/retropad/retropad.c +++ b/cores/retropad/retropad.c @@ -10,7 +10,7 @@ * 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 . */ @@ -236,12 +236,17 @@ bool retro_load_game(const struct retro_game_info *info) { (void)info; check_variables(); - //create socket - if ( (s=socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP)) == SOCKET_ERROR) - { + + s = socket_create( + "retropad", + SOCKET_DOMAIN_INET, + SOCKET_TYPE_DATAGRAM, + SOCKET_PROTOCOL_UDP); + + if (s == SOCKET_ERROR) log_cb(RETRO_LOG_INFO, "socket failed"); - } - //setup address structure + + /* setup address structure */ memset((char *) &si_other, 0, sizeof(si_other)); si_other.sin_family = AF_INET; si_other.sin_port = htons(port); diff --git a/libretro-common/net/net_socket.c b/libretro-common/net/net_socket.c index 5a884cf0fa..5d9e6d98bc 100644 --- a/libretro-common/net/net_socket.c +++ b/libretro-common/net/net_socket.c @@ -288,7 +288,7 @@ int socket_create( protocol = 0; break; case SOCKET_PROTOCOL_UDP: - /* TODO/FIXME - implement */ + protocol = IPPROTO_UDP; break; } From 00a49d068ea26502486cc3c0277f2f5df0ea48c1 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 2 May 2016 18:47:34 +0200 Subject: [PATCH 100/498] Implement TCP protocol for socket_create --- libretro-common/include/net/net_socket.h | 1 + libretro-common/net/net_socket.c | 8 +++++++- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/libretro-common/include/net/net_socket.h b/libretro-common/include/net/net_socket.h index 8399cf9e03..0b45ded990 100644 --- a/libretro-common/include/net/net_socket.h +++ b/libretro-common/include/net/net_socket.h @@ -46,6 +46,7 @@ enum socket_type enum socket_protocol { SOCKET_PROTOCOL_NONE = 0, + SOCKET_PROTOCOL_TCP, SOCKET_PROTOCOL_UDP }; diff --git a/libretro-common/net/net_socket.c b/libretro-common/net/net_socket.c index 5d9e6d98bc..9efd5f514f 100644 --- a/libretro-common/net/net_socket.c +++ b/libretro-common/net/net_socket.c @@ -251,8 +251,11 @@ int socket_create( case SOCKET_PROTOCOL_NONE: protocol = 0; break; + case SOCKET_PROTOCOL_TCP: + protocol = PSP2_NET_IPPROTO_TCP; + break; case SOCKET_PROTOCOL_UDP: - /* TODO/FIXME - implement */ + protocol = PSP2_NET_IPPROTO_UDP; break; } @@ -287,6 +290,9 @@ int socket_create( case SOCKET_PROTOCOL_NONE: protocol = 0; break; + case SOCKET_PROTOCOL_TCP: + protocol = IPPROTO_TCP; + break; case SOCKET_PROTOCOL_UDP: protocol = IPPROTO_UDP; break; From b25b2a0e6c5ba494b550640a1bc4862cfac6b886 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 2 May 2016 18:54:55 +0200 Subject: [PATCH 101/498] Some code de-duplication --- command.c | 5 ----- libretro-common/net/net_compat.c | 14 ++++++++++---- libretro-common/net/net_socket.c | 7 ------- netplay/netplay.c | 6 ------ 4 files changed, 10 insertions(+), 22 deletions(-) diff --git a/command.c b/command.c index 60251d732d..d7ea4eca24 100644 --- a/command.c +++ b/command.c @@ -505,11 +505,6 @@ static bool send_udp_packet(const char *host, int fd = -1; bool ret = true; -#if defined(_WIN32) || defined(HAVE_SOCKET_LEGACY) - hints.ai_family = AF_INET; -#else - hints.ai_family = AF_UNSPEC; -#endif hints.ai_socktype = SOCK_DGRAM; snprintf(port_buf, sizeof(port_buf), "%hu", (unsigned short)port); diff --git a/libretro-common/net/net_compat.c b/libretro-common/net/net_compat.c index 15f9385f5c..be0393c5d0 100644 --- a/libretro-common/net/net_compat.c +++ b/libretro-common/net/net_compat.c @@ -107,10 +107,16 @@ int getaddrinfo_retro(const char *node, const char *service, if (!info) goto error; - info->ai_family = AF_INET; - info->ai_socktype = hints->ai_socktype; +#if defined(_WIN32) || defined(HAVE_SOCKET_LEGACY) + hints->ai_family = AF_INET; +#else + hints->ai_family = AF_UNSPEC; +#endif - in_addr = (struct sockaddr_in*)calloc(1, sizeof(*in_addr)); + info->ai_family = AF_INET; + info->ai_socktype = hints->ai_socktype; + in_addr = (struct sockaddr_in*) + calloc(1, sizeof(*in_addr)); if (!in_addr) goto error; @@ -136,7 +142,7 @@ int getaddrinfo_retro(const char *node, const char *service, goto error; info->ai_addr = (struct sockaddr*)in_addr; - *res = info; + *res = info; return 0; diff --git a/libretro-common/net/net_socket.c b/libretro-common/net/net_socket.c index 9efd5f514f..a2abbcf49d 100644 --- a/libretro-common/net/net_socket.c +++ b/libretro-common/net/net_socket.c @@ -31,16 +31,9 @@ int socket_init(void **address, uint16_t port, const char *server, enum socket_t struct addrinfo **addrinfo = (struct addrinfo**)address; struct addrinfo *addr = NULL; - if (!network_init()) goto error; -#if defined(_WIN32) || defined(HAVE_SOCKET_LEGACY) - hints.ai_family = AF_INET; -#else - hints.ai_family = AF_UNSPEC; -#endif - switch (type) { case SOCKET_TYPE_DATAGRAM: diff --git a/netplay/netplay.c b/netplay/netplay.c index 9d40929184..72de3f3cca 100644 --- a/netplay/netplay.c +++ b/netplay/netplay.c @@ -707,12 +707,6 @@ static bool init_tcp_socket(netplay_t *netplay, const char *server, struct addrinfo *res = NULL; struct addrinfo hints = {0}; -#if defined(_WIN32) || defined(HAVE_SOCKET_LEGACY) - hints.ai_family = AF_INET; -#else - hints.ai_family = AF_UNSPEC; -#endif - hints.ai_socktype = SOCK_STREAM; if (!server) hints.ai_flags = AI_PASSIVE; From bb45bf9a66cfb28b8a51125937a87690987440b6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 2 May 2016 19:02:32 +0200 Subject: [PATCH 102/498] Cleanups --- cores/retropad/retropad.c | 19 +++++++++++-------- netlogger.c | 4 +--- 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/cores/retropad/retropad.c b/cores/retropad/retropad.c index a15ea797c8..41310c43b0 100644 --- a/cores/retropad/retropad.c +++ b/cores/retropad/retropad.c @@ -60,8 +60,8 @@ int input_state = 0; void retro_init(void) { frame_buf = (uint16_t*)calloc(320 * 240, sizeof(uint16_t)); - //Initialise winsock - log_cb(RETRO_LOG_INFO, "Initialising sockets\n"); + + log_cb(RETRO_LOG_INFO, "Initialising sockets...\n"); network_init(); } @@ -222,11 +222,11 @@ void retro_run(void) unsigned i; update_input(); snprintf(message, sizeof(message), "%d", input_state); - //send the message + + /* send the message */ if (sendto(s, message, strlen(message) , 0 , (struct sockaddr *) &si_other, slen)==-1) - { log_cb(RETRO_LOG_INFO, "Error sending data\n"); - } + for (i = 0; i < 320 * 240; i++) frame_buf[i] = 4 << 5; video_cb(frame_buf, 320, 240, 640); @@ -248,14 +248,17 @@ bool retro_load_game(const struct retro_game_info *info) /* setup address structure */ memset((char *) &si_other, 0, sizeof(si_other)); - si_other.sin_family = AF_INET; - si_other.sin_port = htons(port); + + si_other.sin_family = AF_INET; + si_other.sin_port = htons(port); #if defined(_WIN32) || defined(HAVE_SOCKET_LEGACY) si_other.sin_addr.S_un.S_addr = inet_addr(server); #else - si_other.sin_addr.s_addr = inet_addr(server); + si_other.sin_addr.s_addr = inet_addr(server); + inet_aton(server , &si_other.sin_addr); #endif + log_cb(RETRO_LOG_INFO, "Server IP Address: %s\n" , server); return true; diff --git a/netlogger.c b/netlogger.c index 3b7b8b6363..70150cbd1b 100644 --- a/netlogger.c +++ b/netlogger.c @@ -75,10 +75,8 @@ static int network_interface_up(struct sockaddr_in *target, int index, #else #if defined(__CELLOS_LV2__) && !defined(__PSL1GHT__) - int ret = 0; - int state, timeout_count = 10; - ret = cellNetCtlInit(); + int ret = cellNetCtlInit(); if (ret < 0) return -1; From 44cfa6d876c2ac7a58add4324f79d4365de5eab2 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 2 May 2016 19:04:03 +0200 Subject: [PATCH 103/498] Cleanup --- libretro-common/net/net_socket.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-) diff --git a/libretro-common/net/net_socket.c b/libretro-common/net/net_socket.c index a2abbcf49d..450bc3c6b5 100644 --- a/libretro-common/net/net_socket.c +++ b/libretro-common/net/net_socket.c @@ -214,11 +214,10 @@ int socket_create( enum socket_type socket_type, enum socket_protocol protocol_type) { -#ifdef VITA int type = 0; int domain = 0; int protocol = 0; - +#ifdef VITA switch (domain_type) { case SOCKET_DOMAIN_INET: @@ -254,10 +253,6 @@ int socket_create( return sceNetSocket(name, domain, type, protocol); #else - int type = 0; - int domain = 0; - int protocol = 0; - switch (domain_type) { case SOCKET_DOMAIN_INET: From 9c44bbd9eefb1de859fa4fea2b354e8826b8b915 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 2 May 2016 19:09:42 +0200 Subject: [PATCH 104/498] netlogger - cleanups --- netlogger.c | 52 +++++++++++++++++++++++++--------------------------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/netlogger.c b/netlogger.c index 70150cbd1b..f8b4879fe9 100644 --- a/netlogger.c +++ b/netlogger.c @@ -45,11 +45,11 @@ static char sendbuf[4096]; #endif static void *net_memory = NULL; -static int network_interface_up(struct sockaddr_in *target, int index, - const char *ip_address, unsigned udp_port, int *s) +static int network_interface_up(struct sockaddr_in *target, + const char *server, unsigned port, int *s) { - (void)index; - + int ret = 0; + #if defined(VITA) if (sceNetShowNetstat() == PSP2_NET_ERROR_ENOTINIT) { @@ -62,45 +62,34 @@ static int network_interface_up(struct sockaddr_in *target, int index, sceNetInit(&initparam); } - - *s = socket_create( - "ra_netlogger", - SOCKET_DOMAIN_INET, - SOCKET_TYPE_DATAGRAM, - SOCKET_PROTOCOL_NONE); - - target->sin_family = PSP2_NET_AF_INET; - target->sin_port = sceNetHtons(udp_port); - target->sin_addr = inet_aton(ip_address); -#else - -#if defined(__CELLOS_LV2__) && !defined(__PSL1GHT__) +#elif defined(__CELLOS_LV2__) && !defined(__PSL1GHT__) int state, timeout_count = 10; int ret = cellNetCtlInit(); if (ret < 0) - return -1; + goto error; for (;;) { ret = cellNetCtlGetState(&state); if (ret < 0) - return -1; + goto error; if (state == CELL_NET_CTL_STATE_IPObtained) break; retro_sleep(500); timeout_count--; - if (index && timeout_count < 0) + if (timeout_count < 0) return 0; } #elif defined(GEKKO) char t[16]; if (if_config(t, NULL, NULL, TRUE) < 0) - ret = -1; + goto error; #endif + if (ret < 0) - return -1; + goto error; *s = socket_create( "ra_netlogger", @@ -108,22 +97,31 @@ static int network_interface_up(struct sockaddr_in *target, int index, SOCKET_TYPE_DATAGRAM, SOCKET_PROTOCOL_NONE); +#ifdef VITA + target->sin_family = PSP2_NET_AF_INET; + target->sin_port = sceNetHtons(port); + target->sin_addr = inet_aton(server); +#else target->sin_family = AF_INET; - target->sin_port = htons(udp_port); + target->sin_port = htons(port); #ifdef GEKKO target->sin_len = 8; #endif - inet_pton(AF_INET, ip_address, &target->sin_addr); + inet_pton(AF_INET, server, &target->sin_addr); #endif return 0; + +error: + printf("Could not initialize network logger interface.\n"); + + return -1; } void logger_init (void) { - if (network_interface_up(&target, 1, - PC_DEVELOPMENT_IP_ADDRESS,PC_DEVELOPMENT_UDP_PORT, &g_sid) < 0) - printf("Could not initialize network logger interface.\n"); + network_interface_up(&target, + PC_DEVELOPMENT_IP_ADDRESS,PC_DEVELOPMENT_UDP_PORT, &g_sid); } void logger_shutdown (void) From 7869072dd9ccf46b7d13fe70acf9f20ef1a7fe33 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 2 May 2016 19:12:26 +0200 Subject: [PATCH 105/498] (netlogger) Cleanups --- netlogger.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/netlogger.c b/netlogger.c index f8b4879fe9..a2d9da5bf0 100644 --- a/netlogger.c +++ b/netlogger.c @@ -48,8 +48,6 @@ static void *net_memory = NULL; static int network_interface_up(struct sockaddr_in *target, const char *server, unsigned port, int *s) { - int ret = 0; - #if defined(VITA) if (sceNetShowNetstat() == PSP2_NET_ERROR_ENOTINIT) { @@ -64,13 +62,13 @@ static int network_interface_up(struct sockaddr_in *target, } #elif defined(__CELLOS_LV2__) && !defined(__PSL1GHT__) int state, timeout_count = 10; - int ret = cellNetCtlInit(); - if (ret < 0) + + if (cellNetCtlInit() < 0) goto error; for (;;) { - ret = cellNetCtlGetState(&state); + int ret = cellNetCtlGetState(&state); if (ret < 0) goto error; @@ -88,9 +86,6 @@ static int network_interface_up(struct sockaddr_in *target, goto error; #endif - if (ret < 0) - goto error; - *s = socket_create( "ra_netlogger", SOCKET_DOMAIN_INET, @@ -110,6 +105,7 @@ static int network_interface_up(struct sockaddr_in *target, inet_pton(AF_INET, server, &target->sin_addr); #endif + return 0; error: From a6439525543fefceb4db9df597ea081c7d2c05e2 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 2 May 2016 19:15:04 +0200 Subject: [PATCH 106/498] netlogger - cleanups --- netlogger.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/netlogger.c b/netlogger.c index a2d9da5bf0..7a1ea0088a 100644 --- a/netlogger.c +++ b/netlogger.c @@ -61,15 +61,15 @@ static int network_interface_up(struct sockaddr_in *target, sceNetInit(&initparam); } #elif defined(__CELLOS_LV2__) && !defined(__PSL1GHT__) - int state, timeout_count = 10; + int timeout_count = 10; if (cellNetCtlInit() < 0) goto error; for (;;) { - int ret = cellNetCtlGetState(&state); - if (ret < 0) + int state; + if (cellNetCtlGetState(&state) < 0) goto error; if (state == CELL_NET_CTL_STATE_IPObtained) From dbd56997f4636abcd1dacc7d76b0e331ba40238a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 2 May 2016 19:30:12 +0200 Subject: [PATCH 107/498] Changes to getaddrinfo_retro --- libretro-common/include/net/net_compat.h | 3 +-- libretro-common/net/net_compat.c | 16 ++++++++++------ 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/libretro-common/include/net/net_compat.h b/libretro-common/include/net/net_compat.h index e8dd2ef372..ac5ced7c31 100644 --- a/libretro-common/include/net/net_compat.h +++ b/libretro-common/include/net/net_compat.h @@ -212,8 +212,7 @@ struct addrinfo #endif int getaddrinfo_retro(const char *node, const char *service, - const struct addrinfo *hints, - struct addrinfo **res); + struct addrinfo *hints, struct addrinfo **res); void freeaddrinfo_retro(struct addrinfo *res); diff --git a/libretro-common/net/net_compat.c b/libretro-common/net/net_compat.c index be0393c5d0..1a2d9eac58 100644 --- a/libretro-common/net/net_compat.c +++ b/libretro-common/net/net_compat.c @@ -98,14 +98,13 @@ int retro_epoll_fd; #endif int getaddrinfo_retro(const char *node, const char *service, - const struct addrinfo *hints, - struct addrinfo **res) + struct addrinfo *hints, struct addrinfo **res) { -#ifdef HAVE_SOCKET_LEGACY struct sockaddr_in *in_addr = NULL; - struct addrinfo *info = (struct addrinfo*)calloc(1, sizeof(*info)); - if (!info) - goto error; + struct addrinfo *info = NULL; + + (void)in_addr; + (void)info; #if defined(_WIN32) || defined(HAVE_SOCKET_LEGACY) hints->ai_family = AF_INET; @@ -113,6 +112,11 @@ int getaddrinfo_retro(const char *node, const char *service, hints->ai_family = AF_UNSPEC; #endif +#ifdef HAVE_SOCKET_LEGACY + info = (struct addrinfo*)calloc(1, sizeof(*info)); + if (!info) + goto error; + info->ai_family = AF_INET; info->ai_socktype = hints->ai_socktype; in_addr = (struct sockaddr_in*) From 70d3bce2bfb673cff5aef2113cbb63902db5c3eb Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 2 May 2016 19:36:02 +0200 Subject: [PATCH 108/498] (command.c) Nit --- command.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/command.c b/command.c index d7ea4eca24..a8ca988f66 100644 --- a/command.c +++ b/command.c @@ -525,7 +525,7 @@ static bool send_udp_packet(const char *host, goto end; } - len = strlen(msg); + len = strlen(msg); ret_len = sendto(fd, msg, len, 0, tmp->ai_addr, tmp->ai_addrlen); if (ret_len < len) From 2eb4571290d0610c90ca1a267945cff6379dc051 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 2 May 2016 19:44:12 +0200 Subject: [PATCH 109/498] Move this code to net_compat.c --- libretro-common/net/net_compat.c | 48 ++++++++++++++++++++++- netplay/netplay.c | 66 -------------------------------- 2 files changed, 47 insertions(+), 67 deletions(-) diff --git a/libretro-common/net/net_compat.c b/libretro-common/net/net_compat.c index 1a2d9eac58..7ef476c4f0 100644 --- a/libretro-common/net/net_compat.c +++ b/libretro-common/net/net_compat.c @@ -21,15 +21,61 @@ */ #include +#include #include #include +#include #include #include #include #include -#if defined(VITA) +#if defined(_XBOX) +/* TODO - implement h_length and h_addrtype */ +struct hostent +{ + int h_addrtype; /* host address type */ + int h_length; /* length of addresses */ + char **h_addr_list; /* list of addresses */ +}; + +struct hostent *gethostbyname(const char *name) +{ + WSAEVENT event; + static struct hostent he; + static struct in_addr addr; + static char *addr_ptr; + XNDNS *dns = NULL; + + he.h_addr_list = &addr_ptr; + addr_ptr = (char*)&addr; + + if (!name) + return NULL; + + event = WSACreateEvent(); + XNetDnsLookup(name, event, &dns); + if (!dns) + goto error; + + WaitForSingleObject((HANDLE)event, INFINITE); + if (dns->iStatus) + goto error; + + memcpy(&addr, dns->aina, sizeof(addr)); + + WSACloseEvent(event); + XNetDnsRelease(dns); + + return &he; + +error: + if (event) + WSACloseEvent(event); + return NULL; +} +#elif defined(VITA) static void *_net_compat_net_memory = NULL; #define COMPAT_NET_INIT_SIZE 512*1024 #define INET_ADDRSTRLEN sizeof(struct sockaddr_in) diff --git a/netplay/netplay.c b/netplay/netplay.c index 72de3f3cca..bc99c971b5 100644 --- a/netplay/netplay.c +++ b/netplay/netplay.c @@ -1167,69 +1167,3 @@ bool netplay_driver_ctl(enum rarch_netplay_ctl_state state, void *data) return false; } -/* /!\ WARNING: POTENTIAL PITFALL - - netplay.c does something naughty and undefines - sockaddr_storage and addrinfo. This is disastrous - for griffin builds. - - TODO: put this somewhere safer. - */ -#ifdef HAVE_SOCKET_LEGACY - -#undef sockaddr_storage -#undef addrinfo - -#include -#include -#include - -#define addrinfo addrinfo_retro__ - -#ifdef _XBOX -/* TODO - implement h_length and h_addrtype */ -struct hostent -{ - int h_addrtype; /* host address type */ - int h_length; /* length of addresses */ - char **h_addr_list; /* list of addresses */ -}; - -static struct hostent *gethostbyname(const char *name) -{ - WSAEVENT event; - static struct hostent he; - static struct in_addr addr; - static char *addr_ptr; - XNDNS *dns = NULL; - - he.h_addr_list = &addr_ptr; - addr_ptr = (char*)&addr; - - if (!name) - return NULL; - - event = WSACreateEvent(); - XNetDnsLookup(name, event, &dns); - if (!dns) - goto error; - - WaitForSingleObject((HANDLE)event, INFINITE); - if (dns->iStatus) - goto error; - - memcpy(&addr, dns->aina, sizeof(addr)); - - WSACloseEvent(event); - XNetDnsRelease(dns); - - return &he; - -error: - if (event) - WSACloseEvent(event); - return NULL; -} -#endif - -#endif From da72a96041951eefc8b42ff4efa4271ca1dc68f0 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 2 May 2016 22:15:25 +0200 Subject: [PATCH 110/498] Implement labels for Input User Binds List --- menu/cbs/menu_cbs_title.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/menu/cbs/menu_cbs_title.c b/menu/cbs/menu_cbs_title.c index 3d704f4cd9..73119023a7 100644 --- a/menu/cbs/menu_cbs_title.c +++ b/menu/cbs/menu_cbs_title.c @@ -659,6 +659,13 @@ static int action_get_title_input_settings(const char *path, const char *label, return 0; } +static int action_get_title_input_binds_list(const char *path, const char *label, + unsigned menu_type, char *s, size_t len) +{ + snprintf(s, len, "Input User %c Binds", path[0]); + return 0; +} + static int menu_cbs_init_bind_title_compare_label(menu_file_list_cbs_t *cbs, const char *label, uint32_t label_hash, const char *elem1) { @@ -868,6 +875,9 @@ static int menu_cbs_init_bind_title_compare_label(menu_file_list_cbs_t *cbs, case MENU_LABEL_CORE_COUNTERS: BIND_ACTION_GET_TITLE(cbs, action_get_core_counters_list); break; + case MENU_LABEL_DEFERRED_USER_BINDS_LIST: + BIND_ACTION_GET_TITLE(cbs, action_get_title_input_binds_list); + break; case MENU_LABEL_DEFERRED_INPUT_HOTKEY_BINDS_LIST: BIND_ACTION_GET_TITLE(cbs, action_get_input_hotkey_binds_settings_list); break; From 6690711ace3fe146d720d8755528bee8d8d87dd8 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 2 May 2016 22:17:12 +0200 Subject: [PATCH 111/498] Fix label for 'Download Content' --- menu/cbs/menu_cbs_title.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/menu/cbs/menu_cbs_title.c b/menu/cbs/menu_cbs_title.c index 73119023a7..d6c47d60d8 100644 --- a/menu/cbs/menu_cbs_title.c +++ b/menu/cbs/menu_cbs_title.c @@ -910,7 +910,7 @@ static int menu_cbs_init_bind_title_compare_label(menu_file_list_cbs_t *cbs, case MENU_LABEL_DEFERRED_ACCOUNTS_CHEEVOS_LIST: BIND_ACTION_GET_TITLE(cbs, action_get_user_accounts_cheevos_list); break; - case MENU_LABEL_DOWNLOAD_CORE_CONTENT: + case MENU_LABEL_DEFERRED_CORE_CONTENT_LIST: BIND_ACTION_GET_TITLE(cbs, action_get_download_core_content_list); break; case MENU_LABEL_DEFERRED_ACCOUNTS_LIST: From c7067356b5ddfc891a39356a0522467b79dd9128 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Tue, 3 May 2016 08:10:04 +0700 Subject: [PATCH 112/498] (XMB) Prevent showing 'Directory not found' as a playlist. Fixes the black square bug. --- menu/menu_displaylist.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 751ad7344e..8a4c997d22 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -2639,7 +2639,8 @@ static int menu_displaylist_parse_generic( ? menu_hash_to_str(MENU_LABEL_VALUE_UNABLE_TO_READ_COMPRESSED_FILE) : menu_hash_to_str(MENU_LABEL_VALUE_DIRECTORY_NOT_FOUND); - menu_entries_add(info->list, str, "", 0, 0, 0); + if (! horizontal) + menu_entries_add(info->list, str, "", 0, 0, 0); return 0; } From fd2096f3dc1e13ad7b5326cd9cb2a98a9a0b5015 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 3 May 2016 04:26:09 +0200 Subject: [PATCH 113/498] Cleanups --- libretro-common/net/net_compat.c | 24 ++++++++++ netlogger.c | 80 ++++++-------------------------- 2 files changed, 39 insertions(+), 65 deletions(-) diff --git a/libretro-common/net/net_compat.c b/libretro-common/net/net_compat.c index 7ef476c4f0..153b3c479c 100644 --- a/libretro-common/net/net_compat.c +++ b/libretro-common/net/net_compat.c @@ -240,8 +240,28 @@ bool network_init(void) return false; } #elif defined(__CELLOS_LV2__) && !defined(__PSL1GHT__) + int timeout_count = 10; + cellSysmoduleLoadModule(CELL_SYSMODULE_NET); sys_net_initialize_network(); + + if (cellNetCtlInit() < 0) + goto error; + + for (;;) + { + int state; + if (cellNetCtlGetState(&state) < 0) + goto error; + + if (state == CELL_NET_CTL_STATE_IPObtained) + break; + + retro_sleep(500); + timeout_count--; + if (timeout_count < 0) + return 0; + } #elif defined(VITA) SceNetInitParam initparam; @@ -259,6 +279,10 @@ bool network_init(void) } retro_epoll_fd = sceNetEpollCreate("epoll", 0); +#elif defined(GEKKO) + char t[16]; + if (if_config(t, NULL, NULL, TRUE) < 0) + goto error; #else signal(SIGPIPE, SIG_IGN); /* Do not like SIGPIPE killing our app. */ #endif diff --git a/netlogger.c b/netlogger.c index 7a1ea0088a..fdcb289fd1 100644 --- a/netlogger.c +++ b/netlogger.c @@ -40,84 +40,37 @@ static int g_sid; static struct sockaddr_in target; static char sendbuf[4096]; -#ifdef VITA -#define NET_INIT_SIZE 512*1024 -#endif -static void *net_memory = NULL; -static int network_interface_up(struct sockaddr_in *target, - const char *server, unsigned port, int *s) +void logger_init (void) { -#if defined(VITA) - if (sceNetShowNetstat() == PSP2_NET_ERROR_ENOTINIT) + const char *server = PC_DEVELOPMENT_IP_ADDRESS; + unsigned port = PC_DEVELOPMENT_UDP_PORT; + + if (!network_init()) { - SceNetInitParam initparam; - net_memory = malloc(NET_INIT_SIZE); - - initparam.memory = net_memory; - initparam.size = NET_INIT_SIZE; - initparam.flags = 0; - - sceNetInit(&initparam); + printf("Could not initialize network logger interface.\n"); + return; } -#elif defined(__CELLOS_LV2__) && !defined(__PSL1GHT__) - int timeout_count = 10; - if (cellNetCtlInit() < 0) - goto error; - - for (;;) - { - int state; - if (cellNetCtlGetState(&state) < 0) - goto error; - - if (state == CELL_NET_CTL_STATE_IPObtained) - break; - - retro_sleep(500); - timeout_count--; - if (timeout_count < 0) - return 0; - } -#elif defined(GEKKO) - char t[16]; - if (if_config(t, NULL, NULL, TRUE) < 0) - goto error; -#endif - - *s = socket_create( + g_sid = socket_create( "ra_netlogger", SOCKET_DOMAIN_INET, SOCKET_TYPE_DATAGRAM, SOCKET_PROTOCOL_NONE); #ifdef VITA - target->sin_family = PSP2_NET_AF_INET; - target->sin_port = sceNetHtons(port); - target->sin_addr = inet_aton(server); + target.sin_family = PSP2_NET_AF_INET; + target.sin_port = sceNetHtons(port); + target.sin_addr = inet_aton(server); #else - target->sin_family = AF_INET; - target->sin_port = htons(port); + target.sin_family = AF_INET; + target.sin_port = htons(port); #ifdef GEKKO - target->sin_len = 8; + target.sin_len = 8; #endif - inet_pton(AF_INET, server, &target->sin_addr); + inet_pton(AF_INET, server, &target.sin_addr); #endif - - return 0; - -error: - printf("Could not initialize network logger interface.\n"); - - return -1; -} - -void logger_init (void) -{ - network_interface_up(&target, - PC_DEVELOPMENT_IP_ADDRESS,PC_DEVELOPMENT_UDP_PORT, &g_sid); } void logger_shutdown (void) @@ -126,9 +79,6 @@ void logger_shutdown (void) network_deinit(); - if (net_memory) - free(net_memory); - if (ret < 0) printf("Could not deinitialize network logger interface.\n"); } From 35b7d0423fad8d5b267b20035eff2eb7fce7862b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 3 May 2016 04:28:58 +0200 Subject: [PATCH 114/498] init_network - fix some codepaths --- libretro-common/net/net_compat.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libretro-common/net/net_compat.c b/libretro-common/net/net_compat.c index 153b3c479c..e500b1a52b 100644 --- a/libretro-common/net/net_compat.c +++ b/libretro-common/net/net_compat.c @@ -246,13 +246,13 @@ bool network_init(void) sys_net_initialize_network(); if (cellNetCtlInit() < 0) - goto error; + return false; for (;;) { int state; if (cellNetCtlGetState(&state) < 0) - goto error; + return false; if (state == CELL_NET_CTL_STATE_IPObtained) break; @@ -282,7 +282,7 @@ bool network_init(void) #elif defined(GEKKO) char t[16]; if (if_config(t, NULL, NULL, TRUE) < 0) - goto error; + return false; #else signal(SIGPIPE, SIG_IGN); /* Do not like SIGPIPE killing our app. */ #endif From f60676f43e186fdc1e1686702c7f9221cd720170 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 3 May 2016 04:35:51 +0200 Subject: [PATCH 115/498] Create inet_htons --- cores/retropad/retropad.c | 2 +- libretro-common/include/net/net_compat.h | 2 ++ libretro-common/net/net_compat.c | 11 ++++++++++- netlogger.c | 3 +-- 4 files changed, 14 insertions(+), 4 deletions(-) diff --git a/cores/retropad/retropad.c b/cores/retropad/retropad.c index 41310c43b0..f1648588f5 100644 --- a/cores/retropad/retropad.c +++ b/cores/retropad/retropad.c @@ -250,7 +250,7 @@ bool retro_load_game(const struct retro_game_info *info) memset((char *) &si_other, 0, sizeof(si_other)); si_other.sin_family = AF_INET; - si_other.sin_port = htons(port); + si_other.sin_port = inet_htons(port); #if defined(_WIN32) || defined(HAVE_SOCKET_LEGACY) si_other.sin_addr.S_un.S_addr = inet_addr(server); #else diff --git a/libretro-common/include/net/net_compat.h b/libretro-common/include/net/net_compat.h index ac5ced7c31..690a9a1b9c 100644 --- a/libretro-common/include/net/net_compat.h +++ b/libretro-common/include/net/net_compat.h @@ -211,6 +211,8 @@ struct addrinfo #endif +uint16_t inet_htons(uint16_t hostshort); + int getaddrinfo_retro(const char *node, const char *service, struct addrinfo *hints, struct addrinfo **res); diff --git a/libretro-common/net/net_compat.c b/libretro-common/net/net_compat.c index e500b1a52b..c6d1b56dda 100644 --- a/libretro-common/net/net_compat.c +++ b/libretro-common/net/net_compat.c @@ -173,7 +173,7 @@ int getaddrinfo_retro(const char *node, const char *service, info->ai_addrlen = sizeof(*in_addr); in_addr->sin_family = AF_INET; - in_addr->sin_port = htons(strtoul(service, NULL, 0)); + in_addr->sin_port = inet_htons(strtoul(service, NULL, 0)); if (!node && (hints->ai_flags & AI_PASSIVE)) in_addr->sin_addr.s_addr = INADDR_ANY; @@ -317,3 +317,12 @@ void network_deinit(void) net_deinit(); #endif } + +uint16_t inet_htons(uint16_t hostshort) +{ +#ifdef VITA + return sceNetHtons(hostshort); +#else + return htons(hostshort); +#endif +} diff --git a/netlogger.c b/netlogger.c index fdcb289fd1..b9dd8449b1 100644 --- a/netlogger.c +++ b/netlogger.c @@ -58,13 +58,12 @@ void logger_init (void) SOCKET_TYPE_DATAGRAM, SOCKET_PROTOCOL_NONE); + target.sin_port = inet_htons(port); #ifdef VITA target.sin_family = PSP2_NET_AF_INET; - target.sin_port = sceNetHtons(port); target.sin_addr = inet_aton(server); #else target.sin_family = AF_INET; - target.sin_port = htons(port); #ifdef GEKKO target.sin_len = 8; #endif From acd1e0b1e17045e5c1b463664db7dc55aa23fb95 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 3 May 2016 05:00:52 +0200 Subject: [PATCH 116/498] Move sendbuf variable to logger_send_v --- netlogger.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/netlogger.c b/netlogger.c index b9dd8449b1..8d3d530795 100644 --- a/netlogger.c +++ b/netlogger.c @@ -39,7 +39,6 @@ static int g_sid; static struct sockaddr_in target; -static char sendbuf[4096]; void logger_init (void) { @@ -93,7 +92,9 @@ void logger_send(const char *__format,...) void logger_send_v(const char *__format, va_list args) { + static char sendbuf[4096]; int len; + vsnprintf(sendbuf,4000,__format, args); len = strlen(sendbuf); From 93df66ea2fa3804086fd0b9764e7b5d3e77f70bd Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 3 May 2016 15:33:36 +0200 Subject: [PATCH 117/498] (Nuklear) Buildfix --- menu/drivers/nuklear.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/menu/drivers/nuklear.c b/menu/drivers/nuklear.c index faa8742433..8959cc441a 100644 --- a/menu/drivers/nuklear.c +++ b/menu/drivers/nuklear.c @@ -324,7 +324,7 @@ static void *nk_menu_init(void **userdata) *userdata = nk; - fill_pathname_join(nk->assets_directory, settings->assets_directory, + fill_pathname_join(nk->assets_directory, settings->directory.assets, "zahnrad", sizeof(nk->assets_directory)); nk_menu_init_device(nk); @@ -385,7 +385,7 @@ static void nk_menu_context_reset(void *data) if (!nk || !settings) return; - fill_pathname_join(iconpath, settings->assets_directory, + fill_pathname_join(iconpath, settings->directory.assets, "zahnrad", sizeof(iconpath)); fill_pathname_slash(iconpath, sizeof(iconpath)); @@ -395,7 +395,7 @@ static void nk_menu_context_reset(void *data) wimp_context_bg_destroy(nk); nk_menu_context_reset_textures(nk, iconpath); - rarch_task_push_image_load(settings->menu.wallpaper, "cb_menu_wallpaper", + rarch_task_push_image_load(settings->path.menu_wallpaper, "cb_menu_wallpaper", menu_display_handle_wallpaper_upload, NULL); } From 0e774f28d811f92bab91b69083207e77ea91759c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 3 May 2016 16:14:34 +0200 Subject: [PATCH 118/498] (Nuklear) Use menu_display_draw_cursor --- menu/drivers/nuklear.c | 45 ++++++++---------------------------------- 1 file changed, 8 insertions(+), 37 deletions(-) diff --git a/menu/drivers/nuklear.c b/menu/drivers/nuklear.c index 8959cc441a..cb6ba15b3d 100644 --- a/menu/drivers/nuklear.c +++ b/menu/drivers/nuklear.c @@ -161,35 +161,6 @@ static void nk_menu_get_message(void *data, const char *message) strlcpy(nk->box_message, message, sizeof(nk->box_message)); } -static void nk_menu_draw_cursor(nk_menu_handle_t *nk, - float *color, - float x, float y, unsigned width, unsigned height) -{ - menu_display_ctx_draw_t draw; - struct gfx_coords coords; - - coords.vertices = 4; - coords.vertex = NULL; - coords.tex_coord = NULL; - coords.lut_tex_coord = NULL; - coords.color = (const float*)color; - - menu_display_ctl(MENU_DISPLAY_CTL_BLEND_BEGIN, NULL); - - draw.x = x - 32; - draw.y = (int)height - y - 32; - draw.width = 64; - draw.height = 64; - draw.coords = &coords; - draw.matrix_data = NULL; - draw.texture = nk->textures.list[NK_TEXTURE_POINTER]; - draw.prim_type = MENU_DISPLAY_PRIM_TRIANGLESTRIP; - - menu_display_ctl(MENU_DISPLAY_CTL_DRAW, &draw); - - menu_display_ctl(MENU_DISPLAY_CTL_BLEND_END, NULL); -} - static void nk_menu_frame(void *data) { float white_bg[16]= { @@ -232,14 +203,14 @@ static void nk_menu_frame(void *data) nk_menu_wnd_shader_parameters(nk); nk_common_device_draw(&device, &nk->ctx, width, height, NK_ANTI_ALIASING_ON); - if (settings->menu.mouse.enable && (settings->video.fullscreen - || !video_driver_ctl(RARCH_DISPLAY_CTL_HAS_WINDOWED, NULL))) - { - int16_t mouse_x = menu_input_mouse_state(MENU_MOUSE_X_AXIS); - int16_t mouse_y = menu_input_mouse_state(MENU_MOUSE_Y_AXIS); - - nk_menu_draw_cursor(nk, &white_bg[0], mouse_x, mouse_y, width, height); - } + menu_display_draw_cursor( + &white_bg[0], + 64, + nk->textures.list[NK_TEXTURE_POINTER], + menu_input_mouse_state(MENU_MOUSE_X_AXIS), + menu_input_mouse_state(MENU_MOUSE_Y_AXIS), + width, + height); menu_display_ctl(MENU_DISPLAY_CTL_RESTORE_CLEAR_COLOR, NULL); menu_display_ctl(MENU_DISPLAY_CTL_UNSET_VIEWPORT, NULL); From 22f69da0e365e209f03b0006459f739d6ecd5d13 Mon Sep 17 00:00:00 2001 From: Alcaro Date: Tue, 3 May 2016 17:52:43 +0200 Subject: [PATCH 119/498] Uninitialized variables taste bad. --- list_special.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/list_special.c b/list_special.c index 412803254a..cce644eb91 100644 --- a/list_special.c +++ b/list_special.c @@ -58,7 +58,7 @@ struct string_list *dir_list_new_special(const char *input_dir, (void)input_dir; (void)settings; - (void)ext_shaders; + ext_shaders[0] = '\0'; switch (type) { From 64501d2cb0a1de5f3748f6b93348ff7d575d6780 Mon Sep 17 00:00:00 2001 From: Alcaro Date: Tue, 3 May 2016 18:17:12 +0200 Subject: [PATCH 120/498] No point pegging the CPU to download a file. --- libretro-common/queues/task_queue.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libretro-common/queues/task_queue.c b/libretro-common/queues/task_queue.c index 35b4aae987..62f0b8dba4 100644 --- a/libretro-common/queues/task_queue.c +++ b/libretro-common/queues/task_queue.c @@ -328,6 +328,8 @@ static void threaded_worker(void *userdata) else retro_task_threaded_push_running(task); } + + retro_sleep(10); } slock_unlock(running_lock); From d8dcaab996f1e6c7dc458535f7ce768d7a40b0ed Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 4 May 2016 03:58:29 +0200 Subject: [PATCH 121/498] (RPNG) Cleanup --- libretro-common/formats/png/rpng.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/libretro-common/formats/png/rpng.c b/libretro-common/formats/png/rpng.c index 528d361b58..3d5e76bba8 100644 --- a/libretro-common/formats/png/rpng.c +++ b/libretro-common/formats/png/rpng.c @@ -818,14 +818,10 @@ static bool read_chunk_header(uint8_t *buf, struct png_chunk *chunk) for (i = 0; i < 4; i++) dword[i] = buf[i]; - buf += 4; - chunk->size = dword_be(dword); for (i = 0; i < 4; i++) - chunk->type[i] = buf[i]; - - buf += 4; + chunk->type[i] = buf[i + 4]; return true; } @@ -852,14 +848,14 @@ static bool png_parse_ihdr(uint8_t *buf, bool rpng_nbio_load_image_argb_iterate(rpng_t *rpng) { unsigned i; - unsigned ret; - uint8_t *buf = (uint8_t*)rpng->buff_data; - struct png_chunk chunk = {0}; + uint8_t *buf = (uint8_t*)rpng->buff_data; if (!read_chunk_header(buf, &chunk)) return false; + *buf += 8; + #if 0 for (i = 0; i < 4; i++) { @@ -939,8 +935,7 @@ bool rpng_nbio_load_image_argb_iterate(rpng_t *rpng) goto error; } - ret = 4 + 4 + chunk.size + 4; - rpng->buff_data += ret; + rpng->buff_data += chunk.size + 12; return true; From f9bd28663a2adca428a2f6e8fdcd876ade56e4a5 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 4 May 2016 04:03:46 +0200 Subject: [PATCH 122/498] Nit --- libretro-common/formats/png/rpng.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/libretro-common/formats/png/rpng.c b/libretro-common/formats/png/rpng.c index 3d5e76bba8..d90711ff65 100644 --- a/libretro-common/formats/png/rpng.c +++ b/libretro-common/formats/png/rpng.c @@ -1043,9 +1043,9 @@ bool rpng_load_image_argb(const char *path, uint32_t **data, { int retval; size_t file_len; - bool ret = true; - rpng_t *rpng = NULL; - void *ptr = NULL; + bool ret = true; + rpng_t *rpng = NULL; + void *ptr = NULL; struct nbio_t* handle = (struct nbio_t*)nbio_open(path, NBIO_READ); if (!handle) From 51565e6336aa6c1f0c76df7628bca6f240927934 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Wed, 4 May 2016 04:10:33 +0200 Subject: [PATCH 123/498] (iOS) Avoid some analyze warnings --- gfx/drivers/gl.c | 22 ++++++++++++---------- ui/drivers/cocoa/cocoatouch_menu.m | 11 +++++------ 2 files changed, 17 insertions(+), 16 deletions(-) diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 980bd5c9cd..8feea3641c 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -427,7 +427,7 @@ static void gl_create_fbo_texture(gl_t *gl, unsigned i, GLuint texture) { unsigned mip_level; video_shader_ctx_wrap_t wrap; - bool fp_fbo, srgb_fbo; + bool fp_fbo; GLenum min_filter, mag_filter, wrap_enum; video_shader_ctx_filter_t filter_type; bool mipmapped = false; @@ -465,21 +465,12 @@ static void gl_create_fbo_texture(gl_t *gl, unsigned i, GLuint texture) glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrap_enum); fp_fbo = gl->fbo_scale[i].fp_fbo; - srgb_fbo = gl->fbo_scale[i].srgb_fbo; if (fp_fbo) { if (!gl->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"); } - else if (srgb_fbo) - { - if (!gl->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->video.force_srgb_disable) - srgb_fbo = false; #ifndef HAVE_OPENGLES2 if (fp_fbo && gl->has_fp_fbo) @@ -493,6 +484,17 @@ static void gl_create_fbo_texture(gl_t *gl, unsigned i, GLuint texture) #endif { #ifndef HAVE_OPENGLES + bool srgb_fbo = gl->fbo_scale[i].srgb_fbo; + + if (!fp_fbo && srgb_fbo) + { + if (!gl->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->video.force_srgb_disable) + srgb_fbo = false; + if (srgb_fbo && gl->has_srgb_fbo) { RARCH_LOG("[GL]: FBO pass #%d is sRGB.\n", i); diff --git a/ui/drivers/cocoa/cocoatouch_menu.m b/ui/drivers/cocoa/cocoatouch_menu.m index ec746db3c8..5fac429730 100644 --- a/ui/drivers/cocoa/cocoatouch_menu.m +++ b/ui/drivers/cocoa/cocoatouch_menu.m @@ -406,13 +406,13 @@ replacementString:(NSString *)string { char buffer[PATH_MAX_LENGTH]; char label[PATH_MAX_LENGTH]; - NSString *desc = BOXSTRING("N/A"); - UIAlertView *alertView; - UITextField *field; + UIAlertView *alertView = NULL; + UITextField *field = NULL; + NSString *desc = NULL; menu_entry_get_path(self.i, label, sizeof(label)); - desc = BOXSTRING(label); + desc = BOXSTRING(label); alertView = [[UIAlertView alloc] initWithTitle:BOXSTRING("Enter new value") @@ -422,8 +422,7 @@ replacementString:(NSString *)string otherButtonTitles:BOXSTRING("OK"), nil]; alertView.alertViewStyle = UIAlertViewStylePlainTextInput; - field = [alertView textFieldAtIndex:0]; - + field = [alertView textFieldAtIndex:0]; field.delegate = self.formatter; menu_entry_get_value(self.i, buffer, sizeof(buffer)); From 803c27c5824455a38e7c290ad0cd1c559533db8a Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Wed, 4 May 2016 04:13:33 +0200 Subject: [PATCH 124/498] (iOS) Cleanups --- ui/drivers/cocoa/cocoatouch_menu.m | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/ui/drivers/cocoa/cocoatouch_menu.m b/ui/drivers/cocoa/cocoatouch_menu.m index 5fac429730..f00a482dcd 100644 --- a/ui/drivers/cocoa/cocoatouch_menu.m +++ b/ui/drivers/cocoa/cocoatouch_menu.m @@ -640,12 +640,14 @@ didSelectRowAtIndexPath:(NSIndexPath *)indexPath - (void)viewWillAppear:(BOOL)animated { char title_msg[256]; + UIBarButtonItem *item = NULL; + [self reloadData]; self.osdmessage = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 300, 44)]; self.osdmessage.backgroundColor = [UIColor clearColor]; - UIBarButtonItem *item = [[UIBarButtonItem alloc] initWithCustomView:self.osdmessage]; + item = [[UIBarButtonItem alloc] initWithCustomView:self.osdmessage]; [self setToolbarItems: [NSArray arrayWithObject:item]]; menu_entries_get_core_title(title_msg, sizeof(title_msg)); @@ -656,10 +658,8 @@ didSelectRowAtIndexPath:(NSIndexPath *)indexPath { size_t i, end; char title[256], title_msg[256]; - NSMutableArray *everything; - RAMainMenu* __weak weakSelf; - - everything = [NSMutableArray array]; + RAMainMenu* __weak weakSelf = NULL; + NSMutableArray *everything = [NSMutableArray array]; menu_entries_get_core_title(title_msg, sizeof(title_msg)); self.osdmessage.text = BOXSTRING(title_msg); From a393d9a75bd273b5d0ca10efbd535bf9703367f9 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 4 May 2016 04:22:41 +0200 Subject: [PATCH 125/498] Cleanups --- gfx/drivers/gl.c | 73 ++++++++++++++++++++++++++++-------------------- 1 file changed, 43 insertions(+), 30 deletions(-) diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 8feea3641c..aa54ecb783 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -1341,47 +1341,53 @@ static void gl_update_input_size(gl_t *gl, unsigned width, * to use a custom SIMD-optimized conversion routine * than letting GL do it. */ #if !defined(HAVE_PSGL) && !defined(HAVE_OPENGLES2) -static INLINE void gl_convert_frame_rgb16_32(gl_t *gl, void *output, - const void *input, int width, int height, int in_pitch) +static INLINE void gl_convert_frame_rgb16_32( + struct scaler_ctx *scaler, + void *output, + const void *input, + int width, int height, + int in_pitch) { - if (width != gl->scaler.in_width || height != gl->scaler.in_height) + if (width != scaler->in_width || height != scaler->in_height) { - gl->scaler.in_width = width; - gl->scaler.in_height = height; - gl->scaler.out_width = width; - gl->scaler.out_height = height; - gl->scaler.in_fmt = SCALER_FMT_RGB565; - gl->scaler.out_fmt = SCALER_FMT_ARGB8888; - gl->scaler.scaler_type = SCALER_TYPE_POINT; - scaler_ctx_gen_filter(&gl->scaler); + scaler->in_width = width; + scaler->in_height = height; + scaler->out_width = width; + scaler->out_height = height; + scaler->in_fmt = SCALER_FMT_RGB565; + scaler->out_fmt = SCALER_FMT_ARGB8888; + scaler->scaler_type = SCALER_TYPE_POINT; + scaler_ctx_gen_filter(scaler); } - gl->scaler.in_stride = in_pitch; - gl->scaler.out_stride = width * sizeof(uint32_t); - scaler_ctx_scale(&gl->scaler, output, input); + scaler->in_stride = in_pitch; + scaler->out_stride = width * sizeof(uint32_t); + + scaler_ctx_scale(scaler, output, input); } #endif #ifdef HAVE_OPENGLES2 -static INLINE void gl_convert_frame_argb8888_abgr8888(gl_t *gl, +static INLINE void gl_convert_frame_argb8888_abgr8888( + struct scaler_ctx *scaler, void *output, const void *input, int width, int height, int in_pitch) { - if (width != gl->scaler.in_width || height != gl->scaler.in_height) + if (width != scaler->in_width || height != scaler->in_height) { - gl->scaler.in_width = width; - gl->scaler.in_height = height; - gl->scaler.out_width = width; - gl->scaler.out_height = height; - gl->scaler.in_fmt = SCALER_FMT_ARGB8888; - gl->scaler.out_fmt = SCALER_FMT_ABGR8888; - gl->scaler.scaler_type = SCALER_TYPE_POINT; - scaler_ctx_gen_filter(&gl->scaler); + scaler->in_width = width; + scaler->in_height = height; + scaler->out_width = width; + scaler->out_height = height; + scaler->in_fmt = SCALER_FMT_ARGB8888; + scaler->out_fmt = SCALER_FMT_ABGR8888; + scaler->scaler_type = SCALER_TYPE_POINT; + scaler_ctx_gen_filter(scaler); } - gl->scaler.in_stride = in_pitch; - gl->scaler.out_stride = width * sizeof(uint32_t); - scaler_ctx_scale(&gl->scaler, output, input); + scaler->in_stride = in_pitch; + scaler->out_stride = width * sizeof(uint32_t); + scaler_ctx_scale(scaler, output, input); } #endif @@ -1544,7 +1550,9 @@ static INLINE void gl_copy_frame(gl_t *gl, const void *frame, /* Fallback for GLES devices without GL_BGRA_EXT. */ if (gl->base_size == 4 && use_rgba) { - gl_convert_frame_argb8888_abgr8888(gl, gl->conv_buffer, + gl_convert_frame_argb8888_abgr8888( + &gl->scaler, + gl->conv_buffer, frame, width, height, pitch); glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, width, height, gl->texture_type, @@ -1611,8 +1619,13 @@ static INLINE void gl_copy_frame(gl_t *gl, const void *frame, if (gl->base_size == 2 && !gl->have_es2_compat) { /* Convert to 32-bit textures on desktop GL. */ - gl_convert_frame_rgb16_32(gl, gl->conv_buffer, - frame, width, height, pitch); + gl_convert_frame_rgb16_32( + &gl->scaler, + gl->conv_buffer, + frame, + width, + height, + pitch); data_buf = gl->conv_buffer; } else From 3ba02a3786cee5de938edb78ed3eef91c7d1291c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 4 May 2016 04:34:05 +0200 Subject: [PATCH 126/498] Cleanups --- gfx/drivers/gl.c | 8 ++++---- screenshot.c | 52 +++++++++++++++++++++++++++++++----------------- 2 files changed, 38 insertions(+), 22 deletions(-) diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index aa54ecb783..eceda631c2 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -1341,7 +1341,7 @@ static void gl_update_input_size(gl_t *gl, unsigned width, * to use a custom SIMD-optimized conversion routine * than letting GL do it. */ #if !defined(HAVE_PSGL) && !defined(HAVE_OPENGLES2) -static INLINE void gl_convert_frame_rgb16_32( +static INLINE void convert_frame_rgb16_32( struct scaler_ctx *scaler, void *output, const void *input, @@ -1368,7 +1368,7 @@ static INLINE void gl_convert_frame_rgb16_32( #endif #ifdef HAVE_OPENGLES2 -static INLINE void gl_convert_frame_argb8888_abgr8888( +static INLINE void convert_frame_argb8888_abgr8888( struct scaler_ctx *scaler, void *output, const void *input, int width, int height, int in_pitch) @@ -1550,7 +1550,7 @@ static INLINE void gl_copy_frame(gl_t *gl, const void *frame, /* Fallback for GLES devices without GL_BGRA_EXT. */ if (gl->base_size == 4 && use_rgba) { - gl_convert_frame_argb8888_abgr8888( + convert_frame_argb8888_abgr8888( &gl->scaler, gl->conv_buffer, frame, width, height, pitch); @@ -1619,7 +1619,7 @@ static INLINE void gl_copy_frame(gl_t *gl, const void *frame, if (gl->base_size == 2 && !gl->have_es2_compat) { /* Convert to 32-bit textures on desktop GL. */ - gl_convert_frame_rgb16_32( + convert_frame_rgb16_32( &gl->scaler, gl->conv_buffer, frame, diff --git a/screenshot.c b/screenshot.c index 9824715dfb..b7e7334b1c 100644 --- a/screenshot.c +++ b/screenshot.c @@ -50,6 +50,33 @@ #include "config.h" #endif +static INLINE void convert_frame_to_bgr_24( + struct scaler_ctx *scaler, + void *output, + const void *input, + int width, int height, + int in_pitch, bool bgr24) +{ + scaler->in_width = width; + scaler->in_height = height; + scaler->out_width = width; + scaler->out_height = height; + if (bgr24) + scaler->in_fmt = SCALER_FMT_BGR24; + else if (video_driver_get_pixel_format() == RETRO_PIXEL_FORMAT_XRGB8888) + scaler->in_fmt = SCALER_FMT_ARGB8888; + else + scaler->in_fmt = SCALER_FMT_RGB565; + scaler->out_fmt = SCALER_FMT_BGR24; + scaler->scaler_type = SCALER_TYPE_POINT; + scaler_ctx_gen_filter(scaler); + + scaler->in_stride = in_pitch; + scaler->out_stride = width * 3; + + scaler_ctx_scale(scaler, output, input); +} + /* Take frame bottom-up. */ static bool screenshot_dump(const char *folder, const void *frame, unsigned width, unsigned height, int pitch, bool bgr24) @@ -93,25 +120,14 @@ static bool screenshot_dump(const char *folder, const void *frame, if (!out_buffer) return false; - scaler.in_width = width; - scaler.in_height = height; - scaler.out_width = width; - scaler.out_height = height; - scaler.in_stride = -pitch; - scaler.out_stride = width * 3; - scaler.out_fmt = SCALER_FMT_BGR24; - scaler.scaler_type = SCALER_TYPE_POINT; + convert_frame_to_bgr_24( + &scaler, + out_buffer, + (const uint8_t*)frame + ((int)height - 1) * pitch, + width, height, + -pitch, + bgr24); - if (bgr24) - scaler.in_fmt = SCALER_FMT_BGR24; - else if (video_driver_get_pixel_format() == RETRO_PIXEL_FORMAT_XRGB8888) - scaler.in_fmt = SCALER_FMT_ARGB8888; - else - scaler.in_fmt = SCALER_FMT_RGB565; - - scaler_ctx_gen_filter(&scaler); - scaler_ctx_scale(&scaler, out_buffer, - (const uint8_t*)frame + ((int)height - 1) * pitch); scaler_ctx_gen_reset(&scaler); RARCH_LOG("Using RPNG for PNG screenshots.\n"); From dca400aa403088003c4480086d71340a366e0770 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 4 May 2016 04:38:44 +0200 Subject: [PATCH 127/498] Add ifdef --- screenshot.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/screenshot.c b/screenshot.c index b7e7334b1c..6648b0f4c2 100644 --- a/screenshot.c +++ b/screenshot.c @@ -50,6 +50,7 @@ #include "config.h" #endif +#if defined(HAVE_ZLIB_DEFLATE) && defined(HAVE_RPNG) static INLINE void convert_frame_to_bgr_24( struct scaler_ctx *scaler, void *output, @@ -76,6 +77,7 @@ static INLINE void convert_frame_to_bgr_24( scaler_ctx_scale(scaler, output, input); } +#endif /* Take frame bottom-up. */ static bool screenshot_dump(const char *folder, const void *frame, From 66b6129e98fb7d64016b1ae969e7cc9bbf8d0257 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 4 May 2016 04:43:24 +0200 Subject: [PATCH 128/498] Cleanups --- gfx/drivers/omap_gfx.c | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/gfx/drivers/omap_gfx.c b/gfx/drivers/omap_gfx.c index 80b859ed94..b1f44cbc0d 100644 --- a/gfx/drivers/omap_gfx.c +++ b/gfx/drivers/omap_gfx.c @@ -1087,12 +1087,17 @@ static bool omap_gfx_read_viewport(void *data, uint8_t *buffer) return true; } -static void update_scaler(omap_video_t *vid, struct scaler_ctx *scaler, - enum scaler_pix_fmt format, unsigned width, - unsigned height, unsigned pitch) +static void update_scaler( + omap_video_t *vid, + const void *frame, + struct scaler_ctx *scaler, + enum scaler_pix_fmt format, + unsigned width, + unsigned height, + unsigned pitch) { if ( - width != scaler->in_width + width != scaler->in_width || height != scaler->in_height || format != scaler->in_fmt || pitch != scaler->in_stride @@ -1110,6 +1115,8 @@ static void update_scaler(omap_video_t *vid, struct scaler_ctx *scaler, if (!scaler_ctx_gen_filter(scaler)) RARCH_ERR("[video_omap]: scaler_ctx_gen_filter failed\n"); } + + scaler_ctx_scale(scaler, vid->menu.frame, frame); } static void omap_gfx_set_texture_frame(void *data, const void *frame, bool rgb32, @@ -1120,10 +1127,9 @@ static void omap_gfx_set_texture_frame(void *data, const void *frame, bool rgb32 (void) alpha; - update_scaler(vid, &vid->menu.scaler, format, width, height, + update_scaler(vid, frame, &vid->menu.scaler, format, width, height, width * (rgb32 ? sizeof(uint32_t) : sizeof(uint16_t))); - scaler_ctx_scale(&vid->menu.scaler, vid->menu.frame, frame); } static void omap_gfx_set_texture_enable(void *data, bool state, bool full_screen) From 83584c84f8febebcc166f5faf67d28f7e7842cf0 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 4 May 2016 04:45:46 +0200 Subject: [PATCH 129/498] (sdl_gfx.c) Style nit --- gfx/drivers/sdl_gfx.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gfx/drivers/sdl_gfx.c b/gfx/drivers/sdl_gfx.c index f2a8007680..7b5268112c 100644 --- a/gfx/drivers/sdl_gfx.c +++ b/gfx/drivers/sdl_gfx.c @@ -361,11 +361,11 @@ static bool sdl_gfx_frame(void *data, const void *frame, unsigned width, if (!frame) return true; - sdl_update_scaler(vid->screen, &vid->scaler, vid->scaler.in_fmt, width, height, pitch); - if (SDL_MUSTLOCK(vid->screen)) SDL_LockSurface(vid->screen); + sdl_update_scaler(vid->screen, &vid->scaler, vid->scaler.in_fmt, width, height, pitch); + rarch_perf_init(&sdl_scale, "sdl_scale"); retro_perf_start(&sdl_scale); scaler_ctx_scale(&vid->scaler, vid->screen->pixels, frame); From 3c231591484353f830416f9d3caf568c48fed421 Mon Sep 17 00:00:00 2001 From: Sebastien Ronsse Date: Wed, 4 May 2016 14:35:12 +1000 Subject: [PATCH 130/498] Fix deadlock due to missing unlock in task threaded find function --- libretro-common/queues/task_queue.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/libretro-common/queues/task_queue.c b/libretro-common/queues/task_queue.c index 62f0b8dba4..489593e218 100644 --- a/libretro-common/queues/task_queue.c +++ b/libretro-common/queues/task_queue.c @@ -270,16 +270,20 @@ static bool retro_task_threaded_find( retro_task_finder_t func, void *user_data) { retro_task_t *task = NULL; + bool result = false; slock_lock(running_lock); for (task = tasks_running.front; task; task = task->next) { if (func(task, user_data)) - return true; + { + result = true; + break; + } } slock_unlock(running_lock); - return false; + return result; } static void threaded_worker(void *userdata) From 9b36274a95817871f50818945143295153abc157 Mon Sep 17 00:00:00 2001 From: Sebastien Ronsse Date: Wed, 4 May 2016 15:21:48 +1000 Subject: [PATCH 131/498] Add check for decompression failure in generic download function --- menu/cbs/menu_cbs_ok.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 2123756b7a..fc1d1f444b 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -1393,8 +1393,12 @@ static void cb_generic_download(void *task_data, if (string_is_equal_noncase(file_ext, "zip")) { - rarch_task_push_decompress(output_path, dir_path, NULL, NULL, NULL, - cb_decompressed, (void*)(uintptr_t)transf->type_hash); + if (!rarch_task_push_decompress(output_path, dir_path, NULL, NULL, NULL, + cb_decompressed, (void*)(uintptr_t)transf->type_hash)) + { + err = "Decompression failed."; + goto finish; + } } #else switch (transf->type_hash) From bf53a939da022ce134db8046acbf42ca551a3450 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 4 May 2016 16:32:24 +0200 Subject: [PATCH 132/498] Create gfx/video_frame.h --- gfx/drivers/gl.c | 65 ++++++----------------------------------------- gfx/video_frame.h | 55 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 63 insertions(+), 57 deletions(-) create mode 100644 gfx/video_frame.h diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index eceda631c2..6fedde6982 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -52,6 +52,7 @@ #include "../font_driver.h" #include "../video_context_driver.h" +#include "../video_frame.h" #ifdef HAVE_GLSL #include "../drivers_shader/shader_glsl.h" @@ -1337,60 +1338,6 @@ static void gl_update_input_size(gl_t *gl, unsigned width, set_texture_coords(gl->tex_info.coord, xamt, yamt); } -/* It is *much* faster (order of magnitude on my setup) - * to use a custom SIMD-optimized conversion routine - * than letting GL do it. */ -#if !defined(HAVE_PSGL) && !defined(HAVE_OPENGLES2) -static INLINE void convert_frame_rgb16_32( - struct scaler_ctx *scaler, - void *output, - const void *input, - int width, int height, - int in_pitch) -{ - if (width != scaler->in_width || height != scaler->in_height) - { - scaler->in_width = width; - scaler->in_height = height; - scaler->out_width = width; - scaler->out_height = height; - scaler->in_fmt = SCALER_FMT_RGB565; - scaler->out_fmt = SCALER_FMT_ARGB8888; - scaler->scaler_type = SCALER_TYPE_POINT; - scaler_ctx_gen_filter(scaler); - } - - scaler->in_stride = in_pitch; - scaler->out_stride = width * sizeof(uint32_t); - - scaler_ctx_scale(scaler, output, input); -} -#endif - -#ifdef HAVE_OPENGLES2 -static INLINE void convert_frame_argb8888_abgr8888( - struct scaler_ctx *scaler, - void *output, const void *input, - int width, int height, int in_pitch) -{ - if (width != scaler->in_width || height != scaler->in_height) - { - scaler->in_width = width; - scaler->in_height = height; - scaler->out_width = width; - scaler->out_height = height; - scaler->in_fmt = SCALER_FMT_ARGB8888; - scaler->out_fmt = SCALER_FMT_ABGR8888; - scaler->scaler_type = SCALER_TYPE_POINT; - scaler_ctx_gen_filter(scaler); - } - - scaler->in_stride = in_pitch; - scaler->out_stride = width * sizeof(uint32_t); - scaler_ctx_scale(scaler, output, input); -} -#endif - static void gl_init_textures_data(gl_t *gl) { unsigned i; @@ -1550,7 +1497,7 @@ static INLINE void gl_copy_frame(gl_t *gl, const void *frame, /* Fallback for GLES devices without GL_BGRA_EXT. */ if (gl->base_size == 4 && use_rgba) { - convert_frame_argb8888_abgr8888( + video_frame_convert_argb8888_to_abgr8888( &gl->scaler, gl->conv_buffer, frame, width, height, pitch); @@ -1618,8 +1565,12 @@ static INLINE void gl_copy_frame(gl_t *gl, const void *frame, if (gl->base_size == 2 && !gl->have_es2_compat) { - /* Convert to 32-bit textures on desktop GL. */ - convert_frame_rgb16_32( + /* Convert to 32-bit textures on desktop GL. + * + * It is *much* faster (order of magnitude on my setup) + * to use a custom SIMD-optimized conversion routine + * than letting GL do it. */ + video_frame_convert_rgb16_to_rgb32( &gl->scaler, gl->conv_buffer, frame, diff --git a/gfx/video_frame.h b/gfx/video_frame.h new file mode 100644 index 0000000000..5289cd4fd5 --- /dev/null +++ b/gfx/video_frame.h @@ -0,0 +1,55 @@ +#ifndef _VIDEO_FRAME_H +#define _VIDEO_FRAME_H + +#include + +#include + +static INLINE void video_frame_convert_rgb16_to_rgb32( + struct scaler_ctx *scaler, + void *output, + const void *input, + int width, int height, + int in_pitch) +{ + if (width != scaler->in_width || height != scaler->in_height) + { + scaler->in_width = width; + scaler->in_height = height; + scaler->out_width = width; + scaler->out_height = height; + scaler->in_fmt = SCALER_FMT_RGB565; + scaler->out_fmt = SCALER_FMT_ARGB8888; + scaler->scaler_type = SCALER_TYPE_POINT; + scaler_ctx_gen_filter(scaler); + } + + scaler->in_stride = in_pitch; + scaler->out_stride = width * sizeof(uint32_t); + + scaler_ctx_scale(scaler, output, input); +} + +static INLINE void video_frame_convert_argb8888_to_abgr8888( + struct scaler_ctx *scaler, + void *output, const void *input, + int width, int height, int in_pitch) +{ + if (width != scaler->in_width || height != scaler->in_height) + { + scaler->in_width = width; + scaler->in_height = height; + scaler->out_width = width; + scaler->out_height = height; + scaler->in_fmt = SCALER_FMT_ARGB8888; + scaler->out_fmt = SCALER_FMT_ABGR8888; + scaler->scaler_type = SCALER_TYPE_POINT; + scaler_ctx_gen_filter(scaler); + } + + scaler->in_stride = in_pitch; + scaler->out_stride = width * sizeof(uint32_t); + scaler_ctx_scale(scaler, output, input); +} + +#endif From 2c3ca6efed08326da8b93aee52d2c6113e7791a6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 4 May 2016 16:34:13 +0200 Subject: [PATCH 133/498] Move convert frame function to gfx/video_frame.h --- gfx/video_frame.h | 26 ++++++++++++++++++++++++++ screenshot.c | 35 ++++------------------------------- 2 files changed, 30 insertions(+), 31 deletions(-) diff --git a/gfx/video_frame.h b/gfx/video_frame.h index 5289cd4fd5..ef0f5d44cb 100644 --- a/gfx/video_frame.h +++ b/gfx/video_frame.h @@ -52,4 +52,30 @@ static INLINE void video_frame_convert_argb8888_to_abgr8888( scaler_ctx_scale(scaler, output, input); } +static INLINE void video_frame_convert_to_bgr24( + struct scaler_ctx *scaler, + void *output, const void *input, + int width, int height, int in_pitch, + bool bgr24) +{ + scaler->in_width = width; + scaler->in_height = height; + scaler->out_width = width; + scaler->out_height = height; + if (bgr24) + scaler->in_fmt = SCALER_FMT_BGR24; + else if (video_driver_get_pixel_format() == RETRO_PIXEL_FORMAT_XRGB8888) + scaler->in_fmt = SCALER_FMT_ARGB8888; + else + scaler->in_fmt = SCALER_FMT_RGB565; + scaler->out_fmt = SCALER_FMT_BGR24; + scaler->scaler_type = SCALER_TYPE_POINT; + scaler_ctx_gen_filter(scaler); + + scaler->in_stride = in_pitch; + scaler->out_stride = width * 3; + + scaler_ctx_scale(scaler, output, input); +} + #endif diff --git a/screenshot.c b/screenshot.c index 6648b0f4c2..e2d3cd3ae2 100644 --- a/screenshot.c +++ b/screenshot.c @@ -40,45 +40,18 @@ #include "general.h" #include "msg_hash.h" -#include "gfx/scaler/scaler.h" #include "retroarch.h" #include "screenshot.h" #include "verbosity.h" + #include "gfx/video_driver.h" +#include "gfx/scaler/scaler.h" +#include "gfx/video_frame.h" #ifdef HAVE_CONFIG_H #include "config.h" #endif -#if defined(HAVE_ZLIB_DEFLATE) && defined(HAVE_RPNG) -static INLINE void convert_frame_to_bgr_24( - struct scaler_ctx *scaler, - void *output, - const void *input, - int width, int height, - int in_pitch, bool bgr24) -{ - scaler->in_width = width; - scaler->in_height = height; - scaler->out_width = width; - scaler->out_height = height; - if (bgr24) - scaler->in_fmt = SCALER_FMT_BGR24; - else if (video_driver_get_pixel_format() == RETRO_PIXEL_FORMAT_XRGB8888) - scaler->in_fmt = SCALER_FMT_ARGB8888; - else - scaler->in_fmt = SCALER_FMT_RGB565; - scaler->out_fmt = SCALER_FMT_BGR24; - scaler->scaler_type = SCALER_TYPE_POINT; - scaler_ctx_gen_filter(scaler); - - scaler->in_stride = in_pitch; - scaler->out_stride = width * 3; - - scaler_ctx_scale(scaler, output, input); -} -#endif - /* Take frame bottom-up. */ static bool screenshot_dump(const char *folder, const void *frame, unsigned width, unsigned height, int pitch, bool bgr24) @@ -122,7 +95,7 @@ static bool screenshot_dump(const char *folder, const void *frame, if (!out_buffer) return false; - convert_frame_to_bgr_24( + video_frame_convert_to_bgr24( &scaler, out_buffer, (const uint8_t*)frame + ((int)height - 1) * pitch, From 3567c40bb7603bcf9d2a24c6093ca98e2f635894 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 4 May 2016 16:36:10 +0200 Subject: [PATCH 134/498] take_screenshot - cleanup --- screenshot.c | 19 ++++++------------- 1 file changed, 6 insertions(+), 13 deletions(-) diff --git a/screenshot.c b/screenshot.c index e2d3cd3ae2..b6f40c532b 100644 --- a/screenshot.c +++ b/screenshot.c @@ -265,22 +265,15 @@ static bool take_screenshot_choice(void) **/ bool take_screenshot(void) { - bool is_paused; - const char *msg_screenshot = NULL; - const char *msg = NULL; - bool ret = take_screenshot_choice(); - - if (ret) - msg_screenshot = msg_hash_to_str(MSG_TAKING_SCREENSHOT); - else - msg_screenshot = msg_hash_to_str(MSG_FAILED_TO_TAKE_SCREENSHOT); - - msg = msg_screenshot; + bool ret = take_screenshot_choice(); + const char *msg_screenshot = ret + ? msg_hash_to_str(MSG_TAKING_SCREENSHOT) : + msg_hash_to_str(MSG_FAILED_TO_TAKE_SCREENSHOT); + const char *msg = msg_screenshot; + bool is_paused = runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL); RARCH_LOG("%s.\n", msg); - is_paused = runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL); - runloop_msg_queue_push(msg, 1, is_paused ? 1 : 180, true); if (is_paused) From 71cc2fe7614eecbe3c5aed332835702afc43f2e4 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 4 May 2016 16:37:58 +0200 Subject: [PATCH 135/498] (screenshot.c) Cleanups --- screenshot.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/screenshot.c b/screenshot.c index b6f40c532b..bff7a629b5 100644 --- a/screenshot.c +++ b/screenshot.c @@ -56,11 +56,11 @@ static bool screenshot_dump(const char *folder, const void *frame, unsigned width, unsigned height, int pitch, bool bgr24) { - settings_t *settings = config_get_ptr(); - global_t *global = global_get_ptr(); bool ret; char filename[PATH_MAX_LENGTH]; char shotname[256]; + settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); #if defined(HAVE_ZLIB_DEFLATE) && defined(HAVE_RPNG) uint8_t *out_buffer = NULL; struct scaler_ctx scaler = {0}; @@ -79,9 +79,8 @@ static bool screenshot_dump(const char *folder, const void *frame, #ifdef _XBOX1 d3d_video_t *d3d = (d3d_video_t*)video_driver_get_ptr(true); - settings_t *settings = config_get_ptr(); - D3DSurface *surf = NULL; + d3d->dev->GetBackBuffer(-1, D3DBACKBUFFER_TYPE_MONO, &surf); ret = XGWriteSurfaceToFile(surf, filename); surf->Release(); @@ -184,14 +183,12 @@ static bool take_screenshot_raw(void) size_t pitch; char screenshot_path[PATH_MAX_LENGTH] = {0}; const void *data = NULL; - const char *screenshot_dir = NULL; global_t *global = global_get_ptr(); settings_t *settings = config_get_ptr(); + const char *screenshot_dir = settings->directory.screenshot; video_driver_cached_frame_get(&data, &width, &height, &pitch); - screenshot_dir = settings->directory.screenshot; - if (!*settings->directory.screenshot) { fill_pathname_basedir(screenshot_path, global->name.base, From 7b2a2f2336715ce985d695dfbae7108313a54866 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 4 May 2016 16:44:38 +0200 Subject: [PATCH 136/498] Create video_frame_scale --- gfx/drivers/omap_gfx.c | 48 +++++++++++------------------------------- gfx/video_frame.h | 34 ++++++++++++++++++++++++++++++ 2 files changed, 46 insertions(+), 36 deletions(-) diff --git a/gfx/drivers/omap_gfx.c b/gfx/drivers/omap_gfx.c index b1f44cbc0d..7825513baf 100644 --- a/gfx/drivers/omap_gfx.c +++ b/gfx/drivers/omap_gfx.c @@ -41,6 +41,8 @@ #include "../../retroarch.h" #include "../video_context_driver.h" +#include "../video_frame.h" + #include "../font_driver.h" typedef struct omapfb_page @@ -1087,49 +1089,23 @@ static bool omap_gfx_read_viewport(void *data, uint8_t *buffer) return true; } -static void update_scaler( - omap_video_t *vid, - const void *frame, - struct scaler_ctx *scaler, - enum scaler_pix_fmt format, - unsigned width, - unsigned height, - unsigned pitch) -{ - if ( - width != scaler->in_width - || height != scaler->in_height - || format != scaler->in_fmt - || pitch != scaler->in_stride - ) - { - scaler->in_fmt = format; - scaler->in_width = width; - scaler->in_height = height; - scaler->in_stride = pitch; - - scaler->out_width = vid->width; - scaler->out_height = vid->height; - scaler->out_stride = vid->width * vid->bytes_per_pixel; - - if (!scaler_ctx_gen_filter(scaler)) - RARCH_ERR("[video_omap]: scaler_ctx_gen_filter failed\n"); - } - - scaler_ctx_scale(scaler, vid->menu.frame, frame); -} - static void omap_gfx_set_texture_frame(void *data, const void *frame, bool rgb32, unsigned width, unsigned height, float alpha) { omap_video_t *vid = (omap_video_t*)data; enum scaler_pix_fmt format = rgb32 ? SCALER_FMT_ARGB8888 : SCALER_FMT_RGBA4444; - (void) alpha; - - update_scaler(vid, frame, &vid->menu.scaler, format, width, height, + video_frame_scale( + &vid->menu.scaler, + vid->menu.frame, + frame, + format, + vid->width, + vid->height, + vid->bytes_per_pixel, + width, + height, width * (rgb32 ? sizeof(uint32_t) : sizeof(uint16_t))); - } static void omap_gfx_set_texture_enable(void *data, bool state, bool full_screen) diff --git a/gfx/video_frame.h b/gfx/video_frame.h index ef0f5d44cb..8dfadef9bb 100644 --- a/gfx/video_frame.h +++ b/gfx/video_frame.h @@ -30,6 +30,40 @@ static INLINE void video_frame_convert_rgb16_to_rgb32( scaler_ctx_scale(scaler, output, input); } +static INLINE void video_frame_scale( + struct scaler_ctx *scaler, + void *output, + const void *input, + enum scaler_pix_fmt format, + unsigned scaler_width, + unsigned scaler_height, + unsigned scaler_pitch, + unsigned width, + unsigned height, + unsigned pitch) +{ + if ( + width != scaler->in_width + || height != scaler->in_height + || format != scaler->in_fmt + || pitch != scaler->in_stride + ) + { + scaler->in_fmt = format; + scaler->in_width = width; + scaler->in_height = height; + scaler->in_stride = pitch; + + scaler->out_width = scaler_width; + scaler->out_height = scaler_height; + scaler->out_stride = scaler_width * scaler_pitch; + + scaler_ctx_gen_filter(scaler); + } + + scaler_ctx_scale(scaler, output, input); +} + static INLINE void video_frame_convert_argb8888_to_abgr8888( struct scaler_ctx *scaler, void *output, const void *input, From bfcc89f58062eb15c69df1abecba4bc67d1829b2 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 4 May 2016 16:56:16 +0200 Subject: [PATCH 137/498] (SDL) Use video_frame_scale --- gfx/drivers/omap_gfx.c | 2 +- gfx/drivers/sdl_gfx.c | 63 +++++++++++++++++++----------------------- gfx/video_frame.h | 8 +++--- 3 files changed, 34 insertions(+), 39 deletions(-) diff --git a/gfx/drivers/omap_gfx.c b/gfx/drivers/omap_gfx.c index 7825513baf..10f293e65d 100644 --- a/gfx/drivers/omap_gfx.c +++ b/gfx/drivers/omap_gfx.c @@ -1102,7 +1102,7 @@ static void omap_gfx_set_texture_frame(void *data, const void *frame, bool rgb32 format, vid->width, vid->height, - vid->bytes_per_pixel, + vid->width * vid->bytes_per_pixel, width, height, width * (rgb32 ? sizeof(uint32_t) : sizeof(uint16_t))); diff --git a/gfx/drivers/sdl_gfx.c b/gfx/drivers/sdl_gfx.c index 7b5268112c..0af2e7c3b2 100644 --- a/gfx/drivers/sdl_gfx.c +++ b/gfx/drivers/sdl_gfx.c @@ -26,6 +26,8 @@ #include "../../driver.h" #include "../../general.h" #include "../../performance.h" + +#include "../video_frame.h" #include "../video_context_driver.h" #include "../font_driver.h" @@ -83,30 +85,6 @@ static void sdl_gfx_free(void *data) free(vid); } -static void sdl_update_scaler(SDL_Surface *surf, struct scaler_ctx *scaler, - enum scaler_pix_fmt format, unsigned width, - unsigned height, unsigned pitch) -{ - if ( - width != (unsigned)scaler->in_width - || height != (unsigned)scaler->in_height - || format != scaler->in_fmt - || pitch != (unsigned)scaler->in_stride - ) - { - scaler->in_fmt = format; - scaler->in_width = width; - scaler->in_height = height; - scaler->in_stride = pitch; - - scaler->out_width = surf->w; - scaler->out_height = surf->h; - scaler->out_stride = surf->pitch; - - scaler_ctx_gen_filter(scaler); - } -} - static void sdl_init_font(sdl_video_t *vid, const char *font_path, unsigned font_size) { int r, g, b; @@ -364,11 +342,20 @@ static bool sdl_gfx_frame(void *data, const void *frame, unsigned width, if (SDL_MUSTLOCK(vid->screen)) SDL_LockSurface(vid->screen); - sdl_update_scaler(vid->screen, &vid->scaler, vid->scaler.in_fmt, width, height, pitch); - rarch_perf_init(&sdl_scale, "sdl_scale"); retro_perf_start(&sdl_scale); - scaler_ctx_scale(&vid->scaler, vid->screen->pixels, frame); + + video_frame_scale( + &vid->scaler, + vid->screen->pixels, + frame, + vid->scaler.in_fmt, + vid->screen->w, + vid->screen->h, + vid->screen->pitch, + width, + height, + pitch); retro_perf_stop(&sdl_scale); if (vid->menu.active) @@ -480,15 +467,23 @@ 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 ? SCALER_FMT_ARGB8888 : SCALER_FMT_RGBA4444; - sdl_video_t *vid = (sdl_video_t*)data; + enum scaler_pix_fmt format = rgb32 + ? SCALER_FMT_ARGB8888 : SCALER_FMT_RGBA4444; + sdl_video_t *vid = (sdl_video_t*)data; - (void)alpha; + video_frame_scale( + &vid->menu.scaler, + vid->menu.frame->pixels, + frame, + format, + vid->menu.frame->w, + vid->menu.frame->h, + vid->menu.frame->pitch, + width, + height, + width * (rgb32 ? sizeof(uint32_t) : sizeof(uint16_t)) + ); - sdl_update_scaler(vid->menu.frame, &vid->menu.scaler, format, width, height, - width * (rgb32 ? sizeof(uint32_t) : sizeof(uint16_t))); - - scaler_ctx_scale(&vid->menu.scaler, vid->menu.frame->pixels, frame); SDL_SetAlpha(vid->menu.frame, SDL_SRCALPHA, 255.0 * alpha); } diff --git a/gfx/video_frame.h b/gfx/video_frame.h index 8dfadef9bb..3b26c03025 100644 --- a/gfx/video_frame.h +++ b/gfx/video_frame.h @@ -43,10 +43,10 @@ static INLINE void video_frame_scale( unsigned pitch) { if ( - width != scaler->in_width - || height != scaler->in_height + width != (unsigned)scaler->in_width + || height != (unsigned)scaler->in_height || format != scaler->in_fmt - || pitch != scaler->in_stride + || pitch != (unsigned)scaler->in_stride ) { scaler->in_fmt = format; @@ -56,7 +56,7 @@ static INLINE void video_frame_scale( scaler->out_width = scaler_width; scaler->out_height = scaler_height; - scaler->out_stride = scaler_width * scaler_pitch; + scaler->out_stride = scaler_pitch; scaler_ctx_gen_filter(scaler); } From b8e140d6c4dc28d46f0d8650a0a2471f13597070 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 4 May 2016 17:11:22 +0200 Subject: [PATCH 138/498] (record_ffmpeg.c) Move scaler code to gfx/video_frame.h --- gfx/video_frame.h | 34 ++++++++++++++++++++++++++++++++++ record/drivers/record_ffmpeg.c | 33 +++++++++++++-------------------- 2 files changed, 47 insertions(+), 20 deletions(-) diff --git a/gfx/video_frame.h b/gfx/video_frame.h index 3b26c03025..4b3654862b 100644 --- a/gfx/video_frame.h +++ b/gfx/video_frame.h @@ -64,6 +64,40 @@ static INLINE void video_frame_scale( scaler_ctx_scale(scaler, output, input); } +static INLINE void video_frame_record_scale( + struct scaler_ctx *scaler, + void *output, + const void *input, + unsigned scaler_width, + unsigned scaler_height, + unsigned scaler_pitch, + unsigned width, + unsigned height, + unsigned pitch, + bool bilinear) +{ + if ( + width != (unsigned)scaler->in_width + || height != (unsigned)scaler->in_height + ) + { + scaler->in_width = width; + scaler->in_height = height; + scaler->in_stride = pitch; + + scaler->scaler_type = bilinear ? + SCALER_TYPE_BILINEAR : SCALER_TYPE_POINT; + + scaler->out_width = scaler_width; + scaler->out_height = scaler_height; + scaler->out_stride = scaler_pitch; + + scaler_ctx_gen_filter(scaler); + } + + scaler_ctx_scale(scaler, output, input); +} + static INLINE void video_frame_convert_argb8888_to_abgr8888( struct scaler_ctx *scaler, void *output, const void *input, diff --git a/record/drivers/record_ffmpeg.c b/record/drivers/record_ffmpeg.c index 3935471481..0e16a38d2c 100644 --- a/record/drivers/record_ffmpeg.c +++ b/record/drivers/record_ffmpeg.c @@ -66,6 +66,8 @@ extern "C" { #include "../../audio/audio_utils.h" #include "../record_driver.h" +#include "../../gfx/video_frame.h" + #ifndef PIX_FMT_RGB32 #define PIX_FMT_RGB32 AV_PIX_FMT_RGB32 #endif @@ -978,26 +980,17 @@ static void ffmpeg_scale_input(ffmpeg_t *handle, } else { - if ((int)vid->width != handle->video.scaler.in_width - || (int)vid->height != handle->video.scaler.in_height) - { - handle->video.scaler.in_width = vid->width; - handle->video.scaler.in_height = vid->height; - handle->video.scaler.in_stride = vid->pitch; - - handle->video.scaler.scaler_type = shrunk ? - SCALER_TYPE_BILINEAR : SCALER_TYPE_POINT; - - handle->video.scaler.out_width = handle->params.out_width; - handle->video.scaler.out_height = handle->params.out_height; - handle->video.scaler.out_stride = - handle->video.conv_frame->linesize[0]; - - scaler_ctx_gen_filter(&handle->video.scaler); - } - - scaler_ctx_scale(&handle->video.scaler, - handle->video.conv_frame->data[0], vid->data); + video_frame_record_scale( + &handle->video.scaler, + handle->video.conv_frame->data[0], + vid->data, + handle->params.out_width, + handle->params.out_height, + handle->video.conv_frame->linesize[0], + vid->width, + vid->height, + vid->pitch, + shrunk); } } From 2e20e4bbdba248708cf8f202bd23ecaf87bed1c7 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 4 May 2016 17:13:25 +0200 Subject: [PATCH 139/498] Add header --- gfx/video_frame.h | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/gfx/video_frame.h b/gfx/video_frame.h index 4b3654862b..81348bdee8 100644 --- a/gfx/video_frame.h +++ b/gfx/video_frame.h @@ -1,3 +1,18 @@ +/* RetroArch - A frontend for libretro. + * 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. + * + * 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_FRAME_H #define _VIDEO_FRAME_H From 55bc1ccd7806b5925d95ad9ecb7dfe1f929ff5a0 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 4 May 2016 17:16:06 +0200 Subject: [PATCH 140/498] (video4linux2) Cleanup/nits --- camera/drivers/video4linux2.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/camera/drivers/video4linux2.c b/camera/drivers/video4linux2.c index dfa5167ebf..684504ca4c 100644 --- a/camera/drivers/video4linux2.c +++ b/camera/drivers/video4linux2.c @@ -95,8 +95,8 @@ static bool init_mmap(void *data) memset(&req, 0, sizeof(req)); - req.count = 4; - req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + req.count = 4; + req.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; req.memory = V4L2_MEMORY_MMAP; if (xioctl(v4l->fd, (uint8_t)VIDIOC_REQBUFS, &req) == -1) @@ -249,9 +249,9 @@ static void v4l_stop(void *data) static bool v4l_start(void *data) { - video4linux_t *v4l = (video4linux_t*)data; unsigned i; enum v4l2_buf_type type; + video4linux_t *v4l = (video4linux_t*)data; for (i = 0; i < v4l->n_buffers; i++) { @@ -259,9 +259,9 @@ static bool v4l_start(void *data) memset(&buf, 0, sizeof(buf)); - buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; + buf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE; buf.memory = V4L2_MEMORY_MMAP; - buf.index = i; + buf.index = i; if (xioctl(v4l->fd, (uint8_t)VIDIOC_QBUF, &buf) == -1) { From 9465a00d4b38c97bd050e6b05e8c7b769e557c48 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 4 May 2016 18:44:39 +0200 Subject: [PATCH 141/498] Create video_frame_convert_rgba_to_bgr --- gfx/drivers/gl.c | 30 +++++++++--------------------- gfx/video_frame.h | 17 +++++++++++++++++ 2 files changed, 26 insertions(+), 21 deletions(-) diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 6fedde6982..b164a33635 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -3142,16 +3142,13 @@ static bool gl_read_viewport(void *data, uint8_t *buffer) if (ptr) { - unsigned x, y; - + unsigned y; for (y = 0; y < gl->vp.height; y++) { - for (x = 0; x < gl->vp.width; x++, buffer += 3, ptr += 4) - { - buffer[0] = ptr[2]; /* RGBA -> BGR. */ - buffer[1] = ptr[1]; - buffer[2] = ptr[0]; - } + video_frame_convert_rgba_to_bgr( + (const void*)ptr, + buffer, + gl->vp.width); } } else @@ -3176,10 +3173,6 @@ static bool gl_read_viewport(void *data, uint8_t *buffer) as we don't really care about performance in this case. */ #endif { - unsigned i; - uint8_t *dst = NULL; - const uint8_t *src = NULL; - /* GLES2 only guarantees GL_RGBA/GL_UNSIGNED_BYTE * readbacks so do just that. * GLES2 also doesn't support reading back data @@ -3201,15 +3194,10 @@ static bool gl_read_viewport(void *data, uint8_t *buffer) video_driver_ctl(RARCH_DISPLAY_CTL_CACHED_FRAME_RENDER, NULL); - dst = buffer; - src = (const uint8_t*)gl->readback_buffer_screenshot; - - for (i = 0; i < num_pixels; i++, dst += 3, src += 4) - { - dst[0] = src[2]; /* RGBA -> BGR. */ - dst[1] = src[1]; - dst[2] = src[0]; - } + video_frame_convert_rgba_to_bgr( + (const void*)gl->readback_buffer_screenshot, + buffer, + num_pixels); free(gl->readback_buffer_screenshot); gl->readback_buffer_screenshot = NULL; diff --git a/gfx/video_frame.h b/gfx/video_frame.h index 81348bdee8..10cbb4bdd2 100644 --- a/gfx/video_frame.h +++ b/gfx/video_frame.h @@ -161,4 +161,21 @@ static INLINE void video_frame_convert_to_bgr24( scaler_ctx_scale(scaler, output, input); } +static INLINE void video_frame_convert_rgba_to_bgr( + const void *src_data, + void *dst_data, + unsigned width) +{ + unsigned x; + uint8_t *dst = (uint8_t*)dst_data; + const uint8_t *src = (const uint8_t*)src_data; + + for (x = 0; x < width; x++, dst += 3, src += 4) + { + dst[0] = src[2]; + dst[1] = src[1]; + dst[2] = src[0]; + } +} + #endif From 5889489ff79b5cbe480b2804f79f4993a4526f92 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 4 May 2016 21:12:34 +0200 Subject: [PATCH 142/498] (libretro-common) Update GLSM --- libretro-common/glsm/glsm.c | 36 ++++++++++++++++++++++++++ libretro-common/include/glsm/glsmsym.h | 12 +++++++++ 2 files changed, 48 insertions(+) diff --git a/libretro-common/glsm/glsm.c b/libretro-common/glsm/glsm.c index fd5cb102f2..a167cac610 100644 --- a/libretro-common/glsm/glsm.c +++ b/libretro-common/glsm/glsm.c @@ -649,6 +649,42 @@ void rglGetProgramiv(GLuint shader, GLenum pname, GLint *params) glGetProgramiv(shader, pname, params); } +/* + * + * Core in: + * OpenGL : 2.0 + */ +void rglGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, + GLsizei *length, GLint *size, GLenum *type, GLchar *name) +{ + glGetActiveUniform(program, index, bufsize, length, size, type, name); +} + +/* + * + * Core in: + * OpenGL : 2.0 + */ +void rglUniform1ui(GLint location, GLuint v) +{ + glUniform1ui(location ,v); +} + +void rglUniform2ui(GLint location, GLuint v0, GLuint v1) +{ + glUniform2ui(location, v0, v1); +} + +void rglUniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2) +{ + glUniform3ui(location, v0, v1, v2); +} + +void rglUniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) +{ + glUniform4ui(location, v0, v1, v2, v3); +} + /* * * Core in: diff --git a/libretro-common/include/glsm/glsmsym.h b/libretro-common/include/glsm/glsmsym.h index 922d94e986..f96cc9e4ac 100644 --- a/libretro-common/include/glsm/glsmsym.h +++ b/libretro-common/include/glsm/glsmsym.h @@ -95,6 +95,11 @@ RETRO_BEGIN_DECLS #define glUniform3fv rglUniform3fv #define glUniform4f rglUniform4f #define glUniform4fv rglUniform4fv +#define glUniform1ui rglUniform1ui +#define glUniform2ui rglUniform2ui +#define glUniform3ui rglUniform3ui +#define glUniform4ui rglUniform4ui +#define glGetActiveUniform rglGetActiveUniform #define glBlendFunc rglBlendFunc #define glBlendFuncSeparate rglBlendFuncSeparate #define glDepthFunc rglDepthFunc @@ -231,6 +236,13 @@ GLint rglGetAttribLocation(GLuint program, const GLchar *name); void rglDrawBuffers(GLsizei n, const GLenum *bufs); void rglBindVertexArray(GLuint array); +void rglGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, + GLsizei *length, GLint *size, GLenum *type, GLchar *name); +void rglUniform1ui(GLint location, GLuint v); +void rglUniform2ui(GLint location, GLuint v0, GLuint v1); +void rglUniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2); +void rglUniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); + RETRO_END_DECLS #endif From 9a7bde6a02b7d2c434586af2ccefd7c73d0587ea Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 4 May 2016 23:53:21 +0200 Subject: [PATCH 143/498] (GLSM) Add glBlendEquationSeparate --- libretro-common/glsm/glsm.c | 9 +++++++++ libretro-common/include/glsm/glsmsym.h | 2 ++ 2 files changed, 11 insertions(+) diff --git a/libretro-common/glsm/glsm.c b/libretro-common/glsm/glsm.c index a167cac610..65cbd495aa 100644 --- a/libretro-common/glsm/glsm.c +++ b/libretro-common/glsm/glsm.c @@ -1129,6 +1129,15 @@ void rglBlendColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha) glBlendColor(red, green, blue, alpha); } +/* + * + * Core in: + * OpenGL : 2.0 + */ +void rglBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) +{ + glBlendEquationSeparate(modeRGB, modeAlpha); +} /* * Category: VAO diff --git a/libretro-common/include/glsm/glsmsym.h b/libretro-common/include/glsm/glsmsym.h index f96cc9e4ac..95d3d02834 100644 --- a/libretro-common/include/glsm/glsmsym.h +++ b/libretro-common/include/glsm/glsmsym.h @@ -124,6 +124,7 @@ RETRO_BEGIN_DECLS #define glBindVertexArray rglBindVertexArray #define glBlendEquation rglBlendEquation #define glBlendColor rglBlendColor +#define glBlendEquationSeparate rglBlendEquationSeparate void rglBlendColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); void rglBlendEquation(GLenum mode); @@ -242,6 +243,7 @@ void rglUniform1ui(GLint location, GLuint v); void rglUniform2ui(GLint location, GLuint v0, GLuint v1); void rglUniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2); void rglUniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +void rglBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha); RETRO_END_DECLS From b0193885ca3c65117765cf0518239f3c95bc7092 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 5 May 2016 00:23:12 +0200 Subject: [PATCH 144/498] (GLSM) Update --- libretro-common/glsm/glsm.c | 40 ++++++++++++++++++++++++++ libretro-common/include/glsm/glsmsym.h | 16 +++++++++++ 2 files changed, 56 insertions(+) diff --git a/libretro-common/glsm/glsm.c b/libretro-common/glsm/glsm.c index 65cbd495aa..9ed00c867e 100644 --- a/libretro-common/glsm/glsm.c +++ b/libretro-common/glsm/glsm.c @@ -1139,6 +1139,46 @@ void rglBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha) glBlendEquationSeparate(modeRGB, modeAlpha); } +/* + * + * Core in: + * OpenGL : 2.0 + * OpenGLES : 3.2 + */ +void rglCopyImageSubData( GLuint srcName, + GLenum srcTarget, + GLint srcLevel, + GLint srcX, + GLint srcY, + GLint srcZ, + GLuint dstName, + GLenum dstTarget, + GLint dstLevel, + GLint dstX, + GLint dstY, + GLint dstZ, + GLsizei srcWidth, + GLsizei srcHeight, + GLsizei srcDepth) +{ +#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) && defined(HAVE_OPENGLES32) + glCopyImageSubData(srcName, + srcTarget, + srcX, + srcY, + srcZ, + dstName, + dstTarget, + dstLevel, + dstX, + dstY, + dstZ, + srcWidth, + srcHeight, + srcDepth); +#endif +} + /* * Category: VAO * diff --git a/libretro-common/include/glsm/glsmsym.h b/libretro-common/include/glsm/glsmsym.h index 95d3d02834..16d56006d8 100644 --- a/libretro-common/include/glsm/glsmsym.h +++ b/libretro-common/include/glsm/glsmsym.h @@ -125,6 +125,7 @@ RETRO_BEGIN_DECLS #define glBlendEquation rglBlendEquation #define glBlendColor rglBlendColor #define glBlendEquationSeparate rglBlendEquationSeparate +#define glCopyImageSubData rglCopyImageSubData void rglBlendColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); void rglBlendEquation(GLenum mode); @@ -244,6 +245,21 @@ void rglUniform2ui(GLint location, GLuint v0, GLuint v1); void rglUniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2); void rglUniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); void rglBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha); +void rglCopyImageSubData( GLuint srcName, + GLenum srcTarget, + GLint srcLevel, + GLint srcX, + GLint srcY, + GLint srcZ, + GLuint dstName, + GLenum dstTarget, + GLint dstLevel, + GLint dstX, + GLint dstY, + GLint dstZ, + GLsizei srcWidth, + GLsizei srcHeight, + GLsizei srcDepth); RETRO_END_DECLS From 7feac862dbfeb9cbd98e7e3cd57e6fd64d70b65e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 5 May 2016 01:29:52 +0200 Subject: [PATCH 145/498] (GL) Cleanups --- gfx/drivers/gl.c | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index b164a33635..4dc16248ff 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -3121,6 +3121,8 @@ static bool gl_read_viewport(void *data, uint8_t *buffer) rarch_perf_init(&read_viewport, "read_viewport"); retro_perf_start(&read_viewport); + num_pixels = gl->vp.width * gl->vp.height; + #ifdef HAVE_GL_ASYNC_READBACK if (gl->pbo_readback_enable) { @@ -3134,10 +3136,10 @@ static bool gl_read_viewport(void *data, uint8_t *buffer) gl->pbo_readback_valid[gl->pbo_readback_index] = false; glBindBuffer(GL_PIXEL_PACK_BUFFER, gl->pbo_readback[gl->pbo_readback_index]); + #ifdef HAVE_OPENGLES3 /* Slower path, but should work on all implementations at least. */ - num_pixels = gl->vp.width * gl->vp.height; - ptr = (const uint8_t*)glMapBufferRange(GL_PIXEL_PACK_BUFFER, + ptr = (const uint8_t*)glMapBufferRange(GL_PIXEL_PACK_BUFFER, 0, num_pixels * sizeof(uint32_t), GL_MAP_READ_BIT); if (ptr) @@ -3151,21 +3153,18 @@ static bool gl_read_viewport(void *data, uint8_t *buffer) gl->vp.width); } } - else - { - RARCH_ERR("[GL]: Failed to map pixel unpack buffer.\n"); - goto error; - } #else ptr = (const uint8_t*)glMapBuffer(GL_PIXEL_PACK_BUFFER, GL_READ_ONLY); + if (ptr) + scaler_ctx_scale(&gl->pbo_readback_scaler, buffer, ptr); +#endif + if (!ptr) { RARCH_ERR("[GL]: Failed to map pixel unpack buffer.\n"); goto error; } - scaler_ctx_scale(&gl->pbo_readback_scaler, buffer, ptr); -#endif glUnmapBuffer(GL_PIXEL_PACK_BUFFER); glBindBuffer(GL_PIXEL_PACK_BUFFER, 0); } @@ -3182,10 +3181,8 @@ static bool gl_read_viewport(void *data, uint8_t *buffer) * * Keep codepath similar for GLES and desktop GL. */ - - num_pixels = gl->vp.width * gl->vp.height; - gl->readback_buffer_screenshot = malloc(num_pixels * sizeof(uint32_t)); + if (!gl->readback_buffer_screenshot) { retro_perf_stop(&read_viewport); From 0ad0763413160616695deaca3cc9110f8582965c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 5 May 2016 01:32:35 +0200 Subject: [PATCH 146/498] gl_read_viewport - cleanup --- gfx/drivers/gl.c | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 4dc16248ff..e58db57d43 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -3101,14 +3101,9 @@ static void gl_viewport_info(void *data, struct video_viewport *vp) vp->y = top_dist; } -#ifdef NO_GL_READ_PIXELS -static bool gl_read_viewport(void *data, uint8_t *buffer) -{ - return false; -} -#else static bool gl_read_viewport(void *data, uint8_t *buffer) { +#ifndef NO_GL_READ_PIXELS static struct retro_perf_counter read_viewport = {0}; unsigned num_pixels = 0; gl_t *gl = (gl_t*)data; @@ -3206,9 +3201,10 @@ static bool gl_read_viewport(void *data, uint8_t *buffer) error: context_bind_hw_render(gl, true); +#endif + return false; } -#endif #if 0 #define READ_RAW_GL_FRAME_TEST From d4a322add32879d5def90e103ef6baf7a881b215 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 5 May 2016 01:33:54 +0200 Subject: [PATCH 147/498] Cleanups --- gfx/drivers/gl.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index e58db57d43..7a0ddac337 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -3286,10 +3286,16 @@ void gl_load_texture_data(uint32_t id_data, glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrap); #if defined(HAVE_OPENGLES2) || defined(HAVE_PSGL) || defined(OSX_PPC) - if (filter_type == TEXTURE_FILTER_MIPMAP_LINEAR) - filter_type = TEXTURE_FILTER_LINEAR; - if (filter_type == TEXTURE_FILTER_MIPMAP_NEAREST) - filter_type = TEXTURE_FILTER_NEAREST; + /* Assume no mipmapping support. */ + switch (filter_type) + { + case TEXTURE_FILTER_MIPMAP_LINEAR: + filter_type = TEXTURE_FILTER_LINEAR; + break; + case TEXTURE_FILTER_MIPMAP_NEAREST: + filter_type = TEXTURE_FILTER_NEAREST; + break; + } #endif switch (filter_type) From 1b84895ba0781048f0d5acffd9d15aca10929fb6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 5 May 2016 01:42:08 +0200 Subject: [PATCH 148/498] (GL) Cleanup gl_check_fbo_dimensions --- gfx/drivers/gl.c | 73 +++++++++++++++++++++--------------------------- 1 file changed, 32 insertions(+), 41 deletions(-) diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 7a0ddac337..8d904cf135 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -1011,10 +1011,38 @@ static INLINE void gl_start_frame_fbo(gl_t *gl) #endif } +static bool gl_recreate_fbo( + struct gfx_fbo_rect *fbo_rect, + GLuint fbo, + GLuint texture + ) +{ + glBindFramebuffer(RARCH_GL_FRAMEBUFFER, fbo); + glBindTexture(GL_TEXTURE_2D, texture); + + glTexImage2D(GL_TEXTURE_2D, + 0, RARCH_GL_INTERNAL_FORMAT32, + fbo_rect->width, + fbo_rect->height, + 0, RARCH_GL_TEXTURE_TYPE32, + RARCH_GL_FORMAT32, NULL); + + glFramebufferTexture2D(RARCH_GL_FRAMEBUFFER, + RARCH_GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, + texture, 0); + + if (glCheckFramebufferStatus(RARCH_GL_FRAMEBUFFER) != RARCH_GL_FRAMEBUFFER_COMPLETE) + { + RARCH_WARN("Failed to reinitialize FBO texture.\n"); + return false; + } + + return true; +} + static void gl_check_fbo_dimension(gl_t *gl, unsigned i, GLuint fbo, GLuint texture, bool update_feedback) { - GLenum status; unsigned img_width, img_height, max, pow2_size; bool check_dimensions = false; struct gfx_fbo_rect *fbo_rect = &gl->fbo_rect[i]; @@ -1038,57 +1066,20 @@ static void gl_check_fbo_dimension(gl_t *gl, unsigned i, fbo_rect->width = fbo_rect->height = pow2_size; - { - glBindFramebuffer(RARCH_GL_FRAMEBUFFER, fbo); - glBindTexture(GL_TEXTURE_2D, texture); - - glTexImage2D(GL_TEXTURE_2D, - 0, RARCH_GL_INTERNAL_FORMAT32, - fbo_rect->width, - fbo_rect->height, - 0, RARCH_GL_TEXTURE_TYPE32, - RARCH_GL_FORMAT32, NULL); - - glFramebufferTexture2D(RARCH_GL_FRAMEBUFFER, - RARCH_GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, - texture, 0); - - status = glCheckFramebufferStatus(RARCH_GL_FRAMEBUFFER); - if (status != RARCH_GL_FRAMEBUFFER_COMPLETE) - RARCH_WARN("Failed to reinitialize FBO texture.\n"); - } + gl_recreate_fbo(fbo_rect, fbo, texture); /* Update feedback texture in-place so we avoid having to * juggle two different fbo_rect structs since they get updated here. */ if (update_feedback) { - glBindFramebuffer(RARCH_GL_FRAMEBUFFER, gl->fbo_feedback); - glBindTexture(GL_TEXTURE_2D, gl->fbo_feedback_texture); - - glTexImage2D(GL_TEXTURE_2D, - 0, RARCH_GL_INTERNAL_FORMAT32, - fbo_rect->width, - fbo_rect->height, - 0, RARCH_GL_TEXTURE_TYPE32, - RARCH_GL_FORMAT32, NULL); - - glFramebufferTexture2D(RARCH_GL_FRAMEBUFFER, - RARCH_GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, - gl->fbo_feedback_texture, 0); - - status = glCheckFramebufferStatus(RARCH_GL_FRAMEBUFFER); - - if (status == RARCH_GL_FRAMEBUFFER_COMPLETE) + if (gl_recreate_fbo(fbo_rect, gl->fbo_feedback, + gl->fbo_feedback_texture)) { /* 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); } - else - { - RARCH_WARN("Failed to reinitialize FBO texture.\n"); - } } RARCH_LOG("[GL]: Recreating FBO texture #%d: %ux%u\n", From 2c77616ec3d7dffb32f7f5edcb23ec5374b2daa7 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 5 May 2016 01:59:05 +0200 Subject: [PATCH 149/498] (gfx/drivers) Cleanups --- gfx/drivers/sunxi_gfx.c | 16 ++++++------ gfx/drivers/vita2d_gfx.c | 56 +++++++++++++++++++--------------------- 2 files changed, 34 insertions(+), 38 deletions(-) diff --git a/gfx/drivers/sunxi_gfx.c b/gfx/drivers/sunxi_gfx.c index d27f2bc7ad..8a65159496 100644 --- a/gfx/drivers/sunxi_gfx.c +++ b/gfx/drivers/sunxi_gfx.c @@ -73,18 +73,18 @@ typedef struct typedef enum tag_DISP_CMD { /* ----layer---- */ - DISP_CMD_LAYER_REQUEST = 0x40, - DISP_CMD_LAYER_RELEASE = 0x41, - DISP_CMD_LAYER_OPEN = 0x42, - DISP_CMD_LAYER_CLOSE = 0x43, - DISP_CMD_LAYER_SET_FB = 0x44, - DISP_CMD_LAYER_GET_FB = 0x45, + DISP_CMD_LAYER_REQUEST = 0x40, + DISP_CMD_LAYER_RELEASE = 0x41, + DISP_CMD_LAYER_OPEN = 0x42, + DISP_CMD_LAYER_CLOSE = 0x43, + DISP_CMD_LAYER_SET_FB = 0x44, + DISP_CMD_LAYER_GET_FB = 0x45, DISP_CMD_LAYER_SET_SRC_WINDOW = 0x46, DISP_CMD_LAYER_GET_SRC_WINDOW = 0x47, DISP_CMD_LAYER_SET_SCN_WINDOW = 0x48, DISP_CMD_LAYER_GET_SCN_WINDOW = 0x49, - DISP_CMD_LAYER_SET_PARA = 0x4a, - DISP_CMD_LAYER_GET_PARA = 0x4b, + DISP_CMD_LAYER_SET_PARA = 0x4a, + DISP_CMD_LAYER_GET_PARA = 0x4b } __disp_cmd_t; typedef struct diff --git a/gfx/drivers/vita2d_gfx.c b/gfx/drivers/vita2d_gfx.c index 8fc6b265aa..da8b79921e 100644 --- a/gfx/drivers/vita2d_gfx.c +++ b/gfx/drivers/vita2d_gfx.c @@ -121,7 +121,8 @@ static void *vita2d_gfx_init(const video_info_t *video, vita->vsync = video->vsync; vita->rgb32 = video->rgb32; - vita->tex_filter = video->smooth? SCE_GXM_TEXTURE_FILTER_LINEAR : SCE_GXM_TEXTURE_FILTER_POINT; + vita->tex_filter = video->smooth + ? SCE_GXM_TEXTURE_FILTER_LINEAR : SCE_GXM_TEXTURE_FILTER_POINT; if (input && input_data) { @@ -149,14 +150,12 @@ static void *vita2d_gfx_init(const video_info_t *video, static void vita2d_render_overlay(void *data); static void vita2d_free_overlay(vita_video_t *vita) { - for (unsigned i = 0; i < vita->overlays; i++) - { + unsigned i; + for (i = 0; i < vita->overlays; i++) vita2d_free_texture(vita->overlay[i].tex); - } free(vita->overlay); vita->overlay = NULL; vita->overlays = 0; - //GX_InvalidateTexAll(); } #endif @@ -327,8 +326,6 @@ static void vita2d_gfx_free(void *data) { vita_video_t *vita = (vita_video_t *)data; - RARCH_LOG("vita2d_gfx_free()\n"); - vita2d_fini(); if (vita->menu.texture) @@ -491,7 +488,7 @@ static void vita_set_filtering(void *data, unsigned index, bool smooth) static void vita_set_aspect_ratio(void *data, unsigned aspect_ratio_idx) { - vita_video_t *vita = (vita_video_t*)data; + vita_video_t *vita = (vita_video_t*)data; enum rarch_display_ctl_state cmd = RARCH_DISPLAY_CTL_NONE; switch (aspect_ratio_idx) @@ -557,11 +554,13 @@ static void vita_set_texture_frame(void *data, const void *frame, bool rgb32, vita->menu.texture = vita2d_create_empty_texture_format(width, height, SCE_GXM_TEXTURE_FORMAT_U4U4U4U4_RGBA); RARCH_LOG("Creating Frame R5G6B5 texture: w: %i h: %i\n", width, height); } - vita->menu.width = width; + vita->menu.width = width; vita->menu.height = height; } + vita2d_texture_set_filters(vita->menu.texture,SCE_GXM_TEXTURE_FILTER_LINEAR,SCE_GXM_TEXTURE_FILTER_LINEAR); - tex_p = vita2d_texture_get_datap(vita->menu.texture); + + tex_p = vita2d_texture_get_datap(vita->menu.texture); stride = vita2d_texture_get_stride(vita->menu.texture); if (rgb32) @@ -669,10 +668,8 @@ static bool vita2d_overlay_load(void *data, const void *image_data, unsigned num static void vita2d_overlay_tex_geom(void *data, unsigned image, float x, float y, float w, float h) { - vita_video_t *vita = (vita_video_t*)data; - struct vita_overlay_data *o; - - o = NULL; + vita_video_t *vita = (vita_video_t*)data; + struct vita_overlay_data *o = NULL; if (vita) o = (struct vita_overlay_data*)&vita->overlay[image]; @@ -689,10 +686,8 @@ static void vita2d_overlay_tex_geom(void *data, unsigned image, static void vita2d_overlay_vertex_geom(void *data, unsigned image, float x, float y, float w, float h) { - vita_video_t *vita = (vita_video_t*)data; - struct vita_overlay_data *o; - - o = NULL; + 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; @@ -731,20 +726,21 @@ static void vita2d_overlay_set_alpha(void *data, unsigned image, float mod) static void vita2d_render_overlay(void *data) { + unsigned i; vita_video_t *vita = (vita_video_t*)data; - for (unsigned i = 0; i < vita->overlays; i++) + + 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, - vita->overlay[i].h, - RGBA8(0xFF,0xFF,0xFF,(uint8_t)(vita->overlay[i].alpha_mod * 255.0f))); - //RGBA8(0x00, 0x00, 0x00, (uint8_t)(vita->overlay[i].alpha_mod * 255.0f))); + 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))); } } From eb2a4f5c56a2d6b86473b844f5107bb071d8e164 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 5 May 2016 02:07:33 +0200 Subject: [PATCH 150/498] (GL) Nits --- gfx/drivers/gl.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 8d904cf135..ab8197b53b 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -2358,11 +2358,11 @@ static INLINE void gl_set_texture_fmts(gl_t *gl, bool rgb32) static void gl_init_pbo_readback(gl_t *gl) { unsigned i; - struct scaler_ctx *scaler = NULL; settings_t *settings = config_get_ptr(); bool *recording_enabled = recording_is_enabled(); - - (void)scaler; +#ifndef HAVE_OPENGLES3 + struct scaler_ctx *scaler = NULL; +#endif /* Only bother with this if we're doing GPU recording. * Check recording_is_enabled() and not @@ -2413,30 +2413,31 @@ static const gfx_ctx_driver_t *gl_get_context(gl_t *gl) { enum gfx_ctx_api api; unsigned major, minor; - const char *api_name = NULL; + const char *api_name = NULL; struct retro_hw_render_callback *hwr = NULL; - settings_t *settings = config_get_ptr(); + settings_t *settings = config_get_ptr(); video_driver_ctl(RARCH_DISPLAY_CTL_HW_CONTEXT_GET, &hwr); major = hwr->version_major; minor = hwr->version_minor; #ifdef HAVE_OPENGLES - api = GFX_CTX_OPENGL_ES_API; - api_name = "OpenGL ES 2.0"; + api = GFX_CTX_OPENGL_ES_API; + api_name = "OpenGL ES 2.0"; + #ifdef HAVE_OPENGLES3 if (hwr->context_type == RETRO_HW_CONTEXT_OPENGLES3) { - major = 3; - minor = 0; + major = 3; + minor = 0; api_name = "OpenGL ES 3.0"; } else if (hwr->context_type == RETRO_HW_CONTEXT_OPENGLES_VERSION) api_name = "OpenGL ES 3.1+"; #endif #else - api = GFX_CTX_OPENGL_API; - api_name = "OpenGL"; + api = GFX_CTX_OPENGL_API; + api_name = "OpenGL"; #endif (void)api_name; From e482bc7556e589316279684c9978e216278c2b78 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 5 May 2016 02:08:07 +0200 Subject: [PATCH 151/498] (GL) Avoid warning --- gfx/drivers/gl.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index ab8197b53b..e575932360 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -3287,6 +3287,8 @@ void gl_load_texture_data(uint32_t id_data, case TEXTURE_FILTER_MIPMAP_NEAREST: filter_type = TEXTURE_FILTER_NEAREST; break; + default: + break; } #endif From d3c3d209946b40521fc021e60e8ad04584bafbc7 Mon Sep 17 00:00:00 2001 From: Sebastien Ronsse Date: Thu, 5 May 2016 09:40:44 +1000 Subject: [PATCH 152/498] task queue: Add task_queue_remove method --- libretro-common/queues/task_queue.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/libretro-common/queues/task_queue.c b/libretro-common/queues/task_queue.c index 489593e218..e67905e7b5 100644 --- a/libretro-common/queues/task_queue.c +++ b/libretro-common/queues/task_queue.c @@ -113,6 +113,35 @@ static retro_task_t *task_queue_get(task_queue_t *queue) return task; } +static void task_queue_remove(task_queue_t *queue, retro_task_t *task) +{ + retro_task_t *t; + + /* Remove first element if needed */ + if (task == queue->front) + { + queue->front = task->next; + task->next = NULL; + return; + } + + /* Parse queue */ + t = queue->front; + while (t && t->next) + { + /* Remove task and update queue */ + if (t->next == task) + { + t->next = task->next; + task->next = NULL; + break; + } + + /* Update iterator */ + t = t->next; + } +} + static void retro_task_internal_gather(void) { retro_task_t *task = NULL; From cc4b5dbf3571d894f0130dfe52b633a971e0e3bc Mon Sep 17 00:00:00 2001 From: Sebastien Ronsse Date: Thu, 5 May 2016 09:41:30 +1000 Subject: [PATCH 153/498] task queue: Fix multi-threading issues in threaded worker --- libretro-common/queues/task_queue.c | 46 ++++++++++++++--------------- 1 file changed, 22 insertions(+), 24 deletions(-) diff --git a/libretro-common/queues/task_queue.c b/libretro-common/queues/task_queue.c index e67905e7b5..3c4940a24a 100644 --- a/libretro-common/queues/task_queue.c +++ b/libretro-common/queues/task_queue.c @@ -321,24 +321,17 @@ static void threaded_worker(void *userdata) for (;;) { - retro_task_t *queue = NULL; retro_task_t *task = NULL; retro_task_t *next = NULL; - /* pop all into a local queue, - * tasks are in the reverse order here. */ - slock_lock(running_lock); - if (!worker_continue) break; /* should we keep running until all tasks finished? */ - while ((task = task_queue_get(&tasks_running)) != NULL) - { - task->next = queue; - queue = task; - } + slock_lock(running_lock); - if (queue == NULL) /* no tasks running, lets wait a bit */ + /* Get first task to run */ + task = tasks_running.front; + if (task == NULL) { scond_wait(worker_cond, running_lock); slock_unlock(running_lock); @@ -347,21 +340,26 @@ static void threaded_worker(void *userdata) slock_unlock(running_lock); - for (task = queue; task; task = next) - { - next = task->next; - task->handler(task); + task->handler(task); - if (task->finished) - { - slock_lock(finished_lock); - task_queue_put(&tasks_finished, task); - slock_unlock(finished_lock); - } - else - retro_task_threaded_push_running(task); + slock_lock(running_lock); + task_queue_remove(&tasks_running, task); + slock_unlock(running_lock); + + /* Update queue */ + if (!task->finished) + { + /* Re-add task to running queue */ + retro_task_threaded_push_running(task); } - + else + { + /* Add task to finished queue */ + slock_lock(finished_lock); + task_queue_put(&tasks_finished, task); + slock_unlock(finished_lock); + } + retro_sleep(10); } From b8849a574c0eef8a52537cebeee77ae412c0efc8 Mon Sep 17 00:00:00 2001 From: Sebastien Ronsse Date: Thu, 5 May 2016 09:42:56 +1000 Subject: [PATCH 154/498] task decompress: Add helper decompress check method --- tasks/task_decompress.c | 12 ++++++++++++ tasks/tasks_internal.h | 2 ++ 2 files changed, 14 insertions(+) diff --git a/tasks/task_decompress.c b/tasks/task_decompress.c index 3e383b5c96..276b829a5c 100644 --- a/tasks/task_decompress.c +++ b/tasks/task_decompress.c @@ -226,6 +226,18 @@ static bool rarch_task_decompress_finder( return string_is_equal(dec->source_file, (const char*)user_data); } +bool rarch_task_check_decompress(const char *source_file) +{ + task_finder_data_t find_data; + + /* Prepare find parameters */ + find_data.func = rarch_task_decompress_finder; + find_data.userdata = (void *)source_file; + + /* Return whether decompressing is in progress or not */ + return task_queue_ctl(TASK_QUEUE_CTL_FIND, &find_data); +} + bool rarch_task_push_decompress( const char *source_file, const char *target_dir, diff --git a/tasks/tasks_internal.h b/tasks/tasks_internal.h index 25e881e6b9..3fb56d67ce 100644 --- a/tasks/tasks_internal.h +++ b/tasks/tasks_internal.h @@ -61,6 +61,8 @@ int detect_ps1_game(const char *track_path, char *game_id); int detect_psp_game(const char *track_path, char *game_id); +bool rarch_task_check_decompress(const char *source_file); + bool rarch_task_push_decompress( const char *source_file, const char *target_dir, From b100846ad5b5ba9161aaf07f3e280785e1633755 Mon Sep 17 00:00:00 2001 From: Sebastien Ronsse Date: Thu, 5 May 2016 09:43:52 +1000 Subject: [PATCH 155/498] task decompress: Refactor decompress checking code --- tasks/task_decompress.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/tasks/task_decompress.c b/tasks/task_decompress.c index 276b829a5c..104725c831 100644 --- a/tasks/task_decompress.c +++ b/tasks/task_decompress.c @@ -247,7 +247,6 @@ bool rarch_task_push_decompress( retro_task_callback_t cb, void *user_data) { - task_finder_data_t find_data; char tmp[PATH_MAX_LENGTH]; decompress_state_t *s = NULL; retro_task_t *t = NULL; @@ -275,10 +274,7 @@ bool rarch_task_push_decompress( if (!valid_ext || !valid_ext[0]) valid_ext = NULL; - find_data.func = rarch_task_decompress_finder; - find_data.userdata = (void*)source_file; - - if (task_queue_ctl(TASK_QUEUE_CTL_FIND, &find_data)) + if (rarch_task_check_decompress(source_file)) { RARCH_LOG("[decompress] File '%s' already being decompressed.\n", source_file); From e346eccbb70643861f1f760fac321ff80aaeda7b Mon Sep 17 00:00:00 2001 From: Sebastien Ronsse Date: Thu, 5 May 2016 09:48:08 +1000 Subject: [PATCH 156/498] task http: Fix http task finder logic leading to erroneous results --- tasks/task_http.c | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/tasks/task_http.c b/tasks/task_http.c index f7d9bbfc2d..c17d2c465d 100644 --- a/tasks/task_http.c +++ b/tasks/task_http.c @@ -45,6 +45,7 @@ typedef struct http_handle struct http_connection_t *handle; transfer_cb_t cb; char elem1[PATH_MAX_LENGTH]; + char url[PATH_MAX_LENGTH]; } connection; struct http_t *handle; transfer_cb_t cb; @@ -192,20 +193,19 @@ task_finished: static bool rarch_task_http_finder(retro_task_t *task, void *user_data) { - http_handle_t *http = (http_handle_t*)task->state; - const char *handle_url = NULL; - if ( !http || !user_data || - !task || task->handler != rarch_task_http_transfer_handler) - return false; - if (!http->connection.handle) + http_handle_t *http; + + if (!task || (task->handler != rarch_task_http_transfer_handler)) return false; - handle_url = net_http_connection_url(http->connection.handle); - - if (!handle_url) + if (!user_data) return false; - return string_is_equal(handle_url, (const char*)user_data); + http = (http_handle_t*)task->state; + if (!http) + return false; + + return string_is_equal(http->connection.url, (const char*)user_data); } bool rarch_task_push_http_transfer(const char *url, const char *type, @@ -246,6 +246,8 @@ bool rarch_task_push_http_transfer(const char *url, const char *type, if (type) strlcpy(http->connection.elem1, type, sizeof(http->connection.elem1)); + strlcpy(http->connection.url, url, sizeof(http->connection.url)); + http->status = HTTP_STATUS_CONNECTION_TRANSFER; t = (retro_task_t*)calloc(1, sizeof(*t)); From d5b358fde8182477fe31abdbc592c95a7d87e11e Mon Sep 17 00:00:00 2001 From: Sebastien Ronsse Date: Thu, 5 May 2016 09:45:56 +1000 Subject: [PATCH 157/498] menu: Fix bus error during simultaneous file download/decompression --- menu/cbs/menu_cbs_ok.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index fc1d1f444b..fba8fccd12 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -1379,6 +1379,19 @@ static void cb_generic_download(void *task_data, fill_pathname_join(output_path, dir_path, transf->path, sizeof(output_path)); +#ifdef HAVE_ZLIB + file_ext = path_get_extension(output_path); + + if (string_is_equal_noncase(file_ext, "zip")) + { + if (rarch_task_check_decompress(output_path)) + { + err = "Decompression already in progress."; + goto finish; + } + } +#endif + if (!filestream_write_file(output_path, data->data, data->len)) { err = "Write failed."; @@ -1386,8 +1399,6 @@ static void cb_generic_download(void *task_data, } #ifdef HAVE_ZLIB - file_ext = path_get_extension(output_path); - if (!settings->network.buildbot_auto_extract_archive) goto finish; From a0425dfb1437bf173a3459445241795120fd8397 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 5 May 2016 05:35:35 +0200 Subject: [PATCH 158/498] (Context drivers) Add get_flags function --- gfx/drivers_context/android_ctx.c | 7 +++++++ gfx/drivers_context/bbqnx_ctx.c | 9 ++++++++- gfx/drivers_context/cgl_ctx.c | 7 +++++++ gfx/drivers_context/cocoa_gl_ctx.m | 7 +++++++ gfx/drivers_context/d3d_ctx.cpp | 7 +++++++ gfx/drivers_context/drm_ctx.c | 9 ++++++++- gfx/drivers_context/emscriptenegl_ctx.c | 9 ++++++++- gfx/drivers_context/gfx_null_ctx.c | 9 ++++++++- gfx/drivers_context/mali_fbdev_ctx.c | 7 +++++++ gfx/drivers_context/opendingux_fbdev_ctx.c | 7 +++++++ gfx/drivers_context/ps3_ctx.c | 7 +++++++ gfx/drivers_context/sdl_gl_ctx.c | 7 +++++++ gfx/drivers_context/vc_egl_ctx.c | 9 ++++++++- gfx/drivers_context/vivante_fbdev_ctx.c | 9 ++++++++- gfx/drivers_context/wayland_ctx.c | 7 +++++++ gfx/drivers_context/wgl_ctx.cpp | 9 ++++++++- gfx/drivers_context/x_ctx.c | 7 +++++++ gfx/drivers_context/xegl_ctx.c | 9 ++++++++- gfx/video_context_driver.h | 8 ++++++++ 19 files changed, 142 insertions(+), 8 deletions(-) diff --git a/gfx/drivers_context/android_ctx.c b/gfx/drivers_context/android_ctx.c index 9c444b676d..27db8fd692 100644 --- a/gfx/drivers_context/android_ctx.c +++ b/gfx/drivers_context/android_ctx.c @@ -537,6 +537,12 @@ static void *android_gfx_ctx_get_context_data(void *data) } #endif +static uint32_t android_gfx_ctx_get_flags(void *data) +{ + (void)data; + return GFX_CTX_FLAGS_NONE; +} + const gfx_ctx_driver_t gfx_ctx_android = { android_gfx_ctx_init, android_gfx_ctx_destroy, @@ -562,6 +568,7 @@ const gfx_ctx_driver_t gfx_ctx_android = { NULL, NULL, "android", + android_gfx_ctx_get_flags, android_gfx_ctx_bind_hw_render, #ifdef HAVE_VULKAN android_gfx_ctx_get_context_data diff --git a/gfx/drivers_context/bbqnx_ctx.c b/gfx/drivers_context/bbqnx_ctx.c index dc4c3219a1..743f054d04 100644 --- a/gfx/drivers_context/bbqnx_ctx.c +++ b/gfx/drivers_context/bbqnx_ctx.c @@ -398,6 +398,12 @@ static void gfx_ctx_qnx_get_video_size(void *data, #endif } +static uint32_t gfx_ctx_qnx_get_flags(void *data) +{ + (void)data; + return GFX_CTX_FLAGS_NONE; +} + const gfx_ctx_driver_t gfx_ctx_bbqnx = { gfx_ctx_qnx_init, gfx_ctx_qnx_destroy, @@ -423,5 +429,6 @@ const gfx_ctx_driver_t gfx_ctx_bbqnx = { NULL, NULL, "blackberry_qnx", - gfx_ctx_qnx_bind_hw_render, + gfx_ctx_qnx_get_flags, + gfx_ctx_qnx_bind_hw_render }; diff --git a/gfx/drivers_context/cgl_ctx.c b/gfx/drivers_context/cgl_ctx.c index dbe136f657..5301f6ef3a 100644 --- a/gfx/drivers_context/cgl_ctx.c +++ b/gfx/drivers_context/cgl_ctx.c @@ -340,6 +340,12 @@ error: return NULL; } +static uint32_t gfx_ctx_cgl_get_flags(void *data) +{ + (void)data; + return GFX_CTX_FLAGS_NONE; +} + const gfx_ctx_driver_t gfx_ctx_cgl = { gfx_ctx_cgl_init, gfx_ctx_cgl_destroy, @@ -365,5 +371,6 @@ const gfx_ctx_driver_t gfx_ctx_cgl = { NULL, gfx_ctx_cgl_show_mouse, "cgl", + gfx_ctx_cgl_get_flags, gfx_ctx_cgl_bind_hw_render, }; diff --git a/gfx/drivers_context/cocoa_gl_ctx.m b/gfx/drivers_context/cocoa_gl_ctx.m index 8d38890fd2..bd79119abb 100644 --- a/gfx/drivers_context/cocoa_gl_ctx.m +++ b/gfx/drivers_context/cocoa_gl_ctx.m @@ -595,6 +595,12 @@ static void cocoagl_gfx_ctx_bind_hw_render(void *data, bool enable) [g_context makeCurrentContext]; } +static uint32_t cocoagl_gfx_ctx_get_flags(void *data) +{ + (void)data; + return GFX_CTX_FLAGS_NONE; +} + const gfx_ctx_driver_t gfx_ctx_cocoagl = { cocoagl_gfx_ctx_init, cocoagl_gfx_ctx_destroy, @@ -620,5 +626,6 @@ const gfx_ctx_driver_t gfx_ctx_cocoagl = { NULL, NULL, "cocoagl", + cocoagl_gfx_ctx_get_flags, cocoagl_gfx_ctx_bind_hw_render, }; diff --git a/gfx/drivers_context/d3d_ctx.cpp b/gfx/drivers_context/d3d_ctx.cpp index 7b5a023f93..a7feb1bf5b 100644 --- a/gfx/drivers_context/d3d_ctx.cpp +++ b/gfx/drivers_context/d3d_ctx.cpp @@ -302,6 +302,12 @@ static bool gfx_ctx_d3d_get_metrics(void *data, return win32_get_metrics(data, type, value); } +static uint32_t gfx_ctx_d3d_get_flags(void *data) +{ + (void)data; + return GFX_CTX_FLAGS_NONE; +} + const gfx_ctx_driver_t gfx_ctx_d3d = { gfx_ctx_d3d_init, gfx_ctx_d3d_destroy, @@ -327,4 +333,5 @@ const gfx_ctx_driver_t gfx_ctx_d3d = { NULL, gfx_ctx_d3d_show_mouse, "d3d", + gfx_ctx_d3d_get_flags, }; diff --git a/gfx/drivers_context/drm_ctx.c b/gfx/drivers_context/drm_ctx.c index 6e2d6979ac..a279884591 100644 --- a/gfx/drivers_context/drm_ctx.c +++ b/gfx/drivers_context/drm_ctx.c @@ -870,6 +870,12 @@ static void gfx_ctx_drm_bind_hw_render(void *data, bool enable) } } +static uint32_t gfx_ctx_drm_get_flags(void *data) +{ + (void)data; + return GFX_CTX_FLAGS_NONE; +} + const gfx_ctx_driver_t gfx_ctx_drm = { gfx_ctx_drm_init, gfx_ctx_drm_destroy, @@ -895,5 +901,6 @@ const gfx_ctx_driver_t gfx_ctx_drm = { NULL, NULL, "kms", - gfx_ctx_drm_bind_hw_render, + gfx_ctx_drm_get_flags, + gfx_ctx_drm_bind_hw_render }; diff --git a/gfx/drivers_context/emscriptenegl_ctx.c b/gfx/drivers_context/emscriptenegl_ctx.c index ec577563b1..7b06bed330 100644 --- a/gfx/drivers_context/emscriptenegl_ctx.c +++ b/gfx/drivers_context/emscriptenegl_ctx.c @@ -303,6 +303,12 @@ static void gfx_ctx_emscripten_bind_hw_render(void *data, bool enable) #endif } +static uint32_t gfx_ctx_emscripten_get_flags(void *data) +{ + (void)data; + return GFX_CTX_FLAGS_NONE; +} + const gfx_ctx_driver_t gfx_ctx_emscripten = { gfx_ctx_emscripten_init, gfx_ctx_emscripten_destroy, @@ -328,5 +334,6 @@ const gfx_ctx_driver_t gfx_ctx_emscripten = { gfx_ctx_emscripten_write_egl_image, NULL, "emscripten", - gfx_ctx_emscripten_bind_hw_render, + gfx_ctx_emscripten_get_flags, + gfx_ctx_emscripten_bind_hw_render }; diff --git a/gfx/drivers_context/gfx_null_ctx.c b/gfx/drivers_context/gfx_null_ctx.c index f89f917b55..ab2e24890a 100644 --- a/gfx/drivers_context/gfx_null_ctx.c +++ b/gfx/drivers_context/gfx_null_ctx.c @@ -133,6 +133,12 @@ static void *gfx_ctx_null_init(void *video_driver) return (void*)"null"; } +static uint32_t gfx_ctx_null_get_flags(void *data) +{ + (void)data; + return GFX_CTX_FLAGS_NONE; +} + const gfx_ctx_driver_t gfx_ctx_null = { gfx_ctx_null_init, gfx_ctx_null_destroy, @@ -158,6 +164,7 @@ const gfx_ctx_driver_t gfx_ctx_null = { NULL, gfx_ctx_null_show_mouse, "null", - gfx_ctx_null_bind_hw_render, + gfx_ctx_null_get_flags, + gfx_ctx_null_bind_hw_render }; diff --git a/gfx/drivers_context/mali_fbdev_ctx.c b/gfx/drivers_context/mali_fbdev_ctx.c index 5dc46a2fcf..01bec69607 100644 --- a/gfx/drivers_context/mali_fbdev_ctx.c +++ b/gfx/drivers_context/mali_fbdev_ctx.c @@ -291,6 +291,12 @@ static void gfx_ctx_mali_fbdev_bind_hw_render(void *data, bool enable) #endif } +static uint32_t gfx_ctx_mali_fbdev_get_flags(void *data) +{ + (void)data; + return GFX_CTX_FLAGS_NONE; +} + const gfx_ctx_driver_t gfx_ctx_mali_fbdev = { gfx_ctx_mali_fbdev_init, gfx_ctx_mali_fbdev_destroy, @@ -316,6 +322,7 @@ const gfx_ctx_driver_t gfx_ctx_mali_fbdev = { NULL, NULL, "mali-fbdev", + gfx_ctx_mali_fbdev_get_flags, gfx_ctx_mali_fbdev_bind_hw_render }; diff --git a/gfx/drivers_context/opendingux_fbdev_ctx.c b/gfx/drivers_context/opendingux_fbdev_ctx.c index ac86af6c34..e8d45bb06b 100644 --- a/gfx/drivers_context/opendingux_fbdev_ctx.c +++ b/gfx/drivers_context/opendingux_fbdev_ctx.c @@ -267,6 +267,12 @@ static void gfx_ctx_opendingux_bind_hw_render(void *data, bool enable) #endif } +static uint32_t gfx_ctx_opendingux_get_flags(void *data) +{ + (void)data; + return GFX_CTX_FLAGS_NONE; +} + const gfx_ctx_driver_t gfx_ctx_opendingux_fbdev = { gfx_ctx_opendingux_init, gfx_ctx_opendingux_destroy, @@ -292,5 +298,6 @@ const gfx_ctx_driver_t gfx_ctx_opendingux_fbdev = { NULL, NULL, "opendingux-fbdev", + gfx_ctx_opendingux_get_flags, gfx_ctx_opendingux_bind_hw_render }; diff --git a/gfx/drivers_context/ps3_ctx.c b/gfx/drivers_context/ps3_ctx.c index 4859aac7ca..a5cd8a2ff1 100644 --- a/gfx/drivers_context/ps3_ctx.c +++ b/gfx/drivers_context/ps3_ctx.c @@ -414,6 +414,12 @@ static void gfx_ctx_ps3_get_video_output_next(void *data) } } +static uint32_t gfx_ctx_ps3_get_flags(void *data) +{ + (void)data; + return GFX_CTX_FLAGS_NONE; +} + const gfx_ctx_driver_t gfx_ctx_ps3 = { gfx_ctx_ps3_init, gfx_ctx_ps3_destroy, @@ -439,5 +445,6 @@ const gfx_ctx_driver_t gfx_ctx_ps3 = { NULL, NULL, "ps3", + gfx_ctx_ps3_get_flags, }; diff --git a/gfx/drivers_context/sdl_gl_ctx.c b/gfx/drivers_context/sdl_gl_ctx.c index e5984d8af5..4755d4eefa 100644 --- a/gfx/drivers_context/sdl_gl_ctx.c +++ b/gfx/drivers_context/sdl_gl_ctx.c @@ -400,6 +400,12 @@ static void sdl_ctx_show_mouse(void *data, bool state) SDL_ShowCursor(state); } +static uint32_t sdl_ctx_get_flags(void *data) +{ + (void)data; + return GFX_CTX_FLAGS_NONE; +} + const gfx_ctx_driver_t gfx_ctx_sdl_gl = { sdl_ctx_init, @@ -426,5 +432,6 @@ const gfx_ctx_driver_t gfx_ctx_sdl_gl = NULL, sdl_ctx_show_mouse, "sdl_gl", + sdl_ctx_get_flags, NULL /* bind_hw_render */ }; diff --git a/gfx/drivers_context/vc_egl_ctx.c b/gfx/drivers_context/vc_egl_ctx.c index 8e5b690a43..193aef4f18 100644 --- a/gfx/drivers_context/vc_egl_ctx.c +++ b/gfx/drivers_context/vc_egl_ctx.c @@ -624,6 +624,12 @@ static gfx_ctx_proc_t gfx_ctx_vc_get_proc_address(const char *symbol) #endif } +static uint32_t gfx_ctx_vc_get_flags(void *data) +{ + (void)data; + return GFX_CTX_FLAGS_NONE; +} + const gfx_ctx_driver_t gfx_ctx_videocore = { gfx_ctx_vc_init, gfx_ctx_vc_destroy, @@ -649,5 +655,6 @@ const gfx_ctx_driver_t gfx_ctx_videocore = { gfx_ctx_vc_image_buffer_write, NULL, "videocore", - gfx_ctx_vc_bind_hw_render, + gfx_ctx_vc_get_flags, + gfx_ctx_vc_bind_hw_render }; diff --git a/gfx/drivers_context/vivante_fbdev_ctx.c b/gfx/drivers_context/vivante_fbdev_ctx.c index 8e180bbdae..3e60cf6876 100644 --- a/gfx/drivers_context/vivante_fbdev_ctx.c +++ b/gfx/drivers_context/vivante_fbdev_ctx.c @@ -261,6 +261,12 @@ static void gfx_ctx_vivante_swap_buffers(void *data) #endif } +static uint32_t gfx_ctx_vivante_get_flags(void *data) +{ + (void)data; + return GFX_CTX_FLAGS_NONE; +} + const gfx_ctx_driver_t gfx_ctx_vivante_fbdev = { gfx_ctx_vivante_init, gfx_ctx_vivante_destroy, @@ -286,5 +292,6 @@ const gfx_ctx_driver_t gfx_ctx_vivante_fbdev = { NULL, NULL, "vivante-fbdev", - gfx_ctx_vivante_bind_hw_render, + gfx_ctx_vivante_get_flags, + gfx_ctx_vivante_bind_hw_render }; diff --git a/gfx/drivers_context/wayland_ctx.c b/gfx/drivers_context/wayland_ctx.c index 66d756378c..8064548e4f 100644 --- a/gfx/drivers_context/wayland_ctx.c +++ b/gfx/drivers_context/wayland_ctx.c @@ -1138,6 +1138,12 @@ static void gfx_ctx_wl_bind_hw_render(void *data, bool enable) } } +static uint32_t gfx_ctx_wl_get_flags(void *data) +{ + (void)data; + return GFX_CTX_FLAGS_NONE; +} + const gfx_ctx_driver_t gfx_ctx_wayland = { gfx_ctx_wl_init, gfx_ctx_wl_destroy, @@ -1163,6 +1169,7 @@ const gfx_ctx_driver_t gfx_ctx_wayland = { NULL, NULL, "wayland", + gfx_ctx_wl_get_flags, gfx_ctx_wl_bind_hw_render, #ifdef HAVE_VULKAN gfx_ctx_wl_get_context_data diff --git a/gfx/drivers_context/wgl_ctx.cpp b/gfx/drivers_context/wgl_ctx.cpp index b088e5dc9e..1bb3c710f4 100644 --- a/gfx/drivers_context/wgl_ctx.cpp +++ b/gfx/drivers_context/wgl_ctx.cpp @@ -448,6 +448,12 @@ static void gfx_ctx_wgl_bind_hw_render(void *data, bool enable) wglMakeCurrent(g_hdc, enable ? g_hw_hrc : g_hrc); } +static uint32_t gfx_ctx_wgl_get_flags(void *data) +{ + (void)data; + return GFX_CTX_FLAGS_NONE; +} + const gfx_ctx_driver_t gfx_ctx_wgl = { gfx_ctx_wgl_init, gfx_ctx_wgl_destroy, @@ -473,6 +479,7 @@ const gfx_ctx_driver_t gfx_ctx_wgl = { NULL, gfx_ctx_wgl_show_mouse, "wgl", - gfx_ctx_wgl_bind_hw_render, + gfx_ctx_wgl_get_flags, + gfx_ctx_wgl_bind_hw_render }; diff --git a/gfx/drivers_context/x_ctx.c b/gfx/drivers_context/x_ctx.c index 1f1c659b1d..f9d3ebe1d0 100644 --- a/gfx/drivers_context/x_ctx.c +++ b/gfx/drivers_context/x_ctx.c @@ -886,6 +886,12 @@ static void *gfx_ctx_x_get_context_data(void *data) } #endif +static uint32_t gfx_ctx_x_get_flags(void *data) +{ + (void)data; + return GFX_CTX_FLAGS_NONE; +} + const gfx_ctx_driver_t gfx_ctx_x = { gfx_ctx_x_init, gfx_ctx_x_destroy, @@ -911,6 +917,7 @@ const gfx_ctx_driver_t gfx_ctx_x = { NULL, gfx_ctx_x_show_mouse, "x", + gfx_ctx_x_get_flags, gfx_ctx_x_bind_hw_render, #ifdef HAVE_VULKAN diff --git a/gfx/drivers_context/xegl_ctx.c b/gfx/drivers_context/xegl_ctx.c index c1aae15d92..6268a074e8 100644 --- a/gfx/drivers_context/xegl_ctx.c +++ b/gfx/drivers_context/xegl_ctx.c @@ -574,6 +574,12 @@ static gfx_ctx_proc_t gfx_ctx_xegl_get_proc_address(const char *symbol) return NULL; } +static uint32_t gfx_ctx_xegl_get_flags(void *data) +{ + (void)data; + return GFX_CTX_FLAGS_NONE; +} + const gfx_ctx_driver_t gfx_ctx_x_egl = { gfx_ctx_xegl_init, @@ -600,5 +606,6 @@ const gfx_ctx_driver_t gfx_ctx_x_egl = NULL, gfx_ctx_xegl_show_mouse, "x-egl", - gfx_ctx_xegl_bind_hw_render, + gfx_ctx_xegl_get_flags, + gfx_ctx_xegl_bind_hw_render }; diff --git a/gfx/video_context_driver.h b/gfx/video_context_driver.h index ad90b59381..5f5219f3a9 100644 --- a/gfx/video_context_driver.h +++ b/gfx/video_context_driver.h @@ -52,6 +52,12 @@ enum display_metric_types DISPLAY_METRIC_DPI }; +enum display_flags +{ + GFX_CTX_FLAGS_NONE = 0, + GFX_CTX_FLAGS_CORE_GL +}; + enum gfx_ctx_ctl_state { GFX_CTL_NONE = 0, @@ -182,6 +188,8 @@ typedef struct gfx_ctx_driver /* Human readable string. */ const char *ident; + uint32_t (*get_flags)(void *data); + /* Optional. Binds HW-render offscreen context. */ void (*bind_hw_render)(void *data, bool enable); From 8136683ffc6394cff1e19f5792c799f5ff26fd76 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 5 May 2016 05:46:00 +0200 Subject: [PATCH 159/498] (context drivers) Start exposing core GL flag --- gfx/drivers_context/android_ctx.c | 2 +- gfx/drivers_context/bbqnx_ctx.c | 2 +- gfx/drivers_context/cgl_ctx.c | 2 +- gfx/drivers_context/cocoa_gl_ctx.m | 2 +- gfx/drivers_context/d3d_ctx.cpp | 2 +- gfx/drivers_context/drm_ctx.c | 6 ++++-- gfx/drivers_context/emscriptenegl_ctx.c | 2 +- gfx/drivers_context/gfx_null_ctx.c | 2 +- gfx/drivers_context/mali_fbdev_ctx.c | 2 +- gfx/drivers_context/opendingux_fbdev_ctx.c | 2 +- gfx/drivers_context/ps3_ctx.c | 2 +- gfx/drivers_context/sdl_gl_ctx.c | 2 +- gfx/drivers_context/vc_egl_ctx.c | 2 +- gfx/drivers_context/vivante_fbdev_ctx.c | 2 +- gfx/drivers_context/wayland_ctx.c | 6 ++++-- gfx/drivers_context/wgl_ctx.cpp | 4 +++- gfx/drivers_context/x_ctx.c | 6 ++++-- gfx/drivers_context/xegl_ctx.c | 7 +++++-- gfx/video_context_driver.h | 2 +- 19 files changed, 34 insertions(+), 23 deletions(-) diff --git a/gfx/drivers_context/android_ctx.c b/gfx/drivers_context/android_ctx.c index 27db8fd692..2bb0547f35 100644 --- a/gfx/drivers_context/android_ctx.c +++ b/gfx/drivers_context/android_ctx.c @@ -540,7 +540,7 @@ static void *android_gfx_ctx_get_context_data(void *data) static uint32_t android_gfx_ctx_get_flags(void *data) { (void)data; - return GFX_CTX_FLAGS_NONE; + return 1UL << GFX_CTX_FLAGS_NONE; } const gfx_ctx_driver_t gfx_ctx_android = { diff --git a/gfx/drivers_context/bbqnx_ctx.c b/gfx/drivers_context/bbqnx_ctx.c index 743f054d04..947df8e918 100644 --- a/gfx/drivers_context/bbqnx_ctx.c +++ b/gfx/drivers_context/bbqnx_ctx.c @@ -401,7 +401,7 @@ static void gfx_ctx_qnx_get_video_size(void *data, static uint32_t gfx_ctx_qnx_get_flags(void *data) { (void)data; - return GFX_CTX_FLAGS_NONE; + return 1UL << GFX_CTX_FLAGS_NONE; } const gfx_ctx_driver_t gfx_ctx_bbqnx = { diff --git a/gfx/drivers_context/cgl_ctx.c b/gfx/drivers_context/cgl_ctx.c index 5301f6ef3a..2d24b75fea 100644 --- a/gfx/drivers_context/cgl_ctx.c +++ b/gfx/drivers_context/cgl_ctx.c @@ -343,7 +343,7 @@ error: static uint32_t gfx_ctx_cgl_get_flags(void *data) { (void)data; - return GFX_CTX_FLAGS_NONE; + return 1UL << GFX_CTX_FLAGS_NONE; } const gfx_ctx_driver_t gfx_ctx_cgl = { diff --git a/gfx/drivers_context/cocoa_gl_ctx.m b/gfx/drivers_context/cocoa_gl_ctx.m index bd79119abb..dde8ab6ee4 100644 --- a/gfx/drivers_context/cocoa_gl_ctx.m +++ b/gfx/drivers_context/cocoa_gl_ctx.m @@ -598,7 +598,7 @@ static void cocoagl_gfx_ctx_bind_hw_render(void *data, bool enable) static uint32_t cocoagl_gfx_ctx_get_flags(void *data) { (void)data; - return GFX_CTX_FLAGS_NONE; + return 1UL << GFX_CTX_FLAGS_NONE; } const gfx_ctx_driver_t gfx_ctx_cocoagl = { diff --git a/gfx/drivers_context/d3d_ctx.cpp b/gfx/drivers_context/d3d_ctx.cpp index a7feb1bf5b..58ec05682f 100644 --- a/gfx/drivers_context/d3d_ctx.cpp +++ b/gfx/drivers_context/d3d_ctx.cpp @@ -305,7 +305,7 @@ static bool gfx_ctx_d3d_get_metrics(void *data, static uint32_t gfx_ctx_d3d_get_flags(void *data) { (void)data; - return GFX_CTX_FLAGS_NONE; + return 1UL << GFX_CTX_FLAGS_NONE; } const gfx_ctx_driver_t gfx_ctx_d3d = { diff --git a/gfx/drivers_context/drm_ctx.c b/gfx/drivers_context/drm_ctx.c index a279884591..dc662835bb 100644 --- a/gfx/drivers_context/drm_ctx.c +++ b/gfx/drivers_context/drm_ctx.c @@ -872,8 +872,10 @@ static void gfx_ctx_drm_bind_hw_render(void *data, bool enable) static uint32_t gfx_ctx_drm_get_flags(void *data) { - (void)data; - return GFX_CTX_FLAGS_NONE; + gfx_ctx_drm_data_t *drm = (gfx_ctx_drm_data_t*)data; + if ((drm->egl.major * 1000 + drm->egl.minor) >= 3001) + return (1UL << GFX_CTX_FLAGS_GL_CORE_CONTEXT); + return 1UL << GFX_CTX_FLAGS_NONE; } const gfx_ctx_driver_t gfx_ctx_drm = { diff --git a/gfx/drivers_context/emscriptenegl_ctx.c b/gfx/drivers_context/emscriptenegl_ctx.c index 7b06bed330..80bd2d91cc 100644 --- a/gfx/drivers_context/emscriptenegl_ctx.c +++ b/gfx/drivers_context/emscriptenegl_ctx.c @@ -306,7 +306,7 @@ static void gfx_ctx_emscripten_bind_hw_render(void *data, bool enable) static uint32_t gfx_ctx_emscripten_get_flags(void *data) { (void)data; - return GFX_CTX_FLAGS_NONE; + return 1UL << GFX_CTX_FLAGS_NONE; } const gfx_ctx_driver_t gfx_ctx_emscripten = { diff --git a/gfx/drivers_context/gfx_null_ctx.c b/gfx/drivers_context/gfx_null_ctx.c index ab2e24890a..055bd6b0ae 100644 --- a/gfx/drivers_context/gfx_null_ctx.c +++ b/gfx/drivers_context/gfx_null_ctx.c @@ -136,7 +136,7 @@ static void *gfx_ctx_null_init(void *video_driver) static uint32_t gfx_ctx_null_get_flags(void *data) { (void)data; - return GFX_CTX_FLAGS_NONE; + return 1UL << GFX_CTX_FLAGS_NONE; } const gfx_ctx_driver_t gfx_ctx_null = { diff --git a/gfx/drivers_context/mali_fbdev_ctx.c b/gfx/drivers_context/mali_fbdev_ctx.c index 01bec69607..ac47fb7893 100644 --- a/gfx/drivers_context/mali_fbdev_ctx.c +++ b/gfx/drivers_context/mali_fbdev_ctx.c @@ -294,7 +294,7 @@ static void gfx_ctx_mali_fbdev_bind_hw_render(void *data, bool enable) static uint32_t gfx_ctx_mali_fbdev_get_flags(void *data) { (void)data; - return GFX_CTX_FLAGS_NONE; + return 1UL << GFX_CTX_FLAGS_NONE; } const gfx_ctx_driver_t gfx_ctx_mali_fbdev = { diff --git a/gfx/drivers_context/opendingux_fbdev_ctx.c b/gfx/drivers_context/opendingux_fbdev_ctx.c index e8d45bb06b..34ff6c09df 100644 --- a/gfx/drivers_context/opendingux_fbdev_ctx.c +++ b/gfx/drivers_context/opendingux_fbdev_ctx.c @@ -270,7 +270,7 @@ static void gfx_ctx_opendingux_bind_hw_render(void *data, bool enable) static uint32_t gfx_ctx_opendingux_get_flags(void *data) { (void)data; - return GFX_CTX_FLAGS_NONE; + return 1UL << GFX_CTX_FLAGS_NONE; } const gfx_ctx_driver_t gfx_ctx_opendingux_fbdev = { diff --git a/gfx/drivers_context/ps3_ctx.c b/gfx/drivers_context/ps3_ctx.c index a5cd8a2ff1..9b65b6d857 100644 --- a/gfx/drivers_context/ps3_ctx.c +++ b/gfx/drivers_context/ps3_ctx.c @@ -417,7 +417,7 @@ static void gfx_ctx_ps3_get_video_output_next(void *data) static uint32_t gfx_ctx_ps3_get_flags(void *data) { (void)data; - return GFX_CTX_FLAGS_NONE; + return 1UL << GFX_CTX_FLAGS_NONE; } const gfx_ctx_driver_t gfx_ctx_ps3 = { diff --git a/gfx/drivers_context/sdl_gl_ctx.c b/gfx/drivers_context/sdl_gl_ctx.c index 4755d4eefa..3ab6f5ada9 100644 --- a/gfx/drivers_context/sdl_gl_ctx.c +++ b/gfx/drivers_context/sdl_gl_ctx.c @@ -403,7 +403,7 @@ static void sdl_ctx_show_mouse(void *data, bool state) static uint32_t sdl_ctx_get_flags(void *data) { (void)data; - return GFX_CTX_FLAGS_NONE; + return 1UL << GFX_CTX_FLAGS_NONE; } const gfx_ctx_driver_t gfx_ctx_sdl_gl = diff --git a/gfx/drivers_context/vc_egl_ctx.c b/gfx/drivers_context/vc_egl_ctx.c index 193aef4f18..05d8bd83c1 100644 --- a/gfx/drivers_context/vc_egl_ctx.c +++ b/gfx/drivers_context/vc_egl_ctx.c @@ -627,7 +627,7 @@ static gfx_ctx_proc_t gfx_ctx_vc_get_proc_address(const char *symbol) static uint32_t gfx_ctx_vc_get_flags(void *data) { (void)data; - return GFX_CTX_FLAGS_NONE; + return 1UL << GFX_CTX_FLAGS_NONE; } const gfx_ctx_driver_t gfx_ctx_videocore = { diff --git a/gfx/drivers_context/vivante_fbdev_ctx.c b/gfx/drivers_context/vivante_fbdev_ctx.c index 3e60cf6876..5c6ac27acc 100644 --- a/gfx/drivers_context/vivante_fbdev_ctx.c +++ b/gfx/drivers_context/vivante_fbdev_ctx.c @@ -264,7 +264,7 @@ static void gfx_ctx_vivante_swap_buffers(void *data) static uint32_t gfx_ctx_vivante_get_flags(void *data) { (void)data; - return GFX_CTX_FLAGS_NONE; + return 1UL << GFX_CTX_FLAGS_NONE; } const gfx_ctx_driver_t gfx_ctx_vivante_fbdev = { diff --git a/gfx/drivers_context/wayland_ctx.c b/gfx/drivers_context/wayland_ctx.c index 8064548e4f..6efddac860 100644 --- a/gfx/drivers_context/wayland_ctx.c +++ b/gfx/drivers_context/wayland_ctx.c @@ -1140,8 +1140,10 @@ static void gfx_ctx_wl_bind_hw_render(void *data, bool enable) static uint32_t gfx_ctx_wl_get_flags(void *data) { - (void)data; - return GFX_CTX_FLAGS_NONE; + gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data; + if ((wl->egl.major * 1000 + wl->egl.minor) >= 3001) + return (1UL << GFX_CTX_FLAGS_GL_CORE_CONTEXT); + return 1UL << GFX_CTX_FLAGS_NONE; } const gfx_ctx_driver_t gfx_ctx_wayland = { diff --git a/gfx/drivers_context/wgl_ctx.cpp b/gfx/drivers_context/wgl_ctx.cpp index 1bb3c710f4..f5a5c20572 100644 --- a/gfx/drivers_context/wgl_ctx.cpp +++ b/gfx/drivers_context/wgl_ctx.cpp @@ -451,7 +451,9 @@ static void gfx_ctx_wgl_bind_hw_render(void *data, bool enable) static uint32_t gfx_ctx_wgl_get_flags(void *data) { (void)data; - return GFX_CTX_FLAGS_NONE; + if ((g_major * 1000 + g_minor) >= 3001) + return (1UL << GFX_CTX_FLAGS_GL_CORE_CONTEXT); + return (1UL << GFX_CTX_FLAGS_NONE); } const gfx_ctx_driver_t gfx_ctx_wgl = { diff --git a/gfx/drivers_context/x_ctx.c b/gfx/drivers_context/x_ctx.c index f9d3ebe1d0..ddca3f6bc7 100644 --- a/gfx/drivers_context/x_ctx.c +++ b/gfx/drivers_context/x_ctx.c @@ -888,8 +888,10 @@ static void *gfx_ctx_x_get_context_data(void *data) static uint32_t gfx_ctx_x_get_flags(void *data) { - (void)data; - return GFX_CTX_FLAGS_NONE; + gfx_ctx_x_data_t *x = (gfx_ctx_x_data_t*)data; + if (x->g_core_es || x->g_core_es_core) + return (1UL << GFX_CTX_FLAGS_GL_CORE_CONTEXT); + return 1UL << GFX_CTX_FLAGS_NONE; } const gfx_ctx_driver_t gfx_ctx_x = { diff --git a/gfx/drivers_context/xegl_ctx.c b/gfx/drivers_context/xegl_ctx.c index 6268a074e8..bbe05755c3 100644 --- a/gfx/drivers_context/xegl_ctx.c +++ b/gfx/drivers_context/xegl_ctx.c @@ -576,8 +576,11 @@ static gfx_ctx_proc_t gfx_ctx_xegl_get_proc_address(const char *symbol) static uint32_t gfx_ctx_xegl_get_flags(void *data) { - (void)data; - return GFX_CTX_FLAGS_NONE; + xegl_ctx_data_t *xegl = (xegl_ctx_data_t*)data; + + if ((xegl->egl.major * 1000 + xegl->egl.minor) >= 3001) + return (1UL << GFX_CTX_FLAGS_GL_CORE_CONTEXT); + return 1UL << GFX_CTX_FLAGS_NONE; } const gfx_ctx_driver_t gfx_ctx_x_egl = diff --git a/gfx/video_context_driver.h b/gfx/video_context_driver.h index 5f5219f3a9..4cd0b13a13 100644 --- a/gfx/video_context_driver.h +++ b/gfx/video_context_driver.h @@ -55,7 +55,7 @@ enum display_metric_types enum display_flags { GFX_CTX_FLAGS_NONE = 0, - GFX_CTX_FLAGS_CORE_GL + GFX_CTX_FLAGS_GL_CORE_CONTEXT }; enum gfx_ctx_ctl_state From 9d225e388f87dc923e8a39d99cd7367f5704cfb1 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 5 May 2016 05:49:48 +0200 Subject: [PATCH 160/498] Add GFX_CTL_GET_FLAGS --- gfx/video_context_driver.c | 10 ++++++++++ gfx/video_context_driver.h | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/gfx/video_context_driver.c b/gfx/video_context_driver.c index f9613e4b8a..c724aba461 100644 --- a/gfx/video_context_driver.c +++ b/gfx/video_context_driver.c @@ -477,6 +477,16 @@ bool gfx_ctx_ctl(enum gfx_ctx_ctl_state state, void *data) case GFX_CTL_SET_VIDEO_CONTEXT_DATA: video_context_data = data; break; + case GFX_CTL_GET_FLAGS: + { + gfx_ctx_flags_t *flags = (gfx_ctx_flags_t*)data; + if (!flags) + return false; + if (!current_video_context || !current_video_context->get_flags) + return false; + flags->flags = current_video_context->get_flags(video_context_data); + } + break; case GFX_CTL_NONE: default: break; diff --git a/gfx/video_context_driver.h b/gfx/video_context_driver.h index 4cd0b13a13..d6cdfe7544 100644 --- a/gfx/video_context_driver.h +++ b/gfx/video_context_driver.h @@ -83,6 +83,7 @@ enum gfx_ctx_ctl_state GFX_CTL_SWAP_INTERVAL, GFX_CTL_PROC_ADDRESS_GET, GFX_CTL_TRANSLATE_ASPECT, + GFX_CTL_GET_FLAGS, GFX_CTL_GET_METRICS, GFX_CTL_INPUT_DRIVER, GFX_CTL_SUPPRESS_SCREENSAVER, @@ -199,6 +200,11 @@ typedef struct gfx_ctx_driver void *(*get_context_data)(void *data); } gfx_ctx_driver_t; +typedef struct gfx_ctx_flags +{ + uint32_t flags; +} gfx_ctx_flags_t; + typedef struct gfx_ctx_size { bool *quit; From d176f2d48f9097ed0756aaa68d0b07ac489c8e11 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 5 May 2016 05:52:38 +0200 Subject: [PATCH 161/498] Try to query context driver about core GL context ability --- gfx/video_shader_driver.c | 27 ++++++++++++++++----------- 1 file changed, 16 insertions(+), 11 deletions(-) diff --git a/gfx/video_shader_driver.c b/gfx/video_shader_driver.c index 481f0cb01c..91ff8e43dc 100644 --- a/gfx/video_shader_driver.c +++ b/gfx/video_shader_driver.c @@ -40,22 +40,27 @@ static const shader_backend_t *video_shader_set_backend(enum rarch_shader_type t switch (type) { case RARCH_SHADER_CG: + { + #ifdef HAVE_CG - if (core_context_inited) - { - RARCH_ERR("[Shader driver]: Cg cannot be used with core GL context. Trying to fall back to GLSL...\n"); + gfx_ctx_flags_t flags; + gfx_ctx_ctl(GFX_CTL_GET_FLAGS, &flags); + if (flags.flags && (1UL << GFX_CTX_FLAGS_GL_CORE_CONTEXT)) + { + RARCH_ERR("[Shader driver]: Cg cannot be used with core GL context. Trying to fall back to GLSL...\n"); #ifdef HAVE_GLSL - return &gl_glsl_backend; + return &gl_glsl_backend; #endif - } - else - { - RARCH_LOG("[Shader driver]: Using Cg shader backend.\n"); - return &gl_cg_backend; - } + } + else + { + RARCH_LOG("[Shader driver]: Using Cg shader backend.\n"); + return &gl_cg_backend; + } #else - break; + break; #endif + } case RARCH_SHADER_GLSL: #ifdef HAVE_GLSL RARCH_LOG("[Shader driver]: Using GLSL shader backend.\n"); From a22b99838dcddb257a9f0a41ffb7cb8451ea923f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 5 May 2016 05:53:50 +0200 Subject: [PATCH 162/498] Get rid of variable core_context_inited --- gfx/video_shader_driver.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/gfx/video_shader_driver.c b/gfx/video_shader_driver.c index 91ff8e43dc..9bda85664c 100644 --- a/gfx/video_shader_driver.c +++ b/gfx/video_shader_driver.c @@ -34,8 +34,7 @@ static const shader_backend_t *shader_ctx_drivers[] = { NULL }; -static const shader_backend_t *video_shader_set_backend(enum rarch_shader_type type, - bool core_context_inited) +static const shader_backend_t *video_shader_set_backend(enum rarch_shader_type type) { switch (type) { @@ -190,8 +189,7 @@ bool video_shader_driver_ctl(enum video_shader_driver_ctl_state state, void *dat if (!init->shader || !init->shader->init) { - init->shader = video_shader_set_backend(init->shader_type, - init->gl.core_context_enabled); + init->shader = video_shader_set_backend(init->shader_type); if (!init->shader) return false; From 400f50ddac72741cd4f3e21aac79013cdcdaf862 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 5 May 2016 05:58:40 +0200 Subject: [PATCH 163/498] Comment this out for now until we fundamentally fix it --- gfx/drivers_context/x_ctx.c | 2 +- gfx/video_shader_driver.c | 7 ++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/gfx/drivers_context/x_ctx.c b/gfx/drivers_context/x_ctx.c index ddca3f6bc7..8dfe02d9cc 100644 --- a/gfx/drivers_context/x_ctx.c +++ b/gfx/drivers_context/x_ctx.c @@ -889,7 +889,7 @@ static void *gfx_ctx_x_get_context_data(void *data) static uint32_t gfx_ctx_x_get_flags(void *data) { gfx_ctx_x_data_t *x = (gfx_ctx_x_data_t*)data; - if (x->g_core_es || x->g_core_es_core) + if (x->g_core_es_core) return (1UL << GFX_CTX_FLAGS_GL_CORE_CONTEXT); return 1UL << GFX_CTX_FLAGS_NONE; } diff --git a/gfx/video_shader_driver.c b/gfx/video_shader_driver.c index 9bda85664c..0c2091486e 100644 --- a/gfx/video_shader_driver.c +++ b/gfx/video_shader_driver.c @@ -43,8 +43,12 @@ static const shader_backend_t *video_shader_set_backend(enum rarch_shader_type t #ifdef HAVE_CG gfx_ctx_flags_t flags; + struct retro_hw_render_callback *hwr = NULL; gfx_ctx_ctl(GFX_CTL_GET_FLAGS, &flags); - if (flags.flags && (1UL << GFX_CTX_FLAGS_GL_CORE_CONTEXT)) + video_driver_ctl(RARCH_DISPLAY_CTL_HW_CONTEXT_GET, &hwr); + +#if 0 + if ((flags.flags && (1UL << GFX_CTX_FLAGS_GL_CORE_CONTEXT)) && hwr && hwr->context_type != RETRO_HW_CONTEXT_NONE) { RARCH_ERR("[Shader driver]: Cg cannot be used with core GL context. Trying to fall back to GLSL...\n"); #ifdef HAVE_GLSL @@ -52,6 +56,7 @@ static const shader_backend_t *video_shader_set_backend(enum rarch_shader_type t #endif } else +#endif { RARCH_LOG("[Shader driver]: Using Cg shader backend.\n"); return &gl_cg_backend; From 14c14b72ac79e8e95b5b33b415f9b1927962b8be Mon Sep 17 00:00:00 2001 From: Sebastien Ronsse Date: Thu, 5 May 2016 14:11:28 +1000 Subject: [PATCH 164/498] task http: Add support for retrieving list of active transfers --- tasks/task_http.c | 71 ++++++++++++++++++++++++++++++++++++++++++ tasks/tasks_internal.h | 11 +++++++ 2 files changed, 82 insertions(+) diff --git a/tasks/task_http.c b/tasks/task_http.c index c17d2c465d..b77c8512d6 100644 --- a/tasks/task_http.c +++ b/tasks/task_http.c @@ -208,6 +208,49 @@ static bool rarch_task_http_finder(retro_task_t *task, void *user_data) return string_is_equal(http->connection.url, (const char*)user_data); } +static bool rarch_task_http_retriever(retro_task_t *task, void *user_data) +{ + http_handle_t *http; + http_transfer_info_t **list = user_data; + http_transfer_info_t *info; + http_transfer_info_t *link; + + /* Check if task is valid and corresponding to an HTTP transfer */ + if (!task || (task->handler != rarch_task_http_transfer_handler)) + return false; + + /* Check if user data argument is valid */ + if (!list) + return false; + + /* Extract HTTP handle and check if it is valid */ + http = (http_handle_t*)task->state; + if (!http) + return false; + + /* Create new HTTP info link */ + info = malloc(sizeof(http_transfer_info_t)); + strlcpy(info->url, http->connection.url, sizeof(info->url)); + info->progress = task->progress; + info->next = NULL; + + /* Add link to list */ + if (*list == NULL) + { + /* Initialize list with info if required */ + *list = info; + } + else + { + /* Cycle through list until end is reached and add info */ + for (link = *list; link->next != NULL; link = link->next); + link->next = info; + } + + /* Request task finder to continue searching in all cases */ + return false; +} + bool rarch_task_push_http_transfer(const char *url, const char *type, retro_task_callback_t cb, void *user_data) { @@ -279,3 +322,31 @@ error: return false; } + +http_transfer_info_t *http_task_get_transfer_list() +{ + http_transfer_info_t *list = NULL; + task_finder_data_t find_data; + + /* Fill find data */ + find_data.func = rarch_task_http_retriever; + find_data.userdata = &list; + + /* Build list of current HTTP transfers and return it */ + task_queue_ctl(TASK_QUEUE_CTL_FIND, &find_data); + return list; +} + +void http_task_free_transfer_list(http_transfer_info_t *list) +{ + http_transfer_info_t *link; + + /* Free list of transfers */ + while (list) + { + link = list->next; + free(list); + list = link; + } +} + diff --git a/tasks/tasks_internal.h b/tasks/tasks_internal.h index 3fb56d67ce..5bcdc230c0 100644 --- a/tasks/tasks_internal.h +++ b/tasks/tasks_internal.h @@ -34,8 +34,19 @@ typedef struct { size_t len; } http_transfer_data_t; +typedef struct http_transfer_info +{ + char url[PATH_MAX_LENGTH]; + int progress; + struct http_transfer_info *next; +} http_transfer_info_t; + bool rarch_task_push_http_transfer(const char *url, const char *type, retro_task_callback_t cb, void *userdata); + +http_transfer_info_t *http_task_get_transfer_list(); + +void http_task_free_transfer_list(http_transfer_info_t *list); #endif bool rarch_task_push_image_load(const char *fullpath, const char *type, From 9b889e14d4ff7ce089ac7cf43d7df7688f17c643 Mon Sep 17 00:00:00 2001 From: Andre Leiradella Date: Thu, 5 May 2016 09:48:50 -0300 Subject: [PATCH 165/498] http tasks can now be cancelled; on-demand thumbnail download working --- libretro-common/include/queues/task_queue.h | 9 +- libretro-common/queues/task_queue.c | 35 ++++++++ menu/drivers/xmb.c | 97 ++++++++++++++++++--- tasks/task_http.c | 12 +-- tasks/tasks_internal.h | 2 +- 5 files changed, 137 insertions(+), 18 deletions(-) diff --git a/libretro-common/include/queues/task_queue.h b/libretro-common/include/queues/task_queue.h index 7fc9e2b039..5ef6669c29 100644 --- a/libretro-common/include/queues/task_queue.h +++ b/libretro-common/include/queues/task_queue.h @@ -82,7 +82,12 @@ enum task_queue_ctl_state TASK_QUEUE_CTL_UNSET_THREADED, - TASK_QUEUE_CTL_IS_THREADED + TASK_QUEUE_CTL_IS_THREADED, + + /** + * Signals a task to end without waiting for + * it to complete. */ + TASK_QUEUE_CTL_CANCEL, }; typedef struct retro_task retro_task_t; @@ -148,6 +153,8 @@ void task_queue_push_progress(retro_task_t *task); bool task_queue_ctl(enum task_queue_ctl_state state, void *data); +void task_queue_cancel_task(void *task); + RETRO_END_DECLS #endif diff --git a/libretro-common/queues/task_queue.c b/libretro-common/queues/task_queue.c index 3c4940a24a..ec51a00904 100644 --- a/libretro-common/queues/task_queue.c +++ b/libretro-common/queues/task_queue.c @@ -39,6 +39,7 @@ typedef struct struct retro_task_impl { void (*push_running)(retro_task_t *); + void (*cancel)(void *); void (*reset)(void); void (*wait)(void); void (*gather)(void); @@ -167,6 +168,12 @@ static void retro_task_regular_push_running(retro_task_t *task) task_queue_put(&tasks_running, task); } +static void retro_task_regular_cancel(void *task) +{ + retro_task_t *t = task; + t->cancelled = true; +} + static void retro_task_regular_gather(void) { retro_task_t *task = NULL; @@ -232,6 +239,7 @@ static bool retro_task_regular_find(retro_task_finder_t func, void *user_data) static struct retro_task_impl impl_regular = { retro_task_regular_push_running, + retro_task_regular_cancel, retro_task_regular_reset, retro_task_regular_wait, retro_task_regular_gather, @@ -255,6 +263,24 @@ static void retro_task_threaded_push_running(retro_task_t *task) slock_unlock(running_lock); } +static void retro_task_threaded_cancel(void *task) +{ + retro_task_t *t; + + slock_lock(running_lock); + + for (t = tasks_running.front; t; t = t->next) + { + if (t == task) + { + t->cancelled = true; + break; + } + } + + slock_unlock(running_lock); +} + static void retro_task_threaded_gather(void) { retro_task_t *task = NULL; @@ -400,6 +426,7 @@ static void retro_task_threaded_deinit(void) static struct retro_task_impl impl_threaded = { retro_task_threaded_push_running, + retro_task_threaded_cancel, retro_task_threaded_reset, retro_task_threaded_wait, retro_task_threaded_gather, @@ -485,6 +512,9 @@ bool task_queue_ctl(enum task_queue_ctl_state state, void *data) case TASK_QUEUE_CTL_WAIT: impl_current->wait(); break; + case TASK_QUEUE_CTL_CANCEL: + impl_current->cancel(data); + break; case TASK_QUEUE_CTL_NONE: default: break; @@ -492,3 +522,8 @@ bool task_queue_ctl(enum task_queue_ctl_state state, void *data) return true; } + +void task_queue_cancel_task(void *task) +{ + task_queue_ctl(TASK_QUEUE_CTL_CANCEL, task); +} diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 65377e2ba6..a237e3202f 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2011-2016 - Daniel De Matteis - * Copyright (C) 2014-2015 - Jean-André Santoni + * Copyright (C) 2014-2015 - 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- @@ -47,6 +47,7 @@ #include "../../system.h" #include "../../tasks/tasks_internal.h" +#include #define XMB_RIBBON_ROWS 64 #define XMB_RIBBON_COLS 64 @@ -149,6 +150,7 @@ typedef struct xmb_handle uintptr_t thumbnail; float thumbnail_width; float thumbnail_height; + void *thumbnail_task; char background_file_path[PATH_MAX_LENGTH]; char thumbnail_file_path[PATH_MAX_LENGTH]; @@ -719,17 +721,91 @@ static void menu_display_handle_thumbnail_upload(void *task_data, free(img); } + +typedef struct +{ + xmb_handle_t *xmb; + char file_path[1]; +} +download_t; + +static void cb_thumbnail_download(void *task_data, void *user_data, const char *error) +{ + download_t *ud = user_data; + char output_path[PATH_MAX_LENGTH]; + http_transfer_data_t *data = (http_transfer_data_t*)task_data; + + if (!data || !data->data) + goto finished; + + ud->xmb->thumbnail_task = NULL; + + strncpy(output_path, ud->file_path, sizeof(output_path)); + output_path[sizeof(output_path) - 1] = 0; + path_basedir(output_path); + + if (!path_mkdir(output_path)) + { + RARCH_ERR("Error creating folders for file %s\n", ud->file_path); + goto finished; + } + + if (!filestream_write_file(ud->file_path, data->data, data->len)) + { + RARCH_ERR("Error writing file %s\n", ud->file_path); + goto finished; + } + + /* Only update the image on the menu if the user is still at the same entry */ + if (!strcmp(ud->file_path, ud->xmb->thumbnail_file_path)) + rarch_task_push_image_load(ud->file_path, "cb_menu_thumbnail", + menu_display_handle_thumbnail_upload, NULL); + +finished: + free(ud); +} + static void xmb_update_thumbnail_image(void *data) { xmb_handle_t *xmb = (xmb_handle_t*)data; + download_t *ud; + char buf[PATH_MAX_LENGTH]; + if (!xmb) return; + RARCH_LOG ("FILE: %s\n", xmb->thumbnail_file_path); + if (path_file_exists(xmb->thumbnail_file_path)) rarch_task_push_image_load(xmb->thumbnail_file_path, "cb_menu_thumbnail", menu_display_handle_thumbnail_upload, NULL); - else if (xmb->depth == 1) - xmb->thumbnail = 0; + else + { + ud = (download_t *)malloc(sizeof(*ud) + strlen(xmb->thumbnail_file_path)); + + if (!ud) + { + RARCH_ERR("Error allocating memory for the thumbnail download userdata\n"); + return; + } + + ud->xmb = xmb; + strcpy(ud->file_path, strdup(xmb->thumbnail_file_path)); + + snprintf(buf, sizeof(buf), "http://thumbnails.libretro.com/%s/%s/%s", + xmb->title_name, xmb_thumbnails_ident(), + path_basename(xmb->thumbnail_file_path)); + + RARCH_LOG ("URL: %s\n", buf); + + if (xmb->thumbnail_task) + task_queue_cancel_task(xmb->thumbnail_task); + + xmb->thumbnail_task = rarch_task_push_http_transfer(buf, "", cb_thumbnail_download, ud); + + if (xmb->depth == 1) + xmb->thumbnail = 0; + } } static void xmb_selection_pointer_changed( @@ -779,13 +855,6 @@ static void xmb_selection_pointer_changed( { ia = XMB_ITEM_ACTIVE_ALPHA; iz = XMB_ITEM_ACTIVE_ZOOM; - - depth = xmb_list_get_size(xmb, MENU_LIST_PLAIN); - if (strcmp(xmb_thumbnails_ident(), "OFF") && depth == 1) - { - xmb_update_thumbnail_path(xmb, i); - xmb_update_thumbnail_image(xmb); - } } if (real_iy < -threshold) @@ -2468,6 +2537,7 @@ static void *xmb_init(void **userdata) xmb->depth = 1; xmb->old_depth = 1; xmb->alpha = 0; + xmb->thumbnail_task = NULL; menu_driver_ctl(RARCH_MENU_CTL_UNSET_PREVENT_POPULATE, NULL); /* TODO/FIXME - we don't use framebuffer at all @@ -2759,6 +2829,13 @@ static void xmb_navigation_set(void *data, bool scroll) { xmb_handle_t *xmb = (xmb_handle_t*)data; xmb_selection_pointer_changed(xmb, true); + + size_t selection; + if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection)) + return; + + xmb_update_thumbnail_path(xmb, selection); + xmb_update_thumbnail_image(xmb); } static void xmb_navigation_alphabet(void *data, size_t *unused) diff --git a/tasks/task_http.c b/tasks/task_http.c index c17d2c465d..f65dd6e43f 100644 --- a/tasks/task_http.c +++ b/tasks/task_http.c @@ -208,7 +208,7 @@ static bool rarch_task_http_finder(retro_task_t *task, void *user_data) return string_is_equal(http->connection.url, (const char*)user_data); } -bool rarch_task_push_http_transfer(const char *url, const char *type, +void *rarch_task_push_http_transfer(const char *url, const char *type, retro_task_callback_t cb, void *user_data) { char tmp[PATH_MAX_LENGTH]; @@ -218,7 +218,7 @@ bool rarch_task_push_http_transfer(const char *url, const char *type, http_handle_t *http = NULL; if (string_is_empty(url)) - return false; + return NULL; find_data.func = rarch_task_http_finder; find_data.userdata = (void*)url; @@ -227,13 +227,13 @@ bool rarch_task_push_http_transfer(const char *url, const char *type, if (task_queue_ctl(TASK_QUEUE_CTL_FIND, &find_data)) { RARCH_LOG("[http] '%s'' is already being downloaded.\n", url); - return false; + return NULL; } conn = net_http_connection_new(url); if (!conn) - return false; + return NULL; http = (http_handle_t*)calloc(1, sizeof(*http)); @@ -267,7 +267,7 @@ bool rarch_task_push_http_transfer(const char *url, const char *type, task_queue_ctl(TASK_QUEUE_CTL_PUSH, t); - return true; + return t; error: if (conn) @@ -277,5 +277,5 @@ error: if (http) free(http); - return false; + return NULL; } diff --git a/tasks/tasks_internal.h b/tasks/tasks_internal.h index 3fb56d67ce..29883e5cc5 100644 --- a/tasks/tasks_internal.h +++ b/tasks/tasks_internal.h @@ -34,7 +34,7 @@ typedef struct { size_t len; } http_transfer_data_t; -bool rarch_task_push_http_transfer(const char *url, const char *type, +void *rarch_task_push_http_transfer(const char *url, const char *type, retro_task_callback_t cb, void *userdata); #endif From 87e22df9c870bae786214e0e4a11eb3a8c11a03e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Thu, 5 May 2016 21:15:05 +0700 Subject: [PATCH 166/498] (XMB) Bugfix the thumbnail display. And prevent download on non playlist entries. --- menu/drivers/xmb.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index a237e3202f..4ff3961333 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -770,6 +770,8 @@ static void xmb_update_thumbnail_image(void *data) xmb_handle_t *xmb = (xmb_handle_t*)data; download_t *ud; char buf[PATH_MAX_LENGTH]; + unsigned selection = 0; + menu_entry_t entry; if (!xmb) return; @@ -781,6 +783,13 @@ static void xmb_update_thumbnail_image(void *data) menu_display_handle_thumbnail_upload, NULL); else { + menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection); + + menu_entry_get(&entry, 0, selection, NULL, true); + + if (entry.type != MENU_FILE_RPL_ENTRY) + return; + ud = (download_t *)malloc(sizeof(*ud) + strlen(xmb->thumbnail_file_path)); if (!ud) @@ -2830,12 +2839,16 @@ static void xmb_navigation_set(void *data, bool scroll) xmb_handle_t *xmb = (xmb_handle_t*)data; xmb_selection_pointer_changed(xmb, true); - size_t selection; + size_t depth, selection; if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection)) return; - xmb_update_thumbnail_path(xmb, selection); - xmb_update_thumbnail_image(xmb); + depth = xmb_list_get_size(xmb, MENU_LIST_PLAIN); + if (strcmp(xmb_thumbnails_ident(), "OFF") && depth == 1) + { + xmb_update_thumbnail_path(xmb, selection); + xmb_update_thumbnail_image(xmb); + } } static void xmb_navigation_alphabet(void *data, size_t *unused) From dc4a114d36ce14bda002d237f7798a60429e2dc7 Mon Sep 17 00:00:00 2001 From: FIX94 Date: Thu, 5 May 2016 16:47:44 +0200 Subject: [PATCH 167/498] (GX) fixed program crash when no argv structure is present on start --- frontend/drivers/platform_gx.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/frontend/drivers/platform_gx.c b/frontend/drivers/platform_gx.c index 82ee8cdf2c..5b71fb10bd 100644 --- a/frontend/drivers/platform_gx.c +++ b/frontend/drivers/platform_gx.c @@ -174,6 +174,23 @@ static void frontend_gx_get_environment_settings( #endif #endif + /* This situation can happen on some loaders so we really need some + fake args or else retroarch will just crash on parsing NULL pointers */ + if(*argc == 0 || argv == NULL) + { + struct rarch_main_wrap *args = (struct rarch_main_wrap*)params_data; + if (args) + { + args->touched = true; + args->no_content = false; + args->verbose = false; + args->config_path = NULL; + args->sram_path = NULL; + args->state_path = NULL; + args->content_path = NULL; + args->libretro_path = NULL; + } + } #ifdef HW_DOL chdir("carda:/retroarch"); #endif From c2102ecfb538723918fff3aa530190e691c8aff2 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Thu, 5 May 2016 17:00:24 +0200 Subject: [PATCH 168/498] =?UTF-8?q?Revert=20"(XMB)=20Bugfix=20the=20thumbn?= =?UTF-8?q?ail=20display.=20And=20prevent=20download=20on=20non=20playl?= =?UTF-8?q?=E2=80=A6"?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- menu/drivers/xmb.c | 19 +++---------------- 1 file changed, 3 insertions(+), 16 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 4ff3961333..a237e3202f 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -770,8 +770,6 @@ static void xmb_update_thumbnail_image(void *data) xmb_handle_t *xmb = (xmb_handle_t*)data; download_t *ud; char buf[PATH_MAX_LENGTH]; - unsigned selection = 0; - menu_entry_t entry; if (!xmb) return; @@ -783,13 +781,6 @@ static void xmb_update_thumbnail_image(void *data) menu_display_handle_thumbnail_upload, NULL); else { - menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection); - - menu_entry_get(&entry, 0, selection, NULL, true); - - if (entry.type != MENU_FILE_RPL_ENTRY) - return; - ud = (download_t *)malloc(sizeof(*ud) + strlen(xmb->thumbnail_file_path)); if (!ud) @@ -2839,16 +2830,12 @@ static void xmb_navigation_set(void *data, bool scroll) xmb_handle_t *xmb = (xmb_handle_t*)data; xmb_selection_pointer_changed(xmb, true); - size_t depth, selection; + size_t selection; if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection)) return; - depth = xmb_list_get_size(xmb, MENU_LIST_PLAIN); - if (strcmp(xmb_thumbnails_ident(), "OFF") && depth == 1) - { - xmb_update_thumbnail_path(xmb, selection); - xmb_update_thumbnail_image(xmb); - } + xmb_update_thumbnail_path(xmb, selection); + xmb_update_thumbnail_image(xmb); } static void xmb_navigation_alphabet(void *data, size_t *unused) From 1c2bf6e305b43846f211d82143349f378c76e28c Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Thu, 5 May 2016 17:00:43 +0200 Subject: [PATCH 169/498] Revert "http tasks can now be cancelled; on-demand thumbnail download working" --- libretro-common/include/queues/task_queue.h | 9 +- libretro-common/queues/task_queue.c | 35 -------- menu/drivers/xmb.c | 97 +++------------------ tasks/task_http.c | 12 +-- tasks/tasks_internal.h | 2 +- 5 files changed, 18 insertions(+), 137 deletions(-) diff --git a/libretro-common/include/queues/task_queue.h b/libretro-common/include/queues/task_queue.h index 5ef6669c29..7fc9e2b039 100644 --- a/libretro-common/include/queues/task_queue.h +++ b/libretro-common/include/queues/task_queue.h @@ -82,12 +82,7 @@ enum task_queue_ctl_state TASK_QUEUE_CTL_UNSET_THREADED, - TASK_QUEUE_CTL_IS_THREADED, - - /** - * Signals a task to end without waiting for - * it to complete. */ - TASK_QUEUE_CTL_CANCEL, + TASK_QUEUE_CTL_IS_THREADED }; typedef struct retro_task retro_task_t; @@ -153,8 +148,6 @@ void task_queue_push_progress(retro_task_t *task); bool task_queue_ctl(enum task_queue_ctl_state state, void *data); -void task_queue_cancel_task(void *task); - RETRO_END_DECLS #endif diff --git a/libretro-common/queues/task_queue.c b/libretro-common/queues/task_queue.c index ec51a00904..3c4940a24a 100644 --- a/libretro-common/queues/task_queue.c +++ b/libretro-common/queues/task_queue.c @@ -39,7 +39,6 @@ typedef struct struct retro_task_impl { void (*push_running)(retro_task_t *); - void (*cancel)(void *); void (*reset)(void); void (*wait)(void); void (*gather)(void); @@ -168,12 +167,6 @@ static void retro_task_regular_push_running(retro_task_t *task) task_queue_put(&tasks_running, task); } -static void retro_task_regular_cancel(void *task) -{ - retro_task_t *t = task; - t->cancelled = true; -} - static void retro_task_regular_gather(void) { retro_task_t *task = NULL; @@ -239,7 +232,6 @@ static bool retro_task_regular_find(retro_task_finder_t func, void *user_data) static struct retro_task_impl impl_regular = { retro_task_regular_push_running, - retro_task_regular_cancel, retro_task_regular_reset, retro_task_regular_wait, retro_task_regular_gather, @@ -263,24 +255,6 @@ static void retro_task_threaded_push_running(retro_task_t *task) slock_unlock(running_lock); } -static void retro_task_threaded_cancel(void *task) -{ - retro_task_t *t; - - slock_lock(running_lock); - - for (t = tasks_running.front; t; t = t->next) - { - if (t == task) - { - t->cancelled = true; - break; - } - } - - slock_unlock(running_lock); -} - static void retro_task_threaded_gather(void) { retro_task_t *task = NULL; @@ -426,7 +400,6 @@ static void retro_task_threaded_deinit(void) static struct retro_task_impl impl_threaded = { retro_task_threaded_push_running, - retro_task_threaded_cancel, retro_task_threaded_reset, retro_task_threaded_wait, retro_task_threaded_gather, @@ -512,9 +485,6 @@ bool task_queue_ctl(enum task_queue_ctl_state state, void *data) case TASK_QUEUE_CTL_WAIT: impl_current->wait(); break; - case TASK_QUEUE_CTL_CANCEL: - impl_current->cancel(data); - break; case TASK_QUEUE_CTL_NONE: default: break; @@ -522,8 +492,3 @@ bool task_queue_ctl(enum task_queue_ctl_state state, void *data) return true; } - -void task_queue_cancel_task(void *task) -{ - task_queue_ctl(TASK_QUEUE_CTL_CANCEL, task); -} diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index a237e3202f..65377e2ba6 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2011-2016 - Daniel De Matteis - * Copyright (C) 2014-2015 - Jean-André Santoni + * Copyright (C) 2014-2015 - 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- @@ -47,7 +47,6 @@ #include "../../system.h" #include "../../tasks/tasks_internal.h" -#include #define XMB_RIBBON_ROWS 64 #define XMB_RIBBON_COLS 64 @@ -150,7 +149,6 @@ typedef struct xmb_handle uintptr_t thumbnail; float thumbnail_width; float thumbnail_height; - void *thumbnail_task; char background_file_path[PATH_MAX_LENGTH]; char thumbnail_file_path[PATH_MAX_LENGTH]; @@ -721,91 +719,17 @@ static void menu_display_handle_thumbnail_upload(void *task_data, free(img); } - -typedef struct -{ - xmb_handle_t *xmb; - char file_path[1]; -} -download_t; - -static void cb_thumbnail_download(void *task_data, void *user_data, const char *error) -{ - download_t *ud = user_data; - char output_path[PATH_MAX_LENGTH]; - http_transfer_data_t *data = (http_transfer_data_t*)task_data; - - if (!data || !data->data) - goto finished; - - ud->xmb->thumbnail_task = NULL; - - strncpy(output_path, ud->file_path, sizeof(output_path)); - output_path[sizeof(output_path) - 1] = 0; - path_basedir(output_path); - - if (!path_mkdir(output_path)) - { - RARCH_ERR("Error creating folders for file %s\n", ud->file_path); - goto finished; - } - - if (!filestream_write_file(ud->file_path, data->data, data->len)) - { - RARCH_ERR("Error writing file %s\n", ud->file_path); - goto finished; - } - - /* Only update the image on the menu if the user is still at the same entry */ - if (!strcmp(ud->file_path, ud->xmb->thumbnail_file_path)) - rarch_task_push_image_load(ud->file_path, "cb_menu_thumbnail", - menu_display_handle_thumbnail_upload, NULL); - -finished: - free(ud); -} - static void xmb_update_thumbnail_image(void *data) { xmb_handle_t *xmb = (xmb_handle_t*)data; - download_t *ud; - char buf[PATH_MAX_LENGTH]; - if (!xmb) return; - RARCH_LOG ("FILE: %s\n", xmb->thumbnail_file_path); - if (path_file_exists(xmb->thumbnail_file_path)) rarch_task_push_image_load(xmb->thumbnail_file_path, "cb_menu_thumbnail", menu_display_handle_thumbnail_upload, NULL); - else - { - ud = (download_t *)malloc(sizeof(*ud) + strlen(xmb->thumbnail_file_path)); - - if (!ud) - { - RARCH_ERR("Error allocating memory for the thumbnail download userdata\n"); - return; - } - - ud->xmb = xmb; - strcpy(ud->file_path, strdup(xmb->thumbnail_file_path)); - - snprintf(buf, sizeof(buf), "http://thumbnails.libretro.com/%s/%s/%s", - xmb->title_name, xmb_thumbnails_ident(), - path_basename(xmb->thumbnail_file_path)); - - RARCH_LOG ("URL: %s\n", buf); - - if (xmb->thumbnail_task) - task_queue_cancel_task(xmb->thumbnail_task); - - xmb->thumbnail_task = rarch_task_push_http_transfer(buf, "", cb_thumbnail_download, ud); - - if (xmb->depth == 1) - xmb->thumbnail = 0; - } + else if (xmb->depth == 1) + xmb->thumbnail = 0; } static void xmb_selection_pointer_changed( @@ -855,6 +779,13 @@ static void xmb_selection_pointer_changed( { ia = XMB_ITEM_ACTIVE_ALPHA; iz = XMB_ITEM_ACTIVE_ZOOM; + + depth = xmb_list_get_size(xmb, MENU_LIST_PLAIN); + if (strcmp(xmb_thumbnails_ident(), "OFF") && depth == 1) + { + xmb_update_thumbnail_path(xmb, i); + xmb_update_thumbnail_image(xmb); + } } if (real_iy < -threshold) @@ -2537,7 +2468,6 @@ static void *xmb_init(void **userdata) xmb->depth = 1; xmb->old_depth = 1; xmb->alpha = 0; - xmb->thumbnail_task = NULL; menu_driver_ctl(RARCH_MENU_CTL_UNSET_PREVENT_POPULATE, NULL); /* TODO/FIXME - we don't use framebuffer at all @@ -2829,13 +2759,6 @@ static void xmb_navigation_set(void *data, bool scroll) { xmb_handle_t *xmb = (xmb_handle_t*)data; xmb_selection_pointer_changed(xmb, true); - - size_t selection; - if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection)) - return; - - xmb_update_thumbnail_path(xmb, selection); - xmb_update_thumbnail_image(xmb); } static void xmb_navigation_alphabet(void *data, size_t *unused) diff --git a/tasks/task_http.c b/tasks/task_http.c index f65dd6e43f..c17d2c465d 100644 --- a/tasks/task_http.c +++ b/tasks/task_http.c @@ -208,7 +208,7 @@ static bool rarch_task_http_finder(retro_task_t *task, void *user_data) return string_is_equal(http->connection.url, (const char*)user_data); } -void *rarch_task_push_http_transfer(const char *url, const char *type, +bool rarch_task_push_http_transfer(const char *url, const char *type, retro_task_callback_t cb, void *user_data) { char tmp[PATH_MAX_LENGTH]; @@ -218,7 +218,7 @@ void *rarch_task_push_http_transfer(const char *url, const char *type, http_handle_t *http = NULL; if (string_is_empty(url)) - return NULL; + return false; find_data.func = rarch_task_http_finder; find_data.userdata = (void*)url; @@ -227,13 +227,13 @@ void *rarch_task_push_http_transfer(const char *url, const char *type, if (task_queue_ctl(TASK_QUEUE_CTL_FIND, &find_data)) { RARCH_LOG("[http] '%s'' is already being downloaded.\n", url); - return NULL; + return false; } conn = net_http_connection_new(url); if (!conn) - return NULL; + return false; http = (http_handle_t*)calloc(1, sizeof(*http)); @@ -267,7 +267,7 @@ void *rarch_task_push_http_transfer(const char *url, const char *type, task_queue_ctl(TASK_QUEUE_CTL_PUSH, t); - return t; + return true; error: if (conn) @@ -277,5 +277,5 @@ error: if (http) free(http); - return NULL; + return false; } diff --git a/tasks/tasks_internal.h b/tasks/tasks_internal.h index 29883e5cc5..3fb56d67ce 100644 --- a/tasks/tasks_internal.h +++ b/tasks/tasks_internal.h @@ -34,7 +34,7 @@ typedef struct { size_t len; } http_transfer_data_t; -void *rarch_task_push_http_transfer(const char *url, const char *type, +bool rarch_task_push_http_transfer(const char *url, const char *type, retro_task_callback_t cb, void *userdata); #endif From 60233d1abbb4b1ba5a2e5c652b5aeb51cfe6390a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 5 May 2016 17:35:28 +0200 Subject: [PATCH 170/498] Add set_flags to context driver --- gfx/drivers_context/android_ctx.c | 12 ++++++-- gfx/drivers_context/bbqnx_ctx.c | 11 +++++-- gfx/drivers_context/cgl_ctx.c | 11 +++++-- gfx/drivers_context/cocoa_gl_ctx.m | 11 +++++-- gfx/drivers_context/d3d_ctx.cpp | 12 ++++++-- gfx/drivers_context/drm_ctx.c | 23 ++++++++++++-- gfx/drivers_context/emscriptenegl_ctx.c | 9 +++++- gfx/drivers_context/gfx_null_ctx.c | 10 ++++++- gfx/drivers_context/mali_fbdev_ctx.c | 10 ++++++- gfx/drivers_context/opendingux_fbdev_ctx.c | 9 +++++- gfx/drivers_context/ps3_ctx.c | 9 +++++- gfx/drivers_context/sdl_gl_ctx.c | 9 +++++- gfx/drivers_context/vc_egl_ctx.c | 9 +++++- gfx/drivers_context/vivante_fbdev_ctx.c | 9 +++++- gfx/drivers_context/wayland_ctx.c | 22 ++++++++++++-- gfx/drivers_context/wgl_ctx.cpp | 35 ++++++++++++++++------ gfx/drivers_context/x_ctx.c | 24 ++++++++++++--- gfx/drivers_context/xegl_ctx.c | 12 +++++--- gfx/video_context_driver.h | 2 ++ 19 files changed, 208 insertions(+), 41 deletions(-) diff --git a/gfx/drivers_context/android_ctx.c b/gfx/drivers_context/android_ctx.c index 2bb0547f35..976c02cb05 100644 --- a/gfx/drivers_context/android_ctx.c +++ b/gfx/drivers_context/android_ctx.c @@ -539,8 +539,15 @@ static void *android_gfx_ctx_get_context_data(void *data) static uint32_t android_gfx_ctx_get_flags(void *data) { - (void)data; - return 1UL << GFX_CTX_FLAGS_NONE; + uint32_t flags = 0; + BIT32_SET(flags, GFX_CTX_FLAGS_NONE); + + return flags; +} + +static void android_gfx_ctx_set_flags(void *data, uint32_t flags) +{ + (void)flags; } const gfx_ctx_driver_t gfx_ctx_android = { @@ -569,6 +576,7 @@ const gfx_ctx_driver_t gfx_ctx_android = { NULL, "android", android_gfx_ctx_get_flags, + android_gfx_ctx_set_flags, android_gfx_ctx_bind_hw_render, #ifdef HAVE_VULKAN android_gfx_ctx_get_context_data diff --git a/gfx/drivers_context/bbqnx_ctx.c b/gfx/drivers_context/bbqnx_ctx.c index 947df8e918..34981e6bc6 100644 --- a/gfx/drivers_context/bbqnx_ctx.c +++ b/gfx/drivers_context/bbqnx_ctx.c @@ -400,8 +400,14 @@ static void gfx_ctx_qnx_get_video_size(void *data, static uint32_t gfx_ctx_qnx_get_flags(void *data) { - (void)data; - return 1UL << GFX_CTX_FLAGS_NONE; + uint32_t flags = 0; + BIT32_SET(flags, GFX_CTX_FLAGS_NONE); + return flags; +} + +static void gfx_ctx_qnx_set_flags(void *data, uint32_t flags) +{ + (void)flags; } const gfx_ctx_driver_t gfx_ctx_bbqnx = { @@ -430,5 +436,6 @@ const gfx_ctx_driver_t gfx_ctx_bbqnx = { NULL, "blackberry_qnx", gfx_ctx_qnx_get_flags, + gfx_ctx_qnx_set_flags, gfx_ctx_qnx_bind_hw_render }; diff --git a/gfx/drivers_context/cgl_ctx.c b/gfx/drivers_context/cgl_ctx.c index 2d24b75fea..c16b5c121b 100644 --- a/gfx/drivers_context/cgl_ctx.c +++ b/gfx/drivers_context/cgl_ctx.c @@ -341,9 +341,15 @@ error: } static uint32_t gfx_ctx_cgl_get_flags(void *data) +{ + uint32_t flags = 0; + BIT32_SET(flags, GFX_CTX_FLAGS_NONE); + return flags; +} + +static void gfx_ctx_cgl_set_flags(void *data, uint32_t flags) { (void)data; - return 1UL << GFX_CTX_FLAGS_NONE; } const gfx_ctx_driver_t gfx_ctx_cgl = { @@ -372,5 +378,6 @@ const gfx_ctx_driver_t gfx_ctx_cgl = { gfx_ctx_cgl_show_mouse, "cgl", gfx_ctx_cgl_get_flags, - gfx_ctx_cgl_bind_hw_render, + gfx_ctx_cgl_set_flags, + gfx_ctx_cgl_bind_hw_render }; diff --git a/gfx/drivers_context/cocoa_gl_ctx.m b/gfx/drivers_context/cocoa_gl_ctx.m index dde8ab6ee4..0563fcc439 100644 --- a/gfx/drivers_context/cocoa_gl_ctx.m +++ b/gfx/drivers_context/cocoa_gl_ctx.m @@ -597,8 +597,14 @@ static void cocoagl_gfx_ctx_bind_hw_render(void *data, bool enable) static uint32_t cocoagl_gfx_ctx_get_flags(void *data) { - (void)data; - return 1UL << GFX_CTX_FLAGS_NONE; + uint32_t flags = 0; + BIT32_SET(flags, GFX_CTX_FLAGS_NONE); + return flags; +} + +static void cocoagl_gfx_ctx_set_flags(void *data, uint32_t flags) +{ + (void)flags; } const gfx_ctx_driver_t gfx_ctx_cocoagl = { @@ -627,5 +633,6 @@ const gfx_ctx_driver_t gfx_ctx_cocoagl = { NULL, "cocoagl", cocoagl_gfx_ctx_get_flags, + cocoagl_gfx_ctx_set_flags, cocoagl_gfx_ctx_bind_hw_render, }; diff --git a/gfx/drivers_context/d3d_ctx.cpp b/gfx/drivers_context/d3d_ctx.cpp index 58ec05682f..9cf38a7742 100644 --- a/gfx/drivers_context/d3d_ctx.cpp +++ b/gfx/drivers_context/d3d_ctx.cpp @@ -304,8 +304,15 @@ static bool gfx_ctx_d3d_get_metrics(void *data, static uint32_t gfx_ctx_d3d_get_flags(void *data) { - (void)data; - return 1UL << GFX_CTX_FLAGS_NONE; + uint32_t flags = 0; + BIT32_SET(flags, GFX_CTX_FLAGS_NONE); + + return flags; +} + +static void gfx_ctx_d3d_set_flags(void *data, uint32_t flags) +{ + (void)flags; } const gfx_ctx_driver_t gfx_ctx_d3d = { @@ -334,4 +341,5 @@ const gfx_ctx_driver_t gfx_ctx_d3d = { gfx_ctx_d3d_show_mouse, "d3d", gfx_ctx_d3d_get_flags, + gfx_ctx_d3d_set_flags }; diff --git a/gfx/drivers_context/drm_ctx.c b/gfx/drivers_context/drm_ctx.c index dc662835bb..b6d3ba4b89 100644 --- a/gfx/drivers_context/drm_ctx.c +++ b/gfx/drivers_context/drm_ctx.c @@ -80,6 +80,8 @@ typedef struct gfx_ctx_drm_data unsigned interval; unsigned fb_width; unsigned fb_height; + + bool core_hw_context_enable; } gfx_ctx_drm_data_t; struct drm_fb @@ -871,11 +873,25 @@ static void gfx_ctx_drm_bind_hw_render(void *data, bool enable) } static uint32_t gfx_ctx_drm_get_flags(void *data) +{ + uint32_t flags = 0; + gfx_ctx_drm_data_t *drm = (gfx_ctx_drm_data_t*)data; + + if (drm->core_hw_context_enable) + { + BIT32_SET(flags, GFX_CTX_FLAGS_GL_CORE_CONTEXT); + } + else + BIT32_SET(flags, GFX_CTX_FLAGS_NONE); + + return flags; +} + +static void gfx_ctx_drm_set_flags(void *data, uint32_t flags) { gfx_ctx_drm_data_t *drm = (gfx_ctx_drm_data_t*)data; - if ((drm->egl.major * 1000 + drm->egl.minor) >= 3001) - return (1UL << GFX_CTX_FLAGS_GL_CORE_CONTEXT); - return 1UL << GFX_CTX_FLAGS_NONE; + if (BIT32_GET(flags, GFX_CTX_FLAGS_GL_CORE_CONTEXT)) + drm->core_hw_context_enable = true; } const gfx_ctx_driver_t gfx_ctx_drm = { @@ -904,5 +920,6 @@ const gfx_ctx_driver_t gfx_ctx_drm = { NULL, "kms", gfx_ctx_drm_get_flags, + gfx_ctx_drm_set_flags, gfx_ctx_drm_bind_hw_render }; diff --git a/gfx/drivers_context/emscriptenegl_ctx.c b/gfx/drivers_context/emscriptenegl_ctx.c index 80bd2d91cc..793a5dcad0 100644 --- a/gfx/drivers_context/emscriptenegl_ctx.c +++ b/gfx/drivers_context/emscriptenegl_ctx.c @@ -304,9 +304,15 @@ static void gfx_ctx_emscripten_bind_hw_render(void *data, bool enable) } static uint32_t gfx_ctx_emscripten_get_flags(void *data) +{ + uint32_t flags = 0; + BIT32_SET(flags, GFX_CTX_FLAGS_NONE); + return flags; +} + +static void gfx_ctx_emscripten_set_flags(void *data, uint32_t flags) { (void)data; - return 1UL << GFX_CTX_FLAGS_NONE; } const gfx_ctx_driver_t gfx_ctx_emscripten = { @@ -335,5 +341,6 @@ const gfx_ctx_driver_t gfx_ctx_emscripten = { NULL, "emscripten", gfx_ctx_emscripten_get_flags, + gfx_ctx_emscripten_set_flags, gfx_ctx_emscripten_bind_hw_render }; diff --git a/gfx/drivers_context/gfx_null_ctx.c b/gfx/drivers_context/gfx_null_ctx.c index 055bd6b0ae..589da8d7fa 100644 --- a/gfx/drivers_context/gfx_null_ctx.c +++ b/gfx/drivers_context/gfx_null_ctx.c @@ -134,9 +134,16 @@ static void *gfx_ctx_null_init(void *video_driver) } static uint32_t gfx_ctx_null_get_flags(void *data) +{ + uint32_t flags = 0; + BIT32_SET(flags, GFX_CTX_FLAGS_NONE); + + return flags; +} + +static void gfx_ctx_null_set_flags(void *data, uint32_t flags) { (void)data; - return 1UL << GFX_CTX_FLAGS_NONE; } const gfx_ctx_driver_t gfx_ctx_null = { @@ -165,6 +172,7 @@ const gfx_ctx_driver_t gfx_ctx_null = { gfx_ctx_null_show_mouse, "null", gfx_ctx_null_get_flags, + gfx_ctx_null_set_flags, gfx_ctx_null_bind_hw_render }; diff --git a/gfx/drivers_context/mali_fbdev_ctx.c b/gfx/drivers_context/mali_fbdev_ctx.c index ac47fb7893..7f6d833b73 100644 --- a/gfx/drivers_context/mali_fbdev_ctx.c +++ b/gfx/drivers_context/mali_fbdev_ctx.c @@ -292,9 +292,16 @@ static void gfx_ctx_mali_fbdev_bind_hw_render(void *data, bool enable) } static uint32_t gfx_ctx_mali_fbdev_get_flags(void *data) +{ + uint32_t flags = 0; + BIT32_SET(flags, GFX_CTX_FLAGS_NONE); + + return flags; +} + +static void gfx_ctx_mali_fbdev_set_flags(void *data, uint32_t flags) { (void)data; - return 1UL << GFX_CTX_FLAGS_NONE; } const gfx_ctx_driver_t gfx_ctx_mali_fbdev = { @@ -323,6 +330,7 @@ const gfx_ctx_driver_t gfx_ctx_mali_fbdev = { NULL, "mali-fbdev", gfx_ctx_mali_fbdev_get_flags, + gfx_ctx_mali_fbdev_set_flags, gfx_ctx_mali_fbdev_bind_hw_render }; diff --git a/gfx/drivers_context/opendingux_fbdev_ctx.c b/gfx/drivers_context/opendingux_fbdev_ctx.c index 34ff6c09df..d2a7971b6c 100644 --- a/gfx/drivers_context/opendingux_fbdev_ctx.c +++ b/gfx/drivers_context/opendingux_fbdev_ctx.c @@ -268,9 +268,15 @@ static void gfx_ctx_opendingux_bind_hw_render(void *data, bool enable) } static uint32_t gfx_ctx_opendingux_get_flags(void *data) +{ + uint32_t flags = 0; + BIT32_SET(flags, GFX_CTX_FLAGS_NONE); + return flags; +} + +static void gfx_ctx_opendingux_set_flags(void *data, uint32_t flags) { (void)data; - return 1UL << GFX_CTX_FLAGS_NONE; } const gfx_ctx_driver_t gfx_ctx_opendingux_fbdev = { @@ -299,5 +305,6 @@ const gfx_ctx_driver_t gfx_ctx_opendingux_fbdev = { NULL, "opendingux-fbdev", gfx_ctx_opendingux_get_flags, + gfx_ctx_opendingux_set_flags, gfx_ctx_opendingux_bind_hw_render }; diff --git a/gfx/drivers_context/ps3_ctx.c b/gfx/drivers_context/ps3_ctx.c index 9b65b6d857..33de8136d8 100644 --- a/gfx/drivers_context/ps3_ctx.c +++ b/gfx/drivers_context/ps3_ctx.c @@ -415,9 +415,15 @@ static void gfx_ctx_ps3_get_video_output_next(void *data) } static uint32_t gfx_ctx_ps3_get_flags(void *data) +{ + uint32_t flags = 0; + BIT32_SET(flags, GFX_CTX_FLAGS_NONE); + return flags; +} + +static void gfx_ctx_ps3_set_flags(void *data, uint32_t flags) { (void)data; - return 1UL << GFX_CTX_FLAGS_NONE; } const gfx_ctx_driver_t gfx_ctx_ps3 = { @@ -446,5 +452,6 @@ const gfx_ctx_driver_t gfx_ctx_ps3 = { NULL, "ps3", gfx_ctx_ps3_get_flags, + gfx_ctx_ps3_set_flags }; diff --git a/gfx/drivers_context/sdl_gl_ctx.c b/gfx/drivers_context/sdl_gl_ctx.c index 3ab6f5ada9..c5c9ef890c 100644 --- a/gfx/drivers_context/sdl_gl_ctx.c +++ b/gfx/drivers_context/sdl_gl_ctx.c @@ -401,9 +401,15 @@ static void sdl_ctx_show_mouse(void *data, bool state) } static uint32_t sdl_ctx_get_flags(void *data) +{ + uint32_t flags = 0; + BIT32_SET(flags, GFX_CTX_FLAGS_NONE); + return flags; +} + +static void sdl_ctx_set_flags(void *data, uint32_t flags) { (void)data; - return 1UL << GFX_CTX_FLAGS_NONE; } const gfx_ctx_driver_t gfx_ctx_sdl_gl = @@ -433,5 +439,6 @@ const gfx_ctx_driver_t gfx_ctx_sdl_gl = sdl_ctx_show_mouse, "sdl_gl", sdl_ctx_get_flags, + sdl_ctx_set_flags, NULL /* bind_hw_render */ }; diff --git a/gfx/drivers_context/vc_egl_ctx.c b/gfx/drivers_context/vc_egl_ctx.c index 05d8bd83c1..d8fde21683 100644 --- a/gfx/drivers_context/vc_egl_ctx.c +++ b/gfx/drivers_context/vc_egl_ctx.c @@ -625,9 +625,15 @@ static gfx_ctx_proc_t gfx_ctx_vc_get_proc_address(const char *symbol) } static uint32_t gfx_ctx_vc_get_flags(void *data) +{ + uint32_t flags = 0; + BIT32_SET(flags, GFX_CTX_FLAGS_NONE); + return flags; +} + +static void gfx_ctx_vc_set_flags(void *data, uint32_t flags) { (void)data; - return 1UL << GFX_CTX_FLAGS_NONE; } const gfx_ctx_driver_t gfx_ctx_videocore = { @@ -656,5 +662,6 @@ const gfx_ctx_driver_t gfx_ctx_videocore = { NULL, "videocore", gfx_ctx_vc_get_flags, + gfx_ctx_vc_set_flags, gfx_ctx_vc_bind_hw_render }; diff --git a/gfx/drivers_context/vivante_fbdev_ctx.c b/gfx/drivers_context/vivante_fbdev_ctx.c index 5c6ac27acc..4a554fc33b 100644 --- a/gfx/drivers_context/vivante_fbdev_ctx.c +++ b/gfx/drivers_context/vivante_fbdev_ctx.c @@ -262,9 +262,15 @@ static void gfx_ctx_vivante_swap_buffers(void *data) } static uint32_t gfx_ctx_vivante_get_flags(void *data) +{ + uint32_t flags = 0; + BIT32_SET(flags, GFX_CTX_FLAGS_NONE); + return flags; +} + +static void gfx_ctx_vivante_set_flags(void *data, uint32_t flags) { (void)data; - return 1UL << GFX_CTX_FLAGS_NONE; } const gfx_ctx_driver_t gfx_ctx_vivante_fbdev = { @@ -293,5 +299,6 @@ const gfx_ctx_driver_t gfx_ctx_vivante_fbdev = { NULL, "vivante-fbdev", gfx_ctx_vivante_get_flags, + gfx_ctx_vivante_set_flags, gfx_ctx_vivante_bind_hw_render }; diff --git a/gfx/drivers_context/wayland_ctx.c b/gfx/drivers_context/wayland_ctx.c index 6efddac860..f7fedd1f22 100644 --- a/gfx/drivers_context/wayland_ctx.c +++ b/gfx/drivers_context/wayland_ctx.c @@ -66,6 +66,7 @@ typedef struct gfx_ctx_wayland_data struct wl_keyboard *wl_keyboard; struct wl_pointer *wl_pointer; unsigned swap_interval; + bool core_hw_context_enable; unsigned buffer_scale; @@ -1140,10 +1141,24 @@ static void gfx_ctx_wl_bind_hw_render(void *data, bool enable) static uint32_t gfx_ctx_wl_get_flags(void *data) { + uint32_t flags = 0; gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data; - if ((wl->egl.major * 1000 + wl->egl.minor) >= 3001) - return (1UL << GFX_CTX_FLAGS_GL_CORE_CONTEXT); - return 1UL << GFX_CTX_FLAGS_NONE; + + if (wl->core_hw_context_enable) + { + BIT32_SET(flags, GFX_CTX_FLAGS_GL_CORE_CONTEXT); + } + else + BIT32_SET(flags, GFX_CTX_FLAGS_NONE); + + return flags; +} + +static void gfx_ctx_wl_set_flags(void *data, uint32_t flags) +{ + gfx_ctx_wayland_data_t *wl = (gfx_ctx_wayland_data_t*)data; + if (BIT32_GET(flags, GFX_CTX_FLAGS_GL_CORE_CONTEXT)) + wl->core_hw_context_enable = true; } const gfx_ctx_driver_t gfx_ctx_wayland = { @@ -1172,6 +1187,7 @@ const gfx_ctx_driver_t gfx_ctx_wayland = { NULL, "wayland", gfx_ctx_wl_get_flags, + gfx_ctx_wl_set_flags, gfx_ctx_wl_bind_hw_render, #ifdef HAVE_VULKAN gfx_ctx_wl_get_context_data diff --git a/gfx/drivers_context/wgl_ctx.cpp b/gfx/drivers_context/wgl_ctx.cpp index f5a5c20572..4fb452c70d 100644 --- a/gfx/drivers_context/wgl_ctx.cpp +++ b/gfx/drivers_context/wgl_ctx.cpp @@ -70,6 +70,7 @@ static bool g_use_hw_ctx; static HGLRC g_hrc; static HGLRC g_hw_hrc; static HDC g_hdc; +static bool g_core_hw_context_enable; static unsigned g_major; static unsigned g_minor; @@ -306,7 +307,7 @@ static void *gfx_ctx_wgl_init(void *video_driver) if (g_inited) return NULL; - + win32_window_reset(); win32_monitor_init(); @@ -353,12 +354,14 @@ static void gfx_ctx_wgl_destroy(void *data) if (g_restore_desktop) { win32_monitor_get_info(); - g_restore_desktop = false; + g_restore_desktop = false; } - g_inited = false; - g_major = g_minor = 0; - p_swap_interval = NULL; + g_core_hw_context_enable = false; + g_inited = false; + g_major = 0; + g_minor = 0; + p_swap_interval = NULL; } static bool gfx_ctx_wgl_set_video_mode(void *data, @@ -450,10 +453,23 @@ static void gfx_ctx_wgl_bind_hw_render(void *data, bool enable) static uint32_t gfx_ctx_wgl_get_flags(void *data) { - (void)data; - if ((g_major * 1000 + g_minor) >= 3001) - return (1UL << GFX_CTX_FLAGS_GL_CORE_CONTEXT); - return (1UL << GFX_CTX_FLAGS_NONE); + uint32_t flags = 0; + if (g_core_hw_context_enable) + { + BIT32_SET(flags, GFX_CTX_FLAGS_GL_CORE_CONTEXT); + } + else + { + BIT32_SET(flags, GFX_CTX_FLAGS_NONE); + } + return falgs; +} + +static void gfx_ctx_wgl_set_flags(void *data, uint32_t flags) +{ + uint32_t flags = 0; + if (BIT32_GET(flags, GFX_CTX_FLAGS_GL_CORE_CONTEXT)) + g_core_hw_context_enable = true; } const gfx_ctx_driver_t gfx_ctx_wgl = { @@ -482,6 +498,7 @@ const gfx_ctx_driver_t gfx_ctx_wgl = { gfx_ctx_wgl_show_mouse, "wgl", gfx_ctx_wgl_get_flags, + gfx_ctx_wgl_set_flags, gfx_ctx_wgl_bind_hw_render }; diff --git a/gfx/drivers_context/x_ctx.c b/gfx/drivers_context/x_ctx.c index 8dfe02d9cc..d26f6967d8 100644 --- a/gfx/drivers_context/x_ctx.c +++ b/gfx/drivers_context/x_ctx.c @@ -44,6 +44,7 @@ typedef struct gfx_ctx_x_data bool g_debug; bool g_should_reset_mode; bool g_is_double; + bool core_hw_context_enable; #ifdef HAVE_OPENGL GLXWindow g_glx_win; @@ -888,10 +889,24 @@ static void *gfx_ctx_x_get_context_data(void *data) static uint32_t gfx_ctx_x_get_flags(void *data) { + uint32_t flags = 0; gfx_ctx_x_data_t *x = (gfx_ctx_x_data_t*)data; - if (x->g_core_es_core) - return (1UL << GFX_CTX_FLAGS_GL_CORE_CONTEXT); - return 1UL << GFX_CTX_FLAGS_NONE; + if (x->core_hw_context_enable) + { + BIT32_SET(flags, GFX_CTX_FLAGS_GL_CORE_CONTEXT); + } + else + { + BIT32_SET(flags, GFX_CTX_FLAGS_NONE); + } + return flags; +} + +static void gfx_ctx_x_set_flags(void *data, uint32_t flags) +{ + gfx_ctx_x_data_t *x = (gfx_ctx_x_data_t*)data; + if (BIT32_GET(flags, GFX_CTX_FLAGS_GL_CORE_CONTEXT)) + x->core_hw_context_enable = true; } const gfx_ctx_driver_t gfx_ctx_x = { @@ -920,10 +935,11 @@ const gfx_ctx_driver_t gfx_ctx_x = { gfx_ctx_x_show_mouse, "x", gfx_ctx_x_get_flags, + gfx_ctx_x_set_flags, gfx_ctx_x_bind_hw_render, #ifdef HAVE_VULKAN - gfx_ctx_x_get_context_data, + gfx_ctx_x_get_context_data #else NULL #endif diff --git a/gfx/drivers_context/xegl_ctx.c b/gfx/drivers_context/xegl_ctx.c index bbe05755c3..21aa905c95 100644 --- a/gfx/drivers_context/xegl_ctx.c +++ b/gfx/drivers_context/xegl_ctx.c @@ -576,11 +576,14 @@ static gfx_ctx_proc_t gfx_ctx_xegl_get_proc_address(const char *symbol) static uint32_t gfx_ctx_xegl_get_flags(void *data) { - xegl_ctx_data_t *xegl = (xegl_ctx_data_t*)data; + uint32_t flags = 0; + BIT32_SET(flags, GFX_CTX_FLAGS_NONE); + return flags; +} - if ((xegl->egl.major * 1000 + xegl->egl.minor) >= 3001) - return (1UL << GFX_CTX_FLAGS_GL_CORE_CONTEXT); - return 1UL << GFX_CTX_FLAGS_NONE; +static void gfx_ctx_xegl_set_flags(void *data, uint32_t flags) +{ + (void)data; } const gfx_ctx_driver_t gfx_ctx_x_egl = @@ -610,5 +613,6 @@ const gfx_ctx_driver_t gfx_ctx_x_egl = gfx_ctx_xegl_show_mouse, "x-egl", gfx_ctx_xegl_get_flags, + gfx_ctx_xegl_set_flags, gfx_ctx_xegl_bind_hw_render }; diff --git a/gfx/video_context_driver.h b/gfx/video_context_driver.h index d6cdfe7544..6c5538680f 100644 --- a/gfx/video_context_driver.h +++ b/gfx/video_context_driver.h @@ -191,6 +191,8 @@ typedef struct gfx_ctx_driver uint32_t (*get_flags)(void *data); + void (*set_flags)(void *data, uint32_t flags); + /* Optional. Binds HW-render offscreen context. */ void (*bind_hw_render)(void *data, bool enable); From 10b0fca258da09665705abe2a5159ca44b366aa4 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 5 May 2016 17:37:24 +0200 Subject: [PATCH 171/498] Add GFX_CTL_SET_FLAGS --- gfx/video_context_driver.c | 10 ++++++++++ gfx/video_context_driver.h | 1 + 2 files changed, 11 insertions(+) diff --git a/gfx/video_context_driver.c b/gfx/video_context_driver.c index c724aba461..65f700efc1 100644 --- a/gfx/video_context_driver.c +++ b/gfx/video_context_driver.c @@ -487,6 +487,16 @@ bool gfx_ctx_ctl(enum gfx_ctx_ctl_state state, void *data) flags->flags = current_video_context->get_flags(video_context_data); } break; + case GFX_CTL_SET_FLAGS: + { + gfx_ctx_flags_t *flags = (gfx_ctx_flags_t*)data; + if (!flags) + return false; + if (!current_video_context || !current_video_context->set_flags) + return false; + current_video_context->set_flags(video_context_data, flags->flags); + } + break; case GFX_CTL_NONE: default: break; diff --git a/gfx/video_context_driver.h b/gfx/video_context_driver.h index 6c5538680f..882bb57b65 100644 --- a/gfx/video_context_driver.h +++ b/gfx/video_context_driver.h @@ -84,6 +84,7 @@ enum gfx_ctx_ctl_state GFX_CTL_PROC_ADDRESS_GET, GFX_CTL_TRANSLATE_ASPECT, GFX_CTL_GET_FLAGS, + GFX_CTL_SET_FLAGS, GFX_CTL_GET_METRICS, GFX_CTL_INPUT_DRIVER, GFX_CTL_SUPPRESS_SCREENSAVER, From c04122d385cdc9de6a4c0071e5617be09164a776 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 5 May 2016 17:40:38 +0200 Subject: [PATCH 172/498] Set context driver's set_flags function when core GL context is requested, and query the core GL context set bit when loading a Cg shader --- dynamic.c | 12 ++++++++++-- gfx/video_shader_driver.c | 6 +----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/dynamic.c b/dynamic.c index e7c001ec4a..739c3500c1 100644 --- a/dynamic.c +++ b/dynamic.c @@ -39,6 +39,7 @@ #include "libretro_version_1.h" #include "performance.h" #include "system.h" +#include "gfx/video_context_driver.h" #include "cores/internal_cores.h" #include "frontend/frontend_driver.h" @@ -970,8 +971,15 @@ bool rarch_environment_cb(unsigned cmd, void *data) break; case RETRO_HW_CONTEXT_OPENGL_CORE: - RARCH_LOG("Requesting core OpenGL context (%u.%u).\n", - cb->version_major, cb->version_minor); + { + gfx_ctx_flags_t flags; + BIT32_SET(flags.flags, GFX_CTX_FLAGS_GL_CORE_CONTEXT); + + gfx_ctx_ctl(GFX_CTL_SET_FLAGS, &flags); + + RARCH_LOG("Requesting core OpenGL context (%u.%u).\n", + cb->version_major, cb->version_minor); + } break; #endif diff --git a/gfx/video_shader_driver.c b/gfx/video_shader_driver.c index 0c2091486e..d44f60a5bd 100644 --- a/gfx/video_shader_driver.c +++ b/gfx/video_shader_driver.c @@ -43,12 +43,9 @@ static const shader_backend_t *video_shader_set_backend(enum rarch_shader_type t #ifdef HAVE_CG gfx_ctx_flags_t flags; - struct retro_hw_render_callback *hwr = NULL; gfx_ctx_ctl(GFX_CTL_GET_FLAGS, &flags); - video_driver_ctl(RARCH_DISPLAY_CTL_HW_CONTEXT_GET, &hwr); -#if 0 - if ((flags.flags && (1UL << GFX_CTX_FLAGS_GL_CORE_CONTEXT)) && hwr && hwr->context_type != RETRO_HW_CONTEXT_NONE) + if (flags.flags && (1UL << GFX_CTX_FLAGS_GL_CORE_CONTEXT)) { RARCH_ERR("[Shader driver]: Cg cannot be used with core GL context. Trying to fall back to GLSL...\n"); #ifdef HAVE_GLSL @@ -56,7 +53,6 @@ static const shader_backend_t *video_shader_set_backend(enum rarch_shader_type t #endif } else -#endif { RARCH_LOG("[Shader driver]: Using Cg shader backend.\n"); return &gl_cg_backend; From 8966f46d363040deb404a2916d010e8ae1f102b7 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 5 May 2016 17:44:10 +0200 Subject: [PATCH 173/498] video_shader_set_backend - cleanup --- gfx/video_shader_driver.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/gfx/video_shader_driver.c b/gfx/video_shader_driver.c index d44f60a5bd..4544c14350 100644 --- a/gfx/video_shader_driver.c +++ b/gfx/video_shader_driver.c @@ -48,9 +48,7 @@ static const shader_backend_t *video_shader_set_backend(enum rarch_shader_type t if (flags.flags && (1UL << GFX_CTX_FLAGS_GL_CORE_CONTEXT)) { RARCH_ERR("[Shader driver]: Cg cannot be used with core GL context. Trying to fall back to GLSL...\n"); -#ifdef HAVE_GLSL - return &gl_glsl_backend; -#endif + return video_shader_set_backend(RARCH_SHADER_GLSL); } else { From a7588292bf8c2b8d839a827ff808d63a36ee8544 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 5 May 2016 17:44:43 +0200 Subject: [PATCH 174/498] Another cleanup --- gfx/video_shader_driver.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/gfx/video_shader_driver.c b/gfx/video_shader_driver.c index 4544c14350..a0cb4f57a1 100644 --- a/gfx/video_shader_driver.c +++ b/gfx/video_shader_driver.c @@ -50,11 +50,9 @@ static const shader_backend_t *video_shader_set_backend(enum rarch_shader_type t RARCH_ERR("[Shader driver]: Cg cannot be used with core GL context. Trying to fall back to GLSL...\n"); return video_shader_set_backend(RARCH_SHADER_GLSL); } - else - { - RARCH_LOG("[Shader driver]: Using Cg shader backend.\n"); - return &gl_cg_backend; - } + + RARCH_LOG("[Shader driver]: Using Cg shader backend.\n"); + return &gl_cg_backend; #else break; #endif From 18e94a5365b2377517c39d8a6bb08b4affe44f22 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 5 May 2016 17:46:04 +0200 Subject: [PATCH 175/498] (task_queue.c) Remove unused variable --- libretro-common/queues/task_queue.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libretro-common/queues/task_queue.c b/libretro-common/queues/task_queue.c index 3c4940a24a..f7406f4865 100644 --- a/libretro-common/queues/task_queue.c +++ b/libretro-common/queues/task_queue.c @@ -322,7 +322,6 @@ static void threaded_worker(void *userdata) for (;;) { retro_task_t *task = NULL; - retro_task_t *next = NULL; if (!worker_continue) break; /* should we keep running until all tasks finished? */ From 493ad4dfb8ed6251756dadef7f08590c0a47c996 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 5 May 2016 17:50:26 +0200 Subject: [PATCH 176/498] (WGL) Typo buildfix --- gfx/drivers_context/wgl_ctx.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfx/drivers_context/wgl_ctx.cpp b/gfx/drivers_context/wgl_ctx.cpp index 4fb452c70d..dd014edcfd 100644 --- a/gfx/drivers_context/wgl_ctx.cpp +++ b/gfx/drivers_context/wgl_ctx.cpp @@ -462,7 +462,7 @@ static uint32_t gfx_ctx_wgl_get_flags(void *data) { BIT32_SET(flags, GFX_CTX_FLAGS_NONE); } - return falgs; + return flags; } static void gfx_ctx_wgl_set_flags(void *data, uint32_t flags) From 2314733af71f843e923a7b7de0342d76b26331a5 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 5 May 2016 17:52:30 +0200 Subject: [PATCH 177/498] Cleanup --- gfx/video_shader_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfx/video_shader_driver.c b/gfx/video_shader_driver.c index a0cb4f57a1..a0b91cf0e6 100644 --- a/gfx/video_shader_driver.c +++ b/gfx/video_shader_driver.c @@ -45,7 +45,7 @@ static const shader_backend_t *video_shader_set_backend(enum rarch_shader_type t gfx_ctx_flags_t flags; gfx_ctx_ctl(GFX_CTL_GET_FLAGS, &flags); - if (flags.flags && (1UL << GFX_CTX_FLAGS_GL_CORE_CONTEXT)) + if (BIT32_GET(flags.flags, GFX_CTX_FLAGS_GL_CORE_CONTEXT)) { RARCH_ERR("[Shader driver]: Cg cannot be used with core GL context. Trying to fall back to GLSL...\n"); return video_shader_set_backend(RARCH_SHADER_GLSL); From 78cbf97e702937c4867ba9d7d8635c159fc1eef4 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 5 May 2016 17:58:58 +0200 Subject: [PATCH 178/498] Another fix --- gfx/drivers_context/wgl_ctx.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/gfx/drivers_context/wgl_ctx.cpp b/gfx/drivers_context/wgl_ctx.cpp index dd014edcfd..b7f24019f5 100644 --- a/gfx/drivers_context/wgl_ctx.cpp +++ b/gfx/drivers_context/wgl_ctx.cpp @@ -467,7 +467,6 @@ static uint32_t gfx_ctx_wgl_get_flags(void *data) static void gfx_ctx_wgl_set_flags(void *data, uint32_t flags) { - uint32_t flags = 0; if (BIT32_GET(flags, GFX_CTX_FLAGS_GL_CORE_CONTEXT)) g_core_hw_context_enable = true; } From 8a77ac1f041ab6cd2254d13725ac50c2807295cd Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 5 May 2016 18:23:18 +0200 Subject: [PATCH 179/498] (GX) Should not be used for Salamander --- frontend/drivers/platform_gx.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/frontend/drivers/platform_gx.c b/frontend/drivers/platform_gx.c index 5b71fb10bd..6e5d43edee 100644 --- a/frontend/drivers/platform_gx.c +++ b/frontend/drivers/platform_gx.c @@ -171,7 +171,6 @@ static void frontend_gx_get_environment_settings( logger_init(); #elif defined(HAVE_FILE_LOGGER) retro_main_log_file_init("/retroarch-log.txt"); -#endif #endif /* This situation can happen on some loaders so we really need some @@ -191,6 +190,8 @@ static void frontend_gx_get_environment_settings( args->libretro_path = NULL; } } +#endif + #ifdef HW_DOL chdir("carda:/retroarch"); #endif From 8be7fd5f0a8d2074eeb2694abbd6742788d415f8 Mon Sep 17 00:00:00 2001 From: Andre Leiradella Date: Thu, 5 May 2016 15:32:36 -0300 Subject: [PATCH 180/498] http tasks can now be cancelled --- libretro-common/include/queues/task_queue.h | 11 +++++-- libretro-common/queues/task_queue.c | 35 +++++++++++++++++++++ tasks/task_http.c | 17 +++++----- tasks/tasks_internal.h | 2 +- 4 files changed, 55 insertions(+), 10 deletions(-) diff --git a/libretro-common/include/queues/task_queue.h b/libretro-common/include/queues/task_queue.h index 7fc9e2b039..b72ce91192 100644 --- a/libretro-common/include/queues/task_queue.h +++ b/libretro-common/include/queues/task_queue.h @@ -82,8 +82,13 @@ enum task_queue_ctl_state TASK_QUEUE_CTL_UNSET_THREADED, - TASK_QUEUE_CTL_IS_THREADED -}; + TASK_QUEUE_CTL_IS_THREADED, + + /** + * Signals a task to end without waiting for + * it to complete. */ + TASK_QUEUE_CTL_CANCEL, + }; typedef struct retro_task retro_task_t; typedef void (*retro_task_callback_t)(void *task_data, @@ -148,6 +153,8 @@ void task_queue_push_progress(retro_task_t *task); bool task_queue_ctl(enum task_queue_ctl_state state, void *data); +void task_queue_cancel_task(void *task); + RETRO_END_DECLS #endif diff --git a/libretro-common/queues/task_queue.c b/libretro-common/queues/task_queue.c index f7406f4865..be254981b4 100644 --- a/libretro-common/queues/task_queue.c +++ b/libretro-common/queues/task_queue.c @@ -39,6 +39,7 @@ typedef struct struct retro_task_impl { void (*push_running)(retro_task_t *); + void (*cancel)(void *); void (*reset)(void); void (*wait)(void); void (*gather)(void); @@ -167,6 +168,12 @@ static void retro_task_regular_push_running(retro_task_t *task) task_queue_put(&tasks_running, task); } +static void retro_task_regular_cancel(void *task) +{ + retro_task_t *t = task; + t->cancelled = true; +} + static void retro_task_regular_gather(void) { retro_task_t *task = NULL; @@ -232,6 +239,7 @@ static bool retro_task_regular_find(retro_task_finder_t func, void *user_data) static struct retro_task_impl impl_regular = { retro_task_regular_push_running, + retro_task_regular_cancel, retro_task_regular_reset, retro_task_regular_wait, retro_task_regular_gather, @@ -255,6 +263,24 @@ static void retro_task_threaded_push_running(retro_task_t *task) slock_unlock(running_lock); } +static void retro_task_threaded_cancel(void *task) +{ + retro_task_t *t; + + slock_lock(running_lock); + + for (t = tasks_running.front; t; t = t->next) + { + if (t == task) + { + t->cancelled = true; + break; + } + } + + slock_unlock(running_lock); +} + static void retro_task_threaded_gather(void) { retro_task_t *task = NULL; @@ -399,6 +425,7 @@ static void retro_task_threaded_deinit(void) static struct retro_task_impl impl_threaded = { retro_task_threaded_push_running, + retro_task_threaded_cancel, retro_task_threaded_reset, retro_task_threaded_wait, retro_task_threaded_gather, @@ -484,6 +511,9 @@ bool task_queue_ctl(enum task_queue_ctl_state state, void *data) case TASK_QUEUE_CTL_WAIT: impl_current->wait(); break; + case TASK_QUEUE_CTL_CANCEL: + impl_current->cancel(data); + break; case TASK_QUEUE_CTL_NONE: default: break; @@ -491,3 +521,8 @@ bool task_queue_ctl(enum task_queue_ctl_state state, void *data) return true; } + +void task_queue_cancel_task(void *task) +{ + task_queue_ctl(TASK_QUEUE_CTL_CANCEL, task); +} diff --git a/tasks/task_http.c b/tasks/task_http.c index b77c8512d6..36ff154c8f 100644 --- a/tasks/task_http.c +++ b/tasks/task_http.c @@ -127,6 +127,9 @@ static void rarch_task_http_transfer_handler(retro_task_t *task) http_handle_t *http = (http_handle_t*)task->state; http_transfer_data_t *data; + if (task->cancelled) + goto task_finished; + switch (http->status) { case HTTP_STATUS_CONNECTION_TRANSFER_PARSE: @@ -148,7 +151,7 @@ static void rarch_task_http_transfer_handler(retro_task_t *task) break; } - if (task->cancelled || http->error) + if (http->error) goto task_finished; return; @@ -251,7 +254,7 @@ static bool rarch_task_http_retriever(retro_task_t *task, void *user_data) return false; } -bool rarch_task_push_http_transfer(const char *url, const char *type, +void *rarch_task_push_http_transfer(const char *url, const char *type, retro_task_callback_t cb, void *user_data) { char tmp[PATH_MAX_LENGTH]; @@ -261,7 +264,7 @@ bool rarch_task_push_http_transfer(const char *url, const char *type, http_handle_t *http = NULL; if (string_is_empty(url)) - return false; + return NULL; find_data.func = rarch_task_http_finder; find_data.userdata = (void*)url; @@ -270,13 +273,13 @@ bool rarch_task_push_http_transfer(const char *url, const char *type, if (task_queue_ctl(TASK_QUEUE_CTL_FIND, &find_data)) { RARCH_LOG("[http] '%s'' is already being downloaded.\n", url); - return false; + return NULL; } conn = net_http_connection_new(url); if (!conn) - return false; + return NULL; http = (http_handle_t*)calloc(1, sizeof(*http)); @@ -310,7 +313,7 @@ bool rarch_task_push_http_transfer(const char *url, const char *type, task_queue_ctl(TASK_QUEUE_CTL_PUSH, t); - return true; + return t; error: if (conn) @@ -320,7 +323,7 @@ error: if (http) free(http); - return false; + return NULL; } http_transfer_info_t *http_task_get_transfer_list() diff --git a/tasks/tasks_internal.h b/tasks/tasks_internal.h index 5bcdc230c0..7f477b4499 100644 --- a/tasks/tasks_internal.h +++ b/tasks/tasks_internal.h @@ -41,7 +41,7 @@ typedef struct http_transfer_info struct http_transfer_info *next; } http_transfer_info_t; -bool rarch_task_push_http_transfer(const char *url, const char *type, +void *rarch_task_push_http_transfer(const char *url, const char *type, retro_task_callback_t cb, void *userdata); http_transfer_info_t *http_task_get_transfer_list(); From b38e234d2ef33efb68f5c8917f15654d7c0c0c51 Mon Sep 17 00:00:00 2001 From: Andre Leiradella Date: Thu, 5 May 2016 16:22:35 -0300 Subject: [PATCH 181/498] made find_last_slash public --- libretro-common/file/file_path.c | 2 +- libretro-common/include/file/file_path.h | 10 ++++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/libretro-common/file/file_path.c b/libretro-common/file/file_path.c index cc16645d02..85131706b4 100644 --- a/libretro-common/file/file_path.c +++ b/libretro-common/file/file_path.c @@ -243,7 +243,7 @@ void fill_pathname_noext(char *out_path, const char *in_path, retro_assert(strlcat(out_path, replace, size) < size); } -static char *find_last_slash(const char *str) +char *find_last_slash(const char *str) { const char *slash = strrchr(str, '/'); #ifdef _WIN32 diff --git a/libretro-common/include/file/file_path.h b/libretro-common/include/file/file_path.h index 0ac5ffe89b..527cdeebf7 100644 --- a/libretro-common/include/file/file_path.h +++ b/libretro-common/include/file/file_path.h @@ -211,6 +211,16 @@ void fill_dated_filename(char *out_filename, void fill_pathname_noext(char *out_path, const char *in_path, const char *replace, size_t size); +/** + * find_last_slash: + * @str : input path + * + * Gets a pointer to the last slash in the input path. + * + * Returns: a pointer to the last slash in the input path. + **/ +char *find_last_slash(const char *str); + /** * fill_pathname_dir: * @in_dir : input directory path From ccb224043bf5b0731e25dcfd3be50a3de1282eef Mon Sep 17 00:00:00 2001 From: Torsten Paul Date: Fri, 6 May 2016 00:16:56 +0200 Subject: [PATCH 182/498] Initialize window name at window creation time (fixes #1521). The protocol error reported in #1521 is caused by two different issues. First xdg-screensaver fails to parse decimal values for the window id (https://bugzilla.redhat.com/show_bug.cgi?id=1274931). Using the hex notation fixes this part. Second, the script reads the WM_NAME property from the window which is not yet available at this time. Calling x11_update_window_title() early ensures the property is set when xdg-screensaver is run. --- gfx/common/x11_common.c | 5 ++--- gfx/drivers_context/x_ctx.c | 1 + gfx/drivers_context/xegl_ctx.c | 1 + 3 files changed, 4 insertions(+), 3 deletions(-) diff --git a/gfx/common/x11_common.c b/gfx/common/x11_common.c index 5a957e8d5b..3759373cd4 100644 --- a/gfx/common/x11_common.c +++ b/gfx/common/x11_common.c @@ -152,7 +152,7 @@ void x11_suspend_screensaver(Window wnd) RARCH_LOG("Suspending screensaver (X11).\n"); - snprintf(cmd, sizeof(cmd), "xdg-screensaver suspend %d", (int)wnd); + snprintf(cmd, sizeof(cmd), "xdg-screensaver suspend 0x%x", (int)wnd); ret = system(cmd); if (ret == -1) @@ -551,8 +551,7 @@ void x11_update_window_title(void *data) char buf_fps[128] = {0}; settings_t *settings = config_get_ptr(); - if (video_monitor_get_fps(buf, sizeof(buf), - buf_fps, sizeof(buf_fps))) + if (video_monitor_get_fps(buf, sizeof(buf), NULL, 0)) XStoreName(g_x11_dpy, g_x11_win, buf); if (settings->fps_show) runloop_msg_queue_push(buf_fps, 1, 1, false); diff --git a/gfx/drivers_context/x_ctx.c b/gfx/drivers_context/x_ctx.c index d26f6967d8..b86f1d8b95 100644 --- a/gfx/drivers_context/x_ctx.c +++ b/gfx/drivers_context/x_ctx.c @@ -533,6 +533,7 @@ static bool gfx_ctx_x_set_video_mode(void *data, } x11_set_window_attr(g_x11_dpy, g_x11_win); + x11_update_window_title(NULL); if (fullscreen) x11_show_mouse(g_x11_dpy, g_x11_win, false); diff --git a/gfx/drivers_context/xegl_ctx.c b/gfx/drivers_context/xegl_ctx.c index 21aa905c95..9bacb5ce5d 100644 --- a/gfx/drivers_context/xegl_ctx.c +++ b/gfx/drivers_context/xegl_ctx.c @@ -352,6 +352,7 @@ static bool gfx_ctx_xegl_set_video_mode(void *data, goto error; x11_set_window_attr(g_x11_dpy, g_x11_win); + x11_update_window_title(NULL); if (fullscreen) x11_show_mouse(g_x11_dpy, g_x11_win, false); From 72bc5e134a8e3b555562f8e405b3185b4a0199a6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 6 May 2016 04:50:02 +0200 Subject: [PATCH 183/498] Cleanup input_config_autoconfigure_joypad --- input/input_autodetect.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/input/input_autodetect.c b/input/input_autodetect.c index 04bf746b6a..cc9b27fc58 100644 --- a/input/input_autodetect.c +++ b/input/input_autodetect.c @@ -311,32 +311,32 @@ static bool input_config_autoconfigure_joypad_init(autoconfig_params_t *params) bool input_config_autoconfigure_joypad(autoconfig_params_t *params) { - bool ret = false; + char msg[PATH_MAX_LENGTH]; if (!input_config_autoconfigure_joypad_init(params)) - return ret; + goto error; if (!*params->name) - return ret; - - if (!ret) - ret = input_autoconfigure_joypad_from_conf_dir(params); + goto error; + if (input_autoconfigure_joypad_from_conf_dir(params)) + goto success; #if defined(HAVE_BUILTIN_AUTOCONFIG) - if (!ret) - ret = input_autoconfigure_joypad_from_conf_internal(params); + if (input_autoconfigure_joypad_from_conf_internal(params)) + goto success; #endif - if (!ret) - { - char msg[PATH_MAX_LENGTH]; - RARCH_LOG("Autodetect: no profiles found for %s (%d/%d)\n", - params->name, params->vid, params->pid); - snprintf(msg, sizeof(msg), "%s (%ld/%ld) not configured", - params->name, (long)params->vid, (long)params->pid); - runloop_msg_queue_push(msg, 0, 60, false); - } - return ret; + RARCH_LOG("Autodetect: no profiles found for %s (%d/%d)\n", + params->name, params->vid, params->pid); + snprintf(msg, sizeof(msg), "%s (%ld/%ld) not configured", + params->name, (long)params->vid, (long)params->pid); + runloop_msg_queue_push(msg, 0, 60, false); + +error: + return false; + +success: + return true; } const struct retro_keybind *input_get_auto_bind(unsigned port, unsigned id) From cce9190cb21c418331e21651512580c8a226a24d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 6 May 2016 04:51:00 +0200 Subject: [PATCH 184/498] More cleanups --- input/input_autodetect.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/input/input_autodetect.c b/input/input_autodetect.c index cc9b27fc58..846aa0bc85 100644 --- a/input/input_autodetect.c +++ b/input/input_autodetect.c @@ -320,10 +320,10 @@ bool input_config_autoconfigure_joypad(autoconfig_params_t *params) goto error; if (input_autoconfigure_joypad_from_conf_dir(params)) - goto success; + return true; #if defined(HAVE_BUILTIN_AUTOCONFIG) if (input_autoconfigure_joypad_from_conf_internal(params)) - goto success; + return true; #endif RARCH_LOG("Autodetect: no profiles found for %s (%d/%d)\n", @@ -334,9 +334,6 @@ bool input_config_autoconfigure_joypad(autoconfig_params_t *params) error: return false; - -success: - return true; } const struct retro_keybind *input_get_auto_bind(unsigned port, unsigned id) From b91ad3a70ec4e4d3f2bd05c8f65e2f629a228172 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 6 May 2016 05:08:42 +0200 Subject: [PATCH 185/498] (libretro-common) Update glsm --- libretro-common/glsm/glsm.c | 29 ++++++++++++++++++++++++++ libretro-common/include/glsm/glsm.h | 2 ++ libretro-common/include/glsm/glsmsym.h | 14 +++++++++++++ 3 files changed, 45 insertions(+) diff --git a/libretro-common/glsm/glsm.c b/libretro-common/glsm/glsm.c index 9ed00c867e..303af81ad3 100644 --- a/libretro-common/glsm/glsm.c +++ b/libretro-common/glsm/glsm.c @@ -848,6 +848,30 @@ void rglEnableVertexAttribArray(GLuint index) glEnableVertexAttribArray(index); } +void rglVertexAttribIPointer( + GLuint index, + GLint size, + GLenum type, + GLsizei stride, + const GLvoid * pointer) +{ +#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) && defined(HAVE_OPENGLES3) + glVertexAttribIPointer(index, size, type, stride, pointer); +#endif +} + +void rglVertexAttribLPointer( + GLuint index, + GLint size, + GLenum type, + GLsizei stride, + const GLvoid * pointer) +{ +#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) && defined(HAVE_OPENGLES3) + glVertexAttribLPointer(index, size, type, stride, pointer); +#endif +} + /* * Category: Generic vertex attributes * @@ -1484,6 +1508,11 @@ static bool glsm_state_ctx_init(void *data) return true; } +GLuint glsm_get_current_framebuffer(void) +{ + return hw_render.get_current_framebuffer(); +} + bool glsm_ctl(enum glsm_state_ctl state, void *data) { static bool imm_vbo_enable = false; diff --git a/libretro-common/include/glsm/glsm.h b/libretro-common/include/glsm/glsm.h index 9c5ab29181..c6c9ba2a07 100644 --- a/libretro-common/include/glsm/glsm.h +++ b/libretro-common/include/glsm/glsm.h @@ -145,6 +145,8 @@ typedef struct glsm_ctx_params unsigned minor; } glsm_ctx_params_t; +GLuint glsm_get_current_framebuffer(void); + bool glsm_ctl(enum glsm_state_ctl state, void *data); RETRO_END_DECLS diff --git a/libretro-common/include/glsm/glsmsym.h b/libretro-common/include/glsm/glsmsym.h index 16d56006d8..0560d408e6 100644 --- a/libretro-common/include/glsm/glsmsym.h +++ b/libretro-common/include/glsm/glsmsym.h @@ -72,6 +72,8 @@ RETRO_BEGIN_DECLS #define glEnableVertexAttribArray rglEnableVertexAttribArray #define glDisableVertexAttribArray rglDisableVertexAttribArray #define glVertexAttribPointer rglVertexAttribPointer +#define glVertexAttribIPointer rglVertexAttribIPointer +#define glVertexAttribLPointer rglVertexAttribLPointer #define glGetUniformLocation rglGetUniformLocation #define glGenBuffers rglGenBuffers #define glDisable(T) rglDisable(S##T) @@ -260,6 +262,18 @@ void rglCopyImageSubData( GLuint srcName, GLsizei srcWidth, GLsizei srcHeight, GLsizei srcDepth); +void rglVertexAttribIPointer( + GLuint index, + GLint size, + GLenum type, + GLsizei stride, + const GLvoid * pointer); +void rglVertexAttribLPointer( + GLuint index, + GLint size, + GLenum type, + GLsizei stride, + const GLvoid * pointer); RETRO_END_DECLS From 4ec6cb47ec68d41dd242a3e045269260c27eb624 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 6 May 2016 05:16:15 +0200 Subject: [PATCH 186/498] Use BIT32_SET --- input/input_overlay.c | 8 ++++---- menu/menu_input.c | 21 +++++++++++---------- 2 files changed, 15 insertions(+), 14 deletions(-) diff --git a/input/input_overlay.c b/input/input_overlay.c index a4100bdbbf..96baf89304 100644 --- a/input/input_overlay.c +++ b/input/input_overlay.c @@ -751,13 +751,13 @@ void input_poll_overlay(float opacity) analog_y = (float)ol_state->analog[analog_base + 1] / 0x7fff; if (analog_x <= -settings->input.axis_threshold) - ol_state->buttons |= (1UL << RETRO_DEVICE_ID_JOYPAD_LEFT); + BIT32_SET(ol_state->buttons, RETRO_DEVICE_ID_JOYPAD_LEFT); if (analog_x >= settings->input.axis_threshold) - ol_state->buttons |= (1UL << RETRO_DEVICE_ID_JOYPAD_RIGHT); + BIT32_SET(ol_state->buttons, RETRO_DEVICE_ID_JOYPAD_RIGHT); if (analog_y <= -settings->input.axis_threshold) - ol_state->buttons |= (1UL << RETRO_DEVICE_ID_JOYPAD_UP); + BIT32_SET(ol_state->buttons, RETRO_DEVICE_ID_JOYPAD_UP); if (analog_y >= settings->input.axis_threshold) - ol_state->buttons |= (1UL << RETRO_DEVICE_ID_JOYPAD_DOWN); + BIT32_SET(ol_state->buttons, RETRO_DEVICE_ID_JOYPAD_DOWN); break; } diff --git a/menu/menu_input.c b/menu/menu_input.c index 9d1c03bfa8..d7af1f8062 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -1281,15 +1281,6 @@ unsigned menu_input_frame_retropad(retro_input_t input, float delta_time; static bool initial_held = true; static bool first_held = false; - static const retro_input_t input_repeat = - (1UL << RETRO_DEVICE_ID_JOYPAD_UP) - | (1UL << RETRO_DEVICE_ID_JOYPAD_DOWN) - | (1UL << RETRO_DEVICE_ID_JOYPAD_LEFT) - | (1UL << RETRO_DEVICE_ID_JOYPAD_RIGHT) - | (1UL << RETRO_DEVICE_ID_JOYPAD_B) - | (1UL << RETRO_DEVICE_ID_JOYPAD_A) - | (1UL << RETRO_DEVICE_ID_JOYPAD_L) - | (1UL << RETRO_DEVICE_ID_JOYPAD_R); bool set_scroll = false; size_t new_scroll_accel = 0; menu_input_t *menu_input = menu_input_get_ptr(); @@ -1303,7 +1294,7 @@ unsigned menu_input_frame_retropad(retro_input_t input, /* don't run anything first frame, only capture held inputs * for old_input_state. */ - if (input & input_repeat) + if (input) { if (!first_held) { @@ -1314,6 +1305,16 @@ unsigned menu_input_frame_retropad(retro_input_t input, if (menu_input->delay.count >= menu_input->delay.timer) { + retro_input_t input_repeat = 0; + BIT32_SET(input_repeat, RETRO_DEVICE_ID_JOYPAD_UP); + BIT32_SET(input_repeat, RETRO_DEVICE_ID_JOYPAD_DOWN); + BIT32_SET(input_repeat, RETRO_DEVICE_ID_JOYPAD_LEFT); + BIT32_SET(input_repeat, RETRO_DEVICE_ID_JOYPAD_RIGHT); + BIT32_SET(input_repeat, RETRO_DEVICE_ID_JOYPAD_B); + BIT32_SET(input_repeat, RETRO_DEVICE_ID_JOYPAD_A); + BIT32_SET(input_repeat, RETRO_DEVICE_ID_JOYPAD_L); + BIT32_SET(input_repeat, RETRO_DEVICE_ID_JOYPAD_R); + set_scroll = true; first_held = false; trigger_input |= input & input_repeat; From b5e7861125e3b37c17be80f5481c0b8281d7d569 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 6 May 2016 05:19:31 +0200 Subject: [PATCH 187/498] menu_input_frame_retropad - cleanup --- menu/menu_input.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/menu/menu_input.c b/menu/menu_input.c index d7af1f8062..e2081f823f 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -1284,7 +1284,6 @@ unsigned menu_input_frame_retropad(retro_input_t input, bool set_scroll = false; size_t new_scroll_accel = 0; menu_input_t *menu_input = menu_input_get_ptr(); - settings_t *settings = config_get_ptr(); if (!menu_input) return 0; @@ -1347,6 +1346,8 @@ unsigned menu_input_frame_retropad(retro_input_t input, if (menu_input->keyboard.display) { + settings_t *settings = config_get_ptr(); + /* send return key to close keyboard input window */ if (trigger_input & (UINT64_C(1) << settings->menu_cancel_btn)) input_keyboard_event(true, '\n', '\n', 0, RETRO_DEVICE_KEYBOARD); From 9cff56ea62e0b78faa4795b94727f39cbc36664c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 6 May 2016 05:31:17 +0200 Subject: [PATCH 188/498] Cleanup --- tasks/task_http.c | 2 +- tasks/tasks_internal.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tasks/task_http.c b/tasks/task_http.c index 36ff154c8f..e22f739e7c 100644 --- a/tasks/task_http.c +++ b/tasks/task_http.c @@ -326,7 +326,7 @@ error: return NULL; } -http_transfer_info_t *http_task_get_transfer_list() +http_transfer_info_t *http_task_get_transfer_list(void) { http_transfer_info_t *list = NULL; task_finder_data_t find_data; diff --git a/tasks/tasks_internal.h b/tasks/tasks_internal.h index 7f477b4499..cc4ad6e3a6 100644 --- a/tasks/tasks_internal.h +++ b/tasks/tasks_internal.h @@ -44,7 +44,7 @@ typedef struct http_transfer_info void *rarch_task_push_http_transfer(const char *url, const char *type, retro_task_callback_t cb, void *userdata); -http_transfer_info_t *http_task_get_transfer_list(); +http_transfer_info_t *http_task_get_transfer_list(void); void http_task_free_transfer_list(http_transfer_info_t *list); #endif From 3dc40263ea3e09397fbdb414c8e49250c7129d23 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 6 May 2016 05:38:04 +0200 Subject: [PATCH 189/498] menu_content_load_from_playlist - use path_is_valid --- menu/menu_content.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/menu/menu_content.c b/menu/menu_content.c index a922fb25e3..73dc407f09 100644 --- a/menu/menu_content.c +++ b/menu/menu_content.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include "menu_content.h" @@ -162,7 +163,7 @@ static bool menu_content_load_from_playlist(void *data) if (path && !string_is_empty(path)) { unsigned i; - RFILE *fp = NULL; + bool valid_path = false; char *path_check = NULL; char *path_tolower = strdup(path); @@ -179,16 +180,13 @@ static bool menu_content_load_from_playlist(void *data) strncpy(path_check, path, strlen(path_tolower)); + valid_path = path_is_valid(path_check); + free(path_tolower); - - fp = filestream_open(path_check, RFILE_MODE_READ, -1); - free(path_check); - if (!fp) + if (!valid_path) goto error; - - filestream_close(fp); } runloop_ctl(RUNLOOP_CTL_SET_LIBRETRO_PATH, (void*)core_path); From 9c00dd0e2ebc5516dbf6e3c6d4098fee00988079 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 6 May 2016 05:51:01 +0200 Subject: [PATCH 190/498] Cleanup --- menu/menu_content.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/menu/menu_content.c b/menu/menu_content.c index 73dc407f09..44c28e1d5a 100644 --- a/menu/menu_content.c +++ b/menu/menu_content.c @@ -160,7 +160,7 @@ static bool menu_content_load_from_playlist(void *data) content_playlist_get_index(playlist, idx, &path, NULL, &core_path, NULL, NULL, NULL); - if (path && !string_is_empty(path)) + if (!string_is_empty(path)) { unsigned i; bool valid_path = false; From 5db093924cf2ce5c04da0f1fc6ead2e42c6b62d8 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 6 May 2016 06:05:30 +0200 Subject: [PATCH 191/498] Cleanup - slock_new --- libretro-common/rthreads/rthreads.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libretro-common/rthreads/rthreads.c b/libretro-common/rthreads/rthreads.c index 7d6767cd0d..26f7d8bb8d 100644 --- a/libretro-common/rthreads/rthreads.c +++ b/libretro-common/rthreads/rthreads.c @@ -237,7 +237,7 @@ slock_t *slock_new(void) return lock; error: - free(lock); + slock_free(lock); return NULL; } From 10fe532d29617216ecee334118ac70833d58268e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 6 May 2016 06:25:06 +0200 Subject: [PATCH 192/498] Cleanup --- libretro-common/rthreads/rthreads.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/libretro-common/rthreads/rthreads.c b/libretro-common/rthreads/rthreads.c index 26f7d8bb8d..35027902fe 100644 --- a/libretro-common/rthreads/rthreads.c +++ b/libretro-common/rthreads/rthreads.c @@ -219,20 +219,18 @@ bool sthread_isself(sthread_t *thread) **/ slock_t *slock_new(void) { - bool mutex_created = false; slock_t *lock = (slock_t*)calloc(1, sizeof(*lock)); if (!lock) return NULL; #ifdef USE_WIN32_THREADS lock->lock = CreateMutex(NULL, FALSE, NULL); - mutex_created = !!lock->lock; -#else - mutex_created = (pthread_mutex_init(&lock->lock, NULL) == 0); -#endif - - if (!mutex_created) + if (!lock->lock) goto error; +#else + if ((pthread_mutex_init(&lock->lock, NULL) < 0)) + goto error; +#endif return lock; From 8f6bb23f38402d80c475e0f9ee53b71809e542d8 Mon Sep 17 00:00:00 2001 From: Sebastien Ronsse Date: Fri, 6 May 2016 14:29:58 +1000 Subject: [PATCH 193/498] task queue: Implement running tasks retrieval mechanism --- libretro-common/include/queues/task_queue.h | 28 +++++++ libretro-common/queues/task_queue.c | 86 +++++++++++++++++++++ 2 files changed, 114 insertions(+) diff --git a/libretro-common/include/queues/task_queue.h b/libretro-common/include/queues/task_queue.h index b72ce91192..a7482158b3 100644 --- a/libretro-common/include/queues/task_queue.h +++ b/libretro-common/include/queues/task_queue.h @@ -56,6 +56,14 @@ enum task_queue_ctl_state */ TASK_QUEUE_CTL_FIND, + /** + * Calls func for every running task when handler + * parameter matches task handler, allowing the + * list parameter to be filled with user-defined + * data. + */ + TASK_QUEUE_CTL_RETRIEVE, + /* Blocks until all tasks have finished. * This must only be called from the main thread. */ TASK_QUEUE_CTL_WAIT, @@ -99,6 +107,8 @@ typedef void (*retro_task_handler_t)(retro_task_t *task); typedef bool (*retro_task_finder_t)(retro_task_t *task, void *userdata); +typedef bool (*retro_task_retriever_t)(retro_task_t *task, void *data); + typedef struct { char *source_file; @@ -149,10 +159,28 @@ typedef struct task_finder_data void *userdata; } task_finder_data_t; +typedef struct task_retriever_info +{ + struct task_retriever_info *next; + void *data; +} task_retriever_info_t; + +typedef struct task_retriever_data +{ + retro_task_handler_t handler; + size_t element_size; + retro_task_retriever_t func; + task_retriever_info_t *list; +} task_retriever_data_t; + void task_queue_push_progress(retro_task_t *task); bool task_queue_ctl(enum task_queue_ctl_state state, void *data); +void *task_queue_retriever_info_next(task_retriever_info_t **link); + +void task_queue_retriever_info_free(task_retriever_info_t *list); + void task_queue_cancel_task(void *task); RETRO_END_DECLS diff --git a/libretro-common/queues/task_queue.c b/libretro-common/queues/task_queue.c index be254981b4..388b0ba99b 100644 --- a/libretro-common/queues/task_queue.c +++ b/libretro-common/queues/task_queue.c @@ -44,6 +44,7 @@ struct retro_task_impl void (*wait)(void); void (*gather)(void); bool (*find)(retro_task_finder_t, void*); + void (*retrieve)(task_retriever_data_t *data); void (*init)(void); void (*deinit)(void); }; @@ -237,6 +238,43 @@ static bool retro_task_regular_find(retro_task_finder_t func, void *user_data) return false; } +static void retro_task_regular_retrieve(task_retriever_data_t *data) +{ + retro_task_t *task; + task_retriever_info_t *info; + task_retriever_info_t *tail = NULL; + + /* Parse all running tasks and handle matching handlers */ + for (task = tasks_running.front; task != NULL; task = task->next) + if (task->handler == data->handler) + { + /* Create new link */ + info = malloc(sizeof(task_retriever_info_t)); + info->data = malloc(data->element_size); + info->next = NULL; + + /* Call retriever function and fill info-specific data */ + if (!data->func(task, info->data)) + { + free(info->data); + free(info); + continue; + } + + /* Add link to list */ + if (data->list == NULL) + { + data->list = info; + tail = data->list; + } + else + { + tail->next = info; + tail = tail->next; + } + } +} + static struct retro_task_impl impl_regular = { retro_task_regular_push_running, retro_task_regular_cancel, @@ -244,6 +282,7 @@ static struct retro_task_impl impl_regular = { retro_task_regular_wait, retro_task_regular_gather, retro_task_regular_find, + retro_task_regular_retrieve, retro_task_regular_init, retro_task_regular_deinit }; @@ -341,6 +380,20 @@ static bool retro_task_threaded_find( return result; } +static void retro_task_threaded_retrieve(task_retriever_data_t *data) +{ + retro_task_t *task; + + /* Protect access to running tasks */ + slock_lock(running_lock); + + /* Call regular retrieve function */ + retro_task_regular_retrieve(data); + + /* Release access to running tasks */ + slock_unlock(running_lock); +} + static void threaded_worker(void *userdata) { (void)userdata; @@ -430,6 +483,7 @@ static struct retro_task_impl impl_threaded = { retro_task_threaded_wait, retro_task_threaded_gather, retro_task_threaded_find, + retro_task_threaded_retrieve, retro_task_threaded_init, retro_task_threaded_deinit }; @@ -480,6 +534,9 @@ bool task_queue_ctl(enum task_queue_ctl_state state, void *data) return false; } break; + case TASK_QUEUE_CTL_RETRIEVE: + impl_current->retrieve(data); + break; case TASK_QUEUE_CTL_CHECK: { #ifdef HAVE_THREADS @@ -526,3 +583,32 @@ void task_queue_cancel_task(void *task) { task_queue_ctl(TASK_QUEUE_CTL_CANCEL, task); } + +void *task_queue_retriever_info_next(task_retriever_info_t **link) +{ + void *data = NULL; + + /* Grab data and move to next link */ + if (*link) + { + data = (*link)->data; + *link = (*link)->next; + } + + return data; +} + +void task_queue_retriever_info_free(task_retriever_info_t *list) +{ + task_retriever_info_t *info; + + /* Free links including retriever-specific data */ + while (list) + { + info = list->next; + free(list->data); + free(list); + list = info; + } +} + From 9f45722020617ccac79d510e3d053a0e43eca17c Mon Sep 17 00:00:00 2001 From: Sebastien Ronsse Date: Fri, 6 May 2016 14:31:25 +1000 Subject: [PATCH 194/498] task http: Update http_task_get_transfer_list using new task retrieval mechanism --- tasks/task_http.c | 68 +++++++++--------------------------------- tasks/tasks_internal.h | 5 +--- 2 files changed, 15 insertions(+), 58 deletions(-) diff --git a/tasks/task_http.c b/tasks/task_http.c index e22f739e7c..a69e7ae6c1 100644 --- a/tasks/task_http.c +++ b/tasks/task_http.c @@ -211,47 +211,20 @@ static bool rarch_task_http_finder(retro_task_t *task, void *user_data) return string_is_equal(http->connection.url, (const char*)user_data); } -static bool rarch_task_http_retriever(retro_task_t *task, void *user_data) +static bool rarch_task_http_retriever(retro_task_t *task, void *data) { http_handle_t *http; - http_transfer_info_t **list = user_data; - http_transfer_info_t *info; - http_transfer_info_t *link; + http_transfer_info_t *info = data; - /* Check if task is valid and corresponding to an HTTP transfer */ - if (!task || (task->handler != rarch_task_http_transfer_handler)) - return false; - - /* Check if user data argument is valid */ - if (!list) - return false; - - /* Extract HTTP handle and check if it is valid */ - http = (http_handle_t*)task->state; + /* Extract HTTP handle and return already if invalid */ + http = (http_handle_t *)task->state; if (!http) return false; - /* Create new HTTP info link */ - info = malloc(sizeof(http_transfer_info_t)); + /* Fill HTTP info link */ strlcpy(info->url, http->connection.url, sizeof(info->url)); info->progress = task->progress; - info->next = NULL; - - /* Add link to list */ - if (*list == NULL) - { - /* Initialize list with info if required */ - *list = info; - } - else - { - /* Cycle through list until end is reached and add info */ - for (link = *list; link->next != NULL; link = link->next); - link->next = info; - } - - /* Request task finder to continue searching in all cases */ - return false; + return true; } void *rarch_task_push_http_transfer(const char *url, const char *type, @@ -326,30 +299,17 @@ error: return NULL; } -http_transfer_info_t *http_task_get_transfer_list(void) +task_retriever_info_t *http_task_get_transfer_list(void) { - http_transfer_info_t *list = NULL; - task_finder_data_t find_data; + task_retriever_data_t retrieve_data; - /* Fill find data */ - find_data.func = rarch_task_http_retriever; - find_data.userdata = &list; + /* Fill retrieve data */ + retrieve_data.handler = rarch_task_http_transfer_handler; + retrieve_data.element_size = sizeof(http_transfer_info_t); + retrieve_data.func = rarch_task_http_retriever; /* Build list of current HTTP transfers and return it */ - task_queue_ctl(TASK_QUEUE_CTL_FIND, &find_data); - return list; -} - -void http_task_free_transfer_list(http_transfer_info_t *list) -{ - http_transfer_info_t *link; - - /* Free list of transfers */ - while (list) - { - link = list->next; - free(list); - list = link; - } + task_queue_ctl(TASK_QUEUE_CTL_RETRIEVE, &retrieve_data); + return retrieve_data.list; } diff --git a/tasks/tasks_internal.h b/tasks/tasks_internal.h index cc4ad6e3a6..44562f2bad 100644 --- a/tasks/tasks_internal.h +++ b/tasks/tasks_internal.h @@ -38,15 +38,12 @@ typedef struct http_transfer_info { char url[PATH_MAX_LENGTH]; int progress; - struct http_transfer_info *next; } http_transfer_info_t; void *rarch_task_push_http_transfer(const char *url, const char *type, retro_task_callback_t cb, void *userdata); -http_transfer_info_t *http_task_get_transfer_list(void); - -void http_task_free_transfer_list(http_transfer_info_t *list); +task_retriever_info_t *http_task_get_transfer_list(void); #endif bool rarch_task_push_image_load(const char *fullpath, const char *type, From d757889b19e8eba1d4f79f49324793e7da7aaffb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Fri, 6 May 2016 15:08:53 +0700 Subject: [PATCH 195/498] (Lakka) Disable buildbot updaters Keeping two concurrent update systems causes a lot of bugs. Especially in our case where the buildbot stuff overrides the system stuff. Users don't get how to use both updaters properly. They end up using outdated cores or joyconfigs, or even assets. Using the Lakka updater in our case is a better solution, because it ensures version compatibility between all the components. I will do an additional effort to keep all the libretro packages up to date in Lakka. --- menu/menu_displaylist.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 8a4c997d22..b9fff17f05 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -2394,8 +2394,12 @@ static int menu_displaylist_parse_options( menu_hash_to_str(MENU_LABEL_VALUE_UPDATE_LAKKA), menu_hash_to_str(MENU_LABEL_UPDATE_LAKKA), MENU_SETTING_ACTION, 0, 0); -#endif + menu_entries_add(info->list, + menu_hash_to_str(MENU_LABEL_VALUE_THUMBNAILS_UPDATER_LIST), + menu_hash_to_str(MENU_LABEL_THUMBNAILS_UPDATER_LIST), + MENU_SETTING_ACTION, 0, 0); +#else menu_entries_add(info->list, menu_hash_to_str(MENU_LABEL_VALUE_CORE_UPDATER_LIST), menu_hash_to_str(MENU_LABEL_CORE_UPDATER_LIST), @@ -2452,6 +2456,8 @@ static int menu_displaylist_parse_options( MENU_SETTING_ACTION, 0, 0); #endif +#endif + #else menu_entries_add(info->list, menu_hash_to_str(MENU_LABEL_VALUE_NO_ITEMS), From a85bc7bab6c7e4355ec7e075ad2a911f4d1f9acd Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Fri, 6 May 2016 18:55:42 +0200 Subject: [PATCH 196/498] RARCH_DISPLAY_CT_LOCK_NEW - make sure lock is freed beforehand --- gfx/video_driver.c | 1 + 1 file changed, 1 insertion(+) diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 0a71abaaa1..a4041a6f81 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -1300,6 +1300,7 @@ bool video_driver_ctl(enum rarch_display_ctl_state state, void *data) #endif break; case RARCH_DISPLAY_CTL_LOCK_NEW: + video_driver_ctl(RARCH_DISPLAY_CTL_LOCK_FREE, NULL); #ifdef HAVE_THREADS if (!display_lock) display_lock = slock_new(); From 648da7b6e699742d69ba3c29c61e8d744ecfa36e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 6 May 2016 18:57:11 +0200 Subject: [PATCH 197/498] (task_queue) Remove unused variable --- libretro-common/queues/task_queue.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libretro-common/queues/task_queue.c b/libretro-common/queues/task_queue.c index 388b0ba99b..93bd5ef8fd 100644 --- a/libretro-common/queues/task_queue.c +++ b/libretro-common/queues/task_queue.c @@ -382,8 +382,6 @@ static bool retro_task_threaded_find( static void retro_task_threaded_retrieve(task_retriever_data_t *data) { - retro_task_t *task; - /* Protect access to running tasks */ slock_lock(running_lock); From 77649b2f233ab50b0f6a7f84b17e758ae00242b7 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Fri, 6 May 2016 19:14:38 +0200 Subject: [PATCH 198/498] Fix memory leak in async_job_free --- libretro-common/rthreads/async_job.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libretro-common/rthreads/async_job.c b/libretro-common/rthreads/async_job.c index b35ae6e5da..01ed99d3ce 100644 --- a/libretro-common/rthreads/async_job.c +++ b/libretro-common/rthreads/async_job.c @@ -112,6 +112,7 @@ void async_job_free(async_job_t *ajob) ajob->finish = 1; ssem_signal(ajob->sem); sthread_join(ajob->thread); + slock_free(ajob->lock); ssem_free(ajob->sem); free((void*)ajob); From eae911bcd2dad93f474d3b25cfa3f3209fec6032 Mon Sep 17 00:00:00 2001 From: Alcaro Date: Fri, 6 May 2016 20:20:16 +0200 Subject: [PATCH 199/498] No need to remove function names, they don't slow anything down and they're invaluable for crash debugging. --- Makefile.win | 1 - playlist.c | 9 ++++----- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Makefile.win b/Makefile.win index ae2d252593..c89be5935c 100644 --- a/Makefile.win +++ b/Makefile.win @@ -120,7 +120,6 @@ ifeq ($(DEBUG), 1) else CFLAGS += -O3 -ffast-math CXXFLAGS += -O3 -ffast-math - LDCXXFLAGS += -s endif CFLAGS += -Wall -Wno-unused-result -Wno-unused-variable -I. diff --git a/playlist.c b/playlist.c index 265572d5a0..c374ffcfb2 100644 --- a/playlist.c +++ b/playlist.c @@ -51,7 +51,7 @@ struct content_playlist /** * content_playlist_get_index: - * @playlist : Playlist handle. + * @playlist : Playlist handle. * @idx : Index of playlist entry. * @path : Path of playlist entry. * @core_path : Core path of playlist entry. @@ -113,7 +113,6 @@ void content_playlist_get_index_by_path(content_playlist_t *playlist, *crc32 = playlist->entries[i].crc32; break; } - } bool content_playlist_entry_exists(content_playlist_t *playlist, @@ -133,7 +132,7 @@ bool content_playlist_entry_exists(content_playlist_t *playlist, /** * content_playlist_free_entry: - * @entry : Playlist entry handle. + * @entry : Playlist entry handle. * * Frees playlist entry. **/ @@ -246,7 +245,7 @@ void content_playlist_push(content_playlist_t *playlist, /* Seen it before, bump to top. */ tmp = playlist->entries[i]; memmove(playlist->entries + 1, playlist->entries, - i * sizeof(content_playlist_entry_t)); + i * sizeof(content_playlist_entry_t)); playlist->entries[0] = tmp; return; @@ -298,7 +297,7 @@ void content_playlist_write_file(content_playlist_t *playlist) /** * content_playlist_free: - * @playlist : Playlist handle. + * @playlist : Playlist handle. * * Frees playlist handle. */ From 056e8c3ab380f32d4b0d4ab2692f6d0998c6b363 Mon Sep 17 00:00:00 2001 From: Alcaro Date: Fri, 6 May 2016 20:22:37 +0200 Subject: [PATCH 200/498] No need to remove function names here either. --- pkg/apple/RetroArch_iOS.xcodeproj/project.pbxproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/apple/RetroArch_iOS.xcodeproj/project.pbxproj b/pkg/apple/RetroArch_iOS.xcodeproj/project.pbxproj index 5c7e62e496..dea2b6e637 100644 --- a/pkg/apple/RetroArch_iOS.xcodeproj/project.pbxproj +++ b/pkg/apple/RetroArch_iOS.xcodeproj/project.pbxproj @@ -931,7 +931,7 @@ CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; CODE_SIGN_IDENTITY = ""; "CODE_SIGN_IDENTITY[sdk=iphoneos*]" = ""; - COPY_PHASE_STRIP = YES; + COPY_PHASE_STRIP = NO; ENABLE_BITCODE = NO; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_OPTIMIZATION_LEVEL = 2; From e4c9ec090340c42f41db1a24e70e7c752ce47431 Mon Sep 17 00:00:00 2001 From: Alcaro Date: Fri, 6 May 2016 20:23:54 +0200 Subject: [PATCH 201/498] Or here. --- pkg/apple/RetroArch_PPC.xcodeproj/project.pbxproj | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/apple/RetroArch_PPC.xcodeproj/project.pbxproj b/pkg/apple/RetroArch_PPC.xcodeproj/project.pbxproj index 1b7fd50c82..a50c6256b9 100644 --- a/pkg/apple/RetroArch_PPC.xcodeproj/project.pbxproj +++ b/pkg/apple/RetroArch_PPC.xcodeproj/project.pbxproj @@ -337,7 +337,7 @@ CLANG_WARN_OBJC_MISSING_PROPERTY_SYNTHESIS = YES; CLANG_WARN__DUPLICATE_METHOD_MATCH = YES; COMBINE_HIDPI_IMAGES = YES; - COPY_PHASE_STRIP = YES; + COPY_PHASE_STRIP = NO; DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym"; GCC_C_LANGUAGE_STANDARD = gnu99; GCC_ENABLE_OBJC_EXCEPTIONS = YES; From 2e319213e31af689725daa12ce2213f0281d8eaf Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 6 May 2016 22:08:49 +0200 Subject: [PATCH 202/498] Expand glsm --- libretro-common/glsm/glsm.c | 280 +++++++++++++++++++++++-- libretro-common/include/glsm/glsmsym.h | 36 ++++ 2 files changed, 296 insertions(+), 20 deletions(-) diff --git a/libretro-common/glsm/glsm.c b/libretro-common/glsm/glsm.c index 303af81ad3..736c6c5161 100644 --- a/libretro-common/glsm/glsm.c +++ b/libretro-common/glsm/glsm.c @@ -189,6 +189,7 @@ static struct gl_cached_state gl_state; * * Core in: * OpenGL : 3.0 + * OpenGLES : 3.0 */ void rglBlitFramebuffer( GLint srcX0, GLint srcY0, @@ -197,21 +198,31 @@ void rglBlitFramebuffer( GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter) { -#ifndef HAVE_OPENGLES2 +#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) && defined(HAVE_OPENGLES3) glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, mask, filter); #endif } +/* + * + * Core in: + * OpenGLES : 3.0 + */ void rglReadBuffer(GLenum mode) { -#ifndef HAVE_OPENGLES2 +#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) && defined(HAVE_OPENGLES3) glReadBuffer(mode); -#endif gl_state.readbuffer.mode = mode; +#endif } +/* + * + * Core in: + * OpenGLES : 2.0 + */ void rglClearDepth(GLdouble depth) { glsm_ctl(GLSM_CTL_IMM_VBO_DRAW, NULL); @@ -224,6 +235,11 @@ void rglClearDepth(GLdouble depth) gl_state.cleardepth.depth = depth; } +/* + * + * Core in: + * OpenGLES : 2.0 + */ void rglPixelStorei(GLenum pname, GLint param) { glPixelStorei(pname, param); @@ -231,6 +247,11 @@ void rglPixelStorei(GLenum pname, GLint param) gl_state.pixelstore_i.param = param; } +/* + * + * Core in: + * OpenGLES : 2.0 + */ void rglDepthRange(GLclampd zNear, GLclampd zFar) { #ifdef HAVE_OPENGLES @@ -243,6 +264,11 @@ void rglDepthRange(GLclampd zNear, GLclampd zFar) gl_state.depthrange.zFar = zFar; } +/* + * + * Core in: + * OpenGLES : 2.0 + */ void rglFrontFace(GLenum mode) { glsm_ctl(GLSM_CTL_IMM_VBO_DRAW, NULL); @@ -251,6 +277,11 @@ void rglFrontFace(GLenum mode) gl_state.frontface.mode = mode; } +/* + * + * Core in: + * OpenGLES : 2.0 + */ void rglDepthFunc(GLenum func) { glsm_ctl(GLSM_CTL_IMM_VBO_DRAW, NULL); @@ -259,6 +290,11 @@ void rglDepthFunc(GLenum func) glDepthFunc(func); } +/* + * + * Core in: + * OpenGLES : 2.0 + */ void rglColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha) { @@ -271,6 +307,11 @@ void rglColorMask(GLboolean red, GLboolean green, gl_state.colormask.used = true; } +/* + * + * Core in: + * OpenGLES : 2.0 + */ void rglCullFace(GLenum mode) { glsm_ctl(GLSM_CTL_IMM_VBO_DRAW, NULL); @@ -279,6 +320,11 @@ void rglCullFace(GLenum mode) gl_state.cullface.mode = mode; } +/* + * + * Core in: + * OpenGLES : 2.0 + */ void rglStencilOp(GLenum sfail, GLenum dpfail, GLenum dppass) { glStencilOp(sfail, dpfail, dppass); @@ -288,6 +334,11 @@ void rglStencilOp(GLenum sfail, GLenum dpfail, GLenum dppass) gl_state.stencilop.dppass = dppass; } +/* + * + * Core in: + * OpenGLES : 2.0 + */ void rglStencilFunc(GLenum func, GLint ref, GLuint mask) { glStencilFunc(func, ref, mask); @@ -323,6 +374,11 @@ void rglClearColor(GLclampf red, GLclampf green, gl_state.clear_color.a = alpha; } +/* + * + * Core in: + * OpenGLES : 2.0 (maybe earlier?) + */ void rglScissor(GLint x, GLint y, GLsizei width, GLsizei height) { glsm_ctl(GLSM_CTL_IMM_VBO_DRAW, NULL); @@ -506,17 +562,30 @@ void rglLinkProgram(GLuint program) glLinkProgram(program); } +/* + * Category: FBO + * + * Core in: + * OpenGL : 3.0 + * OpenGLES : 2.0 + */ +void rglFramebufferTexture2D(GLenum target, GLenum attachment, + GLenum textarget, GLuint texture, GLint level) +{ + glFramebufferTexture2D(target, attachment, textarget, texture, level); +} + /* * Category: FBO * * Core in: * OpenGL : 3.0 + * OpenGLES : 3.2 */ void rglFramebufferTexture(GLenum target, GLenum attachment, GLuint texture, GLint level) { -#if defined(HAVE_OPENGLES) && !defined(HAVE_OPENGLES32) -#else +#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) && defined(HAVE_OPENGLES32) glFramebufferTexture(target, attachment, texture, level); #endif } @@ -561,28 +630,59 @@ void rglDeleteTextures(GLsizei n, const GLuint *textures) glDeleteTextures(n, textures); } +/* + * + * Core in: + * OpenGLES : 2.0 + */ void rglRenderbufferStorage(GLenum target, GLenum internalFormat, GLsizei width, GLsizei height) { glRenderbufferStorage(target, internalFormat, width, height); } +/* + * + * Core in: + * + * OpenGL : 3.0 + * OpenGLES : 2.0 + */ void rglBindRenderbuffer(GLenum target, GLuint renderbuffer) { glBindRenderbuffer(target, renderbuffer); } +/* + * + * Core in: + * + * OpenGLES : 2.0 + */ void rglDeleteRenderbuffers(GLsizei n, GLuint *renderbuffers) { glDeleteRenderbuffers(n, renderbuffers); } +/* + * + * Core in: + * + * OpenGL : 3.0 + * OpenGLES : 2.0 + */ void rglGenRenderbuffers(GLsizei n, GLuint *renderbuffers) { glGenRenderbuffers(n, renderbuffers); } - +/* + * + * Core in: + * + * OpenGL : 3.0 + * OpenGLES : 2.0 + */ void rglGenerateMipmap(GLenum target) { glGenerateMipmap(target); @@ -604,6 +704,7 @@ GLenum rglCheckFramebufferStatus(GLenum target) * * Core in: * OpenGL : 3.0 + * OpenGLES : 2.0 */ void rglFramebufferRenderbuffer(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer) @@ -611,18 +712,6 @@ void rglFramebufferRenderbuffer(GLenum target, GLenum attachment, glFramebufferRenderbuffer(target, attachment, renderbuffertarget, renderbuffer); } -/* - * Category: FBO - * - * Core in: - * OpenGL : 3.0 - */ -void rglFramebufferTexture2D(GLenum target, GLenum attachment, - GLenum textarget, GLuint texture, GLint level) -{ - glFramebufferTexture2D(target, attachment, textarget, texture, level); -} - /* * Category: Shaders * @@ -660,6 +749,117 @@ void rglGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, glGetActiveUniform(program, index, bufsize, length, size, type, name); } +/* + * + * Core in: + * + * OpenGL : 2.0 + * OpenGLES : 3.0 + */ +void rglGetActiveUniformBlockiv(GLuint program, + GLuint uniformBlockIndex, + GLenum pname, + GLint *params) +{ +#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) && defined(HAVE_OPENGLES3) + glGetActiveUniformBlockiv(program, uniformBlockIndex, + pname, params); +#else + printf("WARNING! Not implemented.\n"); +#endif +} + +/* + * + * Core in: + * + * OpenGLES : 3.0 + */ +void rglGetActiveUniformsiv( GLuint program, + GLsizei uniformCount, + const GLuint *uniformIndices, + GLenum pname, + GLint *params) +{ +#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) && defined(HAVE_OPENGLES3) + glGetActiveUniformsiv(program, uniformCount, + uniformIndices, pname, params); +#else + printf("WARNING! Not implemented.\n"); +#endif +} + +/* + * + * Core in: + * + * OpenGLES : 3.0 + */ +void rglGetUniformIndices(GLuint program, + GLsizei uniformCount, + const GLchar **uniformNames, + GLuint *uniformIndices) +{ +#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) && defined(HAVE_OPENGLES3) + glGetUniformIndices(program, uniformCount, + uniformNames, uniformIndices); +#else + printf("WARNING! Not implemented.\n"); +#endif +} + +/* + * + * Core in: + * + * OpenGLES : 3.0 + */ +void rglBindBufferBase( GLenum target, + GLuint index, + GLuint buffer) +{ +#if defined(HAVE_OPENG) || defined(HAVE_OPENGLES) && defined(HAVE_OPENGLES3) + glBindBufferBase(target, index, buffer); +#else + printf("WARNING! Not implemented.\n"); +#endif +} + +/* + * + * Core in: + * + * OpenGLES : 3.0 + */ +GLuint rglGetUniformBlockIndex( GLuint program, + const GLchar *uniformBlockName) +{ +#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) && defined(HAVE_OPENGLES3) + return glGetUniformBlockIndex(program, uniformBlockName); +#else + printf("WARNING! Not implemented.\n"); + return 0; +#endif +} + +/* + * + * Core in: + * + * OpenGLES : 3.0 + */ +void rglUniformBlockBinding( GLuint program, + GLuint uniformBlockIndex, + GLuint uniformBlockBinding) +{ +#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) && defined(HAVE_OPENGLES3) + glUniformBlockBinding(program, uniformBlockIndex, + uniformBlockBinding); +#else + printf("WARNING! Not implemented.\n"); +#endif +} + /* * * Core in: @@ -1134,15 +1334,53 @@ void rglBindFramebuffer(GLenum target, GLuint framebuffer) * * Core in: * OpenGL : 2.0 + * OpenGLES : 3.0 */ void rglDrawBuffers(GLsizei n, const GLenum *bufs) { -#if defined(HAVE_OPENGLES) && !defined(HAVE_OPENGLES3) && !defined(HAVE_OPENGLES31) -#else +#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) && defined(HAVE_OPENGLES3) glDrawBuffers(n, bufs); #endif } +/* + * Category: FBO + * + * Core in: + * OpenGL : 2.0 + * OpenGLES : 3.0 + */ +void *rglMapBufferRange( GLenum target, + GLintptr offset, + GLsizeiptr length, + GLbitfield access) +{ +#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) && defined(HAVE_OPENGLES3) + return glMapBufferRange(target, offset, length, access); +#else + printf("WARNING! Not implemented.\n"); + return NULL; +#endif +} + +void * rglMapBuffer( GLenum target, GLenum access) +{ +#if defined(HAVE_OPENGLES) + return glMapBufferOES(target, access); +#else + return glMapBuffer(target, access); +#endif +} + +GLboolean rglUnmapBuffer( GLenum target) +{ +#if defined(HAVE_OPENGLES) + return glUnmapBufferOES(target); +#else + return glUnmapBuffer(target); +#endif +} + void rglBlendEquation(GLenum mode) { glBlendEquation(mode); @@ -1248,6 +1486,8 @@ static void glsm_state_setup(void) #ifndef HAVE_OPENGLES gl_state.cap_translate[SGL_COLOR_LOGIC_OP] = GL_COLOR_LOGIC_OP; + gl_state.cap_translate[SGL_CLIP_DISTANCE0] = GL_CLIP_DISTANCE0; + gl_state.cap_translate[SGL_DEPTH_CLAMP] = GL_DEPTH_CLAMP; #endif for (i = 0; i < MAX_ATTRIB; i++) diff --git a/libretro-common/include/glsm/glsmsym.h b/libretro-common/include/glsm/glsmsym.h index 0560d408e6..0d00ea8ad6 100644 --- a/libretro-common/include/glsm/glsmsym.h +++ b/libretro-common/include/glsm/glsmsym.h @@ -128,7 +128,40 @@ RETRO_BEGIN_DECLS #define glBlendColor rglBlendColor #define glBlendEquationSeparate rglBlendEquationSeparate #define glCopyImageSubData rglCopyImageSubData +#define glMapBuffer rglMapBuffer +#define glUnmapBuffer rglUnmapBuffer +#define glMapBufferRange rglMapBufferRange +#define glUniformBlockBinding rglUniformBlockBinding +#define glGetUniformBlockIndex rglGetUniformBlockIndex +#define glGetActiveUniformBlockiv rglGetActiveUniformBlockiv +#define glBindBufferBase rglBindBufferBase +#define glGetUniformIndices rglGetUniformIndices +#define glGetActiveUniformsiv rglGetActiveUniformsiv +void rglGetActiveUniformsiv( GLuint program, + GLsizei uniformCount, + const GLuint *uniformIndices, + GLenum pname, + GLint *params); +void rglGetUniformIndices( GLuint program, + GLsizei uniformCount, + const GLchar **uniformNames, + GLuint *uniformIndices); +void rglBindBufferBase( GLenum target, + GLuint index, + GLuint buffer); +void rglGetActiveUniformBlockiv( GLuint program, + GLuint uniformBlockIndex, + GLenum pname, + GLint *params); +GLuint rglGetUniformBlockIndex( GLuint program, + const GLchar *uniformBlockName); +void * rglMapBuffer( GLenum target, GLenum access); +void *rglMapBufferRange( GLenum target, + GLintptr offset, + GLsizeiptr length, + GLbitfield access); +GLboolean rglUnmapBuffer( GLenum target); void rglBlendColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); void rglBlendEquation(GLenum mode); void rglGenVertexArrays(GLsizei n, GLuint *arrays); @@ -274,6 +307,9 @@ void rglVertexAttribLPointer( GLenum type, GLsizei stride, const GLvoid * pointer); +void rglUniformBlockBinding( GLuint program, + GLuint uniformBlockIndex, + GLuint uniformBlockBinding); RETRO_END_DECLS From 5d5ad0548a93e00c6fe1eb7c43729dfaabdc90a2 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 6 May 2016 22:15:24 +0200 Subject: [PATCH 203/498] Update --- libretro-common/include/glsm/glsm.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libretro-common/include/glsm/glsm.h b/libretro-common/include/glsm/glsm.h index c6c9ba2a07..73b43d1450 100644 --- a/libretro-common/include/glsm/glsm.h +++ b/libretro-common/include/glsm/glsm.h @@ -80,6 +80,10 @@ typedef GLclampf GLclampd; #define GL_ALPHA_TEST 0x0BC0 #endif +#ifndef GL_CLIP_DISTANCE0 +#define GL_CLIP_DISTANCE0 0x3000 +#endif + #define MAX_ATTRIB 8 #define MAX_TEXTURE 32 From dd36a3792ce5308915db991b7eb49c3bb2e184b3 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 6 May 2016 22:20:03 +0200 Subject: [PATCH 204/498] (GLSM) Add new wrapper functions --- libretro-common/glsm/glsm.c | 40 ++++++++++++++++++++++++++ libretro-common/include/glsm/glsmsym.h | 8 ++++++ 2 files changed, 48 insertions(+) diff --git a/libretro-common/glsm/glsm.c b/libretro-common/glsm/glsm.c index 736c6c5161..032fd473dd 100644 --- a/libretro-common/glsm/glsm.c +++ b/libretro-common/glsm/glsm.c @@ -184,6 +184,46 @@ static struct gl_cached_state gl_state; /* GL wrapper-side */ +/* + * + * Core in: + * OpenGL : 1.0 + */ +GLenum GLenum rglGetError(void) +{ + return glGetError(); +} + +/* + * + * Core in: + * OpenGL : 1.0 + */ +void rglClear(GLbitfield mask) +{ + glClear(mask); +} + +/* + * + * Core in: + * OpenGL : 1.0 + */ +void rglPolygonMode(GLenum face, GLenum mode) +{ + glPolygonMode(face, mode); +} + +/* + * + * Core in: + * OpenGL : 1.0 + */ +void rglLineWidth(GLfloat width) +{ + glLineWidth(width); +} + /* * Category: FBO * diff --git a/libretro-common/include/glsm/glsmsym.h b/libretro-common/include/glsm/glsmsym.h index 0d00ea8ad6..54980ff202 100644 --- a/libretro-common/include/glsm/glsmsym.h +++ b/libretro-common/include/glsm/glsmsym.h @@ -137,6 +137,10 @@ RETRO_BEGIN_DECLS #define glBindBufferBase rglBindBufferBase #define glGetUniformIndices rglGetUniformIndices #define glGetActiveUniformsiv rglGetActiveUniformsiv +#define glGetError rglGetError +#define glClear rglClear +#define glPolygonMode rglPolygonMode +#define glLineWidth rglLineWidth void rglGetActiveUniformsiv( GLuint program, GLsizei uniformCount, @@ -310,6 +314,10 @@ void rglVertexAttribLPointer( void rglUniformBlockBinding( GLuint program, GLuint uniformBlockIndex, GLuint uniformBlockBinding); +GLenum rglGetError(void); +void rglClear(GLbitfield mask); +void rglPolygonMode(GLenum face, GLenum mode); +void rglLineWidth(GLfloat width); RETRO_END_DECLS From d997526a1d0ef96254df724eedd65d0fcc1db81d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 6 May 2016 22:40:11 +0200 Subject: [PATCH 205/498] Updates --- libretro-common/glsm/glsm.c | 119 +++++++++++++++++++++++++ libretro-common/include/glsm/glsmsym.h | 36 ++++++++ 2 files changed, 155 insertions(+) diff --git a/libretro-common/glsm/glsm.c b/libretro-common/glsm/glsm.c index 032fd473dd..3b92d4a8aa 100644 --- a/libretro-common/glsm/glsm.c +++ b/libretro-common/glsm/glsm.c @@ -778,6 +778,24 @@ void rglGetProgramiv(GLuint shader, GLenum pname, GLint *params) glGetProgramiv(shader, pname, params); } +/* + * Category: Shaders + * + * Core in: + * OpenGL : 4.1 + * OpenGLES : 3.0 + */ +void rglProgramParameteri( GLuint program, + GLenum pname, + GLint value) +{ +#if !defined(HAVE_OPENGLES) || defined(HAVE_OPENGLES) && (defined(HAVE_OPENGLES3) || defined(HAVE_OPENGLES31)) + glProgramParameteri(program, pname, value); +#else + printf("WARNING! Not implemented.\n"); +#endif +} + /* * * Core in: @@ -1403,6 +1421,107 @@ void *rglMapBufferRange( GLenum target, #endif } +/* + * + * Core in: + * OpenGL : 4.3 + * OpenGLES : 3.1 + */ +void rglTexStorage2DMultisample(GLenum target, GLsizei samples, + GLenum internalformat, GLsizei width, GLsizei height, + GLboolean fixedsamplelocations) +{ +#if defined(HAVE_OPENGLES) && defined(HAVE_OPENGLES31) + glTexStorage2DMultisample(target, samples, internalformat, + width, height, fixedsamplelocations); +#endif +} + +/* + * + * Core in: + * OpenGL : 4.2 + * OpenGLES : 3.1 + */ +void rglMemoryBarrier( GLbitfield barriers) +{ +#if !defined(HAVE_OPENGLES) || defined(HAVE_OPENGLES3) && defined(HAVE_OPENGLES31) + glMemoryBarrier(barriers); +#else + printf("WARNING! Not implemented.\n"); +#endif +} + +/* + * + * Core in: + * OpenGL : 4.2 + * OpenGLES : 3.1 + */ +void rglBindImageTexture( GLuint unit, + GLuint texture, + GLint level, + GLboolean layered, + GLint layer, + GLenum access, + GLenum format) +{ +#if !defined(HAVE_OPENGLES) || defined(HAVE_OPENGLES3) && defined(HAVE_OPENGLES31) + glBindImageTexture(unit, texture, level, layered, layer, access, format); +#else + printf("WARNING! Not implemented.\n"); +#endif +} + +/* + * + * Core in: + * OpenGL : 4.1 + * OpenGLES : 3.1 + */ +void rglGetProgramBinary( GLuint program, + GLsizei bufsize, + GLsizei *length, + GLenum *binaryFormat, + void *binary) +{ +#if !defined(HAVE_OPENGLES) || defined(HAVE_OPENGLES) && defined(HAVE_OPENGLES3) + glGetProgramBinary(program, bufsize, length, binaryFormat, binary); +#else + printf("WARNING! Not implemented.\n"); +#endif +} + +/* + * + * Core in: + * OpenGL : 4.1 + * OpenGLES : 3.1 + */ +void rglProgramBinary(GLuint program, + GLenum binaryFormat, + const void *binary, + GLsizei length) +{ +#if !defined(HAVE_OPENGLES) || defined(HAVE_OPENGLES) && defined(HAVE_OPENGLES31) + glProgramBinary(program, binaryFormat, binary, length); +#else + printf("WARNING! Not implemented.\n"); +#endif +} + +void rglTexImage2DMultisample( GLenum target, + GLsizei samples, + GLenum internalformat, + GLsizei width, + GLsizei height, + GLboolean fixedsamplelocations) +{ +#ifndef HAVE_OPENGLES + glTexImage2DMultisample(target, samples, internalformat, width, height, fixedsamplelocations); +#endif +} + void * rglMapBuffer( GLenum target, GLenum access) { #if defined(HAVE_OPENGLES) diff --git a/libretro-common/include/glsm/glsmsym.h b/libretro-common/include/glsm/glsmsym.h index 54980ff202..d763df4adc 100644 --- a/libretro-common/include/glsm/glsmsym.h +++ b/libretro-common/include/glsm/glsmsym.h @@ -141,7 +141,36 @@ RETRO_BEGIN_DECLS #define glClear rglClear #define glPolygonMode rglPolygonMode #define glLineWidth rglLineWidth +#define glTexImage2DMultisample rglTexImage2DMultisample +#define glTexStorage2DMultisample rglTexStorage2DMultisample +#define glMemoryBarrier rglMemoryBarrier +#define glBindImageTexture rglBindImageTexture +#define glProgramBinary rglProgramBinary +#define glGetProgramBinary rglGetProgramBinary +#define glProgramParameteri rglProgramParameteri +void rglProgramParameteri( GLuint program, + GLenum pname, + GLint value); +void rglGetProgramBinary( GLuint program, + GLsizei bufsize, + GLsizei *length, + GLenum *binaryFormat, + void *binary); +void rglProgramBinary(GLuint program, + GLenum binaryFormat, + const void *binary, + GLsizei length); +void rglBindImageTexture( GLuint unit, + GLuint texture, + GLint level, + GLboolean layered, + GLint layer, + GLenum access, + GLenum format); +void rglTexStorage2DMultisample(GLenum target, GLsizei samples, + GLenum internalformat, GLsizei width, GLsizei height, + GLboolean fixedsamplelocations); void rglGetActiveUniformsiv( GLuint program, GLsizei uniformCount, const GLuint *uniformIndices, @@ -318,6 +347,13 @@ GLenum rglGetError(void); void rglClear(GLbitfield mask); void rglPolygonMode(GLenum face, GLenum mode); void rglLineWidth(GLfloat width); +void rglTexImage2DMultisample( GLenum target, + GLsizei samples, + GLenum internalformat, + GLsizei width, + GLsizei height, + GLboolean fixedsamplelocations); +void rglMemoryBarrier( GLbitfield barriers); RETRO_END_DECLS From 7eef9b87b02cc499de9613fceeb547becdfeb587 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 6 May 2016 23:54:48 +0200 Subject: [PATCH 206/498] Add glTexSubImage2D --- libretro-common/glsm/glsm.c | 15 +++++++++++++++ libretro-common/include/glsm/glsmsym.h | 10 ++++++++++ 2 files changed, 25 insertions(+) diff --git a/libretro-common/glsm/glsm.c b/libretro-common/glsm/glsm.c index 3b92d4a8aa..28a6a3b2e2 100644 --- a/libretro-common/glsm/glsm.c +++ b/libretro-common/glsm/glsm.c @@ -214,6 +214,21 @@ void rglPolygonMode(GLenum face, GLenum mode) glPolygonMode(face, mode); } +void rglTexSubImage2D( + GLenum target, + GLint level, + GLint xoffset, + GLint yoffset, + GLsizei width, + GLsizei height, + GLenum format, + GLenum type, + const GLvoid * pixels) +{ + glTexSubImage2D(target, level, xoffset, yoffset, + width, height, format, type, pixels); +} + /* * * Core in: diff --git a/libretro-common/include/glsm/glsmsym.h b/libretro-common/include/glsm/glsmsym.h index d763df4adc..8eb06661ed 100644 --- a/libretro-common/include/glsm/glsmsym.h +++ b/libretro-common/include/glsm/glsmsym.h @@ -148,6 +148,7 @@ RETRO_BEGIN_DECLS #define glProgramBinary rglProgramBinary #define glGetProgramBinary rglGetProgramBinary #define glProgramParameteri rglProgramParameteri +#define glTexSubImage2D rglTexSubImage2D void rglProgramParameteri( GLuint program, GLenum pname, @@ -354,6 +355,15 @@ void rglTexImage2DMultisample( GLenum target, GLsizei height, GLboolean fixedsamplelocations); void rglMemoryBarrier( GLbitfield barriers); +void rglTexSubImage2D( GLenum target, + GLint level, + GLint xoffset, + GLint yoffset, + GLsizei width, + GLsizei height, + GLenum format, + GLenum type, + const GLvoid * pixels); RETRO_END_DECLS From f4553505a40db44d51f4c8b571d24ff3d3e805c7 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 7 May 2016 00:07:49 +0200 Subject: [PATCH 207/498] (GLSM) Update --- libretro-common/glsm/glsm.c | 34 ++++++---------------------------- 1 file changed, 6 insertions(+), 28 deletions(-) diff --git a/libretro-common/glsm/glsm.c b/libretro-common/glsm/glsm.c index 28a6a3b2e2..a4da922ac2 100644 --- a/libretro-common/glsm/glsm.c +++ b/libretro-common/glsm/glsm.c @@ -20,10 +20,10 @@ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +#include #include #include - struct gl_cached_state { struct @@ -177,8 +177,6 @@ struct gl_cached_state }; static glsm_framebuffer_lock glsm_fb_lock = NULL; -static glsm_imm_vbo_draw imm_vbo_draw = NULL; -static glsm_imm_vbo_draw imm_vbo_disable = NULL; static struct retro_hw_render_callback hw_render; static struct gl_cached_state gl_state; @@ -189,7 +187,7 @@ static struct gl_cached_state gl_state; * Core in: * OpenGL : 1.0 */ -GLenum GLenum rglGetError(void) +GLenum rglGetError(void) { return glGetError(); } @@ -1600,6 +1598,7 @@ void rglCopyImageSubData( GLuint srcName, #if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) && defined(HAVE_OPENGLES32) glCopyImageSubData(srcName, srcTarget, + srcLevel, srcX, srcY, srcZ, @@ -1901,21 +1900,10 @@ static bool glsm_state_ctx_init(void *data) hw_render.bottom_left_origin = true; hw_render.cache_context = true; - imm_vbo_draw = NULL; - imm_vbo_disable = NULL; - - if (params->imm_vbo_draw != NULL) - imm_vbo_draw = params->imm_vbo_draw; - if (params->imm_vbo_disable != NULL) - imm_vbo_disable = params->imm_vbo_disable; - glsm_fb_lock = dummy_framebuffer_lock; if (params->framebuffer_lock != NULL) glsm_fb_lock = params->framebuffer_lock; - if (imm_vbo_draw != NULL && imm_vbo_disable != NULL) - glsm_ctl(GLSM_CTL_SET_IMM_VBO, NULL); - if (!params->environ_cb(RETRO_ENVIRONMENT_SET_HW_RENDER, &hw_render)) return false; @@ -1929,29 +1917,19 @@ GLuint glsm_get_current_framebuffer(void) bool glsm_ctl(enum glsm_state_ctl state, void *data) { - static bool imm_vbo_enable = false; - switch (state) { case GLSM_CTL_IS_FRAMEBUFFER_LOCKED: return glsm_fb_lock(NULL); case GLSM_CTL_IMM_VBO_DRAW: - if (imm_vbo_draw == NULL || !imm_vbo_enable) - return false; - imm_vbo_draw(NULL); - break; + return false; case GLSM_CTL_IMM_VBO_DISABLE: - if (imm_vbo_disable == NULL || !imm_vbo_enable) - return false; - imm_vbo_disable(NULL); - break; + return false; case GLSM_CTL_IS_IMM_VBO: - return imm_vbo_enable; + return false; case GLSM_CTL_SET_IMM_VBO: - imm_vbo_enable = true; break; case GLSM_CTL_UNSET_IMM_VBO: - imm_vbo_enable = false; break; case GLSM_CTL_PROC_ADDRESS_GET: { From b38e269215b18a5d5ea4c3450e4b21d711ecdda3 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 7 May 2016 01:32:34 +0200 Subject: [PATCH 208/498] (GLSM) Some buildfixes --- libretro-common/glsm/glsm.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/libretro-common/glsm/glsm.c b/libretro-common/glsm/glsm.c index a4da922ac2..a1d8fcbdb0 100644 --- a/libretro-common/glsm/glsm.c +++ b/libretro-common/glsm/glsm.c @@ -206,10 +206,13 @@ void rglClear(GLbitfield mask) * * Core in: * OpenGL : 1.0 + * OpenGLES : N/A */ void rglPolygonMode(GLenum face, GLenum mode) { +#ifndef HAVE_OPENGLES glPolygonMode(face, mode); +#endif } void rglTexSubImage2D( @@ -638,7 +641,7 @@ void rglFramebufferTexture2D(GLenum target, GLenum attachment, void rglFramebufferTexture(GLenum target, GLenum attachment, GLuint texture, GLint level) { -#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) && defined(HAVE_OPENGLES32) +#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) && defined(HAVE_OPENGLES_3_2) glFramebufferTexture(target, attachment, texture, level); #endif } @@ -1138,7 +1141,7 @@ void rglVertexAttribLPointer( GLsizei stride, const GLvoid * pointer) { -#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) && defined(HAVE_OPENGLES3) +#if defined(HAVE_OPENGL) glVertexAttribLPointer(index, size, type, stride, pointer); #endif } @@ -1595,7 +1598,7 @@ void rglCopyImageSubData( GLuint srcName, GLsizei srcHeight, GLsizei srcDepth) { -#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) && defined(HAVE_OPENGLES32) +#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) && defined(HAVE_OPENGLES_3_2) glCopyImageSubData(srcName, srcTarget, srcLevel, From afd56893f5923b52f0c57d77ac4ba9be65d8756d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 7 May 2016 03:31:24 +0200 Subject: [PATCH 209/498] video_texture_image - cleanups --- gfx/video_texture_image.c | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/gfx/video_texture_image.c b/gfx/video_texture_image.c index 2812dd0b6b..865c996102 100644 --- a/gfx/video_texture_image.c +++ b/gfx/video_texture_image.c @@ -33,6 +33,13 @@ #include "../general.h" +enum video_image_format +{ + IMAGE_FORMAT_NONE = 0, + IMAGE_FORMAT_TGA, + IMAGE_FORMAT_PNG +}; + bool video_texture_image_set_color_shifts( unsigned *r_shift, unsigned *g_shift, unsigned *b_shift, unsigned *a_shift) @@ -213,24 +220,40 @@ static bool video_texture_image_load_tga( return ret; } +enum video_image_format video_texture_image_get_type(const char *path) +{ + if (strstr(path, ".tga")) + return IMAGE_FORMAT_TGA; + if (strstr(path, ".png")) + return IMAGE_FORMAT_PNG; + return IMAGE_FORMAT_NONE; +} bool video_texture_image_load(struct texture_image *out_img, const char *path) { unsigned r_shift, g_shift, b_shift, a_shift; + enum video_image_format fmt = video_texture_image_get_type(path); video_texture_image_set_color_shifts(&r_shift, &g_shift, &b_shift, &a_shift); - if (strstr(path, ".tga")) - return video_texture_image_load_tga(path, out_img, - a_shift, r_shift, g_shift, b_shift); - + switch (fmt) + { + case IMAGE_FORMAT_TGA: + return video_texture_image_load_tga(path, out_img, + a_shift, r_shift, g_shift, b_shift); + case IMAGE_FORMAT_PNG: #ifdef HAVE_RPNG - if (strstr(path, ".png")) - return video_texture_image_load_png(path, out_img, - a_shift, r_shift, g_shift, b_shift); + return video_texture_image_load_png(path, out_img, + a_shift, r_shift, g_shift, b_shift); +#else + break; #endif + default: + case IMAGE_FORMAT_NONE: + break; + } return false; } From 9ac9ed4b368b8b7bd38343ef4c0fd1c2a29370e7 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 7 May 2016 03:35:31 +0200 Subject: [PATCH 210/498] Cleanups --- gfx/video_texture_image.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/gfx/video_texture_image.c b/gfx/video_texture_image.c index 865c996102..fe66c575e1 100644 --- a/gfx/video_texture_image.c +++ b/gfx/video_texture_image.c @@ -25,6 +25,7 @@ #include #include +#include #ifdef HAVE_RPNG #include #endif @@ -153,10 +154,8 @@ static bool video_texture_image_load_png( unsigned a_shift, unsigned r_shift, unsigned g_shift, unsigned b_shift) { - bool ret = rpng_load_image_argb(path, - &out_img->pixels, &out_img->width, &out_img->height); - - if (!ret) + if (!rpng_load_image_argb(path, + &out_img->pixels, &out_img->width, &out_img->height)) { out_img->pixels = NULL; out_img->width = out_img->height = 0; @@ -167,13 +166,10 @@ static bool video_texture_image_load_png( a_shift, out_img); #ifdef GEKKO - if (ret) + if (!video_texture_image_rpng_gx_convert_texture32(out_img)) { - if (!video_texture_image_rpng_gx_convert_texture32(out_img)) - { - video_texture_image_free(out_img); - return false; - } + video_texture_image_free(out_img); + return false; } #endif From b8644536d2f4a644469fd2630cffbfe5503e334a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 7 May 2016 04:04:09 +0200 Subject: [PATCH 211/498] (video_texture_image.c) Cleanups - we use nbio now in video_texture_image_load for both TGA and PNG, and we remove the file I/O based RPNG function --- gfx/video_texture_image.c | 137 ++++++++++++------- libretro-common/formats/png/rpng.c | 73 ---------- libretro-common/formats/png/test/rpng_test.c | 72 ++++++++++ 3 files changed, 161 insertions(+), 121 deletions(-) diff --git a/gfx/video_texture_image.c b/gfx/video_texture_image.c index fe66c575e1..3824b865d9 100644 --- a/gfx/video_texture_image.c +++ b/gfx/video_texture_image.c @@ -45,14 +45,20 @@ bool video_texture_image_set_color_shifts( unsigned *r_shift, unsigned *g_shift, unsigned *b_shift, unsigned *a_shift) { - bool use_rgba = video_driver_ctl( - RARCH_DISPLAY_CTL_SUPPORTS_RGBA, NULL); *a_shift = 24; - *r_shift = use_rgba ? 0 : 16; + *r_shift = 16; *g_shift = 8; - *b_shift = use_rgba ? 16 : 0; + *b_shift = 0; - return use_rgba; + if (video_driver_ctl( + RARCH_DISPLAY_CTL_SUPPORTS_RGBA, NULL)) + { + *r_shift = 0; + *b_shift = 16; + return true; + } + + return false; } bool video_texture_image_color_convert(unsigned r_shift, @@ -109,6 +115,7 @@ bool video_texture_image_color_convert(unsigned r_shift, static bool video_texture_image_rpng_gx_convert_texture32( struct texture_image *image) { + int ret; unsigned tmp_pitch, width2, i; const uint16_t *src = NULL; uint16_t *dst = NULL; @@ -149,18 +156,36 @@ static bool video_texture_image_rpng_gx_convert_texture32( #endif static bool video_texture_image_load_png( - const char *path, + void *ptr, struct texture_image *out_img, unsigned a_shift, unsigned r_shift, unsigned g_shift, unsigned b_shift) { - if (!rpng_load_image_argb(path, - &out_img->pixels, &out_img->width, &out_img->height)) + int ret; + rpng_t *rpng = rpng_alloc(); + + if (!rpng) + goto error; + + if (!rpng_set_buf_ptr(rpng, (uint8_t*)ptr)) + goto error; + + if (!rpng_nbio_load_image_argb_start(rpng)) + goto error; + + while (rpng_nbio_load_image_argb_iterate(rpng)); + + if (!rpng_is_valid(rpng)) + goto error; + + do { - out_img->pixels = NULL; - out_img->width = out_img->height = 0; - return false; - } + ret = rpng_nbio_load_image_argb_process(rpng, &out_img->pixels, &out_img->width, + &out_img->height); + }while(ret == IMAGE_PROCESS_NEXT); + + if (ret == IMAGE_PROCESS_ERROR || ret == IMAGE_PROCESS_ERROR_END) + goto error; video_texture_image_color_convert(r_shift, g_shift, b_shift, a_shift, out_img); @@ -169,11 +194,21 @@ static bool video_texture_image_load_png( if (!video_texture_image_rpng_gx_convert_texture32(out_img)) { video_texture_image_free(out_img); - return false; + goto error; } #endif + rpng_nbio_load_image_free(rpng); + return true; + +error: + out_img->pixels = NULL; + out_img->width = 0; + out_img->height = 0; + if (rpng) + rpng_nbio_load_image_free(rpng); + return false; } #endif @@ -188,35 +223,7 @@ void video_texture_image_free(struct texture_image *img) memset(img, 0, sizeof(*img)); } -static bool video_texture_image_load_tga( - const char *path, - struct texture_image *out_img, - unsigned a_shift, unsigned r_shift, - unsigned g_shift, unsigned b_shift) -{ - ssize_t len; - void *raw_buf = NULL; - uint8_t *buf = NULL; - bool ret = filestream_read_file(path, &raw_buf, &len); - - if (!ret || len < 0) - { - RARCH_ERR("Failed to read image: %s.\n", path); - return false; - } - - buf = (uint8_t*)raw_buf; - - ret = rtga_image_load_shift(buf, out_img, - a_shift, r_shift, g_shift, b_shift); - - if (buf) - free(buf); - - return ret; -} - -enum video_image_format video_texture_image_get_type(const char *path) +static enum video_image_format video_texture_image_get_type(const char *path) { if (strstr(path, ".tga")) return IMAGE_FORMAT_TGA; @@ -228,28 +235,62 @@ enum video_image_format video_texture_image_get_type(const char *path) bool video_texture_image_load(struct texture_image *out_img, const char *path) { + size_t file_len; unsigned r_shift, g_shift, b_shift, a_shift; + struct nbio_t *handle = NULL; + void *ptr = NULL; enum video_image_format fmt = video_texture_image_get_type(path); video_texture_image_set_color_shifts(&r_shift, &g_shift, &b_shift, &a_shift); + switch (fmt) + { + case IMAGE_FORMAT_NONE: + break; + default: + handle = (struct nbio_t*)nbio_open(path, NBIO_READ); + if (!handle) + goto error; + nbio_begin_read(handle); + + while (!nbio_iterate(handle)); + + ptr = nbio_get_ptr(handle, &file_len); + + if (!ptr) + goto error; + break; + } + switch (fmt) { case IMAGE_FORMAT_TGA: - return video_texture_image_load_tga(path, out_img, - a_shift, r_shift, g_shift, b_shift); + if (rtga_image_load_shift(ptr, out_img, + a_shift, r_shift, g_shift, b_shift)) + goto success; + break; case IMAGE_FORMAT_PNG: #ifdef HAVE_RPNG - return video_texture_image_load_png(path, out_img, - a_shift, r_shift, g_shift, b_shift); -#else - break; + if (video_texture_image_load_png(ptr, out_img, + a_shift, r_shift, g_shift, b_shift)) + goto success; #endif + break; default: case IMAGE_FORMAT_NONE: break; } +error: + if (handle) + nbio_free(handle); + return false; + +success: + if (handle) + nbio_free(handle); + + return true; } diff --git a/libretro-common/formats/png/rpng.c b/libretro-common/formats/png/rpng.c index d90711ff65..ab92674082 100644 --- a/libretro-common/formats/png/rpng.c +++ b/libretro-common/formats/png/rpng.c @@ -30,7 +30,6 @@ #endif #include -#include #include #include @@ -1037,75 +1036,3 @@ rpng_t *rpng_alloc(void) return NULL; return rpng; } - -bool rpng_load_image_argb(const char *path, uint32_t **data, - unsigned *width, unsigned *height) -{ - int retval; - size_t file_len; - bool ret = true; - rpng_t *rpng = NULL; - void *ptr = NULL; - struct nbio_t* handle = (struct nbio_t*)nbio_open(path, NBIO_READ); - - if (!handle) - goto end; - - nbio_begin_read(handle); - - while (!nbio_iterate(handle)); - - ptr = nbio_get_ptr(handle, &file_len); - - if (!ptr) - { - ret = false; - goto end; - } - - rpng = rpng_alloc(); - - if (!rpng) - { - ret = false; - goto end; - } - - if (!rpng_set_buf_ptr(rpng, (uint8_t*)ptr)) - { - ret = false; - goto end; - } - - if (!rpng_nbio_load_image_argb_start(rpng)) - { - ret = false; - goto end; - } - - while (rpng_nbio_load_image_argb_iterate(rpng)); - - if (!rpng_is_valid(rpng)) - { - ret = false; - goto end; - } - - do - { - retval = rpng_nbio_load_image_argb_process(rpng, data, width, height); - }while(retval == PNG_PROCESS_NEXT); - - if (retval == PNG_PROCESS_ERROR || retval == PNG_PROCESS_ERROR_END) - ret = false; - -end: - if (handle) - nbio_free(handle); - if (rpng) - rpng_nbio_load_image_free(rpng); - rpng = NULL; - if (!ret) - free(*data); - return ret; -} diff --git a/libretro-common/formats/png/test/rpng_test.c b/libretro-common/formats/png/test/rpng_test.c index bb457f9065..5642eab9ac 100644 --- a/libretro-common/formats/png/test/rpng_test.c +++ b/libretro-common/formats/png/test/rpng_test.c @@ -31,6 +31,78 @@ #include #include +static bool rpng_load_image_argb(const char *path, uint32_t **data, + unsigned *width, unsigned *height) +{ + int retval; + size_t file_len; + bool ret = true; + rpng_t *rpng = NULL; + void *ptr = NULL; + struct nbio_t* handle = (struct nbio_t*)nbio_open(path, NBIO_READ); + + if (!handle) + goto end; + + nbio_begin_read(handle); + + while (!nbio_iterate(handle)); + + ptr = nbio_get_ptr(handle, &file_len); + + if (!ptr) + { + ret = false; + goto end; + } + + rpng = rpng_alloc(); + + if (!rpng) + { + ret = false; + goto end; + } + + if (!rpng_set_buf_ptr(rpng, (uint8_t*)ptr)) + { + ret = false; + goto end; + } + + if (!rpng_nbio_load_image_argb_start(rpng)) + { + ret = false; + goto end; + } + + while (rpng_nbio_load_image_argb_iterate(rpng)); + + if (!rpng_is_valid(rpng)) + { + ret = false; + goto end; + } + + do + { + retval = rpng_nbio_load_image_argb_process(rpng, data, width, height); + }while(retval == PNG_PROCESS_NEXT); + + if (retval == PNG_PROCESS_ERROR || retval == PNG_PROCESS_ERROR_END) + ret = false; + +end: + if (handle) + nbio_free(handle); + if (rpng) + rpng_nbio_load_image_free(rpng); + rpng = NULL; + if (!ret) + free(*data); + return ret; +} + static int test_rpng(const char *in_path) { #ifdef HAVE_IMLIB2 From c192b8d61fc384373c24dc8329012d48de6b7849 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 7 May 2016 04:07:27 +0200 Subject: [PATCH 212/498] (video_texture_image.c) Cleanup --- gfx/video_texture_image.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/gfx/video_texture_image.c b/gfx/video_texture_image.c index 3824b865d9..80edc15ef9 100644 --- a/gfx/video_texture_image.c +++ b/gfx/video_texture_image.c @@ -162,21 +162,22 @@ static bool video_texture_image_load_png( unsigned g_shift, unsigned b_shift) { int ret; + bool success = false; rpng_t *rpng = rpng_alloc(); if (!rpng) - goto error; + goto end; if (!rpng_set_buf_ptr(rpng, (uint8_t*)ptr)) - goto error; + goto end; if (!rpng_nbio_load_image_argb_start(rpng)) - goto error; + goto end; while (rpng_nbio_load_image_argb_iterate(rpng)); if (!rpng_is_valid(rpng)) - goto error; + goto end; do { @@ -185,7 +186,7 @@ static bool video_texture_image_load_png( }while(ret == IMAGE_PROCESS_NEXT); if (ret == IMAGE_PROCESS_ERROR || ret == IMAGE_PROCESS_ERROR_END) - goto error; + goto end; video_texture_image_color_convert(r_shift, g_shift, b_shift, a_shift, out_img); @@ -194,21 +195,17 @@ static bool video_texture_image_load_png( if (!video_texture_image_rpng_gx_convert_texture32(out_img)) { video_texture_image_free(out_img); - goto error; + goto end; } #endif - rpng_nbio_load_image_free(rpng); + success = true; - return true; - -error: - out_img->pixels = NULL; - out_img->width = 0; - out_img->height = 0; +end: if (rpng) rpng_nbio_load_image_free(rpng); - return false; + + return success; } #endif @@ -283,6 +280,9 @@ bool video_texture_image_load(struct texture_image *out_img, } error: + out_img->pixels = NULL; + out_img->width = 0; + out_img->height = 0; if (handle) nbio_free(handle); From 268be70fe858b14e5f9fefdee5a7ba03edea239f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 7 May 2016 04:15:39 +0200 Subject: [PATCH 213/498] Cleanups --- libretro-common/formats/png/test/rpng_test.c | 5 +++-- libretro-common/include/formats/rpng.h | 3 --- libretro-common/streams/file_stream.c | 8 -------- 3 files changed, 3 insertions(+), 13 deletions(-) diff --git a/libretro-common/formats/png/test/rpng_test.c b/libretro-common/formats/png/test/rpng_test.c index 5642eab9ac..57d37df356 100644 --- a/libretro-common/formats/png/test/rpng_test.c +++ b/libretro-common/formats/png/test/rpng_test.c @@ -30,6 +30,7 @@ #include #include +#include static bool rpng_load_image_argb(const char *path, uint32_t **data, unsigned *width, unsigned *height) @@ -87,9 +88,9 @@ static bool rpng_load_image_argb(const char *path, uint32_t **data, do { retval = rpng_nbio_load_image_argb_process(rpng, data, width, height); - }while(retval == PNG_PROCESS_NEXT); + }while(retval == IMAGE_PROCESS_NEXT); - if (retval == PNG_PROCESS_ERROR || retval == PNG_PROCESS_ERROR_END) + if (retval == IMAGE_PROCESS_ERROR || retval == IMAGE_PROCESS_ERROR_END) ret = false; end: diff --git a/libretro-common/include/formats/rpng.h b/libretro-common/include/formats/rpng.h index 6141e0f9db..94db62932f 100644 --- a/libretro-common/include/formats/rpng.h +++ b/libretro-common/include/formats/rpng.h @@ -35,9 +35,6 @@ RETRO_BEGIN_DECLS typedef struct rpng rpng_t; -bool rpng_load_image_argb(const char *path, uint32_t **data, - unsigned *width, unsigned *height); - rpng_t *rpng_nbio_load_image_argb_init(const char *path); bool rpng_is_valid(rpng_t *rpng); diff --git a/libretro-common/streams/file_stream.c b/libretro-common/streams/file_stream.c index d6ee69691e..d02c8ae616 100644 --- a/libretro-common/streams/file_stream.c +++ b/libretro-common/streams/file_stream.c @@ -477,11 +477,7 @@ int filestream_read_file(const char *path, void **buf, ssize_t *len) if (!file) { -#if __STDC_VERSION__ >= 199901L - fprintf(stderr, "%s: Failed to open %s: %s\n", __FUNCTION__, path, strerror(errno)); -#else fprintf(stderr, "Failed to open %s: %s\n", path, strerror(errno)); -#endif goto error; } @@ -502,11 +498,7 @@ int filestream_read_file(const char *path, void **buf, ssize_t *len) ret = filestream_read(file, content_buf, content_buf_size); if (ret < 0) { -#if __STDC_VERSION__ >= 199901L - fprintf(stderr, "%s: Failed to read %s: %s\n", __FUNCTION__, path, strerror(errno)); -#else fprintf(stderr, "Failed to read %s: %s\n", path, strerror(errno)); -#endif goto error; } From 857a6ac4797b3e588d87c12e4eb398dc137a6f29 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 7 May 2016 04:17:33 +0200 Subject: [PATCH 214/498] Remove streams/file_stream.h --- gfx/video_texture_image.c | 1 - 1 file changed, 1 deletion(-) diff --git a/gfx/video_texture_image.c b/gfx/video_texture_image.c index 80edc15ef9..a9e7e934cb 100644 --- a/gfx/video_texture_image.c +++ b/gfx/video_texture_image.c @@ -30,7 +30,6 @@ #include #endif #include -#include #include "../general.h" From 0ab61a24286db0d71634dc3a8de356afffea2822 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 7 May 2016 04:33:54 +0200 Subject: [PATCH 215/498] (libretro-common) Add rjpeg --- Makefile.common | 3 +- griffin/griffin.c | 1 + libretro-common/formats/jpeg/rjpeg.c | 842 +++++++++++++++++++++++++++ 3 files changed, 845 insertions(+), 1 deletion(-) create mode 100644 libretro-common/formats/jpeg/rjpeg.c diff --git a/Makefile.common b/Makefile.common index 2dd16838ca..b69e1520df 100644 --- a/Makefile.common +++ b/Makefile.common @@ -905,7 +905,8 @@ ifeq ($(HAVE_RPNG), 1) OBJ += libretro-common/formats/png/rpng.o \ libretro-common/formats/png/rpng_encode.o endif -OBJ += libretro-common/formats/bmp/rbmp_encode.o \ +OBJ += libretro-common/formats/jpeg/rjpeg.o \ + libretro-common/formats/bmp/rbmp_encode.o \ libretro-common/formats/tga/rtga.o \ libretro-common/formats/json/jsonsax.o diff --git a/griffin/griffin.c b/griffin/griffin.c index 372ed7e00b..b21c90f1fe 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -231,6 +231,7 @@ VIDEO IMAGE #include "../libretro-common/formats/png/rpng.c" #include "../libretro-common/formats/png/rpng_encode.c" #endif +#include "../libretro-common/formats/jpeg/rjpeg.c" #include "../libretro-common/formats/bmp/rbmp_encode.c" /*============================================================ diff --git a/libretro-common/formats/jpeg/rjpeg.c b/libretro-common/formats/jpeg/rjpeg.c new file mode 100644 index 0000000000..46cdc716dd --- /dev/null +++ b/libretro-common/formats/jpeg/rjpeg.c @@ -0,0 +1,842 @@ +#include +#include +#include + +#include + +#define RJPEG_DECODE_SOF 0xC0 +#define RJPEG_DECODE_DHT 0xC4 +#define RJPEG_DECODE_DQT 0xDB +#define RJPEG_DECODE_DRI 0xDD +#define RJPEG_DECODE_SCAN 0xDA +#define RJPEG_DECODE_SKIP_MARKER 0xFE + +#define CF(x) rjpeg_clip(((x) + 64) >> 7) +#define JPEG_DECODER_THROW(ctx, e) do { ctx->error = e; return; } while (0) + +enum rjpeg_decode_result +{ + RJPEG_OK = 0, + RJPEG_NOT_A_FILE, + RJPEG_UNSUPPORTED, + RJPEG_OOM, + RJPEG_INTERNAL_ERROR, + RJPEG_SYNTAX_ERROR, + RJPEG_INTERNAL_FINISHED +}; + +enum +{ + CF4A = (-9), + CF4B = (111), + CF4C = (29), + CF4D = (-3), + CF3A = (28), + CF3B = (109), + CF3C = (-9), + CF3X = (104), + CF3Y = (27), + CF3Z = (-3), + CF2A = (139), + CF2B = (-11), +}; + +enum +{ + W1 = 2841, + W2 = 2676, + W3 = 2408, + W5 = 1609, + W6 = 1108, + W7 = 565, +}; + +struct rjpeg_vlc_code +{ + uint8_t bits; + uint8_t code; +}; + +struct rjpeg_component +{ + int cid; + int ssx, ssy; + int width, height; + int stride; + int qtsel; + int actabsel; + int dctabsel; + int dcpred; + uint8_t *pixels; +}; + +struct rjpeg_data +{ + enum rjpeg_decode_result error; + const uint8_t *pos; + int size; + int length; + int width, height; + int mbwidth; + int mbheight; + int mbsizex; + int mbsizey; + int ncomp; + struct rjpeg_component comp[3]; + int qtused; + int qtavail; + uint8_t qtab[4][64]; + struct rjpeg_vlc_code vlctab[4][65536]; + int buf, bufbits; + int block[64]; + int rstinterval; + uint8_t *rgb; + char ZZ[64]; +}; + +static INLINE uint8_t rjpeg_clip(const int x) +{ + if (x < 0) + return 0; + return ((x > 0xFF) ? 0xFF : (unsigned char) x); +} + +static void rjpeg_skip(struct rjpeg_data *ctx, int count) +{ + ctx->pos += count; + ctx->size -= count; + ctx->length -= count; + if (ctx->size < 0) + ctx->error = RJPEG_SYNTAX_ERROR; +} + +static INLINE uint16_t rjpeg_decode_16(const uint8_t *pos) +{ + return (pos[0] << 8) | pos[1]; +} + +static INLINE void rjpeg_decode_length(struct rjpeg_data *ctx) +{ + if (ctx->size < 2) + JPEG_DECODER_THROW(ctx, RJPEG_SYNTAX_ERROR); + ctx->length = rjpeg_decode_16(ctx->pos); + if (ctx->length > ctx->size) + JPEG_DECODER_THROW(ctx, RJPEG_SYNTAX_ERROR); + rjpeg_skip(ctx, 2); +} + +static void rjpeg_decode_dqt(struct rjpeg_data *ctx) +{ + unsigned char *t = NULL; + + rjpeg_decode_length(ctx); + + while (ctx->length >= 65) + { + int i = ctx->pos[0]; + if (i & 0xFC) + JPEG_DECODER_THROW(ctx, RJPEG_SYNTAX_ERROR); + ctx->qtavail |= 1 << i; + t = &ctx->qtab[i][0]; + for (i = 0; i < 64; ++i) + t[i] = ctx->pos[i + 1]; + rjpeg_skip(ctx, 65); + } + + if (ctx->length) + JPEG_DECODER_THROW(ctx, RJPEG_SYNTAX_ERROR); +} + +static void rjpeg_decode_dri(struct rjpeg_data *ctx) +{ + rjpeg_decode_length(ctx); + if (ctx->length < 2) + JPEG_DECODER_THROW(ctx, RJPEG_SYNTAX_ERROR); + ctx->rstinterval = rjpeg_decode_16(ctx->pos); + rjpeg_skip(ctx, ctx->length); +} + +static void rjpeg_decode_dht(struct rjpeg_data *ctx) +{ + unsigned char counts[16]; + struct rjpeg_vlc_code *vlc = NULL; + + rjpeg_decode_length(ctx); + + while (ctx->length >= 17) + { + int codelen; + int spread = 65536; + int remain = 65536; + int i = ctx->pos[0]; + + if (i & 0xEC) + JPEG_DECODER_THROW(ctx, RJPEG_SYNTAX_ERROR); + + if (i & 0x02) + JPEG_DECODER_THROW(ctx, RJPEG_UNSUPPORTED); + + i = (i | (i >> 3)) & 3; /* combined DC/AC + tableid value */ + for (codelen = 1; codelen <= 16; ++codelen) + counts[codelen - 1] = ctx->pos[codelen]; + rjpeg_skip(ctx, 17); + vlc = &ctx->vlctab[i][0]; + for (codelen = 1; codelen <= 16; ++codelen) + { + int currcnt; + + spread >>= 1; + currcnt = counts[codelen - 1]; + if (!currcnt) + continue; + + if (ctx->length < currcnt) + JPEG_DECODER_THROW(ctx, RJPEG_SYNTAX_ERROR); + remain -= currcnt << (16 - codelen); + + if (remain < 0) + JPEG_DECODER_THROW(ctx, RJPEG_SYNTAX_ERROR); + + for (i = 0; i < currcnt; ++i) + { + int j; + register unsigned char code = ctx->pos[i]; + + for (j = spread; j; --j) + { + vlc->bits = (unsigned char) codelen; + vlc->code = code; + ++vlc; + } + } + rjpeg_skip(ctx, currcnt); + } + + while (remain--) + { + vlc->bits = 0; + ++vlc; + } + } + + if (ctx->length) + JPEG_DECODER_THROW(ctx, RJPEG_SYNTAX_ERROR); +} + +static int rjpeg_show_bits(struct rjpeg_data *ctx, int bits) +{ + unsigned char newbyte; + if (!bits) + return 0; + + while (ctx->bufbits < bits) + { + if (ctx->size <= 0) + { + ctx->buf = (ctx->buf << 8) | 0xFF; + ctx->bufbits += 8; + continue; + } + + newbyte = *ctx->pos++; + ctx->size--; + ctx->bufbits += 8; + ctx->buf = (ctx->buf << 8) | newbyte; + if (newbyte == 0xFF) + { + if (ctx->size) + { + unsigned char marker = *ctx->pos++; + ctx->size--; + switch (marker) + { + case 0: + break; + case 0xD9: + ctx->size = 0; + break; + default: + if ((marker & 0xF8) != 0xD0) + ctx->error = RJPEG_SYNTAX_ERROR; + else + { + ctx->buf = (ctx->buf << 8) | marker; + ctx->bufbits += 8; + } + } + } else + ctx->error = RJPEG_SYNTAX_ERROR; + } + } + return (ctx->buf >> (ctx->bufbits - bits)) & ((1 << bits) - 1); +} + +static void rjpeg_skip_bits(struct rjpeg_data *ctx, int bits) +{ + if (ctx->bufbits < bits) + rjpeg_show_bits(ctx, bits); + ctx->bufbits -= bits; +} + +static int rjpeg_get_bits(struct rjpeg_data *ctx, int bits) +{ + int res = rjpeg_show_bits(ctx, bits); + rjpeg_skip_bits(ctx, bits); + return res; +} + +static int rjpeg_get_vlc(struct rjpeg_data *ctx, + struct rjpeg_vlc_code *vlc, unsigned char* code) +{ + int value = rjpeg_show_bits(ctx, 16); + int bits = vlc[value].bits; + + if (!bits) + { + ctx->error = RJPEG_SYNTAX_ERROR; + return 0; + } + + rjpeg_skip_bits(ctx, bits); + value = vlc[value].code; + if (code) + *code = (unsigned char) value; + bits = value & 15; + if (!bits) + return 0; + value = rjpeg_get_bits(ctx, bits); + if (value < (1 << (bits - 1))) + value += ((-1) << bits) + 1; + return value; +} + +static void rjpeg_row_idct(int* blk) +{ + int x0, x1, x2, x3, x4, x5, x6, x7, x8; + if (!((x1 = blk[4] << 11) + | (x2 = blk[6]) + | (x3 = blk[2]) + | (x4 = blk[1]) + | (x5 = blk[7]) + | (x6 = blk[5]) + | (x7 = blk[3]))) + { + unsigned i; + int val = blk[0] << 3; + + for (i = 0; i < 8; i++) + blk[i] = val; + return; + } + + x0 = (blk[0] << 11) + 128; + x8 = W7 * (x4 + x5); + x4 = x8 + (W1 - W7) * x4; + x5 = x8 - (W1 + W7) * x5; + x8 = W3 * (x6 + x7); + x6 = x8 - (W3 - W5) * x6; + x7 = x8 - (W3 + W5) * x7; + x8 = x0 + x1; + x0 -= x1; + x1 = W6 * (x3 + x2); + x2 = x1 - (W2 + W6) * x2; + x3 = x1 + (W2 - W6) * x3; + x1 = x4 + x6; + x4 -= x6; + x6 = x5 + x7; + x5 -= x7; + x7 = x8 + x3; + x8 -= x3; + x3 = x0 + x2; + x0 -= x2; + x2 = (181 * (x4 + x5) + 128) >> 8; + x4 = (181 * (x4 - x5) + 128) >> 8; + blk[0] = (x7 + x1) >> 8; + blk[1] = (x3 + x2) >> 8; + blk[2] = (x0 + x4) >> 8; + blk[3] = (x8 + x6) >> 8; + blk[4] = (x8 - x6) >> 8; + blk[5] = (x0 - x4) >> 8; + blk[6] = (x3 - x2) >> 8; + blk[7] = (x7 - x1) >> 8; +} + +static void rjpeg_col_idct(const int* blk, unsigned char *out, int stride) +{ + int x0, x1, x2, x3, x4, x5, x6, x7, x8; + if (!((x1 = blk[8*4] << 8) + | (x2 = blk[8*6]) + | (x3 = blk[8*2]) + | (x4 = blk[8*1]) + | (x5 = blk[8*7]) + | (x6 = blk[8*5]) + | (x7 = blk[8*3]))) + { + x1 = rjpeg_clip(((blk[0] + 32) >> 6) + 128); + for (x0 = 8; x0; --x0) + { + *out = (unsigned char) x1; + out += stride; + } + return; + } + x0 = (blk[0] << 8) + 8192; + x8 = W7 * (x4 + x5) + 4; + x4 = (x8 + (W1 - W7) * x4) >> 3; + x5 = (x8 - (W1 + W7) * x5) >> 3; + x8 = W3 * (x6 + x7) + 4; + x6 = (x8 - (W3 - W5) * x6) >> 3; + x7 = (x8 - (W3 + W5) * x7) >> 3; + x8 = x0 + x1; + x0 -= x1; + x1 = W6 * (x3 + x2) + 4; + x2 = (x1 - (W2 + W6) * x2) >> 3; + x3 = (x1 + (W2 - W6) * x3) >> 3; + x1 = x4 + x6; + x4 -= x6; + x6 = x5 + x7; + x5 -= x7; + x7 = x8 + x3; + x8 -= x3; + x3 = x0 + x2; + x0 -= x2; + x2 = (181 * (x4 + x5) + 128) >> 8; + x4 = (181 * (x4 - x5) + 128) >> 8; + *out = rjpeg_clip(((x7 + x1) >> 14) + 128); + out += stride; + *out = rjpeg_clip(((x3 + x2) >> 14) + 128); + out += stride; + *out = rjpeg_clip(((x0 + x4) >> 14) + 128); + out += stride; + *out = rjpeg_clip(((x8 + x6) >> 14) + 128); + out += stride; + *out = rjpeg_clip(((x8 - x6) >> 14) + 128); + out += stride; + *out = rjpeg_clip(((x0 - x4) >> 14) + 128); + out += stride; + *out = rjpeg_clip(((x3 - x2) >> 14) + 128); + out += stride; + *out = rjpeg_clip(((x7 - x1) >> 14) + 128); +} + +static INLINE void rjpeg_decode_block( + struct rjpeg_data *ctx, + struct rjpeg_component *c, + unsigned char* out) +{ + unsigned char code; + int coef = 0; + + memset(ctx->block, 0, sizeof(ctx->block)); + + c->dcpred += rjpeg_get_vlc(ctx, &ctx->vlctab[c->dctabsel][0], NULL); + ctx->block[0] = (c->dcpred) * ctx->qtab[c->qtsel][0]; + + do + { + int value = rjpeg_get_vlc(ctx, &ctx->vlctab[c->actabsel][0], &code); + + if (!code) + break; /* EOB */ + + if (!(code & 0x0F) && (code != 0xF0)) + JPEG_DECODER_THROW(ctx, RJPEG_SYNTAX_ERROR); + coef += (code >> 4) + 1; + if (coef > 63) + JPEG_DECODER_THROW(ctx, RJPEG_SYNTAX_ERROR); + ctx->block[(int) ctx->ZZ[coef]] = value * ctx->qtab[c->qtsel][coef]; + } while (coef < 63); + + for (coef = 0; coef < 64; coef += 8) + rjpeg_row_idct(&ctx->block[coef]); + + for (coef = 0; coef < 8; ++coef) + rjpeg_col_idct(&ctx->block[coef], &out[coef], c->stride); +} + + +static INLINE void rjpeg_byte_align(struct rjpeg_data *ctx) +{ + ctx->bufbits &= 0xF8; +} + +static INLINE void rjpeg_skip_marker(struct rjpeg_data *ctx) +{ + rjpeg_decode_length(ctx); + rjpeg_skip(ctx, ctx->length); +} + +static void rjpeg_decode_sof(struct rjpeg_data *ctx) +{ + int i; + int ssxmax = 0; + int ssymax = 0; + struct rjpeg_component *c = NULL; + + rjpeg_decode_length(ctx); + + if (ctx->length < 9) + JPEG_DECODER_THROW(ctx, RJPEG_SYNTAX_ERROR); + if (ctx->pos[0] != 8) + JPEG_DECODER_THROW(ctx, RJPEG_UNSUPPORTED); + ctx->height = rjpeg_decode_16(ctx->pos+1); + ctx->width = rjpeg_decode_16(ctx->pos+3); + ctx->ncomp = ctx->pos[5]; + rjpeg_skip(ctx, 6); + + switch (ctx->ncomp) + { + case 1: + case 3: + break; + default: + JPEG_DECODER_THROW(ctx, RJPEG_UNSUPPORTED); + } + + if (ctx->length < (ctx->ncomp * 3)) + JPEG_DECODER_THROW(ctx, RJPEG_SYNTAX_ERROR); + + for (i = 0, c = ctx->comp; i < ctx->ncomp; ++i, ++c) + { + c->cid = ctx->pos[0]; + if (!(c->ssx = ctx->pos[1] >> 4)) + JPEG_DECODER_THROW(ctx, RJPEG_SYNTAX_ERROR); + if (c->ssx & (c->ssx - 1)) + JPEG_DECODER_THROW(ctx, RJPEG_UNSUPPORTED); /* non-power of two */ + if (!(c->ssy = ctx->pos[1] & 15)) + JPEG_DECODER_THROW(ctx, RJPEG_SYNTAX_ERROR); + if (c->ssy & (c->ssy - 1)) + JPEG_DECODER_THROW(ctx, RJPEG_UNSUPPORTED); /* non-power of two */ + if ((c->qtsel = ctx->pos[2]) & 0xFC) + JPEG_DECODER_THROW(ctx, RJPEG_SYNTAX_ERROR); + rjpeg_skip(ctx, 3); + ctx->qtused |= 1 << c->qtsel; + if (c->ssx > ssxmax) ssxmax = c->ssx; + if (c->ssy > ssymax) ssymax = c->ssy; + } + ctx->mbsizex = ssxmax << 3; + ctx->mbsizey = ssymax << 3; + ctx->mbwidth = (ctx->width + ctx->mbsizex - 1) / ctx->mbsizex; + ctx->mbheight = (ctx->height + ctx->mbsizey - 1) / ctx->mbsizey; + + for (i = 0, c = ctx->comp; i < ctx->ncomp; ++i, ++c) + { + c->width = (ctx->width * c->ssx + ssxmax - 1) / ssxmax; + c->stride = (c->width + 7) & 0x7FFFFFF8; + c->height = (ctx->height * c->ssy + ssymax - 1) / ssymax; + c->stride = ctx->mbwidth * ctx->mbsizex * c->ssx / ssxmax; + if (((c->width < 3) && (c->ssx != ssxmax)) || ((c->height < 3) && (c->ssy != ssymax))) + JPEG_DECODER_THROW(ctx, RJPEG_UNSUPPORTED); + if (!(c->pixels = (unsigned char*)malloc(c->stride * (ctx->mbheight * ctx->mbsizey * c->ssy / ssymax)))) + JPEG_DECODER_THROW(ctx, RJPEG_OOM); + } + + if (ctx->ncomp == 3) + { + ctx->rgb = (unsigned char*)malloc(ctx->width * ctx->height * ctx->ncomp); + if (!ctx->rgb) + JPEG_DECODER_THROW(ctx, RJPEG_OOM); + } + rjpeg_skip(ctx, ctx->length); +} + +static void rjpeg_decode_scan(struct rjpeg_data *ctx) +{ + int i, mbx, mby, sbx, sby; + int rstcount = ctx->rstinterval; + int nextrst = 0; + struct rjpeg_component *c = NULL; + + rjpeg_decode_length(ctx); + + if (ctx->length < (4 + 2 * ctx->ncomp)) + JPEG_DECODER_THROW(ctx, RJPEG_SYNTAX_ERROR); + if (ctx->pos[0] != ctx->ncomp) + JPEG_DECODER_THROW(ctx, RJPEG_UNSUPPORTED); + rjpeg_skip(ctx, 1); + for (i = 0, c = ctx->comp; i < ctx->ncomp; ++i, ++c) + { + if (ctx->pos[0] != c->cid) + JPEG_DECODER_THROW(ctx, RJPEG_SYNTAX_ERROR); + if (ctx->pos[1] & 0xEE) + JPEG_DECODER_THROW(ctx, RJPEG_SYNTAX_ERROR); + c->dctabsel = ctx->pos[1] >> 4; + c->actabsel = (ctx->pos[1] & 1) | 2; + rjpeg_skip(ctx, 2); + } + + if (ctx->pos[0] || (ctx->pos[1] != 63) || ctx->pos[2]) + JPEG_DECODER_THROW(ctx, RJPEG_UNSUPPORTED); + + rjpeg_skip(ctx, ctx->length); + + for (mby = 0; mby < ctx->mbheight; ++mby) + { + for (mbx = 0; mbx < ctx->mbwidth; ++mbx) + { + for (i = 0, c = ctx->comp; i < ctx->ncomp; ++i, ++c) + { + for (sby = 0; sby < c->ssy; ++sby) + { + for (sbx = 0; sbx < c->ssx; ++sbx) + { + rjpeg_decode_block(ctx, c, + &c->pixels[((mby * c->ssy + sby) * c->stride + mbx * c->ssx + sbx) << 3]); + if (ctx->error) + return; + } + } + } + + if (ctx->rstinterval && !(--rstcount)) + { + rjpeg_byte_align(ctx); + i = rjpeg_get_bits(ctx, 16); + if (((i & 0xFFF8) != 0xFFD0) || ((i & 7) != nextrst)) + JPEG_DECODER_THROW(ctx, RJPEG_SYNTAX_ERROR); + nextrst = (nextrst + 1) & 7; + rstcount = ctx->rstinterval; + + for (i = 0; i < 3; ++i) + ctx->comp[i].dcpred = 0; + } + } + } + + ctx->error = RJPEG_INTERNAL_FINISHED; +} + +static void rjpeg_upsample_h(struct rjpeg_data *ctx, struct rjpeg_component *c) +{ + int x, y; + unsigned char *lin = NULL; + unsigned char *lout = NULL; + const int xmax = c->width - 3; + uint8_t *out = (uint8_t*)malloc((c->width * c->height) << 1); + if (!out) + JPEG_DECODER_THROW(ctx, RJPEG_OOM); + lin = c->pixels; + lout = out; + for (y = c->height; y; --y) + { + lout[0] = CF(CF2A * lin[0] + CF2B * lin[1]); + lout[1] = CF(CF3X * lin[0] + CF3Y * lin[1] + CF3Z * lin[2]); + lout[2] = CF(CF3A * lin[0] + CF3B * lin[1] + CF3C * lin[2]); + + for (x = 0; x < xmax; ++x) + { + lout[(x << 1) + 3] = CF(CF4A * lin[x] + CF4B * lin[x + 1] + CF4C * lin[x + 2] + CF4D * lin[x + 3]); + lout[(x << 1) + 4] = CF(CF4D * lin[x] + CF4C * lin[x + 1] + CF4B * lin[x + 2] + CF4A * lin[x + 3]); + } + + lin += c->stride; + lout += c->width << 1; + lout[-3] = CF(CF3A * lin[-1] + CF3B * lin[-2] + CF3C * lin[-3]); + lout[-2] = CF(CF3X * lin[-1] + CF3Y * lin[-2] + CF3Z * lin[-3]); + lout[-1] = CF(CF2A * lin[-1] + CF2B * lin[-2]); + } + c->width <<= 1; + c->stride = c->width; + free(c->pixels); + c->pixels = out; +} + +static void rjpeg_upsample_v(struct rjpeg_data *ctx, struct rjpeg_component *c) +{ + int x; + const int w = c->width, s1 = c->stride, s2 = s1 + s1; + unsigned char *out = (unsigned char*)malloc((c->width * c->height) << 1); + + for (x = 0; x < w; ++x) + { + int y; + unsigned char *cin = &c->pixels[x]; + unsigned char *cout = &out[x]; + + *cout = CF(CF2A * cin[0] + CF2B * cin[s1]); + cout += w; + + *cout = CF(CF3X * cin[0] + CF3Y * cin[s1] + CF3Z * cin[s2]); + cout += w; + + *cout = CF(CF3A * cin[0] + CF3B * cin[s1] + CF3C * cin[s2]); + cout += w; + + cin += s1; + for (y = c->height - 3; y; --y) + { + *cout = CF(CF4A * cin[-s1] + CF4B * cin[0] + CF4C * cin[s1] + CF4D * cin[s2]); + cout += w; + *cout = CF(CF4D * cin[-s1] + CF4C * cin[0] + CF4B * cin[s1] + CF4A * cin[s2]); + cout += w; + cin += s1; + } + cin += s1; + *cout = CF(CF3A * cin[0] + CF3B * cin[-s1] + CF3C * cin[-s2]); + cout += w; + *cout = CF(CF3X * cin[0] + CF3Y * cin[-s1] + CF3Z * cin[-s2]); + cout += w; + *cout = CF(CF2A * cin[0] + CF2B * cin[-s1]); + } + + c->height <<= 1; + c->stride = c->width; + + free(c->pixels); + c->pixels = out; +} + + +static void rjpeg_convert(struct rjpeg_data *ctx) +{ + int i; + struct rjpeg_component *c = NULL; + + for (i = 0, c = ctx->comp; i < ctx->ncomp; ++i, ++c) + { + while ((c->width < ctx->width) || (c->height < ctx->height)) + { + if (c->width < ctx->width) + rjpeg_upsample_h(ctx, c); + + if (ctx->error) + return; + + if (c->height < ctx->height) + rjpeg_upsample_v(ctx, c); + + if (ctx->error) + return; + } + if ((c->width < ctx->width) || (c->height < ctx->height)) + JPEG_DECODER_THROW(ctx, RJPEG_INTERNAL_ERROR); + } + + if (ctx->ncomp == 3) + { + /* convert to RGB */ + int x, yy; + unsigned char *prgb = ctx->rgb; + const unsigned char *py = ctx->comp[0].pixels; + const unsigned char *pcb = ctx->comp[1].pixels; + const unsigned char *pcr = ctx->comp[2].pixels; + + for (yy = ctx->height; yy; --yy) + { + for (x = 0; x < ctx->width; ++x) + { + register int y = py[x] << 8; + register int cb = pcb[x] - 128; + register int cr = pcr[x] - 128; + *prgb++ = rjpeg_clip((y + 359 * cr + 128) >> 8); + *prgb++ = rjpeg_clip((y - 88 * cb - 183 * cr + 128) >> 8); + *prgb++ = rjpeg_clip((y + 454 * cb + 128) >> 8); + } + py += ctx->comp[0].stride; + pcb += ctx->comp[1].stride; + pcr += ctx->comp[2].stride; + } + } + else if (ctx->comp[0].width != ctx->comp[0].stride) + { + /* grayscale -> only remove stride */ + int y; + unsigned char *pin = &ctx->comp[0].pixels[ctx->comp[0].stride]; + unsigned char *pout = &ctx->comp[0].pixels[ctx->comp[0].width]; + + for (y = ctx->comp[0].height - 1; y; --y) + { + memcpy(pout, pin, ctx->comp[0].width); + pin += ctx->comp[0].stride; + pout += ctx->comp[0].width; + } + ctx->comp[0].stride = ctx->comp[0].width; + } +} + + +enum rjpeg_decode_result rjpeg_decode( + struct rjpeg_data *ctx, + const unsigned char* jpeg, + const int size) +{ + ctx->pos = (const unsigned char*) jpeg; + ctx->size = size & 0x7FFFFFFF; + + if (ctx->size < 2) + return RJPEG_NOT_A_FILE; + if ((ctx->pos[0] ^ 0xFF) | (ctx->pos[1] ^ 0xD8)) + return RJPEG_NOT_A_FILE; + + rjpeg_skip(ctx, 2); + + while (!ctx->error) + { + if ((ctx->size < 2) || (ctx->pos[0] != 0xFF)) + return RJPEG_SYNTAX_ERROR; + + rjpeg_skip(ctx, 2); + + switch (ctx->pos[-1]) + { + case RJPEG_DECODE_SOF: + rjpeg_decode_sof(ctx); + break; + case RJPEG_DECODE_DHT: + rjpeg_decode_dht(ctx); + break; + case RJPEG_DECODE_DQT: + rjpeg_decode_dqt(ctx); + break; + case RJPEG_DECODE_DRI: + rjpeg_decode_dri(ctx); + break; + case RJPEG_DECODE_SCAN: + rjpeg_decode_scan(ctx); + break; + case RJPEG_DECODE_SKIP_MARKER: + rjpeg_skip_marker(ctx); + break; + default: + if ((ctx->pos[-1] & 0xF0) != 0xE0) + return RJPEG_UNSUPPORTED; + rjpeg_skip_marker(ctx); + break; + } + } + if (ctx->error != RJPEG_INTERNAL_FINISHED) + return ctx->error; + + ctx->error = RJPEG_OK; + rjpeg_convert(ctx); + + return RJPEG_OK; +} + +struct rjpeg_data *rjpeg_new(const uint8_t* data, size_t size) +{ + char temp[64] = { 0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, + 11, 4, 5, 12, 19, 26, 33, 40, 48, 41, 34, 27, 20, 13, 6, 7, 14, 21, 28, 35, + 42, 49, 56, 57, 50, 43, 36, 29, 22, 15, 23, 30, 37, 44, 51, 58, 59, 52, 45, + 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63 }; + struct rjpeg_data *ctx = (struct rjpeg_data*)calloc(1, sizeof(*ctx)); + + if (!ctx) + return NULL; + + memcpy(ctx->ZZ, temp, sizeof(ctx->ZZ)); + rjpeg_decode(ctx, data, size); + + return ctx; +} + +void rjpeg_free(struct rjpeg_data *ctx) +{ + int i; + + for (i = 0; i < 3; ++i) + if (ctx->comp[i].pixels) + free((void*) ctx->comp[i].pixels); + if (ctx->rgb) + free((void*)ctx->rgb); +} From 512753621732672f15ff52b03767f17683249468 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 7 May 2016 04:42:18 +0200 Subject: [PATCH 216/498] (libretro-common) Expand GLSM --- libretro-common/glsm/glsm.c | 79 +++++++++++++++++++++----- libretro-common/include/glsm/glsmsym.h | 2 + 2 files changed, 66 insertions(+), 15 deletions(-) diff --git a/libretro-common/glsm/glsm.c b/libretro-common/glsm/glsm.c index a1d8fcbdb0..7d650c7b18 100644 --- a/libretro-common/glsm/glsm.c +++ b/libretro-common/glsm/glsm.c @@ -805,7 +805,7 @@ void rglProgramParameteri( GLuint program, GLenum pname, GLint value) { -#if !defined(HAVE_OPENGLES) || defined(HAVE_OPENGLES) && (defined(HAVE_OPENGLES3) || defined(HAVE_OPENGLES31)) +#if !defined(HAVE_OPENGLES) || defined(HAVE_OPENGLES) && (defined(HAVE_OPENGLES3) || defined(HAVE_OPENGLES_3_1)) glProgramParameteri(program, pname, value); #else printf("WARNING! Not implemented.\n"); @@ -938,25 +938,52 @@ void rglUniformBlockBinding( GLuint program, * * Core in: * OpenGL : 2.0 + * OpenGLES : 3.0 */ void rglUniform1ui(GLint location, GLuint v) { +#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) && defined(HAVE_OPENGLES3) glUniform1ui(location ,v); +#endif } +/* + * + * Core in: + * OpenGL : 2.0 + * OpenGLES : 3.0 + */ void rglUniform2ui(GLint location, GLuint v0, GLuint v1) { +#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) && defined(HAVE_OPENGLES3) glUniform2ui(location, v0, v1); +#endif } +/* + * + * Core in: + * OpenGL : 2.0 + * OpenGLES : 3.0 + */ void rglUniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2) { +#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) && defined(HAVE_OPENGLES3) glUniform3ui(location, v0, v1, v2); +#endif } +/* + * + * Core in: + * OpenGL : 2.0 + * OpenGLES : 3.0 + */ void rglUniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3) { +#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) && defined(HAVE_OPENGLES3) glUniform4ui(location, v0, v1, v2, v3); +#endif } /* @@ -1356,11 +1383,6 @@ void rglUniform4fv(GLint location, GLsizei count, const GLfloat *value) glUniform4fv(location, count, value); } -void rglTexStorage2D(GLenum target, GLsizei levels, GLenum internalFormat, - GLsizei width, GLsizei height) -{ - glTexStorage2D(target, levels, internalFormat, width, height); -} /* * @@ -1447,12 +1469,25 @@ void rglTexStorage2DMultisample(GLenum target, GLsizei samples, GLenum internalformat, GLsizei width, GLsizei height, GLboolean fixedsamplelocations) { -#if defined(HAVE_OPENGLES) && defined(HAVE_OPENGLES31) +#if defined(HAVE_OPENGLES) && defined(HAVE_OPENGLES_3_1) glTexStorage2DMultisample(target, samples, internalformat, width, height, fixedsamplelocations); #endif } +/* + * + * Core in: + * OpenGLES : 3.0 + */ +void rglTexStorage2D(GLenum target, GLsizei levels, GLenum internalFormat, + GLsizei width, GLsizei height) +{ +#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) && defined(HAVE_OPENGLES3) + glTexStorage2D(target, levels, internalFormat, width, height); +#endif +} + /* * * Core in: @@ -1461,7 +1496,7 @@ void rglTexStorage2DMultisample(GLenum target, GLsizei samples, */ void rglMemoryBarrier( GLbitfield barriers) { -#if !defined(HAVE_OPENGLES) || defined(HAVE_OPENGLES3) && defined(HAVE_OPENGLES31) +#if !defined(HAVE_OPENGLES) || defined(HAVE_OPENGLES3) && defined(HAVE_OPENGLES_3_1) glMemoryBarrier(barriers); #else printf("WARNING! Not implemented.\n"); @@ -1482,7 +1517,7 @@ void rglBindImageTexture( GLuint unit, GLenum access, GLenum format) { -#if !defined(HAVE_OPENGLES) || defined(HAVE_OPENGLES3) && defined(HAVE_OPENGLES31) +#if !defined(HAVE_OPENGLES) || defined(HAVE_OPENGLES3) && defined(HAVE_OPENGLES_3_1) glBindImageTexture(unit, texture, level, layered, layer, access, format); #else printf("WARNING! Not implemented.\n"); @@ -1519,7 +1554,7 @@ void rglProgramBinary(GLuint program, const void *binary, GLsizei length) { -#if !defined(HAVE_OPENGLES) || defined(HAVE_OPENGLES) && defined(HAVE_OPENGLES31) +#if !defined(HAVE_OPENGLES) || defined(HAVE_OPENGLES) && defined(HAVE_OPENGLES_3_1) glProgramBinary(program, binaryFormat, binary, length); #else printf("WARNING! Not implemented.\n"); @@ -1622,11 +1657,11 @@ void rglCopyImageSubData( GLuint srcName, * * Core in: * OpenGL : 3.0 + * OpenGLES : 3.0 */ void rglBindVertexArray(GLuint array) { -#if defined(HAVE_OPENGLES) && !defined(HAVE_OPENGLES3) && !defined(HAVE_OPENGLES31) -#else +#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) && defined(HAVE_OPENGLES3) glBindVertexArray(array); #endif } @@ -1636,15 +1671,29 @@ void rglBindVertexArray(GLuint array) * * Core in: * OpenGL : 3.0 + * OpenGLES : 3.0 */ void rglGenVertexArrays(GLsizei n, GLuint *arrays) { -#if defined(HAVE_OPENGLES) && !defined(HAVE_OPENGLES3) && !defined(HAVE_OPENGLES31) -#else +#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) && defined(HAVE_OPENGLES3) glGenVertexArrays(n, arrays); #endif } +/* + * Category: VAO + * + * Core in: + * OpenGL : 3.0 + * OpenGLES : 3.0 + */ +void rglDeleteVertexArrays(GLuint array) +{ +#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) && defined(HAVE_OPENGLES3) + glDeleteVertexArrays(array); +#endif +} + /* GLSM-side */ static void glsm_state_setup(void) @@ -1878,7 +1927,7 @@ static bool glsm_state_ctx_init(void *data) return false; #ifdef HAVE_OPENGLES -#if defined(HAVE_OPENGLES31) +#if defined(HAVE_OPENGLES_3_1) hw_render.context_type = RETRO_HW_CONTEXT_OPENGLES_VERSION; hw_render.version_major = 3; hw_render.version_minor = 1; diff --git a/libretro-common/include/glsm/glsmsym.h b/libretro-common/include/glsm/glsmsym.h index 8eb06661ed..d6ba744f8e 100644 --- a/libretro-common/include/glsm/glsmsym.h +++ b/libretro-common/include/glsm/glsmsym.h @@ -149,6 +149,7 @@ RETRO_BEGIN_DECLS #define glGetProgramBinary rglGetProgramBinary #define glProgramParameteri rglProgramParameteri #define glTexSubImage2D rglTexSubImage2D +#define glDeleteVertexArrays rglDeleteVertexArrays void rglProgramParameteri( GLuint program, GLenum pname, @@ -364,6 +365,7 @@ void rglTexSubImage2D( GLenum target, GLenum format, GLenum type, const GLvoid * pixels); +void rglDeleteVertexArrays(GLuint array); RETRO_END_DECLS From b2df35bd7ca3583477da2c8b21ce616eaa5dfa06 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 7 May 2016 05:00:14 +0200 Subject: [PATCH 217/498] Correct glDeleteVertexArrays --- libretro-common/glsm/glsm.c | 4 ++-- libretro-common/include/glsm/glsmsym.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/libretro-common/glsm/glsm.c b/libretro-common/glsm/glsm.c index 7d650c7b18..c8bc9d74b0 100644 --- a/libretro-common/glsm/glsm.c +++ b/libretro-common/glsm/glsm.c @@ -1687,10 +1687,10 @@ void rglGenVertexArrays(GLsizei n, GLuint *arrays) * OpenGL : 3.0 * OpenGLES : 3.0 */ -void rglDeleteVertexArrays(GLuint array) +void rglDeleteVertexArrays(GLsizei n, const GLuint *arrays) { #if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) && defined(HAVE_OPENGLES3) - glDeleteVertexArrays(array); + glDeleteVertexArrays(n, arrays); #endif } diff --git a/libretro-common/include/glsm/glsmsym.h b/libretro-common/include/glsm/glsmsym.h index d6ba744f8e..8ae345e6dd 100644 --- a/libretro-common/include/glsm/glsmsym.h +++ b/libretro-common/include/glsm/glsmsym.h @@ -365,7 +365,7 @@ void rglTexSubImage2D( GLenum target, GLenum format, GLenum type, const GLvoid * pixels); -void rglDeleteVertexArrays(GLuint array); +void rglDeleteVertexArrays(GLsizei n, const GLuint *arrays); RETRO_END_DECLS From 7b799755161bdb694248d8d52320117185d00a5a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 7 May 2016 06:16:02 +0200 Subject: [PATCH 218/498] Start adding rjpeg_image_load --- libretro-common/formats/jpeg/rjpeg.c | 30 +++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/libretro-common/formats/jpeg/rjpeg.c b/libretro-common/formats/jpeg/rjpeg.c index 46cdc716dd..254a27222f 100644 --- a/libretro-common/formats/jpeg/rjpeg.c +++ b/libretro-common/formats/jpeg/rjpeg.c @@ -2,7 +2,9 @@ #include #include +#include #include +#include #define RJPEG_DECODE_SOF 0xC0 #define RJPEG_DECODE_DHT 0xC4 @@ -830,7 +832,7 @@ struct rjpeg_data *rjpeg_new(const uint8_t* data, size_t size) return ctx; } -void rjpeg_free(struct rjpeg_data *ctx) +static void rjpeg_free(struct rjpeg_data *ctx) { int i; @@ -840,3 +842,29 @@ void rjpeg_free(struct rjpeg_data *ctx) if (ctx->rgb) free((void*)ctx->rgb); } + +bool rjpeg_image_load(uint8_t *buf, void *data, size_t size) +{ + struct rjpeg_data *rjpg = rjpeg_new(buf, size); + struct texture_image *out_img = (struct texture_image*)data; + + if (!rjpg) + goto error; + + out_img->pixels = (uint32_t*)buf; + out_img->width = rjpg->width; + out_img->height = rjpg->height; + + rjpeg_free(rjpg); + + return true; + +error: + out_img->pixels = NULL; + out_img->width = out_img->height = 0; + + if (rjpg) + rjpeg_free(rjpg); + return false; +} + From f86d4d400dfd11bbd23b1b8de77ad5b06752f7ab Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 7 May 2016 06:20:17 +0200 Subject: [PATCH 219/498] Start adding jpeg hooks --- gfx/video_texture_image.c | 10 ++++++- libretro-common/formats/jpeg/rjpeg.c | 1 - libretro-common/include/formats/rjpeg.h | 40 +++++++++++++++++++++++++ 3 files changed, 49 insertions(+), 2 deletions(-) create mode 100644 libretro-common/include/formats/rjpeg.h diff --git a/gfx/video_texture_image.c b/gfx/video_texture_image.c index a9e7e934cb..a761387f8c 100644 --- a/gfx/video_texture_image.c +++ b/gfx/video_texture_image.c @@ -29,6 +29,7 @@ #ifdef HAVE_RPNG #include #endif +#include #include #include "../general.h" @@ -37,7 +38,8 @@ enum video_image_format { IMAGE_FORMAT_NONE = 0, IMAGE_FORMAT_TGA, - IMAGE_FORMAT_PNG + IMAGE_FORMAT_PNG, + IMAGE_FORMAT_JPEG }; bool video_texture_image_set_color_shifts( @@ -225,6 +227,8 @@ static enum video_image_format video_texture_image_get_type(const char *path) return IMAGE_FORMAT_TGA; if (strstr(path, ".png")) return IMAGE_FORMAT_PNG; + if (strstr(path, ".jpg") || strstr(path, ".jpeg")) + return IMAGE_FORMAT_JPEG; return IMAGE_FORMAT_NONE; } @@ -273,6 +277,10 @@ bool video_texture_image_load(struct texture_image *out_img, goto success; #endif break; + case IMAGE_FORMAT_JPEG: + if (rjpeg_image_load(ptr, out_img, file_len)) + goto success; + break; default: case IMAGE_FORMAT_NONE: break; diff --git a/libretro-common/formats/jpeg/rjpeg.c b/libretro-common/formats/jpeg/rjpeg.c index 254a27222f..7ee00c5fcf 100644 --- a/libretro-common/formats/jpeg/rjpeg.c +++ b/libretro-common/formats/jpeg/rjpeg.c @@ -867,4 +867,3 @@ error: rjpeg_free(rjpg); return false; } - diff --git a/libretro-common/include/formats/rjpeg.h b/libretro-common/include/formats/rjpeg.h new file mode 100644 index 0000000000..4ed6c0a575 --- /dev/null +++ b/libretro-common/include/formats/rjpeg.h @@ -0,0 +1,40 @@ +/* Copyright (C) 2010-2015 The RetroArch team + * + * --------------------------------------------------------------------------------------- + * The following license statement only applies to this file (rjpeg.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_FORMAT_RJPEG_H__ +#define __LIBRETRO_SDK_FORMAT_RJPEG_H__ + +#include +#include + +#include + +#include + +RETRO_BEGIN_DECLS + +bool rjpeg_image_load(uint8_t *buf, void *data, size_t size); + +RETRO_END_DECLS + +#endif + From c5895b4aa0991c058169564dc886ab1fc2f3d012 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 7 May 2016 06:49:48 +0200 Subject: [PATCH 220/498] (libretro-common/formats/jpeg/rjpeg.c) Allocate out_img->pixels --- libretro-common/formats/jpeg/rjpeg.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/libretro-common/formats/jpeg/rjpeg.c b/libretro-common/formats/jpeg/rjpeg.c index 7ee00c5fcf..6dd54aa5d3 100644 --- a/libretro-common/formats/jpeg/rjpeg.c +++ b/libretro-common/formats/jpeg/rjpeg.c @@ -1,3 +1,4 @@ +#include #include #include #include @@ -851,15 +852,26 @@ bool rjpeg_image_load(uint8_t *buf, void *data, size_t size) if (!rjpg) goto error; - out_img->pixels = (uint32_t*)buf; out_img->width = rjpg->width; out_img->height = rjpg->height; + out_img->pixels = (uint32_t*)malloc(rjpg->width * rjpg->height * rjpg->ncomp); + + if (!out_img->pixels) + { + fprintf(stderr, "Failed to allocate JPEG pixels.\n"); + goto error; + } + + memcpy(out_img->pixels, rjpg->rgb, rjpg->width * rjpg->height * rjpg->ncomp); rjpeg_free(rjpg); return true; error: + if (out_img->pixels) + free(out_img->pixels); + out_img->pixels = NULL; out_img->width = out_img->height = 0; From 0a2544c1bf7a6e3bcd6a73ff38f2102bcb7283d1 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 7 May 2016 06:55:52 +0200 Subject: [PATCH 221/498] (rjpeg) Try manual conversion to RGB --- libretro-common/formats/jpeg/rjpeg.c | 29 ++++++++++++++++++++++++---- 1 file changed, 25 insertions(+), 4 deletions(-) diff --git a/libretro-common/formats/jpeg/rjpeg.c b/libretro-common/formats/jpeg/rjpeg.c index 6dd54aa5d3..2933d3ba93 100644 --- a/libretro-common/formats/jpeg/rjpeg.c +++ b/libretro-common/formats/jpeg/rjpeg.c @@ -857,12 +857,33 @@ bool rjpeg_image_load(uint8_t *buf, void *data, size_t size) out_img->pixels = (uint32_t*)malloc(rjpg->width * rjpg->height * rjpg->ncomp); if (!out_img->pixels) - { - fprintf(stderr, "Failed to allocate JPEG pixels.\n"); goto error; - } - memcpy(out_img->pixels, rjpg->rgb, rjpg->width * rjpg->height * rjpg->ncomp); + if (rjpg->ncomp == 3) + { + /* convert to RGB */ + int x, yy; + uint32_t *prgb = (uint32_t*)out_img->pixels; + const unsigned char *py = rjpg->comp[0].pixels; + const unsigned char *pcb = rjpg->comp[1].pixels; + const unsigned char *pcr = rjpg->comp[2].pixels; + + for (yy = rjpg->height; yy; --yy) + { + for (x = 0; x < rjpg->width; ++x) + { + register int y = py[x] << 8; + register int cb = pcb[x] - 128; + register int cr = pcr[x] - 128; + *prgb++ = rjpeg_clip((y + 359 * cr + 128) >> 8); + *prgb++ = rjpeg_clip((y - 88 * cb - 183 * cr + 128) >> 8); + *prgb++ = rjpeg_clip((y + 454 * cb + 128) >> 8); + } + py += rjpg->comp[0].stride; + pcb += rjpg->comp[1].stride; + pcr += rjpg->comp[2].stride; + } + } rjpeg_free(rjpg); From 7f272a4bd04b578162c90143d72c6427caa5cb59 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 7 May 2016 16:24:26 +0200 Subject: [PATCH 222/498] Add missing parameters --- gfx/video_texture_image.c | 3 ++- libretro-common/formats/jpeg/rjpeg.c | 4 +++- libretro-common/include/formats/rjpeg.h | 3 ++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/gfx/video_texture_image.c b/gfx/video_texture_image.c index a761387f8c..8960c29155 100644 --- a/gfx/video_texture_image.c +++ b/gfx/video_texture_image.c @@ -278,7 +278,8 @@ bool video_texture_image_load(struct texture_image *out_img, #endif break; case IMAGE_FORMAT_JPEG: - if (rjpeg_image_load(ptr, out_img, file_len)) + if (rjpeg_image_load(ptr, out_img, file_len, + a_shift, r_shift, g_shift, b_shift)) goto success; break; default: diff --git a/libretro-common/formats/jpeg/rjpeg.c b/libretro-common/formats/jpeg/rjpeg.c index 2933d3ba93..0cc3027a32 100644 --- a/libretro-common/formats/jpeg/rjpeg.c +++ b/libretro-common/formats/jpeg/rjpeg.c @@ -844,7 +844,9 @@ static void rjpeg_free(struct rjpeg_data *ctx) free((void*)ctx->rgb); } -bool rjpeg_image_load(uint8_t *buf, void *data, size_t size) +bool rjpeg_image_load(uint8_t *buf, void *data, size_t size, + unsigned a_shift, unsigned r_shift, + unsigned g_shift, unsigned b_shift) { struct rjpeg_data *rjpg = rjpeg_new(buf, size); struct texture_image *out_img = (struct texture_image*)data; diff --git a/libretro-common/include/formats/rjpeg.h b/libretro-common/include/formats/rjpeg.h index 4ed6c0a575..539fd058df 100644 --- a/libretro-common/include/formats/rjpeg.h +++ b/libretro-common/include/formats/rjpeg.h @@ -32,7 +32,8 @@ RETRO_BEGIN_DECLS -bool rjpeg_image_load(uint8_t *buf, void *data, size_t size); +bool rjpeg_image_load(uint8_t *buf, void *data, size_t size, + unsigned a_shift, unsigned r_shift, unsigned g_shift, unsigned b_shift); RETRO_END_DECLS From ef5da43d354e3b683a86aa46676d186766f58ba9 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 7 May 2016 18:35:06 +0200 Subject: [PATCH 223/498] Cleanups --- libretro-common/formats/jpeg/rjpeg.c | 8 +++++--- netlogger.c | 6 ++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/libretro-common/formats/jpeg/rjpeg.c b/libretro-common/formats/jpeg/rjpeg.c index 0cc3027a32..ddb6698be2 100644 --- a/libretro-common/formats/jpeg/rjpeg.c +++ b/libretro-common/formats/jpeg/rjpeg.c @@ -184,6 +184,7 @@ static void rjpeg_decode_dht(struct rjpeg_data *ctx) counts[codelen - 1] = ctx->pos[codelen]; rjpeg_skip(ctx, 17); vlc = &ctx->vlctab[i][0]; + for (codelen = 1; codelen <= 16; ++codelen) { int currcnt; @@ -241,10 +242,11 @@ static int rjpeg_show_bits(struct rjpeg_data *ctx, int bits) continue; } - newbyte = *ctx->pos++; + newbyte = *ctx->pos++; ctx->size--; ctx->bufbits += 8; - ctx->buf = (ctx->buf << 8) | newbyte; + ctx->buf = (ctx->buf << 8) | newbyte; + if (newbyte == 0xFF) { if (ctx->size) @@ -263,7 +265,7 @@ static int rjpeg_show_bits(struct rjpeg_data *ctx, int bits) ctx->error = RJPEG_SYNTAX_ERROR; else { - ctx->buf = (ctx->buf << 8) | marker; + ctx->buf = (ctx->buf << 8) | marker; ctx->bufbits += 8; } } diff --git a/netlogger.c b/netlogger.c index 8d3d530795..71dd5d42f6 100644 --- a/netlogger.c +++ b/netlogger.c @@ -73,12 +73,10 @@ void logger_init (void) void logger_shutdown (void) { - int ret = socket_close(g_sid); + if (socket_close(g_sid) < 0) + printf("Could not close socket.\n"); network_deinit(); - - if (ret < 0) - printf("Could not deinitialize network logger interface.\n"); } void logger_send(const char *__format,...) From fb62f9bef5507d52233b4a268439e77c6e44f17c Mon Sep 17 00:00:00 2001 From: GeneralFailer Date: Sat, 7 May 2016 23:42:48 +0400 Subject: [PATCH 224/498] Update retroarch.1 --- docs/retroarch.1 | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/retroarch.1 b/docs/retroarch.1 index 8161db1a5e..4be90ebae3 100644 --- a/docs/retroarch.1 +++ b/docs/retroarch.1 @@ -151,7 +151,7 @@ The video input is scaled with point filtering before being encoded at the corre .TP \fB--bsvplay PATH, -P PATH\fR -Play back a movie recorded in the .bsv format (bSNES). Cart ROM and movie file need to correspond. +Play back a movie recorded in the .bsv format (bsnes). Cart ROM and movie file need to correspond. It also requires to play back with the same libretro backend that was used for recording. .TP From 42019bd02f0f742d944e7220b6d14b94900bea27 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 00:15:04 +0200 Subject: [PATCH 225/498] People don't like ioctl functions - so here goes --- cheats.c | 2 +- cheevos.c | 179 ++++++++++++++++++------------------ cheevos.h | 39 +++----- command_event.c | 6 +- content.c | 4 +- menu/drivers/menu_generic.c | 2 +- menu/menu_displaylist.c | 2 +- runloop.c | 2 +- 8 files changed, 112 insertions(+), 124 deletions(-) diff --git a/cheats.c b/cheats.c index 868ef34857..a77ab4b900 100644 --- a/cheats.c +++ b/cheats.c @@ -99,7 +99,7 @@ void cheat_manager_apply_cheats(void) #ifdef HAVE_CHEEVOS data_bool = idx != 0; - cheevos_ctl(CHEEVOS_CTL_APPLY_CHEATS, &data_bool); + cheevos_apply_cheats(&data_bool); #endif } diff --git a/cheevos.c b/cheevos.c index 047c0e9d52..cb83764239 100644 --- a/cheevos.c +++ b/cheevos.c @@ -240,6 +240,9 @@ static cheevos_locals_t cheevos_locals = {0}, }; +static int cheats_are_enabled = 0; +static int cheats_were_enabled = 0; + /* forward declaration */ int rarch_main_async_job_add(async_task_t task, void *payload); @@ -953,7 +956,7 @@ static int cheevos_parse(const char *json) if (jsonsax_parse(json, &handlers, (void*)&ud) != JSONSAX_OK) { - cheevos_ctl(CHEEVOS_CTL_UNLOAD, NULL); + cheevos_unload(); return -1; } @@ -1917,8 +1920,7 @@ static unsigned cheevos_find_game_id_nes( return cheevos_get_game_id(hash, &to); } - -static bool cheevos_load(const void *data) +bool cheevos_load(const void *data) { retro_ctx_memory_info_t mem_info; @@ -2100,9 +2102,9 @@ static bool cheevos_load(const void *data) return false; } -#ifdef HAVE_MENU -static void cheevos_populate_menu(void *data) +void cheevos_populate_menu(void *data) { +#ifdef HAVE_MENU unsigned i; const cheevo_t *end = NULL; cheevo_t *cheevo = NULL; @@ -2165,97 +2167,92 @@ static void cheevos_populate_menu(void *data) cheevo->description, MENU_SETTINGS_CHEEVOS_START + i, 0, 0); } } +#endif } -#endif -bool cheevos_ctl(enum cheevos_ctl_state state, void *data) +bool cheevos_get_description(cheevos_ctx_desc_t *desc) { - static int cheats_are_enabled = 0; - static int cheats_were_enabled = 0; - settings_t *settings = config_get_ptr(); + cheevo_t *cheevos = cheevos_locals.core.cheevos; - switch (state) + if (desc->idx >= cheevos_locals.core.count) { - case CHEEVOS_CTL_GET_DESCRIPTION: - { - cheevos_ctx_desc_t *desc = (cheevos_ctx_desc_t*)data; - cheevo_t *cheevos = cheevos_locals.core.cheevos; - - if (desc->idx >= cheevos_locals.core.count) - { - cheevos = cheevos_locals.unofficial.cheevos; - desc->idx -= cheevos_locals.unofficial.count; - } - - strncpy(desc->s, cheevos[desc->idx].description, desc->len); - desc->s[desc->len - 1] = 0; - } - break; - case CHEEVOS_CTL_APPLY_CHEATS: - { - bool *data_bool = (bool*)data; - cheats_are_enabled = *data_bool; - cheats_were_enabled |= cheats_are_enabled; - } - break; - case CHEEVOS_CTL_LOAD: - if (!cheevos_load((const void*)data)) - return false; - - break; - case CHEEVOS_CTL_UNLOAD: - if (!cheevos_locals.loaded) - return false; - - cheevos_free_cheevo_set(&cheevos_locals.core); - cheevos_free_cheevo_set(&cheevos_locals.unofficial); - - cheevos_locals.loaded = 0; - break; - case CHEEVOS_CTL_TOGGLE_HARDCORE_MODE: - /* reset and deinit rewind to avoid cheat the score */ - if (settings->cheevos.hardcore_mode_enable) - { - /* send reset core cmd to avoid any user savestate previusly loaded */ - event_cmd_ctl(EVENT_CMD_RESET, NULL); - if (settings->rewind_enable) - event_cmd_ctl(EVENT_CMD_REWIND_DEINIT, NULL); - - RARCH_LOG("%s\n", msg_hash_to_str(MSG_CHEEVOS_HARDCORE_MODE_ENABLE)); - runloop_msg_queue_push(msg_hash_to_str(MSG_CHEEVOS_HARDCORE_MODE_ENABLE), 0, 3 * 60, true); - } - else - { - if (settings->rewind_enable) - event_cmd_ctl(EVENT_CMD_REWIND_INIT, NULL); - } - break; - case CHEEVOS_CTL_TEST: - if (!cheevos_locals.loaded) - return false; - - if (!cheats_are_enabled && !cheats_were_enabled) - { - if (!settings->cheevos.enable) - return false; - - cheevos_test_cheevo_set(&cheevos_locals.core); - - if (settings->cheevos.test_unofficial) - cheevos_test_cheevo_set(&cheevos_locals.unofficial); - } - break; - case CHEEVOS_CTL_POPULATE_MENU: -#ifdef HAVE_MENU - cheevos_populate_menu(data); -#endif - break; - case CHEEVOS_CTL_SET_CHEATS: - cheats_were_enabled = cheats_are_enabled; - break; - case CHEEVOS_CTL_NONE: - default: - break; + cheevos = cheevos_locals.unofficial.cheevos; + desc->idx -= cheevos_locals.unofficial.count; } + + strncpy(desc->s, cheevos[desc->idx].description, desc->len); + desc->s[desc->len - 1] = 0; + + return true; +} + +bool cheevos_apply_cheats(bool *data_bool) +{ + cheats_are_enabled = *data_bool; + cheats_were_enabled |= cheats_are_enabled; + + return true; +} + +bool cheevos_unload(void) +{ + if (!cheevos_locals.loaded) + return false; + + cheevos_free_cheevo_set(&cheevos_locals.core); + cheevos_free_cheevo_set(&cheevos_locals.unofficial); + + cheevos_locals.loaded = 0; + + return true; +} + +bool cheevos_toggle_hardcore_mode(void) +{ + settings_t *settings = config_get_ptr(); + /* reset and deinit rewind to avoid cheat the score */ + if (settings->cheevos.hardcore_mode_enable) + { + /* send reset core cmd to avoid any user savestate previusly loaded */ + event_cmd_ctl(EVENT_CMD_RESET, NULL); + if (settings->rewind_enable) + event_cmd_ctl(EVENT_CMD_REWIND_DEINIT, NULL); + + RARCH_LOG("%s\n", msg_hash_to_str(MSG_CHEEVOS_HARDCORE_MODE_ENABLE)); + runloop_msg_queue_push(msg_hash_to_str(MSG_CHEEVOS_HARDCORE_MODE_ENABLE), 0, 3 * 60, true); + } + else + { + if (settings->rewind_enable) + event_cmd_ctl(EVENT_CMD_REWIND_INIT, NULL); + } + + return true; +} + +bool cheevos_test(void) +{ + settings_t *settings = config_get_ptr(); + if (!cheevos_locals.loaded) + return false; + + if (!cheats_are_enabled && !cheats_were_enabled) + { + if (!settings->cheevos.enable) + return false; + + cheevos_test_cheevo_set(&cheevos_locals.core); + + if (settings->cheevos.test_unofficial) + cheevos_test_cheevo_set(&cheevos_locals.unofficial); + } + + return true; +} + +bool cheevos_set_cheats(void) +{ + cheats_were_enabled = cheats_are_enabled; + return true; } diff --git a/cheevos.h b/cheevos.h index 5ca01ab4a2..8e75ed8520 100644 --- a/cheevos.h +++ b/cheevos.h @@ -19,29 +19,6 @@ #include #include -enum cheevos_ctl_state -{ - CHEEVOS_CTL_NONE = 0, - CHEEVOS_CTL_TEST, - CHEEVOS_CTL_LOAD, - - CHEEVOS_CTL_APPLY_CHEATS, - - /* Unload the achievements from memory. */ - CHEEVOS_CTL_UNLOAD, - - /* Toggle Hardcore Mode */ - CHEEVOS_CTL_TOGGLE_HARDCORE_MODE, - - /* Load the achievements into memory if - * the game has content. */ - CHEEVOS_CTL_SET_CHEATS, - - CHEEVOS_CTL_GET_DESCRIPTION, - - CHEEVOS_CTL_POPULATE_MENU -}; - typedef struct cheevos_ctx_desc { unsigned idx; @@ -49,6 +26,20 @@ typedef struct cheevos_ctx_desc size_t len; } cheevos_ctx_desc_t; -bool cheevos_ctl(enum cheevos_ctl_state state, void *data); +bool cheevos_load(const void *data); + +void cheevos_populate_menu(void *data); + +bool cheevos_get_description(cheevos_ctx_desc_t *desc); + +bool cheevos_apply_cheats(bool *data_bool); + +bool cheevos_unload(void); + +bool cheevos_toggle_hardcore_mode(void); + +bool cheevos_test(void); + +bool cheevos_set_cheats(void); #endif /* __RARCH_CHEEVOS_H */ diff --git a/command_event.c b/command_event.c index 34da6ad513..95328a43c0 100644 --- a/command_event.c +++ b/command_event.c @@ -396,7 +396,7 @@ static void event_init_controllers(void) static void event_deinit_core(bool reinit) { #ifdef HAVE_CHEEVOS - cheevos_ctl(CHEEVOS_CTL_UNLOAD, NULL); + cheevos_unload(); #endif core_ctl(CORE_CTL_RETRO_UNLOAD_GAME, NULL); @@ -1089,7 +1089,7 @@ bool event_cmd_ctl(enum event_command cmd, void *data) runloop_msg_queue_push(msg_hash_to_str(MSG_RESET), 1, 120, true); #ifdef HAVE_CHEEVOS - cheevos_ctl(CHEEVOS_CTL_SET_CHEATS, NULL); + cheevos_set_cheats(); #endif core_ctl(CORE_CTL_RETRO_RESET, NULL); break; @@ -1125,7 +1125,7 @@ bool event_cmd_ctl(enum event_command cmd, void *data) break; case EVENT_CMD_CHEEVOS_HARDCORE_MODE_TOGGLE: #ifdef HAVE_CHEEVOS - cheevos_ctl(CHEEVOS_CTL_TOGGLE_HARDCORE_MODE, NULL); + cheevos_toggle_hardcore_mode(); #endif break; case EVENT_CMD_REINIT: diff --git a/content.c b/content.c index a508a2c510..40255786b5 100644 --- a/content.c +++ b/content.c @@ -1441,11 +1441,11 @@ static bool load_content( { const void *load_data = NULL; - cheevos_ctl(CHEEVOS_CTL_SET_CHEATS, NULL); + cheevos_set_cheats(); if (*content->elems[0].data) load_data = info; - cheevos_ctl(CHEEVOS_CTL_LOAD, (void*)load_data); + cheevos_load(load_data); } #endif diff --git a/menu/drivers/menu_generic.c b/menu/drivers/menu_generic.c index 7c4ce90f49..cae769c718 100644 --- a/menu/drivers/menu_generic.c +++ b/menu/drivers/menu_generic.c @@ -178,7 +178,7 @@ static int action_iterate_help(menu_handle_t *menu, desc_info.idx = menu->help_screen_id; desc_info.s = s; desc_info.len = len; - cheevos_ctl(CHEEVOS_CTL_GET_DESCRIPTION, &desc_info); + cheevos_get_description(&desc_info); break; #endif diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index b9fff17f05..85d0bbfdeb 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -3836,7 +3836,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) #ifdef HAVE_CHEEVOS case DISPLAYLIST_ACHIEVEMENT_LIST: - cheevos_ctl(CHEEVOS_CTL_POPULATE_MENU, info); + cheevos_populate_menu(info); info->need_push = true; info->need_refresh = true; break; diff --git a/runloop.c b/runloop.c index add25851c8..5005cba5e9 100644 --- a/runloop.c +++ b/runloop.c @@ -1465,7 +1465,7 @@ int runloop_iterate(unsigned *sleep_ms) core_ctl(CORE_CTL_RETRO_RUN, NULL); #ifdef HAVE_CHEEVOS - cheevos_ctl(CHEEVOS_CTL_TEST, NULL); + cheevos_test(); #endif for (i = 0; i < settings->input.max_users; i++) From 80a453bad1d4e2e1bc7b44a70bf67f11c5ae94c7 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 00:25:04 +0200 Subject: [PATCH 226/498] De-ioctlify command.c --- command.c | 85 ++++++++++++++++++-------------------------- command.h | 22 ++++++------ input/input_driver.c | 6 ++-- retroarch.c | 2 +- 4 files changed, 50 insertions(+), 65 deletions(-) diff --git a/command.c b/command.c index a8ca988f66..fafe0291cf 100644 --- a/command.c +++ b/command.c @@ -197,7 +197,7 @@ rarch_cmd_t *rarch_cmd_new(bool stdin_enable, #if (defined(HAVE_NETWORK_CMD) && defined(HAVE_NETPLAY)) || defined(HAVE_STDIN_CMD) error: - rarch_cmd_ctl(RARCH_CMD_CTL_FREE, handle); + rarch_cmd_free(handle); return NULL; #endif } @@ -564,7 +564,7 @@ static bool verify_command(const char *cmd) return false; } -static bool network_cmd_send(const char *cmd_) +bool rarch_cmd_send(const char *cmd_) { bool ret; char *command = NULL; @@ -609,61 +609,46 @@ static bool network_cmd_send(const char *cmd_) } #endif -bool rarch_cmd_ctl(enum rarch_cmd_ctl_state state, void *data) +bool rarch_cmd_poll(rarch_cmd_t *handle) { - switch (state) - { - case RARCH_CMD_CTL_NETWORK_SEND: -#if defined(HAVE_NETWORK_CMD) && defined(HAVE_NETPLAY) - network_cmd_send((const char*)data); -#endif - break; - case RARCH_CMD_CTL_POLL: - { - rarch_cmd_t *handle = (rarch_cmd_t*)data; - memset(handle->state, 0, sizeof(handle->state)); + memset(handle->state, 0, sizeof(handle->state)); #if defined(HAVE_NETWORK_CMD) && defined(HAVE_NETPLAY) - network_cmd_poll(handle); + network_cmd_poll(handle); #endif #ifdef HAVE_STDIN_CMD - stdin_cmd_poll(handle); + stdin_cmd_poll(handle); #endif - } - break; - case RARCH_CMD_CTL_SET: - { - rarch_cmd_handle_t *handle = (rarch_cmd_handle_t*)data; - if (!handle || !handle->handle) - return false; - if (handle->id < RARCH_BIND_LIST_END) - handle->handle->state[handle->id] = true; - } - break; - case RARCH_CMD_CTL_GET: - { - rarch_cmd_handle_t *handle = (rarch_cmd_handle_t*)data; - if (!handle || !handle->handle) - return false; - return handle->id < RARCH_BIND_LIST_END - && handle->handle->state[handle->id]; - } - case RARCH_CMD_CTL_FREE: - { - rarch_cmd_t *handle = (rarch_cmd_t*)data; -#if defined(HAVE_NETWORK_CMD) && defined(HAVE_NETPLAY) - if (handle && handle->net_fd >= 0) - socket_close(handle->net_fd); -#endif - - free(handle); - } - break; - case RARCH_CMD_CTL_NONE: - default: - break; - } return true; } + +bool rarch_cmd_set(rarch_cmd_handle_t *handle) +{ + if (!handle || !handle->handle) + return false; + if (handle->id < RARCH_BIND_LIST_END) + handle->handle->state[handle->id] = true; + return true; +} + +bool rarch_cmd_free(rarch_cmd_t *handle) +{ +#if defined(HAVE_NETWORK_CMD) && defined(HAVE_NETPLAY) + if (handle && handle->net_fd >= 0) + socket_close(handle->net_fd); +#endif + + free(handle); + + return true; +} + +bool rarch_cmd_get(rarch_cmd_handle_t *handle) +{ + if (!handle || !handle->handle) + return false; + return handle->id < RARCH_BIND_LIST_END + && handle->handle->state[handle->id]; +} diff --git a/command.h b/command.h index 5e31cb75bc..4f6647a144 100644 --- a/command.h +++ b/command.h @@ -28,16 +28,6 @@ extern "C" { #endif -enum rarch_cmd_ctl_state -{ - RARCH_CMD_CTL_NONE = 0, - RARCH_CMD_CTL_GET, - RARCH_CMD_CTL_SET, - RARCH_CMD_CTL_POLL, - RARCH_CMD_CTL_NETWORK_SEND, - RARCH_CMD_CTL_FREE -}; - typedef struct rarch_cmd rarch_cmd_t; typedef struct rarch_cmd_handle @@ -49,7 +39,17 @@ typedef struct rarch_cmd_handle rarch_cmd_t *rarch_cmd_new(bool stdin_enable, bool network_enable, uint16_t port); -bool rarch_cmd_ctl(enum rarch_cmd_ctl_state state, void *data); +#if defined(HAVE_NETWORK_CMD) && defined(HAVE_NETPLAY) +bool rarch_cmd_send(const char *cmd_); +#endif + +bool rarch_cmd_poll(rarch_cmd_t *handle); + +bool rarch_cmd_set(rarch_cmd_handle_t *handle); + +bool rarch_cmd_get(rarch_cmd_handle_t *handle); + +bool rarch_cmd_free(rarch_cmd_t *handle); #ifdef __cplusplus } diff --git a/input/input_driver.c b/input/input_driver.c index 2dfda9d95f..fdb93abf1f 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -274,7 +274,7 @@ static retro_input_t input_driver_keys_pressed(void) handle.handle = input_driver_command; handle.id = key; - state |= rarch_cmd_ctl(RARCH_CMD_CTL_GET, &handle); + state |= rarch_cmd_get(&handle); } #endif @@ -430,7 +430,7 @@ void input_poll(void) #ifdef HAVE_COMMAND if (input_driver_command) - rarch_cmd_ctl(RARCH_CMD_CTL_POLL, input_driver_command); + rarch_cmd_poll(input_driver_command); #endif #ifdef HAVE_NETWORK_GAMEPAD @@ -803,7 +803,7 @@ bool input_driver_ctl(enum rarch_input_ctl_state state, void *data) case RARCH_INPUT_CTL_COMMAND_DEINIT: #ifdef HAVE_COMMAND if (input_driver_command) - rarch_cmd_ctl(RARCH_CMD_CTL_FREE, input_driver_command); + rarch_cmd_free(input_driver_command); input_driver_command = NULL; #endif break; diff --git a/retroarch.c b/retroarch.c index 1854d62501..a186e67b73 100644 --- a/retroarch.c +++ b/retroarch.c @@ -954,7 +954,7 @@ static void parse_input(int argc, char *argv[]) #if defined(HAVE_NETWORK_CMD) && defined(HAVE_NETPLAY) case RA_OPT_COMMAND: - if (rarch_cmd_ctl(RARCH_CMD_CTL_NETWORK_SEND, (void*)optarg)) + if (rarch_cmd_send((void*)optarg)) exit(0); else retro_fail(1, "network_cmd_send()"); From 831de5f15ebae6d4c84ed34642dc50a5153a9d67 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 00:31:21 +0200 Subject: [PATCH 227/498] Add prefix 'core' to libretro_version_1.c --- libretro_version_1.c | 51 ++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 25 deletions(-) diff --git a/libretro_version_1.c b/libretro_version_1.c index 9144ac5ce8..438dd9f8c1 100644 --- a/libretro_version_1.c +++ b/libretro_version_1.c @@ -42,8 +42,16 @@ static struct retro_core_t core; static unsigned core_poll_type; static bool core_input_polled; +static bool core_has_set_input_descriptors = false; +static struct retro_callbacks retro_ctx; -static int16_t input_state_poll(unsigned port, +static void core_input_state_poll_maybe(void) +{ + if (core_poll_type == POLL_TYPE_NORMAL) + input_poll(); +} + +static int16_t core_input_state_poll(unsigned port, unsigned device, unsigned idx, unsigned id) { if (core_poll_type == POLL_TYPE_LATE) @@ -57,12 +65,12 @@ static int16_t input_state_poll(unsigned port, } /** - * retro_set_default_callbacks: + * core_set_default_callbacks: * @data : pointer to retro_callbacks object * * Binds the libretro callbacks to default callback functions. **/ -static bool retro_set_default_callbacks(void *data) +static bool core_set_default_callbacks(void *data) { struct retro_callbacks *cbs = (struct retro_callbacks*)data; @@ -72,13 +80,13 @@ static bool retro_set_default_callbacks(void *data) cbs->frame_cb = video_driver_frame; cbs->sample_cb = audio_driver_sample; cbs->sample_batch_cb = audio_driver_sample_batch; - cbs->state_cb = input_state_poll; + cbs->state_cb = core_input_state_poll; cbs->poll_cb = input_poll; return true; } -static bool retro_uninit_libretro_cbs(void *data) +static bool core_uninit_libretro_cbs(void *data) { struct retro_callbacks *cbs = (struct retro_callbacks*)data; @@ -94,20 +102,15 @@ static bool retro_uninit_libretro_cbs(void *data) return true; } -static void input_poll_maybe(void) -{ - if (core_poll_type == POLL_TYPE_NORMAL) - input_poll(); -} /** - * retro_init_libretro_cbs: + * core_init_libretro_cbs: * @data : pointer to retro_callbacks object * * Initializes libretro callbacks, and binds the libretro callbacks * to default callback functions. **/ -static bool retro_init_libretro_cbs(void *data) +static bool core_init_libretro_cbs(void *data) { struct retro_callbacks *cbs = (struct retro_callbacks*)data; #ifdef HAVE_NETPLAY @@ -120,8 +123,8 @@ static bool retro_init_libretro_cbs(void *data) core.retro_set_video_refresh(video_driver_frame); core.retro_set_audio_sample(audio_driver_sample); core.retro_set_audio_sample_batch(audio_driver_sample_batch); - core.retro_set_input_state(input_state_poll); - core.retro_set_input_poll(input_poll_maybe); + core.retro_set_input_state(core_input_state_poll); + core.retro_set_input_poll(core_input_state_poll_maybe); core_ctl(CORE_CTL_SET_CBS, cbs); @@ -152,12 +155,12 @@ static bool retro_init_libretro_cbs(void *data) } /** - * retro_set_rewind_callbacks: + * core_set_rewind_callbacks: * * Sets the audio sampling callbacks based on whether or not * rewinding is currently activated. **/ -static void retro_set_rewind_callbacks(void) +static void core_set_rewind_callbacks(void) { if (state_manager_frame_is_reversed()) { @@ -173,8 +176,6 @@ static void retro_set_rewind_callbacks(void) bool core_ctl(enum core_ctl_state state, void *data) { - static bool has_set_input_descriptors = false; - static struct retro_callbacks retro_ctx; switch (state) { @@ -332,9 +333,9 @@ bool core_ctl(enum core_ctl_state state, void *data) input_poll(); break; case CORE_CTL_SET_CBS: - return retro_set_default_callbacks(data); + return core_set_default_callbacks(data); case CORE_CTL_SET_CBS_REWIND: - retro_set_rewind_callbacks(); + core_set_rewind_callbacks(); break; case CORE_CTL_INIT: { @@ -342,7 +343,7 @@ bool core_ctl(enum core_ctl_state state, void *data) core_poll_type = settings->input.poll_type_behavior; if (!core_ctl(CORE_CTL_VERIFY_API_VERSION, NULL)) return false; - if (!retro_init_libretro_cbs(&retro_ctx)) + if (!core_init_libretro_cbs(&retro_ctx)) return false; core_ctl(CORE_CTL_RETRO_GET_SYSTEM_AV_INFO, video_viewport_get_system_av_info()); @@ -350,7 +351,7 @@ bool core_ctl(enum core_ctl_state state, void *data) } break; case CORE_CTL_DEINIT: - return retro_uninit_libretro_cbs(&retro_ctx); + return core_uninit_libretro_cbs(&retro_ctx); case CORE_CTL_VERIFY_API_VERSION: { unsigned api_version = core.retro_api_version(); @@ -365,12 +366,12 @@ bool core_ctl(enum core_ctl_state state, void *data) } break; case CORE_CTL_HAS_SET_INPUT_DESCRIPTORS: - return has_set_input_descriptors; + return core_has_set_input_descriptors; case CORE_CTL_SET_INPUT_DESCRIPTORS: - has_set_input_descriptors = true; + core_has_set_input_descriptors = true; break; case CORE_CTL_UNSET_INPUT_DESCRIPTORS: - has_set_input_descriptors = false; + core_has_set_input_descriptors = false; break; case CORE_CTL_NONE: default: From 6544772fb81469ff4fafcc59cfdd2ae1157b7b90 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 01:33:57 +0200 Subject: [PATCH 228/498] De-ioctl ify core_ctl --- autosave.c | 2 +- cheats.c | 4 +- cheevos.c | 18 +- command_event.c | 18 +- configuration.c | 2 +- content.c | 18 +- driver.c | 2 +- dynamic.c | 4 +- gfx/drivers_shader/shader_gl_cg.c | 4 +- gfx/drivers_shader/shader_glsl.c | 2 +- gfx/video_driver.c | 4 +- gfx/video_state_python.c | 4 +- libretro_version_1.c | 493 ++++++++++++++++-------------- libretro_version_1.h | 149 +++++---- menu/menu_display.c | 2 +- menu/menu_displaylist.c | 2 +- menu/menu_input.c | 2 +- menu/menu_setting.c | 10 +- movie.c | 10 +- netplay/netplay.c | 4 +- netplay/netplay_common.c | 12 +- netplay/netplay_net.c | 10 +- rewind.c | 10 +- runloop.c | 8 +- 24 files changed, 405 insertions(+), 389 deletions(-) diff --git a/autosave.c b/autosave.c index 26129b70ed..1381a26854 100644 --- a/autosave.c +++ b/autosave.c @@ -243,7 +243,7 @@ void autosave_event_init(void) mem_info.id = type; - core_ctl(CORE_CTL_RETRO_GET_MEMORY, &mem_info); + core_get_memory(&mem_info); if (mem_info.size <= 0) continue; diff --git a/cheats.c b/cheats.c index a77ab4b900..af051df050 100644 --- a/cheats.c +++ b/cheats.c @@ -81,7 +81,7 @@ void cheat_manager_apply_cheats(void) if (!handle) return; - core_ctl(CORE_CTL_RETRO_CHEAT_RESET, NULL); + core_reset_cheat(); for (i = 0; i < handle->size; i++) { @@ -93,7 +93,7 @@ void cheat_manager_apply_cheats(void) cheat_info.enabled = true; cheat_info.code = handle->cheats[i].code; - core_ctl(CORE_CTL_RETRO_CHEAT_SET, &cheat_info); + core_set_cheat(&cheat_info); } } diff --git a/cheevos.c b/cheevos.c index cb83764239..8700be4e54 100644 --- a/cheevos.c +++ b/cheevos.c @@ -974,7 +974,7 @@ static const uint8_t *cheevos_get_memory(unsigned offset) mem_info.id = RETRO_MEMORY_SYSTEM_RAM; - core_ctl(CORE_CTL_RETRO_GET_MEMORY, &mem_info); + core_get_memory(&mem_info); if (offset < mem_info.size) { @@ -988,7 +988,7 @@ static const uint8_t *cheevos_get_memory(unsigned offset) mem_info.size = 0; mem_info.id = RETRO_MEMORY_SAVE_RAM; - core_ctl(CORE_CTL_RETRO_GET_MEMORY, &mem_info); + core_get_memory(&mem_info); if (offset < mem_info.size) { @@ -1002,7 +1002,7 @@ static const uint8_t *cheevos_get_memory(unsigned offset) mem_info.size = 0; mem_info.id = RETRO_MEMORY_VIDEO_RAM; - core_ctl(CORE_CTL_RETRO_GET_MEMORY, &mem_info); + core_get_memory(&mem_info); if (offset < mem_info.size) { @@ -1016,7 +1016,7 @@ static const uint8_t *cheevos_get_memory(unsigned offset) mem_info.size = 0; mem_info.id = RETRO_MEMORY_RTC; - core_ctl(CORE_CTL_RETRO_GET_MEMORY, &mem_info); + core_get_memory(&mem_info); if (offset < mem_info.size) { @@ -1983,7 +1983,7 @@ bool cheevos_load(const void *data) mem_info.size = 0; mem_info.id = RETRO_MEMORY_SYSTEM_RAM; - core_ctl(CORE_CTL_RETRO_GET_MEMORY, &mem_info); + core_get_memory(&mem_info); memory = mem_info.size; @@ -1991,7 +1991,7 @@ bool cheevos_load(const void *data) mem_info.size = 0; mem_info.id = RETRO_MEMORY_VIDEO_RAM; - core_ctl(CORE_CTL_RETRO_GET_MEMORY, &mem_info); + core_get_memory(&mem_info); memory += mem_info.size; @@ -1999,7 +1999,7 @@ bool cheevos_load(const void *data) mem_info.size = 0; mem_info.id = RETRO_MEMORY_RTC; - core_ctl(CORE_CTL_RETRO_GET_MEMORY, &mem_info); + core_get_memory(&mem_info); memory += mem_info.size; @@ -2007,7 +2007,7 @@ bool cheevos_load(const void *data) mem_info.size = 0; mem_info.id = RETRO_MEMORY_SAVE_RAM; - core_ctl(CORE_CTL_RETRO_GET_MEMORY, &mem_info); + core_get_memory(&mem_info); memory += mem_info.size; @@ -2020,7 +2020,7 @@ bool cheevos_load(const void *data) /* The the supported extensions as a hint to what method we should use. */ - core_ctl(CORE_CTL_RETRO_GET_SYSTEM_INFO, &sysinfo); + core_get_system_info(&sysinfo); for (i = 0; i < sizeof(finders) / sizeof(finders[0]); i++) { diff --git a/command_event.c b/command_event.c index 95328a43c0..02ec85914b 100644 --- a/command_event.c +++ b/command_event.c @@ -388,7 +388,7 @@ static void event_init_controllers(void) { pad.device = device; pad.port = i; - core_ctl(CORE_CTL_RETRO_SET_CONTROLLER_PORT_DEVICE, &pad); + core_set_controller_port_device(&pad); } } } @@ -399,8 +399,8 @@ static void event_deinit_core(bool reinit) cheevos_unload(); #endif - core_ctl(CORE_CTL_RETRO_UNLOAD_GAME, NULL); - core_ctl(CORE_CTL_RETRO_DEINIT, NULL); + core_unload_game(); + core_unload(); if (reinit) { @@ -581,7 +581,7 @@ static bool event_init_core(void *data) retro_ctx_environ_info_t info; settings_t *settings = config_get_ptr(); - if (!core_ctl(CORE_CTL_RETRO_SYMBOLS_INIT, data)) + if (!core_init_symbols(data)) return false; runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_INIT, NULL); @@ -599,7 +599,7 @@ static bool event_init_core(void *data) video_driver_set_pixel_format(RETRO_PIXEL_FORMAT_0RGB1555); info.env = rarch_environment_cb; - core_ctl(CORE_CTL_RETRO_SET_ENVIRONMENT, &info); + core_set_environment(&info); /* Auto-remap: apply remap files */ if(settings->auto_remaps_enable) @@ -608,13 +608,13 @@ static bool event_init_core(void *data) /* Per-core saves: reset redirection paths */ rarch_ctl(RARCH_CTL_SET_PATHS_REDIRECT, NULL); - if (!core_ctl(CORE_CTL_RETRO_INIT, NULL)) + if (!core_init()) return false; if (!event_init_content()) return false; - if (!core_ctl(CORE_CTL_INIT, NULL)) + if (!core_load()) return false; return true; @@ -874,7 +874,7 @@ static void event_main_state(unsigned cmd) else strlcpy(path, global->name.savestate, sizeof(path)); - core_ctl(CORE_CTL_RETRO_SERIALIZE_SIZE, &info); + core_serialize_size(&info); if (info.size) { @@ -1091,7 +1091,7 @@ bool event_cmd_ctl(enum event_command cmd, void *data) #ifdef HAVE_CHEEVOS cheevos_set_cheats(); #endif - core_ctl(CORE_CTL_RETRO_RESET, NULL); + core_reset(); break; case EVENT_CMD_SAVE_STATE: #ifdef HAVE_CHEEVOS diff --git a/configuration.c b/configuration.c index 841051d8b2..992e0cdadd 100644 --- a/configuration.c +++ b/configuration.c @@ -2420,7 +2420,7 @@ void config_load(void) config_save_file(global->path.core_specific_config); /* Flush out some states that could have been set by core environment variables */ - core_ctl(CORE_CTL_UNSET_INPUT_DESCRIPTORS, NULL); + core_unset_input_descriptors(); if (!rarch_ctl(RARCH_CTL_IS_BLOCK_CONFIG_READ, NULL)) { diff --git a/content.c b/content.c index 40255786b5..dafce8b0a0 100644 --- a/content.c +++ b/content.c @@ -1017,7 +1017,7 @@ static bool content_save_state(const char *path) bool ret = false; void *data = NULL; - core_ctl(CORE_CTL_RETRO_SERIALIZE_SIZE, &info); + core_serialize_size(&info); RARCH_LOG("%s: \"%s\".\n", msg_hash_to_str(MSG_SAVING_STATE), @@ -1038,7 +1038,7 @@ static bool content_save_state(const char *path) serial_info.data = data; serial_info.size = info.size; - ret = core_ctl(CORE_CTL_RETRO_SERIALIZE, &serial_info); + ret = core_serialize(&serial_info); if (ret) ret = filestream_write_file(path, data, info.size); @@ -1108,7 +1108,7 @@ static bool content_load_state(const char *path) retro_ctx_memory_info_t mem_info; mem_info.id = blocks[i].type; - core_ctl(CORE_CTL_RETRO_GET_MEMORY, &mem_info); + core_get_memory(&mem_info); blocks[i].size = mem_info.size; } @@ -1127,7 +1127,7 @@ static bool content_load_state(const char *path) mem_info.id = blocks[i].type; - core_ctl(CORE_CTL_RETRO_GET_MEMORY, &mem_info); + core_get_memory(&mem_info); ptr = mem_info.data; if (ptr) @@ -1137,7 +1137,7 @@ static bool content_load_state(const char *path) serial_info.data_const = buf; serial_info.size = size; - ret = core_ctl(CORE_CTL_RETRO_UNSERIALIZE, &serial_info); + ret = core_unserialize(&serial_info); /* Flush back. */ for (i = 0; i < num_blocks; i++) @@ -1149,7 +1149,7 @@ static bool content_load_state(const char *path) mem_info.id = blocks[i].type; - core_ctl(CORE_CTL_RETRO_GET_MEMORY, &mem_info); + core_get_memory(&mem_info); ptr = mem_info.data; if (ptr) @@ -1193,7 +1193,7 @@ static bool load_ram_file(void *data) mem_info.id = ram->type; - core_ctl(CORE_CTL_RETRO_GET_MEMORY, &mem_info); + core_get_memory(&mem_info); if (mem_info.size == 0 || !mem_info.data) return false; @@ -1239,7 +1239,7 @@ static bool save_ram_file(ram_type_t *ram) mem_info.id = ram->type; - core_ctl(CORE_CTL_RETRO_GET_MEMORY, &mem_info); + core_get_memory(&mem_info); if (!mem_info.data || mem_info.size == 0) return false; @@ -1430,7 +1430,7 @@ static bool load_content( load_info.special = special; load_info.info = info; - if (!core_ctl(CORE_CTL_RETRO_LOAD_GAME, &load_info)) + if (!core_load_game(&load_info)) { RARCH_ERR("%s.\n", msg_hash_to_str(MSG_FAILED_TO_LOAD_CONTENT)); return false; diff --git a/driver.c b/driver.c index d6539af9f2..b236be464d 100644 --- a/driver.c +++ b/driver.c @@ -436,7 +436,7 @@ bool driver_ctl(enum driver_ctl_state state, void *data) #endif location_driver_ctl(RARCH_LOCATION_CTL_DESTROY, NULL); camera_driver_ctl(RARCH_CAMERA_CTL_DESTROY, NULL); - core_ctl(CORE_CTL_DEINIT, NULL); + core_uninit_libretro_callbacks(); break; case RARCH_DRIVER_CTL_UNINIT: { diff --git a/dynamic.c b/dynamic.c index 739c3500c1..db1f0adff2 100644 --- a/dynamic.c +++ b/dynamic.c @@ -514,7 +514,7 @@ void libretro_get_current_core_pathname(char *name, size_t size) if (size == 0) return; - core_ctl(CORE_CTL_RETRO_GET_SYSTEM_INFO, &info); + core_get_system_info(&info); if (info.library_name) id = info.library_name; @@ -875,7 +875,7 @@ bool rarch_environment_cb(unsigned cmd, void *data) } } - core_ctl(CORE_CTL_SET_INPUT_DESCRIPTORS, NULL); + core_set_input_descriptors(); break; } diff --git a/gfx/drivers_shader/shader_gl_cg.c b/gfx/drivers_shader/shader_gl_cg.c index 003fd28b4b..e4011d76b6 100644 --- a/gfx/drivers_shader/shader_gl_cg.c +++ b/gfx/drivers_shader/shader_gl_cg.c @@ -811,7 +811,7 @@ static bool gl_cg_load_imports(void *data) mem_info.id = memtype; - core_ctl(CORE_CTL_RETRO_GET_MEMORY, &mem_info); + core_get_memory(&mem_info); if ((memtype != -1u) && (cg->shader->variable[i].addr >= mem_info.size)) @@ -825,7 +825,7 @@ static bool gl_cg_load_imports(void *data) mem_info.size = 0; mem_info.id = RETRO_MEMORY_SYSTEM_RAM; - core_ctl(CORE_CTL_RETRO_GET_MEMORY, &mem_info); + core_get_memory(&mem_info); tracker_info.wram = (uint8_t*)mem_info.data; tracker_info.info = cg->shader->variable; diff --git a/gfx/drivers_shader/shader_glsl.c b/gfx/drivers_shader/shader_glsl.c index eb1778c874..14d98013b7 100644 --- a/gfx/drivers_shader/shader_glsl.c +++ b/gfx/drivers_shader/shader_glsl.c @@ -853,7 +853,7 @@ static void *gl_glsl_init(void *data, const char *path) mem_info.id = RETRO_MEMORY_SYSTEM_RAM; - core_ctl(CORE_CTL_RETRO_GET_MEMORY, &mem_info); + core_get_memory(&mem_info); info.wram = (uint8_t*)mem_info.data; info.info = glsl->shader->variable; diff --git a/gfx/video_driver.c b/gfx/video_driver.c index a4041a6f81..5ce5c325be 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -1107,7 +1107,7 @@ static bool video_driver_cached_frame(void) if (video_driver_state.frame_cache.data != RETRO_HW_FRAME_BUFFER_VALID) info.data = video_driver_state.frame_cache.data; - core_ctl(CORE_CTL_RETRO_CTX_FRAME_CB, &info); + core_frame(&info); recording_driver_set_data_ptr(recording); @@ -1804,7 +1804,7 @@ bool video_driver_ctl(enum rarch_display_ctl_state state, void *data) case RARCH_DISPLAY_CTL_SET_TITLE_BUF: { struct retro_system_info info; - core_ctl(CORE_CTL_RETRO_GET_SYSTEM_INFO, &info); + core_get_system_info(&info); strlcpy(video_driver_title_buf, msg_hash_to_str(MSG_PROGRAM), sizeof(video_driver_title_buf)); diff --git a/gfx/video_state_python.c b/gfx/video_state_python.c index c875a6d975..6df023816f 100644 --- a/gfx/video_state_python.c +++ b/gfx/video_state_python.c @@ -40,7 +40,7 @@ static PyObject* py_read_wram(PyObject *self, PyObject *args) mem_info.id = RETRO_MEMORY_SYSTEM_RAM; - core_ctl(CORE_CTL_RETRO_GET_MEMORY, &mem_info); + core_get_memory(&mem_info); data = (const uint8_t*)mem_info.data; @@ -75,7 +75,7 @@ static PyObject* py_read_vram(PyObject *self, PyObject *args) mem_info.id = RETRO_MEMORY_VIDEO_RAM; - core_ctl(CORE_CTL_RETRO_GET_MEMORY, &mem_info); + core_get_memory(&mem_info); data = (const uint8_t*)mem_info.data; diff --git a/libretro_version_1.c b/libretro_version_1.c index 438dd9f8c1..34683c4591 100644 --- a/libretro_version_1.c +++ b/libretro_version_1.c @@ -64,45 +64,11 @@ static int16_t core_input_state_poll(unsigned port, return input_state(port, device, idx, id); } -/** - * core_set_default_callbacks: - * @data : pointer to retro_callbacks object - * - * Binds the libretro callbacks to default callback functions. - **/ -static bool core_set_default_callbacks(void *data) +void core_set_input_state(retro_ctx_input_state_info_t *info) { - struct retro_callbacks *cbs = (struct retro_callbacks*)data; - - if (!cbs) - return false; - - cbs->frame_cb = video_driver_frame; - cbs->sample_cb = audio_driver_sample; - cbs->sample_batch_cb = audio_driver_sample_batch; - cbs->state_cb = core_input_state_poll; - cbs->poll_cb = input_poll; - - return true; + core.retro_set_input_state(info->cb); } -static bool core_uninit_libretro_cbs(void *data) -{ - struct retro_callbacks *cbs = (struct retro_callbacks*)data; - - if (!cbs) - return false; - - cbs->frame_cb = NULL; - cbs->sample_cb = NULL; - cbs->sample_batch_cb = NULL; - cbs->state_cb = NULL; - cbs->poll_cb = NULL; - - return true; -} - - /** * core_init_libretro_cbs: * @data : pointer to retro_callbacks object @@ -126,7 +92,7 @@ static bool core_init_libretro_cbs(void *data) core.retro_set_input_state(core_input_state_poll); core.retro_set_input_poll(core_input_state_poll_maybe); - core_ctl(CORE_CTL_SET_CBS, cbs); + core_set_default_callbacks(cbs); #ifdef HAVE_NETPLAY if (!netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_DATA_INITED, NULL)) @@ -154,13 +120,57 @@ static bool core_init_libretro_cbs(void *data) return true; } +/** + * core_set_default_callbacks: + * @data : pointer to retro_callbacks object + * + * Binds the libretro callbacks to default callback functions. + **/ +bool core_set_default_callbacks(void *data) +{ + struct retro_callbacks *cbs = (struct retro_callbacks*)data; + + if (!cbs) + return false; + + cbs->frame_cb = video_driver_frame; + cbs->sample_cb = audio_driver_sample; + cbs->sample_batch_cb = audio_driver_sample_batch; + cbs->state_cb = core_input_state_poll; + cbs->poll_cb = input_poll; + + return true; +} + + +bool core_deinit(void *data) +{ + struct retro_callbacks *cbs = (struct retro_callbacks*)data; + + if (!cbs) + return false; + + cbs->frame_cb = NULL; + cbs->sample_cb = NULL; + cbs->sample_batch_cb = NULL; + cbs->state_cb = NULL; + cbs->poll_cb = NULL; + + return true; +} + +bool core_uninit_libretro_callbacks(void) +{ + return core_deinit(&retro_ctx); +} + /** * core_set_rewind_callbacks: * * Sets the audio sampling callbacks based on whether or not * rewinding is currently activated. **/ -static void core_set_rewind_callbacks(void) +bool core_set_rewind_callbacks(void) { if (state_manager_frame_is_reversed()) { @@ -172,211 +182,224 @@ static void core_set_rewind_callbacks(void) core.retro_set_audio_sample(audio_driver_sample); core.retro_set_audio_sample_batch(audio_driver_sample_batch); } + return true; } -bool core_ctl(enum core_ctl_state state, void *data) +bool core_set_cheat(retro_ctx_cheat_info_t *info) { + core.retro_cheat_set(info->index, info->enabled, info->code); + return true; +} - switch (state) +bool core_reset_cheat(void) +{ + core.retro_cheat_reset(); + return true; +} + +bool core_api_version(retro_ctx_api_info_t *api) +{ + if (!api) + return false; + api->version = core.retro_api_version(); + return true; +} + +bool core_set_poll_type(unsigned *type) +{ + core_poll_type = *type; + return true; +} + +bool core_init_symbols(enum rarch_core_type *type) +{ + if (!type) + return false; + init_libretro_sym(*type, &core); + return true; +} + +bool core_set_controller_port_device(retro_ctx_controller_info_t *pad) +{ + if (!pad) + return false; + core.retro_set_controller_port_device(pad->port, pad->device); + return true; +} + +bool core_get_memory(retro_ctx_memory_info_t *info) +{ + if (!info) + return false; + info->size = core.retro_get_memory_size(info->id); + info->data = core.retro_get_memory_data(info->id); + return true; +} + +bool core_load_game(retro_ctx_load_content_info_t *load_info) +{ + if (!load_info) + return false; + + if (load_info->special) + return core.retro_load_game_special(load_info->special->id, load_info->info, load_info->content->size); + return core.retro_load_game(*load_info->content->elems[0].data ? load_info->info : NULL); +} + +bool core_get_system_info(struct retro_system_info *system) +{ + if (!system) + return false; + core.retro_get_system_info(system); + return true; +} + +bool core_unserialize(retro_ctx_serialize_info_t *info) +{ + if (!info) + return false; + if (!core.retro_unserialize(info->data_const, info->size)) + return false; + return true; +} + +bool core_serialize(retro_ctx_serialize_info_t *info) +{ + if (!info) + return false; + if (!core.retro_serialize(info->data, info->size)) + return false; + return true; +} + +bool core_serialize_size(retro_ctx_size_info_t *info) +{ + if (!info) + return false; + info->size = core.retro_serialize_size(); + return true; +} + +bool core_frame(retro_ctx_frame_info_t *info) +{ + if (!info || !retro_ctx.frame_cb) + return false; + + retro_ctx.frame_cb( + info->data, info->width, info->height, info->pitch); + return true; +} + +bool core_poll(void) +{ + if (!retro_ctx.poll_cb) + return false; + retro_ctx.poll_cb(); + return true; +} + +bool core_set_environment(retro_ctx_environ_info_t *info) +{ + if (!info) + return false; + core.retro_set_environment(info->env); + return true; +} + +bool core_get_system_av_info(struct retro_system_av_info *av_info) +{ + if (!av_info) + return false; + core.retro_get_system_av_info(av_info); + return true; +} + +bool core_reset(void) +{ + core.retro_reset(); + return true; +} + +bool core_init(void) +{ + core.retro_init(); + return true; +} + +bool core_unload(void) +{ + core.retro_deinit(); + uninit_libretro_sym(&core); + return true; +} + +bool core_unload_game(void) +{ + video_driver_ctl(RARCH_DISPLAY_CTL_DEINIT_HW_CONTEXT, NULL); + audio_driver_ctl(RARCH_AUDIO_CTL_STOP, NULL); + core.retro_unload_game(); + return true; +} + +bool core_run(void) +{ + switch (core_poll_type) { - case CORE_CTL_RETRO_CHEAT_SET: - { - retro_ctx_cheat_info_t *info = (retro_ctx_cheat_info_t*)data; - core.retro_cheat_set(info->index, info->enabled, info->code); - } + case POLL_TYPE_EARLY: + input_poll(); break; - case CORE_CTL_RETRO_CHEAT_RESET: - core.retro_cheat_reset(); - break; - case CORE_CTL_RETRO_API_VERSION: - { - retro_ctx_api_info_t *api = (retro_ctx_api_info_t*)data; - api->version = core.retro_api_version(); - } - break; - case CORE_CTL_SET_POLL_TYPE: - { - unsigned *poll_type = (unsigned*)data; - core_poll_type = *poll_type; - } - break; - case CORE_CTL_RETRO_SYMBOLS_INIT: - { - enum rarch_core_type *core_type = (enum rarch_core_type*)data; - - if (!core_type) - return false; - init_libretro_sym(*core_type, &core); - } - break; - case CORE_CTL_RETRO_SET_CONTROLLER_PORT_DEVICE: - { - retro_ctx_controller_info_t *pad = (retro_ctx_controller_info_t*)data; - if (!pad) - return false; - core.retro_set_controller_port_device(pad->port, pad->device); - } - break; - case CORE_CTL_RETRO_GET_MEMORY: - { - retro_ctx_memory_info_t *info = (retro_ctx_memory_info_t*)data; - if (!info) - return false; - info->size = core.retro_get_memory_size(info->id); - info->data = core.retro_get_memory_data(info->id); - } - break; - case CORE_CTL_RETRO_LOAD_GAME: - { - retro_ctx_load_content_info_t *load_info = - (retro_ctx_load_content_info_t*)data; - if (!load_info) - return false; - - if (load_info->special) - return core.retro_load_game_special(load_info->special->id, load_info->info, load_info->content->size); - return core.retro_load_game(*load_info->content->elems[0].data ? load_info->info : NULL); - } - case CORE_CTL_RETRO_GET_SYSTEM_INFO: - { - struct retro_system_info *system = (struct retro_system_info*)data; - if (!system) - return false; - core.retro_get_system_info(system); - } - break; - case CORE_CTL_RETRO_UNSERIALIZE: - { - retro_ctx_serialize_info_t *info = (retro_ctx_serialize_info_t*)data; - if (!info) - return false; - if (!core.retro_unserialize(info->data_const, info->size)) - return false; - } - break; - case CORE_CTL_RETRO_SERIALIZE: - { - retro_ctx_serialize_info_t *info = (retro_ctx_serialize_info_t*)data; - if (!info) - return false; - if (!core.retro_serialize(info->data, info->size)) - return false; - } - break; - case CORE_CTL_RETRO_SERIALIZE_SIZE: - { - retro_ctx_size_info_t *info = (retro_ctx_size_info_t *)data; - if (!info) - return false; - info->size = core.retro_serialize_size(); - } - break; - case CORE_CTL_RETRO_CTX_FRAME_CB: - { - retro_ctx_frame_info_t *info = (retro_ctx_frame_info_t*)data; - if (!info || !retro_ctx.frame_cb) - return false; - - retro_ctx.frame_cb( - info->data, info->width, info->height, info->pitch); - } - break; - case CORE_CTL_RETRO_CTX_POLL_CB: - if (!retro_ctx.poll_cb) - return false; - retro_ctx.poll_cb(); - break; - case CORE_CTL_RETRO_SET_ENVIRONMENT: - { - retro_ctx_environ_info_t *info = (retro_ctx_environ_info_t*)data; - if (!info) - return false; - core.retro_set_environment(info->env); - } - break; - case CORE_CTL_RETRO_GET_SYSTEM_AV_INFO: - { - struct retro_system_av_info *av_info = (struct retro_system_av_info*)data; - if (!av_info) - return false; - core.retro_get_system_av_info(av_info); - } - break; - case CORE_CTL_RETRO_RESET: - core.retro_reset(); - break; - case CORE_CTL_RETRO_INIT: - core.retro_init(); - break; - case CORE_CTL_RETRO_DEINIT: - core.retro_deinit(); - uninit_libretro_sym(&core); - break; - case CORE_CTL_RETRO_UNLOAD_GAME: - video_driver_ctl(RARCH_DISPLAY_CTL_DEINIT_HW_CONTEXT, NULL); - audio_driver_ctl(RARCH_AUDIO_CTL_STOP, NULL); - core.retro_unload_game(); - break; - case CORE_CTL_RETRO_RUN: - switch (core_poll_type) - { - case POLL_TYPE_EARLY: - input_poll(); - break; - case POLL_TYPE_LATE: - core_input_polled = false; - break; - } - if (core.retro_run) - core.retro_run(); - if (core_poll_type == POLL_TYPE_LATE && !core_input_polled) - input_poll(); - break; - case CORE_CTL_SET_CBS: - return core_set_default_callbacks(data); - case CORE_CTL_SET_CBS_REWIND: - core_set_rewind_callbacks(); - break; - case CORE_CTL_INIT: - { - settings_t *settings = config_get_ptr(); - core_poll_type = settings->input.poll_type_behavior; - if (!core_ctl(CORE_CTL_VERIFY_API_VERSION, NULL)) - return false; - if (!core_init_libretro_cbs(&retro_ctx)) - return false; - core_ctl(CORE_CTL_RETRO_GET_SYSTEM_AV_INFO, - video_viewport_get_system_av_info()); - runloop_ctl(RUNLOOP_CTL_SET_FRAME_LIMIT, NULL); - } - break; - case CORE_CTL_DEINIT: - return core_uninit_libretro_cbs(&retro_ctx); - case CORE_CTL_VERIFY_API_VERSION: - { - unsigned api_version = core.retro_api_version(); - RARCH_LOG("Version of libretro API: %u\n", api_version); - RARCH_LOG("Compiled against API: %u\n", RETRO_API_VERSION); - - if (api_version != RETRO_API_VERSION) - { - RARCH_WARN("%s\n", msg_hash_to_str(MSG_LIBRETRO_ABI_BREAK)); - return false; - } - } - break; - case CORE_CTL_HAS_SET_INPUT_DESCRIPTORS: - return core_has_set_input_descriptors; - case CORE_CTL_SET_INPUT_DESCRIPTORS: - core_has_set_input_descriptors = true; - break; - case CORE_CTL_UNSET_INPUT_DESCRIPTORS: - core_has_set_input_descriptors = false; - break; - case CORE_CTL_NONE: - default: + case POLL_TYPE_LATE: + core_input_polled = false; break; } + if (core.retro_run) + core.retro_run(); + if (core_poll_type == POLL_TYPE_LATE && !core_input_polled) + input_poll(); + return true; +} + +bool core_load(void) +{ + settings_t *settings = config_get_ptr(); + core_poll_type = settings->input.poll_type_behavior; + + if (!core_verify_api_version()) + return false; + if (!core_init_libretro_cbs(&retro_ctx)) + return false; + + core_get_system_av_info(video_viewport_get_system_av_info()); + runloop_ctl(RUNLOOP_CTL_SET_FRAME_LIMIT, NULL); return true; } + +bool core_verify_api_version(void) +{ + unsigned api_version = core.retro_api_version(); + RARCH_LOG("Version of libretro API: %u\n", api_version); + RARCH_LOG("Compiled against API: %u\n", RETRO_API_VERSION); + + if (api_version != RETRO_API_VERSION) + { + RARCH_WARN("%s\n", msg_hash_to_str(MSG_LIBRETRO_ABI_BREAK)); + return false; + } + return true; +} + +bool core_has_set_input_descriptor(void) +{ + return core_has_set_input_descriptors; +} + +void core_set_input_descriptors(void) +{ + core_has_set_input_descriptors = true; +} + +void core_unset_input_descriptors(void) +{ + core_has_set_input_descriptors = false; +} diff --git a/libretro_version_1.h b/libretro_version_1.h index 01799e00d7..ad7f00be5c 100644 --- a/libretro_version_1.h +++ b/libretro_version_1.h @@ -24,6 +24,7 @@ extern "C" { #include +#include "core_type.h" #include "libretro.h" enum @@ -40,83 +41,6 @@ enum POLL_TYPE_LATE }; -enum core_ctl_state -{ - CORE_CTL_NONE = 0, - - CORE_CTL_INIT, - - CORE_CTL_DEINIT, - - - CORE_CTL_SET_CBS, - - CORE_CTL_SET_CBS_REWIND, - - CORE_CTL_SET_POLL_TYPE, - - /* Runs the core for one frame. */ - CORE_CTL_RETRO_RUN, - - CORE_CTL_RETRO_INIT, - - CORE_CTL_RETRO_DEINIT, - - CORE_CTL_RETRO_UNLOAD_GAME, - - CORE_CTL_RETRO_RESET, - - CORE_CTL_RETRO_GET_SYSTEM_AV_INFO, - - CORE_CTL_RETRO_CTX_FRAME_CB, - - CORE_CTL_RETRO_CTX_POLL_CB, - - CORE_CTL_RETRO_SET_ENVIRONMENT, - - CORE_CTL_RETRO_SERIALIZE_SIZE, - - CORE_CTL_RETRO_SERIALIZE, - - CORE_CTL_RETRO_UNSERIALIZE, - - CORE_CTL_RETRO_SYMBOLS_INIT, - - CORE_CTL_RETRO_CHEAT_SET, - - CORE_CTL_RETRO_CHEAT_RESET, - - CORE_CTL_RETRO_SET_INPUT_STATE, - - CORE_CTL_RETRO_API_VERSION, - - /* Compare libretro core API version against API version - * used by RetroArch. - * - * TODO - when libretro v2 gets added, allow for switching - * between libretro version backend dynamically. - */ - CORE_CTL_VERIFY_API_VERSION, - - CORE_CTL_RETRO_GET_MEMORY, - - /* Initialize system A/V information. */ - CORE_CTL_INIT_SYSTEM_AV_INFO, - - /* Get system A/V information. */ - CORE_CTL_RETRO_GET_SYSTEM_INFO, - - CORE_CTL_RETRO_LOAD_GAME, - - CORE_CTL_RETRO_SET_CONTROLLER_PORT_DEVICE, - - CORE_CTL_HAS_SET_INPUT_DESCRIPTORS, - - CORE_CTL_SET_INPUT_DESCRIPTORS, - - CORE_CTL_UNSET_INPUT_DESCRIPTORS -}; - typedef struct retro_ctx_input_state_info { retro_input_state_t cb; @@ -188,7 +112,76 @@ typedef struct retro_callbacks retro_input_poll_t poll_cb; } retro_callbacks_t; -bool core_ctl(enum core_ctl_state state, void *data); +bool core_load(void); + +bool core_unload(void); + +bool core_set_default_callbacks(void *data); + +bool core_set_rewind_callbacks(void); + +bool core_set_poll_type(unsigned *type); + +/* Runs the core for one frame. */ +bool core_run(void); + +bool core_init(void); + +bool core_deinit(void *data); + +bool core_unload_game(void); + +bool core_reset(void); + +bool core_frame(retro_ctx_frame_info_t *info); + +bool core_poll(void); + +bool core_set_environment(retro_ctx_environ_info_t *info); + +bool core_serialize_size(retro_ctx_size_info_t *info); + +bool core_serialize(retro_ctx_serialize_info_t *info); + +bool core_unserialize(retro_ctx_serialize_info_t *info); + +bool core_init_symbols(enum rarch_core_type *type); + +bool core_set_cheat(retro_ctx_cheat_info_t *info); + +bool core_reset_cheat(void); + +bool core_api_version(retro_ctx_api_info_t *api); + +/* Compare libretro core API version against API version + * used by RetroArch. + * + * TODO - when libretro v2 gets added, allow for switching + * between libretro version backend dynamically. + */ +bool core_verify_api_version(void); + +bool core_get_memory(retro_ctx_memory_info_t *info); + +/* Initialize system A/V information. */ +bool core_get_system_av_info(struct retro_system_av_info *av_info); + +/* Get system A/V information. */ +bool core_get_system_info(struct retro_system_info *system); + +bool core_load_game(retro_ctx_load_content_info_t *load_info); + +bool core_set_controller_port_device(retro_ctx_controller_info_t *pad); + +bool core_has_set_input_descriptor(void); + +void core_set_input_descriptors(void); + +void core_unset_input_descriptors(void); + +bool core_uninit_libretro_callbacks(void); + +void core_set_input_state(retro_ctx_input_state_info_t *info); #ifdef __cplusplus } diff --git a/menu/menu_display.c b/menu/menu_display.c index 1b0b4c0dc1..5c7cc0a40a 100644 --- a/menu/menu_display.c +++ b/menu/menu_display.c @@ -282,7 +282,7 @@ bool menu_display_ctl(enum menu_display_ctl_state state, void *data) input_driver_ctl( RARCH_INPUT_CTL_SET_LIBRETRO_INPUT_BLOCKED, NULL); - core_ctl(CORE_CTL_RETRO_RUN, NULL); + core_run(); input_driver_ctl( RARCH_INPUT_CTL_UNSET_LIBRETRO_INPUT_BLOCKED, NULL); diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 85d0bbfdeb..28548d2835 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -2197,7 +2197,7 @@ static int menu_displaylist_parse_load_content_settings( menu_hash_to_str(MENU_LABEL_CORE_OPTIONS), MENU_SETTING_ACTION, 0, 0); - if (core_ctl(CORE_CTL_HAS_SET_INPUT_DESCRIPTORS, NULL)) + if (core_has_set_input_descriptor()) menu_entries_add(info->list, menu_hash_to_str(MENU_LABEL_VALUE_CORE_INPUT_REMAPPING_OPTIONS), menu_hash_to_str(MENU_LABEL_CORE_INPUT_REMAPPING_OPTIONS), diff --git a/menu/menu_input.c b/menu/menu_input.c index e2081f823f..9f4ceb3826 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -1288,7 +1288,7 @@ unsigned menu_input_frame_retropad(retro_input_t input, if (!menu_input) return 0; - core_ctl(CORE_CTL_RETRO_CTX_POLL_CB, NULL); + core_poll(); /* don't run anything first frame, only capture held inputs * for old_input_state. */ diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 436a4e17c1..cff7817e2f 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -2327,7 +2327,7 @@ static int setting_action_start_libretro_device_type(void *data) pad.port = port; pad.device = current_device; - core_ctl(CORE_CTL_RETRO_SET_CONTROLLER_PORT_DEVICE, &pad); + core_set_controller_port_device(&pad); return 0; } @@ -2488,7 +2488,7 @@ static int setting_action_left_libretro_device_type( pad.port = port; pad.device = current_device; - core_ctl(CORE_CTL_RETRO_SET_CONTROLLER_PORT_DEVICE, &pad); + core_set_controller_port_device(&pad); return 0; } @@ -2553,7 +2553,7 @@ static int setting_action_right_libretro_device_type( pad.port = port; pad.device = current_device; - core_ctl(CORE_CTL_RETRO_SET_CONTROLLER_PORT_DEVICE, &pad); + core_set_controller_port_device(&pad); return 0; } @@ -2915,7 +2915,7 @@ void general_write_handler(void *data) } break; case MENU_LABEL_INPUT_POLL_TYPE_BEHAVIOR: - core_ctl(CORE_CTL_SET_POLL_TYPE, setting->value.target.integer); + core_set_poll_type((unsigned int*)setting->value.target.integer); break; case MENU_LABEL_VIDEO_SCALE_INTEGER: { @@ -3408,7 +3408,7 @@ static bool setting_append_list_input_player_options( if ( settings->input.input_descriptor_label_show && (i < RARCH_FIRST_META_KEY) - && (core_ctl(CORE_CTL_HAS_SET_INPUT_DESCRIPTORS, NULL)) + && core_has_set_input_descriptor() && (i != RARCH_TURBO_ENABLE) ) { diff --git a/movie.c b/movie.c index e56f960fae..086e8bbcdb 100644 --- a/movie.c +++ b/movie.c @@ -120,13 +120,13 @@ static bool init_playback(bsv_movie_t *handle, const char *path) return false; } - core_ctl(CORE_CTL_RETRO_SERIALIZE_SIZE, &info); + core_serialize_size( &info); if (info.size == state_size) { serial_info.data_const = handle->state; serial_info.size = state_size; - core_ctl(CORE_CTL_RETRO_UNSERIALIZE, &serial_info); + core_unserialize(&serial_info); } else RARCH_WARN("Movie format seems to have a different serializer version. Will most likely fail.\n"); @@ -158,7 +158,7 @@ static bool init_record(bsv_movie_t *handle, const char *path) header[MAGIC_INDEX] = swap_if_little32(BSV_MAGIC); header[CRC_INDEX] = swap_if_big32(*content_crc_ptr); - core_ctl(CORE_CTL_RETRO_SERIALIZE_SIZE, &info); + core_serialize_size(&info); state_size = info.size; @@ -180,7 +180,7 @@ static bool init_record(bsv_movie_t *handle, const char *path) serial_info.data = handle->state; serial_info.size = state_size; - core_ctl(CORE_CTL_RETRO_SERIALIZE, &serial_info); + core_serialize(&serial_info); fwrite(handle->state, 1, state_size, handle->file); } @@ -289,7 +289,7 @@ static void bsv_movie_frame_rewind(bsv_movie_t *handle) serial_info.data = handle->state; serial_info.size = handle->state_size; - core_ctl(CORE_CTL_RETRO_SERIALIZE, &serial_info); + core_serialize(&serial_info); fwrite(handle->state, 1, handle->state_size, handle->file); } diff --git a/netplay/netplay.c b/netplay/netplay.c index bc99c971b5..78c5b7feba 100644 --- a/netplay/netplay.c +++ b/netplay/netplay.c @@ -1030,7 +1030,7 @@ static int16_t netplay_get_spectate_input(netplay_t *netplay, bool port, input_info.cb = netplay->cbs.state_cb; - core_ctl(CORE_CTL_RETRO_SET_INPUT_STATE, &input_info); + core_set_input_state(&input_info); return netplay->cbs.state_cb(port, device, idx, id); } @@ -1103,7 +1103,7 @@ bool init_netplay(void) return false; } - core_ctl(CORE_CTL_SET_CBS, &cbs); + core_set_default_callbacks(&cbs); if (*global->netplay.server) { diff --git a/netplay/netplay_common.c b/netplay/netplay_common.c index b27f8de36b..dbdcb9e8fb 100644 --- a/netplay/netplay_common.c +++ b/netplay/netplay_common.c @@ -69,7 +69,7 @@ uint32_t *np_bsv_header_generate(size_t *size, uint32_t magic) size_t serialize_size, header_size; uint32_t *header, bsv_header[4] = {0}; - core_ctl(CORE_CTL_RETRO_SERIALIZE_SIZE, &info); + core_serialize_size(&info); serialize_size = info.size; header_size = sizeof(bsv_header) + serialize_size; @@ -88,7 +88,7 @@ uint32_t *np_bsv_header_generate(size_t *size, uint32_t magic) serial_info.data = header + 4; serial_info.size = serialize_size; - if (serialize_size && !core_ctl(CORE_CTL_RETRO_SERIALIZE, &serial_info)) + if (serialize_size && !core_serialize(&serial_info)) goto error; memcpy(header, bsv_header, sizeof(bsv_header)); @@ -132,7 +132,7 @@ bool np_bsv_parse_header(const uint32_t *header, uint32_t magic) return false; } - core_ctl(CORE_CTL_RETRO_SERIALIZE_SIZE, &info); + core_serialize_size(&info); in_state_size = swap_if_big32(header[STATE_SIZE_INDEX]); if (in_state_size != info.size) @@ -165,7 +165,7 @@ uint32_t np_impl_magic(void) const char *lib = NULL; const char *ver = PACKAGE_VERSION; - core_ctl(CORE_CTL_RETRO_API_VERSION, &api_info); + core_api_version(&api_info); api = api_info.version; @@ -204,7 +204,7 @@ bool np_send_info(netplay_t *netplay) mem_info.id = RETRO_MEMORY_SAVE_RAM; - core_ctl(CORE_CTL_RETRO_GET_MEMORY, &mem_info); + core_get_memory(&mem_info); content_ctl(CONTENT_CTL_GET_CRC, &content_crc_ptr); header[0] = htonl(*content_crc_ptr); @@ -274,7 +274,7 @@ bool np_get_info(netplay_t *netplay) mem_info.id = RETRO_MEMORY_SAVE_RAM; - core_ctl(CORE_CTL_RETRO_GET_MEMORY, &mem_info); + core_get_memory(&mem_info); if (mem_info.size != ntohl(header[2])) { diff --git a/netplay/netplay_net.c b/netplay/netplay_net.c index 6f19a5ce22..fa64b6f880 100644 --- a/netplay/netplay_net.c +++ b/netplay/netplay_net.c @@ -28,7 +28,7 @@ static void netplay_net_pre_frame(netplay_t *netplay) serial_info.data = netplay->buffer[netplay->self_ptr].state; serial_info.size = netplay->state_size; - core_ctl(CORE_CTL_RETRO_SERIALIZE, &serial_info); + core_serialize(&serial_info); netplay->can_poll = true; @@ -77,7 +77,7 @@ static void netplay_net_post_frame(netplay_t *netplay) serial_info.data_const = netplay->buffer[netplay->other_ptr].state; serial_info.size = netplay->state_size; - core_ctl(CORE_CTL_RETRO_UNSERIALIZE, &serial_info); + core_unserialize(&serial_info); while (first || (netplay->tmp_ptr != netplay->self_ptr)) { @@ -85,12 +85,12 @@ static void netplay_net_post_frame(netplay_t *netplay) serial_info.size = netplay->state_size; serial_info.data_const = NULL; - core_ctl(CORE_CTL_RETRO_SERIALIZE, &serial_info); + core_serialize(&serial_info); #if defined(HAVE_THREADS) lock_autosave(); #endif - core_ctl(CORE_CTL_RETRO_RUN, NULL); + core_run(); #if defined(HAVE_THREADS) unlock_autosave(); #endif @@ -118,7 +118,7 @@ static bool netplay_net_init_buffers(netplay_t *netplay) if (!netplay->buffer) return false; - core_ctl(CORE_CTL_RETRO_SERIALIZE_SIZE, &info); + core_serialize_size(&info); netplay->state_size = info.size; diff --git a/rewind.c b/rewind.c index 22274aa35f..f1c54f0796 100644 --- a/rewind.c +++ b/rewind.c @@ -637,7 +637,7 @@ void init_rewind(void) return; } - core_ctl(CORE_CTL_RETRO_SERIALIZE_SIZE, &info); + core_serialize_size(&info); rewind_state.size = info.size; @@ -663,7 +663,7 @@ void init_rewind(void) serial_info.data = state; serial_info.size = rewind_state.size; - core_ctl(CORE_CTL_RETRO_SERIALIZE, &serial_info); + core_serialize(&serial_info); state_manager_push_do(rewind_state.state); } @@ -732,7 +732,7 @@ void state_manager_check_rewind(bool pressed) serial_info.data_const = buf; serial_info.size = rewind_state.size; - core_ctl(CORE_CTL_RETRO_UNSERIALIZE, &serial_info); + core_unserialize(&serial_info); if (bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL)) bsv_movie_ctl(BSV_MOVIE_CTL_FRAME_REWIND, NULL); @@ -763,7 +763,7 @@ void state_manager_check_rewind(bool pressed) serial_info.data = state; serial_info.size = rewind_state.size; - core_ctl(CORE_CTL_RETRO_SERIALIZE, &serial_info); + core_serialize(&serial_info); retro_perf_stop(&rewind_serialize); @@ -771,5 +771,5 @@ void state_manager_check_rewind(bool pressed) } } - core_ctl(CORE_CTL_SET_CBS_REWIND, NULL); + core_set_rewind_callbacks(); } diff --git a/runloop.c b/runloop.c index 5005cba5e9..d70d27689d 100644 --- a/runloop.c +++ b/runloop.c @@ -561,7 +561,7 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) case RUNLOOP_CTL_SHADER_DIR_INIT: return shader_dir_init(&runloop_shader_dir); case RUNLOOP_CTL_SYSTEM_INFO_INIT: - core_ctl(CORE_CTL_RETRO_GET_SYSTEM_INFO, &runloop_system.info); + core_get_system_info(&runloop_system.info); if (!runloop_system.info.library_name) runloop_system.info.library_name = msg_hash_to_str(MSG_UNKNOWN); @@ -914,7 +914,7 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) runloop_ctl(RUNLOOP_CTL_CLEAR_CONTENT_PATH, NULL); runloop_overrides_active = false; - core_ctl(CORE_CTL_UNSET_INPUT_DESCRIPTORS, NULL); + core_unset_input_descriptors(); global = global_get_ptr(); memset(global, 0, sizeof(struct global)); @@ -1428,7 +1428,7 @@ int runloop_iterate(unsigned *sleep_ms) if (!runloop_ctl(RUNLOOP_CTL_CHECK_STATE, &cmd)) { /* RetroArch has been paused. */ - core_ctl(CORE_CTL_RETRO_CTX_POLL_CB, NULL); + core_poll(); *sleep_ms = 10; return 1; } @@ -1462,7 +1462,7 @@ int runloop_iterate(unsigned *sleep_ms) !input_driver_ctl(RARCH_INPUT_CTL_IS_NONBLOCK_STATE, NULL)) retro_sleep(settings->video.frame_delay); - core_ctl(CORE_CTL_RETRO_RUN, NULL); + core_run(); #ifdef HAVE_CHEEVOS cheevos_test(); From a64fe6ce6303269d6cb1b5506ce5ea92cbc73980 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 01:41:32 +0200 Subject: [PATCH 229/498] Move static variables outside of runloop_ctl --- runloop.c | 53 ++++++++++++++++++++++++++--------------------------- 1 file changed, 26 insertions(+), 27 deletions(-) diff --git a/runloop.c b/runloop.c index d70d27689d..73064e0b5b 100644 --- a/runloop.c +++ b/runloop.c @@ -97,7 +97,32 @@ typedef struct event_cmd_state retro_input_t state[3]; } event_cmd_state_t; - +static rarch_dir_list_t runloop_shader_dir; +static char runloop_fullpath[PATH_MAX_LENGTH]; +static rarch_system_info_t runloop_system; +static unsigned runloop_pending_windowed_scale; +static struct retro_frame_time_callback runloop_frame_time; +static retro_keyboard_event_t runloop_key_event = NULL; +static retro_keyboard_event_t runloop_frontend_key_event = NULL; +static retro_usec_t runloop_frame_time_last = 0; +static unsigned runloop_max_frames = false; +static bool runloop_force_nonblock = false; +static bool runloop_frame_time_last_enable = false; +static bool runloop_set_frame_limit = false; +static bool runloop_paused = false; +static bool runloop_idle = false; +static bool runloop_exec = false; +static bool runloop_slowmotion = false; +static bool runloop_shutdown_initiated = false; +static bool runloop_core_shutdown_initiated = false; +static bool runloop_perfcnt_enable = false; +static bool runloop_overrides_active = false; +static bool runloop_game_options_active = false; +static core_option_manager_t *runloop_core_options = NULL; +#ifdef HAVE_THREADS +static slock_t *runloop_msg_queue_lock = NULL; +#endif +static msg_queue_t *runloop_msg_queue = NULL; global_t *global_get_ptr(void) { @@ -522,32 +547,6 @@ static bool runloop_check_pause_state(event_cmd_state_t *cmd) bool runloop_ctl(enum runloop_ctl_state state, void *data) { - static rarch_dir_list_t runloop_shader_dir; - static char runloop_fullpath[PATH_MAX_LENGTH]; - static rarch_system_info_t runloop_system; - static unsigned runloop_pending_windowed_scale; - static struct retro_frame_time_callback runloop_frame_time; - static retro_keyboard_event_t runloop_key_event = NULL; - static retro_keyboard_event_t runloop_frontend_key_event = NULL; - static retro_usec_t runloop_frame_time_last = 0; - static unsigned runloop_max_frames = false; - static bool runloop_force_nonblock = false; - static bool runloop_frame_time_last_enable = false; - static bool runloop_set_frame_limit = false; - static bool runloop_paused = false; - static bool runloop_idle = false; - static bool runloop_exec = false; - static bool runloop_slowmotion = false; - static bool runloop_shutdown_initiated = false; - static bool runloop_core_shutdown_initiated = false; - static bool runloop_perfcnt_enable = false; - static bool runloop_overrides_active = false; - static bool runloop_game_options_active = false; - static core_option_manager_t *runloop_core_options = NULL; -#ifdef HAVE_THREADS - static slock_t *runloop_msg_queue_lock = NULL; -#endif - static msg_queue_t *runloop_msg_queue = NULL; settings_t *settings = config_get_ptr(); switch (state) From 6999322a539024472dd71ae9ad9bb401291f7081 Mon Sep 17 00:00:00 2001 From: radius Date: Sat, 7 May 2016 19:47:20 -0500 Subject: [PATCH 230/498] add a function to retrieve the current OSD line --- runloop.c | 8 ++++++++ runloop.h | 2 ++ 2 files changed, 10 insertions(+) diff --git a/runloop.c b/runloop.c index 73064e0b5b..871dbc6496 100644 --- a/runloop.c +++ b/runloop.c @@ -155,6 +155,14 @@ void runloop_msg_queue_push(const char *msg, } +char* runloop_msg_queue_pull() +{ + runloop_ctx_msg_info_t msg_info; + runloop_ctl(RUNLOOP_CTL_MSG_QUEUE_PULL, &msg_info); + + return strdup(msg_info.msg); +} + #ifdef HAVE_MENU static bool runloop_cmd_get_state_menu_toggle_button_combo( settings_t *settings, diff --git a/runloop.h b/runloop.h index bfd0281447..de671c4041 100644 --- a/runloop.h +++ b/runloop.h @@ -324,6 +324,8 @@ int runloop_iterate(unsigned *sleep_ms); void runloop_msg_queue_push(const char *msg, unsigned prio, unsigned duration, bool flush); +char* runloop_msg_queue_pull(); + bool runloop_ctl(enum runloop_ctl_state state, void *data); From be3f0f9267f728069e7cafacf546ea68d9a7a40f Mon Sep 17 00:00:00 2001 From: radius Date: Sat, 7 May 2016 19:51:42 -0500 Subject: [PATCH 231/498] example implementation of using the menu driver to display the OSD, commented out --- menu/drivers/xmb.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 65377e2ba6..6f1f91f54f 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -2066,10 +2066,19 @@ static void xmb_frame(void *data) xmb->margins.title.top, 1, 1, TEXT_ALIGN_LEFT, width, height); - if (menu_entries_get_core_title(title_msg, sizeof(title_msg)) == 0) - xmb_draw_text(xmb, title_msg, xmb->margins.title.left, - height - xmb->margins.title.bottom, 1, 1, TEXT_ALIGN_LEFT, - width, height); +/* uncomment to print the messages on the XMB status line + if (string_is_empty(runloop_msg_queue_pull())) + {*/ + if (menu_entries_get_core_title(title_msg, sizeof(title_msg)) == 0) + xmb_draw_text(xmb, title_msg, xmb->margins.title.left, + height - xmb->margins.title.bottom, 1, 1, TEXT_ALIGN_LEFT, + width, height); +/* } + else + xmb_draw_text(xmb, runloop_msg_queue_pull(), xmb->margins.title.left, + height - xmb->margins.title.bottom, 1, 1, TEXT_ALIGN_LEFT, + width, height); +*/ rotate_draw.matrix = &mymat; rotate_draw.rotation = 0; From ae9ea8f2db369f1a14263911cffae4740cf5971c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 04:04:50 +0200 Subject: [PATCH 232/498] (MSVC) Buildfixes --- command_event.c | 2 +- gfx/d3d/d3d.cpp | 2 +- gfx/video_texture_image.c | 4 +- libretro-common/include/glsm€glsmsym.h | 372 +++++++++++++++++++++++++ libretro-common/queues/task_queue.c | 8 +- retroarch.c | 2 +- tasks/task_http.c | 5 +- 7 files changed, 383 insertions(+), 12 deletions(-) create mode 100644 libretro-common/include/glsm€glsmsym.h diff --git a/command_event.c b/command_event.c index 02ec85914b..c98cdd35aa 100644 --- a/command_event.c +++ b/command_event.c @@ -581,7 +581,7 @@ static bool event_init_core(void *data) retro_ctx_environ_info_t info; settings_t *settings = config_get_ptr(); - if (!core_init_symbols(data)) + if (!core_init_symbols((rarch_core_type*)data)) return false; runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_INIT, NULL); diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 15ab4b3c06..65a52f27b3 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -103,7 +103,7 @@ static bool d3d_init_imports(d3d_video_t *d3d) mem_info.id = RETRO_MEMORY_SYSTEM_RAM; - core_ctl(CORE_CTL_RETRO_GET_MEMORY, &mem_info); + core_get_memory(&mem_info); tracker_info.wram = (uint8_t*)mem_info.data; tracker_info.info = d3d->shader.variable; diff --git a/gfx/video_texture_image.c b/gfx/video_texture_image.c index 8960c29155..674b625a2c 100644 --- a/gfx/video_texture_image.c +++ b/gfx/video_texture_image.c @@ -266,7 +266,7 @@ bool video_texture_image_load(struct texture_image *out_img, switch (fmt) { case IMAGE_FORMAT_TGA: - if (rtga_image_load_shift(ptr, out_img, + if (rtga_image_load_shift((uint8_t*)ptr, out_img, a_shift, r_shift, g_shift, b_shift)) goto success; break; @@ -278,7 +278,7 @@ bool video_texture_image_load(struct texture_image *out_img, #endif break; case IMAGE_FORMAT_JPEG: - if (rjpeg_image_load(ptr, out_img, file_len, + if (rjpeg_image_load((uint8_t*)ptr, out_img, file_len, a_shift, r_shift, g_shift, b_shift)) goto success; break; diff --git a/libretro-common/include/glsm€glsmsym.h b/libretro-common/include/glsm€glsmsym.h new file mode 100644 index 0000000000..8ae345e6dd --- /dev/null +++ b/libretro-common/include/glsm€glsmsym.h @@ -0,0 +1,372 @@ +/* Copyright (C) 2010-2016 The RetroArch team + * + * --------------------------------------------------------------------------------------- + * The following license statement only applies to this libretro SDK code part (glsmsym.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_GLSM_SYM_H +#define LIBRETRO_SDK_GLSM_SYM_H + +#include + +#include + +RETRO_BEGIN_DECLS + +/* deprecated old FF-style GL symbols */ +#define glTexCoord2f rglTexCoord2f + +/* more forward-compatible GL subset symbols */ +#define glBlitFramebuffer rglBlitFramebuffer +#define glVertexAttrib4f rglVertexAttrib4f +#define glVertexAttrib4fv rglVertexAttrib4fv +#define glDrawArrays rglDrawArrays +#define glDrawElements rglDrawElements +#define glCompressedTexImage2D rglCompressedTexImage2D +#define glBindTexture rglBindTexture +#define glActiveTexture rglActiveTexture +#define glFramebufferTexture rglFramebufferTexture +#define glFramebufferTexture2D rglFramebufferTexture2D +#define glFramebufferRenderbuffer rglFramebufferRenderbuffer +#define glDeleteFramebuffers rglDeleteFramebuffers +#define glDeleteTextures rglDeleteTextures +#define glDeleteBuffers rglDeleteBuffers +#define glRenderbufferStorage rglRenderbufferStorage +#define glBindRenderbuffer rglBindRenderbuffer +#define glDeleteRenderbuffers rglDeleteRenderbuffers +#define glGenRenderbuffers rglGenRenderbuffers +#define glGenFramebuffers rglGenFramebuffers +#define glGenTextures rglGenTextures +#define glBindFramebuffer rglBindFramebuffer +#define glGenerateMipmap rglGenerateMipmap +#define glCheckFramebufferStatus rglCheckFramebufferStatus +#define glBindFragDataLocation rglBindFragDataLocation +#define glBindAttribLocation rglBindAttribLocation +#define glLinkProgram rglLinkProgram +#define glGetProgramiv rglGetProgramiv +#define glGetShaderiv rglGetShaderiv +#define glAttachShader rglAttachShader +#define glDetachShader rglDetachShader +#define glShaderSource rglShaderSource +#define glCompileShader rglCompileShader +#define glCreateProgram rglCreateProgram +#define glGetShaderInfoLog rglGetShaderInfoLog +#define glGetProgramInfoLog rglGetProgramInfoLog +#define glIsProgram rglIsProgram +#define glEnableVertexAttribArray rglEnableVertexAttribArray +#define glDisableVertexAttribArray rglDisableVertexAttribArray +#define glVertexAttribPointer rglVertexAttribPointer +#define glVertexAttribIPointer rglVertexAttribIPointer +#define glVertexAttribLPointer rglVertexAttribLPointer +#define glGetUniformLocation rglGetUniformLocation +#define glGenBuffers rglGenBuffers +#define glDisable(T) rglDisable(S##T) +#define glEnable(T) rglEnable(S##T) +#define glIsEnabled(T) rglIsEnabled(S##T) +#define glUseProgram rglUseProgram +#define glDepthMask rglDepthMask +#define glStencilMask rglStencilMask +#define glBufferData rglBufferData +#define glBufferSubData rglBufferSubData +#define glBindBuffer rglBindBuffer +#define glCreateShader rglCreateShader +#define glDeleteShader rglDeleteShader +#define glDeleteProgram rglDeleteProgram +#define glUniform1f rglUniform1f +#define glUniform1i rglUniform1i +#define glUniform2f rglUniform2f +#define glUniform2i rglUniform2i +#define glUniform2fv rglUniform2fv +#define glUniform3f rglUniform3f +#define glUniform3fv rglUniform3fv +#define glUniform4f rglUniform4f +#define glUniform4fv rglUniform4fv +#define glUniform1ui rglUniform1ui +#define glUniform2ui rglUniform2ui +#define glUniform3ui rglUniform3ui +#define glUniform4ui rglUniform4ui +#define glGetActiveUniform rglGetActiveUniform +#define glBlendFunc rglBlendFunc +#define glBlendFuncSeparate rglBlendFuncSeparate +#define glDepthFunc rglDepthFunc +#define glColorMask rglColorMask +#define glClearColor rglClearColor +#define glViewport rglViewport +#define glScissor rglScissor +#define glStencilFunc rglStencilFunc +#define glCullFace rglCullFace +#define glStencilOp rglStencilOp +#define glFrontFace rglFrontFace +#define glDepthRange rglDepthRange +#define glClearDepth rglClearDepth +#define glPolygonOffset rglPolygonOffset +#define glPixelStorei rglPixelStorei +#define glReadBuffer rglReadBuffer +#define glUniformMatrix4fv rglUniformMatrix4fv +#define glGetAttribLocation rglGetAttribLocation +#define glTexStorage2D rglTexStorage2D +#define glDrawBuffers rglDrawBuffers +#define glGenVertexArrays rglGenVertexArrays +#define glBindVertexArray rglBindVertexArray +#define glBlendEquation rglBlendEquation +#define glBlendColor rglBlendColor +#define glBlendEquationSeparate rglBlendEquationSeparate +#define glCopyImageSubData rglCopyImageSubData +#define glMapBuffer rglMapBuffer +#define glUnmapBuffer rglUnmapBuffer +#define glMapBufferRange rglMapBufferRange +#define glUniformBlockBinding rglUniformBlockBinding +#define glGetUniformBlockIndex rglGetUniformBlockIndex +#define glGetActiveUniformBlockiv rglGetActiveUniformBlockiv +#define glBindBufferBase rglBindBufferBase +#define glGetUniformIndices rglGetUniformIndices +#define glGetActiveUniformsiv rglGetActiveUniformsiv +#define glGetError rglGetError +#define glClear rglClear +#define glPolygonMode rglPolygonMode +#define glLineWidth rglLineWidth +#define glTexImage2DMultisample rglTexImage2DMultisample +#define glTexStorage2DMultisample rglTexStorage2DMultisample +#define glMemoryBarrier rglMemoryBarrier +#define glBindImageTexture rglBindImageTexture +#define glProgramBinary rglProgramBinary +#define glGetProgramBinary rglGetProgramBinary +#define glProgramParameteri rglProgramParameteri +#define glTexSubImage2D rglTexSubImage2D +#define glDeleteVertexArrays rglDeleteVertexArrays + +void rglProgramParameteri( GLuint program, + GLenum pname, + GLint value); +void rglGetProgramBinary( GLuint program, + GLsizei bufsize, + GLsizei *length, + GLenum *binaryFormat, + void *binary); +void rglProgramBinary(GLuint program, + GLenum binaryFormat, + const void *binary, + GLsizei length); +void rglBindImageTexture( GLuint unit, + GLuint texture, + GLint level, + GLboolean layered, + GLint layer, + GLenum access, + GLenum format); +void rglTexStorage2DMultisample(GLenum target, GLsizei samples, + GLenum internalformat, GLsizei width, GLsizei height, + GLboolean fixedsamplelocations); +void rglGetActiveUniformsiv( GLuint program, + GLsizei uniformCount, + const GLuint *uniformIndices, + GLenum pname, + GLint *params); +void rglGetUniformIndices( GLuint program, + GLsizei uniformCount, + const GLchar **uniformNames, + GLuint *uniformIndices); +void rglBindBufferBase( GLenum target, + GLuint index, + GLuint buffer); +void rglGetActiveUniformBlockiv( GLuint program, + GLuint uniformBlockIndex, + GLenum pname, + GLint *params); +GLuint rglGetUniformBlockIndex( GLuint program, + const GLchar *uniformBlockName); +void * rglMapBuffer( GLenum target, GLenum access); +void *rglMapBufferRange( GLenum target, + GLintptr offset, + GLsizeiptr length, + GLbitfield access); +GLboolean rglUnmapBuffer( GLenum target); +void rglBlendColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); +void rglBlendEquation(GLenum mode); +void rglGenVertexArrays(GLsizei n, GLuint *arrays); +void rglReadBuffer(GLenum mode); +void rglPixelStorei(GLenum pname, GLint param); +void rglTexCoord2f(GLfloat s, GLfloat t); +void rglDrawElements(GLenum mode, GLsizei count, GLenum type, + const GLvoid * indices); +void rglTexStorage2D(GLenum target, GLsizei levels, GLenum internalFormat, + GLsizei width, GLsizei height); +void rglCompressedTexImage2D(GLenum target, GLint level, + GLenum internalformat, GLsizei width, GLsizei height, + GLint border, GLsizei imageSize, const GLvoid *data); +void glBindTexture(GLenum target, GLuint texture); +void glActiveTexture(GLenum texture); +void rglFramebufferTexture(GLenum target, GLenum attachment, + GLuint texture, GLint level); +void rglFramebufferTexture2D(GLenum target, GLenum attachment, + GLenum textarget, GLuint texture, GLint level); +void rglFramebufferRenderbuffer(GLenum target, GLenum attachment, + GLenum renderbuffertarget, GLuint renderbuffer); +void rglDeleteFramebuffers(GLsizei n, const GLuint *framebuffers); +void rglRenderbufferStorage(GLenum target, GLenum internalFormat, + GLsizei width, GLsizei height); +void rglDeleteTextures(GLsizei n, const GLuint *textures); +void rglBindRenderbuffer(GLenum target, GLuint renderbuffer); +void rglDeleteRenderbuffers(GLsizei n, GLuint *renderbuffers); +void rglGenRenderbuffers(GLsizei n, GLuint *renderbuffers); +void rglGenFramebuffers(GLsizei n, GLuint *ids); +void rglGenTextures(GLsizei n, GLuint *textures); +void rglBindFramebuffer(GLenum target, GLuint framebuffer); +void rglGenerateMipmap(GLenum target); +GLenum rglCheckFramebufferStatus(GLenum target); +void rglBindFragDataLocation(GLuint program, GLuint colorNumber, + const char * name); +void rglBindAttribLocation(GLuint program, GLuint index, const GLchar *name); +void rglLinkProgram(GLuint program); +void rglGetProgramiv(GLuint shader, GLenum pname, GLint *params); +void rglGetShaderiv(GLuint shader, GLenum pname, GLint *params); +void rglAttachShader(GLuint program, GLuint shader); +void rglShaderSource(GLuint shader, GLsizei count, + const GLchar **string, const GLint *length); +void rglCompileShader(GLuint shader); +GLuint rglCreateProgram(void); +void rglGetShaderInfoLog(GLuint shader, GLsizei maxLength, + GLsizei *length, GLchar *infoLog); +void rglGetProgramInfoLog(GLuint shader, GLsizei maxLength, + GLsizei *length, GLchar *infoLog); +GLboolean rglIsProgram(GLuint program); +void rglEnableVertexAttribArray(GLuint index); +void rglDisableVertexAttribArray(GLuint index); +void rglVertexAttribPointer(GLuint name, GLint size, + GLenum type, GLboolean normalized, GLsizei stride, + const GLvoid* pointer); +GLint rglGetUniformLocation(GLuint program, const GLchar *name); +void rglGenBuffers(GLsizei n, GLuint *buffers); +void rglDisable(GLenum cap); +void rglEnable(GLenum cap); +void rglUseProgram(GLuint program); +void rglDepthMask(GLboolean flag); +void rglStencilMask(GLenum mask); +void rglBufferData(GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); +void rglBufferSubData(GLenum target, GLintptr offset, + GLsizeiptr size, const GLvoid *data); +void rglBindBuffer(GLenum target, GLuint buffer); +GLuint rglCreateShader(GLenum shader); +void rglDeleteShader(GLuint shader); +void rglUniform1f(GLint location, GLfloat v0); +void rglUniform1i(GLint location, GLint v0); +void rglUniform2f(GLint location, GLfloat v0, GLfloat v1); +void rglUniform2i(GLint location, GLint v0, GLint v1); +void rglUniform2fv(GLint location, GLsizei count, const GLfloat *value); +void rglUniform3f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2); +void rglUniform3fv(GLint location, GLsizei count, const GLfloat *value); +void rglUniform4f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); +void rglUniform4fv(GLint location, GLsizei count, const GLfloat *value); +void rglBlendFunc(GLenum sfactor, GLenum dfactor); +void rglBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, + GLenum dstAlpha); +void rglDepthFunc(GLenum func); +void rglColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); +void rglClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); +void rglViewport(GLint x, GLint y, GLsizei width, GLsizei height); +void rglScissor(GLint x, GLint y, GLsizei width, GLsizei height); +GLboolean rglIsEnabled(GLenum cap); +void rglStencilFunc(GLenum func, GLint ref, GLuint mask); +void rglCullFace(GLenum mode); +void rglStencilOp(GLenum sfail, GLenum dpfail, GLenum dppass); +void rglFrontFace(GLenum mode); +void rglDepthRange(GLclampd zNear, GLclampd zFar); +void rglClearDepth(GLdouble depth); +void rglPolygonOffset(GLfloat factor, GLfloat units); +void rglDrawArrays(GLenum mode, GLint first, GLsizei count); +void rglVertexAttrib4f(GLuint name, GLfloat x, GLfloat y, + GLfloat z, GLfloat w); +void rglVertexAttrib4fv(GLuint name, GLfloat* v); +void rglDeleteProgram(GLuint program); +void rglDeleteBuffers(GLsizei n, const GLuint *buffers); +void rglBlitFramebuffer( + GLint srcX0, GLint srcY0, + GLint srcX1, GLint srcY1, + GLint dstX0, GLint dstY0, + GLint dstX1, GLint dstY1, + GLbitfield mask, GLenum filter); +void rglDetachShader(GLuint program, GLuint shader); +void rglUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, + const GLfloat *value); +GLint rglGetAttribLocation(GLuint program, const GLchar *name); +void rglDrawBuffers(GLsizei n, const GLenum *bufs); +void rglBindVertexArray(GLuint array); + +void rglGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, + GLsizei *length, GLint *size, GLenum *type, GLchar *name); +void rglUniform1ui(GLint location, GLuint v); +void rglUniform2ui(GLint location, GLuint v0, GLuint v1); +void rglUniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2); +void rglUniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); +void rglBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha); +void rglCopyImageSubData( GLuint srcName, + GLenum srcTarget, + GLint srcLevel, + GLint srcX, + GLint srcY, + GLint srcZ, + GLuint dstName, + GLenum dstTarget, + GLint dstLevel, + GLint dstX, + GLint dstY, + GLint dstZ, + GLsizei srcWidth, + GLsizei srcHeight, + GLsizei srcDepth); +void rglVertexAttribIPointer( + GLuint index, + GLint size, + GLenum type, + GLsizei stride, + const GLvoid * pointer); +void rglVertexAttribLPointer( + GLuint index, + GLint size, + GLenum type, + GLsizei stride, + const GLvoid * pointer); +void rglUniformBlockBinding( GLuint program, + GLuint uniformBlockIndex, + GLuint uniformBlockBinding); +GLenum rglGetError(void); +void rglClear(GLbitfield mask); +void rglPolygonMode(GLenum face, GLenum mode); +void rglLineWidth(GLfloat width); +void rglTexImage2DMultisample( GLenum target, + GLsizei samples, + GLenum internalformat, + GLsizei width, + GLsizei height, + GLboolean fixedsamplelocations); +void rglMemoryBarrier( GLbitfield barriers); +void rglTexSubImage2D( GLenum target, + GLint level, + GLint xoffset, + GLint yoffset, + GLsizei width, + GLsizei height, + GLenum format, + GLenum type, + const GLvoid * pixels); +void rglDeleteVertexArrays(GLsizei n, const GLuint *arrays); + +RETRO_END_DECLS + +#endif diff --git a/libretro-common/queues/task_queue.c b/libretro-common/queues/task_queue.c index 93bd5ef8fd..5807b44f97 100644 --- a/libretro-common/queues/task_queue.c +++ b/libretro-common/queues/task_queue.c @@ -171,8 +171,8 @@ static void retro_task_regular_push_running(retro_task_t *task) static void retro_task_regular_cancel(void *task) { - retro_task_t *t = task; - t->cancelled = true; + retro_task_t *t = (retro_task_t*)task; + t->cancelled = true; } static void retro_task_regular_gather(void) @@ -249,7 +249,7 @@ static void retro_task_regular_retrieve(task_retriever_data_t *data) if (task->handler == data->handler) { /* Create new link */ - info = malloc(sizeof(task_retriever_info_t)); + info = (task_retriever_info_t*)malloc(sizeof(task_retriever_info_t)); info->data = malloc(data->element_size); info->next = NULL; @@ -533,7 +533,7 @@ bool task_queue_ctl(enum task_queue_ctl_state state, void *data) } break; case TASK_QUEUE_CTL_RETRIEVE: - impl_current->retrieve(data); + impl_current->retrieve((task_retriever_data_t*)data); break; case TASK_QUEUE_CTL_CHECK: { diff --git a/retroarch.c b/retroarch.c index a186e67b73..5f2f64908c 100644 --- a/retroarch.c +++ b/retroarch.c @@ -954,7 +954,7 @@ static void parse_input(int argc, char *argv[]) #if defined(HAVE_NETWORK_CMD) && defined(HAVE_NETPLAY) case RA_OPT_COMMAND: - if (rarch_cmd_send((void*)optarg)) + if (rarch_cmd_send((const char*)optarg)) exit(0); else retro_fail(1, "network_cmd_send()"); diff --git a/tasks/task_http.c b/tasks/task_http.c index a69e7ae6c1..64a7c05501 100644 --- a/tasks/task_http.c +++ b/tasks/task_http.c @@ -213,11 +213,10 @@ static bool rarch_task_http_finder(retro_task_t *task, void *user_data) static bool rarch_task_http_retriever(retro_task_t *task, void *data) { - http_handle_t *http; - http_transfer_info_t *info = data; + http_transfer_info_t *info = (http_transfer_info_t*)data; /* Extract HTTP handle and return already if invalid */ - http = (http_handle_t *)task->state; + http_handle_t *http = (http_handle_t *)task->state; if (!http) return false; From 1968b0a333493935d83c5173d0e3efe5d796b956 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 04:06:07 +0200 Subject: [PATCH 233/498] Dunno where this came from --- libretro-common/include/glsm€glsmsym.h | 372 ------------------------- 1 file changed, 372 deletions(-) delete mode 100644 libretro-common/include/glsm€glsmsym.h diff --git a/libretro-common/include/glsm€glsmsym.h b/libretro-common/include/glsm€glsmsym.h deleted file mode 100644 index 8ae345e6dd..0000000000 --- a/libretro-common/include/glsm€glsmsym.h +++ /dev/null @@ -1,372 +0,0 @@ -/* Copyright (C) 2010-2016 The RetroArch team - * - * --------------------------------------------------------------------------------------- - * The following license statement only applies to this libretro SDK code part (glsmsym.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_GLSM_SYM_H -#define LIBRETRO_SDK_GLSM_SYM_H - -#include - -#include - -RETRO_BEGIN_DECLS - -/* deprecated old FF-style GL symbols */ -#define glTexCoord2f rglTexCoord2f - -/* more forward-compatible GL subset symbols */ -#define glBlitFramebuffer rglBlitFramebuffer -#define glVertexAttrib4f rglVertexAttrib4f -#define glVertexAttrib4fv rglVertexAttrib4fv -#define glDrawArrays rglDrawArrays -#define glDrawElements rglDrawElements -#define glCompressedTexImage2D rglCompressedTexImage2D -#define glBindTexture rglBindTexture -#define glActiveTexture rglActiveTexture -#define glFramebufferTexture rglFramebufferTexture -#define glFramebufferTexture2D rglFramebufferTexture2D -#define glFramebufferRenderbuffer rglFramebufferRenderbuffer -#define glDeleteFramebuffers rglDeleteFramebuffers -#define glDeleteTextures rglDeleteTextures -#define glDeleteBuffers rglDeleteBuffers -#define glRenderbufferStorage rglRenderbufferStorage -#define glBindRenderbuffer rglBindRenderbuffer -#define glDeleteRenderbuffers rglDeleteRenderbuffers -#define glGenRenderbuffers rglGenRenderbuffers -#define glGenFramebuffers rglGenFramebuffers -#define glGenTextures rglGenTextures -#define glBindFramebuffer rglBindFramebuffer -#define glGenerateMipmap rglGenerateMipmap -#define glCheckFramebufferStatus rglCheckFramebufferStatus -#define glBindFragDataLocation rglBindFragDataLocation -#define glBindAttribLocation rglBindAttribLocation -#define glLinkProgram rglLinkProgram -#define glGetProgramiv rglGetProgramiv -#define glGetShaderiv rglGetShaderiv -#define glAttachShader rglAttachShader -#define glDetachShader rglDetachShader -#define glShaderSource rglShaderSource -#define glCompileShader rglCompileShader -#define glCreateProgram rglCreateProgram -#define glGetShaderInfoLog rglGetShaderInfoLog -#define glGetProgramInfoLog rglGetProgramInfoLog -#define glIsProgram rglIsProgram -#define glEnableVertexAttribArray rglEnableVertexAttribArray -#define glDisableVertexAttribArray rglDisableVertexAttribArray -#define glVertexAttribPointer rglVertexAttribPointer -#define glVertexAttribIPointer rglVertexAttribIPointer -#define glVertexAttribLPointer rglVertexAttribLPointer -#define glGetUniformLocation rglGetUniformLocation -#define glGenBuffers rglGenBuffers -#define glDisable(T) rglDisable(S##T) -#define glEnable(T) rglEnable(S##T) -#define glIsEnabled(T) rglIsEnabled(S##T) -#define glUseProgram rglUseProgram -#define glDepthMask rglDepthMask -#define glStencilMask rglStencilMask -#define glBufferData rglBufferData -#define glBufferSubData rglBufferSubData -#define glBindBuffer rglBindBuffer -#define glCreateShader rglCreateShader -#define glDeleteShader rglDeleteShader -#define glDeleteProgram rglDeleteProgram -#define glUniform1f rglUniform1f -#define glUniform1i rglUniform1i -#define glUniform2f rglUniform2f -#define glUniform2i rglUniform2i -#define glUniform2fv rglUniform2fv -#define glUniform3f rglUniform3f -#define glUniform3fv rglUniform3fv -#define glUniform4f rglUniform4f -#define glUniform4fv rglUniform4fv -#define glUniform1ui rglUniform1ui -#define glUniform2ui rglUniform2ui -#define glUniform3ui rglUniform3ui -#define glUniform4ui rglUniform4ui -#define glGetActiveUniform rglGetActiveUniform -#define glBlendFunc rglBlendFunc -#define glBlendFuncSeparate rglBlendFuncSeparate -#define glDepthFunc rglDepthFunc -#define glColorMask rglColorMask -#define glClearColor rglClearColor -#define glViewport rglViewport -#define glScissor rglScissor -#define glStencilFunc rglStencilFunc -#define glCullFace rglCullFace -#define glStencilOp rglStencilOp -#define glFrontFace rglFrontFace -#define glDepthRange rglDepthRange -#define glClearDepth rglClearDepth -#define glPolygonOffset rglPolygonOffset -#define glPixelStorei rglPixelStorei -#define glReadBuffer rglReadBuffer -#define glUniformMatrix4fv rglUniformMatrix4fv -#define glGetAttribLocation rglGetAttribLocation -#define glTexStorage2D rglTexStorage2D -#define glDrawBuffers rglDrawBuffers -#define glGenVertexArrays rglGenVertexArrays -#define glBindVertexArray rglBindVertexArray -#define glBlendEquation rglBlendEquation -#define glBlendColor rglBlendColor -#define glBlendEquationSeparate rglBlendEquationSeparate -#define glCopyImageSubData rglCopyImageSubData -#define glMapBuffer rglMapBuffer -#define glUnmapBuffer rglUnmapBuffer -#define glMapBufferRange rglMapBufferRange -#define glUniformBlockBinding rglUniformBlockBinding -#define glGetUniformBlockIndex rglGetUniformBlockIndex -#define glGetActiveUniformBlockiv rglGetActiveUniformBlockiv -#define glBindBufferBase rglBindBufferBase -#define glGetUniformIndices rglGetUniformIndices -#define glGetActiveUniformsiv rglGetActiveUniformsiv -#define glGetError rglGetError -#define glClear rglClear -#define glPolygonMode rglPolygonMode -#define glLineWidth rglLineWidth -#define glTexImage2DMultisample rglTexImage2DMultisample -#define glTexStorage2DMultisample rglTexStorage2DMultisample -#define glMemoryBarrier rglMemoryBarrier -#define glBindImageTexture rglBindImageTexture -#define glProgramBinary rglProgramBinary -#define glGetProgramBinary rglGetProgramBinary -#define glProgramParameteri rglProgramParameteri -#define glTexSubImage2D rglTexSubImage2D -#define glDeleteVertexArrays rglDeleteVertexArrays - -void rglProgramParameteri( GLuint program, - GLenum pname, - GLint value); -void rglGetProgramBinary( GLuint program, - GLsizei bufsize, - GLsizei *length, - GLenum *binaryFormat, - void *binary); -void rglProgramBinary(GLuint program, - GLenum binaryFormat, - const void *binary, - GLsizei length); -void rglBindImageTexture( GLuint unit, - GLuint texture, - GLint level, - GLboolean layered, - GLint layer, - GLenum access, - GLenum format); -void rglTexStorage2DMultisample(GLenum target, GLsizei samples, - GLenum internalformat, GLsizei width, GLsizei height, - GLboolean fixedsamplelocations); -void rglGetActiveUniformsiv( GLuint program, - GLsizei uniformCount, - const GLuint *uniformIndices, - GLenum pname, - GLint *params); -void rglGetUniformIndices( GLuint program, - GLsizei uniformCount, - const GLchar **uniformNames, - GLuint *uniformIndices); -void rglBindBufferBase( GLenum target, - GLuint index, - GLuint buffer); -void rglGetActiveUniformBlockiv( GLuint program, - GLuint uniformBlockIndex, - GLenum pname, - GLint *params); -GLuint rglGetUniformBlockIndex( GLuint program, - const GLchar *uniformBlockName); -void * rglMapBuffer( GLenum target, GLenum access); -void *rglMapBufferRange( GLenum target, - GLintptr offset, - GLsizeiptr length, - GLbitfield access); -GLboolean rglUnmapBuffer( GLenum target); -void rglBlendColor(GLfloat red, GLfloat green, GLfloat blue, GLfloat alpha); -void rglBlendEquation(GLenum mode); -void rglGenVertexArrays(GLsizei n, GLuint *arrays); -void rglReadBuffer(GLenum mode); -void rglPixelStorei(GLenum pname, GLint param); -void rglTexCoord2f(GLfloat s, GLfloat t); -void rglDrawElements(GLenum mode, GLsizei count, GLenum type, - const GLvoid * indices); -void rglTexStorage2D(GLenum target, GLsizei levels, GLenum internalFormat, - GLsizei width, GLsizei height); -void rglCompressedTexImage2D(GLenum target, GLint level, - GLenum internalformat, GLsizei width, GLsizei height, - GLint border, GLsizei imageSize, const GLvoid *data); -void glBindTexture(GLenum target, GLuint texture); -void glActiveTexture(GLenum texture); -void rglFramebufferTexture(GLenum target, GLenum attachment, - GLuint texture, GLint level); -void rglFramebufferTexture2D(GLenum target, GLenum attachment, - GLenum textarget, GLuint texture, GLint level); -void rglFramebufferRenderbuffer(GLenum target, GLenum attachment, - GLenum renderbuffertarget, GLuint renderbuffer); -void rglDeleteFramebuffers(GLsizei n, const GLuint *framebuffers); -void rglRenderbufferStorage(GLenum target, GLenum internalFormat, - GLsizei width, GLsizei height); -void rglDeleteTextures(GLsizei n, const GLuint *textures); -void rglBindRenderbuffer(GLenum target, GLuint renderbuffer); -void rglDeleteRenderbuffers(GLsizei n, GLuint *renderbuffers); -void rglGenRenderbuffers(GLsizei n, GLuint *renderbuffers); -void rglGenFramebuffers(GLsizei n, GLuint *ids); -void rglGenTextures(GLsizei n, GLuint *textures); -void rglBindFramebuffer(GLenum target, GLuint framebuffer); -void rglGenerateMipmap(GLenum target); -GLenum rglCheckFramebufferStatus(GLenum target); -void rglBindFragDataLocation(GLuint program, GLuint colorNumber, - const char * name); -void rglBindAttribLocation(GLuint program, GLuint index, const GLchar *name); -void rglLinkProgram(GLuint program); -void rglGetProgramiv(GLuint shader, GLenum pname, GLint *params); -void rglGetShaderiv(GLuint shader, GLenum pname, GLint *params); -void rglAttachShader(GLuint program, GLuint shader); -void rglShaderSource(GLuint shader, GLsizei count, - const GLchar **string, const GLint *length); -void rglCompileShader(GLuint shader); -GLuint rglCreateProgram(void); -void rglGetShaderInfoLog(GLuint shader, GLsizei maxLength, - GLsizei *length, GLchar *infoLog); -void rglGetProgramInfoLog(GLuint shader, GLsizei maxLength, - GLsizei *length, GLchar *infoLog); -GLboolean rglIsProgram(GLuint program); -void rglEnableVertexAttribArray(GLuint index); -void rglDisableVertexAttribArray(GLuint index); -void rglVertexAttribPointer(GLuint name, GLint size, - GLenum type, GLboolean normalized, GLsizei stride, - const GLvoid* pointer); -GLint rglGetUniformLocation(GLuint program, const GLchar *name); -void rglGenBuffers(GLsizei n, GLuint *buffers); -void rglDisable(GLenum cap); -void rglEnable(GLenum cap); -void rglUseProgram(GLuint program); -void rglDepthMask(GLboolean flag); -void rglStencilMask(GLenum mask); -void rglBufferData(GLenum target, GLsizeiptr size, const GLvoid *data, GLenum usage); -void rglBufferSubData(GLenum target, GLintptr offset, - GLsizeiptr size, const GLvoid *data); -void rglBindBuffer(GLenum target, GLuint buffer); -GLuint rglCreateShader(GLenum shader); -void rglDeleteShader(GLuint shader); -void rglUniform1f(GLint location, GLfloat v0); -void rglUniform1i(GLint location, GLint v0); -void rglUniform2f(GLint location, GLfloat v0, GLfloat v1); -void rglUniform2i(GLint location, GLint v0, GLint v1); -void rglUniform2fv(GLint location, GLsizei count, const GLfloat *value); -void rglUniform3f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2); -void rglUniform3fv(GLint location, GLsizei count, const GLfloat *value); -void rglUniform4f(GLint location, GLfloat v0, GLfloat v1, GLfloat v2, GLfloat v3); -void rglUniform4fv(GLint location, GLsizei count, const GLfloat *value); -void rglBlendFunc(GLenum sfactor, GLenum dfactor); -void rglBlendFuncSeparate(GLenum srcRGB, GLenum dstRGB, GLenum srcAlpha, - GLenum dstAlpha); -void rglDepthFunc(GLenum func); -void rglColorMask(GLboolean red, GLboolean green, GLboolean blue, GLboolean alpha); -void rglClearColor(GLclampf red, GLclampf green, GLclampf blue, GLclampf alpha); -void rglViewport(GLint x, GLint y, GLsizei width, GLsizei height); -void rglScissor(GLint x, GLint y, GLsizei width, GLsizei height); -GLboolean rglIsEnabled(GLenum cap); -void rglStencilFunc(GLenum func, GLint ref, GLuint mask); -void rglCullFace(GLenum mode); -void rglStencilOp(GLenum sfail, GLenum dpfail, GLenum dppass); -void rglFrontFace(GLenum mode); -void rglDepthRange(GLclampd zNear, GLclampd zFar); -void rglClearDepth(GLdouble depth); -void rglPolygonOffset(GLfloat factor, GLfloat units); -void rglDrawArrays(GLenum mode, GLint first, GLsizei count); -void rglVertexAttrib4f(GLuint name, GLfloat x, GLfloat y, - GLfloat z, GLfloat w); -void rglVertexAttrib4fv(GLuint name, GLfloat* v); -void rglDeleteProgram(GLuint program); -void rglDeleteBuffers(GLsizei n, const GLuint *buffers); -void rglBlitFramebuffer( - GLint srcX0, GLint srcY0, - GLint srcX1, GLint srcY1, - GLint dstX0, GLint dstY0, - GLint dstX1, GLint dstY1, - GLbitfield mask, GLenum filter); -void rglDetachShader(GLuint program, GLuint shader); -void rglUniformMatrix4fv(GLint location, GLsizei count, GLboolean transpose, - const GLfloat *value); -GLint rglGetAttribLocation(GLuint program, const GLchar *name); -void rglDrawBuffers(GLsizei n, const GLenum *bufs); -void rglBindVertexArray(GLuint array); - -void rglGetActiveUniform(GLuint program, GLuint index, GLsizei bufsize, - GLsizei *length, GLint *size, GLenum *type, GLchar *name); -void rglUniform1ui(GLint location, GLuint v); -void rglUniform2ui(GLint location, GLuint v0, GLuint v1); -void rglUniform3ui(GLint location, GLuint v0, GLuint v1, GLuint v2); -void rglUniform4ui(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -void rglBlendEquationSeparate(GLenum modeRGB, GLenum modeAlpha); -void rglCopyImageSubData( GLuint srcName, - GLenum srcTarget, - GLint srcLevel, - GLint srcX, - GLint srcY, - GLint srcZ, - GLuint dstName, - GLenum dstTarget, - GLint dstLevel, - GLint dstX, - GLint dstY, - GLint dstZ, - GLsizei srcWidth, - GLsizei srcHeight, - GLsizei srcDepth); -void rglVertexAttribIPointer( - GLuint index, - GLint size, - GLenum type, - GLsizei stride, - const GLvoid * pointer); -void rglVertexAttribLPointer( - GLuint index, - GLint size, - GLenum type, - GLsizei stride, - const GLvoid * pointer); -void rglUniformBlockBinding( GLuint program, - GLuint uniformBlockIndex, - GLuint uniformBlockBinding); -GLenum rglGetError(void); -void rglClear(GLbitfield mask); -void rglPolygonMode(GLenum face, GLenum mode); -void rglLineWidth(GLfloat width); -void rglTexImage2DMultisample( GLenum target, - GLsizei samples, - GLenum internalformat, - GLsizei width, - GLsizei height, - GLboolean fixedsamplelocations); -void rglMemoryBarrier( GLbitfield barriers); -void rglTexSubImage2D( GLenum target, - GLint level, - GLint xoffset, - GLint yoffset, - GLsizei width, - GLsizei height, - GLenum format, - GLenum type, - const GLvoid * pixels); -void rglDeleteVertexArrays(GLsizei n, const GLuint *arrays); - -RETRO_END_DECLS - -#endif From 496fcc97982cae4618f22d334c6afd4c20778a0f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 04:16:11 +0200 Subject: [PATCH 234/498] Buildfix --- command_event.c | 7 ++++--- content.c | 11 ++++++----- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/command_event.c b/command_event.c index c98cdd35aa..69484e48ac 100644 --- a/command_event.c +++ b/command_event.c @@ -28,6 +28,7 @@ #include "record/record_driver.h" #include "autosave.h" #include "core_info.h" +#include "core_type.h" #include "cheats.h" #include "performance.h" #include "dynamic.h" @@ -576,12 +577,12 @@ static bool event_init_content(void) return true; } -static bool event_init_core(void *data) +static bool event_init_core(enum rarch_core_type *data) { retro_ctx_environ_info_t info; settings_t *settings = config_get_ptr(); - if (!core_init_symbols((rarch_core_type*)data)) + if (!core_init_symbols(data)) return false; runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_INIT, NULL); @@ -1328,7 +1329,7 @@ bool event_cmd_ctl(enum event_command cmd, void *data) break; } case EVENT_CMD_CORE_INIT: - if (!event_init_core(data)) + if (!event_init_core((enum rarch_core_type*)data)) return false; break; case EVENT_CMD_VIDEO_APPLY_STATE_CHANGES: diff --git a/content.c b/content.c index dafce8b0a0..6094b72425 100644 --- a/content.c +++ b/content.c @@ -90,6 +90,12 @@ struct sram_block size_t size; }; +static const struct file_archive_file_backend *stream_backend = NULL; +static struct string_list *temporary_content = NULL; +static bool content_is_inited = false; +static bool core_does_not_need_content = false; +static uint32_t content_crc = 0; + #ifdef HAVE_COMPRESSION #ifdef HAVE_7ZIP @@ -1696,11 +1702,6 @@ static bool content_file_free(struct string_list *temporary_content) bool content_ctl(enum content_ctl_state state, void *data) { - static const struct file_archive_file_backend *stream_backend = NULL; - static struct string_list *temporary_content = NULL; - static bool content_is_inited = false; - static bool core_does_not_need_content = false; - static uint32_t content_crc = 0; switch(state) { From b690b58f8dccc6de49abbd100edeeb3adadd2992 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 04:20:25 +0200 Subject: [PATCH 235/498] Another buildfix for CXX_BUILD --- remote.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/remote.c b/remote.c index 45caf0ce21..2aeb6bd576 100644 --- a/remote.c +++ b/remote.c @@ -78,7 +78,7 @@ static bool remote_init_network(rarch_remote_t *handle, RARCH_LOG("Bringing up remote interface on port %hu.\n", (unsigned short)port); - fd = socket_init((void*)&res, port, NULL, SOCKET_TYPE_DATAGRAM); + fd = socket_init((void**)&res, port, NULL, SOCKET_TYPE_DATAGRAM); if (fd < 0) goto error; From eb689fdd2497ad031c728a08fe6471f486f7e975 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 04:21:56 +0200 Subject: [PATCH 236/498] C89_BUILD fix --- libretro-common/include/queues/task_queue.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libretro-common/include/queues/task_queue.h b/libretro-common/include/queues/task_queue.h index a7482158b3..a265f3d00f 100644 --- a/libretro-common/include/queues/task_queue.h +++ b/libretro-common/include/queues/task_queue.h @@ -95,7 +95,7 @@ enum task_queue_ctl_state /** * Signals a task to end without waiting for * it to complete. */ - TASK_QUEUE_CTL_CANCEL, + TASK_QUEUE_CTL_CANCEL }; typedef struct retro_task retro_task_t; From 6195deb1888530d3546e9f540693c6f8287da6a2 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 04:31:56 +0200 Subject: [PATCH 237/498] De-ioctl-ify content functions --- command_event.c | 12 ++++++------ content.c | 32 ++++++-------------------------- content.h | 21 ++++++++++++--------- 3 files changed, 24 insertions(+), 41 deletions(-) diff --git a/command_event.c b/command_event.c index 69484e48ac..9dedb199db 100644 --- a/command_event.c +++ b/command_event.c @@ -448,7 +448,7 @@ static bool event_load_save_files(void) ram.path = global->savefiles->elems[i].data; ram.type = global->savefiles->elems[i].attr.i; - content_ctl(CONTENT_CTL_LOAD_RAM_FILE, &ram); + content_load_ram_file(&ram); } return true; @@ -481,7 +481,7 @@ static void event_load_auto_state(void) if (!path_file_exists(savestate_name_auto)) return; - ret = content_ctl(CONTENT_CTL_LOAD_STATE, (void*)savestate_name_auto); + ret = content_load_state(savestate_name_auto); RARCH_LOG("Found auto savestate in: %s\n", savestate_name_auto); @@ -643,7 +643,7 @@ static bool event_save_auto_state(void) fill_pathname_noext(savestate_name_auto, global->name.savestate, ".auto", sizeof(savestate_name_auto)); - ret = content_ctl(CONTENT_CTL_SAVE_STATE, (void*)savestate_name_auto); + ret = content_save_state((const char*)savestate_name_auto); RARCH_LOG("Auto save state to \"%s\" %s.\n", savestate_name_auto, ret ? "succeeded" : "failed"); @@ -814,7 +814,7 @@ static void event_save_state(const char *path, { settings_t *settings = config_get_ptr(); - if (!content_ctl(CONTENT_CTL_SAVE_STATE, (void*)path)) + if (!content_save_state(path)) { snprintf(s, len, "%s \"%s\".", msg_hash_to_str(MSG_FAILED_TO_SAVE_STATE_TO), @@ -842,7 +842,7 @@ static void event_load_state(const char *path, char *s, size_t len) { settings_t *settings = config_get_ptr(); - if (!content_ctl(CONTENT_CTL_LOAD_STATE, (void*)path)) + if (!content_load_state(path)) { snprintf(s, len, "%s \"%s\".", msg_hash_to_str(MSG_FAILED_TO_LOAD_STATE), @@ -1497,7 +1497,7 @@ bool event_cmd_ctl(enum event_command cmd, void *data) ram.type, msg_hash_to_str(MSG_TO), ram.path); - content_ctl(CONTENT_CTL_SAVE_RAM_FILE, &ram); + content_save_ram_file(&ram); } } return true; diff --git a/content.c b/content.c index 6094b72425..71ff80c124 100644 --- a/content.c +++ b/content.c @@ -1016,7 +1016,7 @@ static bool dump_to_file_desperate(const void *data, * * Returns: true if successful, false otherwise. **/ -static bool content_save_state(const char *path) +bool content_save_state(const char *path) { retro_ctx_serialize_info_t serial_info; retro_ctx_size_info_t info; @@ -1068,7 +1068,7 @@ static bool content_save_state(const char *path) * * Returns: true if successful, false otherwise. **/ -static bool content_load_state(const char *path) +bool content_load_state(const char *path) { unsigned i; ssize_t size; @@ -1181,18 +1181,17 @@ error: } /** - * load_ram_file: + * content_load_ram_file: * @path : path of RAM state that will be loaded from. * @type : type of memory * * Load a RAM state from disk to memory. */ -static bool load_ram_file(void *data) +bool content_load_ram_file(ram_type_t *ram) { ssize_t rc; retro_ctx_memory_info_t mem_info; void *buf = NULL; - ram_type_t *ram = (ram_type_t*)data; if (!ram) return false; @@ -1229,14 +1228,14 @@ static bool load_ram_file(void *data) } /** - * save_ram_file: + * content_save_ram_file: * @path : path of RAM state that shall be written to. * @type : type of memory * * Save a RAM state from memory to disk. * */ -static bool save_ram_file(ram_type_t *ram) +bool content_save_ram_file(ram_type_t *ram) { retro_ctx_memory_info_t mem_info; @@ -1702,13 +1701,8 @@ static bool content_file_free(struct string_list *temporary_content) bool content_ctl(enum content_ctl_state state, void *data) { - switch(state) { - case CONTENT_CTL_LOAD_RAM_FILE: - return load_ram_file(data); - case CONTENT_CTL_SAVE_RAM_FILE: - return save_ram_file((ram_type_t*)data); case CONTENT_CTL_DOES_NOT_NEED_CONTENT: return core_does_not_need_content; case CONTENT_CTL_SET_DOES_NOT_NEED_CONTENT: @@ -1725,20 +1719,6 @@ bool content_ctl(enum content_ctl_state state, void *data) *content_crc_ptr = &content_crc; } break; - case CONTENT_CTL_LOAD_STATE: - { - const char *path = (const char*)data; - if (!path) - return false; - return content_load_state(path); - } - case CONTENT_CTL_SAVE_STATE: - { - const char *path = (const char*)data; - if (!path) - return false; - return content_save_state(path); - } case CONTENT_CTL_IS_INITED: return content_is_inited; case CONTENT_CTL_DEINIT: diff --git a/content.h b/content.h index e1088acac4..8765df2a50 100644 --- a/content.h +++ b/content.h @@ -55,17 +55,8 @@ enum content_ctl_state CONTENT_CTL_GET_CRC, - /* Load a RAM state from disk to memory. */ - CONTENT_CTL_LOAD_RAM_FILE, - /* Save a RAM state from memory to disk. */ - CONTENT_CTL_SAVE_RAM_FILE, - /* Load a state from disk to memory. */ - CONTENT_CTL_LOAD_STATE, - - /* Save a state from memory to disk. */ - CONTENT_CTL_SAVE_STATE, /* Frees temporary content handle. */ CONTENT_CTL_TEMPORARY_FREE, @@ -100,6 +91,18 @@ typedef struct content_ctx_info void content_push_to_history_playlist(bool do_push, const char *path, void *data); +/* Load a RAM state from disk to memory. */ +bool content_load_ram_file(ram_type_t *ram); + +/* Save a RAM state from memory to disk. */ +bool content_save_ram_file(ram_type_t *ram); + +/* Load a state from disk to memory. */ +bool content_load_state(const char *path); + +/* Save a state from memory to disk. */ +bool content_save_state(const char *path); + bool content_ctl(enum content_ctl_state state, void *data); #ifdef __cplusplus From 0bd45c7f51a40f31a526d39e31385122ca04a5e8 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 04:35:00 +0200 Subject: [PATCH 238/498] Add content_load --- content.c | 4 +--- content.h | 9 +++++---- frontend/frontend.c | 2 +- menu/menu_content.c | 2 +- 4 files changed, 8 insertions(+), 9 deletions(-) diff --git a/content.c b/content.c index 71ff80c124..32fdaa1a6f 100644 --- a/content.c +++ b/content.c @@ -857,7 +857,7 @@ static void content_load_init_wrap( * * Returns: false (0) if rarch_main_init failed, otherwise true (1). **/ -static bool content_load(content_ctx_info_t *info) +bool content_load(content_ctx_info_t *info) { unsigned i; bool retval = true; @@ -1761,8 +1761,6 @@ bool content_ctl(enum content_ctl_state state, void *data) #endif } break; - case CONTENT_CTL_LOAD: - return content_load((content_ctx_info_t*)data); case CONTENT_CTL_NONE: default: break; diff --git a/content.h b/content.h index 8765df2a50..836fdbb3d7 100644 --- a/content.h +++ b/content.h @@ -48,10 +48,6 @@ enum content_ctl_state CONTENT_CTL_DEINIT, - /* Loads content file and starts up RetroArch. - * If no content file can be loaded, will start up RetroArch - * as-is. */ - CONTENT_CTL_LOAD, CONTENT_CTL_GET_CRC, @@ -103,6 +99,11 @@ bool content_load_state(const char *path); /* Save a state from memory to disk. */ bool content_save_state(const char *path); +/* Loads content file and starts up RetroArch. + * If no content file can be loaded, will start up RetroArch + * as-is. */ +bool content_load(content_ctx_info_t *info); + bool content_ctl(enum content_ctl_state state, void *data); #ifdef __cplusplus diff --git a/frontend/frontend.c b/frontend/frontend.c index c338efc628..cb68e911b6 100644 --- a/frontend/frontend.c +++ b/frontend/frontend.c @@ -126,7 +126,7 @@ int rarch_main(int argc, char *argv[], void *data) info.args = args; info.environ_get = frontend_driver_environment_get_ptr(); - if (!content_ctl(CONTENT_CTL_LOAD, &info)) + if (!content_load(&info)) return 0; } diff --git a/menu/menu_content.c b/menu/menu_content.c index 44c28e1d5a..422696a706 100644 --- a/menu/menu_content.c +++ b/menu/menu_content.c @@ -105,7 +105,7 @@ static bool menu_content_load(void) content_info.args = NULL; content_info.environ_get = menu_content_environment_get; - if (!content_ctl(CONTENT_CTL_LOAD, &content_info)) + if (!content_load(&content_info)) goto error; if (*fullpath) From ccb13cdd82e1d6e30e649fd85ff153e1d20223e2 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 04:36:16 +0200 Subject: [PATCH 239/498] remove unnecessary enum --- content.c | 11 ++++------- content.h | 2 -- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/content.c b/content.c index 32fdaa1a6f..994f907587 100644 --- a/content.c +++ b/content.c @@ -1743,16 +1743,13 @@ bool content_ctl(enum content_ctl_state state, void *data) content_file_free(temporary_content); temporary_content = NULL; break; - case CONTENT_CTL_STREAM_INIT: -#ifdef HAVE_ZLIB - if (!stream_backend) - stream_backend = file_archive_get_default_file_backend(); -#endif - break; case CONTENT_CTL_STREAM_CRC_CALCULATE: { content_stream_t *stream = NULL; - content_ctl(CONTENT_CTL_STREAM_INIT, NULL); +#ifdef HAVE_ZLIB + if (!stream_backend) + stream_backend = file_archive_get_default_file_backend(); +#endif stream = (content_stream_t*)data; #ifdef HAVE_ZLIB diff --git a/content.h b/content.h index 836fdbb3d7..7523da1565 100644 --- a/content.h +++ b/content.h @@ -57,8 +57,6 @@ enum content_ctl_state /* Frees temporary content handle. */ CONTENT_CTL_TEMPORARY_FREE, - CONTENT_CTL_STREAM_INIT, - CONTENT_CTL_STREAM_CRC_CALCULATE }; From fadf87e0225fb8fe82715a9785b41701b5158c90 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 04:38:01 +0200 Subject: [PATCH 240/498] Remove another useless enum --- content.c | 7 ++----- content.h | 7 ------- 2 files changed, 2 insertions(+), 12 deletions(-) diff --git a/content.c b/content.c index 994f907587..b90f2bde66 100644 --- a/content.c +++ b/content.c @@ -1722,7 +1722,8 @@ bool content_ctl(enum content_ctl_state state, void *data) case CONTENT_CTL_IS_INITED: return content_is_inited; case CONTENT_CTL_DEINIT: - content_ctl(CONTENT_CTL_TEMPORARY_FREE, NULL); + content_file_free(temporary_content); + temporary_content = NULL; content_crc = 0; content_is_inited = false; core_does_not_need_content = false; @@ -1739,10 +1740,6 @@ bool content_ctl(enum content_ctl_state state, void *data) } content_ctl(CONTENT_CTL_DEINIT, NULL); return false; - case CONTENT_CTL_TEMPORARY_FREE: - content_file_free(temporary_content); - temporary_content = NULL; - break; case CONTENT_CTL_STREAM_CRC_CALCULATE: { content_stream_t *stream = NULL; diff --git a/content.h b/content.h index 7523da1565..d31fe7e8cd 100644 --- a/content.h +++ b/content.h @@ -48,15 +48,8 @@ enum content_ctl_state CONTENT_CTL_DEINIT, - CONTENT_CTL_GET_CRC, - - - - /* Frees temporary content handle. */ - CONTENT_CTL_TEMPORARY_FREE, - CONTENT_CTL_STREAM_CRC_CALCULATE }; From 6bf711228243edbeca42fe14ba2fdb7629d85e1b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 04:42:28 +0200 Subject: [PATCH 241/498] Cleanup another enum --- content.c | 22 ++++------------------ content.h | 2 -- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/content.c b/content.c index b90f2bde66..2f509fbf2e 100644 --- a/content.c +++ b/content.c @@ -960,11 +960,12 @@ static bool read_content_file(unsigned i, const char *path, void **buf, stream_info.b = ret_buf; stream_info.c = *length; - content_ctl(CONTENT_CTL_STREAM_CRC_CALCULATE, &stream_info); - + if (!stream_backend) + stream_backend = file_archive_get_default_file_backend(); + stream_info.crc = stream_backend->stream_crc_calculate( + stream_info.a, stream_info.b, stream_info.c); *content_crc_ptr = stream_info.crc; - RARCH_LOG("CRC32: 0x%x .\n", (unsigned)*content_crc_ptr); #endif *buf = ret_buf; @@ -1740,21 +1741,6 @@ bool content_ctl(enum content_ctl_state state, void *data) } content_ctl(CONTENT_CTL_DEINIT, NULL); return false; - case CONTENT_CTL_STREAM_CRC_CALCULATE: - { - content_stream_t *stream = NULL; -#ifdef HAVE_ZLIB - if (!stream_backend) - stream_backend = file_archive_get_default_file_backend(); -#endif - - stream = (content_stream_t*)data; -#ifdef HAVE_ZLIB - stream->crc = stream_backend->stream_crc_calculate( - stream->a, stream->b, stream->c); -#endif - } - break; case CONTENT_CTL_NONE: default: break; diff --git a/content.h b/content.h index d31fe7e8cd..e2d5948b40 100644 --- a/content.h +++ b/content.h @@ -49,8 +49,6 @@ enum content_ctl_state CONTENT_CTL_DEINIT, CONTENT_CTL_GET_CRC, - - CONTENT_CTL_STREAM_CRC_CALCULATE }; typedef struct ram_type From 5c269d38a1c08a384923c113a63a3ac9c2f253d5 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 05:17:31 +0200 Subject: [PATCH 242/498] (content.c) Remove content_ctl --- command_event.c | 10 ++-- content.c | 103 +++++++++++++++++++++------------------ content.h | 37 ++++++-------- dynamic.c | 4 +- frontend/frontend.c | 4 +- menu/menu_driver.c | 2 +- movie.c | 4 +- netplay/netplay_common.c | 8 +-- retroarch.c | 6 +-- 9 files changed, 89 insertions(+), 89 deletions(-) diff --git a/command_event.c b/command_event.c index 9dedb199db..279211a773 100644 --- a/command_event.c +++ b/command_event.c @@ -555,13 +555,13 @@ static bool event_init_content(void) if (rarch_ctl(RARCH_CTL_IS_DUMMY_CORE, NULL)) return true; - if (!content_ctl(CONTENT_CTL_DOES_NOT_NEED_CONTENT, NULL)) + if (!content_does_not_need_content()) rarch_ctl(RARCH_CTL_FILL_PATHNAMES, NULL); - if (!content_ctl(CONTENT_CTL_INIT, NULL)) + if (!content_init()) return false; - if (content_ctl(CONTENT_CTL_DOES_NOT_NEED_CONTENT, NULL)) + if (content_does_not_need_content()) return true; event_set_savestate_auto_index(); @@ -632,7 +632,7 @@ static bool event_save_auto_state(void) return false; if (rarch_ctl(RARCH_CTL_IS_DUMMY_CORE, NULL)) return false; - if (content_ctl(CONTENT_CTL_DOES_NOT_NEED_CONTENT, NULL)) + if (content_does_not_need_content()) return false; #ifdef HAVE_CHEEVOS @@ -1588,7 +1588,7 @@ bool event_cmd_ctl(enum event_command cmd, void *data) input_driver_ctl(RARCH_INPUT_CTL_REMOTE_INIT, NULL); break; case EVENT_CMD_TEMPORARY_CONTENT_DEINIT: - content_ctl(CONTENT_CTL_DEINIT, NULL); + content_deinit(); break; case EVENT_CMD_SUBSYSTEM_FULLPATHS_DEINIT: { diff --git a/content.c b/content.c index 2f509fbf2e..968d941bf7 100644 --- a/content.c +++ b/content.c @@ -92,7 +92,7 @@ struct sram_block static const struct file_archive_file_backend *stream_backend = NULL; static struct string_list *temporary_content = NULL; -static bool content_is_inited = false; +static bool _content_is_inited = false; static bool core_does_not_need_content = false; static uint32_t content_crc = 0; @@ -954,7 +954,7 @@ static bool read_content_file(unsigned i, const char *path, void **buf, patch_content(&ret_buf, length); #ifdef HAVE_ZLIB - content_ctl(CONTENT_CTL_GET_CRC, &content_crc_ptr); + content_get_crc(&content_crc_ptr); stream_info.a = 0; stream_info.b = ret_buf; @@ -1597,9 +1597,9 @@ static bool init_content_file_set_attribs( attr.i = system->info.block_extract; attr.i |= system->info.need_fullpath << 1; - attr.i |= (!content_ctl(CONTENT_CTL_DOES_NOT_NEED_CONTENT, NULL)) << 2; + attr.i |= (!content_does_not_need_content()) << 2; - if (content_ctl(CONTENT_CTL_DOES_NOT_NEED_CONTENT, NULL) + if (content_does_not_need_content() && settings->set_supports_no_game_enable) string_list_append(content, "", attr); else @@ -1700,51 +1700,58 @@ static bool content_file_free(struct string_list *temporary_content) return true; } -bool content_ctl(enum content_ctl_state state, void *data) +bool content_does_not_need_content(void) { - switch(state) - { - case CONTENT_CTL_DOES_NOT_NEED_CONTENT: - return core_does_not_need_content; - case CONTENT_CTL_SET_DOES_NOT_NEED_CONTENT: - core_does_not_need_content = true; - break; - case CONTENT_CTL_UNSET_DOES_NOT_NEED_CONTENT: - core_does_not_need_content = false; - break; - case CONTENT_CTL_GET_CRC: - { - uint32_t **content_crc_ptr = (uint32_t**)data; - if (!content_crc_ptr) - return false; - *content_crc_ptr = &content_crc; - } - break; - case CONTENT_CTL_IS_INITED: - return content_is_inited; - case CONTENT_CTL_DEINIT: - content_file_free(temporary_content); - temporary_content = NULL; - content_crc = 0; - content_is_inited = false; - core_does_not_need_content = false; - break; - case CONTENT_CTL_INIT: - content_is_inited = false; - temporary_content = string_list_new(); - if (!temporary_content) - return false; - if (content_file_init(temporary_content)) - { - content_is_inited = true; - return true; - } - content_ctl(CONTENT_CTL_DEINIT, NULL); - return false; - case CONTENT_CTL_NONE: - default: - break; - } + return core_does_not_need_content; +} +void content_set_does_not_need_content(void) +{ + core_does_not_need_content = true; +} + +void content_unset_does_not_need_content(void) +{ + core_does_not_need_content = false; +} + +bool content_get_crc(uint32_t **content_crc_ptr) +{ + if (!content_crc_ptr) + return false; + *content_crc_ptr = &content_crc; return true; } + +bool content_is_inited(void) +{ + return _content_is_inited; +} + +void content_deinit(void) +{ + content_file_free(temporary_content); + temporary_content = NULL; + content_crc = 0; + _content_is_inited = false; + core_does_not_need_content = false; +} + +/* Initializes and loads a content file for the currently + * selected libretro core. */ +bool content_init(void) +{ + temporary_content = string_list_new(); + if (!temporary_content) + goto error; + + if (!content_file_init(temporary_content)) + goto error; + + _content_is_inited = true; + return true; + +error: + content_deinit(); + return false; +} diff --git a/content.h b/content.h index e2d5948b40..e02ee8f692 100644 --- a/content.h +++ b/content.h @@ -30,27 +30,6 @@ extern "C" { #endif -enum content_ctl_state -{ - CONTENT_CTL_NONE = 0, - - CONTENT_CTL_IS_INITED, - - CONTENT_CTL_DOES_NOT_NEED_CONTENT, - - CONTENT_CTL_SET_DOES_NOT_NEED_CONTENT, - - CONTENT_CTL_UNSET_DOES_NOT_NEED_CONTENT, - - /* Initializes and loads a content file for the currently - * selected libretro core. */ - CONTENT_CTL_INIT, - - CONTENT_CTL_DEINIT, - - CONTENT_CTL_GET_CRC, -}; - typedef struct ram_type { const char *path; @@ -93,7 +72,21 @@ bool content_save_state(const char *path); * as-is. */ bool content_load(content_ctx_info_t *info); -bool content_ctl(enum content_ctl_state state, void *data); +bool content_does_not_need_content(void); + +void content_set_does_not_need_content(void); + +void content_unset_does_not_need_content(void); + +bool content_get_crc(uint32_t **content_crc_ptr); + +bool content_is_inited(void); + +void content_deinit(void); + +/* Initializes and loads a content file for the currently + * selected libretro core. */ +bool content_init(void); #ifdef __cplusplus } diff --git a/dynamic.c b/dynamic.c index db1f0adff2..2c580a9b69 100644 --- a/dynamic.c +++ b/dynamic.c @@ -1005,9 +1005,9 @@ bool rarch_environment_cb(unsigned cmd, void *data) RARCH_LOG("Environ SET_SUPPORT_NO_GAME: %s.\n", state ? "yes" : "no"); if (state) - content_ctl(CONTENT_CTL_SET_DOES_NOT_NEED_CONTENT, NULL); + content_set_does_not_need_content(); else - content_ctl(CONTENT_CTL_UNSET_DOES_NOT_NEED_CONTENT, NULL); + content_unset_does_not_need_content(); break; } diff --git a/frontend/frontend.c b/frontend/frontend.c index cb68e911b6..e8037df0fb 100644 --- a/frontend/frontend.c +++ b/frontend/frontend.c @@ -133,7 +133,7 @@ int rarch_main(int argc, char *argv[], void *data) runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); runloop_ctl(RUNLOOP_CTL_GET_CONTENT_PATH, &fullpath); - if (content_ctl(CONTENT_CTL_IS_INITED, NULL) || content_ctl(CONTENT_CTL_DOES_NOT_NEED_CONTENT, NULL)) + if (content_is_inited() || content_does_not_need_content()) { char tmp[PATH_MAX_LENGTH]; struct retro_system_info *info = system ? &system->info : NULL; @@ -149,7 +149,7 @@ int rarch_main(int argc, char *argv[], void *data) if (rarch_ctl(RARCH_CTL_IS_DUMMY_CORE, NULL) || !info) content_push_to_history_playlist( - content_ctl(CONTENT_CTL_DOES_NOT_NEED_CONTENT, NULL) || *tmp, + content_does_not_need_content() || *tmp, *tmp ? tmp : NULL, info); } diff --git a/menu/menu_driver.c b/menu/menu_driver.c index f25469389a..1f0517c450 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -529,7 +529,7 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data) menu_driver_data_own = true; break; case RARCH_MENU_CTL_UNSET_OWN_DRIVER: - if (!content_ctl(CONTENT_CTL_IS_INITED, NULL)) + if (!content_is_inited()) return false; menu_driver_data_own = false; break; diff --git a/movie.c b/movie.c index 086e8bbcdb..3b22f13873 100644 --- a/movie.c +++ b/movie.c @@ -97,7 +97,7 @@ static bool init_playback(bsv_movie_t *handle, const char *path) return false; } - content_ctl(CONTENT_CTL_GET_CRC, &content_crc_ptr); + content_get_crc(&content_crc_ptr); if (swap_if_big32(header[CRC_INDEX]) != *content_crc_ptr) RARCH_WARN("CRC32 checksum mismatch between content file and saved content checksum in replay file header; replay highly likely to desync on playback.\n"); @@ -151,7 +151,7 @@ static bool init_record(bsv_movie_t *handle, const char *path) return false; } - content_ctl(CONTENT_CTL_GET_CRC, &content_crc_ptr); + content_get_crc(&content_crc_ptr); /* This value is supposed to show up as * BSV1 in a HEX editor, big-endian. */ diff --git a/netplay/netplay_common.c b/netplay/netplay_common.c index dbdcb9e8fb..f6bc3deb0b 100644 --- a/netplay/netplay_common.c +++ b/netplay/netplay_common.c @@ -78,7 +78,7 @@ uint32_t *np_bsv_header_generate(size_t *size, uint32_t magic) if (!header) goto error; - content_ctl(CONTENT_CTL_GET_CRC, &content_crc_ptr); + content_get_crc(&content_crc_ptr); bsv_header[MAGIC_INDEX] = swap_if_little32(BSV_MAGIC); bsv_header[SERIALIZER_INDEX] = swap_if_big32(magic); @@ -123,7 +123,7 @@ bool np_bsv_parse_header(const uint32_t *header, uint32_t magic) in_crc = swap_if_big32(header[CRC_INDEX]); - content_ctl(CONTENT_CTL_GET_CRC, &content_crc_ptr); + content_get_crc(&content_crc_ptr); if (in_crc != *content_crc_ptr) { @@ -205,7 +205,7 @@ bool np_send_info(netplay_t *netplay) mem_info.id = RETRO_MEMORY_SAVE_RAM; core_get_memory(&mem_info); - content_ctl(CONTENT_CTL_GET_CRC, &content_crc_ptr); + content_get_crc(&content_crc_ptr); header[0] = htonl(*content_crc_ptr); header[1] = htonl(np_impl_magic()); @@ -257,7 +257,7 @@ bool np_get_info(netplay_t *netplay) return false; } - content_ctl(CONTENT_CTL_GET_CRC, &content_crc_ptr); + content_get_crc(&content_crc_ptr); if (*content_crc_ptr != ntohl(header[0])) { diff --git a/retroarch.c b/retroarch.c index 5f2f64908c..fb22ec1ef7 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1050,7 +1050,7 @@ static void parse_input(int argc, char *argv[]) set_special_paths(argv + optind, argc - optind); } else - content_ctl(CONTENT_CTL_SET_DOES_NOT_NEED_CONTENT, NULL); + content_set_does_not_need_content(); /* Copy SRM/state dirs used, so they can be reused on reentrancy. */ if (global->has_set.save_path && @@ -1451,14 +1451,14 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data) case RARCH_CTL_SET_PATHS_REDIRECT: if(settings->sort_savestates_enable || settings->sort_savefiles_enable) { - if (content_ctl(CONTENT_CTL_DOES_NOT_NEED_CONTENT, NULL)) + if (content_does_not_need_content()) return false; set_paths_redirect(global->name.base); } break; case RARCH_CTL_SET_SRAM_ENABLE: global->sram.use = rarch_ctl(RARCH_CTL_IS_PLAIN_CORE, NULL) - && !content_ctl(CONTENT_CTL_DOES_NOT_NEED_CONTENT, NULL); + && !content_does_not_need_content(); break; case RARCH_CTL_SET_ERROR_ON_INIT: rarch_error_on_init = true; From 7e9eb5b6c41ab118809e23bb22e4daea28af9847 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 05:21:31 +0200 Subject: [PATCH 243/498] Cleanup --- runloop.c | 2 +- runloop.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/runloop.c b/runloop.c index 871dbc6496..db4da2fd25 100644 --- a/runloop.c +++ b/runloop.c @@ -155,7 +155,7 @@ void runloop_msg_queue_push(const char *msg, } -char* runloop_msg_queue_pull() +char* runloop_msg_queue_pull(void) { runloop_ctx_msg_info_t msg_info; runloop_ctl(RUNLOOP_CTL_MSG_QUEUE_PULL, &msg_info); diff --git a/runloop.h b/runloop.h index de671c4041..fd58ee694c 100644 --- a/runloop.h +++ b/runloop.h @@ -324,7 +324,7 @@ int runloop_iterate(unsigned *sleep_ms); void runloop_msg_queue_push(const char *msg, unsigned prio, unsigned duration, bool flush); -char* runloop_msg_queue_pull(); +char* runloop_msg_queue_pull(void); bool runloop_ctl(enum runloop_ctl_state state, void *data); From e1659543953fe2f4af4ef3b6b8cfe33b1fa6dc5b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 05:29:10 +0200 Subject: [PATCH 244/498] Rename libretro_version_1 to core_impl --- Makefile.common | 2 +- autosave.c | 2 +- cheats.c | 2 +- cheevos.c | 2 +- command_event.c | 2 +- configuration.c | 2 +- content.c | 2 +- libretro_version_1.h => core.h | 4 ++-- libretro_version_1.c => core_impl.c | 2 +- driver.c | 2 +- dynamic.c | 2 +- gfx/d3d/d3d.cpp | 2 +- gfx/drivers_shader/shader_gl_cg.c | 2 +- gfx/drivers_shader/shader_glsl.c | 2 +- gfx/video_driver.c | 2 +- gfx/video_state_python.c | 2 +- griffin/griffin.c | 2 +- menu/menu_display.c | 2 +- menu/menu_displaylist.c | 2 +- menu/menu_input.c | 2 +- menu/menu_setting.c | 2 +- movie.c | 2 +- netplay/netplay.h | 2 +- retroarch.c | 2 +- rewind.c | 2 +- runloop.c | 2 +- 26 files changed, 27 insertions(+), 27 deletions(-) rename libretro_version_1.h => core.h (98%) rename libretro_version_1.c => core_impl.c (99%) diff --git a/Makefile.common b/Makefile.common index b69e1520df..154ffdc4bf 100644 --- a/Makefile.common +++ b/Makefile.common @@ -108,7 +108,7 @@ OBJ += frontend/frontend.o \ frontend/drivers/platform_null.o \ ui/ui_companion_driver.o \ ui/drivers/ui_null.o \ - libretro_version_1.o \ + core_impl.o \ retroarch.o \ input/input_keyboard.o \ command_event.o \ diff --git a/autosave.c b/autosave.c index 1381a26854..6a09e9cb05 100644 --- a/autosave.c +++ b/autosave.c @@ -27,7 +27,7 @@ #include "configuration.h" #include "msg_hash.h" #include "runloop.h" -#include "libretro_version_1.h" +#include "core.h" #include "verbosity.h" /* Autosave support. */ diff --git a/cheats.c b/cheats.c index af051df050..65a7785b3a 100644 --- a/cheats.c +++ b/cheats.c @@ -26,7 +26,7 @@ #include "cheats.h" #include "runloop.h" #include "dynamic.h" -#include "libretro_version_1.h" +#include "core.h" #include "verbosity.h" #ifdef HAVE_CONFIG_H diff --git a/cheevos.c b/cheevos.c index 8700be4e54..31a38f4ae3 100644 --- a/cheevos.c +++ b/cheevos.c @@ -29,7 +29,7 @@ #include "performance.h" #include "msg_hash.h" #include "runloop.h" -#include "libretro_version_1.h" +#include "core.h" #ifdef HAVE_MENU #include "menu/menu_driver.h" diff --git a/command_event.c b/command_event.c index 279211a773..700ff718b0 100644 --- a/command_event.c +++ b/command_event.c @@ -46,7 +46,7 @@ #include "cheevos.h" #endif -#include "libretro_version_1.h" +#include "core.h" #include "verbosity.h" #include "runloop.h" #include "configuration.h" diff --git a/configuration.c b/configuration.c index 992e0cdadd..f740debfc8 100644 --- a/configuration.c +++ b/configuration.c @@ -33,7 +33,7 @@ #include "input/input_remapping.h" #include "defaults.h" #include "general.h" -#include "libretro_version_1.h" +#include "core.h" #include "retroarch.h" #include "system.h" #include "verbosity.h" diff --git a/content.c b/content.c index 968d941bf7..2957233816 100644 --- a/content.c +++ b/content.c @@ -63,7 +63,7 @@ #include "retroarch.h" #include "command_event.h" #include "file_path_special.h" -#include "libretro_version_1.h" +#include "core.h" #include "verbosity.h" #ifdef HAVE_7ZIP diff --git a/libretro_version_1.h b/core.h similarity index 98% rename from libretro_version_1.h rename to core.h index ad7f00be5c..2866e3abcc 100644 --- a/libretro_version_1.h +++ b/core.h @@ -15,8 +15,8 @@ * If not, see . */ -#ifndef _RETRO_IMPLEMENTATION_V1_H -#define _RETRO_IMPLEMENTATION_V1_H +#ifndef _LIBRETRO_CORE_IMPL_H +#define _LIBRETRO_CORE_IMPL_H #ifdef __cplusplus extern "C" { diff --git a/libretro_version_1.c b/core_impl.c similarity index 99% rename from libretro_version_1.c rename to core_impl.c index 34683c4591..277b211475 100644 --- a/libretro_version_1.c +++ b/core_impl.c @@ -27,7 +27,7 @@ #include "dynamic.h" #include "libretro.h" -#include "libretro_version_1.h" +#include "core.h" #include "general.h" #include "msg_hash.h" #include "rewind.h" diff --git a/driver.c b/driver.c index b236be464d..a6e26e3c00 100644 --- a/driver.c +++ b/driver.c @@ -26,7 +26,7 @@ #include "camera/camera_driver.h" #include "record/record_driver.h" #include "location/location_driver.h" -#include "libretro_version_1.h" +#include "core.h" #ifdef HAVE_MENU #include "menu/menu_driver.h" diff --git a/dynamic.c b/dynamic.c index 2c580a9b69..2e769902d9 100644 --- a/dynamic.c +++ b/dynamic.c @@ -36,7 +36,7 @@ #include "camera/camera_driver.h" #include "location/location_driver.h" #include "record/record_driver.h" -#include "libretro_version_1.h" +#include "core.h" #include "performance.h" #include "system.h" #include "gfx/video_context_driver.h" diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 65a52f27b3..77b12cf8a0 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -46,7 +46,7 @@ #include "../../menu/menu_driver.h" #endif -#include "../../libretro_version_1.h" +#include "../../core.h" #include "../../performance.h" #include "../../defines/d3d_defines.h" diff --git a/gfx/drivers_shader/shader_gl_cg.c b/gfx/drivers_shader/shader_gl_cg.c index e4011d76b6..ab1eb44872 100644 --- a/gfx/drivers_shader/shader_gl_cg.c +++ b/gfx/drivers_shader/shader_gl_cg.c @@ -38,7 +38,7 @@ #include "../video_shader_driver.h" #include "../video_shader_parse.h" -#include "../../libretro_version_1.h" +#include "../../core.h" #include "../../dynamic.h" #include "../../rewind.h" #include "../video_state_tracker.h" diff --git a/gfx/drivers_shader/shader_glsl.c b/gfx/drivers_shader/shader_glsl.c index 14d98013b7..f93413bf8e 100644 --- a/gfx/drivers_shader/shader_glsl.c +++ b/gfx/drivers_shader/shader_glsl.c @@ -28,7 +28,7 @@ #include "../video_state_tracker.h" #include "../../dynamic.h" #include "../../rewind.h" -#include "../../libretro_version_1.h" +#include "../../core.h" #ifdef HAVE_CONFIG_H #include "../../config.h" diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 5ce5c325be..e0946c2015 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -35,7 +35,7 @@ #include "../runloop.h" #include "../performance.h" #include "../list_special.h" -#include "../libretro_version_1.h" +#include "../core.h" #include "../system.h" #include "../command_event.h" #include "../msg_hash.h" diff --git a/gfx/video_state_python.c b/gfx/video_state_python.c index 6df023816f..891a01c804 100644 --- a/gfx/video_state_python.c +++ b/gfx/video_state_python.c @@ -26,7 +26,7 @@ #include "video_state_python.h" #include "../dynamic.h" #include "../libretro.h" -#include "../libretro_version_1.h" +#include "../core.h" #include "../general.h" #include "../verbosity.h" #include "../input/input_config.h" diff --git a/griffin/griffin.c b/griffin/griffin.c index b21c90f1fe..e9e4060fae 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -735,7 +735,7 @@ GIT /*============================================================ RETROARCH ============================================================ */ -#include "../libretro_version_1.c" +#include "../core_impl.c" #include "../retroarch.c" #include "../runloop.c" #include "../libretro-common/queues/task_queue.c" diff --git a/menu/menu_display.c b/menu/menu_display.c index 5c7cc0a40a..7bb36b6470 100644 --- a/menu/menu_display.c +++ b/menu/menu_display.c @@ -25,7 +25,7 @@ #include "../retroarch.h" #include "../configuration.h" #include "../runloop.h" -#include "../libretro_version_1.h" +#include "../core.h" #include "../gfx/video_thread_wrapper.h" #include "../verbosity.h" diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 28548d2835..922d7d0bfa 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -35,7 +35,7 @@ #include "../general.h" #include "../retroarch.h" #include "../system.h" -#include "../libretro_version_1.h" +#include "../core.h" #include "../frontend/frontend_driver.h" #include "../ui/ui_companion_driver.h" #include "../gfx/video_shader_driver.h" diff --git a/menu/menu_input.c b/menu/menu_input.c index 9f4ceb3826..5747af9f32 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -40,7 +40,7 @@ #include "../general.h" #include "../cheats.h" #include "../performance.h" -#include "../libretro_version_1.h" +#include "../core.h" #include "../input/input_joypad_driver.h" #include "../input/input_remapping.h" #include "../input/input_config.h" diff --git a/menu/menu_setting.c b/menu/menu_setting.c index cff7817e2f..0bc85544f4 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -49,7 +49,7 @@ #include "../driver.h" #include "../general.h" #include "../system.h" -#include "../libretro_version_1.h" +#include "../core.h" #include "../dynamic.h" #include "../camera/camera_driver.h" #include "../location/location_driver.h" diff --git a/movie.c b/movie.c index 3b22f13873..6d092322b7 100644 --- a/movie.c +++ b/movie.c @@ -23,7 +23,7 @@ #include "configuration.h" #include "movie.h" -#include "libretro_version_1.h" +#include "core.h" #include "content.h" #include "retroarch.h" #include "runloop.h" diff --git a/netplay/netplay.h b/netplay/netplay.h index 9059c98bf5..8015c4c428 100644 --- a/netplay/netplay.h +++ b/netplay/netplay.h @@ -24,7 +24,7 @@ #include #include "../libretro.h" -#include "../libretro_version_1.h" +#include "../core.h" typedef struct netplay netplay_t; diff --git a/retroarch.c b/retroarch.c index fb22ec1ef7..f577120dad 100644 --- a/retroarch.c +++ b/retroarch.c @@ -54,7 +54,7 @@ #include "frontend/frontend_driver.h" #include "audio/audio_driver.h" #include "record/record_driver.h" -#include "libretro_version_1.h" +#include "core.h" #include "configuration.h" #include "general.h" #include "runloop.h" diff --git a/rewind.c b/rewind.c index f1c54f0796..1621e12d62 100644 --- a/rewind.c +++ b/rewind.c @@ -25,7 +25,7 @@ #include "configuration.h" #include "msg_hash.h" #include "movie.h" -#include "libretro_version_1.h" +#include "core.h" #include "runloop.h" #include "performance.h" #include "verbosity.h" diff --git a/runloop.c b/runloop.c index db4da2fd25..b78bc057b9 100644 --- a/runloop.c +++ b/runloop.c @@ -52,7 +52,7 @@ #include "record/record_driver.h" #include "input/input_driver.h" #include "ui/ui_companion_driver.h" -#include "libretro_version_1.h" +#include "core.h" #include "msg_hash.h" From 0f7cdeaf7887fa6b979029fe34f67b95bf1cc5ae Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 06:09:39 +0200 Subject: [PATCH 245/498] Reduce two enums --- runloop.c | 47 +++++++++++++++++++++++++---------------------- runloop.h | 4 ---- 2 files changed, 25 insertions(+), 26 deletions(-) diff --git a/runloop.c b/runloop.c index b78bc057b9..29f1af10e3 100644 --- a/runloop.c +++ b/runloop.c @@ -120,7 +120,7 @@ static bool runloop_overrides_active = false; static bool runloop_game_options_active = false; static core_option_manager_t *runloop_core_options = NULL; #ifdef HAVE_THREADS -static slock_t *runloop_msg_queue_lock = NULL; +static slock_t *_runloop_msg_queue_lock = NULL; #endif static msg_queue_t *runloop_msg_queue = NULL; @@ -130,6 +130,20 @@ global_t *global_get_ptr(void) return &g_extern; } +static void runloop_msg_queue_lock(void) +{ +#ifdef HAVE_THREADS + slock_lock(_runloop_msg_queue_lock); +#endif +} + +static void runloop_msg_queue_unlock(void) +{ +#ifdef HAVE_THREADS + slock_unlock(_runloop_msg_queue_lock); +#endif +} + void runloop_msg_queue_push(const char *msg, unsigned prio, unsigned duration, bool flush) @@ -139,7 +153,7 @@ void runloop_msg_queue_push(const char *msg, if(!settings->video.font_enable) return; - runloop_ctl(RUNLOOP_CTL_MSG_QUEUE_LOCK, NULL); + runloop_msg_queue_lock(); if (flush) runloop_ctl(RUNLOOP_CTL_MSG_QUEUE_CLEAR, NULL); @@ -151,8 +165,7 @@ void runloop_msg_queue_push(const char *msg, runloop_ctl(RUNLOOP_CTL_MSG_QUEUE_PUSH, &msg_info); - runloop_ctl(RUNLOOP_CTL_MSG_QUEUE_UNLOCK, NULL); - + runloop_msg_queue_unlock(); } char* runloop_msg_queue_pull(void) @@ -988,19 +1001,19 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) } break; case RUNLOOP_CTL_MSG_QUEUE_PULL: - runloop_ctl(RUNLOOP_CTL_MSG_QUEUE_LOCK, NULL); + runloop_msg_queue_lock(); { const char **ret = (const char**)data; if (!ret) return false; *ret = msg_queue_pull(runloop_msg_queue); } - runloop_ctl(RUNLOOP_CTL_MSG_QUEUE_UNLOCK, NULL); + runloop_msg_queue_unlock(); break; case RUNLOOP_CTL_MSG_QUEUE_FREE: #ifdef HAVE_THREADS - slock_free(runloop_msg_queue_lock); - runloop_msg_queue_lock = NULL; + slock_free(_runloop_msg_queue_lock); + _runloop_msg_queue_lock = NULL; #endif break; case RUNLOOP_CTL_MSG_QUEUE_CLEAR: @@ -1010,11 +1023,11 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) if (!runloop_msg_queue) return true; - runloop_ctl(RUNLOOP_CTL_MSG_QUEUE_LOCK, NULL); + runloop_msg_queue_lock(); msg_queue_free(runloop_msg_queue); - runloop_ctl(RUNLOOP_CTL_MSG_QUEUE_UNLOCK, NULL); + runloop_msg_queue_unlock(); runloop_ctl(RUNLOOP_CTL_MSG_QUEUE_FREE, NULL); runloop_msg_queue = NULL; @@ -1025,18 +1038,8 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) retro_assert(runloop_msg_queue); #ifdef HAVE_THREADS - runloop_msg_queue_lock = slock_new(); - retro_assert(runloop_msg_queue_lock); -#endif - break; - case RUNLOOP_CTL_MSG_QUEUE_LOCK: -#ifdef HAVE_THREADS - slock_lock(runloop_msg_queue_lock); -#endif - break; - case RUNLOOP_CTL_MSG_QUEUE_UNLOCK: -#ifdef HAVE_THREADS - slock_unlock(runloop_msg_queue_lock); + _runloop_msg_queue_lock = slock_new(); + retro_assert(_runloop_msg_queue_lock); #endif break; case RUNLOOP_CTL_TASK_INIT: diff --git a/runloop.h b/runloop.h index fd58ee694c..0d6d8e8005 100644 --- a/runloop.h +++ b/runloop.h @@ -107,10 +107,6 @@ enum runloop_ctl_state /* Deinitializes message queue. */ RUNLOOP_CTL_MSG_QUEUE_DEINIT, - /* Initializes dummy core. */ - RUNLOOP_CTL_MSG_QUEUE_LOCK, - - RUNLOOP_CTL_MSG_QUEUE_UNLOCK, RUNLOOP_CTL_MSG_QUEUE_FREE, RUNLOOP_CTL_MSG_QUEUE_PULL, RUNLOOP_CTL_MSG_QUEUE_PUSH, From 13e67aa44e04ed25ed8b083ff962f8d37cf74212 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 06:29:11 +0200 Subject: [PATCH 246/498] Create runloop_iterate_data --- frontend/drivers/platform_emscripten.c | 2 +- frontend/drivers/platform_linux.c | 2 +- frontend/frontend.c | 2 +- menu/cbs/menu_cbs_select.c | 2 +- runloop.c | 8 +++++--- runloop.h | 3 ++- ui/drivers/cocoa/cocoatouch_menu.m | 4 ++-- ui/drivers/ui_cocoa.m | 2 +- ui/drivers/ui_cocoatouch.m | 2 +- 9 files changed, 15 insertions(+), 12 deletions(-) diff --git a/frontend/drivers/platform_emscripten.c b/frontend/drivers/platform_emscripten.c index e915e8f18d..e0a9a33105 100644 --- a/frontend/drivers/platform_emscripten.c +++ b/frontend/drivers/platform_emscripten.c @@ -34,7 +34,7 @@ static void emscripten_mainloop(void) int ret = runloop_iterate(&sleep_ms); if (ret == 1 && sleep_ms > 0) retro_sleep(sleep_ms); - runloop_ctl(RUNLOOP_CTL_DATA_ITERATE, NULL); + runloop_iterate_data(); if (ret != -1) return; diff --git a/frontend/drivers/platform_linux.c b/frontend/drivers/platform_linux.c index 6d45389c3c..634f60c05a 100644 --- a/frontend/drivers/platform_linux.c +++ b/frontend/drivers/platform_linux.c @@ -742,7 +742,7 @@ static void android_app_entry(void *data) if (ret == 1 && sleep_ms > 0) retro_sleep(sleep_ms); - runloop_ctl(RUNLOOP_CTL_DATA_ITERATE, NULL); + runloop_iterate_data(); }while (ret != -1); main_exit(data); diff --git a/frontend/frontend.c b/frontend/frontend.c index e8037df0fb..7922589f47 100644 --- a/frontend/frontend.c +++ b/frontend/frontend.c @@ -164,7 +164,7 @@ int rarch_main(int argc, char *argv[], void *data) if (ret == 1 && sleep_ms > 0) retro_sleep(sleep_ms); - runloop_ctl(RUNLOOP_CTL_DATA_ITERATE, NULL); + runloop_iterate_data(); }while(ret != -1); main_exit(args); diff --git a/menu/cbs/menu_cbs_select.c b/menu/cbs/menu_cbs_select.c index 2185222969..9893791782 100644 --- a/menu/cbs/menu_cbs_select.c +++ b/menu/cbs/menu_cbs_select.c @@ -78,7 +78,7 @@ static int action_select_default(const char *path, const char *label, unsigned t if (action != MENU_ACTION_NOOP) ret = menu_entry_action(&entry, idx, action); - runloop_ctl(RUNLOOP_CTL_DATA_ITERATE, NULL); + runloop_iterate_data(); return ret; } diff --git a/runloop.c b/runloop.c index 29f1af10e3..11f8814660 100644 --- a/runloop.c +++ b/runloop.c @@ -566,15 +566,17 @@ static bool runloop_check_pause_state(event_cmd_state_t *cmd) return true; } +void runloop_iterate_data(void) +{ + task_queue_ctl(TASK_QUEUE_CTL_CHECK, NULL); +} + bool runloop_ctl(enum runloop_ctl_state state, void *data) { settings_t *settings = config_get_ptr(); switch (state) { - case RUNLOOP_CTL_DATA_ITERATE: - task_queue_ctl(TASK_QUEUE_CTL_CHECK, NULL); - break; case RUNLOOP_CTL_SHADER_DIR_DEINIT: shader_dir_free(&runloop_shader_dir); break; diff --git a/runloop.h b/runloop.h index 0d6d8e8005..9ab13de888 100644 --- a/runloop.h +++ b/runloop.h @@ -126,7 +126,6 @@ enum runloop_ctl_state RUNLOOP_CTL_SYSTEM_INFO_GET, RUNLOOP_CTL_SYSTEM_INFO_INIT, RUNLOOP_CTL_SYSTEM_INFO_FREE, - RUNLOOP_CTL_DATA_ITERATE, RUNLOOP_CTL_PREPARE_DUMMY }; @@ -317,6 +316,8 @@ global_t *global_get_ptr(void); **/ int runloop_iterate(unsigned *sleep_ms); +void runloop_iterate_data(void); + void runloop_msg_queue_push(const char *msg, unsigned prio, unsigned duration, bool flush); diff --git a/ui/drivers/cocoa/cocoatouch_menu.m b/ui/drivers/cocoa/cocoatouch_menu.m index f00a482dcd..f91ff1872d 100644 --- a/ui/drivers/cocoa/cocoatouch_menu.m +++ b/ui/drivers/cocoa/cocoatouch_menu.m @@ -754,8 +754,8 @@ didSelectRowAtIndexPath:(NSIndexPath *)indexPath - (void)menuSelect: (uint32_t) i { - menu_entry_select(i); - runloop_ctl(RUNLOOP_CTL_DATA_ITERATE, NULL); + menu_entry_select(i); + runloop_iterate_data(); } - (void)menuBack diff --git a/ui/drivers/ui_cocoa.m b/ui/drivers/ui_cocoa.m index 6c88d5b81a..bce6069f9f 100644 --- a/ui/drivers/ui_cocoa.m +++ b/ui/drivers/ui_cocoa.m @@ -231,7 +231,7 @@ static void poll_iteration(void) ret = runloop_iterate(&sleep_ms); if (ret == 1 && sleep_ms > 0) retro_sleep(sleep_ms); - runloop_ctl(RUNLOOP_CTL_DATA_ITERATE, NULL); + runloop_iterate_data(); while(CFRunLoopRunInMode(kCFRunLoopDefaultMode, 0.002, FALSE) == kCFRunLoopRunHandledSource); } diff --git a/ui/drivers/ui_cocoatouch.m b/ui/drivers/ui_cocoatouch.m index 2c518c342e..51e06cdd5f 100644 --- a/ui/drivers/ui_cocoatouch.m +++ b/ui/drivers/ui_cocoatouch.m @@ -87,7 +87,7 @@ static void rarch_draw_observer(CFRunLoopObserverRef observer, if (ret == 1 && !ui_companion_is_on_foreground() && sleep_ms > 0) retro_sleep(sleep_ms); - runloop_ctl(RUNLOOP_CTL_DATA_ITERATE, NULL); + runloop_iterate_data(); if (ret == -1) { From 3f36c7f877496ed35804797f15dddd443b1d13c2 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 06:31:12 +0200 Subject: [PATCH 247/498] Get rid of RUNLOOP_CTL_FRAME_TIME --- runloop.c | 55 +++++++++++++++++++++++++------------------------------ runloop.h | 1 - 2 files changed, 25 insertions(+), 31 deletions(-) diff --git a/runloop.c b/runloop.c index 11f8814660..55b34f392f 100644 --- a/runloop.c +++ b/runloop.c @@ -720,35 +720,6 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) runloop_frame_time = *info; } break; - case RUNLOOP_CTL_FRAME_TIME: - if (!runloop_frame_time.callback) - return false; - - { - /* Updates frame timing if frame timing callback is in use by the core. - * Limits frame time if fast forward ratio throttle is enabled. */ - - retro_time_t current = retro_get_time_usec(); - retro_time_t delta = current - runloop_frame_time_last; - bool is_locked_fps = (runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL) || - input_driver_ctl(RARCH_INPUT_CTL_IS_NONBLOCK_STATE, NULL)) | - !!recording_driver_get_data_ptr(); - - - if (!runloop_frame_time_last || is_locked_fps) - delta = runloop_frame_time.reference; - - if (!is_locked_fps && runloop_ctl(RUNLOOP_CTL_IS_SLOWMOTION, NULL)) - delta /= settings->slowmotion_ratio; - - runloop_frame_time_last = current; - - if (is_locked_fps) - runloop_frame_time_last = 0; - - runloop_frame_time.callback(delta); - } - break; case RUNLOOP_CTL_GET_WINDOWED_SCALE: { unsigned **scale = (unsigned**)data; @@ -1355,7 +1326,31 @@ int runloop_iterate(unsigned *sleep_ms) } } - runloop_ctl(RUNLOOP_CTL_FRAME_TIME, NULL); + if (runloop_frame_time.callback) + { + /* Updates frame timing if frame timing callback is in use by the core. + * Limits frame time if fast forward ratio throttle is enabled. */ + + retro_time_t current = retro_get_time_usec(); + retro_time_t delta = current - runloop_frame_time_last; + bool is_locked_fps = (runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL) || + input_driver_ctl(RARCH_INPUT_CTL_IS_NONBLOCK_STATE, NULL)) | + !!recording_driver_get_data_ptr(); + + + if (!runloop_frame_time_last || is_locked_fps) + delta = runloop_frame_time.reference; + + if (!is_locked_fps && runloop_ctl(RUNLOOP_CTL_IS_SLOWMOTION, NULL)) + delta /= settings->slowmotion_ratio; + + runloop_frame_time_last = current; + + if (is_locked_fps) + runloop_frame_time_last = 0; + + runloop_frame_time.callback(delta); + } cmd.state[2] = cmd.state[0] & ~cmd.state[1]; /* trigger */ diff --git a/runloop.h b/runloop.h index 9ab13de888..cac320c31a 100644 --- a/runloop.h +++ b/runloop.h @@ -40,7 +40,6 @@ enum runloop_ctl_state RUNLOOP_CTL_GET_WINDOWED_SCALE, RUNLOOP_CTL_SET_WINDOWED_SCALE, RUNLOOP_CTL_SET_IDLE, - RUNLOOP_CTL_FRAME_TIME, RUNLOOP_CTL_SET_FRAME_TIME, RUNLOOP_CTL_IS_OVERRIDES_ACTIVE, RUNLOOP_CTL_SET_OVERRIDES_ACTIVE, From 8e599379f6202aba835a9a432268f468ae11b937 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 06:34:25 +0200 Subject: [PATCH 248/498] Create runloop_is_focused --- runloop.c | 19 +++++++++++-------- runloop.h | 1 - 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/runloop.c b/runloop.c index 55b34f392f..545cff1d3b 100644 --- a/runloop.c +++ b/runloop.c @@ -571,6 +571,14 @@ void runloop_iterate_data(void) task_queue_ctl(TASK_QUEUE_CTL_CHECK, NULL); } +static bool runloop_is_focused(void) +{ + settings_t *settings = config_get_ptr(); + if (settings->pause_nonactive) + return video_driver_ctl(RARCH_DISPLAY_CTL_IS_FOCUSED, NULL); + return true; +} + bool runloop_ctl(enum runloop_ctl_state state, void *data) { settings_t *settings = config_get_ptr(); @@ -766,15 +774,10 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) strlcpy(runloop_fullpath, fullpath, sizeof(runloop_fullpath)); } break; - case RUNLOOP_CTL_CHECK_FOCUS: - if (settings->pause_nonactive) - return video_driver_ctl(RARCH_DISPLAY_CTL_IS_FOCUSED, NULL); - break; case RUNLOOP_CTL_CHECK_IDLE_STATE: { event_cmd_state_t *cmd = (event_cmd_state_t*)data; - bool focused = - runloop_ctl(RUNLOOP_CTL_CHECK_FOCUS, NULL); + bool focused = runloop_is_focused(); check_pause(settings, focused, runloop_cmd_triggered(cmd, RARCH_PAUSE_TOGGLE), @@ -1403,8 +1406,8 @@ int runloop_iterate(unsigned *sleep_ms) if (menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL)) { menu_ctx_iterate_t iter; - bool focused = runloop_ctl(RUNLOOP_CTL_CHECK_FOCUS, NULL) - && !ui_companion_is_on_foreground(); + bool focused = runloop_is_focused() && + !ui_companion_is_on_foreground(); bool is_idle = runloop_ctl(RUNLOOP_CTL_IS_IDLE, NULL); enum menu_action action = (enum menu_action) menu_input_frame_retropad(cmd.state[0], cmd.state[2]); diff --git a/runloop.h b/runloop.h index cac320c31a..7dd76ee51a 100644 --- a/runloop.h +++ b/runloop.h @@ -63,7 +63,6 @@ enum runloop_ctl_state RUNLOOP_CTL_CLEAR_STATE, RUNLOOP_CTL_STATE_FREE, RUNLOOP_CTL_GLOBAL_FREE, - RUNLOOP_CTL_CHECK_FOCUS, RUNLOOP_CTL_SET_CORE_SHUTDOWN, RUNLOOP_CTL_UNSET_CORE_SHUTDOWN, RUNLOOP_CTL_IS_CORE_SHUTDOWN, From a9cec38c1d40942ee48479de88d01040fe10f461 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 06:36:52 +0200 Subject: [PATCH 249/498] Remove RUNLOOP_CTL_IS_FRAME_COUNT_END --- runloop.c | 15 ++++++++------- runloop.h | 1 - 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/runloop.c b/runloop.c index 545cff1d3b..af57dfe8a9 100644 --- a/runloop.c +++ b/runloop.c @@ -579,6 +579,13 @@ static bool runloop_is_focused(void) return true; } +static bool runloop_is_frame_count_end(void) +{ + uint64_t *frame_count = NULL; + video_driver_ctl(RARCH_DISPLAY_CTL_GET_FRAME_COUNT, &frame_count); + return runloop_max_frames && (*frame_count >= runloop_max_frames); +} + bool runloop_ctl(enum runloop_ctl_state state, void *data) { settings_t *settings = config_get_ptr(); @@ -648,12 +655,6 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) audio_driver_ctl(RARCH_AUDIO_CTL_UNSET_CALLBACK, NULL); memset(&runloop_system, 0, sizeof(rarch_system_info_t)); break; - case RUNLOOP_CTL_IS_FRAME_COUNT_END: - { - uint64_t *frame_count = NULL; - video_driver_ctl(RARCH_DISPLAY_CTL_GET_FRAME_COUNT, &frame_count); - return runloop_max_frames && (*frame_count >= runloop_max_frames); - } case RUNLOOP_CTL_SET_FRAME_TIME_LAST: runloop_frame_time_last_enable = true; break; @@ -1251,7 +1252,7 @@ static INLINE int runloop_iterate_time_to_exit(bool quit_key_pressed) time_to_exit = time_to_exit || quit_key_pressed; time_to_exit = time_to_exit || !video_driver_ctl(RARCH_DISPLAY_CTL_IS_ALIVE, NULL); time_to_exit = time_to_exit || bsv_movie_ctl(BSV_MOVIE_CTL_END_EOF, NULL); - time_to_exit = time_to_exit || runloop_ctl(RUNLOOP_CTL_IS_FRAME_COUNT_END, NULL); + time_to_exit = time_to_exit || runloop_is_frame_count_end(); time_to_exit = time_to_exit || runloop_ctl(RUNLOOP_CTL_IS_EXEC, NULL); if (!time_to_exit) diff --git a/runloop.h b/runloop.h index 7dd76ee51a..fc65005bd7 100644 --- a/runloop.h +++ b/runloop.h @@ -35,7 +35,6 @@ enum runloop_ctl_state RUNLOOP_CTL_UNSET_FRAME_TIME_LAST, RUNLOOP_CTL_TASK_INIT, RUNLOOP_CTL_IS_FRAME_TIME_LAST, - RUNLOOP_CTL_IS_FRAME_COUNT_END, RUNLOOP_CTL_IS_IDLE, RUNLOOP_CTL_GET_WINDOWED_SCALE, RUNLOOP_CTL_SET_WINDOWED_SCALE, From b21f09811990c38ae9b5d956a40977a1239995c3 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 06:58:52 +0200 Subject: [PATCH 250/498] Cleanups --- runloop.c | 109 +++++++++++++++++++++++++++++------------------------- runloop.h | 12 ------ 2 files changed, 59 insertions(+), 62 deletions(-) diff --git a/runloop.c b/runloop.c index af57dfe8a9..7a18ddd964 100644 --- a/runloop.c +++ b/runloop.c @@ -176,6 +176,61 @@ char* runloop_msg_queue_pull(void) return strdup(msg_info.msg); } +/* Checks if movie is being played back. */ +static bool runloop_check_movie_playback(void) +{ + if (!bsv_movie_ctl(BSV_MOVIE_CTL_END, NULL)) + return false; + + runloop_msg_queue_push( + msg_hash_to_str(MSG_MOVIE_PLAYBACK_ENDED), 1, 180, false); + RARCH_LOG("%s\n", msg_hash_to_str(MSG_MOVIE_PLAYBACK_ENDED)); + + event_cmd_ctl(EVENT_CMD_BSV_MOVIE_DEINIT, NULL); + + bsv_movie_ctl(BSV_MOVIE_CTL_UNSET_END, NULL); + bsv_movie_ctl(BSV_MOVIE_CTL_UNSET_PLAYBACK, NULL); + + return true; +} + +/* Checks if movie is being recorded. */ +static bool runloop_check_movie_record(void) +{ + if (!bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL)) + return false; + + runloop_msg_queue_push( + msg_hash_to_str(MSG_MOVIE_RECORD_STOPPED), 2, 180, true); + RARCH_LOG("%s\n", msg_hash_to_str(MSG_MOVIE_RECORD_STOPPED)); + + event_cmd_ctl(EVENT_CMD_BSV_MOVIE_DEINIT, NULL); + + return true; +} + +/* Checks if slowmotion toggle/hold was being pressed and/or held. */ +static bool runloop_check_slowmotion(bool *ptr) +{ + settings_t *settings = config_get_ptr(); + if (!ptr) + return false; + + runloop_slowmotion = *ptr; + + if (!runloop_slowmotion) + return false; + + if (settings->video.black_frame_insertion) + video_driver_ctl(RARCH_DISPLAY_CTL_CACHED_FRAME_RENDER, NULL); + + if (state_manager_frame_is_reversed()) + runloop_msg_queue_push(msg_hash_to_str(MSG_SLOW_MOTION_REWIND), 0, 30, true); + else + runloop_msg_queue_push(msg_hash_to_str(MSG_SLOW_MOTION), 0, 30, true); + return true; +} + #ifdef HAVE_MENU static bool runloop_cmd_get_state_menu_toggle_button_combo( settings_t *settings, @@ -513,7 +568,7 @@ static bool runloop_check_state(event_cmd_state_t *cmd, rarch_dir_list_t *shader tmp = runloop_cmd_press(cmd, RARCH_SLOWMOTION); - runloop_ctl(RUNLOOP_CTL_CHECK_SLOWMOTION, &tmp); + runloop_check_slowmotion(&tmp); if (runloop_cmd_triggered(cmd, RARCH_MOVIE_RECORD_TOGGLE)) runloop_ctl(RUNLOOP_CTL_CHECK_MOVIE, NULL); @@ -784,51 +839,18 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) runloop_cmd_triggered(cmd, RARCH_PAUSE_TOGGLE), runloop_cmd_triggered(cmd, RARCH_FRAMEADVANCE)); - if (!runloop_ctl(RUNLOOP_CTL_CHECK_PAUSE_STATE, cmd) || !focused) + if (!runloop_check_pause_state(cmd) || !focused) return false; } break; case RUNLOOP_CTL_CHECK_STATE: return runloop_check_state((event_cmd_state_t*)data, &runloop_shader_dir); - case RUNLOOP_CTL_CHECK_PAUSE_STATE: - return runloop_check_pause_state((event_cmd_state_t*)data); - case RUNLOOP_CTL_CHECK_SLOWMOTION: - { - bool *ptr = (bool*)data; - - if (!ptr) - return false; - - runloop_slowmotion = *ptr; - - if (!runloop_slowmotion) - return false; - - if (settings->video.black_frame_insertion) - video_driver_ctl(RARCH_DISPLAY_CTL_CACHED_FRAME_RENDER, NULL); - - if (state_manager_frame_is_reversed()) - runloop_msg_queue_push(msg_hash_to_str(MSG_SLOW_MOTION_REWIND), 0, 30, true); - else - runloop_msg_queue_push(msg_hash_to_str(MSG_SLOW_MOTION), 0, 30, true); - } - break; case RUNLOOP_CTL_CHECK_MOVIE: if (bsv_movie_ctl(BSV_MOVIE_CTL_PLAYBACK_ON, NULL)) - return runloop_ctl(RUNLOOP_CTL_CHECK_MOVIE_PLAYBACK, NULL); + return runloop_check_movie_playback(); if (!bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL)) return runloop_ctl(RUNLOOP_CTL_CHECK_MOVIE_INIT, NULL); - return runloop_ctl(RUNLOOP_CTL_CHECK_MOVIE_RECORD, NULL); - case RUNLOOP_CTL_CHECK_MOVIE_RECORD: - if (!bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL)) - return false; - - runloop_msg_queue_push( - msg_hash_to_str(MSG_MOVIE_RECORD_STOPPED), 2, 180, true); - RARCH_LOG("%s\n", msg_hash_to_str(MSG_MOVIE_RECORD_STOPPED)); - - event_cmd_ctl(EVENT_CMD_BSV_MOVIE_DEINIT, NULL); - break; + return runloop_check_movie_record(); case RUNLOOP_CTL_CHECK_MOVIE_INIT: if (bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL)) return false; @@ -871,19 +893,6 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) } } break; - case RUNLOOP_CTL_CHECK_MOVIE_PLAYBACK: - if (!bsv_movie_ctl(BSV_MOVIE_CTL_END, NULL)) - return false; - - runloop_msg_queue_push( - msg_hash_to_str(MSG_MOVIE_PLAYBACK_ENDED), 1, 180, false); - RARCH_LOG("%s\n", msg_hash_to_str(MSG_MOVIE_PLAYBACK_ENDED)); - - event_cmd_ctl(EVENT_CMD_BSV_MOVIE_DEINIT, NULL); - - bsv_movie_ctl(BSV_MOVIE_CTL_UNSET_END, NULL); - bsv_movie_ctl(BSV_MOVIE_CTL_UNSET_PLAYBACK, NULL); - break; case RUNLOOP_CTL_FRAME_TIME_FREE: memset(&runloop_frame_time, 0, sizeof(struct retro_frame_time_callback)); runloop_frame_time_last = 0; diff --git a/runloop.h b/runloop.h index fc65005bd7..66623d098d 100644 --- a/runloop.h +++ b/runloop.h @@ -84,20 +84,8 @@ enum runloop_ctl_state RUNLOOP_CTL_CHECK_MOVIE, - /* Checks if movie is being played. */ - RUNLOOP_CTL_CHECK_MOVIE_PLAYBACK, - RUNLOOP_CTL_CHECK_MOVIE_INIT, - /* Checks if movie is being recorded. */ - RUNLOOP_CTL_CHECK_MOVIE_RECORD, - - /* Checks if slowmotion toggle/hold - * was being pressed and/or held. */ - RUNLOOP_CTL_CHECK_SLOWMOTION, - - RUNLOOP_CTL_CHECK_PAUSE_STATE, - /* Initializes message queue. */ RUNLOOP_CTL_MSG_QUEUE_INIT, From b909342e12c546ef5be627b2152ebd1c1a076a85 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 07:00:28 +0200 Subject: [PATCH 251/498] Cleanup --- runloop.c | 4 +--- runloop.h | 3 --- 2 files changed, 1 insertion(+), 6 deletions(-) diff --git a/runloop.c b/runloop.c index 7a18ddd964..9c71752fd4 100644 --- a/runloop.c +++ b/runloop.c @@ -843,8 +843,6 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) return false; } break; - case RUNLOOP_CTL_CHECK_STATE: - return runloop_check_state((event_cmd_state_t*)data, &runloop_shader_dir); case RUNLOOP_CTL_CHECK_MOVIE: if (bsv_movie_ctl(BSV_MOVIE_CTL_PLAYBACK_ON, NULL)) return runloop_check_movie_playback(); @@ -1445,7 +1443,7 @@ int runloop_iterate(unsigned *sleep_ms) } #endif - if (!runloop_ctl(RUNLOOP_CTL_CHECK_STATE, &cmd)) + if (!runloop_check_state(&cmd, &runloop_shader_dir)) { /* RetroArch has been paused. */ core_poll(); diff --git a/runloop.h b/runloop.h index 66623d098d..e451671cde 100644 --- a/runloop.h +++ b/runloop.h @@ -79,9 +79,6 @@ enum runloop_ctl_state RUNLOOP_CTL_KEY_EVENT_GET, RUNLOOP_CTL_DATA_DEINIT, - /* Checks for state changes in this frame. */ - RUNLOOP_CTL_CHECK_STATE, - RUNLOOP_CTL_CHECK_MOVIE, RUNLOOP_CTL_CHECK_MOVIE_INIT, From 889306f8ad6890b6bdd0fd94a160a7d8f13efb44 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 07:10:51 +0200 Subject: [PATCH 252/498] Remove unused variable --- gfx/video_texture_image.c | 1 - 1 file changed, 1 deletion(-) diff --git a/gfx/video_texture_image.c b/gfx/video_texture_image.c index 674b625a2c..012b388c31 100644 --- a/gfx/video_texture_image.c +++ b/gfx/video_texture_image.c @@ -116,7 +116,6 @@ bool video_texture_image_color_convert(unsigned r_shift, static bool video_texture_image_rpng_gx_convert_texture32( struct texture_image *image) { - int ret; unsigned tmp_pitch, width2, i; const uint16_t *src = NULL; uint16_t *dst = NULL; From 897a058d291329fd4867a1541e020086a0b64ae8 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 07:11:49 +0200 Subject: [PATCH 253/498] (PS3) Avoid warning --- dynamic.c | 1 + 1 file changed, 1 insertion(+) diff --git a/dynamic.c b/dynamic.c index 2e769902d9..02bfb5a782 100644 --- a/dynamic.c +++ b/dynamic.c @@ -973,6 +973,7 @@ bool rarch_environment_cb(unsigned cmd, void *data) case RETRO_HW_CONTEXT_OPENGL_CORE: { gfx_ctx_flags_t flags; + flags.flags = 0; BIT32_SET(flags.flags, GFX_CTX_FLAGS_GL_CORE_CONTEXT); gfx_ctx_ctl(GFX_CTL_SET_FLAGS, &flags); From 2f6baffe458cdbc7c489708474395b24c527dfbe Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 07:24:10 +0200 Subject: [PATCH 254/498] Expand net_socket.c --- libretro-common/include/net/net_socket.h | 8 ++++ libretro-common/net/net_socket.c | 50 +++++++++++++++++------- netlogger.c | 16 +++----- 3 files changed, 49 insertions(+), 25 deletions(-) diff --git a/libretro-common/include/net/net_socket.h b/libretro-common/include/net/net_socket.h index 0b45ded990..c7a0524596 100644 --- a/libretro-common/include/net/net_socket.h +++ b/libretro-common/include/net/net_socket.h @@ -50,6 +50,14 @@ enum socket_protocol SOCKET_PROTOCOL_UDP }; +typedef struct socket_target +{ + unsigned port; + const char *server; + enum socket_domain domain; + enum socket_protocol prot; +} socket_target_t; + int socket_init(void **address, uint16_t port, const char *server, enum socket_type type); int socket_close(int fd); diff --git a/libretro-common/net/net_socket.c b/libretro-common/net/net_socket.c index 450bc3c6b5..557ccb6800 100644 --- a/libretro-common/net/net_socket.c +++ b/libretro-common/net/net_socket.c @@ -208,6 +208,23 @@ int socket_connect(int fd, void *data, bool timeout_enable) return connect(fd, addr->ai_addr, addr->ai_addrlen); } +static int domain_get(enum socket_domain type) +{ + switch (type) + { + case SOCKET_DOMAIN_INET: +#ifdef VITA + return PSP2_NET_AF_INET; +#else + return AF_INET; +#endif + default: + break; + } + + return 0; +} + int socket_create( const char *name, enum socket_domain domain_type, @@ -215,15 +232,9 @@ int socket_create( enum socket_protocol protocol_type) { int type = 0; - int domain = 0; int protocol = 0; + int domain = domain_get(domain_type); #ifdef VITA - switch (domain_type) - { - case SOCKET_DOMAIN_INET: - domain = PSP2_NET_AF_INET; - break; - } switch (socket_type) { @@ -253,13 +264,6 @@ int socket_create( return sceNetSocket(name, domain, type, protocol); #else - switch (domain_type) - { - case SOCKET_DOMAIN_INET: - domain = AF_INET; - break; - } - switch (socket_type) { case SOCKET_TYPE_DATAGRAM: @@ -289,3 +293,21 @@ int socket_create( return socket(domain, type, protocol); #endif } + +void socket_set_target(void *data, socket_target_t *in_addr) +{ + struct sockaddr_in *out_target = (struct sockaddr_in*)data; + + out_target->sin_port = inet_htons(in_addr->port); + out_target->sin_family = domain_get(in_addr->domain); +#ifdef VITA + out_target->sin_addr = inet_aton(in_addr->server); +#else +#ifdef GEKKO + out_target->sin_len = 8; +#endif + + inet_pton(AF_INET, in_addr->server, &out_target->sin_addr); + +#endif +} diff --git a/netlogger.c b/netlogger.c index 71dd5d42f6..c6e2dcef06 100644 --- a/netlogger.c +++ b/netlogger.c @@ -42,6 +42,7 @@ static struct sockaddr_in target; void logger_init (void) { + socket_target_t in_target; const char *server = PC_DEVELOPMENT_IP_ADDRESS; unsigned port = PC_DEVELOPMENT_UDP_PORT; @@ -57,18 +58,11 @@ void logger_init (void) SOCKET_TYPE_DATAGRAM, SOCKET_PROTOCOL_NONE); - target.sin_port = inet_htons(port); -#ifdef VITA - target.sin_family = PSP2_NET_AF_INET; - target.sin_addr = inet_aton(server); -#else - target.sin_family = AF_INET; -#ifdef GEKKO - target.sin_len = 8; -#endif + in_target.port = port; + in_target.server = server; + in_target.domain = SOCKET_DOMAIN_INET; - inet_pton(AF_INET, server, &target.sin_addr); -#endif + socket_set_target(&target, &in_target); } void logger_shutdown (void) From 8faa6231db51327b3a39cf5ce2c2e4ff982b10fd Mon Sep 17 00:00:00 2001 From: Hans-Kristian Arntzen Date: Sun, 8 May 2016 09:37:27 +0200 Subject: [PATCH 255/498] Fix some warnings. --- Makefile.common | 2 +- libretro-common/formats/jpeg/rjpeg.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/Makefile.common b/Makefile.common index 154ffdc4bf..7ea3441a0f 100644 --- a/Makefile.common +++ b/Makefile.common @@ -1014,7 +1014,7 @@ ifeq ($(HAVE_FFMPEG), 1) cores/libretro-ffmpeg/ffmpeg_core.o LIBS += $(AVCODEC_LIBS) $(AVFORMAT_LIBS) $(AVUTIL_LIBS) $(SWSCALE_LIBS) $(SWRESAMPLE_LIBS) $(FFMPEG_LIBS) DEFINES += $(AVCODEC_CFLAGS) $(AVFORMAT_CFLAGS) $(AVUTIL_CFLAGS) $(SWSCALE_CFLAGS) $(SWRESAMPLE_CFLAGS) - DEFINES += -DHAVE_FFMPEG -Iffmpeg + DEFINES += -Wno-deprecated-declarations -DHAVE_FFMPEG -Iffmpeg endif ifeq ($(HAVE_COMPRESSION), 1) diff --git a/libretro-common/formats/jpeg/rjpeg.c b/libretro-common/formats/jpeg/rjpeg.c index ddb6698be2..df45b8ffb5 100644 --- a/libretro-common/formats/jpeg/rjpeg.c +++ b/libretro-common/formats/jpeg/rjpeg.c @@ -429,7 +429,7 @@ static INLINE void rjpeg_decode_block( struct rjpeg_component *c, unsigned char* out) { - unsigned char code; + unsigned char code = 0; int coef = 0; memset(ctx->block, 0, sizeof(ctx->block)); From 26cfedc54611263b6505817ac38124f8bbfec302 Mon Sep 17 00:00:00 2001 From: Hans-Kristian Arntzen Date: Sun, 8 May 2016 09:54:36 +0200 Subject: [PATCH 256/498] Add XMB ribbon shaders to Vulkan. --- gfx/drivers/vulkan_shaders/ribbon.frag | 21 + gfx/drivers/vulkan_shaders/ribbon.frag.inc | 127 ++++++ gfx/drivers/vulkan_shaders/ribbon.vert | 52 +++ gfx/drivers/vulkan_shaders/ribbon.vert.inc | 430 ++++++++++++++++++ gfx/drivers/vulkan_shaders/ribbon_simple.frag | 8 + .../vulkan_shaders/ribbon_simple.frag.inc | 34 ++ gfx/drivers/vulkan_shaders/ribbon_simple.vert | 35 ++ .../vulkan_shaders/ribbon_simple.vert.inc | 342 ++++++++++++++ 8 files changed, 1049 insertions(+) create mode 100644 gfx/drivers/vulkan_shaders/ribbon.frag create mode 100644 gfx/drivers/vulkan_shaders/ribbon.frag.inc create mode 100644 gfx/drivers/vulkan_shaders/ribbon.vert create mode 100644 gfx/drivers/vulkan_shaders/ribbon.vert.inc create mode 100644 gfx/drivers/vulkan_shaders/ribbon_simple.frag create mode 100644 gfx/drivers/vulkan_shaders/ribbon_simple.frag.inc create mode 100644 gfx/drivers/vulkan_shaders/ribbon_simple.vert create mode 100644 gfx/drivers/vulkan_shaders/ribbon_simple.vert.inc diff --git a/gfx/drivers/vulkan_shaders/ribbon.frag b/gfx/drivers/vulkan_shaders/ribbon.frag new file mode 100644 index 0000000000..260730f10b --- /dev/null +++ b/gfx/drivers/vulkan_shaders/ribbon.frag @@ -0,0 +1,21 @@ +#version 310 es +precision mediump float; + +layout(std430, push_constant) uniform PushConstants +{ + float time; +} constants; + +layout(location = 0) in vec3 vEC; +layout(location = 0) out vec4 FragColor; + +void main() +{ + const vec3 up = vec3(0.0, 0.0, 1.0); + vec3 x = dFdx(vEC); + vec3 y = dFdy(vEC); + vec3 normal = normalize(cross(x, y)); + float c = 1.0 - dot(normal, up); + c = (1.0 - cos(c * c)) / 3.0; + FragColor = vec4(1.0, 1.0, 1.0, c); +} diff --git a/gfx/drivers/vulkan_shaders/ribbon.frag.inc b/gfx/drivers/vulkan_shaders/ribbon.frag.inc new file mode 100644 index 0000000000..f93eeb2841 --- /dev/null +++ b/gfx/drivers/vulkan_shaders/ribbon.frag.inc @@ -0,0 +1,127 @@ +unsigned char ribbon_frag_spv[] = { + 0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x08, 0x00, + 0x2d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x47, 0x4c, 0x53, 0x4c, 0x2e, 0x73, 0x74, 0x64, 0x2e, 0x34, 0x35, 0x30, + 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x07, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, + 0x0b, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, 0x10, 0x00, 0x03, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x36, 0x01, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, + 0x05, 0x00, 0x03, 0x00, 0x09, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, + 0x05, 0x00, 0x03, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x76, 0x45, 0x43, 0x00, + 0x05, 0x00, 0x03, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x79, 0x00, 0x00, 0x00, + 0x05, 0x00, 0x04, 0x00, 0x11, 0x00, 0x00, 0x00, 0x6e, 0x6f, 0x72, 0x6d, + 0x61, 0x6c, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x17, 0x00, 0x00, 0x00, + 0x63, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, 0x27, 0x00, 0x00, 0x00, + 0x46, 0x72, 0x61, 0x67, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0x00, 0x00, + 0x05, 0x00, 0x06, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x50, 0x75, 0x73, 0x68, + 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x73, 0x00, 0x00, 0x00, + 0x06, 0x00, 0x05, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x74, 0x69, 0x6d, 0x65, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, + 0x2c, 0x00, 0x00, 0x00, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, + 0x73, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, 0x09, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, 0x0b, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x0b, 0x00, 0x00, 0x00, + 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, + 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, + 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, + 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, + 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, + 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, + 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, + 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, + 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, + 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, + 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, + 0x1d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, + 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, + 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, + 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, + 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, + 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, + 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, + 0x27, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, + 0x27, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x47, 0x00, 0x03, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x47, 0x00, 0x03, 0x00, 0x29, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x48, 0x00, 0x04, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x2a, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x47, 0x00, 0x03, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x47, 0x00, 0x04, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x21, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x16, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, + 0x17, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x16, 0x00, 0x00, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, + 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x06, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x1b, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, + 0x18, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x17, 0x00, 0x04, 0x00, + 0x25, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x04, 0x00, 0x26, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x25, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x26, 0x00, 0x00, 0x00, + 0x27, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x03, 0x00, + 0x2a, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, + 0x2b, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0xf8, 0x00, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x11, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, + 0x16, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0x0b, 0x00, 0x00, 0x00, 0xcf, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x0d, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, + 0xd0, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x0f, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x12, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x0c, 0x00, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, + 0x13, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x06, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x15, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x00, + 0x14, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x11, 0x00, 0x00, 0x00, + 0x15, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x19, 0x00, 0x00, 0x00, 0x11, 0x00, 0x00, 0x00, 0x94, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, + 0x1b, 0x00, 0x00, 0x00, 0x83, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x1d, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, + 0x3e, 0x00, 0x03, 0x00, 0x17, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, + 0x17, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x1f, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, + 0x1f, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x06, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x21, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x00, 0x00, 0x83, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x22, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, + 0x88, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, + 0x22, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, + 0x17, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, + 0x50, 0x00, 0x07, 0x00, 0x25, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, + 0x18, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, + 0x28, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x27, 0x00, 0x00, 0x00, + 0x29, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, 0x00 +}; +unsigned int ribbon_frag_spv_len = 1488; diff --git a/gfx/drivers/vulkan_shaders/ribbon.vert b/gfx/drivers/vulkan_shaders/ribbon.vert new file mode 100644 index 0000000000..9414c13d31 --- /dev/null +++ b/gfx/drivers/vulkan_shaders/ribbon.vert @@ -0,0 +1,52 @@ +#version 310 es + +layout(location = 0) in vec3 VertexCoord; +layout(location = 0) out vec3 vEC; + +layout(std430, push_constant) uniform PushConstants +{ + float time; +} constants; + +float iqhash(float n) +{ + return fract(sin(n) * 43758.5453); +} + +float noise(vec3 x) +{ + vec3 p = floor(x); + vec3 f = fract(x); + f = f * f * (3.0 - 2.0 * f); + float n = p.x + p.y * 57.0 + 113.0 * p.z; + return mix(mix(mix(iqhash(n), iqhash(n + 1.0), f.x), + mix(iqhash(n + 57.0), iqhash(n + 58.0), f.x), f.y), + mix(mix(iqhash(n + 113.0), iqhash(n + 114.0), f.x), + mix(iqhash(n + 170.0), iqhash(n + 171.0), f.x), f.y), f.z); +} + +float xmb_noise2(vec3 x) +{ + return cos(x.z * 2.0); +} + +void main() +{ + vec3 v = vec3(VertexCoord.x, 0.0, VertexCoord.y); + vec3 v2 = v; + vec3 v3 = v; + + v.y = xmb_noise2(v2) / 6.0; + + v3.x += constants.time / 5.0; + v3.x /= 2.0; + + v3.z += constants.time / 10.0; + v3.y += constants.time / 100.0; + + v.z += noise(v3 * 7.0) / 15.0; + v.y += noise(v3 * 7.0) / 15.0 + cos(v.x * 2.0 - constants.time / 5.0) / 5.0 - 0.3; + + vEC = v; + gl_Position = vec4(v, 1.0); +} diff --git a/gfx/drivers/vulkan_shaders/ribbon.vert.inc b/gfx/drivers/vulkan_shaders/ribbon.vert.inc new file mode 100644 index 0000000000..39f62ae249 --- /dev/null +++ b/gfx/drivers/vulkan_shaders/ribbon.vert.inc @@ -0,0 +1,430 @@ +unsigned char ribbon_vert_spv[] = { + 0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x08, 0x00, + 0xe2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x47, 0x4c, 0x53, 0x4c, 0x2e, 0x73, 0x74, 0x64, 0x2e, 0x34, 0x35, 0x30, + 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, + 0x80, 0x00, 0x00, 0x00, 0xd5, 0x00, 0x00, 0x00, 0xda, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, 0x36, 0x01, 0x00, 0x00, + 0x05, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, + 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x69, 0x71, 0x68, 0x61, 0x73, 0x68, 0x28, 0x66, 0x31, 0x3b, 0x00, 0x00, + 0x05, 0x00, 0x03, 0x00, 0x09, 0x00, 0x00, 0x00, 0x6e, 0x00, 0x00, 0x00, + 0x05, 0x00, 0x05, 0x00, 0x10, 0x00, 0x00, 0x00, 0x6e, 0x6f, 0x69, 0x73, + 0x65, 0x28, 0x76, 0x66, 0x33, 0x3b, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, + 0x0f, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, + 0x13, 0x00, 0x00, 0x00, 0x78, 0x6d, 0x62, 0x5f, 0x6e, 0x6f, 0x69, 0x73, + 0x65, 0x32, 0x28, 0x76, 0x66, 0x33, 0x3b, 0x00, 0x05, 0x00, 0x03, 0x00, + 0x12, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, + 0x1c, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, + 0x1f, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, + 0x2c, 0x00, 0x00, 0x00, 0x6e, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, + 0x3d, 0x00, 0x00, 0x00, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x00, 0x00, 0x00, + 0x05, 0x00, 0x04, 0x00, 0x43, 0x00, 0x00, 0x00, 0x70, 0x61, 0x72, 0x61, + 0x6d, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x4a, 0x00, 0x00, 0x00, + 0x70, 0x61, 0x72, 0x61, 0x6d, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, + 0x4f, 0x00, 0x00, 0x00, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x00, 0x00, 0x00, + 0x05, 0x00, 0x04, 0x00, 0x59, 0x00, 0x00, 0x00, 0x70, 0x61, 0x72, 0x61, + 0x6d, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x5e, 0x00, 0x00, 0x00, + 0x70, 0x61, 0x72, 0x61, 0x6d, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, + 0x66, 0x00, 0x00, 0x00, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x00, 0x00, 0x00, + 0x05, 0x00, 0x04, 0x00, 0x6b, 0x00, 0x00, 0x00, 0x70, 0x61, 0x72, 0x61, + 0x6d, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x7e, 0x00, 0x00, 0x00, + 0x76, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, 0x80, 0x00, 0x00, 0x00, + 0x56, 0x65, 0x72, 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x00, + 0x05, 0x00, 0x03, 0x00, 0x88, 0x00, 0x00, 0x00, 0x76, 0x32, 0x00, 0x00, + 0x05, 0x00, 0x03, 0x00, 0x8a, 0x00, 0x00, 0x00, 0x76, 0x33, 0x00, 0x00, + 0x05, 0x00, 0x04, 0x00, 0x8c, 0x00, 0x00, 0x00, 0x70, 0x61, 0x72, 0x61, + 0x6d, 0x00, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x92, 0x00, 0x00, 0x00, + 0x50, 0x75, 0x73, 0x68, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, + 0x73, 0x00, 0x00, 0x00, 0x06, 0x00, 0x05, 0x00, 0x92, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x74, 0x69, 0x6d, 0x65, 0x00, 0x00, 0x00, 0x00, + 0x05, 0x00, 0x05, 0x00, 0x94, 0x00, 0x00, 0x00, 0x63, 0x6f, 0x6e, 0x73, + 0x74, 0x61, 0x6e, 0x74, 0x73, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, + 0xb7, 0x00, 0x00, 0x00, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x00, 0x00, 0x00, + 0x05, 0x00, 0x04, 0x00, 0xc1, 0x00, 0x00, 0x00, 0x70, 0x61, 0x72, 0x61, + 0x6d, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0xd5, 0x00, 0x00, 0x00, + 0x76, 0x45, 0x43, 0x00, 0x05, 0x00, 0x06, 0x00, 0xd8, 0x00, 0x00, 0x00, + 0x67, 0x6c, 0x5f, 0x50, 0x65, 0x72, 0x56, 0x65, 0x72, 0x74, 0x65, 0x78, + 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x06, 0x00, 0xd8, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, + 0x69, 0x6f, 0x6e, 0x00, 0x06, 0x00, 0x07, 0x00, 0xd8, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x69, 0x6e, 0x74, + 0x53, 0x69, 0x7a, 0x65, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, + 0xda, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, + 0x80, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x48, 0x00, 0x05, 0x00, 0x92, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, + 0x92, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, + 0x94, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x47, 0x00, 0x04, 0x00, 0xd5, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0xd8, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x48, 0x00, 0x05, 0x00, 0xd8, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x0b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, + 0xd8, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x16, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x21, 0x00, 0x04, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x17, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x21, 0x00, 0x04, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, + 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, + 0x8c, 0xee, 0x2a, 0x47, 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x25, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x2b, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, + 0x15, 0x00, 0x04, 0x00, 0x2d, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x2d, 0x00, 0x00, 0x00, + 0x2e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, + 0x2d, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x64, 0x42, 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x37, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe2, 0x42, 0x2b, 0x00, 0x04, 0x00, + 0x2d, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x80, 0x3f, 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x4d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0x42, 0x2b, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe4, 0x42, + 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x2a, 0x43, 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x69, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2b, 0x43, 0x20, 0x00, 0x04, 0x00, + 0x7f, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x81, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x8f, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xc0, 0x40, 0x1e, 0x00, 0x03, 0x00, 0x92, 0x00, 0x00, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x93, 0x00, 0x00, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x92, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, + 0x93, 0x00, 0x00, 0x00, 0x94, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, + 0x15, 0x00, 0x04, 0x00, 0x95, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x95, 0x00, 0x00, 0x00, + 0x96, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, + 0x97, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x9a, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xa0, 0x40, 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0xa6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x41, 0x2b, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0xae, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc8, 0x42, + 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0xb5, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xe0, 0x40, 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0xb9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x41, 0x2b, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0xce, 0x00, 0x00, 0x00, 0x9a, 0x99, 0x99, 0x3e, + 0x20, 0x00, 0x04, 0x00, 0xd4, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0xd4, 0x00, 0x00, 0x00, + 0xd5, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, + 0xd7, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x1e, 0x00, 0x04, 0x00, 0xd8, 0x00, 0x00, 0x00, 0xd7, 0x00, 0x00, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0xd9, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0xd8, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, + 0xd9, 0x00, 0x00, 0x00, 0xda, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x04, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0xd7, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0xf8, 0x00, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, + 0x0d, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, + 0x8a, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, + 0x0d, 0x00, 0x00, 0x00, 0x8c, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, 0xb7, 0x00, 0x00, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, + 0xc1, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, + 0x81, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, + 0x2e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x83, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, + 0x81, 0x00, 0x00, 0x00, 0x85, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, + 0x31, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x86, 0x00, 0x00, 0x00, 0x85, 0x00, 0x00, 0x00, 0x50, 0x00, 0x06, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0x87, 0x00, 0x00, 0x00, 0x83, 0x00, 0x00, 0x00, + 0x84, 0x00, 0x00, 0x00, 0x86, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, + 0x7e, 0x00, 0x00, 0x00, 0x87, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0x89, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, + 0x3e, 0x00, 0x03, 0x00, 0x88, 0x00, 0x00, 0x00, 0x89, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x8b, 0x00, 0x00, 0x00, + 0x7e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x8a, 0x00, 0x00, 0x00, + 0x8b, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0x8d, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, + 0x8c, 0x00, 0x00, 0x00, 0x8d, 0x00, 0x00, 0x00, 0x39, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x8e, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, + 0x8c, 0x00, 0x00, 0x00, 0x88, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x90, 0x00, 0x00, 0x00, 0x8e, 0x00, 0x00, 0x00, 0x8f, 0x00, 0x00, 0x00, + 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x91, 0x00, 0x00, 0x00, + 0x7e, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, + 0x91, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, + 0x97, 0x00, 0x00, 0x00, 0x98, 0x00, 0x00, 0x00, 0x94, 0x00, 0x00, 0x00, + 0x96, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x99, 0x00, 0x00, 0x00, 0x98, 0x00, 0x00, 0x00, 0x88, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x9b, 0x00, 0x00, 0x00, 0x99, 0x00, 0x00, 0x00, + 0x9a, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x9c, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x9d, 0x00, 0x00, 0x00, + 0x9c, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x9e, 0x00, 0x00, 0x00, 0x9d, 0x00, 0x00, 0x00, 0x9b, 0x00, 0x00, 0x00, + 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x9f, 0x00, 0x00, 0x00, + 0x8a, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, + 0x9f, 0x00, 0x00, 0x00, 0x9e, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, + 0x07, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00, 0x00, + 0x2e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0xa1, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x88, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0xa2, 0x00, 0x00, 0x00, 0xa1, 0x00, 0x00, 0x00, + 0x26, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, + 0xa3, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, + 0x3e, 0x00, 0x03, 0x00, 0xa3, 0x00, 0x00, 0x00, 0xa2, 0x00, 0x00, 0x00, + 0x41, 0x00, 0x05, 0x00, 0x97, 0x00, 0x00, 0x00, 0xa4, 0x00, 0x00, 0x00, + 0x94, 0x00, 0x00, 0x00, 0x96, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0xa5, 0x00, 0x00, 0x00, 0xa4, 0x00, 0x00, 0x00, + 0x88, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0xa7, 0x00, 0x00, 0x00, + 0xa5, 0x00, 0x00, 0x00, 0xa6, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, + 0x07, 0x00, 0x00, 0x00, 0xa8, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00, 0x00, + 0x38, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0xa9, 0x00, 0x00, 0x00, 0xa8, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0xaa, 0x00, 0x00, 0x00, 0xa9, 0x00, 0x00, 0x00, + 0xa7, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, + 0xab, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, + 0x3e, 0x00, 0x03, 0x00, 0xab, 0x00, 0x00, 0x00, 0xaa, 0x00, 0x00, 0x00, + 0x41, 0x00, 0x05, 0x00, 0x97, 0x00, 0x00, 0x00, 0xac, 0x00, 0x00, 0x00, + 0x94, 0x00, 0x00, 0x00, 0x96, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0xad, 0x00, 0x00, 0x00, 0xac, 0x00, 0x00, 0x00, + 0x88, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0xaf, 0x00, 0x00, 0x00, + 0xad, 0x00, 0x00, 0x00, 0xae, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, + 0x07, 0x00, 0x00, 0x00, 0xb0, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00, 0x00, + 0x31, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0xb1, 0x00, 0x00, 0x00, 0xb0, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0xb2, 0x00, 0x00, 0x00, 0xb1, 0x00, 0x00, 0x00, + 0xaf, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, + 0xb3, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, + 0x3e, 0x00, 0x03, 0x00, 0xb3, 0x00, 0x00, 0x00, 0xb2, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0xb4, 0x00, 0x00, 0x00, + 0x8a, 0x00, 0x00, 0x00, 0x8e, 0x00, 0x05, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0xb6, 0x00, 0x00, 0x00, 0xb4, 0x00, 0x00, 0x00, 0xb5, 0x00, 0x00, 0x00, + 0x3e, 0x00, 0x03, 0x00, 0xb7, 0x00, 0x00, 0x00, 0xb6, 0x00, 0x00, 0x00, + 0x39, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0xb8, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0xb7, 0x00, 0x00, 0x00, 0x88, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0xba, 0x00, 0x00, 0x00, 0xb8, 0x00, 0x00, 0x00, + 0xb9, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, + 0xbb, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0xbc, 0x00, 0x00, 0x00, + 0xbb, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0xbd, 0x00, 0x00, 0x00, 0xbc, 0x00, 0x00, 0x00, 0xba, 0x00, 0x00, 0x00, + 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0xbe, 0x00, 0x00, 0x00, + 0x7e, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, + 0xbe, 0x00, 0x00, 0x00, 0xbd, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0xbf, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00, 0x00, + 0x8e, 0x00, 0x05, 0x00, 0x0c, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, + 0xbf, 0x00, 0x00, 0x00, 0xb5, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, + 0xc1, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x39, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0xc2, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0xc1, 0x00, 0x00, 0x00, 0x88, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0xc3, 0x00, 0x00, 0x00, 0xc2, 0x00, 0x00, 0x00, 0xb9, 0x00, 0x00, 0x00, + 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0xc4, 0x00, 0x00, 0x00, + 0x7e, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0xc5, 0x00, 0x00, 0x00, 0xc4, 0x00, 0x00, 0x00, + 0x85, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0xc6, 0x00, 0x00, 0x00, + 0xc5, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, + 0x97, 0x00, 0x00, 0x00, 0xc7, 0x00, 0x00, 0x00, 0x94, 0x00, 0x00, 0x00, + 0x96, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0xc8, 0x00, 0x00, 0x00, 0xc7, 0x00, 0x00, 0x00, 0x88, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0xc9, 0x00, 0x00, 0x00, 0xc8, 0x00, 0x00, 0x00, + 0x9a, 0x00, 0x00, 0x00, 0x83, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0xca, 0x00, 0x00, 0x00, 0xc6, 0x00, 0x00, 0x00, 0xc9, 0x00, 0x00, 0x00, + 0x0c, 0x00, 0x06, 0x00, 0x06, 0x00, 0x00, 0x00, 0xcb, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0xca, 0x00, 0x00, 0x00, + 0x88, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, + 0xcb, 0x00, 0x00, 0x00, 0x9a, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0xcd, 0x00, 0x00, 0x00, 0xc3, 0x00, 0x00, 0x00, + 0xcc, 0x00, 0x00, 0x00, 0x83, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0xcf, 0x00, 0x00, 0x00, 0xcd, 0x00, 0x00, 0x00, 0xce, 0x00, 0x00, 0x00, + 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0xd0, 0x00, 0x00, 0x00, + 0x7e, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0xd1, 0x00, 0x00, 0x00, 0xd0, 0x00, 0x00, 0x00, + 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0xd2, 0x00, 0x00, 0x00, + 0xd1, 0x00, 0x00, 0x00, 0xcf, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, + 0x07, 0x00, 0x00, 0x00, 0xd3, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, + 0x31, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0xd3, 0x00, 0x00, 0x00, + 0xd2, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0xd6, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, + 0xd5, 0x00, 0x00, 0x00, 0xd6, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0xdb, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, + 0x51, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0xdc, 0x00, 0x00, 0x00, + 0xdb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0xdd, 0x00, 0x00, 0x00, 0xdb, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0xde, 0x00, 0x00, 0x00, 0xdb, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x50, 0x00, 0x07, 0x00, 0xd7, 0x00, 0x00, 0x00, 0xdf, 0x00, 0x00, 0x00, + 0xdc, 0x00, 0x00, 0x00, 0xdd, 0x00, 0x00, 0x00, 0xde, 0x00, 0x00, 0x00, + 0x41, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0xe0, 0x00, 0x00, 0x00, + 0xe1, 0x00, 0x00, 0x00, 0xda, 0x00, 0x00, 0x00, 0x96, 0x00, 0x00, 0x00, + 0x3e, 0x00, 0x03, 0x00, 0xe1, 0x00, 0x00, 0x00, 0xdf, 0x00, 0x00, 0x00, + 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, 0x00, 0x36, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x37, 0x00, 0x03, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x09, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x0b, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x06, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x16, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, + 0x15, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x18, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, + 0x0c, 0x00, 0x06, 0x00, 0x06, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, + 0xfe, 0x00, 0x02, 0x00, 0x19, 0x00, 0x00, 0x00, 0x38, 0x00, 0x01, 0x00, + 0x36, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x37, 0x00, 0x03, 0x00, + 0x0d, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, + 0x11, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, + 0x1c, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, + 0x0d, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x43, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x4a, 0x00, 0x00, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x4f, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x59, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x5e, 0x00, 0x00, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x66, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x6b, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, + 0x0f, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x06, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0x1e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x1d, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x1c, 0x00, 0x00, 0x00, + 0x1e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x06, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, + 0x1f, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, + 0x1f, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0x24, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, + 0x1f, 0x00, 0x00, 0x00, 0x8e, 0x00, 0x05, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0x28, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, + 0x50, 0x00, 0x06, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, + 0x25, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, + 0x83, 0x00, 0x05, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, + 0x29, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, + 0x2a, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x1f, 0x00, 0x00, 0x00, + 0x2b, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x2f, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, + 0x2f, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x35, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, + 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, + 0x30, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x39, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, + 0x38, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x3a, 0x00, 0x00, 0x00, 0x39, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00, + 0x3a, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x3c, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x00, 0x00, + 0x3e, 0x00, 0x03, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, + 0x2c, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x3d, 0x00, 0x00, 0x00, + 0x3e, 0x00, 0x00, 0x00, 0x39, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x3f, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, + 0x2c, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x42, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, + 0x3e, 0x00, 0x03, 0x00, 0x43, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, + 0x39, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x43, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, + 0x2e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x46, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x08, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x47, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x2e, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, + 0x46, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x48, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x49, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, + 0x34, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x4a, 0x00, 0x00, 0x00, + 0x49, 0x00, 0x00, 0x00, 0x39, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x4b, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x4a, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, + 0x2c, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x4e, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x4d, 0x00, 0x00, 0x00, + 0x3e, 0x00, 0x03, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x4e, 0x00, 0x00, 0x00, + 0x39, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x51, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, + 0x2e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x52, 0x00, 0x00, 0x00, 0x51, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x08, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x53, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x2e, 0x00, 0x00, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, + 0x52, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x54, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x55, 0x00, 0x00, 0x00, + 0x54, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x08, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x56, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, + 0x47, 0x00, 0x00, 0x00, 0x53, 0x00, 0x00, 0x00, 0x55, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x57, 0x00, 0x00, 0x00, + 0x2c, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x58, 0x00, 0x00, 0x00, 0x57, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00, + 0x3e, 0x00, 0x03, 0x00, 0x59, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, + 0x39, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x59, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x5b, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, + 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x5d, 0x00, 0x00, 0x00, + 0x5b, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, + 0x5e, 0x00, 0x00, 0x00, 0x5d, 0x00, 0x00, 0x00, 0x39, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x5e, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x60, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x61, 0x00, 0x00, 0x00, + 0x60, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x08, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x62, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, + 0x5a, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x61, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x63, 0x00, 0x00, 0x00, + 0x2c, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x65, 0x00, 0x00, 0x00, 0x63, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, + 0x3e, 0x00, 0x03, 0x00, 0x66, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x00, + 0x39, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x67, 0x00, 0x00, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, + 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x6a, 0x00, 0x00, 0x00, + 0x68, 0x00, 0x00, 0x00, 0x69, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, + 0x6b, 0x00, 0x00, 0x00, 0x6a, 0x00, 0x00, 0x00, 0x39, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x6b, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x6d, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x6e, 0x00, 0x00, 0x00, + 0x6d, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x08, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x6f, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, + 0x67, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, 0x6e, 0x00, 0x00, 0x00, + 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, + 0x1f, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x71, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, + 0x0c, 0x00, 0x08, 0x00, 0x06, 0x00, 0x00, 0x00, 0x72, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00, + 0x6f, 0x00, 0x00, 0x00, 0x71, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x73, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, + 0x38, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x74, 0x00, 0x00, 0x00, 0x73, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x08, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x75, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x2e, 0x00, 0x00, 0x00, 0x56, 0x00, 0x00, 0x00, 0x72, 0x00, 0x00, 0x00, + 0x74, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x02, 0x00, 0x75, 0x00, 0x00, 0x00, + 0x38, 0x00, 0x01, 0x00, 0x36, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x37, 0x00, 0x03, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, + 0xf8, 0x00, 0x02, 0x00, 0x14, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, + 0x38, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x79, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x7a, 0x00, 0x00, 0x00, 0x79, 0x00, 0x00, 0x00, + 0x26, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x06, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x7b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x7a, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x02, 0x00, 0x7b, 0x00, 0x00, 0x00, + 0x38, 0x00, 0x01, 0x00 +}; +unsigned int ribbon_vert_spv_len = 5116; diff --git a/gfx/drivers/vulkan_shaders/ribbon_simple.frag b/gfx/drivers/vulkan_shaders/ribbon_simple.frag new file mode 100644 index 0000000000..75f95020f7 --- /dev/null +++ b/gfx/drivers/vulkan_shaders/ribbon_simple.frag @@ -0,0 +1,8 @@ +#version 310 es +precision mediump float; + +layout(location = 0) out vec4 FragColor; +void main() +{ + FragColor = vec4(1.0, 1.0, 1.0, 0.05); +} diff --git a/gfx/drivers/vulkan_shaders/ribbon_simple.frag.inc b/gfx/drivers/vulkan_shaders/ribbon_simple.frag.inc new file mode 100644 index 0000000000..d1280b3427 --- /dev/null +++ b/gfx/drivers/vulkan_shaders/ribbon_simple.frag.inc @@ -0,0 +1,34 @@ +unsigned char ribbon_simple_frag_spv[] = { + 0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x08, 0x00, + 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x47, 0x4c, 0x53, 0x4c, 0x2e, 0x73, 0x74, 0x64, 0x2e, 0x34, 0x35, 0x30, + 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x06, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x10, 0x00, 0x03, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x36, 0x01, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x46, 0x72, 0x61, 0x67, 0x43, 0x6f, 0x6c, 0x6f, + 0x72, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, 0x09, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x09, 0x00, 0x00, 0x00, + 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x16, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x2b, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0xcd, 0xcc, 0x4c, 0x3d, + 0x2c, 0x00, 0x07, 0x00, 0x07, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x0b, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0xf8, 0x00, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00, + 0x38, 0x00, 0x01, 0x00 +}; +unsigned int ribbon_simple_frag_spv_len = 364; diff --git a/gfx/drivers/vulkan_shaders/ribbon_simple.vert b/gfx/drivers/vulkan_shaders/ribbon_simple.vert new file mode 100644 index 0000000000..5758c9f39e --- /dev/null +++ b/gfx/drivers/vulkan_shaders/ribbon_simple.vert @@ -0,0 +1,35 @@ +#version 310 es + +layout(location = 0) in vec3 VertexCoord; + +layout(std430, push_constant) uniform PushConstants +{ + float time; +} constants; + +float iqhash(float n) +{ + return fract(sin(n) * 43758.5453); +} + +float noise(vec3 x) +{ + vec3 p = floor(x); + vec3 f = fract(x); + f = f * f * (3.0 - 2.0 * f); + float n = p.x + p.y * 57.0 + 113.0 * p.z; + return mix(mix(mix(iqhash(n), iqhash(n + 1.0), f.x), + mix(iqhash(n + 57.0), iqhash(n + 58.0), f.x), f.y), + mix(mix(iqhash(n + 113.0), iqhash(n + 114.0), f.x), + mix(iqhash(n + 170.0), iqhash(n + 171.0), f.x), f.y), f.z); +} + +void main() +{ + vec3 v = vec3(VertexCoord.x, 0.0, VertexCoord.y); + vec3 v2 = v; + v2.x = v2.x + constants.time / 2.0; + v2.z = v.z * 3.0; + v.y = -cos((v.x + v.z / 3.0 + constants.time) * 2.0) / 10.0 - noise(v2.xyz) / 4.0; + gl_Position = vec4(v, 1.0); +} diff --git a/gfx/drivers/vulkan_shaders/ribbon_simple.vert.inc b/gfx/drivers/vulkan_shaders/ribbon_simple.vert.inc new file mode 100644 index 0000000000..22463dfb38 --- /dev/null +++ b/gfx/drivers/vulkan_shaders/ribbon_simple.vert.inc @@ -0,0 +1,342 @@ +unsigned char ribbon_simple_vert_spv[] = { + 0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x08, 0x00, + 0xb2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x47, 0x4c, 0x53, 0x4c, 0x2e, 0x73, 0x74, 0x64, 0x2e, 0x34, 0x35, 0x30, + 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, + 0x77, 0x00, 0x00, 0x00, 0xaa, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x36, 0x01, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, + 0x05, 0x00, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x69, 0x71, 0x68, 0x61, + 0x73, 0x68, 0x28, 0x66, 0x31, 0x3b, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x6e, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, + 0x10, 0x00, 0x00, 0x00, 0x6e, 0x6f, 0x69, 0x73, 0x65, 0x28, 0x76, 0x66, + 0x33, 0x3b, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x0f, 0x00, 0x00, 0x00, + 0x78, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x19, 0x00, 0x00, 0x00, + 0x70, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x1c, 0x00, 0x00, 0x00, + 0x66, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x29, 0x00, 0x00, 0x00, + 0x6e, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x3a, 0x00, 0x00, 0x00, + 0x70, 0x61, 0x72, 0x61, 0x6d, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, + 0x40, 0x00, 0x00, 0x00, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x00, 0x00, 0x00, + 0x05, 0x00, 0x04, 0x00, 0x47, 0x00, 0x00, 0x00, 0x70, 0x61, 0x72, 0x61, + 0x6d, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x4c, 0x00, 0x00, 0x00, + 0x70, 0x61, 0x72, 0x61, 0x6d, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, + 0x56, 0x00, 0x00, 0x00, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x00, 0x00, 0x00, + 0x05, 0x00, 0x04, 0x00, 0x5b, 0x00, 0x00, 0x00, 0x70, 0x61, 0x72, 0x61, + 0x6d, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x63, 0x00, 0x00, 0x00, + 0x70, 0x61, 0x72, 0x61, 0x6d, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, + 0x68, 0x00, 0x00, 0x00, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x00, 0x00, 0x00, + 0x05, 0x00, 0x03, 0x00, 0x75, 0x00, 0x00, 0x00, 0x76, 0x00, 0x00, 0x00, + 0x05, 0x00, 0x05, 0x00, 0x77, 0x00, 0x00, 0x00, 0x56, 0x65, 0x72, 0x74, + 0x65, 0x78, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x00, 0x05, 0x00, 0x03, 0x00, + 0x7f, 0x00, 0x00, 0x00, 0x76, 0x32, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, + 0x83, 0x00, 0x00, 0x00, 0x50, 0x75, 0x73, 0x68, 0x43, 0x6f, 0x6e, 0x73, + 0x74, 0x61, 0x6e, 0x74, 0x73, 0x00, 0x00, 0x00, 0x06, 0x00, 0x05, 0x00, + 0x83, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x74, 0x69, 0x6d, 0x65, + 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, 0x85, 0x00, 0x00, 0x00, + 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x73, 0x00, 0x00, 0x00, + 0x05, 0x00, 0x04, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x70, 0x61, 0x72, 0x61, + 0x6d, 0x00, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0xa8, 0x00, 0x00, 0x00, + 0x67, 0x6c, 0x5f, 0x50, 0x65, 0x72, 0x56, 0x65, 0x72, 0x74, 0x65, 0x78, + 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x06, 0x00, 0xa8, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, + 0x69, 0x6f, 0x6e, 0x00, 0x06, 0x00, 0x07, 0x00, 0xa8, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x69, 0x6e, 0x74, + 0x53, 0x69, 0x7a, 0x65, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, + 0xaa, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, + 0x77, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x48, 0x00, 0x05, 0x00, 0x83, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, + 0x83, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, + 0x85, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x48, 0x00, 0x05, 0x00, 0xa8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, + 0xa8, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, 0xa8, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x21, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x16, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x21, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0x21, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x8c, 0xee, 0x2a, 0x47, + 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x40, 0x40, 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x15, 0x00, 0x04, 0x00, + 0x2a, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x2b, 0x00, 0x04, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x2a, 0x00, 0x00, 0x00, + 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x42, + 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xe2, 0x42, 0x2b, 0x00, 0x04, 0x00, 0x2a, 0x00, 0x00, 0x00, + 0x35, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, + 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x4a, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x68, 0x42, 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x59, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe4, 0x42, 0x2b, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x61, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x43, + 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x2b, 0x43, 0x20, 0x00, 0x04, 0x00, 0x76, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, + 0x76, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x04, 0x00, 0x78, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x7b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x03, 0x00, + 0x83, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, + 0x84, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x83, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0x84, 0x00, 0x00, 0x00, 0x85, 0x00, 0x00, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x00, 0x86, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, + 0x86, 0x00, 0x00, 0x00, 0x87, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x04, 0x00, 0x88, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x9e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x41, 0x2b, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0xa3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x40, + 0x17, 0x00, 0x04, 0x00, 0xa7, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x04, 0x00, 0xa8, 0x00, 0x00, 0x00, + 0xa7, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, + 0xa9, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xa8, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0xa9, 0x00, 0x00, 0x00, 0xaa, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0xb0, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0xa7, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x75, 0x00, 0x00, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, + 0x7f, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, + 0x0d, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x41, 0x00, 0x05, 0x00, 0x78, 0x00, 0x00, 0x00, 0x79, 0x00, 0x00, 0x00, + 0x77, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x7a, 0x00, 0x00, 0x00, 0x79, 0x00, 0x00, 0x00, + 0x41, 0x00, 0x05, 0x00, 0x78, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, + 0x77, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x7d, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, + 0x50, 0x00, 0x06, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, + 0x7a, 0x00, 0x00, 0x00, 0x7b, 0x00, 0x00, 0x00, 0x7d, 0x00, 0x00, 0x00, + 0x3e, 0x00, 0x03, 0x00, 0x75, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, + 0x75, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x7f, 0x00, 0x00, 0x00, + 0x80, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x81, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x00, + 0x81, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x88, 0x00, 0x00, 0x00, + 0x89, 0x00, 0x00, 0x00, 0x85, 0x00, 0x00, 0x00, 0x87, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00, 0x00, + 0x89, 0x00, 0x00, 0x00, 0x88, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x8b, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, + 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x8c, 0x00, 0x00, 0x00, + 0x82, 0x00, 0x00, 0x00, 0x8b, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x8d, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, + 0x2b, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x8d, 0x00, 0x00, 0x00, + 0x8c, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x8e, 0x00, 0x00, 0x00, 0x75, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x8f, 0x00, 0x00, 0x00, + 0x8e, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x90, 0x00, 0x00, 0x00, 0x8f, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, + 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x91, 0x00, 0x00, 0x00, + 0x7f, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, + 0x91, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x92, 0x00, 0x00, 0x00, 0x75, 0x00, 0x00, 0x00, + 0x2b, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x93, 0x00, 0x00, 0x00, 0x92, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x94, 0x00, 0x00, 0x00, 0x75, 0x00, 0x00, 0x00, + 0x35, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x95, 0x00, 0x00, 0x00, 0x94, 0x00, 0x00, 0x00, 0x88, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x96, 0x00, 0x00, 0x00, 0x95, 0x00, 0x00, 0x00, + 0x22, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x97, 0x00, 0x00, 0x00, 0x93, 0x00, 0x00, 0x00, 0x96, 0x00, 0x00, 0x00, + 0x41, 0x00, 0x05, 0x00, 0x88, 0x00, 0x00, 0x00, 0x98, 0x00, 0x00, 0x00, + 0x85, 0x00, 0x00, 0x00, 0x87, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x99, 0x00, 0x00, 0x00, 0x98, 0x00, 0x00, 0x00, + 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x9a, 0x00, 0x00, 0x00, + 0x97, 0x00, 0x00, 0x00, 0x99, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x9b, 0x00, 0x00, 0x00, 0x9a, 0x00, 0x00, 0x00, + 0x23, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x06, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x9c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x9b, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x9d, 0x00, 0x00, 0x00, 0x9c, 0x00, 0x00, 0x00, 0x88, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x9f, 0x00, 0x00, 0x00, 0x9d, 0x00, 0x00, 0x00, + 0x9e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0xa1, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, + 0xa0, 0x00, 0x00, 0x00, 0xa1, 0x00, 0x00, 0x00, 0x39, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0xa2, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0xa0, 0x00, 0x00, 0x00, 0x88, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0xa4, 0x00, 0x00, 0x00, 0xa2, 0x00, 0x00, 0x00, 0xa3, 0x00, 0x00, 0x00, + 0x83, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0xa5, 0x00, 0x00, 0x00, + 0x9f, 0x00, 0x00, 0x00, 0xa4, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, + 0x07, 0x00, 0x00, 0x00, 0xa6, 0x00, 0x00, 0x00, 0x75, 0x00, 0x00, 0x00, + 0x2e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0xa6, 0x00, 0x00, 0x00, + 0xa5, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0xab, 0x00, 0x00, 0x00, 0x75, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0xac, 0x00, 0x00, 0x00, 0xab, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0xad, 0x00, 0x00, 0x00, 0xab, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x51, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0xae, 0x00, 0x00, 0x00, + 0xab, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x50, 0x00, 0x07, 0x00, + 0xa7, 0x00, 0x00, 0x00, 0xaf, 0x00, 0x00, 0x00, 0xac, 0x00, 0x00, 0x00, + 0xad, 0x00, 0x00, 0x00, 0xae, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, + 0x41, 0x00, 0x05, 0x00, 0xb0, 0x00, 0x00, 0x00, 0xb1, 0x00, 0x00, 0x00, + 0xaa, 0x00, 0x00, 0x00, 0x87, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, + 0xb1, 0x00, 0x00, 0x00, 0xaf, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00, + 0x38, 0x00, 0x01, 0x00, 0x36, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x37, 0x00, 0x03, 0x00, 0x07, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, + 0xf8, 0x00, 0x02, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, + 0x0c, 0x00, 0x06, 0x00, 0x06, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, + 0x85, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, + 0x13, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x06, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x02, 0x00, + 0x16, 0x00, 0x00, 0x00, 0x38, 0x00, 0x01, 0x00, 0x36, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x37, 0x00, 0x03, 0x00, 0x0d, 0x00, 0x00, 0x00, + 0x0f, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x11, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, + 0x1c, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x00, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x40, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x47, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x56, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x5b, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x63, 0x00, 0x00, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x68, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, + 0x0c, 0x00, 0x06, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, + 0x3e, 0x00, 0x03, 0x00, 0x19, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, + 0x0f, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x06, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0x1e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x1d, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x1c, 0x00, 0x00, 0x00, + 0x1e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0x1f, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, + 0x85, 0x00, 0x05, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, + 0x1f, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, + 0x8e, 0x00, 0x05, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, + 0x24, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x50, 0x00, 0x06, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, + 0x22, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x83, 0x00, 0x05, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, + 0x25, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0x28, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, + 0x3e, 0x00, 0x03, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, + 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, + 0x19, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x2d, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, + 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00, 0x00, + 0x19, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00, 0x00, + 0x85, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, + 0x30, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0x2d, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x36, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00, + 0x36, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x38, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00, + 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x39, 0x00, 0x00, 0x00, + 0x33, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, + 0x29, 0x00, 0x00, 0x00, 0x39, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, + 0x3e, 0x00, 0x03, 0x00, 0x3a, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x00, 0x00, + 0x39, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, + 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, + 0x40, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x39, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x40, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x42, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x43, 0x00, 0x00, 0x00, + 0x42, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x08, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x44, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, + 0x3c, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, 0x43, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x00, + 0x29, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x46, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, + 0x3e, 0x00, 0x03, 0x00, 0x47, 0x00, 0x00, 0x00, 0x46, 0x00, 0x00, 0x00, + 0x39, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x47, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x49, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, + 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x4b, 0x00, 0x00, 0x00, + 0x49, 0x00, 0x00, 0x00, 0x4a, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, + 0x4c, 0x00, 0x00, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x39, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x4d, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x4c, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x4e, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x4f, 0x00, 0x00, 0x00, + 0x4e, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x08, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x50, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, + 0x48, 0x00, 0x00, 0x00, 0x4d, 0x00, 0x00, 0x00, 0x4f, 0x00, 0x00, 0x00, + 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x51, 0x00, 0x00, 0x00, + 0x1c, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x52, 0x00, 0x00, 0x00, 0x51, 0x00, 0x00, 0x00, + 0x0c, 0x00, 0x08, 0x00, 0x06, 0x00, 0x00, 0x00, 0x53, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, + 0x50, 0x00, 0x00, 0x00, 0x52, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, + 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x55, 0x00, 0x00, 0x00, + 0x54, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, + 0x56, 0x00, 0x00, 0x00, 0x55, 0x00, 0x00, 0x00, 0x39, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x57, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x56, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x58, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, + 0x59, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x5b, 0x00, 0x00, 0x00, + 0x5a, 0x00, 0x00, 0x00, 0x39, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x5c, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x5b, 0x00, 0x00, 0x00, + 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x5d, 0x00, 0x00, 0x00, + 0x1c, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x5e, 0x00, 0x00, 0x00, 0x5d, 0x00, 0x00, 0x00, + 0x0c, 0x00, 0x08, 0x00, 0x06, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x57, 0x00, 0x00, 0x00, + 0x5c, 0x00, 0x00, 0x00, 0x5e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, + 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00, + 0x60, 0x00, 0x00, 0x00, 0x61, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, + 0x63, 0x00, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00, 0x39, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x63, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x65, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x67, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x00, + 0x66, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x68, 0x00, 0x00, 0x00, + 0x67, 0x00, 0x00, 0x00, 0x39, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x69, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, + 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x6a, 0x00, 0x00, 0x00, + 0x1c, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x6b, 0x00, 0x00, 0x00, 0x6a, 0x00, 0x00, 0x00, + 0x0c, 0x00, 0x08, 0x00, 0x06, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, + 0x69, 0x00, 0x00, 0x00, 0x6b, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, + 0x2e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x6e, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x08, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x6f, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x2e, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, + 0x6e, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x70, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x71, 0x00, 0x00, 0x00, + 0x70, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x08, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x72, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, + 0x53, 0x00, 0x00, 0x00, 0x6f, 0x00, 0x00, 0x00, 0x71, 0x00, 0x00, 0x00, + 0xfe, 0x00, 0x02, 0x00, 0x72, 0x00, 0x00, 0x00, 0x38, 0x00, 0x01, 0x00 +}; +unsigned int ribbon_simple_vert_spv_len = 4068; From 464a4add66fd85b5c403de1fa6e0b6779fa2b723 Mon Sep 17 00:00:00 2001 From: Hans-Kristian Arntzen Date: Sun, 8 May 2016 11:11:28 +0200 Subject: [PATCH 257/498] XMB ribbon works in Vulkan. --- gfx/common/vulkan_common.c | 82 +- gfx/common/vulkan_common.h | 6 +- gfx/drivers/vulkan.c | 64 +- gfx/drivers/vulkan_shaders/ribbon.frag | 4 +- gfx/drivers/vulkan_shaders/ribbon.frag.inc | 48 +- gfx/drivers/vulkan_shaders/ribbon.vert | 3 +- gfx/drivers/vulkan_shaders/ribbon.vert.inc | 749 +++++++++--------- gfx/drivers/vulkan_shaders/ribbon_simple.vert | 4 +- .../vulkan_shaders/ribbon_simple.vert.inc | 581 +++++++------- gfx/drivers_font/vulkan_raster_font.c | 1 + menu/drivers/materialui.c | 3 + menu/drivers/xmb.c | 8 +- menu/drivers/zarch.c | 1 + menu/drivers_display/menu_display_vulkan.c | 74 +- menu/menu_display.h | 1 + 15 files changed, 861 insertions(+), 768 deletions(-) diff --git a/gfx/common/vulkan_common.c b/gfx/common/vulkan_common.c index dcddc15823..4bd77e93c9 100644 --- a/gfx/common/vulkan_common.c +++ b/gfx/common/vulkan_common.c @@ -523,14 +523,9 @@ static void vulkan_write_quad_descriptors( const struct vk_texture *texture, VkSampler sampler) { - VkDescriptorImageInfo image_info; VkDescriptorBufferInfo buffer_info; VkWriteDescriptorSet write = { VK_STRUCTURE_TYPE_WRITE_DESCRIPTOR_SET }; - image_info.sampler = sampler; - image_info.imageView = texture->view; - image_info.imageLayout = texture->layout; - buffer_info.buffer = buffer; buffer_info.offset = offset; buffer_info.range = range; @@ -542,12 +537,21 @@ static void vulkan_write_quad_descriptors( write.pBufferInfo = &buffer_info; VKFUNC(vkUpdateDescriptorSets)(device, 1, &write, 0, NULL); - write.dstSet = set; - write.dstBinding = 1; - write.descriptorCount = 1; - write.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; - write.pImageInfo = &image_info; - VKFUNC(vkUpdateDescriptorSets)(device, 1, &write, 0, NULL); + if (texture) + { + VkDescriptorImageInfo image_info; + + image_info.sampler = sampler; + image_info.imageView = texture->view; + image_info.imageLayout = texture->layout; + + write.dstSet = set; + write.dstBinding = 1; + write.descriptorCount = 1; + write.descriptorType = VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER; + write.pImageInfo = &image_info; + VKFUNC(vkUpdateDescriptorSets)(device, 1, &write, 0, NULL); + } } void vulkan_transition_texture(vk_t *vk, struct vk_texture *texture) @@ -606,7 +610,8 @@ static void vulkan_check_dynamic_state( void vulkan_draw_triangles(vk_t *vk, const struct vk_draw_triangles *call) { - vulkan_transition_texture(vk, call->texture); + if (call->texture) + vulkan_transition_texture(vk, call->texture); if (call->pipeline != vk->tracker.pipeline) { @@ -624,37 +629,34 @@ void vulkan_draw_triangles(vk_t *vk, const struct vk_draw_triangles *call) { VkDescriptorSet set; - if (memcmp(call->mvp, &vk->tracker.mvp, sizeof(*call->mvp)) - || (call->texture->view != vk->tracker.view) - || (call->sampler != vk->tracker.sampler)) - { - /* Upload UBO */ - struct vk_buffer_range range; - if (!vulkan_buffer_chain_alloc(vk->context, &vk->chain->ubo, - sizeof(*call->mvp), &range)) - return; - memcpy(range.data, call->mvp, sizeof(*call->mvp)); + /* Upload UBO */ + struct vk_buffer_range range; + if (!vulkan_buffer_chain_alloc(vk->context, &vk->chain->ubo, + call->uniform_size, &range)) + return; - set = vulkan_descriptor_manager_alloc( - vk->context->device, - &vk->chain->descriptor_manager); - vulkan_write_quad_descriptors( - vk->context->device, - set, - range.buffer, - range.offset, - sizeof(*call->mvp), - call->texture, - call->sampler); + memcpy(range.data, call->uniform, call->uniform_size); - VKFUNC(vkCmdBindDescriptorSets)(vk->cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, - vk->pipelines.layout, 0, - 1, &set, 0, NULL); + set = vulkan_descriptor_manager_alloc( + vk->context->device, + &vk->chain->descriptor_manager); - vk->tracker.view = call->texture->view; - vk->tracker.sampler = call->sampler; - vk->tracker.mvp = *call->mvp; - } + vulkan_write_quad_descriptors( + vk->context->device, + set, + range.buffer, + range.offset, + call->uniform_size, + call->texture, + call->sampler); + + VKFUNC(vkCmdBindDescriptorSets)(vk->cmd, VK_PIPELINE_BIND_POINT_GRAPHICS, + vk->pipelines.layout, 0, + 1, &set, 0, NULL); + + vk->tracker.view = VK_NULL_HANDLE; + vk->tracker.sampler = VK_NULL_HANDLE; + memset(&vk->tracker.mvp, 0, sizeof(vk->tracker.mvp)); } /* VBO is already uploaded. */ diff --git a/gfx/common/vulkan_common.h b/gfx/common/vulkan_common.h index 6a46bb84d1..02961f8e83 100644 --- a/gfx/common/vulkan_common.h +++ b/gfx/common/vulkan_common.h @@ -249,7 +249,9 @@ struct vk_draw_triangles VkPipeline pipeline; struct vk_texture *texture; VkSampler sampler; - const math_matrix_4x4 *mvp; + + const void *uniform; + size_t uniform_size; const struct vk_buffer_range *vbo; unsigned vertices; @@ -312,7 +314,7 @@ typedef struct vk struct { bool blend; - VkPipeline pipelines[4]; + VkPipeline pipelines[8]; struct vk_texture blank_texture; } display; diff --git a/gfx/drivers/vulkan.c b/gfx/drivers/vulkan.c index f330bd1c7b..e2bb1403d3 100644 --- a/gfx/drivers/vulkan.c +++ b/gfx/drivers/vulkan.c @@ -17,6 +17,10 @@ #include "vulkan_shaders/alpha_blend.vert.inc" #include "vulkan_shaders/alpha_blend.frag.inc" #include "vulkan_shaders/font.frag.inc" +#include "vulkan_shaders/ribbon.vert.inc" +#include "vulkan_shaders/ribbon.frag.inc" +#include "vulkan_shaders/ribbon_simple.vert.inc" +#include "vulkan_shaders/ribbon_simple.frag.inc" #include #include @@ -172,7 +176,7 @@ static void vulkan_init_pipeline_layout( bindings[0].binding = 0; bindings[0].descriptorType = VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER; bindings[0].descriptorCount = 1; - bindings[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT; + bindings[0].stageFlags = VK_SHADER_STAGE_VERTEX_BIT | VK_SHADER_STAGE_FRAGMENT_BIT; bindings[0].pImmutableSamplers = NULL; bindings[1].binding = 1; @@ -360,6 +364,49 @@ static void vulkan_init_pipelines( VKFUNC(vkDestroyShaderModule)(vk->context->device, shader_stages[0].module, NULL); VKFUNC(vkDestroyShaderModule)(vk->context->device, shader_stages[1].module, NULL); + + /* Other menu pipelines. */ + for (i = 0; i < 4; i++) + { + if (i & 2) + { + module_info.codeSize = ribbon_simple_vert_spv_len; + module_info.pCode = (const uint32_t*)ribbon_simple_vert_spv; + } + else + { + module_info.codeSize = ribbon_vert_spv_len; + module_info.pCode = (const uint32_t*)ribbon_vert_spv; + } + + shader_stages[0].stage = VK_SHADER_STAGE_VERTEX_BIT; + shader_stages[0].pName = "main"; + VKFUNC(vkCreateShaderModule)(vk->context->device, + &module_info, NULL, &shader_stages[0].module); + + if (i & 2) + { + module_info.codeSize = ribbon_simple_frag_spv_len; + module_info.pCode = (const uint32_t*)ribbon_simple_frag_spv; + } + else + { + module_info.codeSize = ribbon_frag_spv_len; + module_info.pCode = (const uint32_t*)ribbon_frag_spv; + } + + shader_stages[1].stage = VK_SHADER_STAGE_FRAGMENT_BIT; + shader_stages[1].pName = "main"; + VKFUNC(vkCreateShaderModule)(vk->context->device, + &module_info, NULL, &shader_stages[1].module); + + input_assembly.topology = i & 1 ? + VK_PRIMITIVE_TOPOLOGY_TRIANGLE_STRIP : + VK_PRIMITIVE_TOPOLOGY_TRIANGLE_LIST; + + VKFUNC(vkCreateGraphicsPipelines)(vk->context->device, vk->pipelines.cache, + 1, &pipe, NULL, &vk->display.pipelines[4 + i]); + } } static void vulkan_init_command_buffers(vk_t *vk) @@ -550,7 +597,7 @@ static void vulkan_deinit_pipelines(vk_t *vk) VKFUNC(vkDestroyPipeline)(vk->context->device, vk->pipelines.font, NULL); - for (i = 0; i < 4; i++) + for (i = 0; i < 8; i++) VKFUNC(vkDestroyPipeline)(vk->context->device, vk->display.pipelines[i], NULL); } @@ -2146,12 +2193,13 @@ static void vulkan_render_overlay(vk_t *vk) 4 * sizeof(struct vk_vertex)); memset(&call, 0, sizeof(call)); - call.pipeline = vk->display.pipelines[3]; /* Strip with blend */ - call.texture = &vk->overlay.images[i]; - call.sampler = vk->samplers.linear; - call.mvp = &vk->mvp; - call.vbo = ⦥ - call.vertices = 4; + call.pipeline = vk->display.pipelines[3]; /* Strip with blend */ + call.texture = &vk->overlay.images[i]; + call.sampler = vk->samplers.linear; + call.uniform = &vk->mvp; + call.uniform_size = sizeof(vk->mvp); + call.vbo = ⦥ + call.vertices = 4; vulkan_draw_triangles(vk, &call); } diff --git a/gfx/drivers/vulkan_shaders/ribbon.frag b/gfx/drivers/vulkan_shaders/ribbon.frag index 260730f10b..1ae01f2528 100644 --- a/gfx/drivers/vulkan_shaders/ribbon.frag +++ b/gfx/drivers/vulkan_shaders/ribbon.frag @@ -1,7 +1,7 @@ #version 310 es -precision mediump float; +precision highp float; -layout(std430, push_constant) uniform PushConstants +layout(std140, set = 0, binding = 0) uniform UBO { float time; } constants; diff --git a/gfx/drivers/vulkan_shaders/ribbon.frag.inc b/gfx/drivers/vulkan_shaders/ribbon.frag.inc index f93eeb2841..a229f4a047 100644 --- a/gfx/drivers/vulkan_shaders/ribbon.frag.inc +++ b/gfx/drivers/vulkan_shaders/ribbon.frag.inc @@ -17,44 +17,18 @@ unsigned char ribbon_frag_spv[] = { 0x61, 0x6c, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x17, 0x00, 0x00, 0x00, 0x63, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, 0x27, 0x00, 0x00, 0x00, 0x46, 0x72, 0x61, 0x67, 0x43, 0x6f, 0x6c, 0x6f, 0x72, 0x00, 0x00, 0x00, - 0x05, 0x00, 0x06, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x50, 0x75, 0x73, 0x68, - 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x73, 0x00, 0x00, 0x00, + 0x05, 0x00, 0x03, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x55, 0x42, 0x4f, 0x00, 0x06, 0x00, 0x05, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x74, 0x69, 0x6d, 0x65, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, - 0x73, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, 0x09, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, 0x0b, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x0b, 0x00, 0x00, 0x00, - 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, - 0x0c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, - 0x0d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, - 0x0e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, - 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, - 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, - 0x11, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, - 0x12, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, - 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, - 0x14, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, - 0x15, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, - 0x17, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, - 0x19, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, - 0x1c, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, - 0x1d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, - 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, - 0x1f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, - 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, - 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, - 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, - 0x24, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, - 0x27, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, + 0x73, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x0b, 0x00, 0x00, 0x00, + 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x27, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x03, 0x00, 0x28, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x03, 0x00, 0x29, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x48, 0x00, 0x04, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x2a, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x03, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x04, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, + 0x48, 0x00, 0x05, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, + 0x2a, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, + 0x2c, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x47, 0x00, 0x04, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x16, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, @@ -76,9 +50,9 @@ unsigned char ribbon_frag_spv[] = { 0x25, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x26, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x03, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, - 0x2b, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, + 0x2b, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, - 0x09, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, @@ -124,4 +98,4 @@ unsigned char ribbon_frag_spv[] = { 0x28, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x27, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, 0x00 }; -unsigned int ribbon_frag_spv_len = 1488; +unsigned int ribbon_frag_spv_len = 1176; diff --git a/gfx/drivers/vulkan_shaders/ribbon.vert b/gfx/drivers/vulkan_shaders/ribbon.vert index 9414c13d31..eac9d2d121 100644 --- a/gfx/drivers/vulkan_shaders/ribbon.vert +++ b/gfx/drivers/vulkan_shaders/ribbon.vert @@ -3,7 +3,7 @@ layout(location = 0) in vec3 VertexCoord; layout(location = 0) out vec3 vEC; -layout(std430, push_constant) uniform PushConstants +layout(std140, set = 0, binding = 0) uniform UBO { float time; } constants; @@ -47,6 +47,7 @@ void main() v.z += noise(v3 * 7.0) / 15.0; v.y += noise(v3 * 7.0) / 15.0 + cos(v.x * 2.0 - constants.time / 5.0) / 5.0 - 0.3; + v.y = -v.y; vEC = v; gl_Position = vec4(v, 1.0); } diff --git a/gfx/drivers/vulkan_shaders/ribbon.vert.inc b/gfx/drivers/vulkan_shaders/ribbon.vert.inc index 39f62ae249..7531c5cf20 100644 --- a/gfx/drivers/vulkan_shaders/ribbon.vert.inc +++ b/gfx/drivers/vulkan_shaders/ribbon.vert.inc @@ -1,12 +1,12 @@ unsigned char ribbon_vert_spv[] = { 0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x08, 0x00, - 0xe2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, + 0xe6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x4c, 0x53, 0x4c, 0x2e, 0x73, 0x74, 0x64, 0x2e, 0x34, 0x35, 0x30, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, - 0x80, 0x00, 0x00, 0x00, 0xd5, 0x00, 0x00, 0x00, 0xda, 0x00, 0x00, 0x00, + 0x80, 0x00, 0x00, 0x00, 0xd9, 0x00, 0x00, 0x00, 0xde, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, 0x36, 0x01, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x00, @@ -37,394 +37,401 @@ unsigned char ribbon_vert_spv[] = { 0x05, 0x00, 0x03, 0x00, 0x88, 0x00, 0x00, 0x00, 0x76, 0x32, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x8a, 0x00, 0x00, 0x00, 0x76, 0x33, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x8c, 0x00, 0x00, 0x00, 0x70, 0x61, 0x72, 0x61, - 0x6d, 0x00, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0x92, 0x00, 0x00, 0x00, - 0x50, 0x75, 0x73, 0x68, 0x43, 0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, - 0x73, 0x00, 0x00, 0x00, 0x06, 0x00, 0x05, 0x00, 0x92, 0x00, 0x00, 0x00, + 0x6d, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0x92, 0x00, 0x00, 0x00, + 0x55, 0x42, 0x4f, 0x00, 0x06, 0x00, 0x05, 0x00, 0x92, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x74, 0x69, 0x6d, 0x65, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, 0x94, 0x00, 0x00, 0x00, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x73, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0xb7, 0x00, 0x00, 0x00, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0xc1, 0x00, 0x00, 0x00, 0x70, 0x61, 0x72, 0x61, - 0x6d, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0xd5, 0x00, 0x00, 0x00, - 0x76, 0x45, 0x43, 0x00, 0x05, 0x00, 0x06, 0x00, 0xd8, 0x00, 0x00, 0x00, + 0x6d, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0xd9, 0x00, 0x00, 0x00, + 0x76, 0x45, 0x43, 0x00, 0x05, 0x00, 0x06, 0x00, 0xdc, 0x00, 0x00, 0x00, 0x67, 0x6c, 0x5f, 0x50, 0x65, 0x72, 0x56, 0x65, 0x72, 0x74, 0x65, 0x78, - 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x06, 0x00, 0xd8, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x06, 0x00, 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, - 0x69, 0x6f, 0x6e, 0x00, 0x06, 0x00, 0x07, 0x00, 0xd8, 0x00, 0x00, 0x00, + 0x69, 0x6f, 0x6e, 0x00, 0x06, 0x00, 0x07, 0x00, 0xdc, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x53, 0x69, 0x7a, 0x65, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, - 0xda, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, + 0xde, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x80, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x92, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, 0x92, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x94, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x04, 0x00, 0xd5, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0xd8, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x48, 0x00, 0x05, 0x00, 0xd8, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x0b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, - 0xd8, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x16, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x20, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x21, 0x00, 0x04, 0x00, - 0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x17, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x03, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x21, 0x00, 0x04, 0x00, - 0x0e, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, - 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, - 0x8c, 0xee, 0x2a, 0x47, 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x25, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x2b, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, - 0x15, 0x00, 0x04, 0x00, 0x2d, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x2d, 0x00, 0x00, 0x00, - 0x2e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, - 0x2d, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x64, 0x42, 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x37, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe2, 0x42, 0x2b, 0x00, 0x04, 0x00, - 0x2d, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x80, 0x3f, 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x4d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0x42, 0x2b, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe4, 0x42, - 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x2a, 0x43, 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x69, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2b, 0x43, 0x20, 0x00, 0x04, 0x00, - 0x7f, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, - 0x3b, 0x00, 0x04, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x81, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x8f, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xc0, 0x40, 0x1e, 0x00, 0x03, 0x00, 0x92, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x93, 0x00, 0x00, 0x00, - 0x09, 0x00, 0x00, 0x00, 0x92, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x93, 0x00, 0x00, 0x00, 0x94, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, - 0x15, 0x00, 0x04, 0x00, 0x95, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x95, 0x00, 0x00, 0x00, - 0x96, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, - 0x97, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x9a, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xa0, 0x40, 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0xa6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x41, 0x2b, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0xae, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc8, 0x42, - 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0xb5, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xe0, 0x40, 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0xb9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x41, 0x2b, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0xce, 0x00, 0x00, 0x00, 0x9a, 0x99, 0x99, 0x3e, - 0x20, 0x00, 0x04, 0x00, 0xd4, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, - 0x0c, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0xd4, 0x00, 0x00, 0x00, - 0xd5, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, - 0xd7, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, - 0x1e, 0x00, 0x04, 0x00, 0xd8, 0x00, 0x00, 0x00, 0xd7, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0xd9, 0x00, 0x00, 0x00, - 0x03, 0x00, 0x00, 0x00, 0xd8, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0xd9, 0x00, 0x00, 0x00, 0xda, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, - 0x20, 0x00, 0x04, 0x00, 0xe0, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, - 0xd7, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, - 0xf8, 0x00, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x0d, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x3b, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00, + 0x47, 0x00, 0x04, 0x00, 0x94, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0xd9, 0x00, 0x00, 0x00, + 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, + 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0xdc, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x47, 0x00, 0x03, 0x00, 0xdc, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x13, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x16, 0x00, 0x03, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x21, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, + 0x0d, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0x21, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x0d, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x17, 0x00, 0x00, 0x00, 0x8c, 0xee, 0x2a, 0x47, 0x2b, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, + 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x40, 0x15, 0x00, 0x04, 0x00, 0x2d, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, + 0x2d, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x2b, 0x00, 0x04, 0x00, 0x2d, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x42, 0x2b, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe2, 0x42, + 0x2b, 0x00, 0x04, 0x00, 0x2d, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x41, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, 0x2b, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x4d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0x42, + 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xe4, 0x42, 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x64, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x43, 0x2b, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x69, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2b, 0x43, + 0x20, 0x00, 0x04, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x7f, 0x00, 0x00, 0x00, + 0x80, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, + 0x81, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x8f, 0x00, 0x00, 0x00, 0x00, 0x00, 0xc0, 0x40, 0x1e, 0x00, 0x03, 0x00, + 0x92, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, + 0x93, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x92, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0x93, 0x00, 0x00, 0x00, 0x94, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x00, 0x95, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, + 0x95, 0x00, 0x00, 0x00, 0x96, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x04, 0x00, 0x97, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x9a, 0x00, 0x00, 0x00, 0x00, 0x00, 0xa0, 0x40, 0x2b, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0xa6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x41, + 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0xae, 0x00, 0x00, 0x00, + 0x00, 0x00, 0xc8, 0x42, 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0xb5, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x40, 0x2b, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0xb9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x41, + 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0xce, 0x00, 0x00, 0x00, + 0x9a, 0x99, 0x99, 0x3e, 0x20, 0x00, 0x04, 0x00, 0xd8, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, + 0xd8, 0x00, 0x00, 0x00, 0xd9, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x17, 0x00, 0x04, 0x00, 0xdb, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x04, 0x00, 0xdc, 0x00, 0x00, 0x00, + 0xdb, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, + 0xdd, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xdc, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0xdd, 0x00, 0x00, 0x00, 0xde, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0xe4, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0xdb, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, - 0x8a, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x0d, 0x00, 0x00, 0x00, 0x8c, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x3b, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, 0xb7, 0x00, 0x00, 0x00, + 0x88, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, + 0x0d, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x8c, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, - 0xc1, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, - 0x81, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x2e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x83, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, - 0x81, 0x00, 0x00, 0x00, 0x85, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x31, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x86, 0x00, 0x00, 0x00, 0x85, 0x00, 0x00, 0x00, 0x50, 0x00, 0x06, 0x00, - 0x0c, 0x00, 0x00, 0x00, 0x87, 0x00, 0x00, 0x00, 0x83, 0x00, 0x00, 0x00, - 0x84, 0x00, 0x00, 0x00, 0x86, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, - 0x7e, 0x00, 0x00, 0x00, 0x87, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x0c, 0x00, 0x00, 0x00, 0x89, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x03, 0x00, 0x88, 0x00, 0x00, 0x00, 0x89, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x8b, 0x00, 0x00, 0x00, - 0x7e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x8a, 0x00, 0x00, 0x00, - 0x8b, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, - 0x8d, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, - 0x8c, 0x00, 0x00, 0x00, 0x8d, 0x00, 0x00, 0x00, 0x39, 0x00, 0x05, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x8e, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, - 0x8c, 0x00, 0x00, 0x00, 0x88, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x90, 0x00, 0x00, 0x00, 0x8e, 0x00, 0x00, 0x00, 0x8f, 0x00, 0x00, 0x00, - 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x91, 0x00, 0x00, 0x00, - 0x7e, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, - 0x91, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, - 0x97, 0x00, 0x00, 0x00, 0x98, 0x00, 0x00, 0x00, 0x94, 0x00, 0x00, 0x00, - 0x96, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x99, 0x00, 0x00, 0x00, 0x98, 0x00, 0x00, 0x00, 0x88, 0x00, 0x05, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x9b, 0x00, 0x00, 0x00, 0x99, 0x00, 0x00, 0x00, - 0x9a, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x9c, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x9d, 0x00, 0x00, 0x00, - 0x9c, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x9e, 0x00, 0x00, 0x00, 0x9d, 0x00, 0x00, 0x00, 0x9b, 0x00, 0x00, 0x00, - 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x9f, 0x00, 0x00, 0x00, - 0x8a, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, - 0x9f, 0x00, 0x00, 0x00, 0x9e, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, - 0x07, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00, 0x00, - 0x2e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0xa1, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x88, 0x00, 0x05, 0x00, - 0x06, 0x00, 0x00, 0x00, 0xa2, 0x00, 0x00, 0x00, 0xa1, 0x00, 0x00, 0x00, - 0x26, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, - 0xa3, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x03, 0x00, 0xa3, 0x00, 0x00, 0x00, 0xa2, 0x00, 0x00, 0x00, - 0x41, 0x00, 0x05, 0x00, 0x97, 0x00, 0x00, 0x00, 0xa4, 0x00, 0x00, 0x00, + 0xb7, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, + 0x0d, 0x00, 0x00, 0x00, 0xc1, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x41, 0x00, 0x05, 0x00, 0x81, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x00, + 0x80, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x83, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x00, + 0x41, 0x00, 0x05, 0x00, 0x81, 0x00, 0x00, 0x00, 0x85, 0x00, 0x00, 0x00, + 0x80, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x86, 0x00, 0x00, 0x00, 0x85, 0x00, 0x00, 0x00, + 0x50, 0x00, 0x06, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x87, 0x00, 0x00, 0x00, + 0x83, 0x00, 0x00, 0x00, 0x84, 0x00, 0x00, 0x00, 0x86, 0x00, 0x00, 0x00, + 0x3e, 0x00, 0x03, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x87, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x89, 0x00, 0x00, 0x00, + 0x7e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x88, 0x00, 0x00, 0x00, + 0x89, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0x8b, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, + 0x8a, 0x00, 0x00, 0x00, 0x8b, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0x8d, 0x00, 0x00, 0x00, 0x88, 0x00, 0x00, 0x00, + 0x3e, 0x00, 0x03, 0x00, 0x8c, 0x00, 0x00, 0x00, 0x8d, 0x00, 0x00, 0x00, + 0x39, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x8e, 0x00, 0x00, 0x00, + 0x13, 0x00, 0x00, 0x00, 0x8c, 0x00, 0x00, 0x00, 0x88, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0x8e, 0x00, 0x00, 0x00, + 0x8f, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x91, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, + 0x3e, 0x00, 0x03, 0x00, 0x91, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, + 0x41, 0x00, 0x05, 0x00, 0x97, 0x00, 0x00, 0x00, 0x98, 0x00, 0x00, 0x00, 0x94, 0x00, 0x00, 0x00, 0x96, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0xa5, 0x00, 0x00, 0x00, 0xa4, 0x00, 0x00, 0x00, - 0x88, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0xa7, 0x00, 0x00, 0x00, - 0xa5, 0x00, 0x00, 0x00, 0xa6, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, - 0x07, 0x00, 0x00, 0x00, 0xa8, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x99, 0x00, 0x00, 0x00, 0x98, 0x00, 0x00, 0x00, + 0x88, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x9b, 0x00, 0x00, 0x00, + 0x99, 0x00, 0x00, 0x00, 0x9a, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x9c, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00, 0x00, + 0x2e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x9d, 0x00, 0x00, 0x00, 0x9c, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x9e, 0x00, 0x00, 0x00, 0x9d, 0x00, 0x00, 0x00, + 0x9b, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x9f, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, + 0x3e, 0x00, 0x03, 0x00, 0x9f, 0x00, 0x00, 0x00, 0x9e, 0x00, 0x00, 0x00, + 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, + 0x8a, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0xa1, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, + 0x88, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0xa2, 0x00, 0x00, 0x00, + 0xa1, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, + 0x07, 0x00, 0x00, 0x00, 0xa3, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00, 0x00, + 0x2e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0xa3, 0x00, 0x00, 0x00, + 0xa2, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x97, 0x00, 0x00, 0x00, + 0xa4, 0x00, 0x00, 0x00, 0x94, 0x00, 0x00, 0x00, 0x96, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0xa5, 0x00, 0x00, 0x00, + 0xa4, 0x00, 0x00, 0x00, 0x88, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0xa7, 0x00, 0x00, 0x00, 0xa5, 0x00, 0x00, 0x00, 0xa6, 0x00, 0x00, 0x00, + 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0xa8, 0x00, 0x00, 0x00, + 0x8a, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0xa9, 0x00, 0x00, 0x00, 0xa8, 0x00, 0x00, 0x00, + 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0xaa, 0x00, 0x00, 0x00, + 0xa9, 0x00, 0x00, 0x00, 0xa7, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, + 0x07, 0x00, 0x00, 0x00, 0xab, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00, 0x00, + 0x38, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0xab, 0x00, 0x00, 0x00, + 0xaa, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x97, 0x00, 0x00, 0x00, + 0xac, 0x00, 0x00, 0x00, 0x94, 0x00, 0x00, 0x00, 0x96, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0xad, 0x00, 0x00, 0x00, + 0xac, 0x00, 0x00, 0x00, 0x88, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0xaf, 0x00, 0x00, 0x00, 0xad, 0x00, 0x00, 0x00, 0xae, 0x00, 0x00, 0x00, + 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0xb0, 0x00, 0x00, 0x00, + 0x8a, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0xb1, 0x00, 0x00, 0x00, 0xb0, 0x00, 0x00, 0x00, + 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0xb2, 0x00, 0x00, 0x00, + 0xb1, 0x00, 0x00, 0x00, 0xaf, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, + 0x07, 0x00, 0x00, 0x00, 0xb3, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00, 0x00, + 0x31, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0xb3, 0x00, 0x00, 0x00, + 0xb2, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0xb4, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00, 0x00, 0x8e, 0x00, 0x05, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0xb6, 0x00, 0x00, 0x00, 0xb4, 0x00, 0x00, 0x00, + 0xb5, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0xb7, 0x00, 0x00, 0x00, + 0xb6, 0x00, 0x00, 0x00, 0x39, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0xb8, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0xb7, 0x00, 0x00, 0x00, + 0x88, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0xba, 0x00, 0x00, 0x00, + 0xb8, 0x00, 0x00, 0x00, 0xb9, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, + 0x07, 0x00, 0x00, 0x00, 0xbb, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0xa9, 0x00, 0x00, 0x00, 0xa8, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, - 0x06, 0x00, 0x00, 0x00, 0xaa, 0x00, 0x00, 0x00, 0xa9, 0x00, 0x00, 0x00, - 0xa7, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, - 0xab, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x03, 0x00, 0xab, 0x00, 0x00, 0x00, 0xaa, 0x00, 0x00, 0x00, - 0x41, 0x00, 0x05, 0x00, 0x97, 0x00, 0x00, 0x00, 0xac, 0x00, 0x00, 0x00, - 0x94, 0x00, 0x00, 0x00, 0x96, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0xad, 0x00, 0x00, 0x00, 0xac, 0x00, 0x00, 0x00, - 0x88, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0xaf, 0x00, 0x00, 0x00, - 0xad, 0x00, 0x00, 0x00, 0xae, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, - 0x07, 0x00, 0x00, 0x00, 0xb0, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00, 0x00, - 0x31, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0xb1, 0x00, 0x00, 0x00, 0xb0, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, - 0x06, 0x00, 0x00, 0x00, 0xb2, 0x00, 0x00, 0x00, 0xb1, 0x00, 0x00, 0x00, - 0xaf, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, - 0xb3, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x03, 0x00, 0xb3, 0x00, 0x00, 0x00, 0xb2, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0xb4, 0x00, 0x00, 0x00, + 0xbc, 0x00, 0x00, 0x00, 0xbb, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0xbd, 0x00, 0x00, 0x00, 0xbc, 0x00, 0x00, 0x00, + 0xba, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, + 0xbe, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, + 0x3e, 0x00, 0x03, 0x00, 0xbe, 0x00, 0x00, 0x00, 0xbd, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0xbf, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00, 0x00, 0x8e, 0x00, 0x05, 0x00, 0x0c, 0x00, 0x00, 0x00, - 0xb6, 0x00, 0x00, 0x00, 0xb4, 0x00, 0x00, 0x00, 0xb5, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x03, 0x00, 0xb7, 0x00, 0x00, 0x00, 0xb6, 0x00, 0x00, 0x00, - 0x39, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0xb8, 0x00, 0x00, 0x00, - 0x10, 0x00, 0x00, 0x00, 0xb7, 0x00, 0x00, 0x00, 0x88, 0x00, 0x05, 0x00, - 0x06, 0x00, 0x00, 0x00, 0xba, 0x00, 0x00, 0x00, 0xb8, 0x00, 0x00, 0x00, + 0xc0, 0x00, 0x00, 0x00, 0xbf, 0x00, 0x00, 0x00, 0xb5, 0x00, 0x00, 0x00, + 0x3e, 0x00, 0x03, 0x00, 0xc1, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, + 0x39, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0xc2, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0xc1, 0x00, 0x00, 0x00, 0x88, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0xc3, 0x00, 0x00, 0x00, 0xc2, 0x00, 0x00, 0x00, 0xb9, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, - 0xbb, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0xbc, 0x00, 0x00, 0x00, - 0xbb, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, - 0xbd, 0x00, 0x00, 0x00, 0xbc, 0x00, 0x00, 0x00, 0xba, 0x00, 0x00, 0x00, - 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0xbe, 0x00, 0x00, 0x00, - 0x7e, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, - 0xbe, 0x00, 0x00, 0x00, 0xbd, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x0c, 0x00, 0x00, 0x00, 0xbf, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00, 0x00, - 0x8e, 0x00, 0x05, 0x00, 0x0c, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, - 0xbf, 0x00, 0x00, 0x00, 0xb5, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, - 0xc1, 0x00, 0x00, 0x00, 0xc0, 0x00, 0x00, 0x00, 0x39, 0x00, 0x05, 0x00, - 0x06, 0x00, 0x00, 0x00, 0xc2, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, - 0xc1, 0x00, 0x00, 0x00, 0x88, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, - 0xc3, 0x00, 0x00, 0x00, 0xc2, 0x00, 0x00, 0x00, 0xb9, 0x00, 0x00, 0x00, - 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0xc4, 0x00, 0x00, 0x00, - 0x7e, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0xc5, 0x00, 0x00, 0x00, 0xc4, 0x00, 0x00, 0x00, - 0x85, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0xc6, 0x00, 0x00, 0x00, - 0xc5, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, - 0x97, 0x00, 0x00, 0x00, 0xc7, 0x00, 0x00, 0x00, 0x94, 0x00, 0x00, 0x00, - 0x96, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0xc8, 0x00, 0x00, 0x00, 0xc7, 0x00, 0x00, 0x00, 0x88, 0x00, 0x05, 0x00, - 0x06, 0x00, 0x00, 0x00, 0xc9, 0x00, 0x00, 0x00, 0xc8, 0x00, 0x00, 0x00, - 0x9a, 0x00, 0x00, 0x00, 0x83, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, - 0xca, 0x00, 0x00, 0x00, 0xc6, 0x00, 0x00, 0x00, 0xc9, 0x00, 0x00, 0x00, - 0x0c, 0x00, 0x06, 0x00, 0x06, 0x00, 0x00, 0x00, 0xcb, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0xca, 0x00, 0x00, 0x00, - 0x88, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, - 0xcb, 0x00, 0x00, 0x00, 0x9a, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, - 0x06, 0x00, 0x00, 0x00, 0xcd, 0x00, 0x00, 0x00, 0xc3, 0x00, 0x00, 0x00, - 0xcc, 0x00, 0x00, 0x00, 0x83, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, - 0xcf, 0x00, 0x00, 0x00, 0xcd, 0x00, 0x00, 0x00, 0xce, 0x00, 0x00, 0x00, - 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0xd0, 0x00, 0x00, 0x00, - 0x7e, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0xd1, 0x00, 0x00, 0x00, 0xd0, 0x00, 0x00, 0x00, - 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0xd2, 0x00, 0x00, 0x00, - 0xd1, 0x00, 0x00, 0x00, 0xcf, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, - 0x07, 0x00, 0x00, 0x00, 0xd3, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, - 0x31, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0xd3, 0x00, 0x00, 0x00, - 0xd2, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, - 0xd6, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, - 0xd5, 0x00, 0x00, 0x00, 0xd6, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x0c, 0x00, 0x00, 0x00, 0xdb, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, - 0x51, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0xdc, 0x00, 0x00, 0x00, - 0xdb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, - 0x06, 0x00, 0x00, 0x00, 0xdd, 0x00, 0x00, 0x00, 0xdb, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, - 0xde, 0x00, 0x00, 0x00, 0xdb, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x50, 0x00, 0x07, 0x00, 0xd7, 0x00, 0x00, 0x00, 0xdf, 0x00, 0x00, 0x00, - 0xdc, 0x00, 0x00, 0x00, 0xdd, 0x00, 0x00, 0x00, 0xde, 0x00, 0x00, 0x00, - 0x41, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0xe0, 0x00, 0x00, 0x00, - 0xe1, 0x00, 0x00, 0x00, 0xda, 0x00, 0x00, 0x00, 0x96, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x03, 0x00, 0xe1, 0x00, 0x00, 0x00, 0xdf, 0x00, 0x00, 0x00, - 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, 0x00, 0x36, 0x00, 0x05, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x08, 0x00, 0x00, 0x00, 0x37, 0x00, 0x03, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x09, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x0b, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, - 0x09, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x06, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x16, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, - 0x15, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x18, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x17, 0x00, 0x00, 0x00, - 0x0c, 0x00, 0x06, 0x00, 0x06, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, - 0xfe, 0x00, 0x02, 0x00, 0x19, 0x00, 0x00, 0x00, 0x38, 0x00, 0x01, 0x00, - 0x36, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x37, 0x00, 0x03, 0x00, - 0x0d, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, - 0x11, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, - 0x1c, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x0d, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x43, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x4a, 0x00, 0x00, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x4f, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x59, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x5e, 0x00, 0x00, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x66, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x6b, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, - 0x0f, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x06, 0x00, 0x0c, 0x00, 0x00, 0x00, - 0x1e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, - 0x1d, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x1c, 0x00, 0x00, 0x00, - 0x1e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, - 0x20, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x06, 0x00, - 0x0c, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x0a, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, - 0x1f, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x0c, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, - 0x1f, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, 0x0c, 0x00, 0x00, 0x00, - 0x24, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, - 0x1f, 0x00, 0x00, 0x00, 0x8e, 0x00, 0x05, 0x00, 0x0c, 0x00, 0x00, 0x00, - 0x28, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, - 0x50, 0x00, 0x06, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, - 0x25, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, - 0x83, 0x00, 0x05, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, - 0x29, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, - 0x0c, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, - 0x2a, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x1f, 0x00, 0x00, 0x00, - 0x2b, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x2f, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, - 0x2f, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x32, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, - 0x32, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x35, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, - 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, - 0x30, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x39, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, - 0x38, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x3a, 0x00, 0x00, 0x00, 0x39, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00, - 0x3a, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x3c, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x03, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, - 0x2c, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x3d, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x00, 0x00, 0x39, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x3f, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, - 0x2c, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x42, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x03, 0x00, 0x43, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, - 0x39, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, - 0x0a, 0x00, 0x00, 0x00, 0x43, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, - 0x2e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x46, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x08, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x47, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x2e, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, - 0x46, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x48, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x49, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, - 0x34, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x4a, 0x00, 0x00, 0x00, - 0x49, 0x00, 0x00, 0x00, 0x39, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x4b, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x4a, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, - 0x2c, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x4e, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x4d, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x03, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x4e, 0x00, 0x00, 0x00, - 0x39, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, - 0x0a, 0x00, 0x00, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x51, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, - 0x2e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x52, 0x00, 0x00, 0x00, 0x51, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x08, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x53, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x2e, 0x00, 0x00, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, - 0x52, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x54, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x55, 0x00, 0x00, 0x00, - 0x54, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x08, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x56, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x00, 0x00, 0x53, 0x00, 0x00, 0x00, 0x55, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x57, 0x00, 0x00, 0x00, - 0x2c, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x58, 0x00, 0x00, 0x00, 0x57, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x03, 0x00, 0x59, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, - 0x39, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00, 0x00, - 0x0a, 0x00, 0x00, 0x00, 0x59, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x5b, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, - 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x5d, 0x00, 0x00, 0x00, - 0x5b, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, - 0x5e, 0x00, 0x00, 0x00, 0x5d, 0x00, 0x00, 0x00, 0x39, 0x00, 0x05, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, - 0x5e, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x60, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x61, 0x00, 0x00, 0x00, - 0x60, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x08, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x62, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, - 0x5a, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x61, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x63, 0x00, 0x00, 0x00, - 0x2c, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x65, 0x00, 0x00, 0x00, 0x63, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x03, 0x00, 0x66, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x00, - 0x39, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x67, 0x00, 0x00, 0x00, - 0x0a, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, - 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x6a, 0x00, 0x00, 0x00, - 0x68, 0x00, 0x00, 0x00, 0x69, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, - 0x6b, 0x00, 0x00, 0x00, 0x6a, 0x00, 0x00, 0x00, 0x39, 0x00, 0x05, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, - 0x6b, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x6d, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x6e, 0x00, 0x00, 0x00, - 0x6d, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x08, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x6f, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, - 0x67, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, 0x6e, 0x00, 0x00, 0x00, - 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, - 0x1f, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x71, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, - 0x0c, 0x00, 0x08, 0x00, 0x06, 0x00, 0x00, 0x00, 0x72, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00, - 0x6f, 0x00, 0x00, 0x00, 0x71, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x73, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, - 0x38, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x74, 0x00, 0x00, 0x00, 0x73, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x08, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x75, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x2e, 0x00, 0x00, 0x00, 0x56, 0x00, 0x00, 0x00, 0x72, 0x00, 0x00, 0x00, - 0x74, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x02, 0x00, 0x75, 0x00, 0x00, 0x00, + 0xc4, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0xc5, 0x00, 0x00, 0x00, + 0xc4, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0xc6, 0x00, 0x00, 0x00, 0xc5, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, + 0x41, 0x00, 0x05, 0x00, 0x97, 0x00, 0x00, 0x00, 0xc7, 0x00, 0x00, 0x00, + 0x94, 0x00, 0x00, 0x00, 0x96, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0xc8, 0x00, 0x00, 0x00, 0xc7, 0x00, 0x00, 0x00, + 0x88, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0xc9, 0x00, 0x00, 0x00, + 0xc8, 0x00, 0x00, 0x00, 0x9a, 0x00, 0x00, 0x00, 0x83, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0xca, 0x00, 0x00, 0x00, 0xc6, 0x00, 0x00, 0x00, + 0xc9, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x06, 0x00, 0x06, 0x00, 0x00, 0x00, + 0xcb, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0xca, 0x00, 0x00, 0x00, 0x88, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0xcc, 0x00, 0x00, 0x00, 0xcb, 0x00, 0x00, 0x00, 0x9a, 0x00, 0x00, 0x00, + 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0xcd, 0x00, 0x00, 0x00, + 0xc3, 0x00, 0x00, 0x00, 0xcc, 0x00, 0x00, 0x00, 0x83, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0xcf, 0x00, 0x00, 0x00, 0xcd, 0x00, 0x00, 0x00, + 0xce, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, + 0xd0, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0xd1, 0x00, 0x00, 0x00, + 0xd0, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0xd2, 0x00, 0x00, 0x00, 0xd1, 0x00, 0x00, 0x00, 0xcf, 0x00, 0x00, 0x00, + 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0xd3, 0x00, 0x00, 0x00, + 0x7e, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, + 0xd3, 0x00, 0x00, 0x00, 0xd2, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, + 0x07, 0x00, 0x00, 0x00, 0xd4, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, + 0x31, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0xd5, 0x00, 0x00, 0x00, 0xd4, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0xd6, 0x00, 0x00, 0x00, 0xd5, 0x00, 0x00, 0x00, + 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0xd7, 0x00, 0x00, 0x00, + 0x7e, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, + 0xd7, 0x00, 0x00, 0x00, 0xd6, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0xda, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, + 0x3e, 0x00, 0x03, 0x00, 0xd9, 0x00, 0x00, 0x00, 0xda, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0xdf, 0x00, 0x00, 0x00, + 0x7e, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0xe0, 0x00, 0x00, 0x00, 0xdf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x51, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0xe1, 0x00, 0x00, 0x00, + 0xdf, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0xe2, 0x00, 0x00, 0x00, 0xdf, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x50, 0x00, 0x07, 0x00, 0xdb, 0x00, 0x00, 0x00, + 0xe3, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0xe1, 0x00, 0x00, 0x00, + 0xe2, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, + 0xe4, 0x00, 0x00, 0x00, 0xe5, 0x00, 0x00, 0x00, 0xde, 0x00, 0x00, 0x00, + 0x96, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0xe5, 0x00, 0x00, 0x00, + 0xe3, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, 0x00, + 0x36, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x37, 0x00, 0x03, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, + 0x0b, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x15, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x06, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x0d, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x18, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, + 0x17, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x06, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x19, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x18, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x02, 0x00, 0x19, 0x00, 0x00, 0x00, 0x38, 0x00, 0x01, 0x00, 0x36, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, - 0x37, 0x00, 0x03, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, - 0xf8, 0x00, 0x02, 0x00, 0x14, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, - 0x38, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x79, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x7a, 0x00, 0x00, 0x00, 0x79, 0x00, 0x00, 0x00, - 0x26, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x06, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x7b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, - 0x7a, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x02, 0x00, 0x7b, 0x00, 0x00, 0x00, - 0x38, 0x00, 0x01, 0x00 + 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, + 0x37, 0x00, 0x03, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, + 0xf8, 0x00, 0x02, 0x00, 0x11, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, + 0x0d, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x2c, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x43, 0x00, 0x00, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x4a, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x4f, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x59, 0x00, 0x00, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x5e, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x6b, 0x00, 0x00, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0x1d, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x06, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, + 0x1c, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, + 0x0c, 0x00, 0x06, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, + 0x3e, 0x00, 0x03, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, + 0x1f, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0x23, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, + 0x23, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0x27, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x8e, 0x00, 0x05, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, + 0x26, 0x00, 0x00, 0x00, 0x50, 0x00, 0x06, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0x29, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, + 0x25, 0x00, 0x00, 0x00, 0x83, 0x00, 0x05, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0x2a, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, + 0x85, 0x00, 0x05, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, + 0x24, 0x00, 0x00, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, + 0x1f, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, + 0x2e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x30, 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, + 0x31, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x33, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, + 0x34, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x36, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, + 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x39, 0x00, 0x00, 0x00, + 0x1c, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x00, 0x00, 0x39, 0x00, 0x00, 0x00, + 0x85, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x00, 0x00, + 0x37, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x2c, 0x00, 0x00, 0x00, + 0x3c, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x3e, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, + 0x3d, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x39, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x40, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, + 0x41, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x43, 0x00, 0x00, 0x00, + 0x42, 0x00, 0x00, 0x00, 0x39, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x44, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x43, 0x00, 0x00, 0x00, + 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x00, + 0x1f, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x46, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x00, + 0x0c, 0x00, 0x08, 0x00, 0x06, 0x00, 0x00, 0x00, 0x47, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, + 0x44, 0x00, 0x00, 0x00, 0x46, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, + 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x49, 0x00, 0x00, 0x00, + 0x48, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, + 0x4a, 0x00, 0x00, 0x00, 0x49, 0x00, 0x00, 0x00, 0x39, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x4a, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x4c, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x4e, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, + 0x4d, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x4f, 0x00, 0x00, 0x00, + 0x4e, 0x00, 0x00, 0x00, 0x39, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x50, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x4f, 0x00, 0x00, 0x00, + 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x51, 0x00, 0x00, 0x00, + 0x1f, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x52, 0x00, 0x00, 0x00, 0x51, 0x00, 0x00, 0x00, + 0x0c, 0x00, 0x08, 0x00, 0x06, 0x00, 0x00, 0x00, 0x53, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x4b, 0x00, 0x00, 0x00, + 0x50, 0x00, 0x00, 0x00, 0x52, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, + 0x31, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x55, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x08, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x56, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x2e, 0x00, 0x00, 0x00, 0x47, 0x00, 0x00, 0x00, 0x53, 0x00, 0x00, 0x00, + 0x55, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x57, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, 0x57, 0x00, 0x00, 0x00, + 0x37, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x59, 0x00, 0x00, 0x00, + 0x58, 0x00, 0x00, 0x00, 0x39, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x5a, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x59, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x5b, 0x00, 0x00, 0x00, + 0x2c, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x5d, 0x00, 0x00, 0x00, 0x5b, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, + 0x3e, 0x00, 0x03, 0x00, 0x5e, 0x00, 0x00, 0x00, 0x5d, 0x00, 0x00, 0x00, + 0x39, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x5e, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, + 0x2e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x61, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x08, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x2e, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, + 0x61, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x63, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x00, 0x63, 0x00, 0x00, 0x00, + 0x64, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x66, 0x00, 0x00, 0x00, + 0x65, 0x00, 0x00, 0x00, 0x39, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x67, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, + 0x2c, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x6a, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, 0x69, 0x00, 0x00, 0x00, + 0x3e, 0x00, 0x03, 0x00, 0x6b, 0x00, 0x00, 0x00, 0x6a, 0x00, 0x00, 0x00, + 0x39, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x6b, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, + 0x2e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x6e, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x08, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x6f, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x2e, 0x00, 0x00, 0x00, 0x67, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, + 0x6e, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x70, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x71, 0x00, 0x00, 0x00, + 0x70, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x08, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x72, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, + 0x62, 0x00, 0x00, 0x00, 0x6f, 0x00, 0x00, 0x00, 0x71, 0x00, 0x00, 0x00, + 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x73, 0x00, 0x00, 0x00, + 0x1f, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00, 0x73, 0x00, 0x00, 0x00, + 0x0c, 0x00, 0x08, 0x00, 0x06, 0x00, 0x00, 0x00, 0x75, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x56, 0x00, 0x00, 0x00, + 0x72, 0x00, 0x00, 0x00, 0x74, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x02, 0x00, + 0x75, 0x00, 0x00, 0x00, 0x38, 0x00, 0x01, 0x00, 0x36, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x37, 0x00, 0x03, 0x00, 0x0d, 0x00, 0x00, 0x00, + 0x12, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x14, 0x00, 0x00, 0x00, + 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, + 0x12, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x79, 0x00, 0x00, 0x00, 0x78, 0x00, 0x00, 0x00, + 0x85, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x7a, 0x00, 0x00, 0x00, + 0x79, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x06, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x7b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x7a, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x02, 0x00, + 0x7b, 0x00, 0x00, 0x00, 0x38, 0x00, 0x01, 0x00 }; -unsigned int ribbon_vert_spv_len = 5116; +unsigned int ribbon_vert_spv_len = 5204; diff --git a/gfx/drivers/vulkan_shaders/ribbon_simple.vert b/gfx/drivers/vulkan_shaders/ribbon_simple.vert index 5758c9f39e..89083e222c 100644 --- a/gfx/drivers/vulkan_shaders/ribbon_simple.vert +++ b/gfx/drivers/vulkan_shaders/ribbon_simple.vert @@ -2,7 +2,7 @@ layout(location = 0) in vec3 VertexCoord; -layout(std430, push_constant) uniform PushConstants +layout(std140, set = 0, binding = 0) uniform UBO { float time; } constants; @@ -31,5 +31,5 @@ void main() v2.x = v2.x + constants.time / 2.0; v2.z = v.z * 3.0; v.y = -cos((v.x + v.z / 3.0 + constants.time) * 2.0) / 10.0 - noise(v2.xyz) / 4.0; - gl_Position = vec4(v, 1.0); + gl_Position = vec4(v.x, -v.y, v.z, 1.0); } diff --git a/gfx/drivers/vulkan_shaders/ribbon_simple.vert.inc b/gfx/drivers/vulkan_shaders/ribbon_simple.vert.inc index 22463dfb38..3c7516f652 100644 --- a/gfx/drivers/vulkan_shaders/ribbon_simple.vert.inc +++ b/gfx/drivers/vulkan_shaders/ribbon_simple.vert.inc @@ -1,6 +1,6 @@ unsigned char ribbon_simple_vert_spv[] = { 0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x08, 0x00, - 0xb2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, + 0xb5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x4c, 0x53, 0x4c, 0x2e, 0x73, 0x74, 0x64, 0x2e, 0x34, 0x35, 0x30, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, @@ -31,9 +31,8 @@ unsigned char ribbon_simple_vert_spv[] = { 0x05, 0x00, 0x03, 0x00, 0x75, 0x00, 0x00, 0x00, 0x76, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, 0x77, 0x00, 0x00, 0x00, 0x56, 0x65, 0x72, 0x74, 0x65, 0x78, 0x43, 0x6f, 0x6f, 0x72, 0x64, 0x00, 0x05, 0x00, 0x03, 0x00, - 0x7f, 0x00, 0x00, 0x00, 0x76, 0x32, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, - 0x83, 0x00, 0x00, 0x00, 0x50, 0x75, 0x73, 0x68, 0x43, 0x6f, 0x6e, 0x73, - 0x74, 0x61, 0x6e, 0x74, 0x73, 0x00, 0x00, 0x00, 0x06, 0x00, 0x05, 0x00, + 0x7f, 0x00, 0x00, 0x00, 0x76, 0x32, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, + 0x83, 0x00, 0x00, 0x00, 0x55, 0x42, 0x4f, 0x00, 0x06, 0x00, 0x05, 0x00, 0x83, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x74, 0x69, 0x6d, 0x65, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, 0x85, 0x00, 0x00, 0x00, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x73, 0x00, 0x00, 0x00, @@ -51,292 +50,298 @@ unsigned char ribbon_simple_vert_spv[] = { 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, 0x83, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x85, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x48, 0x00, 0x05, 0x00, 0xa8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, - 0xa8, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, 0xa8, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x21, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, - 0x16, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, - 0x20, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x21, 0x00, 0x04, 0x00, 0x08, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x17, 0x00, 0x04, 0x00, - 0x0c, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, - 0x20, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x0c, 0x00, 0x00, 0x00, 0x21, 0x00, 0x04, 0x00, 0x0e, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x8c, 0xee, 0x2a, 0x47, - 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x40, 0x40, 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x15, 0x00, 0x04, 0x00, - 0x2a, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x2b, 0x00, 0x04, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, + 0x47, 0x00, 0x04, 0x00, 0x85, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0xa8, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x48, 0x00, 0x05, 0x00, 0xa8, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x0b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, + 0xa8, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x16, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x21, 0x00, 0x04, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x17, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x21, 0x00, 0x04, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, + 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, + 0x8c, 0xee, 0x2a, 0x47, 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, 0x40, 0x2b, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x40, + 0x15, 0x00, 0x04, 0x00, 0x2a, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x2a, 0x00, 0x00, 0x00, - 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x00, 0x00, 0x64, 0x42, - 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, - 0x00, 0x00, 0xe2, 0x42, 0x2b, 0x00, 0x04, 0x00, 0x2a, 0x00, 0x00, 0x00, - 0x35, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x3f, - 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x4a, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x68, 0x42, 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x59, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe4, 0x42, 0x2b, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x61, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2a, 0x43, - 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x2b, 0x43, 0x20, 0x00, 0x04, 0x00, 0x76, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x76, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x20, 0x00, 0x04, 0x00, 0x78, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x7b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x03, 0x00, - 0x83, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, - 0x84, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0x83, 0x00, 0x00, 0x00, - 0x3b, 0x00, 0x04, 0x00, 0x84, 0x00, 0x00, 0x00, 0x85, 0x00, 0x00, 0x00, - 0x09, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x00, 0x86, 0x00, 0x00, 0x00, - 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, - 0x86, 0x00, 0x00, 0x00, 0x87, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x20, 0x00, 0x04, 0x00, 0x88, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x9e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x41, 0x2b, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0xa3, 0x00, 0x00, 0x00, 0x00, 0x00, 0x80, 0x40, - 0x17, 0x00, 0x04, 0x00, 0xa7, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x04, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x04, 0x00, 0xa8, 0x00, 0x00, 0x00, - 0xa7, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, - 0xa9, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xa8, 0x00, 0x00, 0x00, - 0x3b, 0x00, 0x04, 0x00, 0xa9, 0x00, 0x00, 0x00, 0xaa, 0x00, 0x00, 0x00, - 0x03, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0xb0, 0x00, 0x00, 0x00, - 0x03, 0x00, 0x00, 0x00, 0xa7, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x03, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00, - 0x3b, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x75, 0x00, 0x00, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, - 0x7f, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x0d, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x41, 0x00, 0x05, 0x00, 0x78, 0x00, 0x00, 0x00, 0x79, 0x00, 0x00, 0x00, - 0x77, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x7a, 0x00, 0x00, 0x00, 0x79, 0x00, 0x00, 0x00, - 0x41, 0x00, 0x05, 0x00, 0x78, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, - 0x77, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x7d, 0x00, 0x00, 0x00, 0x7c, 0x00, 0x00, 0x00, - 0x50, 0x00, 0x06, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, - 0x7a, 0x00, 0x00, 0x00, 0x7b, 0x00, 0x00, 0x00, 0x7d, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x03, 0x00, 0x75, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, - 0x75, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x7f, 0x00, 0x00, 0x00, - 0x80, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x81, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x00, - 0x81, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x88, 0x00, 0x00, 0x00, - 0x89, 0x00, 0x00, 0x00, 0x85, 0x00, 0x00, 0x00, 0x87, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00, 0x00, - 0x89, 0x00, 0x00, 0x00, 0x88, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x8b, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, - 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x8c, 0x00, 0x00, 0x00, - 0x82, 0x00, 0x00, 0x00, 0x8b, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x8d, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, - 0x2b, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x8d, 0x00, 0x00, 0x00, - 0x8c, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x8e, 0x00, 0x00, 0x00, 0x75, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x8f, 0x00, 0x00, 0x00, - 0x8e, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x90, 0x00, 0x00, 0x00, 0x8f, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, - 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x91, 0x00, 0x00, 0x00, - 0x7f, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, - 0x91, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x92, 0x00, 0x00, 0x00, 0x75, 0x00, 0x00, 0x00, + 0x2b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, + 0x2a, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x64, 0x42, 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x34, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe2, 0x42, 0x2b, 0x00, 0x04, 0x00, + 0x2a, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x80, 0x3f, 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x4a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x68, 0x42, 0x2b, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x59, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe4, 0x42, + 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x61, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x2a, 0x43, 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x66, 0x00, 0x00, 0x00, 0x00, 0x00, 0x2b, 0x43, 0x20, 0x00, 0x04, 0x00, + 0x76, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0x76, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x78, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x7b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x1e, 0x00, 0x03, 0x00, 0x83, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x04, 0x00, 0x84, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x83, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x84, 0x00, 0x00, 0x00, + 0x85, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x15, 0x00, 0x04, 0x00, + 0x86, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x2b, 0x00, 0x04, 0x00, 0x86, 0x00, 0x00, 0x00, 0x87, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x88, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x9e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x41, + 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0xa3, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x80, 0x40, 0x17, 0x00, 0x04, 0x00, 0xa7, 0x00, 0x00, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x04, 0x00, + 0xa8, 0x00, 0x00, 0x00, 0xa7, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x04, 0x00, 0xa9, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0xa8, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0xa9, 0x00, 0x00, 0x00, + 0xaa, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, + 0xb3, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xa7, 0x00, 0x00, 0x00, + 0x36, 0x00, 0x05, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, + 0x05, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, + 0x75, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, + 0x0d, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x78, 0x00, 0x00, 0x00, + 0x79, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x7a, 0x00, 0x00, 0x00, + 0x79, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x78, 0x00, 0x00, 0x00, + 0x7c, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x7d, 0x00, 0x00, 0x00, + 0x7c, 0x00, 0x00, 0x00, 0x50, 0x00, 0x06, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0x7e, 0x00, 0x00, 0x00, 0x7a, 0x00, 0x00, 0x00, 0x7b, 0x00, 0x00, 0x00, + 0x7d, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x75, 0x00, 0x00, 0x00, + 0x7e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0x80, 0x00, 0x00, 0x00, 0x75, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, + 0x7f, 0x00, 0x00, 0x00, 0x80, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x93, 0x00, 0x00, 0x00, 0x92, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x94, 0x00, 0x00, 0x00, 0x75, 0x00, 0x00, 0x00, + 0x82, 0x00, 0x00, 0x00, 0x81, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, + 0x88, 0x00, 0x00, 0x00, 0x89, 0x00, 0x00, 0x00, 0x85, 0x00, 0x00, 0x00, + 0x87, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x8a, 0x00, 0x00, 0x00, 0x89, 0x00, 0x00, 0x00, 0x88, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x8b, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00, 0x00, + 0x23, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x8c, 0x00, 0x00, 0x00, 0x82, 0x00, 0x00, 0x00, 0x8b, 0x00, 0x00, 0x00, + 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x8d, 0x00, 0x00, 0x00, + 0x7f, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, + 0x8d, 0x00, 0x00, 0x00, 0x8c, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x8e, 0x00, 0x00, 0x00, 0x75, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x95, 0x00, 0x00, 0x00, 0x94, 0x00, 0x00, 0x00, 0x88, 0x00, 0x05, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x96, 0x00, 0x00, 0x00, 0x95, 0x00, 0x00, 0x00, - 0x22, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x97, 0x00, 0x00, 0x00, 0x93, 0x00, 0x00, 0x00, 0x96, 0x00, 0x00, 0x00, - 0x41, 0x00, 0x05, 0x00, 0x88, 0x00, 0x00, 0x00, 0x98, 0x00, 0x00, 0x00, - 0x85, 0x00, 0x00, 0x00, 0x87, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x99, 0x00, 0x00, 0x00, 0x98, 0x00, 0x00, 0x00, - 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x9a, 0x00, 0x00, 0x00, - 0x97, 0x00, 0x00, 0x00, 0x99, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x9b, 0x00, 0x00, 0x00, 0x9a, 0x00, 0x00, 0x00, - 0x23, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x06, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x9c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, - 0x9b, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x9d, 0x00, 0x00, 0x00, 0x9c, 0x00, 0x00, 0x00, 0x88, 0x00, 0x05, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x9f, 0x00, 0x00, 0x00, 0x9d, 0x00, 0x00, 0x00, - 0x9e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, - 0xa1, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, - 0xa0, 0x00, 0x00, 0x00, 0xa1, 0x00, 0x00, 0x00, 0x39, 0x00, 0x05, 0x00, - 0x06, 0x00, 0x00, 0x00, 0xa2, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, - 0xa0, 0x00, 0x00, 0x00, 0x88, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, - 0xa4, 0x00, 0x00, 0x00, 0xa2, 0x00, 0x00, 0x00, 0xa3, 0x00, 0x00, 0x00, - 0x83, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0xa5, 0x00, 0x00, 0x00, - 0x9f, 0x00, 0x00, 0x00, 0xa4, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, - 0x07, 0x00, 0x00, 0x00, 0xa6, 0x00, 0x00, 0x00, 0x75, 0x00, 0x00, 0x00, - 0x2e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0xa6, 0x00, 0x00, 0x00, - 0xa5, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, - 0xab, 0x00, 0x00, 0x00, 0x75, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, - 0x06, 0x00, 0x00, 0x00, 0xac, 0x00, 0x00, 0x00, 0xab, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, - 0xad, 0x00, 0x00, 0x00, 0xab, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x51, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0xae, 0x00, 0x00, 0x00, - 0xab, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x50, 0x00, 0x07, 0x00, - 0xa7, 0x00, 0x00, 0x00, 0xaf, 0x00, 0x00, 0x00, 0xac, 0x00, 0x00, 0x00, - 0xad, 0x00, 0x00, 0x00, 0xae, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, - 0x41, 0x00, 0x05, 0x00, 0xb0, 0x00, 0x00, 0x00, 0xb1, 0x00, 0x00, 0x00, - 0xaa, 0x00, 0x00, 0x00, 0x87, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, - 0xb1, 0x00, 0x00, 0x00, 0xaf, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00, - 0x38, 0x00, 0x01, 0x00, 0x36, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, - 0x37, 0x00, 0x03, 0x00, 0x07, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, - 0xf8, 0x00, 0x02, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, - 0x0c, 0x00, 0x06, 0x00, 0x06, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, - 0x85, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, - 0x13, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x06, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x0a, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x02, 0x00, - 0x16, 0x00, 0x00, 0x00, 0x38, 0x00, 0x01, 0x00, 0x36, 0x00, 0x05, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x0e, 0x00, 0x00, 0x00, 0x37, 0x00, 0x03, 0x00, 0x0d, 0x00, 0x00, 0x00, - 0x0f, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x11, 0x00, 0x00, 0x00, - 0x3b, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, - 0x1c, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x00, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x40, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x47, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x56, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x5b, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x63, 0x00, 0x00, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x68, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x0c, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, - 0x0c, 0x00, 0x06, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x03, 0x00, 0x19, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, - 0x0f, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x06, 0x00, 0x0c, 0x00, 0x00, 0x00, - 0x1e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, - 0x1d, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x1c, 0x00, 0x00, 0x00, - 0x1e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, - 0x1f, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x0c, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, - 0x85, 0x00, 0x05, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, - 0x1f, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x0c, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, - 0x8e, 0x00, 0x05, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, - 0x24, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x50, 0x00, 0x06, 0x00, - 0x0c, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, - 0x22, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x83, 0x00, 0x05, 0x00, - 0x0c, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, - 0x25, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, 0x0c, 0x00, 0x00, 0x00, - 0x28, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x03, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, - 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, - 0x19, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x2d, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, - 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00, 0x00, - 0x19, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00, 0x00, - 0x85, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, - 0x30, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0x2d, 0x00, 0x00, 0x00, - 0x32, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x36, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00, - 0x36, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x38, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00, - 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x39, 0x00, 0x00, 0x00, - 0x33, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, - 0x29, 0x00, 0x00, 0x00, 0x39, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x03, 0x00, 0x3a, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x00, 0x00, - 0x39, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, - 0x0a, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, - 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, - 0x40, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x39, 0x00, 0x05, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, - 0x40, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x42, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x43, 0x00, 0x00, 0x00, - 0x42, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x08, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x44, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, - 0x3c, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, 0x43, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x00, - 0x29, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x46, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x03, 0x00, 0x47, 0x00, 0x00, 0x00, 0x46, 0x00, 0x00, 0x00, - 0x39, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, - 0x0a, 0x00, 0x00, 0x00, 0x47, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x49, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, - 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x4b, 0x00, 0x00, 0x00, - 0x49, 0x00, 0x00, 0x00, 0x4a, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, - 0x4c, 0x00, 0x00, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x39, 0x00, 0x05, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x4d, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, - 0x4c, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x4e, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x4f, 0x00, 0x00, 0x00, - 0x4e, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x08, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x50, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, - 0x48, 0x00, 0x00, 0x00, 0x4d, 0x00, 0x00, 0x00, 0x4f, 0x00, 0x00, 0x00, - 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x51, 0x00, 0x00, 0x00, - 0x1c, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x52, 0x00, 0x00, 0x00, 0x51, 0x00, 0x00, 0x00, - 0x0c, 0x00, 0x08, 0x00, 0x06, 0x00, 0x00, 0x00, 0x53, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, - 0x50, 0x00, 0x00, 0x00, 0x52, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, - 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x55, 0x00, 0x00, 0x00, - 0x54, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, - 0x56, 0x00, 0x00, 0x00, 0x55, 0x00, 0x00, 0x00, 0x39, 0x00, 0x05, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x57, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, - 0x56, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x58, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, - 0x59, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x5b, 0x00, 0x00, 0x00, - 0x5a, 0x00, 0x00, 0x00, 0x39, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x5c, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x5b, 0x00, 0x00, 0x00, - 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x5d, 0x00, 0x00, 0x00, - 0x1c, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x5e, 0x00, 0x00, 0x00, 0x5d, 0x00, 0x00, 0x00, - 0x0c, 0x00, 0x08, 0x00, 0x06, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x57, 0x00, 0x00, 0x00, - 0x5c, 0x00, 0x00, 0x00, 0x5e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, - 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00, - 0x60, 0x00, 0x00, 0x00, 0x61, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, - 0x63, 0x00, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00, 0x39, 0x00, 0x05, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, - 0x63, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x65, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x67, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x00, - 0x66, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x68, 0x00, 0x00, 0x00, - 0x67, 0x00, 0x00, 0x00, 0x39, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x69, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, - 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x6a, 0x00, 0x00, 0x00, - 0x1c, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x6b, 0x00, 0x00, 0x00, 0x6a, 0x00, 0x00, 0x00, - 0x0c, 0x00, 0x08, 0x00, 0x06, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, - 0x69, 0x00, 0x00, 0x00, 0x6b, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, + 0x8f, 0x00, 0x00, 0x00, 0x8e, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, 0x8f, 0x00, 0x00, 0x00, + 0x22, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x91, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, + 0x3e, 0x00, 0x03, 0x00, 0x91, 0x00, 0x00, 0x00, 0x90, 0x00, 0x00, 0x00, + 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x92, 0x00, 0x00, 0x00, + 0x75, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x93, 0x00, 0x00, 0x00, 0x92, 0x00, 0x00, 0x00, + 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x94, 0x00, 0x00, 0x00, + 0x75, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x95, 0x00, 0x00, 0x00, 0x94, 0x00, 0x00, 0x00, + 0x88, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x96, 0x00, 0x00, 0x00, + 0x95, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x97, 0x00, 0x00, 0x00, 0x93, 0x00, 0x00, 0x00, + 0x96, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x88, 0x00, 0x00, 0x00, + 0x98, 0x00, 0x00, 0x00, 0x85, 0x00, 0x00, 0x00, 0x87, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x99, 0x00, 0x00, 0x00, + 0x98, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x9a, 0x00, 0x00, 0x00, 0x97, 0x00, 0x00, 0x00, 0x99, 0x00, 0x00, 0x00, + 0x85, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x9b, 0x00, 0x00, 0x00, + 0x9a, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x06, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x9c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x9b, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x9d, 0x00, 0x00, 0x00, 0x9c, 0x00, 0x00, 0x00, + 0x88, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x9f, 0x00, 0x00, 0x00, + 0x9d, 0x00, 0x00, 0x00, 0x9e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0xa1, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, + 0x3e, 0x00, 0x03, 0x00, 0xa0, 0x00, 0x00, 0x00, 0xa1, 0x00, 0x00, 0x00, + 0x39, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0xa2, 0x00, 0x00, 0x00, + 0x10, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x88, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0xa4, 0x00, 0x00, 0x00, 0xa2, 0x00, 0x00, 0x00, + 0xa3, 0x00, 0x00, 0x00, 0x83, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0xa5, 0x00, 0x00, 0x00, 0x9f, 0x00, 0x00, 0x00, 0xa4, 0x00, 0x00, 0x00, + 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0xa6, 0x00, 0x00, 0x00, + 0x75, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, + 0xa6, 0x00, 0x00, 0x00, 0xa5, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, + 0x07, 0x00, 0x00, 0x00, 0xab, 0x00, 0x00, 0x00, 0x75, 0x00, 0x00, 0x00, + 0x2b, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0xac, 0x00, 0x00, 0x00, 0xab, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, + 0x07, 0x00, 0x00, 0x00, 0xad, 0x00, 0x00, 0x00, 0x75, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x6e, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x08, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x6f, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x2e, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, - 0x6e, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x70, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x71, 0x00, 0x00, 0x00, - 0x70, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x08, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x72, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, - 0x53, 0x00, 0x00, 0x00, 0x6f, 0x00, 0x00, 0x00, 0x71, 0x00, 0x00, 0x00, - 0xfe, 0x00, 0x02, 0x00, 0x72, 0x00, 0x00, 0x00, 0x38, 0x00, 0x01, 0x00 + 0xae, 0x00, 0x00, 0x00, 0xad, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0xaf, 0x00, 0x00, 0x00, 0xae, 0x00, 0x00, 0x00, + 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0xb0, 0x00, 0x00, 0x00, + 0x75, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0xb1, 0x00, 0x00, 0x00, 0xb0, 0x00, 0x00, 0x00, + 0x50, 0x00, 0x07, 0x00, 0xa7, 0x00, 0x00, 0x00, 0xb2, 0x00, 0x00, 0x00, + 0xac, 0x00, 0x00, 0x00, 0xaf, 0x00, 0x00, 0x00, 0xb1, 0x00, 0x00, 0x00, + 0x3e, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0xb3, 0x00, 0x00, 0x00, + 0xb4, 0x00, 0x00, 0x00, 0xaa, 0x00, 0x00, 0x00, 0x87, 0x00, 0x00, 0x00, + 0x3e, 0x00, 0x03, 0x00, 0xb4, 0x00, 0x00, 0x00, 0xb2, 0x00, 0x00, 0x00, + 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, 0x00, 0x36, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x08, 0x00, 0x00, 0x00, 0x37, 0x00, 0x03, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x09, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x0b, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, + 0x09, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x06, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x13, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, + 0x12, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x15, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, + 0x0c, 0x00, 0x06, 0x00, 0x06, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, + 0xfe, 0x00, 0x02, 0x00, 0x16, 0x00, 0x00, 0x00, 0x38, 0x00, 0x01, 0x00, + 0x36, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x37, 0x00, 0x03, 0x00, + 0x0d, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, + 0x11, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, + 0x19, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, + 0x0d, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x3a, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x47, 0x00, 0x00, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x4c, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x56, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x5b, 0x00, 0x00, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x63, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, + 0x0f, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x06, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0x1b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x1a, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x19, 0x00, 0x00, 0x00, + 0x1b, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0x1d, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x06, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, + 0x1c, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, + 0x1c, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0x21, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, + 0x1c, 0x00, 0x00, 0x00, 0x8e, 0x00, 0x05, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0x25, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, + 0x50, 0x00, 0x06, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, + 0x22, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, + 0x83, 0x00, 0x05, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, + 0x26, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, + 0x27, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x1c, 0x00, 0x00, 0x00, + 0x28, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x2c, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x2d, 0x00, 0x00, 0x00, + 0x2c, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x2f, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, + 0x2f, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, + 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, + 0x2d, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, + 0x35, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x37, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, + 0x37, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x39, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, + 0x3e, 0x00, 0x03, 0x00, 0x29, 0x00, 0x00, 0x00, 0x39, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x00, 0x00, + 0x29, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x3a, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x00, 0x00, 0x39, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x3c, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x00, 0x00, + 0x29, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x3f, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, + 0x3e, 0x00, 0x03, 0x00, 0x40, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, + 0x39, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, + 0x2b, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x43, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x08, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x2e, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, + 0x43, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x45, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x46, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x00, + 0x31, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x47, 0x00, 0x00, 0x00, + 0x46, 0x00, 0x00, 0x00, 0x39, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x48, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x47, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x49, 0x00, 0x00, 0x00, + 0x29, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x4b, 0x00, 0x00, 0x00, 0x49, 0x00, 0x00, 0x00, 0x4a, 0x00, 0x00, 0x00, + 0x3e, 0x00, 0x03, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x4b, 0x00, 0x00, 0x00, + 0x39, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x4d, 0x00, 0x00, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x4e, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, + 0x2b, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x4f, 0x00, 0x00, 0x00, 0x4e, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x08, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x2e, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x4d, 0x00, 0x00, 0x00, + 0x4f, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x51, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x52, 0x00, 0x00, 0x00, + 0x51, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x08, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x53, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, + 0x44, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x52, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, + 0x29, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x55, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, + 0x3e, 0x00, 0x03, 0x00, 0x56, 0x00, 0x00, 0x00, 0x55, 0x00, 0x00, 0x00, + 0x39, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x57, 0x00, 0x00, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x56, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, + 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00, 0x00, + 0x58, 0x00, 0x00, 0x00, 0x59, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, + 0x5b, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x39, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x5b, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x5d, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x5e, 0x00, 0x00, 0x00, + 0x5d, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x08, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x5f, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, + 0x57, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, 0x5e, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, + 0x29, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x62, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x61, 0x00, 0x00, 0x00, + 0x3e, 0x00, 0x03, 0x00, 0x63, 0x00, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00, + 0x39, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x63, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, + 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x67, 0x00, 0x00, 0x00, + 0x65, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, + 0x68, 0x00, 0x00, 0x00, 0x67, 0x00, 0x00, 0x00, 0x39, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x69, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x68, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x6a, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x6b, 0x00, 0x00, 0x00, + 0x6a, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x08, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x6c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, + 0x64, 0x00, 0x00, 0x00, 0x69, 0x00, 0x00, 0x00, 0x6b, 0x00, 0x00, 0x00, + 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x00, + 0x1c, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x6e, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x00, + 0x0c, 0x00, 0x08, 0x00, 0x06, 0x00, 0x00, 0x00, 0x6f, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, + 0x6c, 0x00, 0x00, 0x00, 0x6e, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, + 0x35, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x71, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x08, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x72, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x2e, 0x00, 0x00, 0x00, 0x53, 0x00, 0x00, 0x00, 0x6f, 0x00, 0x00, 0x00, + 0x71, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x02, 0x00, 0x72, 0x00, 0x00, 0x00, + 0x38, 0x00, 0x01, 0x00 }; -unsigned int ribbon_simple_vert_spv_len = 4068; +unsigned int ribbon_simple_vert_spv_len = 4120; diff --git a/gfx/drivers_font/vulkan_raster_font.c b/gfx/drivers_font/vulkan_raster_font.c index 46336e1e9d..40db815f6d 100644 --- a/gfx/drivers_font/vulkan_raster_font.c +++ b/gfx/drivers_font/vulkan_raster_font.c @@ -243,6 +243,7 @@ static void vulkan_raster_font_flush(vulkan_raster_t *font) &font->texture, font->vk->samplers.nearest, &font->vk->mvp, + sizeof(font->vk->mvp), &font->range, font->vertices, }; diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index f23b4df9ba..efdf5a7c41 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -205,6 +205,7 @@ static void mui_draw_icon( draw.matrix_data = &mymat; draw.texture = texture; draw.prim_type = MENU_DISPLAY_PRIM_TRIANGLESTRIP; + draw.pipeline.id = 0; menu_display_ctl(MENU_DISPLAY_CTL_DRAW, &draw); @@ -294,6 +295,7 @@ static void mui_render_quad(mui_handle_t *mui, draw.matrix_data = NULL; draw.texture = menu_display_white_texture; draw.prim_type = MENU_DISPLAY_PRIM_TRIANGLESTRIP; + draw.pipeline.id = 0; menu_display_ctl(MENU_DISPLAY_CTL_DRAW, &draw); @@ -712,6 +714,7 @@ static void mui_draw_bg(menu_display_ctx_draw_t *draw) menu_display_ctl(MENU_DISPLAY_CTL_BLEND_BEGIN, NULL); draw->x = 0; draw->y = 0; + draw->pipeline.id = 0; menu_display_ctl(MENU_DISPLAY_CTL_DRAW_BG, draw); menu_display_ctl(MENU_DISPLAY_CTL_DRAW, draw); menu_display_ctl(MENU_DISPLAY_CTL_BLEND_END, NULL); diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 6f1f91f54f..3bafb72c4c 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -498,6 +498,7 @@ static void xmb_draw_icon( draw.matrix_data = mymat; draw.texture = texture; draw.prim_type = MENU_DISPLAY_PRIM_TRIANGLESTRIP; + draw.pipeline.id = 0; if (settings->menu.xmb_shadows_enable) { @@ -554,6 +555,7 @@ static void xmb_draw_thumbnail(xmb_handle_t *xmb, float *color, draw.matrix_data = &mymat; draw.texture = xmb->thumbnail; draw.prim_type = MENU_DISPLAY_PRIM_TRIANGLESTRIP; + draw.pipeline.id = 0; if (settings->menu.xmb_shadows_enable) { @@ -1943,6 +1945,7 @@ static void xmb_draw_bg( draw.tex_coord = NULL; draw.vertex_count = 4; draw.prim_type = MENU_DISPLAY_PRIM_TRIANGLESTRIP; + draw.pipeline.id = 0; menu_display_ctl(MENU_DISPLAY_CTL_BLEND_BEGIN, NULL); menu_display_ctl(MENU_DISPLAY_CTL_SET_VIEWPORT, NULL); @@ -1956,11 +1959,12 @@ static void xmb_draw_bg( else menu_display_set_alpha(draw.color, coord_white[3]); + menu_display_ctl(MENU_DISPLAY_CTL_DRAW_GRADIENT, &draw); + draw.pipeline.id = VIDEO_SHADER_MENU_SEC; if (settings->menu.shader_pipeline == 2) draw.pipeline.id = VIDEO_SHADER_MENU; - menu_display_ctl(MENU_DISPLAY_CTL_DRAW_GRADIENT, &draw); menu_display_ctl(MENU_DISPLAY_CTL_DRAW_PIPELINE, &draw); } else @@ -1981,7 +1985,6 @@ static void xmb_draw_dark_layer( unsigned width, unsigned height) { - menu_display_ctx_draw_t draw; struct gfx_coords coords; float black[16] = { @@ -2007,6 +2010,7 @@ static void xmb_draw_dark_layer( draw.matrix_data = NULL; draw.texture = menu_display_white_texture; draw.prim_type = MENU_DISPLAY_PRIM_TRIANGLESTRIP; + draw.pipeline.id = 0; menu_display_ctl(MENU_DISPLAY_CTL_BLEND_BEGIN, NULL); menu_display_ctl(MENU_DISPLAY_CTL_DRAW, &draw); diff --git a/menu/drivers/zarch.c b/menu/drivers/zarch.c index b6f8dca2c4..8a2a783040 100644 --- a/menu/drivers/zarch.c +++ b/menu/drivers/zarch.c @@ -954,6 +954,7 @@ static void zarch_frame(void *data) draw.matrix_data = &zui->mvp; draw.texture = menu_display_white_texture; draw.prim_type = MENU_DISPLAY_PRIM_TRIANGLES; + draw.pipeline.id = 0; menu_display_ctl(MENU_DISPLAY_CTL_DRAW, &draw); diff --git a/menu/drivers_display/menu_display_vulkan.c b/menu/drivers_display/menu_display_vulkan.c index 04d2c2deed..8c8142174e 100644 --- a/menu/drivers_display/menu_display_vulkan.c +++ b/menu/drivers_display/menu_display_vulkan.c @@ -20,6 +20,7 @@ #include "../../gfx/font_driver.h" #include "../../gfx/video_context_driver.h" #include "../../gfx/common/vulkan_common.h" +#include "../../gfx/video_shader_driver.h" #include "../menu_display.h" @@ -61,6 +62,20 @@ static unsigned to_display_pipeline( return ((type == MENU_DISPLAY_PRIM_TRIANGLESTRIP) << 1) | (blend << 0); } +static unsigned to_menu_pipeline( + enum menu_display_prim_type type, unsigned pipeline) +{ + switch (pipeline) + { + case VIDEO_SHADER_MENU: + return 4 + (type == MENU_DISPLAY_PRIM_TRIANGLESTRIP); + case VIDEO_SHADER_MENU_SEC: + return 6 + (type == MENU_DISPLAY_PRIM_TRIANGLESTRIP); + default: + return 0; + } +} + static void menu_display_vk_viewport(void *data) { menu_display_ctx_draw_t *draw = (menu_display_ctx_draw_t*)data; @@ -81,14 +96,20 @@ static void menu_display_vk_draw_pipeline(void *data) { menu_display_ctx_draw_t *draw = (menu_display_ctx_draw_t*)data; vk_t *vk = (vk_t*)video_driver_get_ptr(false); + gfx_coord_array_t *ca = NULL; + static float t = 0.0f; if (!vk || !draw) return; - (void)draw; - (void)vk; + menu_display_ctl(MENU_DISPLAY_CTL_COORDS_ARRAY_GET, &ca); + draw->x = 0; + draw->y = 0; + draw->coords = (struct gfx_coords*)&ca->coords; + draw->matrix_data = NULL; + draw->pipeline.backend_data = &t; - /* TODO/FIXME - to implement */ + t += 0.01; } static void menu_display_vk_draw(void *data) @@ -142,19 +163,42 @@ static void menu_display_vk_draw(void *data) pv->color.a = *color++; } + switch (draw->pipeline.id) { - const struct vk_draw_triangles call = { - vk->display.pipelines[ - to_display_pipeline(draw->prim_type, vk->display.blend)], - texture, - texture->default_smooth - ? vk->samplers.linear : vk->samplers.nearest, - draw->matrix_data ? (math_matrix_4x4*)draw->matrix_data - : (math_matrix_4x4*)menu_display_vk_get_default_mvp(), - &range, - draw->coords->vertices, - }; - vulkan_draw_triangles(vk, &call); + case VIDEO_SHADER_MENU: + case VIDEO_SHADER_MENU_SEC: + { + const struct vk_draw_triangles call = { + vk->display.pipelines[ + to_menu_pipeline(draw->prim_type, draw->pipeline.id)], + NULL, + VK_NULL_HANDLE, + draw->pipeline.backend_data, + sizeof(float), + &range, + draw->coords->vertices, + }; + vulkan_draw_triangles(vk, &call); + break; + } + + default: + { + const struct vk_draw_triangles call = { + vk->display.pipelines[ + to_display_pipeline(draw->prim_type, vk->display.blend)], + texture, + texture->default_smooth + ? vk->samplers.linear : vk->samplers.nearest, + draw->matrix_data + ? draw->matrix_data : menu_display_vk_get_default_mvp(), + sizeof(math_matrix_4x4), + &range, + draw->coords->vertices, + }; + vulkan_draw_triangles(vk, &call); + break; + } } } diff --git a/menu/menu_display.h b/menu/menu_display.h index a8c251c031..2fd55f8162 100644 --- a/menu/menu_display.h +++ b/menu/menu_display.h @@ -124,6 +124,7 @@ typedef struct menu_display_ctx_draw struct { unsigned id; + const void *backend_data; } pipeline; } menu_display_ctx_draw_t; From 951c3e408511b7fdf1915ef6fec9daaaaafce4fb Mon Sep 17 00:00:00 2001 From: Hans-Kristian Arntzen Date: Sun, 8 May 2016 12:33:28 +0200 Subject: [PATCH 258/498] De-ioctl menu display interface. Holy crap ... --- command_event.c | 4 +- menu/cbs/menu_cbs_ok.c | 3 +- menu/drivers/materialui.c | 89 +-- menu/drivers/menu_generic.c | 2 +- menu/drivers/rgui.c | 84 +- menu/drivers/xmb.c | 82 +- menu/drivers/zarch.c | 50 +- menu/drivers_display/menu_display_gl.c | 2 +- menu/drivers_display/menu_display_vulkan.c | 2 +- menu/menu_content.c | 3 +- menu/menu_display.c | 861 ++++++++++----------- menu/menu_display.h | 112 +-- menu/menu_driver.c | 12 +- menu/menu_input.c | 8 +- 14 files changed, 624 insertions(+), 690 deletions(-) diff --git a/command_event.c b/command_event.c index 700ff718b0..e5906d5be2 100644 --- a/command_event.c +++ b/command_event.c @@ -1151,9 +1151,7 @@ bool event_cmd_ctl(enum event_command cmd, void *data) input_driver_ctl(RARCH_INPUT_CTL_POLL, NULL); #ifdef HAVE_MENU - menu_display_ctl( - MENU_DISPLAY_CTL_SET_FRAMEBUFFER_DIRTY_FLAG, NULL); - + menu_display_set_framebuffer_dirty_flag(); if (menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL)) event_cmd_ctl(EVENT_CMD_VIDEO_SET_BLOCKING_STATE, NULL); #endif diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index fba8fccd12..0b84e6e4b3 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -768,10 +768,9 @@ static int generic_action_ok(const char *path, break; case ACTION_OK_LOAD_CONFIG_FILE: { - bool msg_force = true; flush_char = NULL; flush_type = MENU_SETTINGS; - menu_display_ctl(MENU_DISPLAY_CTL_SET_MSG_FORCE, &msg_force); + menu_display_set_msg_force(true); if (rarch_ctl(RARCH_CTL_REPLACE_CONFIG, action_path)) { diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index efdf5a7c41..875d7c8e44 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -180,7 +180,7 @@ static void mui_draw_icon( struct gfx_coords coords; math_matrix_4x4 mymat; - menu_display_ctl(MENU_DISPLAY_CTL_BLEND_BEGIN, NULL); + menu_display_blend_begin(); rotate_draw.matrix = &mymat; rotate_draw.rotation = rotation; @@ -189,7 +189,7 @@ static void mui_draw_icon( rotate_draw.scale_z = 1; rotate_draw.scale_enable = true; - menu_display_ctl(MENU_DISPLAY_CTL_ROTATE_Z, &rotate_draw); + menu_display_rotate_z(&rotate_draw); coords.vertices = 4; coords.vertex = NULL; @@ -207,12 +207,10 @@ static void mui_draw_icon( draw.prim_type = MENU_DISPLAY_PRIM_TRIANGLESTRIP; draw.pipeline.id = 0; - menu_display_ctl(MENU_DISPLAY_CTL_DRAW, &draw); - - menu_display_ctl(MENU_DISPLAY_CTL_BLEND_END, NULL); + menu_display_draw(&draw); + menu_display_blend_end(); } - static void mui_draw_tab(mui_handle_t *mui, unsigned i, unsigned width, unsigned height, @@ -256,7 +254,7 @@ static void mui_draw_text(float x, float y, unsigned width, unsigned height, int font_size; struct font_params params; - menu_display_ctl(MENU_DISPLAY_CTL_FONT_SIZE, &font_size); + font_size = menu_display_get_font_size(); params.x = x / width; params.y = 1.0f - (y + font_size / 3) / height; @@ -285,7 +283,7 @@ static void mui_render_quad(mui_handle_t *mui, coords.lut_tex_coord = NULL; coords.color = coord_color; - menu_display_ctl(MENU_DISPLAY_CTL_BLEND_BEGIN, NULL); + menu_display_blend_begin(); draw.x = x; draw.y = (int)height - y - (int)h; @@ -297,17 +295,15 @@ static void mui_render_quad(mui_handle_t *mui, draw.prim_type = MENU_DISPLAY_PRIM_TRIANGLESTRIP; draw.pipeline.id = 0; - menu_display_ctl(MENU_DISPLAY_CTL_DRAW, &draw); - - menu_display_ctl(MENU_DISPLAY_CTL_BLEND_END, NULL); + menu_display_draw(&draw); + menu_display_blend_end(); } static void mui_draw_tab_begin(mui_handle_t *mui, unsigned width, unsigned height, float *white_bg, float *grey_bg) { - float scale_factor; - menu_display_ctl(MENU_DISPLAY_CTL_GET_DPI, &scale_factor); + float scale_factor = menu_display_get_dpi(); mui->tabs_height = scale_factor / 3; @@ -350,7 +346,7 @@ static void mui_draw_scrollbar(mui_handle_t *mui, if (!mui) return; - menu_display_ctl(MENU_DISPLAY_CTL_HEADER_HEIGHT, &header_height); + header_height = menu_display_get_header_height(); content_height = menu_entries_get_end() * mui->line_height; total_height = height - header_height - mui->tabs_height; @@ -404,7 +400,7 @@ static void mui_render_messagebox(const char *message) video_driver_get_size(&width, &height); - menu_display_ctl(MENU_DISPLAY_CTL_FONT_SIZE, &font_size); + font_size = menu_display_get_font_size(); x = width / 2; y = height / 2 - list->size * font_size / 2; @@ -445,9 +441,9 @@ static void mui_render(void *data) if (menu_animation_ctl(MENU_ANIMATION_CTL_IDEAL_DELTA_TIME_GET, &delta)) menu_animation_ctl(MENU_ANIMATION_CTL_UPDATE, &delta.ideal); - menu_display_ctl(MENU_DISPLAY_CTL_SET_WIDTH, &width); - menu_display_ctl(MENU_DISPLAY_CTL_SET_HEIGHT, &height); - menu_display_ctl(MENU_DISPLAY_CTL_HEADER_HEIGHT, &header_height); + menu_display_set_width(width); + menu_display_set_height(height); + header_height = menu_display_get_header_height(); if (settings->menu.pointer.enable) { @@ -624,10 +620,10 @@ static void mui_render_menu_list(mui_handle_t *mui, size_t end = menu_entries_get_end(); video_driver_ctl(RARCH_DISPLAY_CTL_GET_FRAME_COUNT, &frame_count); - if (!menu_display_ctl(MENU_DISPLAY_CTL_UPDATE_PENDING, NULL)) + if (!menu_display_get_update_pending()) return; - menu_display_ctl(MENU_DISPLAY_CTL_HEADER_HEIGHT, &header_height); + header_height = menu_display_get_header_height(); mui->list_block.carr.coords.vertices = 0; @@ -711,13 +707,15 @@ static int mui_get_core_title(char *s, size_t len) static void mui_draw_bg(menu_display_ctx_draw_t *draw) { - menu_display_ctl(MENU_DISPLAY_CTL_BLEND_BEGIN, NULL); + menu_display_blend_begin(); + draw->x = 0; draw->y = 0; draw->pipeline.id = 0; - menu_display_ctl(MENU_DISPLAY_CTL_DRAW_BG, draw); - menu_display_ctl(MENU_DISPLAY_CTL_DRAW, draw); - menu_display_ctl(MENU_DISPLAY_CTL_BLEND_END, NULL); + + menu_display_draw_bg(draw); + menu_display_draw(draw); + menu_display_blend_end(); } static void mui_frame(void *data) @@ -789,8 +787,7 @@ static void mui_frame(void *data) const uint32_t activetab_color = 0x0096f2ff; const uint32_t passivetab_color = 0x9e9e9eff; bool background_rendered = false; - bool libretro_running = menu_display_ctl( - MENU_DISPLAY_CTL_LIBRETRO_RUNNING, NULL); + bool libretro_running = menu_display_libretro_running(); video_driver_ctl(RARCH_DISPLAY_CTL_GET_FRAME_COUNT, &frame_count); @@ -802,8 +799,8 @@ static void mui_frame(void *data) video_driver_get_size(&width, &height); - menu_display_ctl(MENU_DISPLAY_CTL_SET_VIEWPORT, NULL); - menu_display_ctl(MENU_DISPLAY_CTL_HEADER_HEIGHT, &header_height); + menu_display_set_viewport(); + header_height = menu_display_get_header_height(); if (libretro_running) { @@ -818,8 +815,7 @@ static void mui_frame(void *data) draw.vertex_count = 4; draw.prim_type = MENU_DISPLAY_PRIM_TRIANGLESTRIP; - if (!menu_display_ctl(MENU_DISPLAY_CTL_LIBRETRO_RUNNING, NULL) - && draw.texture) + if (!menu_display_libretro_running() && draw.texture) draw.color = &white_bg[0]; mui_draw_bg(&draw); @@ -833,7 +829,7 @@ static void mui_frame(void *data) clearcolor.b = 1.0f; clearcolor.a = 0.75f; - menu_display_ctl(MENU_DISPLAY_CTL_CLEAR_COLOR, &clearcolor); + menu_display_clear_color(&clearcolor); if (mui->textures.bg) { @@ -852,8 +848,7 @@ static void mui_frame(void *data) draw.vertex_count = 4; draw.prim_type = MENU_DISPLAY_PRIM_TRIANGLESTRIP; - if (!menu_display_ctl(MENU_DISPLAY_CTL_LIBRETRO_RUNNING, NULL) - && draw.texture) + if (!menu_display_libretro_running() && draw.texture) draw.color = &white_bg[0]; mui_draw_bg(&draw); @@ -880,12 +875,12 @@ static void mui_frame(void *data) width, height, &lightblue_bg[0]); - menu_display_ctl(MENU_DISPLAY_CTL_FONT_BIND_BLOCK, &mui->list_block); + menu_display_font_bind_block(&mui->list_block); mui_render_menu_list(mui, width, height, normal_color, hover_color, &pure_white[0]); - menu_display_ctl(MENU_DISPLAY_CTL_FONT_FLUSH_BLOCK, NULL); + menu_display_font_flush_block(); menu_animation_ctl(MENU_ANIMATION_CTL_SET_ACTIVE, NULL); /* header */ @@ -997,8 +992,8 @@ static void mui_frame(void *data) width, height); - menu_display_ctl(MENU_DISPLAY_CTL_RESTORE_CLEAR_COLOR, NULL); - menu_display_ctl(MENU_DISPLAY_CTL_UNSET_VIEWPORT, NULL); + menu_display_restore_clear_color(); + menu_display_unset_viewport(); } static void mui_font(void) @@ -1008,7 +1003,7 @@ static void mui_font(void) menu_display_ctx_font_t font_info; settings_t *settings = config_get_ptr(); - menu_display_ctl(MENU_DISPLAY_CTL_FONT_SIZE, &font_size); + font_size = menu_display_get_font_size(); fill_pathname_join(mediapath, settings->directory.assets, "glui", sizeof(mediapath)); @@ -1018,7 +1013,7 @@ static void mui_font(void) font_info.path = fontpath; font_info.size = font_size; - if (!menu_display_ctl(MENU_DISPLAY_CTL_FONT_MAIN_INIT, &font_info)) + if (!menu_display_font_main_init(&font_info)) RARCH_WARN("Failed to load font."); } @@ -1037,7 +1032,7 @@ static void mui_layout(mui_handle_t *mui) * * On desktops, we just care about readability, with every widget * size proportional to the display width. */ - menu_display_ctl(MENU_DISPLAY_CTL_GET_DPI, &scale_factor); + scale_factor = menu_display_get_dpi(); new_header_height = scale_factor / 3; new_font_size = scale_factor / 9; @@ -1049,17 +1044,15 @@ static void mui_layout(mui_handle_t *mui) mui->margin = scale_factor / 9; mui->icon_size = scale_factor / 3; - menu_display_ctl(MENU_DISPLAY_CTL_SET_HEADER_HEIGHT, - &new_header_height); - menu_display_ctl(MENU_DISPLAY_CTL_SET_FONT_SIZE, - &new_font_size); + menu_display_set_header_height(new_header_height); + menu_display_set_font_size(new_font_size); /* we assume the average glyph aspect ratio is close to 3:4 */ mui->glyph_width = new_font_size * 3/4; mui_font(); - menu_display_ctl(MENU_DISPLAY_CTL_FONT_BUF, &fb_buf); + fb_buf = menu_display_get_font_buffer(); if (fb_buf) /* calculate a more realistic ticker_limit */ { @@ -1080,7 +1073,7 @@ static void *mui_init(void **userdata) if (!menu) goto error; - if (!menu_display_ctl(MENU_DISPLAY_CTL_INIT_FIRST_DRIVER, NULL)) + if (!menu_display_init_first_driver()) goto error; mui = (mui_handle_t*)calloc(1, sizeof(mui_handle_t)); @@ -1134,7 +1127,7 @@ static void mui_context_destroy(void *data) for (i = 0; i < MUI_TEXTURE_LAST; i++) video_driver_texture_unload(&mui->textures.list[i]); - menu_display_ctl(MENU_DISPLAY_CTL_FONT_MAIN_DEINIT, NULL); + menu_display_font_main_deinit(); mui_context_bg_destroy(mui); } @@ -1498,7 +1491,7 @@ static int mui_pointer_tap(void *userdata, video_driver_get_size(&width, &height); menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection); - menu_display_ctl(MENU_DISPLAY_CTL_HEADER_HEIGHT, &header_height); + header_height = menu_display_get_header_height(); if (y < header_height) { diff --git a/menu/drivers/menu_generic.c b/menu/drivers/menu_generic.c index cae769c718..293fba9f12 100644 --- a/menu/drivers/menu_generic.c +++ b/menu/drivers/menu_generic.c @@ -289,7 +289,7 @@ int generic_menu_iterate(void *data, void *userdata, enum menu_action action) if ( action != MENU_ACTION_NOOP || menu_entries_ctl(MENU_ENTRIES_CTL_NEEDS_REFRESH, NULL) - || menu_display_ctl(MENU_DISPLAY_CTL_UPDATE_PENDING, NULL)) + || menu_display_get_update_pending()) { BIT64_SET(menu->state, MENU_STATE_RENDER_FRAMEBUFFER); } diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index f9f0ee3616..5717e5b101 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -202,19 +202,15 @@ static void blit_line(int x, int y, const char *message, uint16_t color) { unsigned i, j; - size_t pitch = 0; - - menu_display_ctl(MENU_DISPLAY_CTL_FB_PITCH, &pitch); + size_t pitch = menu_display_get_framebuffer_pitch(); if (!rgui_framebuf_data) return; while (*message) { - uint8_t *font_fb = NULL; - uint32_t symbol = string_walk(&message); - - menu_display_ctl(MENU_DISPLAY_CTL_FONT_FB, &font_fb); + const uint8_t *font_fb = menu_display_get_font_framebuffer(); + uint32_t symbol = string_walk(&message); for (j = 0; j < FONT_HEIGHT; j++) { @@ -244,7 +240,7 @@ static bool init_font(menu_handle_t *menu, const uint8_t *font_bmp_buf) if (!font) return false; - menu_display_ctl(MENU_DISPLAY_CTL_SET_FONT_DATA_INIT, &fb_font_inited); + menu_display_set_font_data_init(fb_font_inited); for (i = 0; i < 256; i++) { @@ -254,7 +250,7 @@ static bool init_font(menu_handle_t *menu, const uint8_t *font_bmp_buf) font_bmp_buf + 54 + 3 * (256 * (255 - 16 * y) + 16 * x)); } - menu_display_ctl(MENU_DISPLAY_CTL_SET_FONT_FB, &font); + menu_display_set_font_framebuffer(font); return true; } @@ -273,7 +269,7 @@ static bool rguidisp_init_font(menu_handle_t *menu) if (!font_bin_buf) return false; - menu_display_ctl(MENU_DISPLAY_CTL_SET_FONT_FB, &font_bin_buf); + menu_display_set_font_framebuffer(font_bin_buf); return true; } @@ -285,9 +281,9 @@ static void rgui_render_background(void) uint16_t *src = NULL; uint16_t *dst = NULL; - menu_display_ctl(MENU_DISPLAY_CTL_WIDTH, &fb_width); - menu_display_ctl(MENU_DISPLAY_CTL_HEIGHT, &fb_height); - menu_display_ctl(MENU_DISPLAY_CTL_FB_PITCH, &fb_pitch); + fb_width = menu_display_get_width(); + fb_height = menu_display_get_height(); + fb_pitch = menu_display_get_framebuffer_pitch(); pitch_in_pixels = fb_pitch >> 1; size = fb_pitch * 4; @@ -343,9 +339,9 @@ static void rgui_render_messagebox(const char *message) width = 0; glyphs_width = 0; - menu_display_ctl(MENU_DISPLAY_CTL_WIDTH, &fb_width); - menu_display_ctl(MENU_DISPLAY_CTL_HEIGHT, &fb_height); - menu_display_ctl(MENU_DISPLAY_CTL_FB_PITCH, &fb_pitch); + fb_width = menu_display_get_width(); + fb_height = menu_display_get_height(); + fb_pitch = menu_display_get_framebuffer_pitch(); for (i = 0; i < list->size; i++) { @@ -403,9 +399,9 @@ static void rgui_blit_cursor(void) int16_t x = menu_input_mouse_state(MENU_MOUSE_X_AXIS); int16_t y = menu_input_mouse_state(MENU_MOUSE_Y_AXIS); - menu_display_ctl(MENU_DISPLAY_CTL_WIDTH, &fb_width); - menu_display_ctl(MENU_DISPLAY_CTL_HEIGHT, &fb_height); - menu_display_ctl(MENU_DISPLAY_CTL_FB_PITCH, &fb_pitch); + fb_width = menu_display_get_width(); + fb_height = menu_display_get_height(); + fb_pitch = menu_display_get_framebuffer_pitch(); rgui_color_rect(fb_pitch, fb_width, fb_height, x, y - 5, 1, 11, 0xFFFF); rgui_color_rect(fb_pitch, fb_width, fb_height, x - 5, y, 11, 1, 0xFFFF); @@ -438,7 +434,7 @@ static void rgui_render(void *data) if (!rgui->force_redraw) { - menu_display_ctl(MENU_DISPLAY_CTL_MSG_FORCE, &msg_force); + msg_force = menu_display_get_msg_force(); if (menu_entries_ctl(MENU_ENTRIES_CTL_NEEDS_REFRESH, NULL) && menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL) && !msg_force) @@ -447,13 +443,13 @@ static void rgui_render(void *data) if (runloop_ctl(RUNLOOP_CTL_IS_IDLE, NULL)) return; - if (!menu_display_ctl(MENU_DISPLAY_CTL_UPDATE_PENDING, NULL)) + if (!menu_display_get_update_pending()) return; } - menu_display_ctl(MENU_DISPLAY_CTL_WIDTH, &fb_width); - menu_display_ctl(MENU_DISPLAY_CTL_HEIGHT, &fb_height); - menu_display_ctl(MENU_DISPLAY_CTL_FB_PITCH, &fb_pitch); + fb_width = menu_display_get_width(); + fb_height = menu_display_get_height(); + fb_pitch = menu_display_get_framebuffer_pitch(); /* if the framebuffer changed size, recache the background */ if (rgui->last_width != fb_width || rgui->last_height != fb_height) @@ -463,12 +459,11 @@ static void rgui_render(void *data) rgui->last_height = fb_height; } - menu_display_ctl(MENU_DISPLAY_CTL_SET_FRAMEBUFFER_DIRTY_FLAG, NULL); + menu_display_set_framebuffer_dirty_flag(); menu_animation_ctl(MENU_ANIMATION_CTL_CLEAR_ACTIVE, NULL); rgui->force_redraw = false; - if (settings->menu.pointer.enable) { unsigned new_val; @@ -574,7 +569,7 @@ static void rgui_render(void *data) datetime.len = sizeof(timedate); datetime.time_mode = 3; - menu_display_ctl(MENU_DISPLAY_CTL_TIMEDATE, &datetime); + menu_display_timedate(&datetime); blit_line( RGUI_TERM_WIDTH(fb_width) * FONT_WIDTH_STRIDE - RGUI_TERM_START_X(fb_width), @@ -705,10 +700,10 @@ static void *rgui_init(void **userdata) fb_pitch = fb_width * sizeof(uint16_t); new_font_height = FONT_HEIGHT_STRIDE * 2; - menu_display_ctl(MENU_DISPLAY_CTL_SET_WIDTH, &fb_width); - menu_display_ctl(MENU_DISPLAY_CTL_SET_HEIGHT, &fb_height); - menu_display_ctl(MENU_DISPLAY_CTL_SET_HEADER_HEIGHT, &new_font_height); - menu_display_ctl(MENU_DISPLAY_CTL_SET_FB_PITCH, &fb_pitch); + menu_display_set_width(fb_width); + menu_display_set_height(fb_height); + menu_display_set_header_height(new_font_height); + menu_display_set_framebuffer_pitch(fb_pitch); start = 0; menu_entries_ctl(MENU_ENTRIES_CTL_SET_START, &start); @@ -736,31 +731,30 @@ error: static void rgui_free(void *data) { - uint8_t *font_fb; + const uint8_t *font_fb; bool fb_font_inited = false; - menu_display_ctl(MENU_DISPLAY_CTL_FONT_DATA_INIT, &fb_font_inited); - menu_display_ctl(MENU_DISPLAY_CTL_FONT_FB, &font_fb); + fb_font_inited = menu_display_get_font_data_init(); + font_fb = menu_display_get_font_framebuffer(); if (fb_font_inited) - free(font_fb); + free((void*)font_fb); fb_font_inited = false; - - - menu_display_ctl(MENU_DISPLAY_CTL_SET_FONT_DATA_INIT, &fb_font_inited); + menu_display_set_font_data_init(fb_font_inited); } static void rgui_set_texture(void) { unsigned fb_width, fb_height; - if (!menu_display_ctl(MENU_DISPLAY_CTL_GET_FRAMEBUFFER_DIRTY_FLAG, NULL)) + if (!menu_display_get_framebuffer_dirty_flag()) return; - menu_display_ctl(MENU_DISPLAY_CTL_WIDTH, &fb_width); - menu_display_ctl(MENU_DISPLAY_CTL_HEIGHT, &fb_height); - menu_display_ctl(MENU_DISPLAY_CTL_UNSET_FRAMEBUFFER_DIRTY_FLAG, NULL); + fb_width = menu_display_get_width(); + fb_height = menu_display_get_height(); + + menu_display_unset_framebuffer_dirty_flag(); video_driver_set_texture_frame(rgui_framebuf_data, false, fb_width, fb_height, 1.0f); @@ -789,8 +783,8 @@ static void rgui_navigation_set(void *data, bool scroll) if (!scroll) return; - menu_display_ctl(MENU_DISPLAY_CTL_WIDTH, &fb_width); - menu_display_ctl(MENU_DISPLAY_CTL_HEIGHT, &fb_height); + fb_width = menu_display_get_width(); + fb_height = menu_display_get_height(); if (selection < RGUI_TERM_HEIGHT(fb_width, fb_height) /2) { @@ -859,7 +853,7 @@ static int rgui_pointer_tap(void *data, bool scroll = false; menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection); - menu_display_ctl(MENU_DISPLAY_CTL_HEADER_HEIGHT, &header_height); + header_height = menu_display_get_header_height(); if (y < header_height) { diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 3bafb72c4c..fa08b94616 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -511,14 +511,14 @@ static void xmb_draw_icon( draw.x = x + 2; draw.y = height - y - 2; - menu_display_ctl(MENU_DISPLAY_CTL_DRAW, &draw); + menu_display_draw(&draw); } coords.color = (const float*)color; draw.x = x; draw.y = height - y; - menu_display_ctl(MENU_DISPLAY_CTL_DRAW, &draw); + menu_display_draw(&draw); } static void xmb_draw_thumbnail(xmb_handle_t *xmb, float *color, @@ -542,7 +542,7 @@ static void xmb_draw_thumbnail(xmb_handle_t *xmb, float *color, rotate_draw.scale_z = 1; rotate_draw.scale_enable = true; - menu_display_ctl(MENU_DISPLAY_CTL_ROTATE_Z, &rotate_draw); + menu_display_rotate_z(&rotate_draw); coords.vertices = 4; coords.vertex = NULL; @@ -568,14 +568,14 @@ static void xmb_draw_thumbnail(xmb_handle_t *xmb, float *color, draw.x = x + 2; draw.y = height - y - 2; - menu_display_ctl(MENU_DISPLAY_CTL_DRAW, &draw); + menu_display_draw(&draw); } coords.color = (const float*)color; draw.x = x; draw.y = height - y; - menu_display_ctl(MENU_DISPLAY_CTL_DRAW, &draw); + menu_display_draw(&draw); } static void xmb_draw_text(xmb_handle_t *xmb, @@ -650,7 +650,7 @@ static void xmb_render_messagebox_internal( if (list->elems == 0) goto end; - menu_display_ctl(MENU_DISPLAY_CTL_FONT_SIZE, &font_size); + font_size = menu_display_get_font_size(); x = width / 2 - strlen(list->elems[0].data) * font_size / 4; y = height / 2 - list->size * font_size / 2; @@ -1659,14 +1659,14 @@ static void xmb_draw_items(xmb_handle_t *xmb, rotate_draw.scale_z = 1; rotate_draw.scale_enable = true; - menu_display_ctl(MENU_DISPLAY_CTL_ROTATE_Z, &rotate_draw); + menu_display_rotate_z(&rotate_draw); menu_entries_ctl(MENU_ENTRIES_CTL_START_GET, &i); if (list == xmb->selection_buf_old) i = 0; - menu_display_ctl(MENU_DISPLAY_CTL_BLEND_BEGIN, NULL); + menu_display_blend_begin(); for (; i < end; i++) { @@ -1826,7 +1826,7 @@ static void xmb_draw_items(xmb_handle_t *xmb, rotate_draw.scale_z = 1; rotate_draw.scale_enable = true; - menu_display_ctl(MENU_DISPLAY_CTL_ROTATE_Z, &rotate_draw); + menu_display_rotate_z(&rotate_draw); xmb_draw_icon( xmb->icon.size, @@ -1859,7 +1859,7 @@ static void xmb_draw_items(xmb_handle_t *xmb, 1, &color[0]); } - menu_display_ctl(MENU_DISPLAY_CTL_BLEND_END, NULL); + menu_display_blend_end(); } static void xmb_render(void *data) @@ -1933,7 +1933,8 @@ static void xmb_draw_bg( { menu_display_ctx_draw_t draw; settings_t *settings = config_get_ptr(); - bool running = menu_display_ctl(MENU_DISPLAY_CTL_LIBRETRO_RUNNING, NULL); + + bool running = menu_display_libretro_running(); draw.x = 0; draw.y = 0; @@ -1947,8 +1948,8 @@ static void xmb_draw_bg( draw.prim_type = MENU_DISPLAY_PRIM_TRIANGLESTRIP; draw.pipeline.id = 0; - menu_display_ctl(MENU_DISPLAY_CTL_BLEND_BEGIN, NULL); - menu_display_ctl(MENU_DISPLAY_CTL_SET_VIEWPORT, NULL); + menu_display_blend_begin(); + menu_display_set_viewport(); if (settings->menu.shader_pipeline > 0) { @@ -1959,25 +1960,24 @@ static void xmb_draw_bg( else menu_display_set_alpha(draw.color, coord_white[3]); - menu_display_ctl(MENU_DISPLAY_CTL_DRAW_GRADIENT, &draw); + menu_display_draw_gradient(&draw); draw.pipeline.id = VIDEO_SHADER_MENU_SEC; if (settings->menu.shader_pipeline == 2) draw.pipeline.id = VIDEO_SHADER_MENU; - menu_display_ctl(MENU_DISPLAY_CTL_DRAW_PIPELINE, &draw); + menu_display_draw_pipeline(&draw); } else { if (!running && draw.texture) draw.color = &coord_white[0]; - menu_display_ctl(MENU_DISPLAY_CTL_DRAW_BG, &draw); + menu_display_draw_bg(&draw); } - menu_display_ctl(MENU_DISPLAY_CTL_DRAW, &draw); - - menu_display_ctl(MENU_DISPLAY_CTL_BLEND_END, NULL); + menu_display_draw(&draw); + menu_display_blend_end(); } static void xmb_draw_dark_layer( @@ -2012,9 +2012,9 @@ static void xmb_draw_dark_layer( draw.prim_type = MENU_DISPLAY_PRIM_TRIANGLESTRIP; draw.pipeline.id = 0; - menu_display_ctl(MENU_DISPLAY_CTL_BLEND_BEGIN, NULL); - menu_display_ctl(MENU_DISPLAY_CTL_DRAW, &draw); - menu_display_ctl(MENU_DISPLAY_CTL_BLEND_END, NULL); + menu_display_blend_begin(); + menu_display_draw(&draw); + menu_display_blend_end(); } static void xmb_frame(void *data) @@ -2040,7 +2040,7 @@ static void xmb_frame(void *data) video_driver_get_size(&width, &height); - menu_display_ctl(MENU_DISPLAY_CTL_FONT_BIND_BLOCK, &xmb->raster_block); + menu_display_font_bind_block(&xmb->raster_block); xmb->raster_block.carr.coords.vertices = 0; @@ -2091,8 +2091,8 @@ static void xmb_frame(void *data) rotate_draw.scale_z = 1; rotate_draw.scale_enable = true; - menu_display_ctl(MENU_DISPLAY_CTL_ROTATE_Z, &rotate_draw); - menu_display_ctl(MENU_DISPLAY_CTL_BLEND_BEGIN, NULL); + menu_display_rotate_z(&rotate_draw); + menu_display_blend_begin(); if (strcmp(xmb_thumbnails_ident(), "OFF") && xmb->thumbnail) xmb_draw_thumbnail(xmb, &coord_white[0], width, height); @@ -2122,7 +2122,7 @@ static void xmb_frame(void *data) datetime.len = sizeof(timedate); datetime.time_mode = 4; - menu_display_ctl(MENU_DISPLAY_CTL_TIMEDATE, &datetime); + menu_display_timedate(&datetime); xmb_draw_text(xmb, timedate, width - xmb->margins.title.left - xmb->icon.size / 4, @@ -2149,7 +2149,7 @@ static void xmb_frame(void *data) 0, 1, &coord_white[0]); - menu_display_ctl(MENU_DISPLAY_CTL_BLEND_BEGIN, NULL); + menu_display_blend_begin(); /* Horizontal tab icons */ for (i = 0; i <= xmb_list_get_size(xmb, MENU_LIST_HORIZONTAL) @@ -2181,7 +2181,7 @@ static void xmb_frame(void *data) rotate_draw.scale_z = 1; rotate_draw.scale_enable = true; - menu_display_ctl(MENU_DISPLAY_CTL_ROTATE_Z, &rotate_draw); + menu_display_rotate_z(&rotate_draw); xmb_draw_icon( xmb->icon.size, @@ -2198,7 +2198,7 @@ static void xmb_frame(void *data) } } - menu_display_ctl(MENU_DISPLAY_CTL_BLEND_END, NULL); + menu_display_blend_end(); /* Vertical icons */ xmb_draw_items(xmb, @@ -2227,7 +2227,7 @@ static void xmb_frame(void *data) width, height); - menu_display_ctl(MENU_DISPLAY_CTL_FONT_FLUSH_BLOCK, NULL); + menu_display_font_flush_block(); menu_input_ctl(MENU_INPUT_CTL_KEYBOARD_DISPLAY, &display_kb); @@ -2269,7 +2269,7 @@ static void xmb_frame(void *data) width, height); - menu_display_ctl(MENU_DISPLAY_CTL_UNSET_VIEWPORT, NULL); + menu_display_unset_viewport(); } @@ -2281,7 +2281,7 @@ static void xmb_font(xmb_handle_t *xmb) menu_display_ctx_font_t font_info; settings_t *settings = config_get_ptr(); - menu_display_ctl(MENU_DISPLAY_CTL_FONT_SIZE, &font_size); + font_size = menu_display_get_font_size(); fill_pathname_join( mediapath, @@ -2298,7 +2298,7 @@ static void xmb_font(xmb_handle_t *xmb) font_info.path = fontpath; font_info.size = font_size; - if (!menu_display_ctl(MENU_DISPLAY_CTL_FONT_MAIN_INIT, &font_info)) + if (!menu_display_font_main_init(&font_info)) RARCH_WARN("Failed to load font."); } @@ -2345,8 +2345,8 @@ static void xmb_layout(xmb_handle_t *xmb) xmb->margins.setting.left = 600.0 * scale_factor; xmb->icon.size = 128.0 * scale_factor; - menu_display_ctl(MENU_DISPLAY_CTL_SET_FONT_SIZE, &new_font_size); - menu_display_ctl(MENU_DISPLAY_CTL_SET_HEADER_HEIGHT, &new_header_height); + menu_display_set_font_size(new_font_size); + menu_display_set_header_height(new_header_height); current = selection; end = menu_entries_get_end(); @@ -2418,7 +2418,7 @@ static void xmb_init_ribbon(xmb_handle_t * xmb) gfx_coord_array_t *ca = NULL; memset(&dummy[0], 0, 4 * XMB_RIBBON_VERTICES * sizeof(float)); - menu_display_ctl(MENU_DISPLAY_CTL_COORDS_ARRAY_GET, &ca); + ca = menu_display_get_coords_array(); /* Set up vertices */ i = 0; @@ -2451,7 +2451,7 @@ static void *xmb_init(void **userdata) if (!menu) goto error; - if (!menu_display_ctl(MENU_DISPLAY_CTL_INIT_FIRST_DRIVER, NULL)) + if (!menu_display_init_first_driver()) goto error; video_driver_get_size(&width, &height); @@ -2487,8 +2487,8 @@ static void *xmb_init(void **userdata) * for XMB, we should refactor this dependency * away. */ - menu_display_ctl(MENU_DISPLAY_CTL_SET_WIDTH, &width); - menu_display_ctl(MENU_DISPLAY_CTL_SET_HEIGHT, &height); + menu_display_set_width(width); + menu_display_set_height(height); menu_display_allocate_white_texture(); @@ -3017,7 +3017,7 @@ static void xmb_context_destroy(void *data) xmb_context_destroy_horizontal_list(xmb); xmb_context_bg_destroy(xmb); - menu_display_ctl(MENU_DISPLAY_CTL_FONT_MAIN_DEINIT, NULL); + menu_display_font_main_deinit(); } static void xmb_toggle(void *userdata, bool menu_on) @@ -3204,7 +3204,7 @@ static int xmb_pointer_tap(void *userdata, bool scroll = false; menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection); - menu_display_ctl(MENU_DISPLAY_CTL_HEADER_HEIGHT, &header_height); + header_height = menu_display_get_header_height(); if (y < header_height) { diff --git a/menu/drivers/zarch.c b/menu/drivers/zarch.c index 8a2a783040..64dde48889 100644 --- a/menu/drivers/zarch.c +++ b/menu/drivers/zarch.c @@ -174,7 +174,7 @@ static void zarch_zui_font(void) menu_display_ctx_font_t font_info; settings_t *settings = config_get_ptr(); - menu_display_ctl(MENU_DISPLAY_CTL_FONT_SIZE, &font_size); + font_size = menu_display_get_font_size(); fill_pathname_join( mediapath, @@ -187,7 +187,7 @@ static void zarch_zui_font(void) font_info.path = fontpath; font_info.size = font_size; - if (!menu_display_ctl(MENU_DISPLAY_CTL_FONT_MAIN_INIT, &font_info)) + if (!menu_display_font_main_init(&font_info)) RARCH_WARN("Failed to load font."); } @@ -874,15 +874,15 @@ static void zarch_frame(void *data) zui_t *zui = (zui_t*)data; gfx_coord_array_t *ca = NULL; - menu_display_ctl(MENU_DISPLAY_CTL_COORDS_ARRAY_GET, &ca); + ca = menu_display_get_coords_array(); if (!zui) return; video_driver_get_size(&zui->width, &zui->height); - menu_display_ctl(MENU_DISPLAY_CTL_SET_VIEWPORT, NULL); - menu_display_ctl(MENU_DISPLAY_CTL_FONT_BUF, &zui->fb_buf); + menu_display_set_viewport(); + zui->fb_buf = menu_display_get_font_buffer(); for (i = 0; i < 16; i++) { @@ -904,11 +904,11 @@ static void zarch_frame(void *data) zui->mouse.wheel = menu_input_mouse_state(MENU_MOUSE_WHEEL_DOWN) - menu_input_mouse_state(MENU_MOUSE_WHEEL_UP); - menu_display_ctl(MENU_DISPLAY_CTL_COORDS_ARRAY_RESET, NULL); + menu_display_coords_array_reset(); zui->tmp_block.carr.coords.vertices = 0; - menu_display_ctl(MENU_DISPLAY_CTL_FONT_BIND_BLOCK, &zui->tmp_block); + menu_display_font_bind_block(&zui->tmp_block); menu_display_push_quad(zui->width, zui->height, zui_bg_screen, 0, 0, zui->width, zui->height); @@ -944,7 +944,7 @@ static void zarch_frame(void *data) else if (zui->item.active == 0) zui->item.active = -1; - menu_display_ctl(MENU_DISPLAY_CTL_BLEND_BEGIN, NULL); + menu_display_blend_begin(); draw.x = 0; draw.y = 0; @@ -956,15 +956,14 @@ static void zarch_frame(void *data) draw.prim_type = MENU_DISPLAY_PRIM_TRIANGLES; draw.pipeline.id = 0; - menu_display_ctl(MENU_DISPLAY_CTL_DRAW, &draw); - - menu_display_ctl(MENU_DISPLAY_CTL_BLEND_END, NULL); + menu_display_draw(&draw); + menu_display_blend_end(); memset(&draw, 0, sizeof(menu_display_ctx_draw_t)); coord_draw.ptr = NULL; - menu_display_ctl(MENU_DISPLAY_CTL_TEX_COORDS_GET, &coord_draw); + menu_display_get_tex_coords(&coord_draw); draw.width = zui->width; draw.height = zui->height; @@ -975,21 +974,20 @@ static void zarch_frame(void *data) draw.vertex_count = 4; draw.prim_type = MENU_DISPLAY_PRIM_TRIANGLESTRIP; - if (!menu_display_ctl(MENU_DISPLAY_CTL_LIBRETRO_RUNNING, NULL) - && draw.texture) + if (!menu_display_libretro_running() && draw.texture) draw.color = &coord_color2[0]; - menu_display_ctl(MENU_DISPLAY_CTL_BLEND_BEGIN, NULL); + menu_display_blend_begin(); draw.x = 0; draw.y = 0; - menu_display_ctl(MENU_DISPLAY_CTL_DRAW_BG, &draw); - menu_display_ctl(MENU_DISPLAY_CTL_DRAW, &draw); - menu_display_ctl(MENU_DISPLAY_CTL_BLEND_END, NULL); + menu_display_draw_bg(&draw); + menu_display_draw(&draw); + menu_display_blend_end(); zui->rendering = false; - menu_display_ctl(MENU_DISPLAY_CTL_FONT_FLUSH_BLOCK, NULL); - menu_display_ctl(MENU_DISPLAY_CTL_UNSET_VIEWPORT, NULL); + menu_display_font_flush_block(); + menu_display_unset_viewport(); } static void *zarch_init(void **userdata) @@ -1003,7 +1001,7 @@ static void *zarch_init(void **userdata) if (!menu) goto error; - if (!menu_display_ctl(MENU_DISPLAY_CTL_INIT_FIRST_DRIVER, NULL)) + if (!menu_display_init_first_driver()) goto error; zui = (zui_t*)calloc(1, sizeof(zui_t)); @@ -1020,10 +1018,10 @@ static void *zarch_init(void **userdata) } unused = 1000; - menu_display_ctl(MENU_DISPLAY_CTL_SET_HEADER_HEIGHT, &unused); + menu_display_set_header_height(unused); unused = 28; - menu_display_ctl(MENU_DISPLAY_CTL_SET_FONT_SIZE, &unused); + menu_display_set_font_size(unused); (void)unused; @@ -1067,7 +1065,7 @@ static void zarch_context_bg_destroy(void *data) static void zarch_context_destroy(void *data) { - menu_display_ctl(MENU_DISPLAY_CTL_FONT_MAIN_DEINIT, NULL); + menu_display_font_main_deinit(); zarch_context_bg_destroy(data); } @@ -1111,7 +1109,7 @@ static void zarch_context_reset(void *data) if (settings->video.font_enable) font_info.path = settings->path.font; - if (!menu_display_ctl(MENU_DISPLAY_CTL_FONT_MAIN_INIT, &font_info)) + if (!menu_display_font_main_init(&font_info)) RARCH_WARN("Failed to load font."); zarch_context_bg_destroy(zui); @@ -1121,7 +1119,7 @@ static void zarch_context_reset(void *data) menu_display_allocate_white_texture(); - menu_display_ctl(MENU_DISPLAY_CTL_SET_FONT_SIZE, &zui->font_size); + menu_display_set_font_size(zui->font_size); zarch_zui_font(); } diff --git a/menu/drivers_display/menu_display_gl.c b/menu/drivers_display/menu_display_gl.c index 966db0b55a..13bb13beb0 100644 --- a/menu/drivers_display/menu_display_gl.c +++ b/menu/drivers_display/menu_display_gl.c @@ -160,7 +160,7 @@ static void menu_display_gl_draw_pipeline(void *data) static float t = 0; gfx_coord_array_t *ca = NULL; - menu_display_ctl(MENU_DISPLAY_CTL_COORDS_ARRAY_GET, &ca); + ca = menu_display_get_coords_array(); draw->x = 0; draw->y = 0; diff --git a/menu/drivers_display/menu_display_vulkan.c b/menu/drivers_display/menu_display_vulkan.c index 8c8142174e..a8c0b4ff00 100644 --- a/menu/drivers_display/menu_display_vulkan.c +++ b/menu/drivers_display/menu_display_vulkan.c @@ -102,7 +102,7 @@ static void menu_display_vk_draw_pipeline(void *data) if (!vk || !draw) return; - menu_display_ctl(MENU_DISPLAY_CTL_COORDS_ARRAY_GET, &ca); + ca = menu_display_get_coords_array(); draw->x = 0; draw->y = 0; draw->coords = (struct gfx_coords*)&ca->coords; diff --git a/menu/menu_content.c b/menu/menu_content.c index 422696a706..61ec905824 100644 --- a/menu/menu_content.c +++ b/menu/menu_content.c @@ -89,12 +89,11 @@ static bool menu_content_load(void) content_ctx_info_t content_info; char name[PATH_MAX_LENGTH]; char msg[PATH_MAX_LENGTH]; - bool msg_force = true; char *fullpath = NULL; runloop_ctl(RUNLOOP_CTL_GET_CONTENT_PATH, &fullpath); /* redraw menu frame */ - menu_display_ctl(MENU_DISPLAY_CTL_SET_MSG_FORCE, &msg_force); + menu_display_set_msg_force(true); menu_driver_ctl(RARCH_MENU_CTL_RENDER, NULL); if (*fullpath) diff --git a/menu/menu_display.c b/menu/menu_display.c index 7bb36b6470..3e453aa05e 100644 --- a/menu/menu_display.c +++ b/menu/menu_display.c @@ -92,11 +92,9 @@ static bool menu_display_check_compatibility( return false; } -static void menu_display_timedate(void *data) +void menu_display_timedate(menu_display_ctx_datetime_t *datetime) { time_t time_; - menu_display_ctx_datetime_t *datetime = - (menu_display_ctx_datetime_t *)data; if (!datetime) return; @@ -128,459 +126,419 @@ static void menu_display_timedate(void *data) } } +static gfx_coord_array_t menu_disp_ca; +static unsigned menu_display_framebuf_width = 0; +static unsigned menu_display_framebuf_height = 0; +static size_t menu_display_framebuf_pitch = 0; +static int menu_display_font_size = 0; +static unsigned menu_display_header_height = 0; +static bool menu_display_msg_force = false; +static bool menu_display_font_alloc_framebuf = false; +static bool menu_display_framebuf_dirty = false; +static const uint8_t *menu_display_font_framebuf = NULL; +static void *menu_display_font_buf = NULL; +static msg_queue_t *menu_display_msg_queue = NULL; +static menu_display_ctx_driver_t *menu_disp = NULL; -bool menu_display_ctl(enum menu_display_ctl_state state, void *data) +void menu_display_blend_begin(void) { - unsigned width, height; - static gfx_coord_array_t menu_disp_ca; - static unsigned menu_display_framebuf_width = 0; - static unsigned menu_display_framebuf_height = 0; - static size_t menu_display_framebuf_pitch = 0; - static int menu_display_font_size = 0; - static unsigned menu_display_header_height = 0; - static bool menu_display_msg_force = false; - static bool menu_display_font_alloc_framebuf = false; - static bool menu_display_framebuf_dirty = false; - static const uint8_t *menu_display_font_framebuf = NULL; - static void *menu_display_font_buf = NULL; - static msg_queue_t *menu_display_msg_queue = NULL; - static menu_display_ctx_driver_t *menu_disp = NULL; - settings_t *settings = config_get_ptr(); + if (!menu_disp || !menu_disp->blend_begin) + return; + menu_disp->blend_begin(); +} - switch (state) +void menu_display_blend_end(void) +{ + if (!menu_disp || !menu_disp->blend_end) + return; + menu_disp->blend_end(); +} + +void menu_display_font_main_deinit(void) +{ + if (menu_display_font_buf) + font_driver_free(menu_display_font_buf); + menu_display_font_buf = NULL; + menu_display_font_size = 0; +} + +bool menu_display_font_main_init(menu_display_ctx_font_t *font) +{ + menu_display_font_main_deinit(); + if (!font || !menu_disp) + return false; + + if (!menu_disp->font_init_first) + return false; + + if (!menu_disp->font_init_first(&menu_display_font_buf, + video_driver_get_ptr(false), + font->path, font->size)) + return false; + + menu_display_font_size = font->size; + return true; +} + +void menu_display_font_bind_block(void *block) +{ + font_driver_bind_block(menu_display_font_buf, block); +} + +bool menu_display_font_flush_block(void) +{ + if (!menu_display_font_buf) + return false; + + font_driver_flush(menu_display_font_buf); + font_driver_bind_block(menu_display_font_buf, NULL); + return true; +} + +void menu_display_framebuffer_deinit(void) +{ + menu_display_framebuf_width = 0; + menu_display_framebuf_height = 0; + menu_display_framebuf_pitch = 0; +} + +void menu_display_deinit(void) +{ + if (menu_display_msg_queue) + msg_queue_free(menu_display_msg_queue); + gfx_coord_array_free(&menu_disp_ca); + menu_display_msg_queue = NULL; + menu_display_msg_force = false; + menu_display_header_height = 0; + menu_disp = NULL; + + menu_animation_ctl(MENU_ANIMATION_CTL_DEINIT, NULL); + menu_display_framebuffer_deinit(); +} + +bool menu_display_init(void) +{ + retro_assert(menu_display_msg_queue = msg_queue_new(8)); + menu_disp_ca.allocated = 0; + return true; +} + +void menu_display_coords_array_reset(void) +{ + menu_disp_ca.coords.vertices = 0; +} + +gfx_coord_array_t *menu_display_get_coords_array(void) +{ + return &menu_disp_ca; +} + +void *menu_display_get_font_buffer(void) +{ + return menu_display_font_buf; +} + +void menu_display_set_font_buffer(void *buffer) +{ + menu_display_font_buf = buffer; +} + +const uint8_t *menu_display_get_font_framebuffer(void) +{ + return menu_display_font_framebuf; +} + +void menu_display_set_font_framebuffer(const uint8_t *buffer) +{ + menu_display_font_framebuf = buffer; +} + +bool menu_display_libretro_running(void) +{ + settings_t *settings = config_get_ptr(); + if (!settings->menu.pause_libretro) { - case MENU_DISPLAY_CTL_BLEND_BEGIN: - if (!menu_disp || !menu_disp->blend_begin) - return false; - menu_disp->blend_begin(); - break; - case MENU_DISPLAY_CTL_BLEND_END: - if (!menu_disp || !menu_disp->blend_end) - return false; - menu_disp->blend_end(); - break; - case MENU_DISPLAY_CTL_FONT_MAIN_DEINIT: - if (menu_display_font_buf) - font_driver_free(menu_display_font_buf); - menu_display_font_buf = NULL; - menu_display_font_size = 0; - break; - case MENU_DISPLAY_CTL_FONT_MAIN_INIT: - { - menu_display_ctx_font_t *font = (menu_display_ctx_font_t*)data; - - menu_display_ctl(MENU_DISPLAY_CTL_FONT_MAIN_DEINIT, NULL); - - if (!font || !menu_disp) - return false; - - if (!menu_disp->font_init_first) - return false; - - if (!menu_disp->font_init_first(&menu_display_font_buf, - video_driver_get_ptr(false), - font->path, font->size)) - return false; - - menu_display_font_size = font->size; - } - break; - case MENU_DISPLAY_CTL_FONT_BIND_BLOCK: - font_driver_bind_block(menu_display_font_buf, data); - break; - case MENU_DISPLAY_CTL_FONT_FLUSH_BLOCK: - if (!menu_display_font_buf) - return false; - - font_driver_flush(menu_display_font_buf); - font_driver_bind_block(menu_display_font_buf, NULL); - break; - case MENU_DISPLAY_CTL_FRAMEBUF_DEINIT: - menu_display_framebuf_width = 0; - menu_display_framebuf_height = 0; - menu_display_framebuf_pitch = 0; - break; - case MENU_DISPLAY_CTL_DEINIT: - if (menu_display_msg_queue) - msg_queue_free(menu_display_msg_queue); - gfx_coord_array_free(&menu_disp_ca); - menu_display_msg_queue = NULL; - menu_display_msg_force = false; - menu_display_header_height = 0; - menu_disp = NULL; - - menu_animation_ctl(MENU_ANIMATION_CTL_DEINIT, NULL); - menu_display_ctl(MENU_DISPLAY_CTL_FRAMEBUF_DEINIT, NULL); - break; - case MENU_DISPLAY_CTL_INIT: - retro_assert(menu_display_msg_queue = msg_queue_new(8)); - menu_disp_ca.allocated = 0; - break; - case MENU_DISPLAY_CTL_COORDS_ARRAY_RESET: - menu_disp_ca.coords.vertices = 0; - break; - case MENU_DISPLAY_CTL_COORDS_ARRAY_GET: - { - void **ptr = (void**)data; - if (!ptr) - return false; - *ptr = &menu_disp_ca; - } - break; - case MENU_DISPLAY_CTL_SET_STUB_DRAW_FRAME: - break; - case MENU_DISPLAY_CTL_UNSET_STUB_DRAW_FRAME: - break; - case MENU_DISPLAY_CTL_FONT_BUF: - { - void **ptr = (void**)data; - if (!ptr) - return false; - *ptr = menu_display_font_buf; - } - break; - case MENU_DISPLAY_CTL_SET_FONT_BUF: - { - void **ptr = (void**)data; - if (!ptr) - return false; - menu_display_font_buf = *ptr; - } - break; - case MENU_DISPLAY_CTL_FONT_FB: - { - uint8_t **ptr = (uint8_t**)data; - if (!ptr) - return false; - *ptr = (uint8_t*)menu_display_font_framebuf; - } - break; - case MENU_DISPLAY_CTL_SET_FONT_FB: - { - uint8_t **ptr = (uint8_t**)data; - if (!ptr) - return false; - menu_display_font_framebuf = *ptr; - } - break; - case MENU_DISPLAY_CTL_LIBRETRO_RUNNING: - if (!settings->menu.pause_libretro) - if (rarch_ctl(RARCH_CTL_IS_INITED, NULL) - && !rarch_ctl(RARCH_CTL_IS_DUMMY_CORE, NULL)) - return true; - return false; - case MENU_DISPLAY_CTL_LIBRETRO: - video_driver_set_texture_enable(true, false); - - if (menu_display_ctl(MENU_DISPLAY_CTL_LIBRETRO_RUNNING, NULL)) - { - bool libretro_input_is_blocked = - input_driver_ctl( - RARCH_INPUT_CTL_IS_LIBRETRO_INPUT_BLOCKED, NULL); - - if (!libretro_input_is_blocked) - input_driver_ctl( - RARCH_INPUT_CTL_SET_LIBRETRO_INPUT_BLOCKED, NULL); - - core_run(); - - input_driver_ctl( - RARCH_INPUT_CTL_UNSET_LIBRETRO_INPUT_BLOCKED, NULL); - return true; - } - - return video_driver_ctl(RARCH_DISPLAY_CTL_CACHED_FRAME_RENDER, NULL); - case MENU_DISPLAY_CTL_SET_WIDTH: - { - unsigned *ptr = (unsigned*)data; - if (!ptr) - return false; - menu_display_framebuf_width = *ptr; - } - break; - case MENU_DISPLAY_CTL_WIDTH: - { - unsigned *ptr = (unsigned*)data; - if (!ptr) - return false; - *ptr = menu_display_framebuf_width; - } - break; - case MENU_DISPLAY_CTL_HEIGHT: - { - unsigned *ptr = (unsigned*)data; - if (!ptr) - return false; - *ptr = menu_display_framebuf_height; - } - break; - case MENU_DISPLAY_CTL_HEADER_HEIGHT: - { - unsigned *ptr = (unsigned*)data; - if (!ptr) - return false; - *ptr = menu_display_header_height; - } - break; - case MENU_DISPLAY_CTL_SET_HEADER_HEIGHT: - { - unsigned *ptr = (unsigned*)data; - if (!ptr) - return false; - menu_display_header_height = *ptr; - } - break; - case MENU_DISPLAY_CTL_FONT_SIZE: - { - unsigned *ptr = (unsigned*)data; - if (!ptr) - return false; - *ptr = menu_display_font_size; - } - break; - case MENU_DISPLAY_CTL_SET_FONT_SIZE: - { - unsigned *ptr = (unsigned*)data; - if (!ptr) - return false; - menu_display_font_size = *ptr; - } - break; - case MENU_DISPLAY_CTL_SET_HEIGHT: - { - unsigned *ptr = (unsigned*)data; - if (!ptr) - return false; - menu_display_framebuf_height = *ptr; - } - break; - case MENU_DISPLAY_CTL_FB_PITCH: - { - size_t *ptr = (size_t*)data; - if (!ptr) - return false; - *ptr = menu_display_framebuf_pitch; - } - break; - case MENU_DISPLAY_CTL_SET_FB_PITCH: - { - size_t *ptr = (size_t*)data; - if (!ptr) - return false; - menu_display_framebuf_pitch = *ptr; - } - break; - case MENU_DISPLAY_CTL_MSG_FORCE: - { - bool *ptr = (bool*)data; - if (!ptr) - return false; - *ptr = menu_display_msg_force; - } - break; - case MENU_DISPLAY_CTL_SET_MSG_FORCE: - { - bool *ptr = (bool*)data; - if (!ptr) - return false; - menu_display_msg_force = *ptr; - } - break; - case MENU_DISPLAY_CTL_FONT_DATA_INIT: - { - bool *ptr = (bool*)data; - if (!ptr) - return false; - *ptr = menu_display_font_alloc_framebuf; - } + if (rarch_ctl(RARCH_CTL_IS_INITED, NULL) + && !rarch_ctl(RARCH_CTL_IS_DUMMY_CORE, NULL)) return true; - case MENU_DISPLAY_CTL_SET_FONT_DATA_INIT: - { - bool *ptr = (bool*)data; - if (!ptr) - return false; - menu_display_font_alloc_framebuf = *ptr; - } - break; - case MENU_DISPLAY_CTL_UPDATE_PENDING: - { - if (menu_animation_ctl(MENU_ANIMATION_CTL_IS_ACTIVE, NULL)) - return true; - if (menu_display_ctl( - MENU_DISPLAY_CTL_GET_FRAMEBUFFER_DIRTY_FLAG, NULL)) - return true; - } - return false; - case MENU_DISPLAY_CTL_SET_VIEWPORT: - video_driver_get_size(&width, &height); - video_driver_set_viewport(width, - height, true, false); - break; - case MENU_DISPLAY_CTL_UNSET_VIEWPORT: - video_driver_get_size(&width, &height); - video_driver_set_viewport(width, - height, false, true); - break; - case MENU_DISPLAY_CTL_GET_FRAMEBUFFER_DIRTY_FLAG: - return menu_display_framebuf_dirty; - case MENU_DISPLAY_CTL_SET_FRAMEBUFFER_DIRTY_FLAG: - menu_display_framebuf_dirty = true; - break; - case MENU_DISPLAY_CTL_UNSET_FRAMEBUFFER_DIRTY_FLAG: - menu_display_framebuf_dirty = false; - break; - case MENU_DISPLAY_CTL_GET_DPI: - { - gfx_ctx_metrics_t metrics; - float *dpi = (float*)data; - *dpi = menu_dpi_override_value; + } + return false; +} - if (!settings) - return true; +bool menu_display_libretro(void) +{ + video_driver_set_texture_enable(true, false); - metrics.type = DISPLAY_METRIC_DPI; - metrics.value = dpi; + if (menu_display_libretro_running()) + { + bool libretro_input_is_blocked = + input_driver_ctl( + RARCH_INPUT_CTL_IS_LIBRETRO_INPUT_BLOCKED, NULL); - if (settings->menu.dpi.override_enable) - *dpi = settings->menu.dpi.override_value; - else if (!gfx_ctx_ctl(GFX_CTL_GET_METRICS, &metrics) || !*dpi) - *dpi = menu_dpi_override_value; - } - break; - case MENU_DISPLAY_CTL_INIT_FIRST_DRIVER: - { - unsigned i; + if (!libretro_input_is_blocked) + input_driver_ctl( + RARCH_INPUT_CTL_SET_LIBRETRO_INPUT_BLOCKED, NULL); - for (i = 0; menu_display_ctx_drivers[i]; i++) - { - if (!menu_display_check_compatibility( - menu_display_ctx_drivers[i]->type)) - continue; + core_run(); - RARCH_LOG("Found menu display driver: \"%s\".\n", - menu_display_ctx_drivers[i]->ident); - menu_disp = menu_display_ctx_drivers[i]; - return true; - } - } - return false; - case MENU_DISPLAY_CTL_RESTORE_CLEAR_COLOR: - if (!menu_disp || !menu_disp->restore_clear_color) - return false; - menu_disp->restore_clear_color(); - break; - case MENU_DISPLAY_CTL_CLEAR_COLOR: - if (!menu_disp || !menu_disp->clear_color) - return false; - menu_disp->clear_color((menu_display_ctx_clearcolor_t*)data); - break; - case MENU_DISPLAY_CTL_DRAW: - { - menu_display_ctx_draw_t *draw = (menu_display_ctx_draw_t*)data; - if (!menu_disp || !draw || !menu_disp->draw) - return false; - /* TODO - edge case */ - if (draw->height <= 0) - draw->height = 1; - - menu_disp->draw(draw); - } - break; - case MENU_DISPLAY_CTL_DRAW_PIPELINE: - { - menu_display_ctx_draw_t *draw = (menu_display_ctx_draw_t*)data; - if (!menu_disp || !draw || !menu_disp->draw_pipeline) - return false; - menu_disp->draw_pipeline(draw); - } - break; - case MENU_DISPLAY_CTL_DRAW_BG: - { - struct gfx_coords coords; - const float *new_vertex = NULL; - const float *new_tex_coord = NULL; - menu_display_ctx_draw_t *draw = (menu_display_ctx_draw_t*)data; - if (!menu_disp || !draw) - return false; - - new_vertex = draw->vertex; - new_tex_coord = draw->tex_coord; - - if (!new_vertex) - new_vertex = menu_disp->get_default_vertices(); - if (!new_tex_coord) - new_tex_coord = menu_disp->get_default_tex_coords(); - - coords.vertices = draw->vertex_count; - coords.vertex = new_vertex; - coords.tex_coord = new_tex_coord; - coords.lut_tex_coord = new_tex_coord; - coords.color = (const float*)draw->color; - - draw->coords = &coords; - - if (!draw->texture) - draw->texture = menu_display_white_texture; - - draw->matrix_data = (math_matrix_4x4*)menu_disp->get_default_mvp(); - } - break; - case MENU_DISPLAY_CTL_DRAW_GRADIENT: - { - menu_display_ctx_draw_t *draw = (menu_display_ctx_draw_t*)data; - - draw->texture = 0; - draw->x = 0; - draw->y = 0; - - menu_display_ctl(MENU_DISPLAY_CTL_DRAW_BG, draw); - menu_display_ctl(MENU_DISPLAY_CTL_DRAW, draw); - } - break; - case MENU_DISPLAY_CTL_ROTATE_Z: - { - math_matrix_4x4 matrix_rotated, matrix_scaled; - math_matrix_4x4 *b = NULL; - menu_display_ctx_rotate_draw_t *draw = - (menu_display_ctx_rotate_draw_t*)data; - - if (!draw || !menu_disp || !menu_disp->get_default_mvp) - return false; - - b = (math_matrix_4x4*)menu_disp->get_default_mvp(); - - matrix_4x4_rotate_z(&matrix_rotated, draw->rotation); - matrix_4x4_multiply(draw->matrix, &matrix_rotated, b); - - if (!draw->scale_enable) - return false; - - matrix_4x4_scale(&matrix_scaled, - draw->scale_x, draw->scale_y, draw->scale_z); - matrix_4x4_multiply(draw->matrix, &matrix_scaled, draw->matrix); - } - break; - case MENU_DISPLAY_CTL_TEX_COORDS_GET: - { - menu_display_ctx_coord_draw_t *draw = - (menu_display_ctx_coord_draw_t*)data; - if (!draw) - return false; - - if (!menu_disp || !menu_disp->get_default_tex_coords) - return false; - - draw->ptr = menu_disp->get_default_tex_coords(); - } - break; - case MENU_DISPLAY_CTL_TIMEDATE: - menu_display_timedate(data); - break; - case MENU_DISPLAY_CTL_NONE: - default: - break; + input_driver_ctl( + RARCH_INPUT_CTL_UNSET_LIBRETRO_INPUT_BLOCKED, NULL); + return true; } + return video_driver_ctl(RARCH_DISPLAY_CTL_CACHED_FRAME_RENDER, NULL); +} + +void menu_display_set_width(unsigned width) +{ + menu_display_framebuf_width = width; +} + +unsigned menu_display_get_width(void) +{ + return menu_display_framebuf_width; +} + +void menu_display_set_height(unsigned height) +{ + menu_display_framebuf_height = height; +} + +unsigned menu_display_get_height(void) +{ + return menu_display_framebuf_height; +} + +void menu_display_set_header_height(unsigned height) +{ + menu_display_header_height = height; +} + +unsigned menu_display_get_header_height(void) +{ + return menu_display_header_height; +} + +unsigned menu_display_get_font_size(void) +{ + return menu_display_font_size; +} + +void menu_display_set_font_size(unsigned size) +{ + menu_display_font_size = size; +} + +size_t menu_display_get_framebuffer_pitch(void) +{ + return menu_display_framebuf_pitch; +} + +void menu_display_set_framebuffer_pitch(size_t pitch) +{ + menu_display_framebuf_pitch = pitch; +} + +bool menu_display_get_msg_force(void) +{ + return menu_display_msg_force; +} + +void menu_display_set_msg_force(bool state) +{ + menu_display_msg_force = state; +} + +bool menu_display_get_font_data_init(void) +{ + return menu_display_font_alloc_framebuf; +} + +void menu_display_set_font_data_init(bool state) +{ + menu_display_font_alloc_framebuf = state; +} + +bool menu_display_get_update_pending(void) +{ + if (menu_animation_ctl(MENU_ANIMATION_CTL_IS_ACTIVE, NULL)) + return true; + if (menu_display_get_framebuffer_dirty_flag()) + return true; + return false; +} + +void menu_display_set_viewport(void) +{ + unsigned width, height; + video_driver_get_size(&width, &height); + video_driver_set_viewport(width, height, true, false); +} + +void menu_display_unset_viewport(void) +{ + unsigned width, height; + video_driver_get_size(&width, &height); + video_driver_set_viewport(width, height, false, true); +} + +bool menu_display_get_framebuffer_dirty_flag(void) +{ + return menu_display_framebuf_dirty; +} + +void menu_display_set_framebuffer_dirty_flag(void) +{ + menu_display_framebuf_dirty = true; +} + +void menu_display_unset_framebuffer_dirty_flag(void) +{ + menu_display_framebuf_dirty = false; +} + +float menu_display_get_dpi(void) +{ + settings_t *settings = config_get_ptr(); + gfx_ctx_metrics_t metrics; + float dpi = menu_dpi_override_value; + + if (!settings) + return true; + + metrics.type = DISPLAY_METRIC_DPI; + metrics.value = &dpi; + + if (settings->menu.dpi.override_enable) + return settings->menu.dpi.override_value; + else if (!gfx_ctx_ctl(GFX_CTL_GET_METRICS, &metrics) || !dpi) + return menu_dpi_override_value; + + return dpi; +} + +bool menu_display_init_first_driver(void) +{ + unsigned i; + + for (i = 0; menu_display_ctx_drivers[i]; i++) + { + if (!menu_display_check_compatibility( + menu_display_ctx_drivers[i]->type)) + continue; + + RARCH_LOG("Found menu display driver: \"%s\".\n", + menu_display_ctx_drivers[i]->ident); + menu_disp = menu_display_ctx_drivers[i]; + return true; + } + return false; +} + +bool menu_display_restore_clear_color(void) +{ + if (!menu_disp || !menu_disp->restore_clear_color) + return false; + menu_disp->restore_clear_color(); + return true; +} + +void menu_display_clear_color(menu_display_ctx_clearcolor_t *color) +{ + if (!menu_disp || !menu_disp->clear_color) + return; + menu_disp->clear_color(color); +} + +void menu_display_draw(menu_display_ctx_draw_t *draw) +{ + if (!menu_disp || !draw || !menu_disp->draw) + return; + + /* TODO - edge case */ + if (draw->height <= 0) + draw->height = 1; + + menu_disp->draw(draw); +} + +void menu_display_draw_pipeline(menu_display_ctx_draw_t *draw) +{ + if (!menu_disp || !draw || !menu_disp->draw_pipeline) + return; + menu_disp->draw_pipeline(draw); +} + +void menu_display_draw_bg(menu_display_ctx_draw_t *draw) +{ + struct gfx_coords coords; + const float *new_vertex = NULL; + const float *new_tex_coord = NULL; + if (!menu_disp || !draw) + return; + + new_vertex = draw->vertex; + new_tex_coord = draw->tex_coord; + + if (!new_vertex) + new_vertex = menu_disp->get_default_vertices(); + if (!new_tex_coord) + new_tex_coord = menu_disp->get_default_tex_coords(); + + coords.vertices = draw->vertex_count; + coords.vertex = new_vertex; + coords.tex_coord = new_tex_coord; + coords.lut_tex_coord = new_tex_coord; + coords.color = (const float*)draw->color; + + draw->coords = &coords; + + if (!draw->texture) + draw->texture = menu_display_white_texture; + + draw->matrix_data = (math_matrix_4x4*)menu_disp->get_default_mvp(); +} + +void menu_display_draw_gradient(menu_display_ctx_draw_t *draw) +{ + draw->texture = 0; + draw->x = 0; + draw->y = 0; + + menu_display_draw_bg(draw); + menu_display_draw(draw); +} + +void menu_display_rotate_z(menu_display_ctx_rotate_draw_t *draw) +{ + math_matrix_4x4 matrix_rotated, matrix_scaled; + math_matrix_4x4 *b = NULL; + + if (!draw || !menu_disp || !menu_disp->get_default_mvp) + return; + + b = (math_matrix_4x4*)menu_disp->get_default_mvp(); + + matrix_4x4_rotate_z(&matrix_rotated, draw->rotation); + matrix_4x4_multiply(draw->matrix, &matrix_rotated, b); + + if (!draw->scale_enable) + return; + + matrix_4x4_scale(&matrix_scaled, + draw->scale_x, draw->scale_y, draw->scale_z); + matrix_4x4_multiply(draw->matrix, &matrix_scaled, draw->matrix); +} + +bool menu_display_get_tex_coords(menu_display_ctx_coord_draw_t *draw) +{ + if (!draw) + return false; + + if (!menu_disp || !menu_disp->get_default_tex_coords) + return false; + + draw->ptr = menu_disp->get_default_tex_coords(); return true; } @@ -621,7 +579,7 @@ void menu_display_draw_cursor( bool cursor_visible = settings->video.fullscreen || !video_driver_ctl(RARCH_DISPLAY_CTL_HAS_WINDOWED, NULL); - if ( !settings->menu.mouse.enable) + if (!settings->menu.mouse.enable) return; if (!cursor_visible) return; @@ -632,7 +590,7 @@ void menu_display_draw_cursor( coords.lut_tex_coord = NULL; coords.color = (const float*)color; - menu_display_ctl(MENU_DISPLAY_CTL_BLEND_BEGIN, NULL); + menu_display_blend_begin(); draw.x = x - (cursor_size / 2); draw.y = (int)height - y - (cursor_size / 2); @@ -643,8 +601,8 @@ void menu_display_draw_cursor( draw.texture = texture; draw.prim_type = MENU_DISPLAY_PRIM_TRIANGLESTRIP; - menu_display_ctl(MENU_DISPLAY_CTL_DRAW, &draw); - menu_display_ctl(MENU_DISPLAY_CTL_BLEND_END, NULL); + menu_display_draw(&draw); + menu_display_blend_end(); } static INLINE float menu_display_scalef(float val, @@ -668,7 +626,7 @@ void menu_display_push_quad( float vertex[8]; gfx_coord_array_t *ca = NULL; - menu_display_ctl(MENU_DISPLAY_CTL_COORDS_ARRAY_GET, &ca); + ca = menu_display_get_coords_array(); vertex[0] = x1 / (float)width; vertex[1] = y1 / (float)height; @@ -681,7 +639,7 @@ void menu_display_push_quad( coord_draw.ptr = NULL; - menu_display_ctl(MENU_DISPLAY_CTL_TEX_COORDS_GET, &coord_draw); + menu_display_get_tex_coords(&coord_draw); coords.color = colors; coords.vertex = vertex; @@ -794,8 +752,7 @@ void menu_display_draw_text(const char *msg, params->x = params->x; params->y = params->y; - menu_display_ctl(MENU_DISPLAY_CTL_FONT_BUF, &fb_buf); - + fb_buf = menu_display_get_font_buffer(); video_driver_set_osd_msg(msg, params, fb_buf); } diff --git a/menu/menu_display.h b/menu/menu_display.h index 2fd55f8162..2570ca432e 100644 --- a/menu/menu_display.h +++ b/menu/menu_display.h @@ -29,61 +29,6 @@ extern "C" { #endif -enum menu_display_ctl_state -{ - MENU_DISPLAY_CTL_NONE = 0, - MENU_DISPLAY_CTL_SET_VIEWPORT, - MENU_DISPLAY_CTL_UNSET_VIEWPORT, - MENU_DISPLAY_CTL_GET_FRAMEBUFFER_DIRTY_FLAG, - MENU_DISPLAY_CTL_SET_FRAMEBUFFER_DIRTY_FLAG, - MENU_DISPLAY_CTL_UNSET_FRAMEBUFFER_DIRTY_FLAG, - MENU_DISPLAY_CTL_GET_DPI, - MENU_DISPLAY_CTL_UPDATE_PENDING, - MENU_DISPLAY_CTL_WIDTH, - MENU_DISPLAY_CTL_HEIGHT, - MENU_DISPLAY_CTL_HEADER_HEIGHT, - MENU_DISPLAY_CTL_SET_HEADER_HEIGHT, - MENU_DISPLAY_CTL_SET_WIDTH, - MENU_DISPLAY_CTL_SET_HEIGHT, - MENU_DISPLAY_CTL_FB_PITCH, - MENU_DISPLAY_CTL_SET_FB_PITCH, - MENU_DISPLAY_CTL_LIBRETRO, - MENU_DISPLAY_CTL_LIBRETRO_RUNNING, - MENU_DISPLAY_CTL_SET_STUB_DRAW_FRAME, - MENU_DISPLAY_CTL_UNSET_STUB_DRAW_FRAME, - MENU_DISPLAY_CTL_FRAMEBUF_DEINIT, - MENU_DISPLAY_CTL_DEINIT, - MENU_DISPLAY_CTL_INIT, - MENU_DISPLAY_CTL_INIT_FIRST_DRIVER, - MENU_DISPLAY_CTL_FONT_DATA_INIT, - MENU_DISPLAY_CTL_SET_FONT_DATA_INIT, - MENU_DISPLAY_CTL_FONT_SIZE, - MENU_DISPLAY_CTL_SET_FONT_SIZE, - MENU_DISPLAY_CTL_MSG_FORCE, - MENU_DISPLAY_CTL_SET_MSG_FORCE, - MENU_DISPLAY_CTL_FONT_BUF, - MENU_DISPLAY_CTL_FONT_FLUSH_BLOCK, - MENU_DISPLAY_CTL_SET_FONT_BUF, - MENU_DISPLAY_CTL_FONT_FB, - MENU_DISPLAY_CTL_SET_FONT_FB, - MENU_DISPLAY_CTL_FONT_MAIN_DEINIT, - MENU_DISPLAY_CTL_FONT_MAIN_INIT, - MENU_DISPLAY_CTL_FONT_BIND_BLOCK, - MENU_DISPLAY_CTL_BLEND_BEGIN, - MENU_DISPLAY_CTL_BLEND_END, - MENU_DISPLAY_CTL_RESTORE_CLEAR_COLOR, - MENU_DISPLAY_CTL_CLEAR_COLOR, - MENU_DISPLAY_CTL_DRAW, - MENU_DISPLAY_CTL_DRAW_BG, - MENU_DISPLAY_CTL_DRAW_GRADIENT, - MENU_DISPLAY_CTL_DRAW_PIPELINE, - MENU_DISPLAY_CTL_ROTATE_Z, - MENU_DISPLAY_CTL_TEX_COORDS_GET, - MENU_DISPLAY_CTL_TIMEDATE, - MENU_DISPLAY_CTL_COORDS_ARRAY_RESET, - MENU_DISPLAY_CTL_COORDS_ARRAY_GET -}; - enum menu_display_prim_type { MENU_DISPLAY_PRIM_NONE = 0, @@ -177,7 +122,62 @@ typedef struct menu_display_ctx_font typedef uintptr_t menu_texture_item; -bool menu_display_ctl(enum menu_display_ctl_state state, void *data); +void menu_display_blend_begin(void); +void menu_display_blend_end(void); + +void menu_display_font_main_deinit(void); +bool menu_display_font_main_init(menu_display_ctx_font_t *font); +void menu_display_font_bind_block(void *block); +bool menu_display_font_flush_block(void); + +void menu_display_framebuffer_deinit(void); + +void menu_display_deinit(void); +bool menu_display_init(void); + +void menu_display_coords_array_reset(void); +gfx_coord_array_t *menu_display_get_coords_array(void); +void *menu_display_get_font_buffer(void); +void menu_display_set_font_buffer(void *buffer); +const uint8_t *menu_display_get_font_framebuffer(void); +void menu_display_set_font_framebuffer(const uint8_t *buffer); +bool menu_display_libretro_running(void); +bool menu_display_libretro(void); + +void menu_display_set_width(unsigned width); +unsigned menu_display_get_width(void); +void menu_display_set_height(unsigned height); +unsigned menu_display_get_height(void); +void menu_display_set_header_height(unsigned height); +unsigned menu_display_get_header_height(void); +unsigned menu_display_get_font_size(void); +void menu_display_set_font_size(unsigned size); +size_t menu_display_get_framebuffer_pitch(void); +void menu_display_set_framebuffer_pitch(size_t pitch); + +bool menu_display_get_msg_force(void); +void menu_display_set_msg_force(bool state); +bool menu_display_get_font_data_init(void); +void menu_display_set_font_data_init(bool state); +bool menu_display_get_update_pending(void); +void menu_display_set_viewport(void); +void menu_display_unset_viewport(void); +bool menu_display_get_framebuffer_dirty_flag(void); +void menu_display_set_framebuffer_dirty_flag(void); +void menu_display_unset_framebuffer_dirty_flag(void); +float menu_display_get_dpi(void); +bool menu_display_init_first_driver(void); +bool menu_display_restore_clear_color(void); +void menu_display_clear_color(menu_display_ctx_clearcolor_t *color); +void menu_display_draw(menu_display_ctx_draw_t *draw); + +void menu_display_draw_pipeline(menu_display_ctx_draw_t *draw); +void menu_display_draw_bg(menu_display_ctx_draw_t *draw); +void menu_display_draw_gradient(menu_display_ctx_draw_t *draw); +void menu_display_rotate_z(menu_display_ctx_rotate_draw_t *draw); +bool menu_display_get_tex_coords(menu_display_ctx_coord_draw_t *draw); + +void menu_display_timedate(menu_display_ctx_datetime_t *datetime); void menu_display_handle_wallpaper_upload(void *task_data, void *user_data, const char *err); diff --git a/menu/menu_driver.c b/menu/menu_driver.c index 1f0517c450..13c08da017 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -185,7 +185,7 @@ static bool menu_init(menu_handle_t *menu_data) menu_driver_ctl(RARCH_MENU_CTL_SHADER_MANAGER_INIT, NULL); - if (!menu_display_ctl(MENU_DISPLAY_CTL_INIT, NULL)) + if (!menu_display_init()) return false; return true; @@ -445,7 +445,7 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data) BIT64_SET(menu_driver_data->state, MENU_STATE_RENDER_FRAMEBUFFER); if (BIT64_GET(menu_driver_data->state, MENU_STATE_RENDER_FRAMEBUFFER)) - menu_display_ctl(MENU_DISPLAY_CTL_SET_FRAMEBUFFER_DIRTY_FLAG, NULL); + menu_display_set_framebuffer_dirty_flag(); if (BIT64_GET(menu_driver_data->state, MENU_STATE_RENDER_MESSAGEBOX) && !string_is_empty(menu_driver_data->menu_state.msg)) @@ -468,7 +468,7 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data) if (menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL) && !runloop_ctl(RUNLOOP_CTL_IS_IDLE, NULL)) - menu_display_ctl(MENU_DISPLAY_CTL_LIBRETRO, NULL); + menu_display_libretro(); menu_driver_ctl(RARCH_MENU_CTL_SET_TEXTURE, NULL); @@ -562,7 +562,7 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data) menu_userdata = NULL; menu_driver_ctl(RARCH_MENU_CTL_SYSTEM_INFO_DEINIT, NULL); - menu_display_ctl(MENU_DISPLAY_CTL_DEINIT, NULL); + menu_display_deinit(); menu_entries_ctl(MENU_ENTRIES_CTL_DEINIT, NULL); event_cmd_ctl(EVENT_CMD_HISTORY_DEINIT, NULL); @@ -836,11 +836,9 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data) if (menu_driver_ctl(RARCH_MENU_CTL_IS_PENDING_QUICK_MENU, NULL)) { - bool msg_force = true; - menu_driver_ctl(RARCH_MENU_CTL_UNSET_PENDING_QUICK_MENU, NULL); menu_entries_flush_stack(NULL, MENU_SETTINGS); - menu_display_ctl(MENU_DISPLAY_CTL_SET_MSG_FORCE, &msg_force); + menu_display_set_msg_force(true); generic_action_ok_displaylist_push("", "", 0, 0, 0, ACTION_OK_DL_CONTENT_SETTINGS); diff --git a/menu/menu_input.c b/menu/menu_input.c index 5747af9f32..78f8581592 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -825,8 +825,8 @@ static int menu_input_pointer(unsigned *action) const struct retro_keybind *binds[MAX_USERS] = {NULL}; menu_input_t *menu_input = menu_input_get_ptr(); - menu_display_ctl(MENU_DISPLAY_CTL_WIDTH, &fb_width); - menu_display_ctl(MENU_DISPLAY_CTL_HEIGHT, &fb_height); + fb_width = menu_display_get_width(); + fb_height = menu_display_get_height(); pointer_device = menu_driver_ctl(RARCH_MENU_CTL_IS_SET_TEXTURE, NULL) ? RETRO_DEVICE_POINTER : RARCH_DEVICE_POINTER_SCREEN; @@ -940,7 +940,7 @@ static int menu_input_mouse_post_iterate(uint64_t *input_mouse, menu_input_t *menu_input = menu_input_get_ptr(); menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection); - menu_display_ctl(MENU_DISPLAY_CTL_HEADER_HEIGHT, &header_height); + header_height = menu_display_get_header_height(); BIT64_SET(*input_mouse, MENU_MOUSE_ACTION_BUTTON_L); @@ -1068,7 +1068,6 @@ static int menu_input_pointer_post_iterate( menu_file_list_cbs_t *cbs, menu_entry_t *entry, unsigned action) { - unsigned header_height; size_t selection; static bool pointer_oldpressed[2]; static bool pointer_oldback = false; @@ -1088,7 +1087,6 @@ static int menu_input_pointer_post_iterate( return -1; if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection)) return -1; - menu_display_ctl(MENU_DISPLAY_CTL_HEADER_HEIGHT, &header_height); #ifdef HAVE_OVERLAY check_overlay = check_overlay || From ade5131833d4bcc11da57e497d2fdde81105c8f4 Mon Sep 17 00:00:00 2001 From: Hans-Kristian Arntzen Date: Sun, 8 May 2016 12:43:58 +0200 Subject: [PATCH 259/498] Vulkan: Move to SPIRV-Cross. --- .gitmodules | 6 +++--- Makefile.common | 8 ++++---- deps/SPIRV-Cross | 1 + gfx/drivers_shader/slang_reflection.cpp | 4 ++-- 4 files changed, 10 insertions(+), 9 deletions(-) create mode 160000 deps/SPIRV-Cross diff --git a/.gitmodules b/.gitmodules index 49f252a8ef..71d65bba2f 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,6 +1,6 @@ [submodule "deps/glslang/glslang"] path = deps/glslang/glslang url = git://github.com/KhronosGroup/glslang.git -[submodule "deps/spir2cross"] - path = deps/spir2cross - url = git://github.com/ARM-software/spir2cross +[submodule "deps/SPIRV-Cross"] + path = deps/SPIRV-Cross + url = git://github.com/KhronosGroup/SPIRV-Cross diff --git a/Makefile.common b/Makefile.common index 7ea3441a0f..39c1b13713 100644 --- a/Makefile.common +++ b/Makefile.common @@ -752,7 +752,7 @@ ifeq ($(HAVE_VULKAN), 1) $(wildcard deps/glslang/glslang/glslang/MachineIndependent/preprocessor/*.cpp) \ $(wildcard deps/glslang/glslang/glslang/OSDependent/$(GLSLANG_PLATFORM)/*.cpp) - SPIR2CROSS_SOURCES := deps/spir2cross/spir2cross.cpp + SPIRV_CROSS_SOURCES := deps/SPIRV-Cross/spirv_cross.cpp DEFINES += \ -Ideps/glslang/glslang/glslang/OSDependent/$(GLSLANG_PLATFORM) \ @@ -761,13 +761,13 @@ ifeq ($(HAVE_VULKAN), 1) -Ideps/glslang/glslang/glslang/Public \ -Ideps/glslang/glslang/SPIRV \ -Ideps/glslang \ - -Ideps/spir2cross + -Ideps/SPIRV-Cross CXXFLAGS += -Wno-switch -Wno-sign-compare -fno-strict-aliasing -Wno-maybe-uninitialized -Wno-reorder -I./gfx/include/vulkan CFLAGS += -I./gfx/include/vulkan GLSLANG_OBJ := $(GLSLANG_SOURCES:.cpp=.o) - SPIR2CROSS_OBJ := $(SPIR2CROSS_SOURCES:.cpp=.o) + SPIRV_CROSS_OBJ := $(SPIRV_CROSS_SOURCES:.cpp=.o) OBJ += gfx/drivers/vulkan.o \ gfx/common/vulkan_common.o \ @@ -776,7 +776,7 @@ ifeq ($(HAVE_VULKAN), 1) gfx/drivers_shader/glslang_util.o \ gfx/drivers_shader/slang_reflection.o \ $(GLSLANG_OBJ) \ - $(SPIR2CROSS_OBJ) + $(SPIRV_CROSS_OBJ) ifeq ($(HAVE_MENU_COMMON), 1) OBJ += menu/drivers_display/menu_display_vulkan.o endif diff --git a/deps/SPIRV-Cross b/deps/SPIRV-Cross new file mode 160000 index 0000000000..44ef367141 --- /dev/null +++ b/deps/SPIRV-Cross @@ -0,0 +1 @@ +Subproject commit 44ef367141f9935bc719c9cc25693a9055f61efa diff --git a/gfx/drivers_shader/slang_reflection.cpp b/gfx/drivers_shader/slang_reflection.cpp index 0715850fb7..748f11e00d 100644 --- a/gfx/drivers_shader/slang_reflection.cpp +++ b/gfx/drivers_shader/slang_reflection.cpp @@ -13,14 +13,14 @@ * If not, see . */ -#include "spir2cross.hpp" +#include "spirv_cross.hpp" #include "slang_reflection.hpp" #include #include #include "../../verbosity.h" using namespace std; -using namespace spir2cross; +using namespace spirv_cross; static bool slang_texture_semantic_is_array(slang_texture_semantic sem) { From d7234114365ebed8f4ce3b1224e87a81ceb01584 Mon Sep 17 00:00:00 2001 From: Hans-Kristian Arntzen Date: Sun, 8 May 2016 14:00:51 +0200 Subject: [PATCH 260/498] De ioctl video_driver. --- command_event.c | 39 +- configuration.c | 6 +- core_impl.c | 2 +- driver.c | 31 +- dynamic.c | 8 +- gfx/common/vulkan_common.c | 4 +- gfx/drivers/gl.c | 31 +- gfx/drivers/sdl_gfx.c | 11 +- gfx/drivers/vulkan.c | 16 +- gfx/drivers_context/drm_ctx.c | 4 +- gfx/drivers_context/wayland_ctx.c | 4 +- gfx/drivers_context/x_ctx.c | 10 +- gfx/drivers_context/xegl_ctx.c | 2 +- gfx/drivers_font/gl_raster_font.c | 2 +- gfx/font_driver.c | 2 +- gfx/video_context_driver.c | 3 +- gfx/video_driver.c | 1254 ++++++++++++++++------------- gfx/video_driver.h | 142 ++-- gfx/video_texture_image.c | 3 +- input/drivers/x11_input.c | 6 +- input/input_driver.c | 2 +- menu/cbs/menu_cbs_left.c | 3 +- menu/cbs/menu_cbs_right.c | 3 +- menu/drivers/materialui.c | 5 +- menu/drivers/rgui.c | 4 +- menu/drivers/xmb.c | 3 +- menu/drivers/zarch.c | 3 +- menu/menu_display.c | 4 +- menu/menu_setting.c | 23 +- record/record_driver.c | 25 +- retroarch.c | 2 +- runloop.c | 14 +- screenshot.c | 16 +- 33 files changed, 868 insertions(+), 819 deletions(-) diff --git a/command_event.c b/command_event.c index e5906d5be2..b91f71b738 100644 --- a/command_event.c +++ b/command_event.c @@ -1131,21 +1131,17 @@ bool event_cmd_ctl(enum event_command cmd, void *data) break; case EVENT_CMD_REINIT: { - struct retro_hw_render_callback *hwr = NULL; - video_driver_ctl(RARCH_DISPLAY_CTL_HW_CONTEXT_GET, &hwr); + struct retro_hw_render_callback *hwr = + video_driver_get_hw_context(); if (hwr->cache_context) - video_driver_ctl( - RARCH_DISPLAY_CTL_SET_VIDEO_CACHE_CONTEXT, NULL); + video_driver_set_video_cache_context(); else - video_driver_ctl( - RARCH_DISPLAY_CTL_UNSET_VIDEO_CACHE_CONTEXT, NULL); + video_driver_unset_video_cache_context(); - video_driver_ctl( - RARCH_DISPLAY_CTL_UNSET_VIDEO_CACHE_CONTEXT_ACK, NULL); + video_driver_unset_video_cache_context_ack(); event_cmd_ctl(EVENT_CMD_RESET_CONTEXT, NULL); - video_driver_ctl( - RARCH_DISPLAY_CTL_UNSET_VIDEO_CACHE_CONTEXT, NULL); + video_driver_unset_video_cache_context(); /* Poll input to avoid possibly stale data to corrupt things. */ input_driver_ctl(RARCH_INPUT_CTL_POLL, NULL); @@ -1276,7 +1272,7 @@ bool event_cmd_ctl(enum event_command cmd, void *data) audio_driver_dsp_filter_init(settings->path.audio_dsp_plugin); break; case EVENT_CMD_GPU_RECORD_DEINIT: - video_driver_ctl(RARCH_DISPLAY_CTL_GPU_RECORD_DEINIT, NULL); + video_driver_gpu_record_deinit(); break; case EVENT_CMD_RECORD_DEINIT: if (!recording_deinit()) @@ -1317,8 +1313,8 @@ bool event_cmd_ctl(enum event_command cmd, void *data) break; case EVENT_CMD_CORE_DEINIT: { - struct retro_hw_render_callback *hwr = NULL; - video_driver_ctl(RARCH_DISPLAY_CTL_HW_CONTEXT_GET, &hwr); + struct retro_hw_render_callback *hwr = + hwr = video_driver_get_hw_context(); event_deinit_core(true); if (hwr) @@ -1331,15 +1327,15 @@ bool event_cmd_ctl(enum event_command cmd, void *data) return false; break; case EVENT_CMD_VIDEO_APPLY_STATE_CHANGES: - video_driver_ctl(RARCH_DISPLAY_CTL_APPLY_STATE_CHANGES, NULL); + video_driver_apply_state_changes(); break; case EVENT_CMD_VIDEO_SET_NONBLOCKING_STATE: boolean = true; /* fall-through */ case EVENT_CMD_VIDEO_SET_BLOCKING_STATE: - video_driver_ctl(RARCH_DISPLAY_CTL_SET_NONBLOCK_STATE, &boolean); + video_driver_set_nonblock_state(boolean); break; case EVENT_CMD_VIDEO_SET_ASPECT_RATIO: - video_driver_ctl(RARCH_DISPLAY_CTL_SET_ASPECT_RATIO, NULL); + video_driver_set_aspect_ratio(); break; case EVENT_CMD_AUDIO_SET_NONBLOCKING_STATE: boolean = true; /* fall-through */ @@ -1371,8 +1367,7 @@ bool event_cmd_ctl(enum event_command cmd, void *data) struct retro_hw_render_callback hwr_copy; int flags = DRIVERS_CMD_ALL; - video_driver_ctl(RARCH_DISPLAY_CTL_HW_CONTEXT_GET, &hwr); - + hwr = video_driver_get_hw_context(); memcpy(&hwr_copy, hwr, sizeof(hwr_copy)); driver_ctl(RARCH_DRIVER_CTL_UNINIT, &flags); @@ -1427,7 +1422,7 @@ bool event_cmd_ctl(enum event_command cmd, void *data) event_cmd_ctl(EVENT_CMD_AUDIO_STOP, NULL); if (settings->video.black_frame_insertion) - video_driver_ctl(RARCH_DISPLAY_CTL_CACHED_FRAME_RENDER, NULL); + video_driver_cached_frame_render(); } else { @@ -1563,7 +1558,7 @@ bool event_cmd_ctl(enum event_command cmd, void *data) #endif break; case EVENT_CMD_FULLSCREEN_TOGGLE: - if (!video_driver_ctl(RARCH_DISPLAY_CTL_HAS_WINDOWED, NULL)) + if (!video_driver_has_windowed()) return false; /* If we go fullscreen we drop all drivers and @@ -1694,9 +1689,9 @@ bool event_cmd_ctl(enum event_command cmd, void *data) grab_mouse_state ? "yes" : "no"); if (grab_mouse_state) - video_driver_ctl(RARCH_DISPLAY_CTL_HIDE_MOUSE, NULL); + video_driver_hide_mouse(); else - video_driver_ctl(RARCH_DISPLAY_CTL_SHOW_MOUSE, NULL); + video_driver_show_mouse(); } break; case EVENT_CMD_PERFCNT_REPORT_FRONTEND_LOG: diff --git a/configuration.c b/configuration.c index f740debfc8..219cd5138b 100644 --- a/configuration.c +++ b/configuration.c @@ -720,7 +720,7 @@ static void config_set_defaults(void) settings->set_supports_no_game_enable = true; - video_driver_ctl(RARCH_DISPLAY_CTL_RESET_CUSTOM_VIEWPORT, NULL); + video_driver_reset_custom_viewport(); /* Make sure settings from other configs carry over into defaults * for another config. */ @@ -803,7 +803,7 @@ static void config_set_defaults(void) global->console.sound.system_bgm_enable = false; - video_driver_ctl(RARCH_DISPLAY_CTL_DEFAULT_SETTINGS, NULL); + video_driver_default_settings(); if (*g_defaults.dir.wallpapers) strlcpy(settings->directory.dynamic_wallpapers, @@ -2846,7 +2846,7 @@ bool config_save_file(const char *path) config_set_int(conf, "custom_viewport_y", settings->video_viewport_custom.y); - video_driver_ctl(RARCH_DISPLAY_CTL_SAVE_SETTINGS, conf); + video_driver_save_settings(conf); config_set_float(conf, "video_font_size", settings->video.font_size); diff --git a/core_impl.c b/core_impl.c index 277b211475..fe3745758c 100644 --- a/core_impl.c +++ b/core_impl.c @@ -335,7 +335,7 @@ bool core_unload(void) bool core_unload_game(void) { - video_driver_ctl(RARCH_DISPLAY_CTL_DEINIT_HW_CONTEXT, NULL); + video_driver_deinit_hw_context(); audio_driver_ctl(RARCH_AUDIO_CTL_STOP, NULL); core.retro_unload_game(); return true; diff --git a/driver.c b/driver.c index a6e26e3c00..6a4f3c94af 100644 --- a/driver.c +++ b/driver.c @@ -201,7 +201,7 @@ bool driver_find_next(const char *label, char *s, size_t len) static void driver_adjust_system_rates(void) { audio_driver_ctl(RARCH_AUDIO_CTL_MONITOR_ADJUST_SYSTEM_RATES, NULL); - video_driver_ctl(RARCH_DISPLAY_CTL_MONITOR_ADJUST_SYSTEM_RATES, NULL); + video_driver_monitor_adjust_system_rates(); if (!video_driver_get_ptr(false)) return; @@ -227,15 +227,14 @@ static void driver_set_nonblock_state(void) RARCH_INPUT_CTL_IS_NONBLOCK_STATE, NULL); /* Only apply non-block-state for video if we're using vsync. */ - if (video_driver_ctl(RARCH_DISPLAY_CTL_IS_ACTIVE, NULL) - && video_driver_get_ptr(false)) + if (video_driver_is_active() && video_driver_get_ptr(false)) { bool video_nonblock = enable; if ( !settings->video.vsync || runloop_ctl(RUNLOOP_CTL_IS_NONBLOCK_FORCED, NULL)) video_nonblock = true; - video_driver_ctl(RARCH_DISPLAY_CTL_SET_NONBLOCK_STATE, &video_nonblock); + video_driver_set_nonblock_state(video_nonblock); } audio_driver_set_nonblocking_state(enable); @@ -303,7 +302,7 @@ static void menu_update_libretro_info(void) static void init_drivers(int flags) { if (flags & DRIVER_VIDEO) - video_driver_ctl(RARCH_DISPLAY_CTL_UNSET_OWN_DRIVER, NULL); + video_driver_unset_own_driver(); if (flags & DRIVER_AUDIO) audio_driver_ctl(RARCH_AUDIO_CTL_UNSET_OWN_DRIVER, NULL); if (flags & DRIVER_INPUT) @@ -323,16 +322,16 @@ static void init_drivers(int flags) if (flags & DRIVER_VIDEO) { - struct retro_hw_render_callback *hwr = NULL; - video_driver_ctl(RARCH_DISPLAY_CTL_HW_CONTEXT_GET, &hwr); + struct retro_hw_render_callback *hwr = + video_driver_get_hw_context(); - video_driver_ctl(RARCH_DISPLAY_CTL_MONITOR_RESET, NULL); - video_driver_ctl(RARCH_DISPLAY_CTL_INIT, NULL); + video_driver_monitor_reset(); + video_driver_init(); - if (!video_driver_ctl(RARCH_DISPLAY_CTL_IS_VIDEO_CACHE_CONTEXT_ACK, NULL) + if (!video_driver_is_video_cache_context_ack() && hwr->context_reset) hwr->context_reset(); - video_driver_ctl(RARCH_DISPLAY_CTL_UNSET_VIDEO_CACHE_CONTEXT_ACK, NULL); + video_driver_unset_video_cache_context_ack(); runloop_ctl(RUNLOOP_CTL_SET_FRAME_TIME_LAST, NULL); } @@ -411,10 +410,10 @@ static void uninit_drivers(int flags) audio_driver_ctl(RARCH_AUDIO_CTL_DEINIT, NULL); if (flags & DRIVERS_VIDEO_INPUT) - video_driver_ctl(RARCH_DISPLAY_CTL_DEINIT, NULL); + video_driver_deinit(); - if ((flags & DRIVER_VIDEO) && !video_driver_ctl(RARCH_DISPLAY_CTL_OWNS_DRIVER, NULL)) - video_driver_ctl(RARCH_DISPLAY_CTL_DESTROY_DATA, NULL); + if ((flags & DRIVER_VIDEO) && !video_driver_owns_driver()) + video_driver_destroy_data(); if ((flags & DRIVER_INPUT) && !input_driver_ctl(RARCH_INPUT_CTL_OWNS_DRIVER, NULL)) input_driver_ctl(RARCH_INPUT_CTL_DESTROY_DATA, NULL); @@ -428,7 +427,7 @@ bool driver_ctl(enum driver_ctl_state state, void *data) switch (state) { case RARCH_DRIVER_CTL_DEINIT: - video_driver_ctl(RARCH_DISPLAY_CTL_DESTROY, NULL); + video_driver_destroy(); audio_driver_ctl(RARCH_AUDIO_CTL_DESTROY, NULL); input_driver_ctl(RARCH_INPUT_CTL_DESTROY, NULL); #ifdef HAVE_MENU @@ -466,7 +465,7 @@ bool driver_ctl(enum driver_ctl_state state, void *data) } case RARCH_DRIVER_CTL_INIT_PRE: audio_driver_ctl(RARCH_AUDIO_CTL_FIND_DRIVER, NULL); - video_driver_ctl(RARCH_DISPLAY_CTL_FIND_DRIVER, NULL); + video_driver_find_driver(); input_driver_ctl(RARCH_INPUT_CTL_FIND_DRIVER, NULL); camera_driver_ctl(RARCH_CAMERA_CTL_FIND_DRIVER, NULL); find_location_driver(); diff --git a/dynamic.c b/dynamic.c index 02bfb5a782..03ca24106b 100644 --- a/dynamic.c +++ b/dynamic.c @@ -911,7 +911,7 @@ bool rarch_environment_cb(unsigned cmd, void *data) struct retro_hw_render_callback *cb = (struct retro_hw_render_callback*)data; - video_driver_ctl(RARCH_DISPLAY_CTL_HW_CONTEXT_GET, &hwr); + hwr = video_driver_get_hw_context(); RARCH_LOG("Environ SET_HW_RENDER.\n"); @@ -1253,13 +1253,11 @@ bool rarch_environment_cb(unsigned cmd, void *data) } case RETRO_ENVIRONMENT_GET_CURRENT_SOFTWARE_FRAMEBUFFER: - return video_driver_ctl( - RARCH_DISPLAY_CTL_GET_CURRENT_SOFTWARE_FRAMEBUFFER, + return video_driver_get_current_software_framebuffer( (struct retro_framebuffer*)data); case RETRO_ENVIRONMENT_GET_HW_RENDER_INTERFACE: - return video_driver_ctl( - RARCH_DISPLAY_CTL_GET_HW_RENDER_INTERFACE, + return video_driver_get_hw_render_interface( (const struct retro_hw_render_interface**)data); /* Private extensions for internal use, not part of libretro API. */ diff --git a/gfx/common/vulkan_common.c b/gfx/common/vulkan_common.c index 4bd77e93c9..7f232211b1 100644 --- a/gfx/common/vulkan_common.c +++ b/gfx/common/vulkan_common.c @@ -1373,7 +1373,7 @@ bool vulkan_context_init(gfx_ctx_vulkan_data_t *vk, vk->context.device = cached_device; cached_device = NULL; - video_driver_ctl(RARCH_DISPLAY_CTL_SET_VIDEO_CACHE_CONTEXT_ACK, NULL); + video_driver_set_video_cache_context_ack(); RARCH_LOG("[Vulkan]: Using cached Vulkan context.\n"); } else if (VKFUNC(vkCreateDevice)(vk->context.gpu, &device_info, @@ -1614,7 +1614,7 @@ void vulkan_context_destroy(gfx_ctx_vulkan_data_t *vk, vk->context.swapchain_fences[i], NULL); } - if (video_driver_ctl(RARCH_DISPLAY_CTL_IS_VIDEO_CACHE_CONTEXT, NULL)) + if (video_driver_is_video_cache_context()) { cached_device = vk->context.device; cached_instance = vk->context.instance; diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index e575932360..68da573c1d 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -755,8 +755,8 @@ static bool gl_init_hw_render(gl_t *gl, unsigned width, unsigned height) bool stencil = false; GLint max_fbo_size = 0; GLint max_renderbuffer_size = 0; - struct retro_hw_render_callback *hwr = NULL; - video_driver_ctl(RARCH_DISPLAY_CTL_HW_CONTEXT_GET, &hwr); + struct retro_hw_render_callback *hwr = + video_driver_get_hw_context(); /* We can only share texture objects through contexts. * FBOs are "abstract" objects and are not shared. */ @@ -2157,8 +2157,8 @@ static bool resolve_extensions(gl_t *gl, const char *context_ident) #if defined(HAVE_GL_SYNC) || defined(HAVE_FBO) settings_t *settings = config_get_ptr(); #endif - struct retro_hw_render_callback *hwr = NULL; - video_driver_ctl(RARCH_DISPLAY_CTL_HW_CONTEXT_GET, &hwr); + struct retro_hw_render_callback *hwr = + video_driver_get_hw_context(); (void)vendor; (void)renderer; @@ -2222,7 +2222,7 @@ static bool resolve_extensions(gl_t *gl, const char *context_ident) RARCH_LOG("[GL]: Using ARB_sync to reduce latency.\n"); #endif - video_driver_ctl(RARCH_DISPLAY_CTL_UNSET_RGBA, NULL); + video_driver_unset_rgba(); #if defined(HAVE_OPENGLES) || defined(HAVE_OPENGLES2) bool gles3 = false; @@ -2329,8 +2329,7 @@ static INLINE void gl_set_texture_fmts(gl_t *gl, bool rgb32) if (rgb32) { - bool use_rgba = - video_driver_ctl(RARCH_DISPLAY_CTL_SUPPORTS_RGBA, NULL); + bool use_rgba = video_driver_supports_rgba(); gl->internal_fmt = RARCH_GL_INTERNAL_FORMAT32; gl->texture_type = RARCH_GL_TEXTURE_TYPE32; @@ -2417,7 +2416,7 @@ static const gfx_ctx_driver_t *gl_get_context(gl_t *gl) struct retro_hw_render_callback *hwr = NULL; settings_t *settings = config_get_ptr(); - video_driver_ctl(RARCH_DISPLAY_CTL_HW_CONTEXT_GET, &hwr); + hwr = video_driver_get_hw_context(); major = hwr->version_major; minor = hwr->version_minor; @@ -2695,7 +2694,7 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo RARCH_LOG("GL: Using resolution %ux%u\n", temp_width, temp_height); - video_driver_ctl(RARCH_DISPLAY_CTL_HW_CONTEXT_GET, &hwr); + hwr = video_driver_get_hw_context(); gl->vertex_ptr = hwr->bottom_left_origin ? vertexes : vertexes_flipped; @@ -3176,7 +3175,7 @@ static bool gl_read_viewport(void *data, uint8_t *buffer) goto error; } - video_driver_ctl(RARCH_DISPLAY_CTL_CACHED_FRAME_RENDER, NULL); + video_driver_cached_frame_render(); video_frame_convert_rgba_to_bgr( (const void*)gl->readback_buffer_screenshot, @@ -3268,7 +3267,7 @@ void gl_load_texture_data(uint32_t id_data, { GLint mag_filter, min_filter; bool want_mipmap = false; - bool use_rgba = video_driver_ctl(RARCH_DISPLAY_CTL_SUPPORTS_RGBA, NULL); + bool use_rgba = video_driver_supports_rgba(); bool rgb32 = (base_size == (sizeof(uint32_t))); GLenum wrap = gl_wrap_type_to_enum(wrap_type); GLuint id = (GLuint)id_data; @@ -3588,29 +3587,25 @@ static retro_proc_address_t gl_get_proc_address(void *data, const char *sym) static void gl_set_aspect_ratio(void *data, unsigned aspect_ratio_idx) { gl_t *gl = (gl_t*)data; - enum rarch_display_ctl_state cmd = RARCH_DISPLAY_CTL_NONE; switch (aspect_ratio_idx) { case ASPECT_RATIO_SQUARE: - cmd = RARCH_DISPLAY_CTL_SET_VIEWPORT_SQUARE_PIXEL; + video_driver_set_viewport_square_pixel(); break; case ASPECT_RATIO_CORE: - cmd = RARCH_DISPLAY_CTL_SET_VIEWPORT_CORE; + video_driver_set_viewport_core(); break; case ASPECT_RATIO_CONFIG: - cmd = RARCH_DISPLAY_CTL_SET_VIEWPORT_CONFIG; + video_driver_set_viewport_config(); break; default: break; } - if (cmd != RARCH_DISPLAY_CTL_NONE) - video_driver_ctl(cmd, NULL); - video_driver_set_aspect_ratio_value( aspectratio_lut[aspect_ratio_idx].value); diff --git a/gfx/drivers/sdl_gfx.c b/gfx/drivers/sdl_gfx.c index 0af2e7c3b2..fe238fa8c9 100644 --- a/gfx/drivers/sdl_gfx.c +++ b/gfx/drivers/sdl_gfx.c @@ -433,29 +433,24 @@ static void sdl_set_filtering(void *data, unsigned index, bool smooth) static void sdl_set_aspect_ratio(void *data, unsigned aspect_ratio_idx) { - enum rarch_display_ctl_state cmd = RARCH_DISPLAY_CTL_NONE; - switch (aspect_ratio_idx) { case ASPECT_RATIO_SQUARE: - cmd = RARCH_DISPLAY_CTL_SET_VIEWPORT_SQUARE_PIXEL; + video_driver_set_viewport_square_pixel(); break; case ASPECT_RATIO_CORE: - cmd = RARCH_DISPLAY_CTL_SET_VIEWPORT_CORE; + video_driver_set_viewport_core(); break; case ASPECT_RATIO_CONFIG: - cmd = RARCH_DISPLAY_CTL_SET_VIEWPORT_CONFIG; + video_driver_set_viewport_config(); break; default: break; } - if (cmd != RARCH_DISPLAY_CTL_NONE) - video_driver_ctl(cmd, NULL); - video_driver_set_aspect_ratio_value(aspectratio_lut[aspect_ratio_idx].value); } diff --git a/gfx/drivers/vulkan.c b/gfx/drivers/vulkan.c index e2bb1403d3..8740a7ae50 100644 --- a/gfx/drivers/vulkan.c +++ b/gfx/drivers/vulkan.c @@ -896,8 +896,8 @@ static void vulkan_init_hw_render(vk_t *vk) { struct retro_hw_render_interface_vulkan *iface = &vk->hw.iface; - struct retro_hw_render_callback *hwr = NULL; - video_driver_ctl(RARCH_DISPLAY_CTL_HW_CONTEXT_GET, &hwr); + struct retro_hw_render_callback *hwr = + video_driver_get_hw_context(); if (hwr->context_type != RETRO_HW_CONTEXT_VULKAN) return; @@ -1770,29 +1770,25 @@ static bool vulkan_frame(void *data, const void *frame, static void vulkan_set_aspect_ratio(void *data, unsigned aspect_ratio_idx) { vk_t *vk = (vk_t*)data; - enum rarch_display_ctl_state cmd = RARCH_DISPLAY_CTL_NONE; switch (aspect_ratio_idx) { case ASPECT_RATIO_SQUARE: - cmd = RARCH_DISPLAY_CTL_SET_VIEWPORT_SQUARE_PIXEL; + video_driver_set_viewport_square_pixel(); break; case ASPECT_RATIO_CORE: - cmd = RARCH_DISPLAY_CTL_SET_VIEWPORT_CORE; + video_driver_set_viewport_core(); break; case ASPECT_RATIO_CONFIG: - cmd = RARCH_DISPLAY_CTL_SET_VIEWPORT_CONFIG; + video_driver_set_viewport_config(); break; default: break; } - if (cmd != RARCH_DISPLAY_CTL_NONE) - video_driver_ctl(cmd, NULL); - video_driver_set_aspect_ratio_value( aspectratio_lut[aspect_ratio_idx].value); @@ -2081,7 +2077,7 @@ static bool vulkan_read_viewport(void *data, uint8_t *buffer) * with conversion. */ vk->readback.pending = true; - video_driver_ctl(RARCH_DISPLAY_CTL_CACHED_FRAME_RENDER, NULL); + video_driver_cached_frame_render(); VKFUNC(vkQueueWaitIdle)(vk->context->queue); if (!staging->mapped) diff --git a/gfx/drivers_context/drm_ctx.c b/gfx/drivers_context/drm_ctx.c index b6d3ba4b89..edd1c63a13 100644 --- a/gfx/drivers_context/drm_ctx.c +++ b/gfx/drivers_context/drm_ctx.c @@ -468,9 +468,7 @@ static EGLint *gfx_ctx_drm_egl_fill_attribs( #ifdef GL_DEBUG debug = true; #else - struct retro_hw_render_callback *hwr = NULL; - - video_driver_ctl(RARCH_DISPLAY_CTL_HW_CONTEXT_GET, &hwr); + struct retro_hw_render_callback *hwr = video_driver_get_hw_context(); debug = hwr->debug_context; #endif diff --git a/gfx/drivers_context/wayland_ctx.c b/gfx/drivers_context/wayland_ctx.c index f7fedd1f22..7098916b39 100644 --- a/gfx/drivers_context/wayland_ctx.c +++ b/gfx/drivers_context/wayland_ctx.c @@ -639,8 +639,8 @@ static EGLint *egl_fill_attribs(gfx_ctx_wayland_data_t *wl, EGLint *attr) #ifdef GL_DEBUG debug = true; #else - struct retro_hw_render_callback *hwr = NULL; - video_driver_ctl(RARCH_DISPLAY_CTL_HW_CONTEXT_GET, &hwr); + struct retro_hw_render_callback *hwr = + video_driver_get_hw_context(); debug = hwr->debug_context; #endif diff --git a/gfx/drivers_context/x_ctx.c b/gfx/drivers_context/x_ctx.c index b86f1d8b95..3abf1bda62 100644 --- a/gfx/drivers_context/x_ctx.c +++ b/gfx/drivers_context/x_ctx.c @@ -91,7 +91,7 @@ static void gfx_ctx_x_destroy_resources(gfx_ctx_x_data_t *x) glFinish(); glXMakeContextCurrent(g_x11_dpy, None, None, NULL); - if (!video_driver_ctl(RARCH_DISPLAY_CTL_IS_VIDEO_CACHE_CONTEXT, NULL)) + if (!video_driver_is_video_cache_context()) { if (x->g_hw_ctx) glXDestroyContext(g_x11_dpy, x->g_hw_ctx); @@ -139,7 +139,7 @@ static void gfx_ctx_x_destroy_resources(gfx_ctx_x_data_t *x) x->g_should_reset_mode = false; } - if (!video_driver_ctl(RARCH_DISPLAY_CTL_IS_VIDEO_CACHE_CONTEXT, NULL) + if (!video_driver_is_video_cache_context() && g_x11_dpy) { XCloseDisplay(g_x11_dpy); @@ -333,8 +333,8 @@ static void *gfx_ctx_x_init(void *data) gfx_ctx_x_data_t *x = (gfx_ctx_x_data_t*) calloc(1, sizeof(gfx_ctx_x_data_t)); #ifndef GL_DEBUG - struct retro_hw_render_callback *hwr = NULL; - video_driver_ctl(RARCH_DISPLAY_CTL_HW_CONTEXT_GET, &hwr); + struct retro_hw_render_callback *hwr = + video_driver_get_hw_context(); #endif if (!x) @@ -646,7 +646,7 @@ static bool gfx_ctx_x_set_video_mode(void *data, } else { - video_driver_ctl(RARCH_DISPLAY_CTL_SET_VIDEO_CACHE_CONTEXT_ACK, NULL); + video_driver_set_video_cache_context_ack(); RARCH_LOG("[GLX]: Using cached GL context.\n"); } diff --git a/gfx/drivers_context/xegl_ctx.c b/gfx/drivers_context/xegl_ctx.c index 9bacb5ce5d..4665258f4f 100644 --- a/gfx/drivers_context/xegl_ctx.c +++ b/gfx/drivers_context/xegl_ctx.c @@ -194,7 +194,7 @@ static EGLint *xegl_fill_attribs(xegl_ctx_data_t *xegl, EGLint *attr) bool core = version >= 3001; struct retro_hw_render_callback *hwr = NULL; - video_driver_ctl(RARCH_DISPLAY_CTL_HW_CONTEXT_GET, &hwr); + hwr = video_driver_get_hw_context(); #ifdef GL_DEBUG debug = true; #else diff --git a/gfx/drivers_font/gl_raster_font.c b/gfx/drivers_font/gl_raster_font.c index 89c9259b69..0a30b0e6fb 100644 --- a/gfx/drivers_font/gl_raster_font.c +++ b/gfx/drivers_font/gl_raster_font.c @@ -61,7 +61,7 @@ static bool gl_raster_font_upload_atlas(gl_raster_t *font, struct retro_hw_render_callback *hwr = NULL; bool ancient = false; /* add a check here if needed */ - video_driver_ctl(RARCH_DISPLAY_CTL_HW_CONTEXT_GET, &hwr); + hwr = video_driver_get_hw_context(); if (ancient) { diff --git a/gfx/font_driver.c b/gfx/font_driver.c index f92d0b4187..b496d60530 100644 --- a/gfx/font_driver.c +++ b/gfx/font_driver.c @@ -312,7 +312,7 @@ bool font_driver_init_first( if (threading_hint && settings->video.threaded - && !video_driver_ctl(RARCH_DISPLAY_CTL_IS_HW_CONTEXT, NULL)) + && !video_driver_is_hw_context()) return rarch_threaded_video_font_init(new_font_driver, new_font_handle, data, font_path, font_size, api, font_init_first); #endif diff --git a/gfx/video_context_driver.c b/gfx/video_context_driver.c index 65f700efc1..b009d8dea5 100644 --- a/gfx/video_context_driver.c +++ b/gfx/video_context_driver.c @@ -266,8 +266,7 @@ bool gfx_ctx_ctl(enum gfx_ctx_ctl_state state, void *data) { uint64_t *frame_count = NULL; gfx_ctx_size_t *size_data = (gfx_ctx_size_t*)data; - - video_driver_ctl(RARCH_DISPLAY_CTL_GET_FRAME_COUNT, &frame_count); + frame_count = video_driver_get_frame_count_ptr(); if (!video_context_data || !size_data) return false; diff --git a/gfx/video_driver.c b/gfx/video_driver.c index e0946c2015..f8ca8f9abe 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -286,7 +286,7 @@ void *video_driver_get_ptr(bool force_nonthreaded_data) settings_t *settings = config_get_ptr(); if (settings->video.threaded - && !(video_driver_ctl(RARCH_DISPLAY_CTL_IS_HW_CONTEXT, NULL)) + && !video_driver_is_hw_context() && !force_nonthreaded_data) return rarch_threaded_video_get_ptr(NULL); #endif @@ -363,7 +363,7 @@ static void init_video_filter(enum retro_pixel_format colfmt) if (colfmt == RETRO_PIXEL_FORMAT_0RGB1555) colfmt = RETRO_PIXEL_FORMAT_RGB565; - if (video_driver_ctl(RARCH_DISPLAY_CTL_IS_HW_CONTEXT, NULL)) + if (video_driver_is_hw_context()) { RARCH_WARN("Cannot use CPU filters when hardware rendering is used.\n"); return; @@ -510,8 +510,8 @@ static bool uninit_video_input(void) { event_cmd_ctl(EVENT_CMD_OVERLAY_DEINIT, NULL); - if (!video_driver_ctl(RARCH_DISPLAY_CTL_IS_VIDEO_CACHE_CONTEXT, NULL)) - video_driver_ctl(RARCH_DISPLAY_CTL_DEINIT_HW_CONTEXT, NULL); + if (!video_driver_is_video_cache_context()) + video_driver_deinit_hw_context(); if ( !input_driver_ctl(RARCH_INPUT_CTL_OWNS_DRIVER, NULL) && @@ -520,7 +520,7 @@ static bool uninit_video_input(void) input_driver_ctl(RARCH_INPUT_CTL_DEINIT, NULL); if ( - !video_driver_ctl(RARCH_DISPLAY_CTL_OWNS_DRIVER, NULL) + !video_driver_owns_driver() && video_driver_data && current_video && current_video->free ) @@ -537,8 +537,8 @@ static bool uninit_video_input(void) static bool init_video_pixel_converter(unsigned size) { - struct retro_hw_render_callback *hwr = NULL; - video_driver_ctl(RARCH_DISPLAY_CTL_HW_CONTEXT_GET, &hwr); + struct retro_hw_render_callback *hwr = + video_driver_get_hw_context(); /* If pixel format is not 0RGB1555, we don't need to do * any internal pixel conversion. */ @@ -622,9 +622,9 @@ static bool init_video(void) scale = video_driver_state.filter.scale; /* Update core-dependent aspect ratio values. */ - video_driver_ctl(RARCH_DISPLAY_CTL_SET_VIEWPORT_SQUARE_PIXEL, NULL); - video_driver_ctl(RARCH_DISPLAY_CTL_SET_VIEWPORT_CORE, NULL); - video_driver_ctl(RARCH_DISPLAY_CTL_SET_VIEWPORT_CONFIG, NULL); + video_driver_set_viewport_square_pixel(); + video_driver_set_viewport_core(); + video_driver_set_viewport_config(); /* Update CUSTOM viewport. */ custom_vp = video_viewport_get_custom(); @@ -691,11 +691,11 @@ static bool init_video(void) tmp = input_get_ptr(); /* Need to grab the "real" video driver interface on a reinit. */ - video_driver_ctl(RARCH_DISPLAY_CTL_FIND_DRIVER, NULL); + video_driver_find_driver(); #ifdef HAVE_THREADS if (settings->video.threaded - && !video_driver_ctl(RARCH_DISPLAY_CTL_IS_HW_CONTEXT, NULL)) + && !video_driver_is_hw_context()) { /* Can't do hardware rendering with threaded driver currently. */ RARCH_LOG("Starting threaded video driver ...\n"); @@ -731,7 +731,7 @@ static bool init_video(void) custom_vp->width = width; custom_vp->height = height; - video_driver_ctl(RARCH_DISPLAY_CTL_VIEWPORT_INFO, custom_vp); + video_driver_get_viewport_info(custom_vp); } video_driver_set_rotation( @@ -856,7 +856,7 @@ void video_driver_set_filtering(unsigned index, bool smooth) void video_driver_cached_frame_set(const void *data, unsigned width, unsigned height, size_t pitch) { - video_driver_ctl(RARCH_DISPLAY_CTL_CACHED_FRAME_SET_PTR, (void*)data); + video_driver_set_cached_frame_ptr(data); video_driver_state.frame_cache.width = width; video_driver_state.frame_cache.height = height; video_driver_state.frame_cache.pitch = pitch; @@ -1114,7 +1114,7 @@ static bool video_driver_cached_frame(void) return true; } -static void video_monitor_adjust_system_rates(void) +void video_driver_monitor_adjust_system_rates(void) { float timing_skew; const struct retro_system_timing *info = NULL; @@ -1252,582 +1252,670 @@ void video_driver_menu_settings(void **list_data, void *list_info_data, #endif } -bool video_driver_ctl(enum rarch_display_ctl_state state, void *data) +/* Graphics driver requires RGBA byte order data (ABGR on little-endian) + * for 32-bit. + * This takes effect for overlay and shader cores that wants to load + * data into graphics driver. Kinda hackish to place it here, it is only + * used for GLES. + * TODO: Refactor this better. */ +static struct retro_hw_render_callback hw_render; +static bool video_driver_use_rgba = false; +static bool video_driver_data_own = false; +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 + * context state. */ +static bool video_driver_cache_context = false; +/* Set to true by driver if context caching succeeded. */ +static bool video_driver_cache_context_ack = false; +static uint8_t *video_driver_record_gpu_buffer = NULL; +#ifdef HAVE_THREADS +static slock_t *display_lock = NULL; +#endif + +void video_driver_lock(void) { - /* Graphics driver requires RGBA byte order data (ABGR on little-endian) - * for 32-bit. - * This takes effect for overlay and shader cores that wants to load - * data into graphics driver. Kinda hackish to place it here, it is only - * used for GLES. - * TODO: Refactor this better. */ - static struct retro_hw_render_callback hw_render; - static bool video_driver_use_rgba = false; - static bool video_driver_data_own = false; - 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 - * context state. */ - static bool video_driver_cache_context = false; - /* Set to true by driver if context caching succeeded. */ - static bool video_driver_cache_context_ack = false; - static uint8_t *video_driver_record_gpu_buffer = NULL; #ifdef HAVE_THREADS - static slock_t *display_lock = NULL; + if (!display_lock) + return; + slock_lock(display_lock); #endif - settings_t *settings = config_get_ptr(); +} - switch (state) +void video_driver_unlock(void) +{ +#ifdef HAVE_THREADS + if (!display_lock) + return; + slock_unlock(display_lock); +#endif +} + +void video_driver_lock_free(void) +{ +#ifdef HAVE_THREADS + slock_free(display_lock); + display_lock = NULL; +#endif +} + +void video_driver_lock_new(void) +{ + video_driver_lock_free(); +#ifdef HAVE_THREADS + if (!display_lock) + display_lock = slock_new(); + retro_assert(display_lock); +#endif +} + +void video_driver_destroy(void) +{ + video_driver_use_rgba = false; + video_driver_data_own = false; + video_driver_active = false; + video_driver_cache_context = false; + video_driver_cache_context_ack = false; + video_driver_record_gpu_buffer = NULL; + current_video = NULL; +} + +void video_driver_set_cached_frame_ptr(const void *data) +{ + if (data) + video_driver_state.frame_cache.data = data; +} + +void video_driver_set_stub_frame(void) +{ + frame_bak = current_video->frame; + current_video->frame = video_null.frame; +} + +void video_driver_unset_stub_frame(void) +{ + if (frame_bak != NULL) + current_video->frame = frame_bak; + + frame_bak = NULL; +} + +bool video_driver_supports_recording(void) +{ + settings_t *settings = config_get_ptr(); + return settings->video.gpu_record && current_video->read_viewport; +} + +bool video_driver_supports_viewport_read(void) +{ + settings_t *settings = config_get_ptr(); + return (settings->video.gpu_screenshot || + (video_driver_is_hw_context() && !current_video->read_frame_raw)) + && current_video->read_viewport && current_video->viewport_info; +} + +bool video_driver_supports_read_frame_raw(void) +{ + return current_video->read_frame_raw; +} + +void video_driver_set_viewport_config(void) +{ + settings_t *settings = config_get_ptr(); + struct retro_system_av_info *av_info = video_viewport_get_system_av_info(); + + if (settings->video.aspect_ratio < 0.0f) { - case RARCH_DISPLAY_CTL_LOCK: -#ifdef HAVE_THREADS - if (!display_lock) - return false; - slock_lock(display_lock); -#endif - break; - case RARCH_DISPLAY_CTL_UNLOCK: -#ifdef HAVE_THREADS - if (!display_lock) - return false; - slock_unlock(display_lock); -#endif - break; - case RARCH_DISPLAY_CTL_LOCK_FREE: -#ifdef HAVE_THREADS - slock_free(display_lock); - display_lock = NULL; -#endif - break; - case RARCH_DISPLAY_CTL_LOCK_NEW: - video_driver_ctl(RARCH_DISPLAY_CTL_LOCK_FREE, NULL); -#ifdef HAVE_THREADS - if (!display_lock) - display_lock = slock_new(); - retro_assert(display_lock); -#endif - break; - case RARCH_DISPLAY_CTL_DESTROY: - video_driver_use_rgba = false; - video_driver_data_own = false; - video_driver_active = false; - video_driver_cache_context = false; - video_driver_cache_context_ack = false; - video_driver_record_gpu_buffer = NULL; - current_video = NULL; - break; - case RARCH_DISPLAY_CTL_CACHED_FRAME_SET_PTR: - if (!data) - return false; - video_driver_state.frame_cache.data = (const void*)data; - break; - case RARCH_DISPLAY_CTL_SET_STUB_FRAME: - frame_bak = current_video->frame; - current_video->frame = video_null.frame; - break; - case RARCH_DISPLAY_CTL_UNSET_STUB_FRAME: - if (frame_bak != NULL) - current_video->frame = frame_bak; - frame_bak = NULL; - break; - case RARCH_DISPLAY_CTL_SUPPORTS_RECORDING: - return settings->video.gpu_record && current_video->read_viewport; - case RARCH_DISPLAY_CTL_SUPPORTS_VIEWPORT_READ: - return (settings->video.gpu_screenshot || - (video_driver_ctl(RARCH_DISPLAY_CTL_IS_HW_CONTEXT, NULL) - && !current_video->read_frame_raw)) - && current_video->read_viewport && current_video->viewport_info; - case RARCH_DISPLAY_CTL_SUPPORTS_READ_FRAME_RAW: - return current_video->read_frame_raw; - case RARCH_DISPLAY_CTL_SET_VIEWPORT_CONFIG: - { - struct retro_system_av_info *av_info = video_viewport_get_system_av_info(); + struct retro_game_geometry *geom = &av_info->geometry; - if (settings->video.aspect_ratio < 0.0f) - { - struct retro_game_geometry *geom = &av_info->geometry; + if (!geom) + return; - if (!geom) - return false; + if (geom->aspect_ratio > 0.0f && settings->video.aspect_ratio_auto) + aspectratio_lut[ASPECT_RATIO_CONFIG].value = geom->aspect_ratio; + else + { + unsigned base_width = geom->base_width; + unsigned base_height = geom->base_height; - if (geom->aspect_ratio > 0.0f && settings->video.aspect_ratio_auto) - aspectratio_lut[ASPECT_RATIO_CONFIG].value = geom->aspect_ratio; - else - { - unsigned base_width = geom->base_width; - unsigned base_height = geom->base_height; - - /* Get around division by zero errors */ - if (base_width == 0) - base_width = 1; - if (base_height == 0) - base_height = 1; - aspectratio_lut[ASPECT_RATIO_CONFIG].value = - (float)base_width / base_height; /* 1:1 PAR. */ - } - } - else - aspectratio_lut[ASPECT_RATIO_CONFIG].value = - settings->video.aspect_ratio; - } - break; - case RARCH_DISPLAY_CTL_SET_VIEWPORT_SQUARE_PIXEL: - { - unsigned len, highest, i, aspect_x, aspect_y; - unsigned width, height; - struct retro_game_geometry *geom = NULL; - struct retro_system_av_info *av_info = - video_viewport_get_system_av_info(); - - if (av_info) - geom = &av_info->geometry; - - if (!geom) - return false; - - width = geom->base_width; - height = geom->base_height; - - if (width == 0 || height == 0) - return false; - - len = MIN(width, height); - highest = 1; - - for (i = 1; i < len; i++) - { - if ((width % i) == 0 && (height % i) == 0) - highest = i; - } - - aspect_x = width / highest; - aspect_y = height / highest; - - snprintf(aspectratio_lut[ASPECT_RATIO_SQUARE].name, - sizeof(aspectratio_lut[ASPECT_RATIO_SQUARE].name), - "%u:%u (1:1 PAR)", aspect_x, aspect_y); - - aspectratio_lut[ASPECT_RATIO_SQUARE].value = (float)aspect_x / aspect_y; - } - break; - case RARCH_DISPLAY_CTL_SET_VIEWPORT_CORE: - { - struct retro_system_av_info *av_info = - video_viewport_get_system_av_info(); - struct retro_game_geometry *geom = &av_info->geometry; - - if (!geom || geom->base_width <= 0.0f || geom->base_height <= 0.0f) - return false; - - /* Fallback to 1:1 pixel ratio if none provided */ - if (geom->aspect_ratio > 0.0f) - aspectratio_lut[ASPECT_RATIO_CORE].value = geom->aspect_ratio; - else - aspectratio_lut[ASPECT_RATIO_CORE].value = - (float)geom->base_width / geom->base_height; - } - break; - case RARCH_DISPLAY_CTL_RESET_CUSTOM_VIEWPORT: - { - struct video_viewport *custom_vp = video_viewport_get_custom(); - if (!custom_vp) - return false; - - custom_vp->width = 0; - custom_vp->height = 0; - custom_vp->x = 0; - custom_vp->y = 0; - } - break; - case RARCH_DISPLAY_CTL_SET_RGBA: - video_driver_ctl(RARCH_DISPLAY_CTL_LOCK, NULL); - video_driver_use_rgba = true; - video_driver_ctl(RARCH_DISPLAY_CTL_UNLOCK, NULL); - break; - case RARCH_DISPLAY_CTL_UNSET_RGBA: - video_driver_ctl(RARCH_DISPLAY_CTL_LOCK, NULL); - video_driver_use_rgba = false; - video_driver_ctl(RARCH_DISPLAY_CTL_UNLOCK, NULL); - break; - case RARCH_DISPLAY_CTL_SUPPORTS_RGBA: - { - bool tmp = false; - video_driver_ctl(RARCH_DISPLAY_CTL_LOCK, NULL); - tmp = video_driver_use_rgba; - video_driver_ctl(RARCH_DISPLAY_CTL_UNLOCK, NULL); - - if (!tmp) - return false; - } - break; - case RARCH_DISPLAY_CTL_GET_NEXT_VIDEO_OUT: - if (!video_driver_poke) - return false; - - if (!video_driver_poke->get_video_output_next) - return gfx_ctx_ctl(GFX_CTL_GET_VIDEO_OUTPUT_NEXT, NULL); - video_driver_poke->get_video_output_next(video_driver_data); - break; - case RARCH_DISPLAY_CTL_GET_PREV_VIDEO_OUT: - if (!video_driver_poke) - return false; - - if (!video_driver_poke->get_video_output_prev) - return gfx_ctx_ctl(GFX_CTL_GET_VIDEO_OUTPUT_NEXT, NULL); - video_driver_poke->get_video_output_prev(video_driver_data); - break; - case RARCH_DISPLAY_CTL_INIT: - video_driver_ctl(RARCH_DISPLAY_CTL_LOCK_NEW, NULL); - return init_video(); - case RARCH_DISPLAY_CTL_DESTROY_DATA: - video_driver_data = NULL; - break; - case RARCH_DISPLAY_CTL_DEINIT: - uninit_video_input(); - video_driver_ctl(RARCH_DISPLAY_CTL_LOCK_FREE, NULL); - video_driver_data = NULL; - break; - case RARCH_DISPLAY_CTL_MONITOR_RESET: - video_driver_state.frame_time.count = 0; - break; - case RARCH_DISPLAY_CTL_MONITOR_ADJUST_SYSTEM_RATES: - video_monitor_adjust_system_rates(); - break; - case RARCH_DISPLAY_CTL_SET_ASPECT_RATIO: - if (!video_driver_poke || !video_driver_poke->set_aspect_ratio) - return false; - video_driver_poke->set_aspect_ratio( - video_driver_data, settings->video.aspect_ratio_idx); - break; - case RARCH_DISPLAY_CTL_SHOW_MOUSE: - if (!video_driver_poke) - return false; - if (video_driver_poke->show_mouse) - video_driver_poke->show_mouse(video_driver_data, true); - break; - case RARCH_DISPLAY_CTL_HIDE_MOUSE: - if (!video_driver_poke) - return false; - if (video_driver_poke->show_mouse) - video_driver_poke->show_mouse(video_driver_data, false); - break; - case RARCH_DISPLAY_CTL_SET_NONBLOCK_STATE: - { - bool *toggle = (bool*)data; - - if (!toggle) - return false; - - if (current_video->set_nonblock_state) - current_video->set_nonblock_state(video_driver_data, *toggle); - } - break; - case RARCH_DISPLAY_CTL_FIND_DRIVER: - { - int i; - driver_ctx_info_t drv; - - if (video_driver_ctl(RARCH_DISPLAY_CTL_IS_HW_CONTEXT, NULL)) - { - struct retro_hw_render_callback *hwr = NULL; - current_video = NULL; - - video_driver_ctl(RARCH_DISPLAY_CTL_HW_CONTEXT_GET, &hwr); - (void)hwr; - - if (hwr && hw_render_context_is_vulkan(hwr->context_type)) - { -#if defined(HAVE_VULKAN) - RARCH_LOG("Using HW render, Vulkan driver forced.\n"); - current_video = &video_vulkan; -#endif - } - - if (hwr && hw_render_context_is_gl(hwr->context_type)) - { -#if defined(HAVE_OPENGL) && defined(HAVE_FBO) - RARCH_LOG("Using HW render, OpenGL driver forced.\n"); - current_video = &video_gl; -#endif - } - - if (current_video) - return true; - } - - if (frontend_driver_has_get_video_driver_func()) - { - current_video = (video_driver_t*)frontend_driver_get_video_driver(); - - if (current_video) - return true; - RARCH_WARN("Frontend supports get_video_driver() but did not specify one.\n"); - } - - drv.label = "video_driver"; - drv.s = settings->video.driver; - - driver_ctl(RARCH_DRIVER_CTL_FIND_INDEX, &drv); - - i = drv.len; - - if (i >= 0) - current_video = (video_driver_t*)video_driver_find_handle(i); - else - { - unsigned d; - RARCH_ERR("Couldn't find any video driver named \"%s\"\n", - settings->video.driver); - RARCH_LOG_OUTPUT("Available video drivers are:\n"); - for (d = 0; video_driver_find_handle(d); d++) - RARCH_LOG_OUTPUT("\t%s\n", video_driver_find_ident(d)); - RARCH_WARN("Going to default to first video driver...\n"); - - current_video = (video_driver_t*)video_driver_find_handle(0); - - if (!current_video) - retro_fail(1, "find_video_driver()"); - } - } - break; - case RARCH_DISPLAY_CTL_APPLY_STATE_CHANGES: - if (!video_driver_poke) - return false; - if (video_driver_poke->apply_state_changes) - video_driver_poke->apply_state_changes(video_driver_data); - break; - case RARCH_DISPLAY_CTL_READ_VIEWPORT: - if (!current_video->read_viewport) - return false; - if (!current_video->read_viewport(video_driver_data, - (uint8_t*)data)) - return false; - break; - case RARCH_DISPLAY_CTL_CACHED_FRAME_HAS_VALID_FB: - if (!video_driver_state.frame_cache.data) - return false; - return (video_driver_state.frame_cache.data - == RETRO_HW_FRAME_BUFFER_VALID); - case RARCH_DISPLAY_CTL_CACHED_FRAME_RENDER: - if (!current_video) - return false; - return video_driver_cached_frame(); - case RARCH_DISPLAY_CTL_IS_ALIVE: - if (current_video) - return current_video->alive(video_driver_data); - break; - case RARCH_DISPLAY_CTL_IS_FOCUSED: - return current_video->focus(video_driver_data); - case RARCH_DISPLAY_CTL_HAS_WINDOWED: -#if defined(RARCH_CONSOLE) || defined(RARCH_MOBILE) - return false; -#else - if (!current_video->has_windowed(video_driver_data)) - return false; - break; -#endif - case RARCH_DISPLAY_CTL_GET_FRAME_COUNT: - { - uint64_t **ptr = (uint64_t**)data; - if (!ptr) - return false; - *ptr = &video_driver_frame_count; - } - break; - case RARCH_DISPLAY_CTL_FRAME_FILTER_ALIVE: - if (!video_driver_state.filter.filter) - return false; - break; - case RARCH_DISPLAY_CTL_FRAME_FILTER_IS_32BIT: - return video_driver_state.filter.out_rgb32; - case RARCH_DISPLAY_CTL_DEFAULT_SETTINGS: - { - global_t *global = global_get_ptr(); - - if (!global) - return false; - - global->console.screen.gamma_correction = DEFAULT_GAMMA; - global->console.flickerfilter_enable = false; - global->console.softfilter_enable = false; - - global->console.screen.resolutions.current.id = 0; - } - break; - case RARCH_DISPLAY_CTL_LOAD_SETTINGS: - { - global_t *global = global_get_ptr(); - config_file_t *conf = (config_file_t*)data; - - if (!conf) - return false; - - CONFIG_GET_BOOL_BASE(conf, global, - console.screen.gamma_correction, "gamma_correction"); - config_get_bool(conf, "flicker_filter_enable", - &global->console.flickerfilter_enable); - config_get_bool(conf, "soft_filter_enable", - &global->console.softfilter_enable); - - CONFIG_GET_INT_BASE(conf, global, - console.screen.soft_filter_index, - "soft_filter_index"); - CONFIG_GET_INT_BASE(conf, global, - console.screen.resolutions.current.id, - "current_resolution_id"); - CONFIG_GET_INT_BASE(conf, global, - console.screen.flicker_filter_index, - "flicker_filter_index"); - } - break; - case RARCH_DISPLAY_CTL_SAVE_SETTINGS: - { - global_t *global = global_get_ptr(); - config_file_t *conf = (config_file_t*)data; - - if (!conf) - return false; - - config_set_bool(conf, "gamma_correction", - global->console.screen.gamma_correction); - config_set_bool(conf, "flicker_filter_enable", - global->console.flickerfilter_enable); - config_set_bool(conf, "soft_filter_enable", - global->console.softfilter_enable); - - config_set_int(conf, "soft_filter_index", - global->console.screen.soft_filter_index); - config_set_int(conf, "current_resolution_id", - global->console.screen.resolutions.current.id); - config_set_int(conf, "flicker_filter_index", - global->console.screen.flicker_filter_index); - } - break; - case RARCH_DISPLAY_CTL_SET_OWN_DRIVER: - video_driver_data_own = true; - break; - case RARCH_DISPLAY_CTL_UNSET_OWN_DRIVER: - video_driver_data_own = false; - break; - case RARCH_DISPLAY_CTL_OWNS_DRIVER: - return video_driver_data_own; - case RARCH_DISPLAY_CTL_IS_HW_CONTEXT: - return (hw_render.context_type != RETRO_HW_CONTEXT_NONE); - case RARCH_DISPLAY_CTL_DEINIT_HW_CONTEXT: - if (hw_render.context_destroy) - hw_render.context_destroy(); - - memset(&hw_render, 0, sizeof(hw_render)); - break; - case RARCH_DISPLAY_CTL_HW_CONTEXT_GET: - { - struct retro_hw_render_callback **hw_cb = - (struct retro_hw_render_callback**)data; - if (!hw_cb) - return false; - *hw_cb = &hw_render; - } - break; - case RARCH_DISPLAY_CTL_SET_VIDEO_CACHE_CONTEXT: - video_driver_cache_context = true; - break; - case RARCH_DISPLAY_CTL_UNSET_VIDEO_CACHE_CONTEXT: - video_driver_cache_context = false; - break; - case RARCH_DISPLAY_CTL_IS_VIDEO_CACHE_CONTEXT: - return video_driver_cache_context; - case RARCH_DISPLAY_CTL_SET_VIDEO_CACHE_CONTEXT_ACK: - video_driver_cache_context_ack = true; - break; - case RARCH_DISPLAY_CTL_UNSET_VIDEO_CACHE_CONTEXT_ACK: - video_driver_cache_context_ack = false; - break; - case RARCH_DISPLAY_CTL_IS_VIDEO_CACHE_CONTEXT_ACK: - return video_driver_cache_context_ack; - case RARCH_DISPLAY_CTL_SET_ACTIVE: - video_driver_active = true; - break; - case RARCH_DISPLAY_CTL_UNSET_ACTIVE: - video_driver_active = false; - break; - case RARCH_DISPLAY_CTL_IS_ACTIVE: - return video_driver_active; - case RARCH_DISPLAY_CTL_HAS_GPU_RECORD: - return (video_driver_record_gpu_buffer != NULL); - case RARCH_DISPLAY_CTL_GPU_RECORD_GET: - { - uint8_t **new_data = (uint8_t**)data; - - if (!new_data) - return false; - *new_data = video_driver_record_gpu_buffer; - } - break; - case RARCH_DISPLAY_CTL_GPU_RECORD_INIT: - { - unsigned *new_size = (unsigned*)data; - if (!new_size) - return false; - video_driver_record_gpu_buffer = (uint8_t*)malloc(*new_size); - if (!video_driver_record_gpu_buffer) - return false; - } - break; - case RARCH_DISPLAY_CTL_GPU_RECORD_DEINIT: - if (video_driver_record_gpu_buffer) - free(video_driver_record_gpu_buffer); - video_driver_record_gpu_buffer = NULL; - break; - case RARCH_DISPLAY_CTL_GET_CURRENT_SOFTWARE_FRAMEBUFFER: - if ( - !video_driver_poke || - !video_driver_poke->get_current_software_framebuffer) - return false; - if (!video_driver_poke->get_current_software_framebuffer( - video_driver_data, (struct retro_framebuffer *)data)) - return false; - break; - case RARCH_DISPLAY_CTL_GET_HW_RENDER_INTERFACE: - if ( - !video_driver_poke || - !video_driver_poke->get_hw_render_interface) - return false; - if (!video_driver_poke->get_hw_render_interface(video_driver_data, - (const struct retro_hw_render_interface**)data)) - return false; - break; - case RARCH_DISPLAY_CTL_VIEWPORT_INFO: - if (!current_video || !current_video->viewport_info) - return false; - current_video->viewport_info(video_driver_data, (struct video_viewport*)data); - break; - case RARCH_DISPLAY_CTL_SET_TITLE_BUF: - { - struct retro_system_info info; - core_get_system_info(&info); - strlcpy(video_driver_title_buf, - msg_hash_to_str(MSG_PROGRAM), - sizeof(video_driver_title_buf)); - strlcat(video_driver_title_buf, - " ", sizeof(video_driver_title_buf)); - strlcat(video_driver_title_buf, - info.library_name, - sizeof(video_driver_title_buf)); - strlcat(video_driver_title_buf, - " ", sizeof(video_driver_title_buf)); - strlcat(video_driver_title_buf, - info.library_version, - sizeof(video_driver_title_buf)); - } - break; - case RARCH_DISPLAY_CTL_NONE: - default: - break; + /* Get around division by zero errors */ + if (base_width == 0) + base_width = 1; + if (base_height == 0) + base_height = 1; + aspectratio_lut[ASPECT_RATIO_CONFIG].value = + (float)base_width / base_height; /* 1:1 PAR. */ + } } + else + { + aspectratio_lut[ASPECT_RATIO_CONFIG].value = + settings->video.aspect_ratio; + } +} + +void video_driver_set_viewport_square_pixel(void) +{ + unsigned len, highest, i, aspect_x, aspect_y; + unsigned width, height; + struct retro_game_geometry *geom = NULL; + struct retro_system_av_info *av_info = + video_viewport_get_system_av_info(); + + if (av_info) + geom = &av_info->geometry; + + if (!geom) + return; + + width = geom->base_width; + height = geom->base_height; + + if (width == 0 || height == 0) + return; + + len = MIN(width, height); + highest = 1; + + for (i = 1; i < len; i++) + { + if ((width % i) == 0 && (height % i) == 0) + highest = i; + } + + aspect_x = width / highest; + aspect_y = height / highest; + + snprintf(aspectratio_lut[ASPECT_RATIO_SQUARE].name, + sizeof(aspectratio_lut[ASPECT_RATIO_SQUARE].name), + "%u:%u (1:1 PAR)", aspect_x, aspect_y); + + aspectratio_lut[ASPECT_RATIO_SQUARE].value = (float)aspect_x / aspect_y; +} + +void video_driver_set_viewport_core(void) +{ + struct retro_system_av_info *av_info = + video_viewport_get_system_av_info(); + struct retro_game_geometry *geom = &av_info->geometry; + + if (!geom || geom->base_width <= 0.0f || geom->base_height <= 0.0f) + return; + + /* Fallback to 1:1 pixel ratio if none provided */ + if (geom->aspect_ratio > 0.0f) + { + aspectratio_lut[ASPECT_RATIO_CORE].value = geom->aspect_ratio; + } + else + { + aspectratio_lut[ASPECT_RATIO_CORE].value = + (float)geom->base_width / geom->base_height; + } +} + +void video_driver_reset_custom_viewport(void) +{ + struct video_viewport *custom_vp = video_viewport_get_custom(); + if (!custom_vp) + return; + + custom_vp->width = 0; + custom_vp->height = 0; + custom_vp->x = 0; + custom_vp->y = 0; +} + +void video_driver_set_rgba(void) +{ + video_driver_lock(); + video_driver_use_rgba = true; + video_driver_unlock(); +} + +void video_driver_unset_rgba(void) +{ + video_driver_lock(); + video_driver_use_rgba = false; + video_driver_unlock(); +} + +bool video_driver_supports_rgba(void) +{ + bool tmp; + video_driver_lock(); + tmp = video_driver_use_rgba; + video_driver_unlock(); + return tmp; +} + +bool video_driver_get_next_video_out(void) +{ + if (!video_driver_poke) + return false; + + if (!video_driver_poke->get_video_output_next) + return gfx_ctx_ctl(GFX_CTL_GET_VIDEO_OUTPUT_NEXT, NULL); + video_driver_poke->get_video_output_next(video_driver_data); + return true; +} + +bool video_driver_get_prev_video_out(void) +{ + if (!video_driver_poke) + return false; + + if (!video_driver_poke->get_video_output_prev) + return gfx_ctx_ctl(GFX_CTL_GET_VIDEO_OUTPUT_NEXT, NULL); + video_driver_poke->get_video_output_prev(video_driver_data); + return true; +} + +bool video_driver_init(void) +{ + video_driver_lock_new(); + return init_video(); +} + +void video_driver_destroy_data(void) +{ + video_driver_data = NULL; +} + +void video_driver_deinit(void) +{ + uninit_video_input(); + video_driver_lock_free(); + video_driver_data = NULL; +} + +void video_driver_monitor_reset(void) +{ + video_driver_state.frame_time.count = 0; +} + +void video_driver_set_aspect_ratio(void) +{ + settings_t *settings = config_get_ptr(); + if (!video_driver_poke || !video_driver_poke->set_aspect_ratio) + return; + video_driver_poke->set_aspect_ratio( + video_driver_data, settings->video.aspect_ratio_idx); +} + +void video_driver_show_mouse(void) +{ + if (!video_driver_poke) + return; + if (video_driver_poke->show_mouse) + video_driver_poke->show_mouse(video_driver_data, true); +} + +void video_driver_hide_mouse(void) +{ + if (!video_driver_poke) + return; + if (video_driver_poke->show_mouse) + video_driver_poke->show_mouse(video_driver_data, false); +} + +void video_driver_set_nonblock_state(bool toggle) +{ + if (current_video->set_nonblock_state) + current_video->set_nonblock_state(video_driver_data, toggle); +} + +bool video_driver_find_driver(void) +{ + settings_t *settings = config_get_ptr(); + int i; + driver_ctx_info_t drv; + + if (video_driver_is_hw_context()) + { + current_video = NULL; + struct retro_hw_render_callback *hwr = video_driver_get_hw_context(); + + if (hwr && hw_render_context_is_vulkan(hwr->context_type)) + { +#if defined(HAVE_VULKAN) + RARCH_LOG("Using HW render, Vulkan driver forced.\n"); + current_video = &video_vulkan; +#endif + } + + if (hwr && hw_render_context_is_gl(hwr->context_type)) + { +#if defined(HAVE_OPENGL) && defined(HAVE_FBO) + RARCH_LOG("Using HW render, OpenGL driver forced.\n"); + current_video = &video_gl; +#endif + } + + if (current_video) + return true; + } + + if (frontend_driver_has_get_video_driver_func()) + { + current_video = (video_driver_t*)frontend_driver_get_video_driver(); + + if (current_video) + return true; + RARCH_WARN("Frontend supports get_video_driver() but did not specify one.\n"); + } + + drv.label = "video_driver"; + drv.s = settings->video.driver; + + driver_ctl(RARCH_DRIVER_CTL_FIND_INDEX, &drv); + + i = drv.len; + + if (i >= 0) + current_video = (video_driver_t*)video_driver_find_handle(i); + else + { + unsigned d; + RARCH_ERR("Couldn't find any video driver named \"%s\"\n", + settings->video.driver); + RARCH_LOG_OUTPUT("Available video drivers are:\n"); + for (d = 0; video_driver_find_handle(d); d++) + RARCH_LOG_OUTPUT("\t%s\n", video_driver_find_ident(d)); + RARCH_WARN("Going to default to first video driver...\n"); + + current_video = (video_driver_t*)video_driver_find_handle(0); + + if (!current_video) + retro_fail(1, "find_video_driver()"); + } + return true; +} + +void video_driver_apply_state_changes(void) +{ + if (!video_driver_poke) + return; + if (video_driver_poke->apply_state_changes) + video_driver_poke->apply_state_changes(video_driver_data); +} + +bool video_driver_read_viewport(uint8_t *buffer) +{ + if (!current_video->read_viewport) + return false; + if (!current_video->read_viewport(video_driver_data, buffer)) + return false; return true; } +bool video_driver_cached_frame_has_valid_framebuffer(void) +{ + if (!video_driver_state.frame_cache.data) + return false; + return video_driver_state.frame_cache.data == RETRO_HW_FRAME_BUFFER_VALID; +} + +bool video_driver_cached_frame_render(void) +{ + if (!current_video) + return false; + return video_driver_cached_frame(); +} + +bool video_driver_is_alive(void) +{ + if (current_video) + return current_video->alive(video_driver_data); + else + return true; +} + +bool video_driver_is_focused(void) +{ + return current_video->focus(video_driver_data); +} + +bool video_driver_has_windowed(void) +{ +#if defined(RARCH_CONSOLE) || defined(RARCH_MOBILE) + return false; +#else + return current_video->has_windowed(video_driver_data); +#endif +} + +uint64_t *video_driver_get_frame_count_ptr(void) +{ + return &video_driver_frame_count; +} + +bool video_driver_frame_filter_alive(void) +{ + return !!video_driver_state.filter.filter; +} + +bool video_driver_frame_filter_is_32bit(void) +{ + return video_driver_state.filter.out_rgb32; +} + +void video_driver_default_settings(void) +{ + global_t *global = global_get_ptr(); + + if (!global) + return; + + global->console.screen.gamma_correction = DEFAULT_GAMMA; + global->console.flickerfilter_enable = false; + global->console.softfilter_enable = false; + + global->console.screen.resolutions.current.id = 0; +} + +void video_driver_load_settings(config_file_t *conf) +{ + global_t *global = global_get_ptr(); + + if (!conf) + return; + + CONFIG_GET_BOOL_BASE(conf, global, + console.screen.gamma_correction, "gamma_correction"); + config_get_bool(conf, "flicker_filter_enable", + &global->console.flickerfilter_enable); + config_get_bool(conf, "soft_filter_enable", + &global->console.softfilter_enable); + + CONFIG_GET_INT_BASE(conf, global, + console.screen.soft_filter_index, + "soft_filter_index"); + CONFIG_GET_INT_BASE(conf, global, + console.screen.resolutions.current.id, + "current_resolution_id"); + CONFIG_GET_INT_BASE(conf, global, + console.screen.flicker_filter_index, + "flicker_filter_index"); +} + +void video_driver_save_settings(config_file_t *conf) +{ + global_t *global = global_get_ptr(); + if (!conf) + return; + + config_set_bool(conf, "gamma_correction", + global->console.screen.gamma_correction); + config_set_bool(conf, "flicker_filter_enable", + global->console.flickerfilter_enable); + config_set_bool(conf, "soft_filter_enable", + global->console.softfilter_enable); + + config_set_int(conf, "soft_filter_index", + global->console.screen.soft_filter_index); + config_set_int(conf, "current_resolution_id", + global->console.screen.resolutions.current.id); + config_set_int(conf, "flicker_filter_index", + global->console.screen.flicker_filter_index); +} + +void video_driver_set_own_driver(void) +{ + video_driver_data_own = true; +} + +void video_driver_unset_own_driver(void) +{ + video_driver_data_own = false; +} + +bool video_driver_owns_driver(void) +{ + return video_driver_data_own; +} + +bool video_driver_is_hw_context(void) +{ + return hw_render.context_type != RETRO_HW_CONTEXT_NONE; +} + +void video_driver_deinit_hw_context(void) +{ + if (hw_render.context_destroy) + hw_render.context_destroy(); + + memset(&hw_render, 0, sizeof(hw_render)); +} + +struct retro_hw_render_callback *video_driver_get_hw_context(void) +{ + return &hw_render; +} + +void video_driver_set_video_cache_context(void) +{ + video_driver_cache_context = true; +} + +void video_driver_unset_video_cache_context(void) +{ + video_driver_cache_context = false; +} + +bool video_driver_is_video_cache_context(void) +{ + return video_driver_cache_context; +} + +void video_driver_set_video_cache_context_ack(void) +{ + video_driver_cache_context_ack = true; +} + +void video_driver_unset_video_cache_context_ack(void) +{ + video_driver_cache_context_ack = false; +} + +bool video_driver_is_video_cache_context_ack(void) +{ + return video_driver_cache_context_ack; +} + +void video_driver_set_active(void) +{ + video_driver_active = true; +} + +void video_driver_unset_active(void) +{ + video_driver_active = false; +} + +bool video_driver_is_active(void) +{ + return video_driver_active; +} + +bool video_driver_has_gpu_record(void) +{ + return video_driver_record_gpu_buffer != NULL; +} + +uint8_t *video_driver_get_gpu_record(void) +{ + return video_driver_record_gpu_buffer; +} + +bool video_driver_gpu_record_init(unsigned size) +{ + video_driver_record_gpu_buffer = (uint8_t*)malloc(size); + if (!video_driver_record_gpu_buffer) + return false; + return true; +} + +void video_driver_gpu_record_deinit(void) +{ + free(video_driver_record_gpu_buffer); + video_driver_record_gpu_buffer = NULL; +} + +bool video_driver_get_current_software_framebuffer(struct retro_framebuffer *fb) +{ + if ( + !video_driver_poke || + !video_driver_poke->get_current_software_framebuffer) + return false; + if (!video_driver_poke->get_current_software_framebuffer( + video_driver_data, fb)) + return false; + + return true; +} + +bool video_driver_get_hw_render_interface(const struct retro_hw_render_interface **iface) +{ + if ( + !video_driver_poke || + !video_driver_poke->get_hw_render_interface) + return false; + + if (!video_driver_poke->get_hw_render_interface(video_driver_data, iface)) + return false; + + return true; +} + +bool video_driver_get_viewport_info(struct video_viewport *viewport) +{ + if (!current_video || !current_video->viewport_info) + return false; + current_video->viewport_info(video_driver_data, viewport); + return true; +} + +void video_driver_set_title_buf(void) +{ + struct retro_system_info info; + core_get_system_info(&info); + strlcpy(video_driver_title_buf, + msg_hash_to_str(MSG_PROGRAM), + sizeof(video_driver_title_buf)); + strlcat(video_driver_title_buf, + " ", sizeof(video_driver_title_buf)); + strlcat(video_driver_title_buf, + info.library_name, + sizeof(video_driver_title_buf)); + strlcat(video_driver_title_buf, + " ", sizeof(video_driver_title_buf)); + strlcat(video_driver_title_buf, + info.library_version, + sizeof(video_driver_title_buf)); +} /** * video_viewport_get_scaled_integer: @@ -1991,7 +2079,7 @@ void video_driver_frame(const void *data, unsigned width, runloop_ctl(RUNLOOP_CTL_MSG_QUEUE_PULL, &msg); - if (!video_driver_ctl(RARCH_DISPLAY_CTL_IS_ACTIVE, NULL)) + if (!video_driver_is_active()) return; if (video_driver_scaler_ptr && @@ -2012,7 +2100,7 @@ void video_driver_frame(const void *data, unsigned width, !video_driver_state.filter.filter || !settings->video.post_filter_record || !data - || video_driver_ctl(RARCH_DISPLAY_CTL_HAS_GPU_RECORD, NULL) + || video_driver_has_gpu_record() ) ) recording_dump_frame(data, width, height, pitch); @@ -2034,7 +2122,9 @@ void video_driver_frame(const void *data, unsigned width, video_driver_data, data, width, height, video_driver_frame_count, pitch, video_driver_msg)) - video_driver_ctl(RARCH_DISPLAY_CTL_UNSET_ACTIVE, NULL); + { + video_driver_unset_active(); + } video_driver_frame_count++; } @@ -2083,7 +2173,7 @@ bool video_driver_texture_load(void *data, *id = video_driver_poke->load_texture(video_driver_data, data, #ifdef HAVE_THREADS settings->video.threaded - && !video_driver_ctl(RARCH_DISPLAY_CTL_IS_HW_CONTEXT, NULL), + && !video_driver_is_hw_context(), #else false, #endif diff --git a/gfx/video_driver.h b/gfx/video_driver.h index f20482ed76..450f3b2782 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -92,81 +92,6 @@ enum rarch_display_type RARCH_DISPLAY_OSX }; -enum rarch_display_ctl_state -{ - RARCH_DISPLAY_CTL_NONE = 0, - RARCH_DISPLAY_CTL_INIT, - RARCH_DISPLAY_CTL_DEINIT, - RARCH_DISPLAY_CTL_DESTROY, - RARCH_DISPLAY_CTL_DESTROY_DATA, - RARCH_DISPLAY_CTL_LOCK, - RARCH_DISPLAY_CTL_UNLOCK, - RARCH_DISPLAY_CTL_LOCK_FREE, - RARCH_DISPLAY_CTL_LOCK_NEW, - RARCH_DISPLAY_CTL_SUPPORTS_RGBA, - RARCH_DISPLAY_CTL_SET_RGBA, - RARCH_DISPLAY_CTL_UNSET_RGBA, - RARCH_DISPLAY_CTL_DEFAULT_SETTINGS, - RARCH_DISPLAY_CTL_LOAD_SETTINGS, - RARCH_DISPLAY_CTL_SAVE_SETTINGS, - RARCH_DISPLAY_CTL_MONITOR_RESET, - RARCH_DISPLAY_CTL_MONITOR_ADJUST_SYSTEM_RATES, - RARCH_DISPLAY_CTL_APPLY_STATE_CHANGES, - RARCH_DISPLAY_CTL_FIND_DRIVER, - RARCH_DISPLAY_CTL_FRAME_FILTER_ALIVE, - RARCH_DISPLAY_CTL_FRAME_FILTER_IS_32BIT, - RARCH_DISPLAY_CTL_GET_PREV_VIDEO_OUT, - RARCH_DISPLAY_CTL_GET_NEXT_VIDEO_OUT, - RARCH_DISPLAY_CTL_HAS_WINDOWED, - RARCH_DISPLAY_CTL_SUPPORTS_RECORDING, - RARCH_DISPLAY_CTL_SUPPORTS_VIEWPORT_READ, - RARCH_DISPLAY_CTL_SUPPORTS_READ_FRAME_RAW, - RARCH_DISPLAY_CTL_IS_FOCUSED, - RARCH_DISPLAY_CTL_IS_ALIVE, - RARCH_DISPLAY_CTL_SET_ASPECT_RATIO, - /* Sets viewport to aspect ratio set by core. */ - RARCH_DISPLAY_CTL_SET_VIEWPORT_CORE, - /* Sets viewport to config aspect ratio. */ - RARCH_DISPLAY_CTL_SET_VIEWPORT_CONFIG, - /* Sets viewport to square pixel aspect ratio based on width/height. */ - RARCH_DISPLAY_CTL_SET_VIEWPORT_SQUARE_PIXEL, - RARCH_DISPLAY_CTL_RESET_CUSTOM_VIEWPORT, - RARCH_DISPLAY_CTL_READ_VIEWPORT, - RARCH_DISPLAY_CTL_SET_NONBLOCK_STATE, - RARCH_DISPLAY_CTL_SET_STUB_FRAME, - RARCH_DISPLAY_CTL_UNSET_STUB_FRAME, - /* Renders the current video frame. */ - RARCH_DISPLAY_CTL_CACHED_FRAME_RENDER, - RARCH_DISPLAY_CTL_CACHED_FRAME_HAS_VALID_FB, - RARCH_DISPLAY_CTL_CACHED_FRAME_SET_PTR, - RARCH_DISPLAY_CTL_SHOW_MOUSE, - RARCH_DISPLAY_CTL_HIDE_MOUSE, - RARCH_DISPLAY_CTL_GET_FRAME_COUNT, - RARCH_DISPLAY_CTL_SET_OWN_DRIVER, - RARCH_DISPLAY_CTL_UNSET_OWN_DRIVER, - RARCH_DISPLAY_CTL_OWNS_DRIVER, - RARCH_DISPLAY_CTL_DEINIT_HW_CONTEXT, - RARCH_DISPLAY_CTL_IS_HW_CONTEXT, - RARCH_DISPLAY_CTL_HW_CONTEXT_GET, - RARCH_DISPLAY_CTL_SET_VIDEO_CACHE_CONTEXT, - RARCH_DISPLAY_CTL_UNSET_VIDEO_CACHE_CONTEXT, - RARCH_DISPLAY_CTL_IS_VIDEO_CACHE_CONTEXT, - RARCH_DISPLAY_CTL_SET_VIDEO_CACHE_CONTEXT_ACK, - RARCH_DISPLAY_CTL_UNSET_VIDEO_CACHE_CONTEXT_ACK, - RARCH_DISPLAY_CTL_IS_VIDEO_CACHE_CONTEXT_ACK, - RARCH_DISPLAY_CTL_SET_ACTIVE, - RARCH_DISPLAY_CTL_UNSET_ACTIVE, - RARCH_DISPLAY_CTL_IS_ACTIVE, - RARCH_DISPLAY_CTL_HAS_GPU_RECORD, - RARCH_DISPLAY_CTL_GPU_RECORD_GET, - RARCH_DISPLAY_CTL_GPU_RECORD_INIT, - RARCH_DISPLAY_CTL_GPU_RECORD_DEINIT, - RARCH_DISPLAY_CTL_GET_CURRENT_SOFTWARE_FRAMEBUFFER, - RARCH_DISPLAY_CTL_GET_HW_RENDER_INTERFACE, - RARCH_DISPLAY_CTL_VIEWPORT_INFO, - RARCH_DISPLAY_CTL_SET_TITLE_BUF -}; - typedef struct video_info { unsigned width; @@ -341,7 +266,72 @@ struct aspect_ratio_elem extern struct aspect_ratio_elem aspectratio_lut[ASPECT_RATIO_END]; -bool video_driver_ctl(enum rarch_display_ctl_state state, void *data); +void video_driver_lock(void); +void video_driver_unlock(void); +void video_driver_lock_free(void); +void video_driver_lock_new(void); +void video_driver_destroy(void); +void video_driver_set_cached_frame_ptr(const void *data); +void video_driver_set_stub_frame(void); +void video_driver_unset_stub_frame(void); +bool video_driver_supports_recording(void); +bool video_driver_supports_viewport_read(void); +bool video_driver_supports_read_frame_raw(void); +void video_driver_set_viewport_config(void); +void video_driver_set_viewport_square_pixel(void); +void video_driver_set_viewport_core(void); +void video_driver_reset_custom_viewport(void); +void video_driver_set_rgba(void); +void video_driver_unset_rgba(void); +bool video_driver_supports_rgba(void); +bool video_driver_get_next_video_out(void); +bool video_driver_get_prev_video_out(void); +bool video_driver_init(void); +void video_driver_destroy_data(void); +void video_driver_deinit(void); +void video_driver_monitor_reset(void); +void video_driver_set_aspect_ratio(void); +void video_driver_show_mouse(void); +void video_driver_hide_mouse(void); +void video_driver_set_nonblock_state(bool toggle); +bool video_driver_find_driver(void); +void video_driver_apply_state_changes(void); +bool video_driver_read_viewport(uint8_t *buffer); +bool video_driver_cached_frame_has_valid_framebuffer(void); +bool video_driver_cached_frame_render(void); +bool video_driver_is_alive(void); +bool video_driver_is_focused(void); +bool video_driver_has_windowed(void); +uint64_t *video_driver_get_frame_count_ptr(void); +bool video_driver_frame_filter_alive(void); +bool video_driver_frame_filter_is_32bit(void); +void video_driver_default_settings(void); +void video_driver_load_settings(config_file_t *conf); +void video_driver_save_settings(config_file_t *conf); +void video_driver_set_own_driver(void); +void video_driver_unset_own_driver(void); +bool video_driver_owns_driver(void); +bool video_driver_is_hw_context(void); +void video_driver_deinit_hw_context(void); +struct retro_hw_render_callback *video_driver_get_hw_context(void); +void video_driver_set_video_cache_context(void); +void video_driver_unset_video_cache_context(void); +bool video_driver_is_video_cache_context(void); +void video_driver_set_video_cache_context_ack(void); +void video_driver_unset_video_cache_context_ack(void); +bool video_driver_is_video_cache_context_ack(void); +void video_driver_set_active(void); +void video_driver_unset_active(void); +bool video_driver_is_active(void); +bool video_driver_has_gpu_record(void); +uint8_t *video_driver_get_gpu_record(void); +bool video_driver_gpu_record_init(unsigned size); +void video_driver_gpu_record_deinit(void); +bool video_driver_get_current_software_framebuffer(struct retro_framebuffer *fb); +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); +void video_driver_monitor_adjust_system_rates(void); /** * video_driver_find_handle: diff --git a/gfx/video_texture_image.c b/gfx/video_texture_image.c index 012b388c31..966ac7812d 100644 --- a/gfx/video_texture_image.c +++ b/gfx/video_texture_image.c @@ -51,8 +51,7 @@ bool video_texture_image_set_color_shifts( *g_shift = 8; *b_shift = 0; - if (video_driver_ctl( - RARCH_DISPLAY_CTL_SUPPORTS_RGBA, NULL)) + if (video_driver_supports_rgba()) { *r_shift = 0; *b_shift = 16; diff --git a/input/drivers/x11_input.c b/input/drivers/x11_input.c index 1354788c24..d9402e5e15 100644 --- a/input/drivers/x11_input.c +++ b/input/drivers/x11_input.c @@ -312,12 +312,12 @@ static void x_input_poll_mouse(x11_input_t *x11) x11->mouse_r = mask & Button3Mask; /* Somewhat hacky, but seem to do the job. */ - if (x11->grab_mouse && video_driver_ctl(RARCH_DISPLAY_CTL_IS_FOCUSED, NULL)) + if (x11->grab_mouse && video_driver_is_focused()) { int mid_w, mid_h; struct video_viewport vp = {0}; - video_driver_ctl(RARCH_DISPLAY_CTL_VIEWPORT_INFO, &vp); + video_driver_get_viewport_info(&vp); mid_w = vp.full_width >> 1; mid_h = vp.full_height >> 1; @@ -338,7 +338,7 @@ static void x_input_poll(void *data) { x11_input_t *x11 = (x11_input_t*)data; - if (video_driver_ctl(RARCH_DISPLAY_CTL_IS_FOCUSED, NULL)) + if (video_driver_is_focused()) XQueryKeymap(x11->display, x11->state); else memset(x11->state, 0, sizeof(x11->state)); diff --git a/input/input_driver.c b/input/input_driver.c index fdb93abf1f..7c2bd548ae 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -379,7 +379,7 @@ bool input_translate_coord_viewport(int mouse_x, int mouse_y, int scaled_screen_x, scaled_screen_y, scaled_x, scaled_y; struct video_viewport vp = {0}; - if (!video_driver_ctl(RARCH_DISPLAY_CTL_VIEWPORT_INFO, &vp)) + if (!video_driver_get_viewport_info(&vp)) return false; scaled_screen_x = (2 * mouse_x * 0x7fff) / (int)vp.full_width - 0x7fff; diff --git a/menu/cbs/menu_cbs_left.c b/menu/cbs/menu_cbs_left.c index 1f0c044087..ab23bbe1bc 100644 --- a/menu/cbs/menu_cbs_left.c +++ b/menu/cbs/menu_cbs_left.c @@ -299,8 +299,7 @@ static int action_left_shader_num_passes(unsigned type, const char *label, static int action_left_video_resolution(unsigned type, const char *label, bool wraparound) { - video_driver_ctl(RARCH_DISPLAY_CTL_GET_PREV_VIDEO_OUT, NULL); - + video_driver_get_prev_video_out(); return 0; } diff --git a/menu/cbs/menu_cbs_right.c b/menu/cbs/menu_cbs_right.c index 85e4c4ac4c..47b865482b 100644 --- a/menu/cbs/menu_cbs_right.c +++ b/menu/cbs/menu_cbs_right.c @@ -322,8 +322,7 @@ static int action_right_shader_num_passes(unsigned type, const char *label, static int action_right_video_resolution(unsigned type, const char *label, bool wraparound) { - video_driver_ctl(RARCH_DISPLAY_CTL_GET_NEXT_VIDEO_OUT, NULL); - + video_driver_get_next_video_out(); return 0; } diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index 875d7c8e44..3d27c90ab0 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -618,7 +618,7 @@ static void mui_render_menu_list(mui_handle_t *mui, uint64_t *frame_count; size_t i = 0; size_t end = menu_entries_get_end(); - video_driver_ctl(RARCH_DISPLAY_CTL_GET_FRAME_COUNT, &frame_count); + frame_count = video_driver_get_frame_count_ptr(); if (!menu_display_get_update_pending()) return; @@ -788,8 +788,7 @@ static void mui_frame(void *data) const uint32_t passivetab_color = 0x9e9e9eff; bool background_rendered = false; bool libretro_running = menu_display_libretro_running(); - - video_driver_ctl(RARCH_DISPLAY_CTL_GET_FRAME_COUNT, &frame_count); + frame_count = video_driver_get_frame_count_ptr(); (void)passivetab_color; (void)activetab_color; diff --git a/menu/drivers/rgui.c b/menu/drivers/rgui.c index 5717e5b101..9f64a98404 100644 --- a/menu/drivers/rgui.c +++ b/menu/drivers/rgui.c @@ -422,7 +422,7 @@ static void rgui_render(void *data) settings_t *settings = config_get_ptr(); rgui_t *rgui = (rgui_t*)data; - video_driver_ctl(RARCH_DISPLAY_CTL_GET_FRAME_COUNT, &frame_count); + frame_count = video_driver_get_frame_count_ptr(); msg[0] = '\0'; title[0] = '\0'; @@ -658,7 +658,7 @@ static void rgui_render(void *data) if (settings->menu.mouse.enable && (settings->video.fullscreen - || !video_driver_ctl(RARCH_DISPLAY_CTL_HAS_WINDOWED, NULL)) + || !video_driver_has_windowed()) ) rgui_blit_cursor(); } diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index fa08b94616..51f80e8b15 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -1640,8 +1640,7 @@ static void xmb_draw_items(xmb_handle_t *xmb, uint64_t *frame_count = NULL; xmb_node_t *core_node = NULL; size_t end = 0; - - video_driver_ctl(RARCH_DISPLAY_CTL_GET_FRAME_COUNT, &frame_count); + frame_count = video_driver_get_frame_count_ptr(); if (!list || !list->size) return; diff --git a/menu/drivers/zarch.c b/menu/drivers/zarch.c index 64dde48889..6ed851130c 100644 --- a/menu/drivers/zarch.c +++ b/menu/drivers/zarch.c @@ -348,8 +348,7 @@ static bool zarch_zui_list_item(zui_t *zui, struct zui_tabbed *tab, int x1, int int y2 = y1 + 50; bool active = zarch_zui_check_button_up(zui, id, x1, y1, x2, y2); const float *bg = zui_bg_panel; - - video_driver_ctl(RARCH_DISPLAY_CTL_GET_FRAME_COUNT, &frame_count); + frame_count = video_driver_get_frame_count_ptr(); if (tab->active_id != tab->prev_id) { diff --git a/menu/menu_display.c b/menu/menu_display.c index 3e453aa05e..f0db55c910 100644 --- a/menu/menu_display.c +++ b/menu/menu_display.c @@ -286,7 +286,7 @@ bool menu_display_libretro(void) return true; } - return video_driver_ctl(RARCH_DISPLAY_CTL_CACHED_FRAME_RENDER, NULL); + return video_driver_cached_frame_render(); } void menu_display_set_width(unsigned width) @@ -577,7 +577,7 @@ void menu_display_draw_cursor( struct gfx_coords coords; settings_t *settings = config_get_ptr(); bool cursor_visible = settings->video.fullscreen || - !video_driver_ctl(RARCH_DISPLAY_CTL_HAS_WINDOWED, NULL); + !video_driver_has_windowed(); if (!settings->menu.mouse.enable) return; diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 0bc85544f4..87d8502097 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -584,7 +584,7 @@ static int setting_uint_action_left_custom_viewport_width(void *data, bool wrapa if (!settings || !av_info) return -1; - video_driver_ctl(RARCH_DISPLAY_CTL_VIEWPORT_INFO, &vp); + video_driver_get_viewport_info(&vp); if (custom->width <= 1) custom->width = 1; @@ -611,7 +611,7 @@ static int setting_uint_action_right_custom_viewport_width(void *data, bool wrap if (!settings || !av_info) return -1; - video_driver_ctl(RARCH_DISPLAY_CTL_VIEWPORT_INFO, &vp); + video_driver_get_viewport_info(&vp); if (settings->video.scale_integer) custom->width += geom->base_width; @@ -636,7 +636,7 @@ static int setting_uint_action_left_custom_viewport_height(void *data, bool wrap if (!settings || !av_info) return -1; - video_driver_ctl(RARCH_DISPLAY_CTL_VIEWPORT_INFO, &vp); + video_driver_get_viewport_info(&vp); if (custom->height <= 1) custom->height = 1; @@ -663,7 +663,7 @@ static int setting_uint_action_right_custom_viewport_height(void *data, bool wra if (!settings || !av_info) return -1; - video_driver_ctl(RARCH_DISPLAY_CTL_VIEWPORT_INFO, &vp); + video_driver_get_viewport_info(&vp); if (settings->video.scale_integer) custom->height += geom->base_height; @@ -2224,7 +2224,7 @@ static int setting_action_start_custom_viewport_width(void *data) if (!settings || !av_info) return -1; - video_driver_ctl(RARCH_DISPLAY_CTL_VIEWPORT_INFO, &vp); + video_driver_get_viewport_info(&vp); if (settings->video.scale_integer) custom->width = ((custom->width + geom->base_width - 1) / @@ -2250,7 +2250,7 @@ static int setting_action_start_custom_viewport_height(void *data) if (!settings || !av_info) return -1; - video_driver_ctl(RARCH_DISPLAY_CTL_VIEWPORT_INFO, &vp); + video_driver_get_viewport_info(&vp); if (settings->video.scale_integer) custom->height = ((custom->height + geom->base_height - 1) / @@ -2335,8 +2335,7 @@ static int setting_action_start_libretro_device_type(void *data) static int setting_action_start_video_refresh_rate_auto( void *data) { - video_driver_ctl(RARCH_DISPLAY_CTL_MONITOR_RESET, NULL); - + video_driver_monitor_reset(); return 0; } @@ -2925,7 +2924,7 @@ void general_write_handler(void *data) struct retro_game_geometry *geom = (struct retro_game_geometry*) &av_info->geometry; - video_driver_ctl(RARCH_DISPLAY_CTL_VIEWPORT_INFO, &vp); + video_driver_get_viewport_info(&vp); if (*setting->value.target.boolean) { @@ -4297,7 +4296,7 @@ static bool setting_append_list( &setting_get_string_representation_uint_video_monitor_index; settings_data_list_current_add_flags(list, list_info, SD_FLAG_ADVANCED); - if (video_driver_ctl(RARCH_DISPLAY_CTL_HAS_WINDOWED, NULL)) + if (video_driver_has_windowed()) { CONFIG_BOOL( list, list_info, @@ -4315,7 +4314,7 @@ static bool setting_append_list( menu_settings_list_current_add_cmd(list, list_info, EVENT_CMD_REINIT); settings_data_list_current_add_flags(list, list_info, SD_FLAG_CMD_APPLY_AUTO); } - if (video_driver_ctl(RARCH_DISPLAY_CTL_HAS_WINDOWED, NULL)) + if (video_driver_has_windowed()) { CONFIG_BOOL( list, list_info, @@ -4489,7 +4488,7 @@ static bool setting_append_list( END_SUB_GROUP(list, list_info, parent_group); START_SUB_GROUP(list, list_info, "Scaling", &group_info, &subgroup_info, parent_group); - if (video_driver_ctl(RARCH_DISPLAY_CTL_HAS_WINDOWED, NULL)) + if (video_driver_has_windowed()) { CONFIG_FLOAT( list, list_info, diff --git a/record/record_driver.c b/record/record_driver.c index fd8c14b5df..d5e0bb71ad 100644 --- a/record/record_driver.c +++ b/record/record_driver.c @@ -187,12 +187,12 @@ void recording_dump_frame(const void *data, unsigned width, ffemu_data.height = height; ffemu_data.data = data; - if (video_driver_ctl(RARCH_DISPLAY_CTL_HAS_GPU_RECORD, NULL)) + if (video_driver_has_gpu_record()) { uint8_t *gpu_buf = NULL; struct video_viewport vp = {0}; - video_driver_ctl(RARCH_DISPLAY_CTL_VIEWPORT_INFO, &vp); + video_driver_get_viewport_info(&vp); if (!vp.width || !vp.height) { @@ -217,14 +217,15 @@ void recording_dump_frame(const void *data, unsigned width, return; } - if (!video_driver_ctl(RARCH_DISPLAY_CTL_GPU_RECORD_GET, &gpu_buf)) + gpu_buf = video_driver_get_gpu_record(); + if (!gpu_buf) return; /* Big bottleneck. * Since we might need to do read-backs asynchronously, * it might take 3-4 times before this returns true. */ - if (!video_driver_ctl(RARCH_DISPLAY_CTL_READ_VIEWPORT, gpu_buf)) - return; + if (!video_driver_read_viewport(gpu_buf)) + return; ffemu_data.pitch = global->record.gpu_width * 3; ffemu_data.width = global->record.gpu_width; @@ -234,7 +235,7 @@ void recording_dump_frame(const void *data, unsigned width, ffemu_data.pitch = -ffemu_data.pitch; } - if (!video_driver_ctl(RARCH_DISPLAY_CTL_HAS_GPU_RECORD, NULL)) + if (!video_driver_has_gpu_record()) ffemu_data.is_dupe = !data; if (recording_driver && recording_driver->push_video) @@ -311,7 +312,7 @@ bool recording_init(void) } if (!settings->video.gpu_record - && video_driver_ctl(RARCH_DISPLAY_CTL_IS_HW_CONTEXT, NULL)) + && video_driver_is_hw_context()) { RARCH_WARN("%s.\n", msg_hash_to_str(MSG_HW_RENDERED_MUST_USE_POSTSHADED_RECORDING)); @@ -345,12 +346,12 @@ bool recording_init(void) if (*global->record.config) params.config = global->record.config; - if (video_driver_ctl(RARCH_DISPLAY_CTL_SUPPORTS_RECORDING, NULL)) + if (video_driver_supports_recording()) { unsigned gpu_size; struct video_viewport vp = {0}; - video_driver_ctl(RARCH_DISPLAY_CTL_VIEWPORT_INFO, &vp); + video_driver_get_viewport_info(&vp); if (!vp.width || !vp.height) { @@ -378,7 +379,7 @@ bool recording_init(void) vp.width, vp.height); gpu_size = vp.width * vp.height * 3; - if (!video_driver_ctl(RARCH_DISPLAY_CTL_GPU_RECORD_INIT, &gpu_size)) + if (!video_driver_gpu_record_init(gpu_size)) return false; } else @@ -396,14 +397,14 @@ bool recording_init(void) params.aspect_ratio = (float)params.out_width / params.out_height; if (settings->video.post_filter_record - && video_driver_ctl(RARCH_DISPLAY_CTL_FRAME_FILTER_ALIVE, NULL)) + && video_driver_frame_filter_alive()) { unsigned max_width = 0; unsigned max_height = 0; params.pix_fmt = FFEMU_PIX_RGB565; - if (video_driver_ctl(RARCH_DISPLAY_CTL_FRAME_FILTER_IS_32BIT, NULL)) + if (video_driver_frame_filter_is_32bit()) params.pix_fmt = FFEMU_PIX_ARGB8888; rarch_softfilter_get_max_output_size( diff --git a/retroarch.c b/retroarch.c index f577120dad..f5147d910d 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1157,7 +1157,7 @@ static void rarch_init_savefile_paths(void) static bool init_state(void) { - video_driver_ctl(RARCH_DISPLAY_CTL_SET_ACTIVE, NULL); + video_driver_set_active(); audio_driver_ctl(RARCH_AUDIO_CTL_SET_ACTIVE, NULL); rarch_ctl(RARCH_CTL_UNSET_FORCE_FULLSCREEN, NULL); diff --git a/runloop.c b/runloop.c index 9c71752fd4..72d1f9e4ae 100644 --- a/runloop.c +++ b/runloop.c @@ -222,7 +222,7 @@ static bool runloop_check_slowmotion(bool *ptr) return false; if (settings->video.black_frame_insertion) - video_driver_ctl(RARCH_DISPLAY_CTL_CACHED_FRAME_RENDER, NULL); + video_driver_cached_frame_render(); if (state_manager_frame_is_reversed()) runloop_msg_queue_push(msg_hash_to_str(MSG_SLOW_MOTION_REWIND), 0, 30, true); @@ -612,7 +612,7 @@ static bool runloop_check_pause_state(event_cmd_state_t *cmd) if (runloop_cmd_triggered(cmd, RARCH_FULLSCREEN_TOGGLE_KEY)) { event_cmd_ctl(EVENT_CMD_FULLSCREEN_TOGGLE, NULL); - video_driver_ctl(RARCH_DISPLAY_CTL_CACHED_FRAME_RENDER, NULL); + video_driver_cached_frame_render(); } if (!check_is_oneshot) @@ -630,14 +630,14 @@ static bool runloop_is_focused(void) { settings_t *settings = config_get_ptr(); if (settings->pause_nonactive) - return video_driver_ctl(RARCH_DISPLAY_CTL_IS_FOCUSED, NULL); + return video_driver_is_focused(); return true; } static bool runloop_is_frame_count_end(void) { - uint64_t *frame_count = NULL; - video_driver_ctl(RARCH_DISPLAY_CTL_GET_FRAME_COUNT, &frame_count); + uint64_t *frame_count = + video_driver_get_frame_count_ptr(); return runloop_max_frames && (*frame_count >= runloop_max_frames); } @@ -660,7 +660,7 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) if (!runloop_system.info.library_version) runloop_system.info.library_version = "v0"; - video_driver_ctl(RARCH_DISPLAY_CTL_SET_TITLE_BUF, NULL); + video_driver_set_title_buf(); strlcpy(runloop_system.valid_extensions, runloop_system.info.valid_extensions ? @@ -1257,7 +1257,7 @@ static INLINE int runloop_iterate_time_to_exit(bool quit_key_pressed) settings_t *settings = NULL; bool time_to_exit = runloop_ctl(RUNLOOP_CTL_IS_SHUTDOWN, NULL); time_to_exit = time_to_exit || quit_key_pressed; - time_to_exit = time_to_exit || !video_driver_ctl(RARCH_DISPLAY_CTL_IS_ALIVE, NULL); + time_to_exit = time_to_exit || !video_driver_is_alive(); time_to_exit = time_to_exit || bsv_movie_ctl(BSV_MOVIE_CTL_END_EOF, NULL); time_to_exit = time_to_exit || runloop_is_frame_count_end(); time_to_exit = time_to_exit || runloop_ctl(RUNLOOP_CTL_IS_EXEC, NULL); diff --git a/screenshot.c b/screenshot.c index bff7a629b5..70d196d0f5 100644 --- a/screenshot.c +++ b/screenshot.c @@ -144,7 +144,7 @@ static bool take_screenshot_viewport(void) settings_t *settings = config_get_ptr(); global_t *global = global_get_ptr(); - video_driver_ctl(RARCH_DISPLAY_CTL_VIEWPORT_INFO, &vp); + video_driver_get_viewport_info(&vp); if (!vp.width || !vp.height) return false; @@ -152,7 +152,7 @@ static bool take_screenshot_viewport(void) if (!(buffer = (uint8_t*)malloc(vp.width * vp.height * 3))) return false; - if (!video_driver_ctl(RARCH_DISPLAY_CTL_READ_VIEWPORT, buffer)) + if (!video_driver_read_viewport(buffer)) goto done; screenshot_dir = settings->directory.screenshot; @@ -213,18 +213,18 @@ static bool take_screenshot_choice(void) if ((!*settings->directory.screenshot) && (!*global->name.base)) return false; - if (video_driver_ctl(RARCH_DISPLAY_CTL_SUPPORTS_VIEWPORT_READ, NULL)) + if (video_driver_supports_viewport_read()) { /* Avoid taking screenshot of GUI overlays. */ video_driver_set_texture_enable(false, false); - video_driver_ctl(RARCH_DISPLAY_CTL_CACHED_FRAME_RENDER, NULL); + video_driver_cached_frame_render(); return take_screenshot_viewport(); } - if (!video_driver_ctl(RARCH_DISPLAY_CTL_CACHED_FRAME_HAS_VALID_FB, NULL)) + if (!video_driver_cached_frame_has_valid_framebuffer()) return take_screenshot_raw(); - if (video_driver_ctl(RARCH_DISPLAY_CTL_SUPPORTS_READ_FRAME_RAW, NULL)) + if (video_driver_supports_read_frame_raw()) { unsigned old_width, old_height; size_t old_pitch; @@ -243,7 +243,7 @@ static bool take_screenshot_choice(void) if (frame_data) { - video_driver_ctl(RARCH_DISPLAY_CTL_CACHED_FRAME_SET_PTR, (void*)frame_data); + video_driver_set_cached_frame_ptr(frame_data); if (take_screenshot_raw()) ret = true; free(frame_data); @@ -274,7 +274,7 @@ bool take_screenshot(void) runloop_msg_queue_push(msg, 1, is_paused ? 1 : 180, true); if (is_paused) - video_driver_ctl(RARCH_DISPLAY_CTL_CACHED_FRAME_RENDER, NULL); + video_driver_cached_frame_render(); return ret; } From 66c4f608e6a988fbf014cc1624691c3b872901fc Mon Sep 17 00:00:00 2001 From: Hans-Kristian Arntzen Date: Sun, 8 May 2016 14:10:28 +0200 Subject: [PATCH 261/498] Clear out rest of video_driver_ctl use. --- configuration.c | 2 +- gfx/d3d/d3d.cpp | 16 ++++++---------- gfx/d3d/render_chain_xdk.cpp | 2 +- gfx/drivers/ctr_gfx.c | 10 +++------- gfx/drivers/exynos_gfx.c | 10 +++------- gfx/drivers/gl.c | 4 ++-- gfx/drivers/gx_gfx.c | 10 +++------- gfx/drivers/psp1_gfx.c | 10 +++------- gfx/drivers/sdl2_gfx.c | 12 ++++-------- gfx/drivers/vita2d_gfx.c | 10 +++------- gfx/drivers_context/sdl_gl_ctx.c | 2 +- gfx/drivers_context/wgl_ctx.cpp | 6 +++--- input/drivers/android_input.c | 4 ++-- menu/drivers/xui.cpp | 2 +- 14 files changed, 36 insertions(+), 64 deletions(-) diff --git a/configuration.c b/configuration.c index 219cd5138b..2adf63d908 100644 --- a/configuration.c +++ b/configuration.c @@ -1406,7 +1406,7 @@ static bool config_load_file(const char *path, bool set_defaults) * important that it works for consoles right now */ config_get_bool(conf, "custom_bgm_enable", &global->console.sound.system_bgm_enable); - video_driver_ctl(RARCH_DISPLAY_CTL_LOAD_SETTINGS, conf); + video_driver_load_settings(conf); #endif CONFIG_GET_INT_BASE(conf, settings, state_slot, "state_slot"); diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 77b12cf8a0..26c694f9b7 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -913,29 +913,25 @@ static bool d3d_has_windowed(void *data) static void d3d_set_aspect_ratio(void *data, unsigned aspect_ratio_idx) { d3d_video_t *d3d = (d3d_video_t*)data; - enum rarch_display_ctl_state cmd = RARCH_DISPLAY_CTL_NONE; switch (aspect_ratio_idx) { case ASPECT_RATIO_SQUARE: - cmd = RARCH_DISPLAY_CTL_SET_VIEWPORT_SQUARE_PIXEL; + video_driver_set_viewport_square_pixel(); break; case ASPECT_RATIO_CORE: - cmd = RARCH_DISPLAY_CTL_SET_VIEWPORT_CORE; + video_driver_set_viewport_core(); break; case ASPECT_RATIO_CONFIG: - cmd = RARCH_DISPLAY_CTL_SET_VIEWPORT_CONFIG; + video_driver_set_viewport_config(); break; default: break; } - if (cmd != RARCH_DISPLAY_CTL_NONE) - video_driver_ctl(cmd, NULL); - video_driver_set_aspect_ratio_value(aspectratio_lut[aspect_ratio_idx].value); if (!d3d) @@ -1129,7 +1125,7 @@ static void *d3d_init(const video_info_t *info, input_driver_set(input, input_data); - video_driver_ctl(RARCH_DISPLAY_CTL_SET_OWN_DRIVER, NULL); + video_driver_set_own_driver(); return d3d; } } @@ -1168,8 +1164,8 @@ static void *d3d_init(const video_info_t *info, d3d->keep_aspect = info->force_aspect; #ifdef _XBOX - video_driver_ctl(RARCH_DISPLAY_CTL_SET_OWN_DRIVER, NULL); - video_driver_ctl(RARCH_INPUT_CTL_SET_OWN_DRIVER, NULL); + video_driver_set_own_driver(); + video_input_ctl(RARCH_INPUT_CTL_SET_OWN_DRIVER, NULL); #endif return d3d; diff --git a/gfx/d3d/render_chain_xdk.cpp b/gfx/d3d/render_chain_xdk.cpp index a18dc19032..3f1a4dc6a2 100644 --- a/gfx/d3d/render_chain_xdk.cpp +++ b/gfx/d3d/render_chain_xdk.cpp @@ -398,7 +398,7 @@ static bool xdk_renderchain_render(void *data, const void *frame, settings_t *settings = config_get_ptr(); xdk_renderchain_t *chain = (xdk_renderchain_t*)d3d->renderchain_data; - video_driver_ctl(RARCH_DISPLAY_CTL_GET_FRAME_COUNT, &frame_count); + frame_count = video_driver_get_frame_count_ptr(); video_driver_get_size(&width, &height); diff --git a/gfx/drivers/ctr_gfx.c b/gfx/drivers/ctr_gfx.c index 5f47769f48..31919122f2 100644 --- a/gfx/drivers/ctr_gfx.c +++ b/gfx/drivers/ctr_gfx.c @@ -961,29 +961,25 @@ static void ctr_set_filtering(void* data, unsigned index, bool smooth) static void ctr_set_aspect_ratio(void* data, unsigned aspect_ratio_idx) { ctr_video_t *ctr = (ctr_video_t*)data; - enum rarch_display_ctl_state cmd = RARCH_DISPLAY_CTL_NONE; switch (aspect_ratio_idx) { case ASPECT_RATIO_SQUARE: - cmd = RARCH_DISPLAY_CTL_SET_VIEWPORT_SQUARE_PIXEL; + video_driver_set_viewport_square_pixel(); break; case ASPECT_RATIO_CORE: - cmd = RARCH_DISPLAY_CTL_SET_VIEWPORT_CORE; + video_driver_set_viewport_core(); break; case ASPECT_RATIO_CONFIG: - cmd = RARCH_DISPLAY_CTL_SET_VIEWPORT_CONFIG; + video_driver_set_viewport_config(); break; default: break; } - if (cmd != RARCH_DISPLAY_CTL_NONE) - video_driver_ctl(cmd, NULL); - video_driver_set_aspect_ratio_value(aspectratio_lut[aspect_ratio_idx].value); ctr->keep_aspect = true; diff --git a/gfx/drivers/exynos_gfx.c b/gfx/drivers/exynos_gfx.c index bdcfa55911..3b86a97257 100644 --- a/gfx/drivers/exynos_gfx.c +++ b/gfx/drivers/exynos_gfx.c @@ -1402,29 +1402,25 @@ static void exynos_gfx_viewport_info(void *data, struct video_viewport *vp) static void exynos_set_aspect_ratio(void *data, unsigned aspect_ratio_idx) { struct exynos_video *vid = (struct exynos_video*)data; - enum rarch_display_ctl_state cmd = RARCH_DISPLAY_CTL_NONE; switch (aspect_ratio_idx) { case ASPECT_RATIO_SQUARE: - cmd = RARCH_DISPLAY_CTL_SET_VIEWPORT_SQUARE_PIXEL; + video_driver_set_viewport_square_pixel(); break; case ASPECT_RATIO_CORE: - cmd = RARCH_DISPLAY_CTL_SET_VIEWPORT_CORE; + video_driver_set_viewport_core(); break; case ASPECT_RATIO_CONFIG: - cmd = RARCH_DISPLAY_CTL_SET_VIEWPORT_CONFIG; + video_driver_set_viewport_config(); break; default: break; } - if (cmd != RARCH_DISPLAY_CTL_NONE) - video_driver_ctl(cmd, NULL); - video_driver_set_aspect_ratio_value(aspectratio_lut[aspect_ratio_idx].value); vid->aspect_changed = true; } diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 68da573c1d..e06ca87be0 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -1480,7 +1480,7 @@ static INLINE void gl_copy_frame(gl_t *gl, const void *frame, else #endif { - bool use_rgba = video_driver_ctl(RARCH_DISPLAY_CTL_SUPPORTS_RGBA, NULL); + bool use_rgba = video_driver_supports_rgba(); glPixelStorei(GL_UNPACK_ALIGNMENT, video_pixel_get_alignment(width * gl->base_size)); @@ -2253,7 +2253,7 @@ static bool resolve_extensions(gl_t *gl, const char *context_ident) RARCH_LOG("[GL]: BGRA8888 extension found for GLES.\n"); else { - video_driver_ctl(RARCH_DISPLAY_CTL_SET_RGBA, NULL); + video_driver_set_rgba(); RARCH_WARN("[GL]: GLES implementation does not have BGRA8888 extension.\n" "32-bit path will require conversion.\n"); } diff --git a/gfx/drivers/gx_gfx.c b/gfx/drivers/gx_gfx.c index af95198bff..3b483a111b 100644 --- a/gfx/drivers/gx_gfx.c +++ b/gfx/drivers/gx_gfx.c @@ -472,29 +472,25 @@ static void gx_set_video_mode(void *data, unsigned fbWidth, unsigned lines, static void gx_set_aspect_ratio(void *data, unsigned aspect_ratio_idx) { gx_video_t *gx = (gx_video_t*)data; - enum rarch_display_ctl_state cmd = RARCH_DISPLAY_CTL_NONE; switch (aspect_ratio_idx) { case ASPECT_RATIO_SQUARE: - cmd = RARCH_DISPLAY_CTL_SET_VIEWPORT_SQUARE_PIXEL; + video_driver_set_viewport_square_pixel(); break; case ASPECT_RATIO_CORE: - cmd = RARCH_DISPLAY_CTL_SET_VIEWPORT_CORE; + video_driver_set_viewport_core(); break; case ASPECT_RATIO_CONFIG: - cmd = RARCH_DISPLAY_CTL_SET_VIEWPORT_CONFIG; + video_driver_set_viewport_config(); break; default: break; } - if (cmd != RARCH_DISPLAY_CTL_NONE) - video_driver_ctl(cmd, NULL); - video_driver_set_aspect_ratio_value( aspectratio_lut[aspect_ratio_idx].value); diff --git a/gfx/drivers/psp1_gfx.c b/gfx/drivers/psp1_gfx.c index ed4c96605d..54d11a2408 100644 --- a/gfx/drivers/psp1_gfx.c +++ b/gfx/drivers/psp1_gfx.c @@ -793,29 +793,25 @@ static void psp_set_filtering(void *data, unsigned index, bool smooth) static void psp_set_aspect_ratio(void *data, unsigned aspect_ratio_idx) { psp1_video_t *psp = (psp1_video_t*)data; - enum rarch_display_ctl_state cmd = RARCH_DISPLAY_CTL_NONE; switch (aspect_ratio_idx) { case ASPECT_RATIO_SQUARE: - cmd = RARCH_DISPLAY_CTL_SET_VIEWPORT_SQUARE_PIXEL; + video_driver_set_viewport_square_pixel(); break; case ASPECT_RATIO_CORE: - cmd = RARCH_DISPLAY_CTL_SET_VIEWPORT_CORE; + video_driver_set_viewport_core(); break; case ASPECT_RATIO_CONFIG: - cmd = RARCH_DISPLAY_CTL_SET_VIEWPORT_CONFIG; + video_driver_set_viewport_config(); break; default: break; } - if (cmd != RARCH_DISPLAY_CTL_NONE) - video_driver_ctl(cmd, NULL); - video_driver_set_aspect_ratio_value(aspectratio_lut[aspect_ratio_idx].value); psp->keep_aspect = true; diff --git a/gfx/drivers/sdl2_gfx.c b/gfx/drivers/sdl2_gfx.c index 8b894363ee..1729561738 100644 --- a/gfx/drivers/sdl2_gfx.c +++ b/gfx/drivers/sdl2_gfx.c @@ -629,7 +629,7 @@ static bool sdl2_gfx_read_viewport(void *data, uint8_t *buffer) rarch_perf_init(&sdl2_gfx_read_viewport, "sdl2_gfx_read_viewport"); retro_perf_start(&sdl2_gfx_read_viewport); - video_driver_ctl(RARCH_DISPLAY_CTL_CACHED_FRAME_RENDER, NULL); + video_driver_cached_frame_render(); surf = SDL_GetWindowSurface(vid->window); bgr24 = SDL_ConvertSurfaceFormat(surf, SDL_PIXELFORMAT_BGR24, 0); @@ -658,29 +658,25 @@ static void sdl2_poke_set_filtering(void *data, unsigned index, bool smooth) static void sdl2_poke_set_aspect_ratio(void *data, unsigned aspect_ratio_idx) { sdl2_video_t *vid = (sdl2_video_t*)data; - enum rarch_display_ctl_state cmd = RARCH_DISPLAY_CTL_NONE; switch (aspect_ratio_idx) { case ASPECT_RATIO_SQUARE: - cmd = RARCH_DISPLAY_CTL_SET_VIEWPORT_SQUARE_PIXEL; + video_driver_set_viewport_square_pixel(); break; case ASPECT_RATIO_CORE: - cmd = RARCH_DISPLAY_CTL_SET_VIEWPORT_CORE; + video_driver_set_viewport_core(); break; case ASPECT_RATIO_CONFIG: - cmd = RARCH_DISPLAY_CTL_SET_VIEWPORT_CONFIG; + video_driver_set_viewport_config(); break; default: break; } - if (cmd != RARCH_DISPLAY_CTL_NONE) - video_driver_ctl(cmd, NULL); - video_driver_set_aspect_ratio_value(aspectratio_lut[aspect_ratio_idx].value); vid->video.force_aspect = true; diff --git a/gfx/drivers/vita2d_gfx.c b/gfx/drivers/vita2d_gfx.c index da8b79921e..d982fe420a 100644 --- a/gfx/drivers/vita2d_gfx.c +++ b/gfx/drivers/vita2d_gfx.c @@ -489,29 +489,25 @@ static void vita_set_filtering(void *data, unsigned index, bool smooth) static void vita_set_aspect_ratio(void *data, unsigned aspect_ratio_idx) { vita_video_t *vita = (vita_video_t*)data; - enum rarch_display_ctl_state cmd = RARCH_DISPLAY_CTL_NONE; switch (aspect_ratio_idx) { case ASPECT_RATIO_SQUARE: - cmd = RARCH_DISPLAY_CTL_SET_VIEWPORT_SQUARE_PIXEL; + video_driver_set_viewport_square_pixel(); break; case ASPECT_RATIO_CORE: - cmd = RARCH_DISPLAY_CTL_SET_VIEWPORT_CORE; + video_driver_set_viewport_core(); break; case ASPECT_RATIO_CONFIG: - cmd = RARCH_DISPLAY_CTL_SET_VIEWPORT_CONFIG; + video_driver_set_viewport_config(); break; default: break; } - if (cmd != RARCH_DISPLAY_CTL_NONE) - video_driver_ctl(cmd, NULL); - video_driver_set_aspect_ratio_value(aspectratio_lut[aspect_ratio_idx].value); vita->keep_aspect = true; diff --git a/gfx/drivers_context/sdl_gl_ctx.c b/gfx/drivers_context/sdl_gl_ctx.c index c5c9ef890c..caaccbd653 100644 --- a/gfx/drivers_context/sdl_gl_ctx.c +++ b/gfx/drivers_context/sdl_gl_ctx.c @@ -200,7 +200,7 @@ static bool sdl_ctx_set_video_mode(void *data, unsigned width, unsigned height, #ifdef HAVE_SDL2 if (sdl->g_ctx) - video_driver_ctl(RARCH_DISPLAY_CTL_SET_VIDEO_CACHE_CONTEXT_ACK, NULL); + video_driver_set_video_cache_context_ack(); else { sdl->g_ctx = SDL_GL_CreateContext(sdl->g_win); diff --git a/gfx/drivers_context/wgl_ctx.cpp b/gfx/drivers_context/wgl_ctx.cpp index b7f24019f5..d8b687b7f1 100644 --- a/gfx/drivers_context/wgl_ctx.cpp +++ b/gfx/drivers_context/wgl_ctx.cpp @@ -102,7 +102,7 @@ void create_gl_context(HWND hwnd, bool *quit) struct retro_hw_render_callback *hwr = NULL; bool debug = false; - video_driver_ctl(RARCH_DISPLAY_CTL_HW_CONTEXT_GET, &hwr); + hwr = video_driver_get_hw_context(); debug = hwr->debug_context; #ifdef _WIN32 @@ -119,7 +119,7 @@ void create_gl_context(HWND hwnd, bool *quit) if (g_hrc) { RARCH_LOG("[WGL]: Using cached GL context.\n"); - video_driver_ctl(RARCH_DISPLAY_CTL_SET_VIDEO_CACHE_CONTEXT_ACK, NULL); + video_driver_set_video_cache_context_ack(); } else { @@ -329,7 +329,7 @@ static void gfx_ctx_wgl_destroy(void *data) glFinish(); wglMakeCurrent(NULL, NULL); - if (!video_driver_ctl(RARCH_DISPLAY_CTL_IS_VIDEO_CACHE_CONTEXT, NULL)) + if (!video_driver_is_video_cache_context()) { if (g_hw_hrc) wglDeleteContext(g_hw_hrc); diff --git a/input/drivers/android_input.c b/input/drivers/android_input.c index 7de8fdea33..c8be598441 100644 --- a/input/drivers/android_input.c +++ b/input/drivers/android_input.c @@ -341,7 +341,7 @@ static void android_input_poll_main_cmd(void) runloop_ctl(RUNLOOP_CTL_SET_IDLE, &boolean); #ifdef HAVE_MENU menu_display_ctl(MENU_DISPLAY_CTL_UNSET_STUB_DRAW_FRAME, NULL); - video_driver_ctl(RARCH_DISPLAY_CTL_UNSET_STUB_FRAME, NULL); + video_driver_unset_stub_frame(); #endif if ((android_app->sensor_state_mask @@ -364,7 +364,7 @@ static void android_input_poll_main_cmd(void) runloop_ctl(RUNLOOP_CTL_SET_IDLE, &boolean); #ifdef HAVE_MENU menu_display_ctl(MENU_DISPLAY_CTL_SET_STUB_DRAW_FRAME, NULL); - video_driver_ctl(RARCH_DISPLAY_CTL_SET_STUB_FRAME, NULL); + video_driver_set_stub_frame(); #endif /* Avoid draining battery while app is not being used. */ diff --git a/menu/drivers/xui.cpp b/menu/drivers/xui.cpp index b06efdefc9..705ecf2714 100644 --- a/menu/drivers/xui.cpp +++ b/menu/drivers/xui.cpp @@ -534,7 +534,7 @@ static void xui_render(void *data) const char *label = NULL; unsigned menu_type = 0; - video_driver_ctl(RARCH_DISPLAY_CTL_GET_FRAME_COUNT, &frame_count); + frame_count = video_driver_get_frame_count_ptr(); menu_display_ctl(MENU_DISPLAY_CTL_WIDTH, &fb_width); menu_display_ctl(MENU_DISPLAY_CTL_MSG_FORCE, &msg_force); From 8870e853957758c396fdc4a3d6e918e6345500f3 Mon Sep 17 00:00:00 2001 From: Hans-Kristian Arntzen Date: Sun, 8 May 2016 14:18:12 +0200 Subject: [PATCH 262/498] More fixes for menu_display_ctl. Grep shows nothing now. --- gfx/drivers/gx_gfx.c | 16 +- input/drivers/android_input.c | 2 - menu/drivers/nk_common.c | 554 +++++++++++----------- menu/drivers/nuklear.c | 21 +- menu/drivers/xui.cpp | 12 +- menu/drivers_display/menu_display_d3d.cpp | 2 +- 6 files changed, 300 insertions(+), 307 deletions(-) diff --git a/gfx/drivers/gx_gfx.c b/gfx/drivers/gx_gfx.c index 3b483a111b..db5a246816 100644 --- a/gfx/drivers/gx_gfx.c +++ b/gfx/drivers/gx_gfx.c @@ -413,9 +413,9 @@ static void gx_set_video_mode(void *data, unsigned fbWidth, unsigned lines, new_fb_pitch = new_fb_width * 2; - menu_display_ctl(MENU_DISPLAY_CTL_SET_WIDTH, &new_fb_width); - menu_display_ctl(MENU_DISPLAY_CTL_SET_HEIGHT, &new_fb_height); - menu_display_ctl(MENU_DISPLAY_CTL_SET_FB_PITCH, &new_fb_pitch); + menu_display_set_width(new_fb_width); + menu_display_set_height(new_fb_height); + menu_display_set_framebuffer_pitch(new_fb_pitch); GX_SetViewportJitter(0, 0, gx_mode.fbWidth, gx_mode.efbHeight, 0, 1, 1); GX_SetDispCopySrc(0, 0, gx_mode.fbWidth, gx_mode.efbHeight); @@ -551,8 +551,8 @@ static void init_texture(void *data, unsigned width, unsigned height) menu_w = 320; menu_h = 240; - menu_display_ctl(MENU_DISPLAY_CTL_WIDTH, &menu_w); - menu_display_ctl(MENU_DISPLAY_CTL_HEIGHT, &menu_h); + menu_w = menu_display_get_width(); + menu_h = menu_display_get_height(); GX_InitTexObj(fb_ptr, g_tex.data, width, height, (gx->rgb32) ? GX_TF_RGBA8 : gx->menu_texture_enable ? @@ -1492,9 +1492,9 @@ static bool gx_frame(void *data, const void *frame, size_t fb_pitch; unsigned fb_width, fb_height; - menu_display_ctl(MENU_DISPLAY_CTL_WIDTH, &fb_width); - menu_display_ctl(MENU_DISPLAY_CTL_HEIGHT, &fb_height); - menu_display_ctl(MENU_DISPLAY_CTL_FB_PITCH, &fb_pitch); + fb_width = menu_display_get_width(); + fb_height = menu_display_get_height(); + fb_pitch = menu_display_get_framebuffer_pitch(); convert_texture16( gx->menu_data, diff --git a/input/drivers/android_input.c b/input/drivers/android_input.c index c8be598441..c3f450a9cc 100644 --- a/input/drivers/android_input.c +++ b/input/drivers/android_input.c @@ -340,7 +340,6 @@ static void android_input_poll_main_cmd(void) runloop_ctl(RUNLOOP_CTL_SET_PAUSED, &boolean); runloop_ctl(RUNLOOP_CTL_SET_IDLE, &boolean); #ifdef HAVE_MENU - menu_display_ctl(MENU_DISPLAY_CTL_UNSET_STUB_DRAW_FRAME, NULL); video_driver_unset_stub_frame(); #endif @@ -363,7 +362,6 @@ static void android_input_poll_main_cmd(void) runloop_ctl(RUNLOOP_CTL_SET_PAUSED, &boolean); runloop_ctl(RUNLOOP_CTL_SET_IDLE, &boolean); #ifdef HAVE_MENU - menu_display_ctl(MENU_DISPLAY_CTL_SET_STUB_DRAW_FRAME, NULL); video_driver_set_stub_frame(); #endif diff --git a/menu/drivers/nk_common.c b/menu/drivers/nk_common.c index 13823f0504..1edd4f6e16 100644 --- a/menu/drivers/nk_common.c +++ b/menu/drivers/nk_common.c @@ -1,279 +1,279 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2011-2016 - Daniel De Matteis - * Copyright (C) 2014-2015 - Jean-Andr� Santoni - * Copyright (C) 2016 - 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. - * - * 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 - -#define NK_INCLUDE_FIXED_TYPES -#define NK_INCLUDE_STANDARD_IO -#define NK_INCLUDE_DEFAULT_ALLOCATOR -#define NK_INCLUDE_VERTEX_BUFFER_OUTPUT -#define NK_INCLUDE_FONT_BAKING +/* RetroArch - A frontend for libretro. + * Copyright (C) 2011-2016 - Daniel De Matteis + * Copyright (C) 2014-2015 - Jean-Andr� Santoni + * Copyright (C) 2016 - 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. + * + * 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 + +#define NK_INCLUDE_FIXED_TYPES +#define NK_INCLUDE_STANDARD_IO +#define NK_INCLUDE_DEFAULT_ALLOCATOR +#define NK_INCLUDE_VERTEX_BUFFER_OUTPUT +#define NK_INCLUDE_FONT_BAKING #define NK_INCLUDE_DEFAULT_FONT #define NK_IMPLEMENTATION - -#include "nk_common.h" - -#include "../menu_display.h" -#include "../../gfx/video_shader_driver.h" - -#include "../../gfx/drivers/gl_shaders/pipeline_zahnrad.glsl.vert.h" -#include "../../gfx/drivers/gl_shaders/pipeline_zahnrad.glsl.frag.h" - -struct nk_font *font; -struct nk_font_atlas atlas; -struct nk_user_font usrfnt; -struct nk_allocator nk_alloc; -struct nk_device device; - -struct nk_image nk_common_image_load(const char *filename) -{ - int x,y,n; - GLuint tex; - unsigned char *data = stbi_load(filename, &x, &y, &n, 0); - if (!data) printf("Failed to load image: %s\n", filename); - -#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) - glGenTextures(1, &tex); - glBindTexture(GL_TEXTURE_2D, tex); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_NEAREST); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); - glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, x, y, 0, GL_RGBA, GL_UNSIGNED_BYTE, data); - glGenerateMipmap(GL_TEXTURE_2D); -#endif - - stbi_image_free(data); - return nk_image_id((int)tex); -} - -char* nk_common_file_load(const char* path, size_t* size) -{ - void *buf; - ssize_t *length = (ssize_t*)size; - filestream_read_file(path, &buf, length); - return (char*)buf; -} - -NK_API void nk_common_device_init(struct nk_device *dev) -{ -#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) - GLint status; - - dev->prog = glCreateProgram(); - dev->vert_shdr = glCreateShader(GL_VERTEX_SHADER); - dev->frag_shdr = glCreateShader(GL_FRAGMENT_SHADER); - glShaderSource(dev->vert_shdr, 1, &zahnrad_vertex_shader, 0); - glShaderSource(dev->frag_shdr, 1, &zahnrad_fragment_shader, 0); - glCompileShader(dev->vert_shdr); - glCompileShader(dev->frag_shdr); - glGetShaderiv(dev->vert_shdr, GL_COMPILE_STATUS, &status); - glGetShaderiv(dev->frag_shdr, GL_COMPILE_STATUS, &status); - glAttachShader(dev->prog, dev->vert_shdr); - glAttachShader(dev->prog, dev->frag_shdr); - glLinkProgram(dev->prog); - glGetProgramiv(dev->prog, GL_LINK_STATUS, &status); - - dev->uniform_proj = glGetUniformLocation(dev->prog, "ProjMtx"); - dev->attrib_pos = glGetAttribLocation(dev->prog, "Position"); - dev->attrib_uv = glGetAttribLocation(dev->prog, "TexCoord"); - dev->attrib_col = glGetAttribLocation(dev->prog, "Color"); - - { - /* buffer setup */ - GLsizei vs = sizeof(struct nk_draw_vertex); - size_t vp = offsetof(struct nk_draw_vertex, position); - size_t vt = offsetof(struct nk_draw_vertex, uv); - size_t vc = offsetof(struct nk_draw_vertex, col); - - glGenBuffers(1, &dev->vbo); - glGenBuffers(1, &dev->ebo); - glGenVertexArrays(1, &dev->vao); - - glBindVertexArray(dev->vao); - glBindBuffer(GL_ARRAY_BUFFER, dev->vbo); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, dev->ebo); - - glEnableVertexAttribArray((GLuint)dev->attrib_pos); - glEnableVertexAttribArray((GLuint)dev->attrib_uv); - glEnableVertexAttribArray((GLuint)dev->attrib_col); - - glVertexAttribPointer((GLuint)dev->attrib_pos, 2, GL_FLOAT, GL_FALSE, vs, (void*)vp); - glVertexAttribPointer((GLuint)dev->attrib_uv, 2, GL_FLOAT, GL_FALSE, vs, (void*)vt); - glVertexAttribPointer((GLuint)dev->attrib_col, 4, GL_UNSIGNED_BYTE, GL_TRUE, vs, (void*)vc); - } - - glBindTexture(GL_TEXTURE_2D, 0); - glBindBuffer(GL_ARRAY_BUFFER, 0); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); - glBindVertexArray(0); -#endif -} - -void device_upload_atlas(struct nk_device *dev, const void *image, int width, int height) -{ - glGenTextures(1, &dev->font_tex); - glBindTexture(GL_TEXTURE_2D, dev->font_tex); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); - glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); - glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, (GLsizei)width, (GLsizei)height, 0, - GL_RGBA, GL_UNSIGNED_BYTE, image); -} - -void nk_common_device_shutdown(struct nk_device *dev) -{ -#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) - glDetachShader(dev->prog, dev->vert_shdr); - glDetachShader(dev->prog, dev->frag_shdr); - glDeleteShader(dev->vert_shdr); - glDeleteShader(dev->frag_shdr); - glDeleteProgram(dev->prog); - glDeleteTextures(1, &dev->font_tex); - glDeleteBuffers(1, &dev->vbo); - glDeleteBuffers(1, &dev->ebo); -#endif -} - -void nk_common_device_draw(struct nk_device *dev, - struct nk_context *ctx, int width, int height, - enum nk_anti_aliasing AA) -{ - video_shader_ctx_info_t shader_info; - struct nk_buffer vbuf, ebuf; - struct nk_convert_config config; - uintptr_t last_prog; - const struct nk_draw_command *cmd = NULL; - void *vertices = NULL; - void *elements = NULL; - const nk_draw_index *offset = NULL; -#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) - GLint last_tex; - GLint last_ebo, last_vbo, last_vao; - GLfloat ortho[4][4] = { - {2.0f, 0.0f, 0.0f, 0.0f}, - {0.0f,-2.0f, 0.0f, 0.0f}, - {0.0f, 0.0f,-1.0f, 0.0f}, - {-1.0f,1.0f, 0.0f, 1.0f}, - }; - ortho[0][0] /= (GLfloat)width; - ortho[1][1] /= (GLfloat)height; - - /* save previous opengl state */ - glGetIntegerv(GL_CURRENT_PROGRAM, (GLint*)&last_prog); - glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_tex); - glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &last_vao); - glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &last_ebo); - glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &last_vbo); -#endif - - menu_display_ctl(MENU_DISPLAY_CTL_BLEND_BEGIN, NULL); - -#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) - glActiveTexture(GL_TEXTURE0); -#endif - - /* setup program */ - shader_info.data = NULL; - shader_info.idx = dev->prog; - shader_info.set_active = false; - video_shader_driver_ctl(SHADER_CTL_USE, &shader_info); - -#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) - glUniformMatrix4fv(dev->uniform_proj, 1, GL_FALSE, &ortho[0][0]); - - /* convert from command queue into draw list and draw to screen */ - - /* allocate vertex and element buffer */ - glBindVertexArray(dev->vao); - glBindBuffer(GL_ARRAY_BUFFER, dev->vbo); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, dev->ebo); - - glBufferData(GL_ARRAY_BUFFER, MAX_VERTEX_MEMORY, NULL, GL_STREAM_DRAW); - glBufferData(GL_ELEMENT_ARRAY_BUFFER, MAX_ELEMENT_MEMORY, NULL, GL_STREAM_DRAW); - - /* load draw vertices & elements directly into vertex + element buffer */ - vertices = glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY); - elements = glMapBuffer(GL_ELEMENT_ARRAY_BUFFER, GL_WRITE_ONLY); -#endif - - /* fill converting configuration */ - memset(&config, 0, sizeof(config)); - - config.global_alpha = 1.0f; - config.shape_AA = AA; - config.line_AA = AA; - config.circle_segment_count = 22; - //config.line_thickness = 1.0f; - config.null = dev->null; - - /* setup buffers to load vertices and elements */ - nk_buffer_init_fixed(&vbuf, vertices, MAX_VERTEX_MEMORY); - nk_buffer_init_fixed(&ebuf, elements, MAX_ELEMENT_MEMORY); - nk_convert(ctx, &dev->cmds, &vbuf, &ebuf, &config); - -#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) - glUnmapBuffer(GL_ARRAY_BUFFER); - glUnmapBuffer(GL_ELEMENT_ARRAY_BUFFER); -#endif - - /* iterate over and execute each draw command */ - nk_draw_foreach(cmd, ctx, &dev->cmds) - { - if (!cmd->elem_count) - continue; - -#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) - glBindTexture(GL_TEXTURE_2D, (GLuint)cmd->texture.id); - glScissor((GLint)cmd->clip_rect.x, - height - (GLint)(cmd->clip_rect.y + cmd->clip_rect.h), - (GLint)cmd->clip_rect.w, (GLint)cmd->clip_rect.h); - glDrawElements(GL_TRIANGLES, (GLsizei)cmd->elem_count, - GL_UNSIGNED_SHORT, offset); -#endif - - offset += cmd->elem_count; - } - nk_clear(ctx); - - /* restore old state */ - shader_info.data = NULL; - shader_info.idx = (GLint)last_prog; - shader_info.set_active = false; - video_shader_driver_ctl(SHADER_CTL_USE, &shader_info); - -#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) - glBindTexture(GL_TEXTURE_2D, (GLuint)last_tex); - glBindBuffer(GL_ARRAY_BUFFER, (GLuint)last_vbo); - glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, (GLuint)last_ebo); - glBindVertexArray((GLuint)last_vao); -#endif - - menu_display_ctl(MENU_DISPLAY_CTL_BLEND_END, NULL); -} - -//void nk_mem_alloc(nk_handle a, void *old, nk_size b); -void* nk_common_mem_alloc(nk_handle a, void *old, nk_size b) -{ - (void)a; - return calloc(1, b); -} - -void nk_common_mem_free(nk_handle unused, void *ptr) -{ - (void)unused; - free(ptr); -} + +#include "nk_common.h" + +#include "../menu_display.h" +#include "../../gfx/video_shader_driver.h" + +#include "../../gfx/drivers/gl_shaders/pipeline_zahnrad.glsl.vert.h" +#include "../../gfx/drivers/gl_shaders/pipeline_zahnrad.glsl.frag.h" + +struct nk_font *font; +struct nk_font_atlas atlas; +struct nk_user_font usrfnt; +struct nk_allocator nk_alloc; +struct nk_device device; + +struct nk_image nk_common_image_load(const char *filename) +{ + int x,y,n; + GLuint tex; + unsigned char *data = stbi_load(filename, &x, &y, &n, 0); + if (!data) printf("Failed to load image: %s\n", filename); + +#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) + glGenTextures(1, &tex); + glBindTexture(GL_TEXTURE_2D, tex); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_NEAREST); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_NEAREST); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); + glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, x, y, 0, GL_RGBA, GL_UNSIGNED_BYTE, data); + glGenerateMipmap(GL_TEXTURE_2D); +#endif + + stbi_image_free(data); + return nk_image_id((int)tex); +} + +char* nk_common_file_load(const char* path, size_t* size) +{ + void *buf; + ssize_t *length = (ssize_t*)size; + filestream_read_file(path, &buf, length); + return (char*)buf; +} + +NK_API void nk_common_device_init(struct nk_device *dev) +{ +#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) + GLint status; + + dev->prog = glCreateProgram(); + dev->vert_shdr = glCreateShader(GL_VERTEX_SHADER); + dev->frag_shdr = glCreateShader(GL_FRAGMENT_SHADER); + glShaderSource(dev->vert_shdr, 1, &zahnrad_vertex_shader, 0); + glShaderSource(dev->frag_shdr, 1, &zahnrad_fragment_shader, 0); + glCompileShader(dev->vert_shdr); + glCompileShader(dev->frag_shdr); + glGetShaderiv(dev->vert_shdr, GL_COMPILE_STATUS, &status); + glGetShaderiv(dev->frag_shdr, GL_COMPILE_STATUS, &status); + glAttachShader(dev->prog, dev->vert_shdr); + glAttachShader(dev->prog, dev->frag_shdr); + glLinkProgram(dev->prog); + glGetProgramiv(dev->prog, GL_LINK_STATUS, &status); + + dev->uniform_proj = glGetUniformLocation(dev->prog, "ProjMtx"); + dev->attrib_pos = glGetAttribLocation(dev->prog, "Position"); + dev->attrib_uv = glGetAttribLocation(dev->prog, "TexCoord"); + dev->attrib_col = glGetAttribLocation(dev->prog, "Color"); + + { + /* buffer setup */ + GLsizei vs = sizeof(struct nk_draw_vertex); + size_t vp = offsetof(struct nk_draw_vertex, position); + size_t vt = offsetof(struct nk_draw_vertex, uv); + size_t vc = offsetof(struct nk_draw_vertex, col); + + glGenBuffers(1, &dev->vbo); + glGenBuffers(1, &dev->ebo); + glGenVertexArrays(1, &dev->vao); + + glBindVertexArray(dev->vao); + glBindBuffer(GL_ARRAY_BUFFER, dev->vbo); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, dev->ebo); + + glEnableVertexAttribArray((GLuint)dev->attrib_pos); + glEnableVertexAttribArray((GLuint)dev->attrib_uv); + glEnableVertexAttribArray((GLuint)dev->attrib_col); + + glVertexAttribPointer((GLuint)dev->attrib_pos, 2, GL_FLOAT, GL_FALSE, vs, (void*)vp); + glVertexAttribPointer((GLuint)dev->attrib_uv, 2, GL_FLOAT, GL_FALSE, vs, (void*)vt); + glVertexAttribPointer((GLuint)dev->attrib_col, 4, GL_UNSIGNED_BYTE, GL_TRUE, vs, (void*)vc); + } + + glBindTexture(GL_TEXTURE_2D, 0); + glBindBuffer(GL_ARRAY_BUFFER, 0); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); + glBindVertexArray(0); +#endif +} + +void device_upload_atlas(struct nk_device *dev, const void *image, int width, int height) +{ + glGenTextures(1, &dev->font_tex); + glBindTexture(GL_TEXTURE_2D, dev->font_tex); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR); + glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, (GLsizei)width, (GLsizei)height, 0, + GL_RGBA, GL_UNSIGNED_BYTE, image); +} + +void nk_common_device_shutdown(struct nk_device *dev) +{ +#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) + glDetachShader(dev->prog, dev->vert_shdr); + glDetachShader(dev->prog, dev->frag_shdr); + glDeleteShader(dev->vert_shdr); + glDeleteShader(dev->frag_shdr); + glDeleteProgram(dev->prog); + glDeleteTextures(1, &dev->font_tex); + glDeleteBuffers(1, &dev->vbo); + glDeleteBuffers(1, &dev->ebo); +#endif +} + +void nk_common_device_draw(struct nk_device *dev, + struct nk_context *ctx, int width, int height, + enum nk_anti_aliasing AA) +{ + video_shader_ctx_info_t shader_info; + struct nk_buffer vbuf, ebuf; + struct nk_convert_config config; + uintptr_t last_prog; + const struct nk_draw_command *cmd = NULL; + void *vertices = NULL; + void *elements = NULL; + const nk_draw_index *offset = NULL; +#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) + GLint last_tex; + GLint last_ebo, last_vbo, last_vao; + GLfloat ortho[4][4] = { + {2.0f, 0.0f, 0.0f, 0.0f}, + {0.0f,-2.0f, 0.0f, 0.0f}, + {0.0f, 0.0f,-1.0f, 0.0f}, + {-1.0f,1.0f, 0.0f, 1.0f}, + }; + ortho[0][0] /= (GLfloat)width; + ortho[1][1] /= (GLfloat)height; + + /* save previous opengl state */ + glGetIntegerv(GL_CURRENT_PROGRAM, (GLint*)&last_prog); + glGetIntegerv(GL_TEXTURE_BINDING_2D, &last_tex); + glGetIntegerv(GL_ARRAY_BUFFER_BINDING, &last_vao); + glGetIntegerv(GL_ELEMENT_ARRAY_BUFFER_BINDING, &last_ebo); + glGetIntegerv(GL_VERTEX_ARRAY_BINDING, &last_vbo); +#endif + + menu_display_blend_begin(); + +#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) + glActiveTexture(GL_TEXTURE0); +#endif + + /* setup program */ + shader_info.data = NULL; + shader_info.idx = dev->prog; + shader_info.set_active = false; + video_shader_driver_ctl(SHADER_CTL_USE, &shader_info); + +#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) + glUniformMatrix4fv(dev->uniform_proj, 1, GL_FALSE, &ortho[0][0]); + + /* convert from command queue into draw list and draw to screen */ + + /* allocate vertex and element buffer */ + glBindVertexArray(dev->vao); + glBindBuffer(GL_ARRAY_BUFFER, dev->vbo); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, dev->ebo); + + glBufferData(GL_ARRAY_BUFFER, MAX_VERTEX_MEMORY, NULL, GL_STREAM_DRAW); + glBufferData(GL_ELEMENT_ARRAY_BUFFER, MAX_ELEMENT_MEMORY, NULL, GL_STREAM_DRAW); + + /* load draw vertices & elements directly into vertex + element buffer */ + vertices = glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY); + elements = glMapBuffer(GL_ELEMENT_ARRAY_BUFFER, GL_WRITE_ONLY); +#endif + + /* fill converting configuration */ + memset(&config, 0, sizeof(config)); + + config.global_alpha = 1.0f; + config.shape_AA = AA; + config.line_AA = AA; + config.circle_segment_count = 22; + //config.line_thickness = 1.0f; + config.null = dev->null; + + /* setup buffers to load vertices and elements */ + nk_buffer_init_fixed(&vbuf, vertices, MAX_VERTEX_MEMORY); + nk_buffer_init_fixed(&ebuf, elements, MAX_ELEMENT_MEMORY); + nk_convert(ctx, &dev->cmds, &vbuf, &ebuf, &config); + +#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) + glUnmapBuffer(GL_ARRAY_BUFFER); + glUnmapBuffer(GL_ELEMENT_ARRAY_BUFFER); +#endif + + /* iterate over and execute each draw command */ + nk_draw_foreach(cmd, ctx, &dev->cmds) + { + if (!cmd->elem_count) + continue; + +#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) + glBindTexture(GL_TEXTURE_2D, (GLuint)cmd->texture.id); + glScissor((GLint)cmd->clip_rect.x, + height - (GLint)(cmd->clip_rect.y + cmd->clip_rect.h), + (GLint)cmd->clip_rect.w, (GLint)cmd->clip_rect.h); + glDrawElements(GL_TRIANGLES, (GLsizei)cmd->elem_count, + GL_UNSIGNED_SHORT, offset); +#endif + + offset += cmd->elem_count; + } + nk_clear(ctx); + + /* restore old state */ + shader_info.data = NULL; + shader_info.idx = (GLint)last_prog; + shader_info.set_active = false; + video_shader_driver_ctl(SHADER_CTL_USE, &shader_info); + +#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) + glBindTexture(GL_TEXTURE_2D, (GLuint)last_tex); + glBindBuffer(GL_ARRAY_BUFFER, (GLuint)last_vbo); + glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, (GLuint)last_ebo); + glBindVertexArray((GLuint)last_vao); +#endif + + menu_display_blend_end(); +} + +//void nk_mem_alloc(nk_handle a, void *old, nk_size b); +void* nk_common_mem_alloc(nk_handle a, void *old, nk_size b) +{ + (void)a; + return calloc(1, b); +} + +void nk_common_mem_free(nk_handle unused, void *ptr) +{ + (void)unused; + free(ptr); +} diff --git a/menu/drivers/nuklear.c b/menu/drivers/nuklear.c index cb6ba15b3d..598c5f9cca 100644 --- a/menu/drivers/nuklear.c +++ b/menu/drivers/nuklear.c @@ -174,15 +174,14 @@ static void nk_menu_frame(void *data) nk_menu_handle_t *nk = (nk_menu_handle_t*)data; settings_t *settings = config_get_ptr(); - bool libretro_running = menu_display_ctl( - MENU_DISPLAY_CTL_LIBRETRO_RUNNING, NULL); + bool libretro_running = menu_display_libretro_running(); if (!nk) return; video_driver_get_size(&width, &height); - menu_display_ctl(MENU_DISPLAY_CTL_SET_VIEWPORT, NULL); + menu_display_set_viewport(); nk_input_begin(&nk->ctx); nk_menu_input_gamepad(nk); @@ -212,22 +211,19 @@ static void nk_menu_frame(void *data) width, height); - menu_display_ctl(MENU_DISPLAY_CTL_RESTORE_CLEAR_COLOR, NULL); - menu_display_ctl(MENU_DISPLAY_CTL_UNSET_VIEWPORT, NULL); + menu_display_restore_clear_color(); + menu_display_unset_viewport(); } static void nk_menu_layout(nk_menu_handle_t *nk) { - void *fb_buf; float scale_factor; unsigned width, height, new_header_height; video_driver_get_size(&width, &height); - menu_display_ctl(MENU_DISPLAY_CTL_GET_DPI, &scale_factor); - menu_display_ctl(MENU_DISPLAY_CTL_SET_HEADER_HEIGHT, - &new_header_height); - + scale_factor = menu_display_get_dpi(); + menu_display_set_header_height(new_header_height); } static void nk_menu_init_device(nk_menu_handle_t *nk) @@ -285,7 +281,7 @@ static void *nk_menu_init(void **userdata) if (!menu) goto error; - if (!menu_display_ctl(MENU_DISPLAY_CTL_INIT_FIRST_DRIVER, NULL)) + if (!menu_display_init_first_driver()) goto error; nk = (nk_menu_handle_t*)calloc(1, sizeof(nk_menu_handle_t)); @@ -339,8 +335,7 @@ static void nk_menu_context_destroy(void *data) for (i = 0; i < NK_TEXTURE_LAST; i++) video_driver_texture_unload((uintptr_t*)&nk->textures.list[i]); - menu_display_ctl(MENU_DISPLAY_CTL_FONT_MAIN_DEINIT, NULL); - + menu_display_font_main_deinit(); wimp_context_bg_destroy(nk); } diff --git a/menu/drivers/xui.cpp b/menu/drivers/xui.cpp index 705ecf2714..434580531a 100644 --- a/menu/drivers/xui.cpp +++ b/menu/drivers/xui.cpp @@ -417,7 +417,7 @@ static void xui_frame(void *data) if (!d3dr) return; - menu_display_ctl(MENU_DISPLAY_CTL_SET_VIEWPORT, NULL); + menu_display_set_viewport(); app.RunFrame(); XuiTimersRun(); @@ -445,7 +445,7 @@ static void xui_frame(void *data) XuiRenderEnd( app.GetDC() ); - menu_display_ctl(MENU_DISPLAY_CTL_UNSET_VIEWPORT, NULL); + menu_display_unset_viewport(); } static void blit_line(int x, int y, const char *message, bool green) @@ -454,7 +454,7 @@ static void blit_line(int x, int y, const char *message, bool green) static void xui_render_background(void) { - if (menu_display_ctl(MENU_DISPLAY_CTL_LIBRETRO_RUNNING, NULL)) + if (menu_display_libretro_running()) XuiElementSetShow(m_background, FALSE); else XuiElementSetShow(m_background, TRUE); @@ -536,8 +536,8 @@ static void xui_render(void *data) frame_count = video_driver_get_frame_count_ptr(); - menu_display_ctl(MENU_DISPLAY_CTL_WIDTH, &fb_width); - menu_display_ctl(MENU_DISPLAY_CTL_MSG_FORCE, &msg_force); + fb_width = menu_display_get_width(); + msg_force = menu_display_get_msg_force(); if ( menu_entries_ctl(MENU_ENTRIES_CTL_NEEDS_REFRESH, NULL) @@ -546,7 +546,7 @@ static void xui_render(void *data) ) return; - menu_display_ctl(MENU_DISPLAY_CTL_UNSET_FRAMEBUFFER_DIRTY_FLAG, NULL); + menu_display_unset_framebuffer_dirty_flag(); menu_animation_ctl(MENU_ANIMATION_CTL_CLEAR_ACTIVE, NULL); xui_render_background(); diff --git a/menu/drivers_display/menu_display_d3d.cpp b/menu/drivers_display/menu_display_d3d.cpp index c6b7e08848..fe00476e51 100644 --- a/menu/drivers_display/menu_display_d3d.cpp +++ b/menu/drivers_display/menu_display_d3d.cpp @@ -186,7 +186,7 @@ static void menu_display_d3d_draw_pipeline(void *data) static float t = 0; gfx_coord_array_t *ca = NULL; - menu_display_ctl(MENU_DISPLAY_CTL_COORDS_ARRAY_GET, &ca); + ca = menu_display_get_coords_array(); draw->x = 0; draw->y = 0; From f91b36eec8de06470b7a5532d90199f53d871307 Mon Sep 17 00:00:00 2001 From: Hans-Kristian Arntzen Date: Sun, 8 May 2016 15:21:53 +0200 Subject: [PATCH 263/498] Fix inconsistencies between Vulkan and GL in ribbon. Also fixes a shitty bug in menu_driver_draw_bg with pointer to stack. --- gfx/drivers/vulkan_shaders/ribbon.vert | 11 +- gfx/drivers/vulkan_shaders/ribbon.vert.inc | 87 ++-- gfx/drivers/vulkan_shaders/ribbon_simple.vert | 4 +- .../vulkan_shaders/ribbon_simple.vert.inc | 388 +++++++++--------- menu/drivers_display/menu_display_vulkan.c | 12 +- menu/menu_display.c | 8 +- 6 files changed, 249 insertions(+), 261 deletions(-) diff --git a/gfx/drivers/vulkan_shaders/ribbon.vert b/gfx/drivers/vulkan_shaders/ribbon.vert index eac9d2d121..6eef95d728 100644 --- a/gfx/drivers/vulkan_shaders/ribbon.vert +++ b/gfx/drivers/vulkan_shaders/ribbon.vert @@ -38,16 +38,15 @@ void main() v.y = xmb_noise2(v2) / 6.0; - v3.x += constants.time / 5.0; + v3.x -= constants.time / 5.0; v3.x /= 2.0; - v3.z += constants.time / 10.0; - v3.y += constants.time / 100.0; + v3.z -= constants.time / 10.0; + v3.y -= constants.time / 100.0; - v.z += noise(v3 * 7.0) / 15.0; - v.y += noise(v3 * 7.0) / 15.0 + cos(v.x * 2.0 - constants.time / 5.0) / 5.0 - 0.3; + v.z -= noise(v3 * 7.0) / 15.0; + v.y -= noise(v3 * 7.0) / 15.0 + cos(v.x * 2.0 - constants.time / 5.0) / 5.0 - 0.3; - v.y = -v.y; vEC = v; gl_Position = vec4(v, 1.0); } diff --git a/gfx/drivers/vulkan_shaders/ribbon.vert.inc b/gfx/drivers/vulkan_shaders/ribbon.vert.inc index 7531c5cf20..cdd2c85275 100644 --- a/gfx/drivers/vulkan_shaders/ribbon.vert.inc +++ b/gfx/drivers/vulkan_shaders/ribbon.vert.inc @@ -1,12 +1,12 @@ unsigned char ribbon_vert_spv[] = { 0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x08, 0x00, - 0xe6, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, + 0xe2, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x4c, 0x53, 0x4c, 0x2e, 0x73, 0x74, 0x64, 0x2e, 0x34, 0x35, 0x30, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, - 0x80, 0x00, 0x00, 0x00, 0xd9, 0x00, 0x00, 0x00, 0xde, 0x00, 0x00, 0x00, + 0x80, 0x00, 0x00, 0x00, 0xd5, 0x00, 0x00, 0x00, 0xda, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, 0x36, 0x01, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x00, @@ -44,27 +44,27 @@ unsigned char ribbon_vert_spv[] = { 0x74, 0x61, 0x6e, 0x74, 0x73, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0xb7, 0x00, 0x00, 0x00, 0x70, 0x61, 0x72, 0x61, 0x6d, 0x00, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0xc1, 0x00, 0x00, 0x00, 0x70, 0x61, 0x72, 0x61, - 0x6d, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0xd9, 0x00, 0x00, 0x00, - 0x76, 0x45, 0x43, 0x00, 0x05, 0x00, 0x06, 0x00, 0xdc, 0x00, 0x00, 0x00, + 0x6d, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, 0xd5, 0x00, 0x00, 0x00, + 0x76, 0x45, 0x43, 0x00, 0x05, 0x00, 0x06, 0x00, 0xd8, 0x00, 0x00, 0x00, 0x67, 0x6c, 0x5f, 0x50, 0x65, 0x72, 0x56, 0x65, 0x72, 0x74, 0x65, 0x78, - 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x06, 0x00, 0xdc, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x06, 0x00, 0xd8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, - 0x69, 0x6f, 0x6e, 0x00, 0x06, 0x00, 0x07, 0x00, 0xdc, 0x00, 0x00, 0x00, + 0x69, 0x6f, 0x6e, 0x00, 0x06, 0x00, 0x07, 0x00, 0xd8, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x53, 0x69, 0x7a, 0x65, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, - 0xde, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, + 0xda, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x80, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x92, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, 0x92, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x94, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x94, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0xd9, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0xd5, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, - 0xdc, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0xdc, 0x00, 0x00, 0x00, + 0xd8, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0xd8, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x47, 0x00, 0x03, 0x00, 0xdc, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, + 0x47, 0x00, 0x03, 0x00, 0xd8, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x16, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, @@ -115,16 +115,16 @@ unsigned char ribbon_vert_spv[] = { 0xb5, 0x00, 0x00, 0x00, 0x00, 0x00, 0xe0, 0x40, 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0xb9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x70, 0x41, 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0xce, 0x00, 0x00, 0x00, - 0x9a, 0x99, 0x99, 0x3e, 0x20, 0x00, 0x04, 0x00, 0xd8, 0x00, 0x00, 0x00, + 0x9a, 0x99, 0x99, 0x3e, 0x20, 0x00, 0x04, 0x00, 0xd4, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0xd8, 0x00, 0x00, 0x00, 0xd9, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, - 0x17, 0x00, 0x04, 0x00, 0xdb, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x04, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x04, 0x00, 0xdc, 0x00, 0x00, 0x00, - 0xdb, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, - 0xdd, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xdc, 0x00, 0x00, 0x00, - 0x3b, 0x00, 0x04, 0x00, 0xdd, 0x00, 0x00, 0x00, 0xde, 0x00, 0x00, 0x00, - 0x03, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0xe4, 0x00, 0x00, 0x00, - 0x03, 0x00, 0x00, 0x00, 0xdb, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, 0x00, + 0xd4, 0x00, 0x00, 0x00, 0xd5, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0x17, 0x00, 0x04, 0x00, 0xd7, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x04, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x04, 0x00, 0xd8, 0x00, 0x00, 0x00, + 0xd7, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, + 0xd9, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xd8, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0xd9, 0x00, 0x00, 0x00, 0xda, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0xe0, 0x00, 0x00, 0x00, + 0x03, 0x00, 0x00, 0x00, 0xd7, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, @@ -164,7 +164,7 @@ unsigned char ribbon_vert_spv[] = { 0x99, 0x00, 0x00, 0x00, 0x9a, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x9c, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x9d, 0x00, 0x00, 0x00, 0x9c, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, + 0x9d, 0x00, 0x00, 0x00, 0x9c, 0x00, 0x00, 0x00, 0x83, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x9e, 0x00, 0x00, 0x00, 0x9d, 0x00, 0x00, 0x00, 0x9b, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x9f, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, @@ -184,7 +184,7 @@ unsigned char ribbon_vert_spv[] = { 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0xa8, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0xa9, 0x00, 0x00, 0x00, 0xa8, 0x00, 0x00, 0x00, - 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0xaa, 0x00, 0x00, 0x00, + 0x83, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0xaa, 0x00, 0x00, 0x00, 0xa9, 0x00, 0x00, 0x00, 0xa7, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0xab, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0xab, 0x00, 0x00, 0x00, @@ -196,7 +196,7 @@ unsigned char ribbon_vert_spv[] = { 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0xb0, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0xb1, 0x00, 0x00, 0x00, 0xb0, 0x00, 0x00, 0x00, - 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0xb2, 0x00, 0x00, 0x00, + 0x83, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0xb2, 0x00, 0x00, 0x00, 0xb1, 0x00, 0x00, 0x00, 0xaf, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0xb3, 0x00, 0x00, 0x00, 0x8a, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0xb3, 0x00, 0x00, 0x00, @@ -210,7 +210,7 @@ unsigned char ribbon_vert_spv[] = { 0xb8, 0x00, 0x00, 0x00, 0xb9, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0xbb, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0xbc, 0x00, 0x00, 0x00, 0xbb, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, + 0xbc, 0x00, 0x00, 0x00, 0xbb, 0x00, 0x00, 0x00, 0x83, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0xbd, 0x00, 0x00, 0x00, 0xbc, 0x00, 0x00, 0x00, 0xba, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0xbe, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, @@ -243,32 +243,25 @@ unsigned char ribbon_vert_spv[] = { 0xce, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0xd0, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0xd1, 0x00, 0x00, 0x00, - 0xd0, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0xd0, 0x00, 0x00, 0x00, 0x83, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0xd2, 0x00, 0x00, 0x00, 0xd1, 0x00, 0x00, 0x00, 0xcf, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0xd3, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, - 0xd3, 0x00, 0x00, 0x00, 0xd2, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, - 0x07, 0x00, 0x00, 0x00, 0xd4, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, - 0x31, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0xd5, 0x00, 0x00, 0x00, 0xd4, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0xd6, 0x00, 0x00, 0x00, 0xd5, 0x00, 0x00, 0x00, - 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0xd7, 0x00, 0x00, 0x00, - 0x7e, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, - 0xd7, 0x00, 0x00, 0x00, 0xd6, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x0c, 0x00, 0x00, 0x00, 0xda, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x03, 0x00, 0xd9, 0x00, 0x00, 0x00, 0xda, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0xdf, 0x00, 0x00, 0x00, + 0xd3, 0x00, 0x00, 0x00, 0xd2, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0xd6, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, + 0x3e, 0x00, 0x03, 0x00, 0xd5, 0x00, 0x00, 0x00, 0xd6, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0xdb, 0x00, 0x00, 0x00, 0x7e, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, - 0xe0, 0x00, 0x00, 0x00, 0xdf, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x51, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0xe1, 0x00, 0x00, 0x00, - 0xdf, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, - 0x06, 0x00, 0x00, 0x00, 0xe2, 0x00, 0x00, 0x00, 0xdf, 0x00, 0x00, 0x00, - 0x02, 0x00, 0x00, 0x00, 0x50, 0x00, 0x07, 0x00, 0xdb, 0x00, 0x00, 0x00, - 0xe3, 0x00, 0x00, 0x00, 0xe0, 0x00, 0x00, 0x00, 0xe1, 0x00, 0x00, 0x00, - 0xe2, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, - 0xe4, 0x00, 0x00, 0x00, 0xe5, 0x00, 0x00, 0x00, 0xde, 0x00, 0x00, 0x00, - 0x96, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0xe5, 0x00, 0x00, 0x00, - 0xe3, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, 0x00, + 0xdc, 0x00, 0x00, 0x00, 0xdb, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x51, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0xdd, 0x00, 0x00, 0x00, + 0xdb, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0xde, 0x00, 0x00, 0x00, 0xdb, 0x00, 0x00, 0x00, + 0x02, 0x00, 0x00, 0x00, 0x50, 0x00, 0x07, 0x00, 0xd7, 0x00, 0x00, 0x00, + 0xdf, 0x00, 0x00, 0x00, 0xdc, 0x00, 0x00, 0x00, 0xdd, 0x00, 0x00, 0x00, + 0xde, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, + 0xe0, 0x00, 0x00, 0x00, 0xe1, 0x00, 0x00, 0x00, 0xda, 0x00, 0x00, 0x00, + 0x96, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0xe1, 0x00, 0x00, 0x00, + 0xdf, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, 0x00, 0x36, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x37, 0x00, 0x03, 0x00, 0x07, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, @@ -434,4 +427,4 @@ unsigned char ribbon_vert_spv[] = { 0x0e, 0x00, 0x00, 0x00, 0x7a, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x02, 0x00, 0x7b, 0x00, 0x00, 0x00, 0x38, 0x00, 0x01, 0x00 }; -unsigned int ribbon_vert_spv_len = 5204; +unsigned int ribbon_vert_spv_len = 5120; diff --git a/gfx/drivers/vulkan_shaders/ribbon_simple.vert b/gfx/drivers/vulkan_shaders/ribbon_simple.vert index 89083e222c..a7bee379e8 100644 --- a/gfx/drivers/vulkan_shaders/ribbon_simple.vert +++ b/gfx/drivers/vulkan_shaders/ribbon_simple.vert @@ -30,6 +30,6 @@ void main() vec3 v2 = v; v2.x = v2.x + constants.time / 2.0; v2.z = v.z * 3.0; - v.y = -cos((v.x + v.z / 3.0 + constants.time) * 2.0) / 10.0 - noise(v2.xyz) / 4.0; - gl_Position = vec4(v.x, -v.y, v.z, 1.0); + v.y = cos((v.x + v.z / 3.0 + constants.time) * 2.0) / 10.0 + noise(v2.xyz) / 4.0; + gl_Position = vec4(v, 1.0); } diff --git a/gfx/drivers/vulkan_shaders/ribbon_simple.vert.inc b/gfx/drivers/vulkan_shaders/ribbon_simple.vert.inc index 3c7516f652..32c153f40b 100644 --- a/gfx/drivers/vulkan_shaders/ribbon_simple.vert.inc +++ b/gfx/drivers/vulkan_shaders/ribbon_simple.vert.inc @@ -1,12 +1,12 @@ unsigned char ribbon_simple_vert_spv[] = { 0x03, 0x02, 0x23, 0x07, 0x00, 0x00, 0x01, 0x00, 0x01, 0x00, 0x08, 0x00, - 0xb5, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, + 0xb1, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x11, 0x00, 0x02, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x06, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x4c, 0x53, 0x4c, 0x2e, 0x73, 0x74, 0x64, 0x2e, 0x34, 0x35, 0x30, 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x07, 0x00, 0x00, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, - 0x77, 0x00, 0x00, 0x00, 0xaa, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, + 0x77, 0x00, 0x00, 0x00, 0xa9, 0x00, 0x00, 0x00, 0x03, 0x00, 0x03, 0x00, 0x01, 0x00, 0x00, 0x00, 0x36, 0x01, 0x00, 0x00, 0x05, 0x00, 0x04, 0x00, 0x04, 0x00, 0x00, 0x00, 0x6d, 0x61, 0x69, 0x6e, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x69, 0x71, 0x68, 0x61, @@ -36,26 +36,26 @@ unsigned char ribbon_simple_vert_spv[] = { 0x83, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x74, 0x69, 0x6d, 0x65, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x05, 0x00, 0x85, 0x00, 0x00, 0x00, 0x63, 0x6f, 0x6e, 0x73, 0x74, 0x61, 0x6e, 0x74, 0x73, 0x00, 0x00, 0x00, - 0x05, 0x00, 0x04, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x70, 0x61, 0x72, 0x61, - 0x6d, 0x00, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0xa8, 0x00, 0x00, 0x00, + 0x05, 0x00, 0x04, 0x00, 0x9f, 0x00, 0x00, 0x00, 0x70, 0x61, 0x72, 0x61, + 0x6d, 0x00, 0x00, 0x00, 0x05, 0x00, 0x06, 0x00, 0xa7, 0x00, 0x00, 0x00, 0x67, 0x6c, 0x5f, 0x50, 0x65, 0x72, 0x56, 0x65, 0x72, 0x74, 0x65, 0x78, - 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x06, 0x00, 0xa8, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x06, 0x00, 0x06, 0x00, 0xa7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x73, 0x69, 0x74, - 0x69, 0x6f, 0x6e, 0x00, 0x06, 0x00, 0x07, 0x00, 0xa8, 0x00, 0x00, 0x00, + 0x69, 0x6f, 0x6e, 0x00, 0x06, 0x00, 0x07, 0x00, 0xa7, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x67, 0x6c, 0x5f, 0x50, 0x6f, 0x69, 0x6e, 0x74, 0x53, 0x69, 0x7a, 0x65, 0x00, 0x00, 0x00, 0x00, 0x05, 0x00, 0x03, 0x00, - 0xaa, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, + 0xa9, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x77, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0x83, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, 0x83, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x85, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x47, 0x00, 0x04, 0x00, 0x85, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0xa8, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x48, 0x00, 0x05, 0x00, 0xa7, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x48, 0x00, 0x05, 0x00, 0xa8, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x48, 0x00, 0x05, 0x00, 0xa7, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x47, 0x00, 0x03, 0x00, - 0xa8, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00, + 0xa7, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x13, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00, 0x21, 0x00, 0x03, 0x00, 0x03, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x16, 0x00, 0x03, 0x00, 0x06, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, @@ -97,21 +97,21 @@ unsigned char ribbon_simple_vert_spv[] = { 0x2b, 0x00, 0x04, 0x00, 0x86, 0x00, 0x00, 0x00, 0x87, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, 0x88, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x9e, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x41, - 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0xa3, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x80, 0x40, 0x17, 0x00, 0x04, 0x00, 0xa7, 0x00, 0x00, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x9d, 0x00, 0x00, 0x00, 0x00, 0x00, 0x20, 0x41, + 0x2b, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0xa2, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x80, 0x40, 0x17, 0x00, 0x04, 0x00, 0xa6, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x04, 0x00, - 0xa8, 0x00, 0x00, 0x00, 0xa7, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x20, 0x00, 0x04, 0x00, 0xa9, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, - 0xa8, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0xa9, 0x00, 0x00, 0x00, - 0xaa, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, - 0xb3, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xa7, 0x00, 0x00, 0x00, + 0xa7, 0x00, 0x00, 0x00, 0xa6, 0x00, 0x00, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x20, 0x00, 0x04, 0x00, 0xa8, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, + 0xa7, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0xa8, 0x00, 0x00, 0x00, + 0xa9, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x20, 0x00, 0x04, 0x00, + 0xaf, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xa6, 0x00, 0x00, 0x00, 0x36, 0x00, 0x05, 0x00, 0x02, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x05, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x75, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x3b, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x9f, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x78, 0x00, 0x00, 0x00, 0x79, 0x00, 0x00, 0x00, 0x77, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x7a, 0x00, 0x00, 0x00, @@ -160,188 +160,182 @@ unsigned char ribbon_simple_vert_spv[] = { 0x85, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x9b, 0x00, 0x00, 0x00, 0x9a, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x06, 0x00, 0x06, 0x00, 0x00, 0x00, 0x9c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x0e, 0x00, 0x00, 0x00, 0x9b, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x9d, 0x00, 0x00, 0x00, 0x9c, 0x00, 0x00, 0x00, - 0x88, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x9f, 0x00, 0x00, 0x00, - 0x9d, 0x00, 0x00, 0x00, 0x9e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x0c, 0x00, 0x00, 0x00, 0xa1, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x03, 0x00, 0xa0, 0x00, 0x00, 0x00, 0xa1, 0x00, 0x00, 0x00, - 0x39, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0xa2, 0x00, 0x00, 0x00, - 0x10, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x88, 0x00, 0x05, 0x00, - 0x06, 0x00, 0x00, 0x00, 0xa4, 0x00, 0x00, 0x00, 0xa2, 0x00, 0x00, 0x00, - 0xa3, 0x00, 0x00, 0x00, 0x83, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, - 0xa5, 0x00, 0x00, 0x00, 0x9f, 0x00, 0x00, 0x00, 0xa4, 0x00, 0x00, 0x00, - 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0xa6, 0x00, 0x00, 0x00, - 0x75, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, - 0xa6, 0x00, 0x00, 0x00, 0xa5, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, - 0x07, 0x00, 0x00, 0x00, 0xab, 0x00, 0x00, 0x00, 0x75, 0x00, 0x00, 0x00, - 0x2b, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0xac, 0x00, 0x00, 0x00, 0xab, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, - 0x07, 0x00, 0x00, 0x00, 0xad, 0x00, 0x00, 0x00, 0x75, 0x00, 0x00, 0x00, - 0x2e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0xae, 0x00, 0x00, 0x00, 0xad, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0xaf, 0x00, 0x00, 0x00, 0xae, 0x00, 0x00, 0x00, - 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0xb0, 0x00, 0x00, 0x00, - 0x75, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0xb1, 0x00, 0x00, 0x00, 0xb0, 0x00, 0x00, 0x00, - 0x50, 0x00, 0x07, 0x00, 0xa7, 0x00, 0x00, 0x00, 0xb2, 0x00, 0x00, 0x00, - 0xac, 0x00, 0x00, 0x00, 0xaf, 0x00, 0x00, 0x00, 0xb1, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0xb3, 0x00, 0x00, 0x00, - 0xb4, 0x00, 0x00, 0x00, 0xaa, 0x00, 0x00, 0x00, 0x87, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x03, 0x00, 0xb4, 0x00, 0x00, 0x00, 0xb2, 0x00, 0x00, 0x00, - 0xfd, 0x00, 0x01, 0x00, 0x38, 0x00, 0x01, 0x00, 0x36, 0x00, 0x05, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, - 0x08, 0x00, 0x00, 0x00, 0x37, 0x00, 0x03, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x09, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x0b, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, - 0x09, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x06, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x13, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, - 0x12, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x15, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, - 0x0c, 0x00, 0x06, 0x00, 0x06, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, - 0xfe, 0x00, 0x02, 0x00, 0x16, 0x00, 0x00, 0x00, 0x38, 0x00, 0x01, 0x00, - 0x36, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, - 0x00, 0x00, 0x00, 0x00, 0x0e, 0x00, 0x00, 0x00, 0x37, 0x00, 0x03, 0x00, - 0x0d, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, - 0x11, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, - 0x19, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x0d, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x9b, 0x00, 0x00, 0x00, 0x88, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x9e, 0x00, 0x00, 0x00, 0x9c, 0x00, 0x00, 0x00, + 0x9d, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0xa0, 0x00, 0x00, 0x00, 0x7f, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, + 0x9f, 0x00, 0x00, 0x00, 0xa0, 0x00, 0x00, 0x00, 0x39, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0xa1, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, + 0x9f, 0x00, 0x00, 0x00, 0x88, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0xa3, 0x00, 0x00, 0x00, 0xa1, 0x00, 0x00, 0x00, 0xa2, 0x00, 0x00, 0x00, + 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0xa4, 0x00, 0x00, 0x00, + 0x9e, 0x00, 0x00, 0x00, 0xa3, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, + 0x07, 0x00, 0x00, 0x00, 0xa5, 0x00, 0x00, 0x00, 0x75, 0x00, 0x00, 0x00, + 0x2e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0xa5, 0x00, 0x00, 0x00, + 0xa4, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0xaa, 0x00, 0x00, 0x00, 0x75, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0xab, 0x00, 0x00, 0x00, 0xaa, 0x00, 0x00, 0x00, + 0x00, 0x00, 0x00, 0x00, 0x51, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0xac, 0x00, 0x00, 0x00, 0xaa, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x51, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0xad, 0x00, 0x00, 0x00, + 0xaa, 0x00, 0x00, 0x00, 0x02, 0x00, 0x00, 0x00, 0x50, 0x00, 0x07, 0x00, + 0xa6, 0x00, 0x00, 0x00, 0xae, 0x00, 0x00, 0x00, 0xab, 0x00, 0x00, 0x00, + 0xac, 0x00, 0x00, 0x00, 0xad, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, + 0x41, 0x00, 0x05, 0x00, 0xaf, 0x00, 0x00, 0x00, 0xb0, 0x00, 0x00, 0x00, + 0xa9, 0x00, 0x00, 0x00, 0x87, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, + 0xb0, 0x00, 0x00, 0x00, 0xae, 0x00, 0x00, 0x00, 0xfd, 0x00, 0x01, 0x00, + 0x38, 0x00, 0x01, 0x00, 0x36, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, + 0x37, 0x00, 0x03, 0x00, 0x07, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, + 0xf8, 0x00, 0x02, 0x00, 0x0b, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, 0x09, 0x00, 0x00, 0x00, + 0x0c, 0x00, 0x06, 0x00, 0x06, 0x00, 0x00, 0x00, 0x13, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x12, 0x00, 0x00, 0x00, + 0x85, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, + 0x13, 0x00, 0x00, 0x00, 0x14, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x06, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x16, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x15, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x02, 0x00, + 0x16, 0x00, 0x00, 0x00, 0x38, 0x00, 0x01, 0x00, 0x36, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x10, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, + 0x0e, 0x00, 0x00, 0x00, 0x37, 0x00, 0x03, 0x00, 0x0d, 0x00, 0x00, 0x00, + 0x0f, 0x00, 0x00, 0x00, 0xf8, 0x00, 0x02, 0x00, 0x11, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x0d, 0x00, 0x00, 0x00, + 0x1c, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x3a, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x47, 0x00, 0x00, 0x00, + 0x40, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x47, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x4c, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x56, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x5b, 0x00, 0x00, 0x00, + 0x56, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x5b, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, 0x63, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x63, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x04, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, + 0x68, 0x00, 0x00, 0x00, 0x07, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, + 0x0c, 0x00, 0x06, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, 0x1a, 0x00, 0x00, 0x00, + 0x3e, 0x00, 0x03, 0x00, 0x19, 0x00, 0x00, 0x00, 0x1b, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x06, 0x00, 0x0c, 0x00, 0x00, 0x00, - 0x1b, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x08, 0x00, 0x00, 0x00, - 0x1a, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x19, 0x00, 0x00, 0x00, - 0x1b, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, - 0x1d, 0x00, 0x00, 0x00, 0x0f, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x06, 0x00, - 0x0c, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x0a, 0x00, 0x00, 0x00, 0x1d, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, - 0x1c, 0x00, 0x00, 0x00, 0x1e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x0c, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, - 0x1c, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, 0x0c, 0x00, 0x00, 0x00, - 0x21, 0x00, 0x00, 0x00, 0x1f, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, - 0x1c, 0x00, 0x00, 0x00, 0x8e, 0x00, 0x05, 0x00, 0x0c, 0x00, 0x00, 0x00, - 0x25, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, - 0x50, 0x00, 0x06, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, - 0x22, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, - 0x83, 0x00, 0x05, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, - 0x26, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, - 0x0c, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, - 0x27, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x1c, 0x00, 0x00, 0x00, - 0x28, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x2c, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x2d, 0x00, 0x00, 0x00, - 0x2c, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x2f, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, - 0x2f, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x32, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, - 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, - 0x2d, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, - 0x35, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x37, 0x00, 0x00, 0x00, 0x36, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, - 0x37, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x39, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x03, 0x00, 0x29, 0x00, 0x00, 0x00, 0x39, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x00, 0x00, - 0x29, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x3a, 0x00, 0x00, 0x00, - 0x3b, 0x00, 0x00, 0x00, 0x39, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x3c, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x00, 0x00, + 0x1e, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x1d, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x1c, 0x00, 0x00, 0x00, + 0x1e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0x1f, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, + 0x85, 0x00, 0x05, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, + 0x1f, 0x00, 0x00, 0x00, 0x20, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0x24, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, + 0x8e, 0x00, 0x05, 0x00, 0x0c, 0x00, 0x00, 0x00, 0x25, 0x00, 0x00, 0x00, + 0x24, 0x00, 0x00, 0x00, 0x23, 0x00, 0x00, 0x00, 0x50, 0x00, 0x06, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, + 0x22, 0x00, 0x00, 0x00, 0x22, 0x00, 0x00, 0x00, 0x83, 0x00, 0x05, 0x00, + 0x0c, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, 0x26, 0x00, 0x00, 0x00, + 0x25, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, 0x0c, 0x00, 0x00, 0x00, + 0x28, 0x00, 0x00, 0x00, 0x21, 0x00, 0x00, 0x00, 0x27, 0x00, 0x00, 0x00, + 0x3e, 0x00, 0x03, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x28, 0x00, 0x00, 0x00, + 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, + 0x19, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x2d, 0x00, 0x00, 0x00, 0x2c, 0x00, 0x00, 0x00, + 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00, 0x00, + 0x19, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x30, 0x00, 0x00, 0x00, 0x2f, 0x00, 0x00, 0x00, + 0x85, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x32, 0x00, 0x00, 0x00, + 0x30, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x33, 0x00, 0x00, 0x00, 0x2d, 0x00, 0x00, 0x00, + 0x32, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x36, 0x00, 0x00, 0x00, 0x19, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00, + 0x36, 0x00, 0x00, 0x00, 0x85, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x38, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x37, 0x00, 0x00, 0x00, + 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x39, 0x00, 0x00, 0x00, + 0x33, 0x00, 0x00, 0x00, 0x38, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, + 0x29, 0x00, 0x00, 0x00, 0x39, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, + 0x3e, 0x00, 0x03, 0x00, 0x3a, 0x00, 0x00, 0x00, 0x3b, 0x00, 0x00, 0x00, + 0x39, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x3a, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, + 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, + 0x40, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, 0x39, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x40, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x42, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x43, 0x00, 0x00, 0x00, + 0x42, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x08, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x44, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, + 0x3c, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, 0x43, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x3f, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x03, 0x00, 0x40, 0x00, 0x00, 0x00, 0x3f, 0x00, 0x00, 0x00, - 0x39, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, - 0x0a, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, - 0x2b, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x43, 0x00, 0x00, 0x00, 0x42, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x08, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x2e, 0x00, 0x00, 0x00, 0x3c, 0x00, 0x00, 0x00, 0x41, 0x00, 0x00, 0x00, - 0x43, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x45, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x46, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x00, - 0x31, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x47, 0x00, 0x00, 0x00, - 0x46, 0x00, 0x00, 0x00, 0x39, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x48, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x47, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x49, 0x00, 0x00, 0x00, - 0x29, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x4b, 0x00, 0x00, 0x00, 0x49, 0x00, 0x00, 0x00, 0x4a, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x03, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x4b, 0x00, 0x00, 0x00, - 0x39, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x4d, 0x00, 0x00, 0x00, - 0x0a, 0x00, 0x00, 0x00, 0x4c, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x4e, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, - 0x2b, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x4f, 0x00, 0x00, 0x00, 0x4e, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x08, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x2e, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, 0x4d, 0x00, 0x00, 0x00, - 0x4f, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x51, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x52, 0x00, 0x00, 0x00, - 0x51, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x08, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x53, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, - 0x44, 0x00, 0x00, 0x00, 0x50, 0x00, 0x00, 0x00, 0x52, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, - 0x29, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x55, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x03, 0x00, 0x56, 0x00, 0x00, 0x00, 0x55, 0x00, 0x00, 0x00, - 0x39, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x57, 0x00, 0x00, 0x00, - 0x0a, 0x00, 0x00, 0x00, 0x56, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, - 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00, 0x00, - 0x58, 0x00, 0x00, 0x00, 0x59, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, - 0x5b, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x39, 0x00, 0x05, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, - 0x5b, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x5d, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x5e, 0x00, 0x00, 0x00, - 0x5d, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x08, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x5f, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, - 0x57, 0x00, 0x00, 0x00, 0x5c, 0x00, 0x00, 0x00, 0x5e, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, - 0x29, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x62, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x61, 0x00, 0x00, 0x00, - 0x3e, 0x00, 0x03, 0x00, 0x63, 0x00, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00, - 0x39, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, - 0x0a, 0x00, 0x00, 0x00, 0x63, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, - 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x67, 0x00, 0x00, 0x00, - 0x65, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, - 0x68, 0x00, 0x00, 0x00, 0x67, 0x00, 0x00, 0x00, 0x39, 0x00, 0x05, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x69, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, - 0x68, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, - 0x6a, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, - 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x6b, 0x00, 0x00, 0x00, - 0x6a, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x08, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x6c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, - 0x64, 0x00, 0x00, 0x00, 0x69, 0x00, 0x00, 0x00, 0x6b, 0x00, 0x00, 0x00, - 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x00, + 0x46, 0x00, 0x00, 0x00, 0x45, 0x00, 0x00, 0x00, 0x31, 0x00, 0x00, 0x00, + 0x3e, 0x00, 0x03, 0x00, 0x47, 0x00, 0x00, 0x00, 0x46, 0x00, 0x00, 0x00, + 0x39, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x48, 0x00, 0x00, 0x00, + 0x0a, 0x00, 0x00, 0x00, 0x47, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x49, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, + 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x4b, 0x00, 0x00, 0x00, + 0x49, 0x00, 0x00, 0x00, 0x4a, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, + 0x4c, 0x00, 0x00, 0x00, 0x4b, 0x00, 0x00, 0x00, 0x39, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x4d, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x4c, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x4e, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x4f, 0x00, 0x00, 0x00, + 0x4e, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x08, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x50, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, + 0x48, 0x00, 0x00, 0x00, 0x4d, 0x00, 0x00, 0x00, 0x4f, 0x00, 0x00, 0x00, + 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x51, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x6e, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x00, - 0x0c, 0x00, 0x08, 0x00, 0x06, 0x00, 0x00, 0x00, 0x6f, 0x00, 0x00, 0x00, - 0x01, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, - 0x6c, 0x00, 0x00, 0x00, 0x6e, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, - 0x07, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, - 0x35, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, - 0x71, 0x00, 0x00, 0x00, 0x70, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x08, 0x00, - 0x06, 0x00, 0x00, 0x00, 0x72, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, - 0x2e, 0x00, 0x00, 0x00, 0x53, 0x00, 0x00, 0x00, 0x6f, 0x00, 0x00, 0x00, - 0x71, 0x00, 0x00, 0x00, 0xfe, 0x00, 0x02, 0x00, 0x72, 0x00, 0x00, 0x00, - 0x38, 0x00, 0x01, 0x00 + 0x06, 0x00, 0x00, 0x00, 0x52, 0x00, 0x00, 0x00, 0x51, 0x00, 0x00, 0x00, + 0x0c, 0x00, 0x08, 0x00, 0x06, 0x00, 0x00, 0x00, 0x53, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x44, 0x00, 0x00, 0x00, + 0x50, 0x00, 0x00, 0x00, 0x52, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x54, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, + 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x55, 0x00, 0x00, 0x00, + 0x54, 0x00, 0x00, 0x00, 0x34, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, + 0x56, 0x00, 0x00, 0x00, 0x55, 0x00, 0x00, 0x00, 0x39, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x57, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x56, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x58, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x5a, 0x00, 0x00, 0x00, 0x58, 0x00, 0x00, 0x00, + 0x59, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x5b, 0x00, 0x00, 0x00, + 0x5a, 0x00, 0x00, 0x00, 0x39, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x5c, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x5b, 0x00, 0x00, 0x00, + 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x5d, 0x00, 0x00, 0x00, + 0x1c, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x5e, 0x00, 0x00, 0x00, 0x5d, 0x00, 0x00, 0x00, + 0x0c, 0x00, 0x08, 0x00, 0x06, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x57, 0x00, 0x00, 0x00, + 0x5c, 0x00, 0x00, 0x00, 0x5e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x60, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, + 0x81, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00, + 0x60, 0x00, 0x00, 0x00, 0x61, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, + 0x63, 0x00, 0x00, 0x00, 0x62, 0x00, 0x00, 0x00, 0x39, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, + 0x63, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x65, 0x00, 0x00, 0x00, 0x29, 0x00, 0x00, 0x00, 0x81, 0x00, 0x05, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x67, 0x00, 0x00, 0x00, 0x65, 0x00, 0x00, 0x00, + 0x66, 0x00, 0x00, 0x00, 0x3e, 0x00, 0x03, 0x00, 0x68, 0x00, 0x00, 0x00, + 0x67, 0x00, 0x00, 0x00, 0x39, 0x00, 0x05, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x69, 0x00, 0x00, 0x00, 0x0a, 0x00, 0x00, 0x00, 0x68, 0x00, 0x00, 0x00, + 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, 0x6a, 0x00, 0x00, 0x00, + 0x1c, 0x00, 0x00, 0x00, 0x2b, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x6b, 0x00, 0x00, 0x00, 0x6a, 0x00, 0x00, 0x00, + 0x0c, 0x00, 0x08, 0x00, 0x06, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, + 0x01, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, 0x64, 0x00, 0x00, 0x00, + 0x69, 0x00, 0x00, 0x00, 0x6b, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, + 0x07, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, + 0x2e, 0x00, 0x00, 0x00, 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x6e, 0x00, 0x00, 0x00, 0x6d, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x08, 0x00, + 0x06, 0x00, 0x00, 0x00, 0x6f, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, + 0x2e, 0x00, 0x00, 0x00, 0x5f, 0x00, 0x00, 0x00, 0x6c, 0x00, 0x00, 0x00, + 0x6e, 0x00, 0x00, 0x00, 0x41, 0x00, 0x05, 0x00, 0x07, 0x00, 0x00, 0x00, + 0x70, 0x00, 0x00, 0x00, 0x1c, 0x00, 0x00, 0x00, 0x35, 0x00, 0x00, 0x00, + 0x3d, 0x00, 0x04, 0x00, 0x06, 0x00, 0x00, 0x00, 0x71, 0x00, 0x00, 0x00, + 0x70, 0x00, 0x00, 0x00, 0x0c, 0x00, 0x08, 0x00, 0x06, 0x00, 0x00, 0x00, + 0x72, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x2e, 0x00, 0x00, 0x00, + 0x53, 0x00, 0x00, 0x00, 0x6f, 0x00, 0x00, 0x00, 0x71, 0x00, 0x00, 0x00, + 0xfe, 0x00, 0x02, 0x00, 0x72, 0x00, 0x00, 0x00, 0x38, 0x00, 0x01, 0x00 }; -unsigned int ribbon_simple_vert_spv_len = 4120; +unsigned int ribbon_simple_vert_spv_len = 4056; diff --git a/menu/drivers_display/menu_display_vulkan.c b/menu/drivers_display/menu_display_vulkan.c index a8c0b4ff00..82e5eaca03 100644 --- a/menu/drivers_display/menu_display_vulkan.c +++ b/menu/drivers_display/menu_display_vulkan.c @@ -24,18 +24,19 @@ #include "../menu_display.h" +/* Will do Y-flip later, but try to make it similar to GL. */ static const float vk_vertexes[] = { 0, 0, - 0, 1, 1, 0, + 0, 1, 1, 1 }; static const float vk_tex_coords[] = { - 0, 0, 0, 1, - 1, 0, - 1, 1 + 1, 1, + 0, 0, + 1, 0 }; static void *menu_display_vk_get_default_mvp(void) @@ -154,7 +155,7 @@ static void menu_display_vk_draw(void *data) for (i = 0; i < draw->coords->vertices; i++, pv++) { pv->x = *vertex++; - pv->y = *vertex++; + pv->y = 1.0f - (*vertex++); /* Y-flip. Vulkan is top-left clip space */ pv->tex_x = *tex_coord++; pv->tex_y = *tex_coord++; pv->color.r = *color++; @@ -215,6 +216,7 @@ static void menu_display_vk_clear_color(menu_display_ctx_clearcolor_t *clearcolo if (!vk || !clearcolor) return; + memset(&attachment, 0, sizeof(attachment)); attachment.aspectMask = VK_IMAGE_ASPECT_COLOR_BIT; attachment.clearValue.color.float32[0] = clearcolor->r; attachment.clearValue.color.float32[1] = clearcolor->g; diff --git a/menu/menu_display.c b/menu/menu_display.c index f0db55c910..bb8bc842ca 100644 --- a/menu/menu_display.c +++ b/menu/menu_display.c @@ -471,7 +471,7 @@ void menu_display_draw_pipeline(menu_display_ctx_draw_t *draw) void menu_display_draw_bg(menu_display_ctx_draw_t *draw) { - struct gfx_coords coords; + static struct gfx_coords coords; const float *new_vertex = NULL; const float *new_tex_coord = NULL; if (!menu_disp || !draw) @@ -501,9 +501,9 @@ void menu_display_draw_bg(menu_display_ctx_draw_t *draw) void menu_display_draw_gradient(menu_display_ctx_draw_t *draw) { - draw->texture = 0; - draw->x = 0; - draw->y = 0; + draw->texture = 0; + draw->x = 0; + draw->y = 0; menu_display_draw_bg(draw); menu_display_draw(draw); From 11ec23bc18d762d9f1b9f1dfcfaa977e846b9dc6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 15:41:23 +0200 Subject: [PATCH 264/498] Create inet_ptrton --- libretro-common/include/net/net_compat.h | 10 ++-------- libretro-common/net/net_compat.c | 13 +++++++++++++ libretro-common/net/net_socket.c | 2 +- 3 files changed, 16 insertions(+), 9 deletions(-) diff --git a/libretro-common/include/net/net_compat.h b/libretro-common/include/net/net_compat.h index 690a9a1b9c..e95c203678 100644 --- a/libretro-common/include/net/net_compat.h +++ b/libretro-common/include/net/net_compat.h @@ -136,14 +136,6 @@ struct hostent #ifdef GEKKO #define sendto(s, msg, len, flags, addr, tolen) net_sendto(s, msg, len, 0, addr, 8) #define socket(domain, type, protocol) net_socket(domain, type, protocol) - -static INLINE int inet_pton(int af, const char *src, void *dst) -{ - if (af != AF_INET) - return -1; - - return inet_aton (src, dst); -} #endif static INLINE bool isagain(int bytes) @@ -213,6 +205,8 @@ struct addrinfo uint16_t inet_htons(uint16_t hostshort); +int inet_ptrton(int af, const char *src, void *dst); + int getaddrinfo_retro(const char *node, const char *service, struct addrinfo *hints, struct addrinfo **res); diff --git a/libretro-common/net/net_compat.c b/libretro-common/net/net_compat.c index c6d1b56dda..ce989975c8 100644 --- a/libretro-common/net/net_compat.c +++ b/libretro-common/net/net_compat.c @@ -326,3 +326,16 @@ uint16_t inet_htons(uint16_t hostshort) return htons(hostshort); #endif } + +int inet_ptrton(int af, const char *src, void *dst) +{ + /* TODO/FIXME - should use InetPton on Vista and later */ +#if defined(GEKKO) || defined(_WIN32) + if (af != AF_INET) + return -1; + + return inet_aton(src, dst); +#else + return inet_pton(af, src, dst); +#endif +} diff --git a/libretro-common/net/net_socket.c b/libretro-common/net/net_socket.c index 557ccb6800..f86c04dc02 100644 --- a/libretro-common/net/net_socket.c +++ b/libretro-common/net/net_socket.c @@ -307,7 +307,7 @@ void socket_set_target(void *data, socket_target_t *in_addr) out_target->sin_len = 8; #endif - inet_pton(AF_INET, in_addr->server, &out_target->sin_addr); + inet_ptrton(AF_INET, in_addr->server, &out_target->sin_addr); #endif } From d1eb9a0d3a5cde50c18c74741902bd67fcf576b2 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 15:48:12 +0200 Subject: [PATCH 265/498] Move variables outside of audio_driver_ctl --- audio/audio_driver.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/audio/audio_driver.c b/audio/audio_driver.c index 0f598d1f96..ba596b7833 100644 --- a/audio/audio_driver.c +++ b/audio/audio_driver.c @@ -154,8 +154,15 @@ static const audio_driver_t *audio_drivers[] = { }; static audio_driver_input_data_t audio_driver_data; -static const audio_driver_t *current_audio = NULL; -static void *audio_driver_context_audio_data = NULL; +static struct retro_audio_callback audio_callback; +static struct string_list *audio_driver_devices_list = NULL; +static struct retro_perf_counter resampler_proc = {0}; +static const rarch_resampler_t *audio_driver_resampler = NULL; +static void *audio_driver_resampler_data = NULL; +static bool audio_driver_active = false; +static bool audio_driver_data_own = false; +static const audio_driver_t *current_audio = NULL; +static void *audio_driver_context_audio_data = NULL; /** * compute_audio_buffer_statistics: @@ -778,13 +785,6 @@ static bool find_audio_driver(void) bool audio_driver_ctl(enum rarch_audio_ctl_state state, void *data) { - static struct retro_audio_callback audio_callback; - static struct string_list *audio_driver_devices_list = NULL; - static struct retro_perf_counter resampler_proc = {0}; - static const rarch_resampler_t *audio_driver_resampler = NULL; - static void *audio_driver_resampler_data = NULL; - static bool audio_driver_active = false; - static bool audio_driver_data_own = false; settings_t *settings = config_get_ptr(); switch (state) From 41a8496b1c362ae6e3d212eea2bde6f90ed357db Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 15:53:12 +0200 Subject: [PATCH 266/498] Start converting functions --- audio/audio_driver.c | 54 +++++++++++++++++++++++++------------------- audio/audio_driver.h | 9 +++++--- driver.c | 2 +- 3 files changed, 38 insertions(+), 27 deletions(-) diff --git a/audio/audio_driver.c b/audio/audio_driver.c index ba596b7833..80cd8a8314 100644 --- a/audio/audio_driver.c +++ b/audio/audio_driver.c @@ -288,7 +288,7 @@ static bool uninit_audio(void) return false; } - audio_driver_ctl(RARCH_AUDIO_CTL_RESAMPLER_DEINIT, NULL); + audio_driver_deinit_resampler(); if (audio_driver_data.data) free(audio_driver_data.data); @@ -783,33 +783,41 @@ static bool find_audio_driver(void) return true; } +void audio_driver_deinit_resampler(void) +{ + rarch_resampler_freep(&audio_driver_resampler, + &audio_driver_resampler_data); +} + +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, + audio_driver_devices_list); + audio_driver_devices_list = NULL; + return true; +} + +bool audio_driver_new_devices_list(void) +{ + if (!current_audio || !current_audio->device_list_new + || !audio_driver_context_audio_data) + return false; + audio_driver_devices_list = (struct string_list*) + current_audio->device_list_new(audio_driver_context_audio_data); + if (!audio_driver_devices_list) + return false; + return true; +} + bool audio_driver_ctl(enum rarch_audio_ctl_state state, void *data) { settings_t *settings = config_get_ptr(); switch (state) { - case RARCH_AUDIO_CTL_RESAMPLER_DEINIT: - rarch_resampler_freep(&audio_driver_resampler, - &audio_driver_resampler_data); - break; - case RARCH_AUDIO_CTL_DEVICES_LIST_FREE: - 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, - audio_driver_devices_list); - audio_driver_devices_list = NULL; - break; - case RARCH_AUDIO_CTL_DEVICES_LIST_NEW: - if (!current_audio || !current_audio->device_list_new - || !audio_driver_context_audio_data) - return false; - audio_driver_devices_list = (struct string_list*) - current_audio->device_list_new(audio_driver_context_audio_data); - if (!audio_driver_devices_list) - return false; - break; case RARCH_AUDIO_CTL_DEVICES_LIST_GET: { struct string_list**ptr = (struct string_list**)data; @@ -843,7 +851,7 @@ bool audio_driver_ctl(enum rarch_audio_ctl_state state, void *data) audio_driver_context_audio_data = NULL; break; case RARCH_AUDIO_CTL_DEINIT: - audio_driver_ctl(RARCH_AUDIO_CTL_DEVICES_LIST_FREE, NULL); + audio_driver_free_devices_list(); if (!uninit_audio()) return false; break; diff --git a/audio/audio_driver.h b/audio/audio_driver.h index 38ac06352f..90fc35c4b7 100644 --- a/audio/audio_driver.h +++ b/audio/audio_driver.h @@ -63,11 +63,8 @@ enum rarch_audio_ctl_state RARCH_AUDIO_CTL_SET_ACTIVE, RARCH_AUDIO_CTL_UNSET_ACTIVE, RARCH_AUDIO_CTL_IS_ACTIVE, - RARCH_AUDIO_CTL_RESAMPLER_DEINIT, RARCH_AUDIO_CTL_RESAMPLER_INIT, RARCH_AUDIO_CTL_RESAMPLER_PROCESS, - RARCH_AUDIO_CTL_DEVICES_LIST_NEW, - RARCH_AUDIO_CTL_DEVICES_LIST_FREE, RARCH_AUDIO_CTL_DEVICES_LIST_GET }; @@ -125,6 +122,12 @@ typedef struct audio_driver bool audio_driver_ctl(enum rarch_audio_ctl_state state, void *data); +void audio_driver_deinit_resampler(void); + +bool audio_driver_free_devices_list(void); + +bool audio_driver_new_devices_list(void); + /** * audio_driver_find_handle: * @index : index of driver to get handle to. diff --git a/driver.c b/driver.c index 6a4f3c94af..cd9c5ff426 100644 --- a/driver.c +++ b/driver.c @@ -339,7 +339,7 @@ static void init_drivers(int flags) if (flags & DRIVER_AUDIO) { audio_driver_ctl(RARCH_AUDIO_CTL_INIT, NULL); - audio_driver_ctl(RARCH_AUDIO_CTL_DEVICES_LIST_NEW, NULL); + audio_driver_new_devices_list(); } /* Only initialize camera driver if we're ever going to use it. */ From fc5f1524cce73e92877c932e43e5d18338bf4db2 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 16:02:46 +0200 Subject: [PATCH 267/498] Convert more functions over --- audio/audio_driver.c | 29 ++++++++++++++++------------- audio/audio_driver.h | 10 +++++++--- driver.c | 2 +- menu/menu_setting.c | 6 ++++-- 4 files changed, 28 insertions(+), 19 deletions(-) diff --git a/audio/audio_driver.c b/audio/audio_driver.c index 80cd8a8314..7984dc4859 100644 --- a/audio/audio_driver.c +++ b/audio/audio_driver.c @@ -260,7 +260,6 @@ const char *config_get_audio_driver_options(void) return char_list_new_special(STRING_LIST_AUDIO_DRIVERS, NULL); } - static bool uninit_audio(void) { settings_t *settings = config_get_ptr(); @@ -305,7 +304,7 @@ static bool uninit_audio(void) return true; } -static bool init_audio(bool audio_cb_inited) +static bool audio_driver_init_internal(bool audio_cb_inited) { size_t outsamples_max, max_bufsamples = AUDIO_CHUNK_SIZE_NONBLOCKING * 2; settings_t *settings = config_get_ptr(); @@ -356,7 +355,7 @@ static bool init_audio(bool audio_cb_inited) current_audio)) { RARCH_ERR("Cannot open threaded audio driver ... Exiting ...\n"); - retro_fail(1, "init_audio()"); + retro_fail(1, "audio_driver_init_internal()"); } } else @@ -812,20 +811,26 @@ bool audio_driver_new_devices_list(void) return true; } +bool audio_driver_init(void) +{ + return audio_driver_init_internal(audio_callback.callback != NULL); +} + +bool audio_driver_get_devices_list(void **data) +{ + struct string_list**ptr = (struct string_list**)data; + if (!ptr) + return false; + *ptr = audio_driver_devices_list; + return true; +} + bool audio_driver_ctl(enum rarch_audio_ctl_state state, void *data) { settings_t *settings = config_get_ptr(); switch (state) { - case RARCH_AUDIO_CTL_DEVICES_LIST_GET: - { - struct string_list**ptr = (struct string_list**)data; - if (!ptr) - return false; - *ptr = audio_driver_devices_list; - } - break; case RARCH_AUDIO_CTL_RESAMPLER_INIT: return rarch_resampler_realloc( &audio_driver_resampler_data, @@ -840,8 +845,6 @@ bool audio_driver_ctl(enum rarch_audio_ctl_state state, void *data) (struct resampler_data*)data); retro_perf_stop(&resampler_proc); break; - case RARCH_AUDIO_CTL_INIT: - return init_audio(audio_callback.callback != NULL); case RARCH_AUDIO_CTL_DESTROY: audio_driver_active = false; audio_driver_data_own = false; diff --git a/audio/audio_driver.h b/audio/audio_driver.h index 90fc35c4b7..91a42b72ab 100644 --- a/audio/audio_driver.h +++ b/audio/audio_driver.h @@ -20,7 +20,9 @@ #include #include #include + #include + #include "audio_dsp_filter.h" #ifdef __cplusplus @@ -37,7 +39,6 @@ extern "C" { enum rarch_audio_ctl_state { RARCH_AUDIO_CTL_NONE = 0, - RARCH_AUDIO_CTL_INIT, RARCH_AUDIO_CTL_DEINIT, RARCH_AUDIO_CTL_DESTROY, RARCH_AUDIO_CTL_DESTROY_DATA, @@ -64,8 +65,7 @@ enum rarch_audio_ctl_state RARCH_AUDIO_CTL_UNSET_ACTIVE, RARCH_AUDIO_CTL_IS_ACTIVE, RARCH_AUDIO_CTL_RESAMPLER_INIT, - RARCH_AUDIO_CTL_RESAMPLER_PROCESS, - RARCH_AUDIO_CTL_DEVICES_LIST_GET + RARCH_AUDIO_CTL_RESAMPLER_PROCESS }; typedef struct audio_driver @@ -173,6 +173,10 @@ void audio_driver_dsp_filter_init(const char *device); void audio_driver_set_buffer_size(size_t bufsize); +bool audio_driver_get_devices_list(void **ptr); + +bool audio_driver_init(void); + extern audio_driver_t audio_rsound; extern audio_driver_t audio_oss; extern audio_driver_t audio_alsa; diff --git a/driver.c b/driver.c index cd9c5ff426..4b7133b3d0 100644 --- a/driver.c +++ b/driver.c @@ -338,7 +338,7 @@ static void init_drivers(int flags) if (flags & DRIVER_AUDIO) { - audio_driver_ctl(RARCH_AUDIO_CTL_INIT, NULL); + audio_driver_init(); audio_driver_new_devices_list(); } diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 87d8502097..4d21434843 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -759,7 +759,8 @@ static int setting_string_action_left_audio_device(void *data, bool wraparound) int audio_device_index; struct string_list *ptr = NULL; rarch_setting_t *setting = (rarch_setting_t*)data; - if (!audio_driver_ctl(RARCH_AUDIO_CTL_DEVICES_LIST_GET, &ptr)) + + if (!audio_driver_get_devices_list((void**)&ptr)) return -1; if (!ptr) @@ -783,7 +784,8 @@ static int setting_string_action_right_audio_device(void *data, bool wraparound) int audio_device_index; struct string_list *ptr = NULL; rarch_setting_t *setting = (rarch_setting_t*)data; - if (!audio_driver_ctl(RARCH_AUDIO_CTL_DEVICES_LIST_GET, &ptr)) + + if (!audio_driver_get_devices_list((void**)&ptr)) return -1; if (!ptr) From 0c05828874bfeca2474d0928a00619975fe68542 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 16:09:08 +0200 Subject: [PATCH 268/498] Change more functions --- audio/audio_driver.c | 37 +++++++++++++++++++++---------------- audio/audio_driver.h | 9 ++++++--- 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/audio/audio_driver.c b/audio/audio_driver.c index 7984dc4859..f32dfed2fd 100644 --- a/audio/audio_driver.c +++ b/audio/audio_driver.c @@ -396,7 +396,7 @@ static bool audio_driver_init_internal(bool audio_cb_inited) audio_driver_data.audio_rate.source_ratio.current = (double)settings->audio.out_rate / audio_driver_data.audio_rate.input; - if (!audio_driver_ctl(RARCH_AUDIO_CTL_RESAMPLER_INIT, NULL)) + if (!audio_driver_init_resampler()) { RARCH_ERR("Failed to initialize resampler \"%s\".\n", settings->audio.resampler); @@ -572,7 +572,7 @@ static bool audio_driver_flush(const int16_t *data, size_t samples) if (runloop_ctl(RUNLOOP_CTL_IS_SLOWMOTION, NULL)) src_data.ratio *= settings->slowmotion_ratio; - audio_driver_ctl(RARCH_AUDIO_CTL_RESAMPLER_PROCESS, &src_data); + audio_driver_process_resampler(&src_data); output_data = audio_driver_data.output_samples.buf; output_frames = src_data.output_frames; @@ -825,26 +825,31 @@ bool audio_driver_get_devices_list(void **data) return true; } +bool audio_driver_init_resampler(void) +{ + settings_t *settings = config_get_ptr(); + return rarch_resampler_realloc( + &audio_driver_resampler_data, + &audio_driver_resampler, + settings->audio.resampler, + audio_driver_data.audio_rate.source_ratio.original); +} + +void audio_driver_process_resampler(struct resampler_data *data) +{ + rarch_perf_init(&resampler_proc, "resampler_proc"); + retro_perf_start(&resampler_proc); + rarch_resampler_process(audio_driver_resampler, + audio_driver_resampler_data, data); + retro_perf_stop(&resampler_proc); +} + bool audio_driver_ctl(enum rarch_audio_ctl_state state, void *data) { settings_t *settings = config_get_ptr(); switch (state) { - case RARCH_AUDIO_CTL_RESAMPLER_INIT: - return rarch_resampler_realloc( - &audio_driver_resampler_data, - &audio_driver_resampler, - settings->audio.resampler, - audio_driver_data.audio_rate.source_ratio.original); - case RARCH_AUDIO_CTL_RESAMPLER_PROCESS: - rarch_perf_init(&resampler_proc, "resampler_proc"); - retro_perf_start(&resampler_proc); - rarch_resampler_process(audio_driver_resampler, - audio_driver_resampler_data, - (struct resampler_data*)data); - retro_perf_stop(&resampler_proc); - break; case RARCH_AUDIO_CTL_DESTROY: audio_driver_active = false; audio_driver_data_own = false; diff --git a/audio/audio_driver.h b/audio/audio_driver.h index 91a42b72ab..dc6979a055 100644 --- a/audio/audio_driver.h +++ b/audio/audio_driver.h @@ -24,6 +24,7 @@ #include #include "audio_dsp_filter.h" +#include "audio_resampler_driver.h" #ifdef __cplusplus extern "C" { @@ -63,9 +64,7 @@ enum rarch_audio_ctl_state RARCH_AUDIO_CTL_OWNS_DRIVER, RARCH_AUDIO_CTL_SET_ACTIVE, RARCH_AUDIO_CTL_UNSET_ACTIVE, - RARCH_AUDIO_CTL_IS_ACTIVE, - RARCH_AUDIO_CTL_RESAMPLER_INIT, - RARCH_AUDIO_CTL_RESAMPLER_PROCESS + RARCH_AUDIO_CTL_IS_ACTIVE }; typedef struct audio_driver @@ -124,6 +123,10 @@ bool audio_driver_ctl(enum rarch_audio_ctl_state state, void *data); void audio_driver_deinit_resampler(void); +bool audio_driver_init_resampler(void); + +void audio_driver_process_resampler(struct resampler_data *data); + bool audio_driver_free_devices_list(void); bool audio_driver_new_devices_list(void); From e2090dc02d698a42019b7f04d0d785cac504e971 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 16:13:55 +0200 Subject: [PATCH 269/498] Vita doesn't support inet_pton either --- libretro-common/net/net_compat.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/libretro-common/net/net_compat.c b/libretro-common/net/net_compat.c index ce989975c8..c477c5f21c 100644 --- a/libretro-common/net/net_compat.c +++ b/libretro-common/net/net_compat.c @@ -330,10 +330,7 @@ uint16_t inet_htons(uint16_t hostshort) int inet_ptrton(int af, const char *src, void *dst) { /* TODO/FIXME - should use InetPton on Vista and later */ -#if defined(GEKKO) || defined(_WIN32) - if (af != AF_INET) - return -1; - +#if defined(GEKKO) || defined(_WIN32) || defined(VITA) return inet_aton(src, dst); #else return inet_pton(af, src, dst); From 60789e0141ffd0893423014b57e0870088e867c7 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 16:25:26 +0200 Subject: [PATCH 270/498] Cleanups --- libretro-common/queues/task_queue.c | 57 +++++++++++++++-------------- 1 file changed, 29 insertions(+), 28 deletions(-) diff --git a/libretro-common/queues/task_queue.c b/libretro-common/queues/task_queue.c index 5807b44f97..bddaf435ef 100644 --- a/libretro-common/queues/task_queue.c +++ b/libretro-common/queues/task_queue.c @@ -115,34 +115,6 @@ static retro_task_t *task_queue_get(task_queue_t *queue) return task; } -static void task_queue_remove(task_queue_t *queue, retro_task_t *task) -{ - retro_task_t *t; - - /* Remove first element if needed */ - if (task == queue->front) - { - queue->front = task->next; - task->next = NULL; - return; - } - - /* Parse queue */ - t = queue->front; - while (t && t->next) - { - /* Remove task and update queue */ - if (t->next == task) - { - t->next = task->next; - task->next = NULL; - break; - } - - /* Update iterator */ - t = t->next; - } -} static void retro_task_internal_gather(void) { @@ -294,6 +266,35 @@ static scond_t *worker_cond = NULL; static sthread_t *worker_thread = NULL; static bool worker_continue = true; /* use running_lock when touching it */ +static void task_queue_remove(task_queue_t *queue, retro_task_t *task) +{ + retro_task_t *t = NULL; + + /* Remove first element if needed */ + if (task == queue->front) + { + queue->front = task->next; + task->next = NULL; + return; + } + + /* Parse queue */ + t = queue->front; + while (t && t->next) + { + /* Remove task and update queue */ + if (t->next == task) + { + t->next = task->next; + task->next = NULL; + break; + } + + /* Update iterator */ + t = t->next; + } +} + static void retro_task_threaded_push_running(retro_task_t *task) { slock_lock(running_lock); From e1307c7d4b341486c686ab2ec570c5496652af75 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 16:28:24 +0200 Subject: [PATCH 271/498] Create audio_driver_setup_rewind --- audio/audio_driver.c | 5 +---- audio/audio_driver.h | 3 ++- rewind.c | 3 ++- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/audio/audio_driver.c b/audio/audio_driver.c index f32dfed2fd..9cbd0fee49 100644 --- a/audio/audio_driver.c +++ b/audio/audio_driver.c @@ -729,7 +729,7 @@ static void audio_monitor_adjust_system_rates(void) audio_driver_data.audio_rate.input); } -static void audio_driver_setup_rewind(void) +void audio_driver_setup_rewind(void) { unsigned i; @@ -863,9 +863,6 @@ bool audio_driver_ctl(enum rarch_audio_ctl_state state, void *data) if (!uninit_audio()) return false; break; - case RARCH_AUDIO_CTL_SETUP_REWIND: - audio_driver_setup_rewind(); - break; case RARCH_AUDIO_CTL_SET_CALLBACK_ENABLE: if (!audio_driver_ctl(RARCH_AUDIO_CTL_HAS_CALLBACK, NULL)) return false; diff --git a/audio/audio_driver.h b/audio/audio_driver.h index dc6979a055..37916e4f19 100644 --- a/audio/audio_driver.h +++ b/audio/audio_driver.h @@ -46,7 +46,6 @@ enum rarch_audio_ctl_state RARCH_AUDIO_CTL_START, RARCH_AUDIO_CTL_STOP, RARCH_AUDIO_CTL_FIND_DRIVER, - RARCH_AUDIO_CTL_SETUP_REWIND, /* Sets audio monitor refresh rate to new value. */ RARCH_AUDIO_CTL_MONITOR_SET_REFRESH_RATE, RARCH_AUDIO_CTL_MONITOR_ADJUST_SYSTEM_RATES, @@ -178,6 +177,8 @@ void audio_driver_set_buffer_size(size_t bufsize); bool audio_driver_get_devices_list(void **ptr); +void audio_driver_setup_rewind(void); + bool audio_driver_init(void); extern audio_driver_t audio_rsound; diff --git a/rewind.c b/rewind.c index 1621e12d62..9ee215ba67 100644 --- a/rewind.c +++ b/rewind.c @@ -722,7 +722,8 @@ void state_manager_check_rewind(bool pressed) retro_ctx_serialize_info_t serial_info; state_manager_set_frame_is_reversed(true); - audio_driver_ctl(RARCH_AUDIO_CTL_SETUP_REWIND, NULL); + + audio_driver_setup_rewind(); runloop_msg_queue_push( msg_hash_to_str(MSG_REWINDING), 0, From 9dc3326d0eb84ea0492ee3abd83993d73471ab38 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 16:45:58 +0200 Subject: [PATCH 272/498] (audio_driver) Refactors --- audio/audio_driver.c | 54 ++++++++++++++++++++++++-------------------- audio/audio_driver.h | 5 +++- dynamic.c | 2 +- 3 files changed, 34 insertions(+), 27 deletions(-) diff --git a/audio/audio_driver.c b/audio/audio_driver.c index 9cbd0fee49..9960dc4079 100644 --- a/audio/audio_driver.c +++ b/audio/audio_driver.c @@ -453,7 +453,7 @@ static bool audio_driver_init_internal(bool audio_cb_inited) return true; error: - return audio_driver_ctl(RARCH_AUDIO_CTL_DEINIT, NULL); + return audio_driver_deinit(); } /* @@ -844,6 +844,34 @@ void audio_driver_process_resampler(struct resampler_data *data) retro_perf_stop(&resampler_proc); } +bool audio_driver_deinit(void) +{ + audio_driver_free_devices_list(); + if (!uninit_audio()) + return false; + return true; +} + +bool audio_driver_set_callback(const void *data) +{ + const struct retro_audio_callback *cb = (const struct retro_audio_callback*)data; +#ifdef HAVE_NETPLAY + global_t *global = global_get_ptr(); +#endif + + if (recording_driver_get_data_ptr()) /* A/V sync is a must. */ + return false; + +#ifdef HAVE_NETPLAY + if (global->netplay.enable) + return false; +#endif + if (cb) + audio_callback = *cb; + + return true; +} + bool audio_driver_ctl(enum rarch_audio_ctl_state state, void *data) { settings_t *settings = config_get_ptr(); @@ -858,11 +886,6 @@ bool audio_driver_ctl(enum rarch_audio_ctl_state state, void *data) case RARCH_AUDIO_CTL_DESTROY_DATA: audio_driver_context_audio_data = NULL; break; - case RARCH_AUDIO_CTL_DEINIT: - audio_driver_free_devices_list(); - if (!uninit_audio()) - return false; - break; case RARCH_AUDIO_CTL_SET_CALLBACK_ENABLE: if (!audio_driver_ctl(RARCH_AUDIO_CTL_HAS_CALLBACK, NULL)) return false; @@ -889,25 +912,6 @@ bool audio_driver_ctl(enum rarch_audio_ctl_state state, void *data) audio_callback.callback = NULL; audio_callback.set_state = NULL; break; - case RARCH_AUDIO_CTL_SET_CALLBACK: - { - const struct retro_audio_callback *cb = - (const struct retro_audio_callback*)data; -#ifdef HAVE_NETPLAY - global_t *global = global_get_ptr(); -#endif - - if (recording_driver_get_data_ptr()) /* A/V sync is a must. */ - return false; - -#ifdef HAVE_NETPLAY - if (global->netplay.enable) - return false; -#endif - if (cb) - audio_callback = *cb; - } - break; case RARCH_AUDIO_CTL_MONITOR_ADJUST_SYSTEM_RATES: audio_monitor_adjust_system_rates(); break; diff --git a/audio/audio_driver.h b/audio/audio_driver.h index 37916e4f19..ad8dd4db6a 100644 --- a/audio/audio_driver.h +++ b/audio/audio_driver.h @@ -52,7 +52,6 @@ enum rarch_audio_ctl_state RARCH_AUDIO_CTL_MUTE_TOGGLE, RARCH_AUDIO_CTL_SET_CALLBACK_ENABLE, RARCH_AUDIO_CTL_SET_CALLBACK_DISABLE, - RARCH_AUDIO_CTL_SET_CALLBACK, RARCH_AUDIO_CTL_UNSET_CALLBACK, RARCH_AUDIO_CTL_CALLBACK, RARCH_AUDIO_CTL_HAS_CALLBACK, @@ -179,6 +178,10 @@ bool audio_driver_get_devices_list(void **ptr); void audio_driver_setup_rewind(void); +bool audio_driver_set_callback(const void *data); + +bool audio_driver_deinit(void); + bool audio_driver_init(void); extern audio_driver_t audio_rsound; diff --git a/dynamic.c b/dynamic.c index 03ca24106b..cc06df1191 100644 --- a/dynamic.c +++ b/dynamic.c @@ -1029,7 +1029,7 @@ bool rarch_environment_cb(unsigned cmd, void *data) case RETRO_ENVIRONMENT_SET_AUDIO_CALLBACK: { RARCH_LOG("Environ SET_AUDIO_CALLBACK.\n"); - audio_driver_ctl(RARCH_AUDIO_CTL_SET_CALLBACK, data); + audio_driver_set_callback(data); break; } #endif From 13998f583acda7eb4cc5472e480ca8b8f68cd6c9 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 16:50:23 +0200 Subject: [PATCH 273/498] (audio driver) Refactors --- audio/audio_driver.c | 40 ++++++++++++++++++++---------------- audio/audio_driver.h | 9 +++++--- audio/audio_thread_wrapper.c | 4 ++-- driver.c | 2 +- 4 files changed, 31 insertions(+), 24 deletions(-) diff --git a/audio/audio_driver.c b/audio/audio_driver.c index 9960dc4079..ebdc6465b7 100644 --- a/audio/audio_driver.c +++ b/audio/audio_driver.c @@ -342,7 +342,7 @@ static bool audio_driver_init_internal(bool audio_cb_inited) return false; } - audio_driver_ctl(RARCH_AUDIO_CTL_FIND_DRIVER, NULL); + audio_driver_find_driver(); #ifdef HAVE_THREADS if (audio_cb_inited) { @@ -748,7 +748,7 @@ void audio_driver_setup_rewind(void) audio_driver_data.data_ptr = 0; } -static bool find_audio_driver(void) +bool audio_driver_find_driver(void) { int i; driver_ctx_info_t drv; @@ -776,7 +776,7 @@ static bool find_audio_driver(void) current_audio = (const audio_driver_t*)audio_driver_find_handle(0); if (!current_audio) - retro_fail(1, "find_audio_driver()"); + retro_fail(1, "audio_driver_find()"); } return true; @@ -872,6 +872,25 @@ bool audio_driver_set_callback(const void *data) return true; } +bool audio_driver_enable_callback(void) +{ + if (!audio_driver_ctl(RARCH_AUDIO_CTL_HAS_CALLBACK, NULL)) + return false; + if (audio_callback.set_state) + audio_callback.set_state(true); + return true; +} + +bool audio_driver_disable_callback(void) +{ + if (!audio_driver_ctl(RARCH_AUDIO_CTL_HAS_CALLBACK, NULL)) + return false; + + if (audio_callback.set_state) + audio_callback.set_state(false); + return true; +} + bool audio_driver_ctl(enum rarch_audio_ctl_state state, void *data) { settings_t *settings = config_get_ptr(); @@ -886,19 +905,6 @@ bool audio_driver_ctl(enum rarch_audio_ctl_state state, void *data) case RARCH_AUDIO_CTL_DESTROY_DATA: audio_driver_context_audio_data = NULL; break; - case RARCH_AUDIO_CTL_SET_CALLBACK_ENABLE: - if (!audio_driver_ctl(RARCH_AUDIO_CTL_HAS_CALLBACK, NULL)) - return false; - if (audio_callback.set_state) - audio_callback.set_state(true); - break; - case RARCH_AUDIO_CTL_SET_CALLBACK_DISABLE: - if (!audio_driver_ctl(RARCH_AUDIO_CTL_HAS_CALLBACK, NULL)) - return false; - - if (audio_callback.set_state) - audio_callback.set_state(false); - break; case RARCH_AUDIO_CTL_HAS_CALLBACK: return audio_callback.callback; case RARCH_AUDIO_CTL_CALLBACK: @@ -955,8 +961,6 @@ bool audio_driver_ctl(enum rarch_audio_ctl_state state, void *data) || !audio_driver_context_audio_data) return false; return current_audio->stop(audio_driver_context_audio_data); - case RARCH_AUDIO_CTL_FIND_DRIVER: - return find_audio_driver(); case RARCH_AUDIO_CTL_SET_OWN_DRIVER: audio_driver_data_own = true; break; diff --git a/audio/audio_driver.h b/audio/audio_driver.h index ad8dd4db6a..c2b6c33a94 100644 --- a/audio/audio_driver.h +++ b/audio/audio_driver.h @@ -45,13 +45,10 @@ enum rarch_audio_ctl_state RARCH_AUDIO_CTL_DESTROY_DATA, RARCH_AUDIO_CTL_START, RARCH_AUDIO_CTL_STOP, - RARCH_AUDIO_CTL_FIND_DRIVER, /* Sets audio monitor refresh rate to new value. */ RARCH_AUDIO_CTL_MONITOR_SET_REFRESH_RATE, RARCH_AUDIO_CTL_MONITOR_ADJUST_SYSTEM_RATES, RARCH_AUDIO_CTL_MUTE_TOGGLE, - RARCH_AUDIO_CTL_SET_CALLBACK_ENABLE, - RARCH_AUDIO_CTL_SET_CALLBACK_DISABLE, RARCH_AUDIO_CTL_UNSET_CALLBACK, RARCH_AUDIO_CTL_CALLBACK, RARCH_AUDIO_CTL_HAS_CALLBACK, @@ -129,6 +126,10 @@ bool audio_driver_free_devices_list(void); bool audio_driver_new_devices_list(void); +bool audio_driver_enable_callback(void); + +bool audio_driver_disable_callback(void); + /** * audio_driver_find_handle: * @index : index of driver to get handle to. @@ -180,6 +181,8 @@ void audio_driver_setup_rewind(void); bool audio_driver_set_callback(const void *data); +bool audio_driver_find_driver(void); + bool audio_driver_deinit(void); bool audio_driver_init(void); diff --git a/audio/audio_thread_wrapper.c b/audio/audio_thread_wrapper.c index 1ff8dd3c83..f2d5f297ef 100644 --- a/audio/audio_thread_wrapper.c +++ b/audio/audio_thread_wrapper.c @@ -190,7 +190,7 @@ static bool audio_thread_stop(void *data) audio_thread_block(thr); thr->is_paused = true; - audio_driver_ctl(RARCH_AUDIO_CTL_SET_CALLBACK_DISABLE, NULL); + audio_driver_disable_callback(); return true; } @@ -202,7 +202,7 @@ static bool audio_thread_start(void *data) if (!thr) return false; - audio_driver_ctl(RARCH_AUDIO_CTL_SET_CALLBACK_ENABLE, NULL); + audio_driver_enable_callback(); thr->is_paused = false; audio_thread_unblock(thr); diff --git a/driver.c b/driver.c index 4b7133b3d0..fc0c9ac4ea 100644 --- a/driver.c +++ b/driver.c @@ -464,7 +464,7 @@ bool driver_ctl(enum driver_ctl_state state, void *data) return driver_ctl(RARCH_DRIVER_CTL_INIT, &flags); } case RARCH_DRIVER_CTL_INIT_PRE: - audio_driver_ctl(RARCH_AUDIO_CTL_FIND_DRIVER, NULL); + audio_driver_find_driver(); video_driver_find_driver(); input_driver_ctl(RARCH_INPUT_CTL_FIND_DRIVER, NULL); camera_driver_ctl(RARCH_CAMERA_CTL_FIND_DRIVER, NULL); From 8b714d2932af78f3e3adcbfbf4c84a1930057e8c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 16:54:15 +0200 Subject: [PATCH 274/498] (audio driver) Refactor --- audio/audio_driver.c | 20 +++++++++++--------- audio/audio_driver.h | 5 +++-- driver.c | 2 +- 3 files changed, 15 insertions(+), 12 deletions(-) diff --git a/audio/audio_driver.c b/audio/audio_driver.c index ebdc6465b7..54ba10e362 100644 --- a/audio/audio_driver.c +++ b/audio/audio_driver.c @@ -891,6 +891,17 @@ bool audio_driver_disable_callback(void) return true; } +/* Sets audio monitor rate to new value. */ +void audio_driver_monitor_set_rate(void) +{ + settings_t *settings = config_get_ptr(); + double new_src_ratio = (double)settings->audio.out_rate / + audio_driver_data.audio_rate.input; + + audio_driver_data.audio_rate.source_ratio.original = new_src_ratio; + audio_driver_data.audio_rate.source_ratio.current = new_src_ratio; +} + bool audio_driver_ctl(enum rarch_audio_ctl_state state, void *data) { settings_t *settings = config_get_ptr(); @@ -921,15 +932,6 @@ bool audio_driver_ctl(enum rarch_audio_ctl_state state, void *data) case RARCH_AUDIO_CTL_MONITOR_ADJUST_SYSTEM_RATES: audio_monitor_adjust_system_rates(); break; - case RARCH_AUDIO_CTL_MONITOR_SET_REFRESH_RATE: - { - double new_src_ratio = (double)settings->audio.out_rate / - audio_driver_data.audio_rate.input; - - audio_driver_data.audio_rate.source_ratio.original = new_src_ratio; - audio_driver_data.audio_rate.source_ratio.current = new_src_ratio; - } - break; case RARCH_AUDIO_CTL_MUTE_TOGGLE: if (!audio_driver_context_audio_data) return false; diff --git a/audio/audio_driver.h b/audio/audio_driver.h index c2b6c33a94..1e9989f8e6 100644 --- a/audio/audio_driver.h +++ b/audio/audio_driver.h @@ -45,8 +45,6 @@ enum rarch_audio_ctl_state RARCH_AUDIO_CTL_DESTROY_DATA, RARCH_AUDIO_CTL_START, RARCH_AUDIO_CTL_STOP, - /* Sets audio monitor refresh rate to new value. */ - RARCH_AUDIO_CTL_MONITOR_SET_REFRESH_RATE, RARCH_AUDIO_CTL_MONITOR_ADJUST_SYSTEM_RATES, RARCH_AUDIO_CTL_MUTE_TOGGLE, RARCH_AUDIO_CTL_UNSET_CALLBACK, @@ -181,6 +179,9 @@ void audio_driver_setup_rewind(void); bool audio_driver_set_callback(const void *data); +/* Sets audio monitor rate to new value. */ +void audio_driver_monitor_set_rate(void); + bool audio_driver_find_driver(void); bool audio_driver_deinit(void); diff --git a/driver.c b/driver.c index fc0c9ac4ea..5cda09a53e 100644 --- a/driver.c +++ b/driver.c @@ -477,7 +477,7 @@ bool driver_ctl(enum driver_ctl_state state, void *data) { float *hz = (float*)data; video_monitor_set_refresh_rate(*hz); - audio_driver_ctl(RARCH_AUDIO_CTL_MONITOR_SET_REFRESH_RATE, NULL); + audio_driver_monitor_set_rate(); driver_adjust_system_rates(); } break; From 8125579b7c4ebd145f7f2504bc537d613ed6ebc2 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 17:03:51 +0200 Subject: [PATCH 275/498] (audio driver) Refactors --- audio/audio_driver.c | 29 ++++++++++++++++++----------- audio/audio_driver.h | 6 ++++-- audio/audio_thread_wrapper.c | 2 +- rewind.c | 2 +- 4 files changed, 24 insertions(+), 15 deletions(-) diff --git a/audio/audio_driver.c b/audio/audio_driver.c index 54ba10e362..d18fdf5c30 100644 --- a/audio/audio_driver.c +++ b/audio/audio_driver.c @@ -874,7 +874,7 @@ bool audio_driver_set_callback(const void *data) bool audio_driver_enable_callback(void) { - if (!audio_driver_ctl(RARCH_AUDIO_CTL_HAS_CALLBACK, NULL)) + if (!audio_driver_has_callback()) return false; if (audio_callback.set_state) audio_callback.set_state(true); @@ -883,7 +883,7 @@ bool audio_driver_enable_callback(void) bool audio_driver_disable_callback(void) { - if (!audio_driver_ctl(RARCH_AUDIO_CTL_HAS_CALLBACK, NULL)) + if (!audio_driver_has_callback()) return false; if (audio_callback.set_state) @@ -902,6 +902,22 @@ void audio_driver_monitor_set_rate(void) audio_driver_data.audio_rate.source_ratio.current = new_src_ratio; } +bool audio_driver_callback(void) +{ + if (!audio_driver_has_callback()) + return false; + + if (audio_callback.callback) + audio_callback.callback(); + + return true; +} + +bool audio_driver_has_callback(void) +{ + return audio_callback.callback; +} + bool audio_driver_ctl(enum rarch_audio_ctl_state state, void *data) { settings_t *settings = config_get_ptr(); @@ -916,15 +932,6 @@ bool audio_driver_ctl(enum rarch_audio_ctl_state state, void *data) case RARCH_AUDIO_CTL_DESTROY_DATA: audio_driver_context_audio_data = NULL; break; - case RARCH_AUDIO_CTL_HAS_CALLBACK: - return audio_callback.callback; - case RARCH_AUDIO_CTL_CALLBACK: - if (!audio_driver_ctl(RARCH_AUDIO_CTL_HAS_CALLBACK, NULL)) - return false; - - if (audio_callback.callback) - audio_callback.callback(); - break; case RARCH_AUDIO_CTL_UNSET_CALLBACK: audio_callback.callback = NULL; audio_callback.set_state = NULL; diff --git a/audio/audio_driver.h b/audio/audio_driver.h index 1e9989f8e6..dc2b6ca5cc 100644 --- a/audio/audio_driver.h +++ b/audio/audio_driver.h @@ -48,8 +48,6 @@ enum rarch_audio_ctl_state RARCH_AUDIO_CTL_MONITOR_ADJUST_SYSTEM_RATES, RARCH_AUDIO_CTL_MUTE_TOGGLE, RARCH_AUDIO_CTL_UNSET_CALLBACK, - RARCH_AUDIO_CTL_CALLBACK, - RARCH_AUDIO_CTL_HAS_CALLBACK, RARCH_AUDIO_CTL_ALIVE, RARCH_AUDIO_CTL_FRAME_IS_REVERSE, RARCH_AUDIO_CTL_SET_OWN_DRIVER, @@ -179,6 +177,10 @@ void audio_driver_setup_rewind(void); bool audio_driver_set_callback(const void *data); +bool audio_driver_callback(void); + +bool audio_driver_has_callback(void); + /* Sets audio monitor rate to new value. */ void audio_driver_monitor_set_rate(void); diff --git a/audio/audio_thread_wrapper.c b/audio/audio_thread_wrapper.c index f2d5f297ef..522fbdff85 100644 --- a/audio/audio_thread_wrapper.c +++ b/audio/audio_thread_wrapper.c @@ -102,7 +102,7 @@ static void audio_thread_loop(void *data) } slock_unlock(thr->lock); - audio_driver_ctl(RARCH_AUDIO_CTL_CALLBACK, NULL); + audio_driver_callback(); } RARCH_LOG("[Audio Thread]: Tearing down driver.\n"); diff --git a/rewind.c b/rewind.c index 9ee215ba67..f049c228ea 100644 --- a/rewind.c +++ b/rewind.c @@ -631,7 +631,7 @@ void init_rewind(void) if (!settings->rewind_enable || rewind_state.state) return; - if (audio_driver_ctl(RARCH_AUDIO_CTL_HAS_CALLBACK, NULL)) + if (audio_driver_has_callback()) { RARCH_ERR("%s.\n", msg_hash_to_str(MSG_REWIND_INIT_FAILED)); return; From b1f6a7e0a11eaf332cf7417e73123534d869334e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 17:25:31 +0200 Subject: [PATCH 276/498] Rename another function --- audio/audio_driver.c | 6 +----- audio/audio_driver.h | 3 ++- driver.c | 2 +- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/audio/audio_driver.c b/audio/audio_driver.c index d18fdf5c30..9a87f59c27 100644 --- a/audio/audio_driver.c +++ b/audio/audio_driver.c @@ -705,8 +705,7 @@ void audio_driver_set_buffer_size(size_t bufsize) audio_driver_data.driver_buffer_size = bufsize; } - -static void audio_monitor_adjust_system_rates(void) +void audio_driver_adjust_system_rates(void) { float timing_skew; settings_t *settings = config_get_ptr(); @@ -936,9 +935,6 @@ bool audio_driver_ctl(enum rarch_audio_ctl_state state, void *data) audio_callback.callback = NULL; audio_callback.set_state = NULL; break; - case RARCH_AUDIO_CTL_MONITOR_ADJUST_SYSTEM_RATES: - audio_monitor_adjust_system_rates(); - break; case RARCH_AUDIO_CTL_MUTE_TOGGLE: if (!audio_driver_context_audio_data) return false; diff --git a/audio/audio_driver.h b/audio/audio_driver.h index dc2b6ca5cc..0a92de2173 100644 --- a/audio/audio_driver.h +++ b/audio/audio_driver.h @@ -45,7 +45,6 @@ enum rarch_audio_ctl_state RARCH_AUDIO_CTL_DESTROY_DATA, RARCH_AUDIO_CTL_START, RARCH_AUDIO_CTL_STOP, - RARCH_AUDIO_CTL_MONITOR_ADJUST_SYSTEM_RATES, RARCH_AUDIO_CTL_MUTE_TOGGLE, RARCH_AUDIO_CTL_UNSET_CALLBACK, RARCH_AUDIO_CTL_ALIVE, @@ -175,6 +174,8 @@ bool audio_driver_get_devices_list(void **ptr); void audio_driver_setup_rewind(void); +void audio_driver_adjust_system_rates(void); + bool audio_driver_set_callback(const void *data); bool audio_driver_callback(void); diff --git a/driver.c b/driver.c index 5cda09a53e..322c88f14c 100644 --- a/driver.c +++ b/driver.c @@ -200,7 +200,7 @@ bool driver_find_next(const char *label, char *s, size_t len) static void driver_adjust_system_rates(void) { - audio_driver_ctl(RARCH_AUDIO_CTL_MONITOR_ADJUST_SYSTEM_RATES, NULL); + audio_driver_adjust_system_rates(); video_driver_monitor_adjust_system_rates(); if (!video_driver_get_ptr(false)) From ca79faa4eda649e339ea5ffeaa85db4d2f0927e7 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 17:26:17 +0200 Subject: [PATCH 277/498] Rename for consistency --- audio/audio_driver.c | 2 +- audio/audio_driver.h | 2 +- driver.c | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/audio/audio_driver.c b/audio/audio_driver.c index 9a87f59c27..aaab9e1dec 100644 --- a/audio/audio_driver.c +++ b/audio/audio_driver.c @@ -705,7 +705,7 @@ void audio_driver_set_buffer_size(size_t bufsize) audio_driver_data.driver_buffer_size = bufsize; } -void audio_driver_adjust_system_rates(void) +void audio_driver_monitor_adjust_system_rates(void) { float timing_skew; settings_t *settings = config_get_ptr(); diff --git a/audio/audio_driver.h b/audio/audio_driver.h index 0a92de2173..86a2197959 100644 --- a/audio/audio_driver.h +++ b/audio/audio_driver.h @@ -174,7 +174,7 @@ bool audio_driver_get_devices_list(void **ptr); void audio_driver_setup_rewind(void); -void audio_driver_adjust_system_rates(void); +void audio_driver_monitor_adjust_system_rates(void); bool audio_driver_set_callback(const void *data); diff --git a/driver.c b/driver.c index 322c88f14c..ac62477c98 100644 --- a/driver.c +++ b/driver.c @@ -200,7 +200,7 @@ bool driver_find_next(const char *label, char *s, size_t len) static void driver_adjust_system_rates(void) { - audio_driver_adjust_system_rates(); + audio_driver_monitor_adjust_system_rates(); video_driver_monitor_adjust_system_rates(); if (!video_driver_get_ptr(false)) From 518a83b2c33f91554e3df58eae677816ec8ddea2 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 17:42:20 +0200 Subject: [PATCH 278/498] Create audio_driver_toggle_mute --- audio/audio_driver.c | 36 ++++++++++++++++++++---------------- audio/audio_driver.h | 3 ++- command_event.c | 2 +- 3 files changed, 23 insertions(+), 18 deletions(-) diff --git a/audio/audio_driver.c b/audio/audio_driver.c index aaab9e1dec..4ca9274596 100644 --- a/audio/audio_driver.c +++ b/audio/audio_driver.c @@ -917,6 +917,26 @@ bool audio_driver_has_callback(void) return audio_callback.callback; } +bool audio_driver_toggle_mute(void) +{ + settings_t *settings = config_get_ptr(); + if (!audio_driver_context_audio_data) + return false; + if (!audio_driver_ctl(RARCH_AUDIO_CTL_IS_ACTIVE, NULL)) + return false; + + settings->audio.mute_enable = !settings->audio.mute_enable; + + if (settings->audio.mute_enable) + event_cmd_ctl(EVENT_CMD_AUDIO_STOP, NULL); + else if (!event_cmd_ctl(EVENT_CMD_AUDIO_START, NULL)) + { + audio_driver_ctl(RARCH_AUDIO_CTL_UNSET_ACTIVE, NULL); + return false; + } + return true; +} + bool audio_driver_ctl(enum rarch_audio_ctl_state state, void *data) { settings_t *settings = config_get_ptr(); @@ -935,22 +955,6 @@ bool audio_driver_ctl(enum rarch_audio_ctl_state state, void *data) audio_callback.callback = NULL; audio_callback.set_state = NULL; break; - case RARCH_AUDIO_CTL_MUTE_TOGGLE: - if (!audio_driver_context_audio_data) - return false; - if (!audio_driver_ctl(RARCH_AUDIO_CTL_IS_ACTIVE, NULL)) - return false; - - settings->audio.mute_enable = !settings->audio.mute_enable; - - if (settings->audio.mute_enable) - event_cmd_ctl(EVENT_CMD_AUDIO_STOP, NULL); - else if (!event_cmd_ctl(EVENT_CMD_AUDIO_START, NULL)) - { - audio_driver_ctl(RARCH_AUDIO_CTL_UNSET_ACTIVE, NULL); - return false; - } - break; case RARCH_AUDIO_CTL_ALIVE: if (!current_audio || !current_audio->alive || !audio_driver_context_audio_data) diff --git a/audio/audio_driver.h b/audio/audio_driver.h index 86a2197959..2a26b03dfa 100644 --- a/audio/audio_driver.h +++ b/audio/audio_driver.h @@ -45,7 +45,6 @@ enum rarch_audio_ctl_state RARCH_AUDIO_CTL_DESTROY_DATA, RARCH_AUDIO_CTL_START, RARCH_AUDIO_CTL_STOP, - RARCH_AUDIO_CTL_MUTE_TOGGLE, RARCH_AUDIO_CTL_UNSET_CALLBACK, RARCH_AUDIO_CTL_ALIVE, RARCH_AUDIO_CTL_FRAME_IS_REVERSE, @@ -187,6 +186,8 @@ void audio_driver_monitor_set_rate(void); bool audio_driver_find_driver(void); +bool audio_driver_toggle_mute(void); + bool audio_driver_deinit(void); bool audio_driver_init(void); diff --git a/command_event.c b/command_event.c index b91f71b738..a454ba701e 100644 --- a/command_event.c +++ b/command_event.c @@ -1235,7 +1235,7 @@ bool event_cmd_ctl(enum event_command cmd, void *data) msg_hash_to_str(MSG_AUDIO_MUTED): msg_hash_to_str(MSG_AUDIO_UNMUTED); - if (!audio_driver_ctl(RARCH_AUDIO_CTL_MUTE_TOGGLE, NULL)) + if (!audio_driver_toggle_mute()) { RARCH_ERR("%s.\n", msg_hash_to_str(MSG_FAILED_TO_UNMUTE_AUDIO)); From 7e1a06d8dde6d0129a8a922a1838981e173366af Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 17:54:30 +0200 Subject: [PATCH 279/498] Remove some warnings --- audio/audio_driver.c | 2 -- audio/audio_driver.h | 1 - driver.c | 2 +- gfx/drivers_font/gl_raster_font.c | 6 +++--- 4 files changed, 4 insertions(+), 7 deletions(-) diff --git a/audio/audio_driver.c b/audio/audio_driver.c index 4ca9274596..d192730478 100644 --- a/audio/audio_driver.c +++ b/audio/audio_driver.c @@ -939,8 +939,6 @@ bool audio_driver_toggle_mute(void) bool audio_driver_ctl(enum rarch_audio_ctl_state state, void *data) { - settings_t *settings = config_get_ptr(); - switch (state) { case RARCH_AUDIO_CTL_DESTROY: diff --git a/audio/audio_driver.h b/audio/audio_driver.h index 2a26b03dfa..e241b645f0 100644 --- a/audio/audio_driver.h +++ b/audio/audio_driver.h @@ -40,7 +40,6 @@ extern "C" { enum rarch_audio_ctl_state { RARCH_AUDIO_CTL_NONE = 0, - RARCH_AUDIO_CTL_DEINIT, RARCH_AUDIO_CTL_DESTROY, RARCH_AUDIO_CTL_DESTROY_DATA, RARCH_AUDIO_CTL_START, diff --git a/driver.c b/driver.c index ac62477c98..ae9967d0b6 100644 --- a/driver.c +++ b/driver.c @@ -407,7 +407,7 @@ static void uninit_drivers(int flags) camera_driver_ctl(RARCH_CAMERA_CTL_DEINIT, NULL); if (flags & DRIVER_AUDIO) - audio_driver_ctl(RARCH_AUDIO_CTL_DEINIT, NULL); + audio_driver_deinit(); if (flags & DRIVERS_VIDEO_INPUT) video_driver_deinit(); diff --git a/gfx/drivers_font/gl_raster_font.c b/gfx/drivers_font/gl_raster_font.c index 0a30b0e6fb..ba730f413c 100644 --- a/gfx/drivers_font/gl_raster_font.c +++ b/gfx/drivers_font/gl_raster_font.c @@ -58,10 +58,10 @@ static bool gl_raster_font_upload_atlas(gl_raster_t *font, GLenum gl_format = GL_LUMINANCE_ALPHA; size_t ncomponents = 2; uint8_t *tmp = NULL; - struct retro_hw_render_callback *hwr = NULL; bool ancient = false; /* add a check here if needed */ - - hwr = video_driver_get_hw_context(); +#if defined(GL_VERSION_3_0) + struct retro_hw_render_callback *hwr = video_driver_get_hw_context(); +#endif if (ancient) { From 93d16aaba37b6a1c2fdfaf2be9455a9ba7d64d17 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 18:00:32 +0200 Subject: [PATCH 280/498] (audio driver) refactor functions --- audio/audio_driver.c | 28 +++++++++++++++++----------- audio/audio_driver.h | 6 ++++-- command_event.c | 5 ++--- core_impl.c | 2 +- 4 files changed, 24 insertions(+), 17 deletions(-) diff --git a/audio/audio_driver.c b/audio/audio_driver.c index d192730478..3391a8d304 100644 --- a/audio/audio_driver.c +++ b/audio/audio_driver.c @@ -448,7 +448,7 @@ static bool audio_driver_init_internal(bool audio_cb_inited) && !settings->audio.mute_enable && audio_cb_inited ) - audio_driver_ctl(RARCH_AUDIO_CTL_START, NULL); + audio_driver_start(); return true; @@ -937,6 +937,22 @@ bool audio_driver_toggle_mute(void) return true; } +bool audio_driver_start(void) +{ + if (!current_audio || !current_audio->start + || !audio_driver_context_audio_data) + return false; + return current_audio->start(audio_driver_context_audio_data); +} + +bool audio_driver_stop(void) +{ + if (!current_audio || !current_audio->stop + || !audio_driver_context_audio_data) + return false; + return current_audio->stop(audio_driver_context_audio_data); +} + bool audio_driver_ctl(enum rarch_audio_ctl_state state, void *data) { switch (state) @@ -958,16 +974,6 @@ bool audio_driver_ctl(enum rarch_audio_ctl_state state, void *data) || !audio_driver_context_audio_data) return false; return current_audio->alive(audio_driver_context_audio_data); - case RARCH_AUDIO_CTL_START: - if (!current_audio || !current_audio->start - || !audio_driver_context_audio_data) - return false; - return current_audio->start(audio_driver_context_audio_data); - case RARCH_AUDIO_CTL_STOP: - if (!current_audio || !current_audio->stop - || !audio_driver_context_audio_data) - return false; - return current_audio->stop(audio_driver_context_audio_data); case RARCH_AUDIO_CTL_SET_OWN_DRIVER: audio_driver_data_own = true; break; diff --git a/audio/audio_driver.h b/audio/audio_driver.h index e241b645f0..e3eeafc08e 100644 --- a/audio/audio_driver.h +++ b/audio/audio_driver.h @@ -42,8 +42,6 @@ enum rarch_audio_ctl_state RARCH_AUDIO_CTL_NONE = 0, RARCH_AUDIO_CTL_DESTROY, RARCH_AUDIO_CTL_DESTROY_DATA, - RARCH_AUDIO_CTL_START, - RARCH_AUDIO_CTL_STOP, RARCH_AUDIO_CTL_UNSET_CALLBACK, RARCH_AUDIO_CTL_ALIVE, RARCH_AUDIO_CTL_FRAME_IS_REVERSE, @@ -187,6 +185,10 @@ bool audio_driver_find_driver(void); bool audio_driver_toggle_mute(void); +bool audio_driver_start(void); + +bool audio_driver_stop(void); + bool audio_driver_deinit(void); bool audio_driver_init(void); diff --git a/command_event.c b/command_event.c index a454ba701e..a5065dc23a 100644 --- a/command_event.c +++ b/command_event.c @@ -1214,15 +1214,14 @@ bool event_cmd_ctl(enum event_command cmd, void *data) if (!audio_driver_ctl(RARCH_AUDIO_CTL_ALIVE, NULL)) return false; - if (!audio_driver_ctl(RARCH_AUDIO_CTL_STOP, NULL)) + if (!audio_driver_stop()) return false; break; case EVENT_CMD_AUDIO_START: if (audio_driver_ctl(RARCH_AUDIO_CTL_ALIVE, NULL)) return false; - if (!settings->audio.mute_enable && - !audio_driver_ctl(RARCH_AUDIO_CTL_START, NULL)) + if (!settings->audio.mute_enable && !audio_driver_start()) { RARCH_ERR("Failed to start audio driver. " "Will continue without audio.\n"); diff --git a/core_impl.c b/core_impl.c index fe3745758c..0f6671cac4 100644 --- a/core_impl.c +++ b/core_impl.c @@ -336,7 +336,7 @@ bool core_unload(void) bool core_unload_game(void) { video_driver_deinit_hw_context(); - audio_driver_ctl(RARCH_AUDIO_CTL_STOP, NULL); + audio_driver_stop(); core.retro_unload_game(); return true; } From de71776405f5a4f376286766d90935eaee397870 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 18:03:09 +0200 Subject: [PATCH 281/498] (audio driver) Cleanups --- audio/audio_driver.c | 23 ++++++++++++++--------- audio/audio_driver.h | 6 ++++-- command_event.c | 4 ++-- runloop.c | 2 +- 4 files changed, 21 insertions(+), 14 deletions(-) diff --git a/audio/audio_driver.c b/audio/audio_driver.c index 3391a8d304..dece4cfee9 100644 --- a/audio/audio_driver.c +++ b/audio/audio_driver.c @@ -953,6 +953,20 @@ bool audio_driver_stop(void) return current_audio->stop(audio_driver_context_audio_data); } +void audio_driver_unset_callback(void) +{ + audio_callback.callback = NULL; + audio_callback.set_state = NULL; +} + +bool audio_driver_alive(void) +{ + if (!current_audio || !current_audio->alive + || !audio_driver_context_audio_data) + return false; + return current_audio->alive(audio_driver_context_audio_data); +} + bool audio_driver_ctl(enum rarch_audio_ctl_state state, void *data) { switch (state) @@ -965,15 +979,6 @@ bool audio_driver_ctl(enum rarch_audio_ctl_state state, void *data) case RARCH_AUDIO_CTL_DESTROY_DATA: audio_driver_context_audio_data = NULL; break; - case RARCH_AUDIO_CTL_UNSET_CALLBACK: - audio_callback.callback = NULL; - audio_callback.set_state = NULL; - break; - case RARCH_AUDIO_CTL_ALIVE: - if (!current_audio || !current_audio->alive - || !audio_driver_context_audio_data) - return false; - return current_audio->alive(audio_driver_context_audio_data); case RARCH_AUDIO_CTL_SET_OWN_DRIVER: audio_driver_data_own = true; break; diff --git a/audio/audio_driver.h b/audio/audio_driver.h index e3eeafc08e..fc33d95225 100644 --- a/audio/audio_driver.h +++ b/audio/audio_driver.h @@ -42,8 +42,6 @@ enum rarch_audio_ctl_state RARCH_AUDIO_CTL_NONE = 0, RARCH_AUDIO_CTL_DESTROY, RARCH_AUDIO_CTL_DESTROY_DATA, - RARCH_AUDIO_CTL_UNSET_CALLBACK, - RARCH_AUDIO_CTL_ALIVE, RARCH_AUDIO_CTL_FRAME_IS_REVERSE, RARCH_AUDIO_CTL_SET_OWN_DRIVER, RARCH_AUDIO_CTL_UNSET_OWN_DRIVER, @@ -189,6 +187,10 @@ bool audio_driver_start(void); bool audio_driver_stop(void); +void audio_driver_unset_callback(void); + +bool audio_driver_alive(void); + bool audio_driver_deinit(void); bool audio_driver_init(void); diff --git a/command_event.c b/command_event.c index a5065dc23a..6859f17908 100644 --- a/command_event.c +++ b/command_event.c @@ -1211,14 +1211,14 @@ bool event_cmd_ctl(enum event_command cmd, void *data) event_save_auto_state(); break; case EVENT_CMD_AUDIO_STOP: - if (!audio_driver_ctl(RARCH_AUDIO_CTL_ALIVE, NULL)) + if (!audio_driver_alive()) return false; if (!audio_driver_stop()) return false; break; case EVENT_CMD_AUDIO_START: - if (audio_driver_ctl(RARCH_AUDIO_CTL_ALIVE, NULL)) + if (!audio_driver_alive()) return false; if (!settings->audio.mute_enable && !audio_driver_start()) diff --git a/runloop.c b/runloop.c index 72d1f9e4ae..32ce249a2e 100644 --- a/runloop.c +++ b/runloop.c @@ -707,7 +707,7 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) runloop_key_event = NULL; runloop_frontend_key_event = NULL; - audio_driver_ctl(RARCH_AUDIO_CTL_UNSET_CALLBACK, NULL); + audio_driver_unset_callback(); memset(&runloop_system, 0, sizeof(rarch_system_info_t)); break; case RUNLOOP_CTL_SET_FRAME_TIME_LAST: From 4791c370399a7223d40c5337d12fb9d1f8d1dfb2 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 18:09:03 +0200 Subject: [PATCH 282/498] (Vita) Reimplement inet_ptrton for Vita --- libretro-common/net/net_compat.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libretro-common/net/net_compat.c b/libretro-common/net/net_compat.c index c477c5f21c..1be55808de 100644 --- a/libretro-common/net/net_compat.c +++ b/libretro-common/net/net_compat.c @@ -102,7 +102,7 @@ struct SceNetInAddr inet_aton(const char *ip_addr) { SceNetInAddr inaddr; - sceNetInetPton(AF_INET, ip_addr, &inaddr); + inet_ptrton(AF_INET, ip_addr, &inaddr); return inaddr; } @@ -329,8 +329,10 @@ uint16_t inet_htons(uint16_t hostshort) int inet_ptrton(int af, const char *src, void *dst) { +#if defined(VITA) + return sceNetInetPton(af, src, dst); +#elif defined(GEKKO) || defined(_WIN32) /* TODO/FIXME - should use InetPton on Vista and later */ -#if defined(GEKKO) || defined(_WIN32) || defined(VITA) return inet_aton(src, dst); #else return inet_pton(af, src, dst); From 807b5c63258f96f0b0536f7550f243d9f807b4bd Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 18:24:25 +0200 Subject: [PATCH 283/498] Get rid of audio_driver_ctl --- audio/audio_driver.c | 112 +++++++++++++++++++++++-------------------- audio/audio_driver.h | 31 ++++++------ command_event.c | 2 +- driver.c | 8 ++-- retroarch.c | 2 +- rewind.c | 2 +- 6 files changed, 83 insertions(+), 74 deletions(-) diff --git a/audio/audio_driver.c b/audio/audio_driver.c index dece4cfee9..6c91324ea6 100644 --- a/audio/audio_driver.c +++ b/audio/audio_driver.c @@ -283,7 +283,7 @@ static bool uninit_audio(void) if (!settings->audio.enable) { - audio_driver_ctl(RARCH_AUDIO_CTL_UNSET_ACTIVE, NULL); + audio_driver_unset_active(); return false; } @@ -338,7 +338,7 @@ static bool audio_driver_init_internal(bool audio_cb_inited) if (!settings->audio.enable) { - audio_driver_ctl(RARCH_AUDIO_CTL_UNSET_ACTIVE, NULL); + audio_driver_unset_active(); return false; } @@ -370,15 +370,15 @@ static bool audio_driver_init_internal(bool audio_cb_inited) if (!audio_driver_context_audio_data) { RARCH_ERR("Failed to initialize audio driver. Will continue without audio.\n"); - audio_driver_ctl(RARCH_AUDIO_CTL_UNSET_ACTIVE, NULL); + audio_driver_unset_active(); } audio_driver_data.use_float = false; - if ( audio_driver_ctl(RARCH_AUDIO_CTL_IS_ACTIVE, NULL) + if ( audio_driver_is_active() && current_audio->use_float(audio_driver_context_audio_data)) audio_driver_data.use_float = true; - if (!settings->audio.sync && audio_driver_ctl(RARCH_AUDIO_CTL_IS_ACTIVE, NULL)) + if (!settings->audio.sync && audio_driver_is_active()) { event_cmd_ctl(EVENT_CMD_AUDIO_SET_NONBLOCKING_STATE, NULL); audio_driver_data.chunk.size = audio_driver_data.chunk.nonblock_size; @@ -400,7 +400,7 @@ static bool audio_driver_init_internal(bool audio_cb_inited) { RARCH_ERR("Failed to initialize resampler \"%s\".\n", settings->audio.resampler); - audio_driver_ctl(RARCH_AUDIO_CTL_UNSET_ACTIVE, NULL); + audio_driver_unset_active(); } retro_assert(audio_driver_data.data = (float*) @@ -422,7 +422,7 @@ static bool audio_driver_init_internal(bool audio_cb_inited) audio_driver_data.audio_rate.control = false; if ( !audio_cb_inited - && audio_driver_ctl(RARCH_AUDIO_CTL_IS_ACTIVE, NULL) + && audio_driver_is_active() && settings->audio.rate_control ) { @@ -444,7 +444,7 @@ static bool audio_driver_init_internal(bool audio_cb_inited) /* Threaded driver is initially stopped. */ if ( - audio_driver_ctl(RARCH_AUDIO_CTL_IS_ACTIVE, NULL) + audio_driver_is_active() && !settings->audio.mute_enable && audio_cb_inited ) @@ -493,7 +493,7 @@ void audio_driver_set_nonblocking_state(bool enable) { settings_t *settings = config_get_ptr(); if ( - audio_driver_ctl(RARCH_AUDIO_CTL_IS_ACTIVE, NULL) + audio_driver_is_active() && audio_driver_context_audio_data ) current_audio->set_nonblock_state(audio_driver_context_audio_data, @@ -531,7 +531,7 @@ static bool audio_driver_flush(const int16_t *data, size_t samples) if (runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL) || settings->audio.mute_enable) return true; - if (!audio_driver_ctl(RARCH_AUDIO_CTL_IS_ACTIVE, NULL)) + if (!audio_driver_is_active()) return false; if (!audio_driver_data.data) return false; @@ -592,7 +592,7 @@ static bool audio_driver_flush(const int16_t *data, size_t samples) if (current_audio->write(audio_driver_context_audio_data, output_data, output_frames * output_size * 2) < 0) { - audio_driver_ctl(RARCH_AUDIO_CTL_UNSET_ACTIVE, NULL); + audio_driver_unset_active(); return false; } @@ -922,7 +922,7 @@ bool audio_driver_toggle_mute(void) settings_t *settings = config_get_ptr(); if (!audio_driver_context_audio_data) return false; - if (!audio_driver_ctl(RARCH_AUDIO_CTL_IS_ACTIVE, NULL)) + if (!audio_driver_is_active()) return false; settings->audio.mute_enable = !settings->audio.mute_enable; @@ -931,7 +931,7 @@ bool audio_driver_toggle_mute(void) event_cmd_ctl(EVENT_CMD_AUDIO_STOP, NULL); else if (!event_cmd_ctl(EVENT_CMD_AUDIO_START, NULL)) { - audio_driver_ctl(RARCH_AUDIO_CTL_UNSET_ACTIVE, NULL); + audio_driver_unset_active(); return false; } return true; @@ -967,44 +967,52 @@ bool audio_driver_alive(void) return current_audio->alive(audio_driver_context_audio_data); } -bool audio_driver_ctl(enum rarch_audio_ctl_state state, void *data) +void audio_driver_frame_is_reverse(void) { - switch (state) - { - case RARCH_AUDIO_CTL_DESTROY: - audio_driver_active = false; - audio_driver_data_own = false; - current_audio = NULL; - break; - case RARCH_AUDIO_CTL_DESTROY_DATA: - audio_driver_context_audio_data = NULL; - break; - case RARCH_AUDIO_CTL_SET_OWN_DRIVER: - audio_driver_data_own = true; - break; - case RARCH_AUDIO_CTL_UNSET_OWN_DRIVER: - audio_driver_data_own = false; - break; - case RARCH_AUDIO_CTL_OWNS_DRIVER: - return audio_driver_data_own; - case RARCH_AUDIO_CTL_SET_ACTIVE: - audio_driver_active = true; - break; - case RARCH_AUDIO_CTL_UNSET_ACTIVE: - audio_driver_active = false; - break; - case RARCH_AUDIO_CTL_IS_ACTIVE: - return audio_driver_active; - case RARCH_AUDIO_CTL_FRAME_IS_REVERSE: - /* We just rewound. Flush rewind audio buffer. */ - audio_driver_flush( - audio_driver_data.rewind.buf + audio_driver_data.rewind.ptr, - audio_driver_data.rewind.size - audio_driver_data.rewind.ptr); - break; - case RARCH_AUDIO_CTL_NONE: - default: - break; - } - - return true; + /* We just rewound. Flush rewind audio buffer. */ + audio_driver_flush( + audio_driver_data.rewind.buf + audio_driver_data.rewind.ptr, + audio_driver_data.rewind.size - audio_driver_data.rewind.ptr); +} + +void audio_driver_destroy_data(void) +{ + audio_driver_context_audio_data = NULL; +} + +void audio_driver_set_own_driver(void) +{ + audio_driver_data_own = true; +} + +void audio_driver_unset_own_driver(void) +{ + audio_driver_data_own = false; +} + +bool audio_driver_owns_driver(void) +{ + return audio_driver_data_own; +} + +void audio_driver_set_active(void) +{ + audio_driver_active = true; +} + +void audio_driver_unset_active(void) +{ + audio_driver_active = false; +} + +bool audio_driver_is_active(void) +{ + return audio_driver_active; +} + +void audio_driver_destroy(void) +{ + audio_driver_active = false; + audio_driver_data_own = false; + current_audio = NULL; } diff --git a/audio/audio_driver.h b/audio/audio_driver.h index fc33d95225..0e8fa372bc 100644 --- a/audio/audio_driver.h +++ b/audio/audio_driver.h @@ -37,20 +37,6 @@ extern "C" { #define AUDIO_MAX_RATIO 16 -enum rarch_audio_ctl_state -{ - RARCH_AUDIO_CTL_NONE = 0, - RARCH_AUDIO_CTL_DESTROY, - RARCH_AUDIO_CTL_DESTROY_DATA, - RARCH_AUDIO_CTL_FRAME_IS_REVERSE, - RARCH_AUDIO_CTL_SET_OWN_DRIVER, - RARCH_AUDIO_CTL_UNSET_OWN_DRIVER, - RARCH_AUDIO_CTL_OWNS_DRIVER, - RARCH_AUDIO_CTL_SET_ACTIVE, - RARCH_AUDIO_CTL_UNSET_ACTIVE, - RARCH_AUDIO_CTL_IS_ACTIVE -}; - typedef struct audio_driver { /* Creates and initializes handle to audio driver. @@ -102,8 +88,19 @@ typedef struct audio_driver size_t (*buffer_size)(void *data); } audio_driver_t; +void audio_driver_destroy_data(void); -bool audio_driver_ctl(enum rarch_audio_ctl_state state, void *data); +void audio_driver_set_own_driver(void); + +void audio_driver_unset_own_driver(void); + +void audio_driver_set_active(void); + +void audio_driver_unset_active(void); + +bool audio_driver_is_active(void); + +void audio_driver_destroy(void); void audio_driver_deinit_resampler(void); @@ -187,8 +184,12 @@ bool audio_driver_start(void); bool audio_driver_stop(void); +bool audio_driver_owns_driver(void); + void audio_driver_unset_callback(void); +void audio_driver_frame_is_reverse(void); + bool audio_driver_alive(void); bool audio_driver_deinit(void); diff --git a/command_event.c b/command_event.c index 6859f17908..eed8c4fdf8 100644 --- a/command_event.c +++ b/command_event.c @@ -1225,7 +1225,7 @@ bool event_cmd_ctl(enum event_command cmd, void *data) { RARCH_ERR("Failed to start audio driver. " "Will continue without audio.\n"); - audio_driver_ctl(RARCH_AUDIO_CTL_UNSET_ACTIVE, NULL); + audio_driver_unset_active(); } break; case EVENT_CMD_AUDIO_MUTE_TOGGLE: diff --git a/driver.c b/driver.c index ae9967d0b6..3da72edf97 100644 --- a/driver.c +++ b/driver.c @@ -304,7 +304,7 @@ static void init_drivers(int flags) if (flags & DRIVER_VIDEO) video_driver_unset_own_driver(); if (flags & DRIVER_AUDIO) - audio_driver_ctl(RARCH_AUDIO_CTL_UNSET_OWN_DRIVER, NULL); + audio_driver_unset_own_driver(); if (flags & DRIVER_INPUT) input_driver_ctl(RARCH_INPUT_CTL_UNSET_OWN_DRIVER, NULL); if (flags & DRIVER_CAMERA) @@ -418,8 +418,8 @@ static void uninit_drivers(int flags) if ((flags & DRIVER_INPUT) && !input_driver_ctl(RARCH_INPUT_CTL_OWNS_DRIVER, NULL)) input_driver_ctl(RARCH_INPUT_CTL_DESTROY_DATA, NULL); - if ((flags & DRIVER_AUDIO) && !audio_driver_ctl(RARCH_AUDIO_CTL_OWNS_DRIVER, NULL)) - audio_driver_ctl(RARCH_AUDIO_CTL_DESTROY_DATA, NULL); + if ((flags & DRIVER_AUDIO) && !audio_driver_owns_driver()) + audio_driver_destroy_data(); } bool driver_ctl(enum driver_ctl_state state, void *data) @@ -428,7 +428,7 @@ bool driver_ctl(enum driver_ctl_state state, void *data) { case RARCH_DRIVER_CTL_DEINIT: video_driver_destroy(); - audio_driver_ctl(RARCH_AUDIO_CTL_DESTROY, NULL); + audio_driver_destroy(); input_driver_ctl(RARCH_INPUT_CTL_DESTROY, NULL); #ifdef HAVE_MENU menu_driver_ctl(RARCH_MENU_CTL_DESTROY, NULL); diff --git a/retroarch.c b/retroarch.c index f5147d910d..824243fee8 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1158,7 +1158,7 @@ static void rarch_init_savefile_paths(void) static bool init_state(void) { video_driver_set_active(); - audio_driver_ctl(RARCH_AUDIO_CTL_SET_ACTIVE, NULL); + audio_driver_set_active(); rarch_ctl(RARCH_CTL_UNSET_FORCE_FULLSCREEN, NULL); diff --git a/rewind.c b/rewind.c index f049c228ea..e0b2a05e87 100644 --- a/rewind.c +++ b/rewind.c @@ -700,7 +700,7 @@ void state_manager_check_rewind(bool pressed) if (state_manager_frame_is_reversed()) { - audio_driver_ctl(RARCH_AUDIO_CTL_FRAME_IS_REVERSE, NULL); + audio_driver_frame_is_reverse(); state_manager_set_frame_is_reversed(false); } From 50a3cc3cf7b719d0100fe08b23d653a1fe814ea3 Mon Sep 17 00:00:00 2001 From: Torsten Paul Date: Sun, 8 May 2016 18:48:14 +0200 Subject: [PATCH 284/498] Ensure video_driver_frame_count is reset when the driver is (re-)initialized. --- gfx/video_driver.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gfx/video_driver.c b/gfx/video_driver.c index f8ca8f9abe..0040216cb7 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -426,9 +426,6 @@ static void init_video_input(const input_driver_t *tmp) if (*input) return; - /* Reset video frame count */ - video_driver_frame_count = 0; - /* Video driver didn't provide an input driver, * so we use configured one. */ RARCH_LOG("Graphics driver did not initialize an input driver. Attempting to pick a suitable driver.\n"); @@ -689,6 +686,9 @@ static bool init_video(void) video_driver_state.filter.out_rgb32 : (video_driver_state.pix_fmt == RETRO_PIXEL_FORMAT_XRGB8888); + /* Reset video frame count */ + video_driver_frame_count = 0; + tmp = input_get_ptr(); /* Need to grab the "real" video driver interface on a reinit. */ video_driver_find_driver(); From 510c8047817e6efdcc792c61d90ba6896297c6e1 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 19:12:01 +0200 Subject: [PATCH 285/498] (Win32) Provide inet_aton implementation --- libretro-common/net/net_compat.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/libretro-common/net/net_compat.c b/libretro-common/net/net_compat.c index 1be55808de..452fb04dcc 100644 --- a/libretro-common/net/net_compat.c +++ b/libretro-common/net/net_compat.c @@ -140,7 +140,19 @@ struct hostent *gethostbyname(const char *name) } int retro_epoll_fd; +#elif defined(_WIN32) +int inet_aton(const char *cp, struct in_addr *inp) +{ + uint32_t addr = 0; + if (cp == 0 || inp == 0) + return -1; + addr = inet_addr(cp); + if (addr == INADDR_NONE || addr == INADDR_ANY) + return -1; + + inp->s_addr = addr; +} #endif int getaddrinfo_retro(const char *node, const char *service, @@ -333,7 +345,7 @@ int inet_ptrton(int af, const char *src, void *dst) return sceNetInetPton(af, src, dst); #elif defined(GEKKO) || defined(_WIN32) /* TODO/FIXME - should use InetPton on Vista and later */ - return inet_aton(src, dst); + return inet_aton(src, (struct in_addr*)dst); #else return inet_pton(af, src, dst); #endif From bc74e7199bda369ab3d262a33b16baca39927bab Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 19:18:17 +0200 Subject: [PATCH 286/498] Move variables outside of gfx_ctx_ctl --- gfx/video_context_driver.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gfx/video_context_driver.c b/gfx/video_context_driver.c index b009d8dea5..7a1ba6b3e4 100644 --- a/gfx/video_context_driver.c +++ b/gfx/video_context_driver.c @@ -85,6 +85,8 @@ static const gfx_ctx_driver_t *gfx_ctx_drivers[] = { NULL }; +static const gfx_ctx_driver_t *current_video_context = NULL; +static void *video_context_data = NULL; /** * find_gfx_ctx_driver_index: @@ -257,8 +259,6 @@ const gfx_ctx_driver_t *gfx_ctx_init_first(void *data, bool gfx_ctx_ctl(enum gfx_ctx_ctl_state state, void *data) { - static const gfx_ctx_driver_t *current_video_context = NULL; - static void *video_context_data = NULL; switch (state) { From 1979ea52d222d6c1dc63b5556270759ff9d5e89d Mon Sep 17 00:00:00 2001 From: Torsten Paul Date: Sun, 8 May 2016 19:19:31 +0200 Subject: [PATCH 287/498] Suppress screensaver only if requested by user settings. --- gfx/common/x11_common.c | 5 ++++- gfx/common/x11_common.h | 2 +- gfx/drivers/sdl2_gfx.c | 2 +- gfx/drivers/sdl_gfx.c | 2 +- gfx/drivers/xvideo.c | 4 +++- gfx/drivers_context/x_ctx.c | 4 +++- gfx/drivers_context/xegl_ctx.c | 3 +-- 7 files changed, 14 insertions(+), 8 deletions(-) diff --git a/gfx/common/x11_common.c b/gfx/common/x11_common.c index 3759373cd4..430a1891e5 100644 --- a/gfx/common/x11_common.c +++ b/gfx/common/x11_common.c @@ -141,12 +141,15 @@ void x11_set_window_attr(Display *dpy, Window win) x11_set_window_class(dpy, win); } -void x11_suspend_screensaver(Window wnd) +void x11_suspend_screensaver(Window wnd, bool enable) { int ret; char cmd[64] = {0}; static bool screensaver_na = false; + if (!enable) + return; + if (screensaver_na) return; diff --git a/gfx/common/x11_common.h b/gfx/common/x11_common.h index ceaa40a0c9..4f27c991e4 100644 --- a/gfx/common/x11_common.h +++ b/gfx/common/x11_common.h @@ -43,7 +43,7 @@ extern unsigned g_x11_screen; void x11_save_last_used_monitor(Window win); void x11_show_mouse(Display *dpy, Window win, bool state); void x11_windowed_fullscreen(Display *dpy, Window win); -void x11_suspend_screensaver(Window win); +void x11_suspend_screensaver(Window win, bool enable); bool x11_enter_fullscreen(Display *dpy, unsigned width, unsigned height, XF86VidModeModeInfo *desktop_mode); diff --git a/gfx/drivers/sdl2_gfx.c b/gfx/drivers/sdl2_gfx.c index 1729561738..5b8dfa7dee 100644 --- a/gfx/drivers/sdl2_gfx.c +++ b/gfx/drivers/sdl2_gfx.c @@ -569,7 +569,7 @@ static bool sdl2_gfx_suppress_screensaver(void *data, bool enable) if (video_driver_display_type_get() == RARCH_DISPLAY_X11) { #ifdef HAVE_X11 - x11_suspend_screensaver(video_driver_window_get()); + x11_suspend_screensaver(video_driver_window_get(), enable); #endif return true; } diff --git a/gfx/drivers/sdl_gfx.c b/gfx/drivers/sdl_gfx.c index fe238fa8c9..50ae2b98ce 100644 --- a/gfx/drivers/sdl_gfx.c +++ b/gfx/drivers/sdl_gfx.c @@ -401,7 +401,7 @@ static bool sdl_gfx_suppress_screensaver(void *data, bool enable) #ifdef HAVE_X11 if (video_driver_display_type_get() == RARCH_DISPLAY_X11) { - x11_suspend_screensaver(video_driver_window_get()); + x11_suspend_screensaver(video_driver_window_get(), enable); return true; } #endif diff --git a/gfx/drivers/xvideo.c b/gfx/drivers/xvideo.c index b97bf52cdf..34d14e80c8 100644 --- a/gfx/drivers/xvideo.c +++ b/gfx/drivers/xvideo.c @@ -806,10 +806,12 @@ static bool xv_frame(void *data, const void *frame, unsigned width, static bool xv_suppress_screensaver(void *data, bool enable) { + (void)data; + if (video_driver_display_type_get() != RARCH_DISPLAY_X11) return false; - x11_suspend_screensaver(video_driver_window_get()); + x11_suspend_screensaver(video_driver_window_get(), enable); return true; } diff --git a/gfx/drivers_context/x_ctx.c b/gfx/drivers_context/x_ctx.c index 3abf1bda62..1e6c41101b 100644 --- a/gfx/drivers_context/x_ctx.c +++ b/gfx/drivers_context/x_ctx.c @@ -765,10 +765,12 @@ static void gfx_ctx_x_input_driver(void *data, static bool gfx_ctx_x_suppress_screensaver(void *data, bool enable) { + (void)data; + if (video_driver_display_type_get() != RARCH_DISPLAY_X11) return false; - x11_suspend_screensaver(video_driver_window_get()); + x11_suspend_screensaver(video_driver_window_get(), enable); return true; } diff --git a/gfx/drivers_context/xegl_ctx.c b/gfx/drivers_context/xegl_ctx.c index 4665258f4f..6fa1a2f33b 100644 --- a/gfx/drivers_context/xegl_ctx.c +++ b/gfx/drivers_context/xegl_ctx.c @@ -444,12 +444,11 @@ static bool gfx_ctx_xegl_has_focus(void *data) static bool gfx_ctx_xegl_suppress_screensaver(void *data, bool enable) { (void)data; - (void)enable; if (video_driver_display_type_get() != RARCH_DISPLAY_X11) return false; - x11_suspend_screensaver(video_driver_window_get()); + x11_suspend_screensaver(video_driver_window_get(), enable); return true; } From 7399ba386ad2c49b510f700e023cdf4568bc8e43 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 19:24:23 +0200 Subject: [PATCH 288/498] Rename gfx_ctx_ prefix --- gfx/d3d/d3d.cpp | 2 +- gfx/drivers/gl.c | 2 +- gfx/drivers/vg.c | 2 +- gfx/drivers/vulkan.c | 3 ++- gfx/video_context_driver.c | 37 +++++++++++++++++++------------------ gfx/video_context_driver.h | 4 ++-- 6 files changed, 26 insertions(+), 24 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 26c694f9b7..fa2b30900d 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -1100,7 +1100,7 @@ static const gfx_ctx_driver_t *d3d_get_context(void *data) unsigned major = 9; enum gfx_ctx_api api = GFX_CTX_DIRECT3D9_API; #endif - return gfx_ctx_init_first(data, + return video_driver_context_init_first(data, settings->video.context_driver, api, major, minor, false); } diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index e06ca87be0..3cb645ee03 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -2444,7 +2444,7 @@ static const gfx_ctx_driver_t *gl_get_context(gl_t *gl) gl->shared_context_use = settings->video.shared_context && hwr->context_type != RETRO_HW_CONTEXT_NONE; - return gfx_ctx_init_first(gl, settings->video.context_driver, + return video_driver_context_init_first(gl, settings->video.context_driver, api, major, minor, gl->shared_context_use); } diff --git a/gfx/drivers/vg.c b/gfx/drivers/vg.c index b401349181..0d7dfb34dc 100644 --- a/gfx/drivers/vg.c +++ b/gfx/drivers/vg.c @@ -94,7 +94,7 @@ static void *vg_init(const video_info_t *video, VGfloat clearColor[4] = {0, 0, 0, 1}; settings_t *settings = config_get_ptr(); vg_t *vg = (vg_t*)calloc(1, sizeof(vg_t)); - const gfx_ctx_driver_t *ctx = gfx_ctx_init_first( + const gfx_ctx_driver_t *ctx = video_driver_context_init_first( vg, settings->video.context_driver, GFX_CTX_OPENVG_API, 0, 0, false); diff --git a/gfx/drivers/vulkan.c b/gfx/drivers/vulkan.c index 8740a7ae50..699184eec0 100644 --- a/gfx/drivers/vulkan.c +++ b/gfx/drivers/vulkan.c @@ -70,7 +70,8 @@ static const gfx_ctx_driver_t *vulkan_get_context(vk_t *vk) settings_t *settings = config_get_ptr(); enum gfx_ctx_api api = GFX_CTX_VULKAN_API; - return gfx_ctx_init_first(vk, settings->video.context_driver, + return video_driver_context_init_first( + vk, settings->video.context_driver, api, major, minor, false); } diff --git a/gfx/video_context_driver.c b/gfx/video_context_driver.c index 7a1ba6b3e4..2a25b9aae3 100644 --- a/gfx/video_context_driver.c +++ b/gfx/video_context_driver.c @@ -89,7 +89,7 @@ static const gfx_ctx_driver_t *current_video_context = NULL; static void *video_context_data = NULL; /** - * find_gfx_ctx_driver_index: + * find_video_driver_context_driver_index: * @ident : Identifier of resampler driver to find. * * Finds graphics context driver index by @ident name. @@ -97,7 +97,7 @@ static void *video_context_data = NULL; * Returns: graphics context driver index if driver was found, otherwise * -1. **/ -static int find_gfx_ctx_driver_index(const char *ident) +static int find_video_driver_context_index(const char *ident) { unsigned i; for (i = 0; gfx_ctx_drivers[i]; i++) @@ -111,10 +111,10 @@ static int find_gfx_ctx_driver_index(const char *ident) * * Finds previous driver in graphics context driver array. **/ -static bool gfx_ctl_find_prev_driver(void) +static bool video_driver_context_find_prev_driver(void) { settings_t *settings = config_get_ptr(); - int i = find_gfx_ctx_driver_index( + int i = find_video_driver_context_index( settings->video.context_driver); if (i > 0) @@ -134,10 +134,10 @@ static bool gfx_ctl_find_prev_driver(void) * * Finds next driver in graphics context driver array. **/ -static bool gfx_ctl_find_next_driver(void) +static bool video_driver_context_find_next_driver(void) { settings_t *settings = config_get_ptr(); - int i = find_gfx_ctx_driver_index(settings->video.context_driver); + int i = find_video_driver_context_index(settings->video.context_driver); if (i >= 0 && gfx_ctx_drivers[i + 1]) { @@ -152,7 +152,7 @@ static bool gfx_ctl_find_next_driver(void) } /** - * gfx_ctx_init: + * video_driver_context_init: * @data : Input data. * @ctx : Graphics context driver to initialize. * @ident : Identifier of graphics context driver to find. @@ -166,7 +166,8 @@ static bool gfx_ctl_find_next_driver(void) * * Returns: graphics context driver if successfully initialized, otherwise NULL. **/ -static const gfx_ctx_driver_t *gfx_ctx_init(void *data, +static const gfx_ctx_driver_t *video_driver_context_init( + void *data, const gfx_ctx_driver_t *ctx, const char *ident, enum gfx_ctx_api api, unsigned major, @@ -198,7 +199,7 @@ static const gfx_ctx_driver_t *gfx_ctx_init(void *data, } /** - * gfx_ctx_find_driver: + * video_driver_context_find_driver: * @data : Input data. * @ident : Identifier of graphics context driver to find. * @api : API of higher-level graphics API. @@ -211,21 +212,21 @@ static const gfx_ctx_driver_t *gfx_ctx_init(void *data, * * Returns: graphics context driver if found, otherwise NULL. **/ -static const gfx_ctx_driver_t *gfx_ctx_find_driver(void *data, +static const gfx_ctx_driver_t *video_driver_context_find_driver(void *data, const char *ident, enum gfx_ctx_api api, unsigned major, unsigned minor, bool hw_render_ctx) { - int i = find_gfx_ctx_driver_index(ident); + int i = find_video_driver_context_index(ident); if (i >= 0) - return gfx_ctx_init(data, gfx_ctx_drivers[i], ident, + return video_driver_context_init(data, gfx_ctx_drivers[i], ident, api, major, minor, hw_render_ctx); for (i = 0; gfx_ctx_drivers[i]; i++) { const gfx_ctx_driver_t *ctx = - gfx_ctx_init(data, gfx_ctx_drivers[i], ident, + video_driver_context_init(data, gfx_ctx_drivers[i], ident, api, major, minor, hw_render_ctx); if (ctx) @@ -236,7 +237,7 @@ static const gfx_ctx_driver_t *gfx_ctx_find_driver(void *data, } /** - * gfx_ctx_init_first: + * video_driver_context_init_first: * @data : Input data. * @ident : Identifier of graphics context driver to find. * @api : API of higher-level graphics API. @@ -249,11 +250,11 @@ static const gfx_ctx_driver_t *gfx_ctx_find_driver(void *data, * * Returns: graphics context driver if found, otherwise NULL. **/ -const gfx_ctx_driver_t *gfx_ctx_init_first(void *data, +const gfx_ctx_driver_t *video_driver_context_init_first(void *data, const char *ident, enum gfx_ctx_api api, unsigned major, unsigned minor, bool hw_render_ctx) { - return gfx_ctx_find_driver(data, ident, api, + return video_driver_context_find_driver(data, ident, api, major, minor, hw_render_ctx); } @@ -281,11 +282,11 @@ bool gfx_ctx_ctl(enum gfx_ctx_ctl_state state, void *data) } break; case GFX_CTL_FIND_PREV_DRIVER: - if (!gfx_ctl_find_prev_driver()) + if (!video_driver_context_find_prev_driver()) return false; break; case GFX_CTL_FIND_NEXT_DRIVER: - if (!gfx_ctl_find_next_driver()) + if (!video_driver_context_find_next_driver()) return false; break; case GFX_CTL_IMAGE_BUFFER_INIT: diff --git a/gfx/video_context_driver.h b/gfx/video_context_driver.h index 882bb57b65..279674fa9a 100644 --- a/gfx/video_context_driver.h +++ b/gfx/video_context_driver.h @@ -284,7 +284,7 @@ extern const gfx_ctx_driver_t gfx_ctx_opendingux_fbdev; extern const gfx_ctx_driver_t gfx_ctx_null; /** - * gfx_ctx_init_first: + * video_driver_context_init_first: * @data : Input data. * @ident : Identifier of graphics context driver to find. * @api : API of higher-level graphics API. @@ -297,7 +297,7 @@ extern const gfx_ctx_driver_t gfx_ctx_null; * * Returns: graphics context driver if found, otherwise NULL. **/ -const gfx_ctx_driver_t *gfx_ctx_init_first(void *data, const char *ident, +const gfx_ctx_driver_t *video_driver_context_init_first(void *data, const char *ident, enum gfx_ctx_api api, unsigned major, unsigned minor, bool hw_render_ctx); bool gfx_ctx_ctl(enum gfx_ctx_ctl_state state, void *data); From b20d550cc433a03f6426d1e9832bc53e56a730c2 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 20:32:46 +0200 Subject: [PATCH 289/498] Rename video context driver functions --- dynamic.c | 2 +- gfx/d3d/d3d.cpp | 36 +-- gfx/drivers/gl.c | 59 ++-- gfx/drivers/vg.c | 42 +-- gfx/drivers/vulkan.c | 42 +-- gfx/drivers_context/vc_egl_ctx.c | 1 - gfx/video_context_driver.c | 531 ++++++++++++++++--------------- gfx/video_context_driver.h | 104 +++--- gfx/video_driver.c | 6 +- gfx/video_shader_driver.c | 2 +- menu/menu_display.c | 2 +- menu/menu_displaylist.c | 8 +- menu/menu_input.c | 2 +- 13 files changed, 440 insertions(+), 397 deletions(-) diff --git a/dynamic.c b/dynamic.c index cc06df1191..2fc5a5fa7a 100644 --- a/dynamic.c +++ b/dynamic.c @@ -976,7 +976,7 @@ bool rarch_environment_cb(unsigned cmd, void *data) flags.flags = 0; BIT32_SET(flags.flags, GFX_CTX_FLAGS_GL_CORE_CONTEXT); - gfx_ctx_ctl(GFX_CTL_SET_FLAGS, &flags); + video_context_driver_set_flags(&flags); RARCH_LOG("Requesting core OpenGL context (%u.%u).\n", cb->version_major, cb->version_minor); diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index fa2b30900d..fb525f343e 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -544,7 +544,7 @@ void d3d_make_d3dpp(void *data, unsigned width = 0; unsigned height = 0; - gfx_ctx_ctl(GFX_CTL_GET_VIDEO_SIZE, &mode); + video_context_driver_get_video_size(&mode); width = mode.width; height = mode.height; @@ -664,7 +664,7 @@ static void d3d_calculate_rect(void *data, aspect_data.width = *width; aspect_data.height = *height; - gfx_ctx_ctl(GFX_CTL_TRANSLATE_ASPECT, &aspect_data); + video_context_driver_translate_aspect(&aspect_data); *x = 0; *y = 0; @@ -845,7 +845,7 @@ static void d3d_set_nonblock_state(void *data, bool state) d3d->video_info.vsync = !state; - gfx_ctx_ctl(GFX_CTL_SWAP_INTERVAL, &interval); + video_context_driver_swap_interval(&interval); #ifndef _XBOX d3d->needs_restore = true; d3d_restore(d3d); @@ -867,7 +867,7 @@ static bool d3d_alive(void *data) size_data.width = &temp_width; size_data.height = &temp_height; - if (gfx_ctx_ctl(GFX_CTL_CHECK_WINDOW, &size_data)) + if (video_context_driver_check_window(&size_data)) { if (quit) d3d->quitting = quit; @@ -881,7 +881,7 @@ static bool d3d_alive(void *data) mode.width = temp_width; mode.height = temp_height; - gfx_ctx_ctl(GFX_CTL_SET_RESIZE, &mode); + video_context_driver_set_resize(&mode); d3d_restore(d3d); } @@ -896,18 +896,18 @@ static bool d3d_alive(void *data) static bool d3d_focus(void *data) { - return gfx_ctx_ctl(GFX_CTL_FOCUS, NULL); + return video_context_driver_focus(); } static bool d3d_suppress_screensaver(void *data, bool enable) { bool enabled = enable; - return gfx_ctx_ctl(GFX_CTL_SUPPRESS_SCREENSAVER, &enabled); + return video_context_driver_suppress_screensaver(&enabled); } static bool d3d_has_windowed(void *data) { - return gfx_ctx_ctl(GFX_CTL_HAS_WINDOWED, NULL); + return video_context_driver_has_windowed(); } static void d3d_set_aspect_ratio(void *data, unsigned aspect_ratio_idx) @@ -1017,7 +1017,7 @@ static bool d3d_construct(d3d_video_t *d3d, { gfx_ctx_mode_t mode; - gfx_ctx_ctl(GFX_CTL_GET_VIDEO_SIZE, &mode); + video_context_driver_get_video_size(&mode); full_x = mode.width; full_y = mode.height; @@ -1065,7 +1065,7 @@ static bool d3d_construct(d3d_video_t *d3d, inp.input = input; inp.input_data = input_data; - gfx_ctx_ctl(GFX_CTL_INPUT_DRIVER, &inp); + video_context_driver_input_driver(&inp); RARCH_LOG("[D3D]: Init complete.\n"); return true; @@ -1084,7 +1084,7 @@ static void d3d_set_rotation(void *data, unsigned rot) static void d3d_show_mouse(void *data, bool state) { - gfx_ctx_ctl(GFX_CTL_SHOW_MOUSE, &state); + video_context_driver_show_mouse(&state); } static const gfx_ctx_driver_t *d3d_get_context(void *data) @@ -1100,7 +1100,7 @@ static const gfx_ctx_driver_t *d3d_get_context(void *data) unsigned major = 9; enum gfx_ctx_api api = GFX_CTX_DIRECT3D9_API; #endif - return video_driver_context_init_first(data, + return video_context_driver_init_first(data, settings->video.context_driver, api, major, minor, false); } @@ -1154,7 +1154,7 @@ static void *d3d_init(const video_info_t *info, #endif #endif - gfx_ctx_ctl(GFX_CTL_SET, (void*)ctx_driver); + video_context_driver_set((void*)ctx_driver); if (!d3d_construct(d3d, info, input, input_data)) { @@ -1171,7 +1171,7 @@ static void *d3d_init(const video_info_t *info, return d3d; error: - gfx_ctx_ctl(GFX_CTL_DESTROY, NULL); + video_context_driver_destroy(); if (d3d) delete d3d; return NULL; @@ -1204,7 +1204,7 @@ static void d3d_free(void *data) d3d_free_overlays(d3d); #endif - gfx_ctx_ctl(GFX_CTL_FREE, NULL); + video_context_driver_free(); #ifndef _XBOX #ifdef HAVE_MENU @@ -1392,7 +1392,7 @@ static void d3d_overlay_enable(void *data, bool state) for (i = 0; i < d3d->overlays.size(); i++) d3d->overlays_enabled = state; - gfx_ctx_ctl(GFX_CTL_SHOW_MOUSE, &state); + video_context_driver_show_mouse(&state); } static void d3d_overlay_full_screen(void *data, bool enable) @@ -1537,11 +1537,11 @@ static bool d3d_frame(void *data, const void *frame, } #endif - gfx_ctx_ctl(GFX_CTL_UPDATE_WINDOW_TITLE, NULL); + video_context_driver_update_window_title(); retro_perf_stop(&d3d_frame); - gfx_ctx_ctl(GFX_CTL_SWAP_BUFFERS, NULL); + video_context_driver_swap_buffers(); return true; } diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 3cb645ee03..65dfe0bcab 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -115,7 +115,7 @@ static const GLfloat white_color[] = { static INLINE void context_bind_hw_render(gl_t *gl, bool enable) { if (gl && gl->shared_context_use) - gfx_ctx_ctl(GFX_CTL_BIND_HW_RENDER, &enable); + video_context_driver_bind_hw_render(&enable); } static INLINE bool gl_query_extension(gl_t *gl, const char *ext) @@ -882,7 +882,7 @@ static void gl_set_viewport(void *data, unsigned viewport_width, aspect_data.width = viewport_width; aspect_data.height = viewport_height; - gfx_ctx_ctl(GFX_CTL_TRANSLATE_ASPECT, &aspect_data); + video_context_driver_translate_aspect(&aspect_data); if (settings->video.scale_integer && !force_full) { @@ -987,7 +987,7 @@ static void gl_set_video_mode(void *data, unsigned width, unsigned height, mode.height = height; mode.fullscreen = fullscreen; - gfx_ctx_ctl(GFX_CTL_SET_VIDEO_MODE, &mode); + video_context_driver_set_video_mode(&mode); } #ifdef HAVE_FBO @@ -1387,7 +1387,7 @@ static void gl_init_textures(gl_t *gl, const video_info_t *video) #if defined(HAVE_EGL) && defined(HAVE_OPENGLES2) /* Use regular textures if we use HW render. */ gl->egl_images = !gl->hw_render_use && gl_check_eglimage_proc() && - gfx_ctx_ctl(GFX_CTL_IMAGE_BUFFER_INIT, (void*)video); + video_context_driver_init_image_buffer((void*)video); #else (void)video; #endif @@ -1466,7 +1466,7 @@ static INLINE void gl_copy_frame(gl_t *gl, const void *frame, img_info.rgb32 = (gl->base_size == 4); img_info.handle = &img; - new_egl = gfx_ctx_ctl(GFX_CTL_IMAGE_BUFFER_WRITE, &img_info); + new_egl = video_context_driver_write_to_image_buffer(&img_info); if (img == EGL_NO_IMAGE_KHR) { @@ -1793,7 +1793,7 @@ static bool gl_frame(void *data, const void *frame, mode.width = width; mode.height = height; - gfx_ctx_ctl(GFX_CTL_SET_RESIZE, &mode); + video_context_driver_set_resize(&mode); #ifdef HAVE_FBO if (gl->fbo_inited) @@ -1938,7 +1938,7 @@ static bool gl_frame(void *data, const void *frame, gl_render_overlay(gl); #endif - gfx_ctx_ctl(GFX_CTL_UPDATE_WINDOW_TITLE, NULL); + video_context_driver_update_window_title(); retro_perf_stop(&frame_run); @@ -1989,11 +1989,11 @@ static bool gl_frame(void *data, const void *frame, && !runloop_ctl(RUNLOOP_CTL_IS_SLOWMOTION, NULL) && !runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL)) { - gfx_ctx_ctl(GFX_CTL_SWAP_BUFFERS, NULL); + video_context_driver_swap_buffers(); glClear(GL_COLOR_BUFFER_BIT); } - gfx_ctx_ctl(GFX_CTL_SWAP_BUFFERS, NULL); + video_context_driver_swap_buffers(); #ifdef HAVE_GL_SYNC if (settings->video.hard_sync && gl->have_sync) @@ -2121,7 +2121,7 @@ static void gl_free(void *data) } #endif - gfx_ctx_ctl(GFX_CTL_FREE, NULL); + video_context_driver_free(); free(gl->empty_buf); free(gl->conv_buffer); @@ -2144,7 +2144,7 @@ static void gl_set_nonblock_state(void *data, bool state) if (!state) interval = settings->video.swap_interval; - gfx_ctx_ctl(GFX_CTL_SWAP_INTERVAL, &interval); + video_context_driver_swap_interval(&interval); context_bind_hw_render(gl, true); } @@ -2444,7 +2444,7 @@ static const gfx_ctx_driver_t *gl_get_context(gl_t *gl) gl->shared_context_use = settings->video.shared_context && hwr->context_type != RETRO_HW_CONTEXT_NONE; - return video_driver_context_init_first(gl, settings->video.context_driver, + return video_context_driver_init_first(gl, settings->video.context_driver, api, major, minor, gl->shared_context_use); } @@ -2610,13 +2610,13 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo if (!gl || !ctx_driver) goto error; - gfx_ctx_ctl(GFX_CTL_SET, (void*)ctx_driver); + video_context_driver_set((void*)ctx_driver); gl->video_info = *video; RARCH_LOG("Found GL context: %s\n", ctx_driver->ident); - gfx_ctx_ctl(GFX_CTL_GET_VIDEO_SIZE, &mode); + video_context_driver_get_video_size(&mode); full_x = mode.width; full_y = mode.height; @@ -2627,7 +2627,7 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo interval = video->vsync ? settings->video.swap_interval : 0; - gfx_ctx_ctl(GFX_CTL_SWAP_INTERVAL, &interval); + video_context_driver_swap_interval(&interval); win_width = video->width; win_height = video->height; @@ -2642,7 +2642,7 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo mode.height = win_height; mode.fullscreen = video->fullscreen; - if (!gfx_ctx_ctl(GFX_CTL_SET_VIDEO_MODE, &mode)) + if (!video_context_driver_set_video_mode(&mode)) goto error; /* Clear out potential error flags in case we use cached context. */ @@ -2678,7 +2678,7 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo mode.width = 0; mode.height = 0; - gfx_ctx_ctl(GFX_CTL_GET_VIDEO_SIZE, &mode); + video_context_driver_get_video_size(&mode); temp_width = mode.width; temp_height = mode.height; @@ -2832,7 +2832,7 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo inp.input = input; inp.input_data = input_data; - gfx_ctx_ctl(GFX_CTL_INPUT_DRIVER, &inp); + video_context_driver_input_driver(&inp); if (settings->video.font_enable) { @@ -2853,7 +2853,7 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo return gl; error: - gfx_ctx_ctl(GFX_CTL_DESTROY, NULL); + video_context_driver_destroy(); free(gl); return NULL; } @@ -2876,7 +2876,7 @@ static bool gl_alive(void *data) size_data.width = &temp_width; size_data.height = &temp_height; - if (gfx_ctx_ctl(GFX_CTL_CHECK_WINDOW, &size_data)) + if (video_context_driver_check_window(&size_data)) { if (quit) gl->quitting = true; @@ -2894,18 +2894,18 @@ static bool gl_alive(void *data) static bool gl_focus(void *data) { - return gfx_ctx_ctl(GFX_CTL_FOCUS, NULL); + return video_context_driver_focus(); } static bool gl_suppress_screensaver(void *data, bool enable) { bool enabled = enable; - return gfx_ctx_ctl(GFX_CTL_SUPPRESS_SCREENSAVER, &enabled); + return video_context_driver_suppress_screensaver(&enabled); } static bool gl_has_windowed(void *data) { - return gfx_ctx_ctl(GFX_CTL_HAS_WINDOWED, NULL); + return video_context_driver_has_windowed(); } static void gl_update_tex_filter_frame(gl_t *gl) @@ -3463,7 +3463,7 @@ static void gl_overlay_enable(void *data, bool state) gl->overlay_enable = state; if (gl->fullscreen) - gfx_ctx_ctl(GFX_CTL_SHOW_MOUSE, &state); + video_context_driver_show_mouse(&state); } static void gl_overlay_full_screen(void *data, bool enable) @@ -3579,7 +3579,7 @@ static retro_proc_address_t gl_get_proc_address(void *data, const char *sym) proc_address.sym = sym; - gfx_ctx_ctl(GFX_CTL_PROC_ADDRESS_GET, &proc_address); + video_context_driver_get_proc_address(&proc_address); return proc_address.addr; } @@ -3677,7 +3677,7 @@ static void gl_set_osd_msg(void *data, const char *msg, static void gl_show_mouse(void *data, bool state) { - gfx_ctx_ctl(GFX_CTL_SHOW_MOUSE, &state); + video_context_driver_show_mouse(&state); } static struct video_shader *gl_get_current_shader(void *data) @@ -3696,20 +3696,19 @@ static void gl_get_video_output_size(void *data, gfx_ctx_size_t size_data; size_data.width = width; size_data.height = height; - gfx_ctx_ctl(GFX_CTL_GET_VIDEO_OUTPUT_SIZE, &size_data); + video_context_driver_get_video_output_size(&size_data); } static void gl_get_video_output_prev(void *data) { - gfx_ctx_ctl(GFX_CTL_GET_VIDEO_OUTPUT_PREV, NULL); + video_context_driver_get_video_output_prev(); } static void gl_get_video_output_next(void *data) { - gfx_ctx_ctl(GFX_CTL_GET_VIDEO_OUTPUT_NEXT, NULL); + video_context_driver_get_video_output_next(); } - static void video_texture_load_gl( struct texture_image *ti, enum texture_filter_type filter_type, diff --git a/gfx/drivers/vg.c b/gfx/drivers/vg.c index 0d7dfb34dc..ba1e91198c 100644 --- a/gfx/drivers/vg.c +++ b/gfx/drivers/vg.c @@ -70,7 +70,7 @@ static PFNVGCREATEEGLIMAGETARGETKHRPROC pvgCreateEGLImageTargetKHR; static void vg_set_nonblock_state(void *data, bool state) { unsigned interval = state ? 0 : 1; - gfx_ctx_ctl(GFX_CTL_SWAP_INTERVAL, &interval); + video_context_driver_set_swap_interval(&interval); } static INLINE bool vg_query_extension(const char *ext) @@ -94,16 +94,16 @@ static void *vg_init(const video_info_t *video, VGfloat clearColor[4] = {0, 0, 0, 1}; settings_t *settings = config_get_ptr(); vg_t *vg = (vg_t*)calloc(1, sizeof(vg_t)); - const gfx_ctx_driver_t *ctx = video_driver_context_init_first( + const gfx_ctx_driver_t *ctx = video_context_driver_init_first( vg, settings->video.context_driver, GFX_CTX_OPENVG_API, 0, 0, false); if (!vg || !ctx) goto error; - gfx_ctx_ctl(GFX_CTL_SET, (void*)ctx); + video_context_driver_set((void*)ctx); - gfx_ctx_ctl(GFX_CTL_GET_VIDEO_SIZE, &mode); + video_context_driver_get_video_size(&mode); temp_width = mode.width; temp_height = mode.height; @@ -117,8 +117,8 @@ static void *vg_init(const video_info_t *video, interval = video->vsync ? 1 : 0; - gfx_ctx_ctl(GFX_CTL_SWAP_INTERVAL, &interval); - gfx_ctx_ctl(GFX_CTL_UPDATE_WINDOW_TITLE, NULL); + video_context_driver_swap_interval(&interval); + video_context_driver_update_window_title(); vg->mTexType = video->rgb32 ? VG_sXRGB_8888 : VG_sRGB_565; vg->keep_aspect = video->force_aspect; @@ -137,7 +137,7 @@ static void *vg_init(const video_info_t *video, mode.height = win_height; mode.fullscreen = video->fullscreen; - if (!gfx_ctx_ctl(GFX_CTL_SET_VIDEO_MODE, &mode)) + if (!vidoe_context_driver_set_video_mode(&mode)) goto error; video_driver_get_size(&temp_width, &temp_height); @@ -147,7 +147,7 @@ static void *vg_init(const video_info_t *video, mode.width = 0; mode.height = 0; - gfx_ctx_ctl(GFX_CTL_GET_VIDEO_SIZE, &mode); + video_context_driver_get_video_size(&mode); temp_width = mode.width; temp_height = mode.height; @@ -170,7 +170,7 @@ static void *vg_init(const video_info_t *video, aspect_data.width = temp_width; aspect_data.height = temp_height; - gfx_ctx_ctl(GFX_CTL_TRANSLATE_ASPECT, &aspect_data); + video_context_driver_translate_aspect(&aspect_data); vgSetfv(VG_CLEAR_COLOR, 4, clearColor); @@ -182,7 +182,7 @@ static void *vg_init(const video_info_t *video, inp.input = input; inp.input_data = input_data; - gfx_ctx_ctl(GFX_CTL_INPUT_DRIVER, &inp); + video_context_driver_input_driver(&inp); if ( settings->video.font_enable && font_renderer_create_default((const void**)&vg->font_driver, &vg->mFontRenderer, @@ -216,13 +216,13 @@ static void *vg_init(const video_info_t *video, } if (vg_query_extension("KHR_EGL_image") - && gfx_ctx_ctl(GFX_CTL_IMAGE_BUFFER_INIT, (void*)video)) + && video_context_driver_init_image_buffer((void*)video)) { gfx_ctx_proc_address_t proc_address; proc_address.sym = "vgCreateEGLImageTargetKHR"; - gfx_ctx_ctl(GFX_CTL_PROC_ADDRESS_GET, &proc_address); + video_context_driver_get_proc_address(&proc_address); pvgCreateEGLImageTargetKHR = (PFNVGCREATEEGLIMAGETARGETKHRPROC)proc_address.addr; @@ -245,7 +245,7 @@ static void *vg_init(const video_info_t *video, error: if (vg) free(vg); - gfx_ctx_ctl(GFX_CTL_DESTROY, NULL); + video_context_driver_destroy(); return NULL; } @@ -266,7 +266,7 @@ static void vg_free(void *data) vgDestroyPaint(vg->mPaintBg); } - gfx_ctx_ctl(GFX_CTL_FREE, NULL); + video_context_driver_free(); free(vg); } @@ -343,7 +343,7 @@ static void vg_copy_frame(void *data, const void *frame, img_info.index = 0; img_info.handle = &img; - new_egl = gfx_ctx_ctl(GFX_CTL_IMAGE_BUFFER_WRITE, &img_info); + new_egl = video_context_driver_write_to_image_buffer(&img_info); retro_assert(img != EGL_NO_IMAGE_KHR); @@ -413,11 +413,11 @@ static bool vg_frame(void *data, const void *frame, vg_draw_message(vg, msg); #endif - gfx_ctx_ctl(GFX_CTL_UPDATE_WINDOW_TITLE, NULL); + video_context_driver_update_window_title(); retro_perf_stop(&vg_fr); - gfx_ctx_ctl(GFX_CTL_SWAP_BUFFERS, NULL); + video_context_driver_swap_buffers(); return true; } @@ -435,7 +435,7 @@ static bool vg_alive(void *data) size_data.width = &temp_width; size_data.height = &temp_height; - gfx_ctx_ctl(GFX_CTL_CHECK_WINDOW, &size_data); + video_context_driver_check_window(&size_data); if (temp_width != 0 && temp_height != 0) video_driver_set_size(&temp_width, &temp_height); @@ -445,18 +445,18 @@ static bool vg_alive(void *data) static bool vg_focus(void *data) { - return gfx_ctx_ctl(GFX_CTL_FOCUS, NULL); + return video_context_driver_focus(); } static bool vg_suppress_screensaver(void *data, bool enable) { bool enabled = enable; - return gfx_ctx_ctl(GFX_CTL_SUPPRESS_SCREENSAVER, &enabled); + return video_context_driver_suppress_screensaver(&enabled); } static bool vg_has_windowed(void *data) { - return gfx_ctx_ctl(GFX_CTL_HAS_WINDOWED, NULL); + return video_context_driver_has_windowed(); } static bool vg_set_shader(void *data, diff --git a/gfx/drivers/vulkan.c b/gfx/drivers/vulkan.c index 699184eec0..e02995fac4 100644 --- a/gfx/drivers/vulkan.c +++ b/gfx/drivers/vulkan.c @@ -70,7 +70,7 @@ static const gfx_ctx_driver_t *vulkan_get_context(vk_t *vk) settings_t *settings = config_get_ptr(); enum gfx_ctx_api api = GFX_CTX_VULKAN_API; - return video_driver_context_init_first( + return video_context_driver_init_first( vk, settings->video.context_driver, api, major, minor, false); } @@ -810,7 +810,7 @@ static void vulkan_free(void *data) if (vk->filter_chain) vulkan_filter_chain_free(vk->filter_chain); - gfx_ctx_ctl(GFX_CTL_FREE, NULL); + video_context_driver_free(); } scaler_ctx_gen_reset(&vk->readback.scaler); @@ -980,9 +980,9 @@ static void *vulkan_init(const video_info_t *video, if (!ctx_driver) goto error; - gfx_ctx_ctl(GFX_CTL_SET, (void*)ctx_driver); + video_context_driver_set((void*)ctx_driver); - gfx_ctx_ctl(GFX_CTL_GET_VIDEO_SIZE, &mode); + video_context_driver_get_video_size(&mode); full_x = mode.width; full_y = mode.height; mode.width = 0; @@ -990,7 +990,7 @@ static void *vulkan_init(const video_info_t *video, RARCH_LOG("Detecting screen resolution %ux%u.\n", full_x, full_y); interval = video->vsync ? settings->video.swap_interval : 0; - gfx_ctx_ctl(GFX_CTL_SWAP_INTERVAL, &interval); + video_context_driver_swap_interval(&interval); win_width = video->width; win_height = video->height; @@ -1004,10 +1004,10 @@ static void *vulkan_init(const video_info_t *video, mode.width = win_width; mode.height = win_height; mode.fullscreen = video->fullscreen; - if (!gfx_ctx_ctl(GFX_CTL_SET_VIDEO_MODE, &mode)) + if (!video_context_driver_set_video_mode(&mode)) goto error; - gfx_ctx_ctl(GFX_CTL_GET_VIDEO_SIZE, &mode); + video_context_driver_get_video_size(&mode); temp_width = mode.width; temp_height = mode.height; @@ -1017,7 +1017,7 @@ static void *vulkan_init(const video_info_t *video, RARCH_LOG("Vulkan: Using resolution %ux%u\n", temp_width, temp_height); - gfx_ctx_ctl(GFX_CTL_GET_CONTEXT_DATA, &vk->context); + video_context_driver_get_context_data(&vk->context); vk->vsync = video->vsync; vk->fullscreen = video->fullscreen; @@ -1041,7 +1041,7 @@ static void *vulkan_init(const video_info_t *video, inp.input = input; inp.input_data = input_data; - gfx_ctx_ctl(GFX_CTL_INPUT_DRIVER, &inp); + video_context_driver_input_driver(&inp); if (settings->video.font_enable) { @@ -1098,7 +1098,7 @@ static void vulkan_set_nonblock_state(void *data, bool state) RARCH_LOG("[Vulkan]: VSync => %s\n", state ? "off" : "on"); interval = state ? 0 : settings->video.swap_interval; - gfx_ctx_ctl(GFX_CTL_SWAP_INTERVAL, &interval); + video_context_driver_swap_interval(&interval); /* Changing vsync might require recreating the swapchain, which means new VkImages * to render into. */ @@ -1122,7 +1122,7 @@ static bool vulkan_alive(void *data) size_data.width = &temp_width; size_data.height = &temp_height; - if (gfx_ctx_ctl(GFX_CTL_CHECK_WINDOW, &size_data)) + if (video_context_driver_check_window(&size_data)) { if (quit) vk->quitting = true; @@ -1141,20 +1141,20 @@ static bool vulkan_alive(void *data) static bool vulkan_focus(void *data) { (void)data; - return gfx_ctx_ctl(GFX_CTL_FOCUS, NULL); + return video_context_driver_focus(); } static bool vulkan_suppress_screensaver(void *data, bool enable) { (void)data; bool enabled = enable; - return gfx_ctx_ctl(GFX_CTL_SUPPRESS_SCREENSAVER, &enabled); + return video_context_driver_suppress_screensaver(&enabled); } static bool vulkan_has_windowed(void *data) { (void)data; - return gfx_ctx_ctl(GFX_CTL_HAS_WINDOWED, NULL); + return video_context_driver_has_windowed(); } static bool vulkan_set_shader(void *data, @@ -1232,7 +1232,7 @@ static void vulkan_set_video_mode(void *data, mode.height = height; mode.fullscreen = fullscreen; - gfx_ctx_ctl(GFX_CTL_SET_VIDEO_MODE, &mode); + video_context_driver_set_video_mode(&mode); } static void vulkan_set_viewport(void *data, unsigned viewport_width, @@ -1253,7 +1253,7 @@ static void vulkan_set_viewport(void *data, unsigned viewport_width, aspect_data.width = viewport_width; aspect_data.height = viewport_height; - gfx_ctx_ctl(GFX_CTL_TRANSLATE_ASPECT, &aspect_data); + video_context_driver_translate_aspect(&aspect_data); if (settings->video.scale_integer && !force_full) { @@ -1747,10 +1747,10 @@ static bool vulkan_frame(void *data, const void *frame, retro_perf_stop(&queue_submit); retro_perf_start(&swapbuffers); - gfx_ctx_ctl(GFX_CTL_SWAP_BUFFERS, NULL); + video_context_driver_swap_buffers(); retro_perf_stop(&swapbuffers); - gfx_ctx_ctl(GFX_CTL_UPDATE_WINDOW_TITLE, NULL); + video_context_driver_update_window_title(); /* Handle spurious swapchain invalidations as soon as we can, * i.e. right after swap buffers. */ @@ -1759,7 +1759,7 @@ static bool vulkan_frame(void *data, const void *frame, gfx_ctx_mode_t mode; mode.width = width; mode.height = height; - gfx_ctx_ctl(GFX_CTL_SET_RESIZE, &mode); + video_context_driver_set_resize(&mode); vk->should_resize = false; } @@ -1810,7 +1810,7 @@ static void vulkan_apply_state_changes(void *data) static void vulkan_show_mouse(void *data, bool state) { (void)data; - gfx_ctx_ctl(GFX_CTL_SHOW_MOUSE, &state); + video_context_driver_show_mouse(&state); } static struct video_shader *vulkan_get_current_shader(void *data) @@ -2117,7 +2117,7 @@ static void vulkan_overlay_enable(void *data, bool enable) vk->overlay.enable = enable; if (vk->fullscreen) - gfx_ctx_ctl(GFX_CTL_SHOW_MOUSE, &enable); + video_context_driver_show_mouse(&enable); } static void vulkan_overlay_full_screen(void *data, bool enable) diff --git a/gfx/drivers_context/vc_egl_ctx.c b/gfx/drivers_context/vc_egl_ctx.c index d8fde21683..4288a8ab58 100644 --- a/gfx/drivers_context/vc_egl_ctx.c +++ b/gfx/drivers_context/vc_egl_ctx.c @@ -469,7 +469,6 @@ static float gfx_ctx_vc_translate_aspect(void *data, unsigned width, unsigned height) { (void)data; - /* Check for SD televisions: they should always be 4:3. */ if ((width == 640 || width == 720) && (height == 480 || height == 576)) return 4.0f / 3.0f; diff --git a/gfx/video_context_driver.c b/gfx/video_context_driver.c index 2a25b9aae3..2c3f3b7e54 100644 --- a/gfx/video_context_driver.c +++ b/gfx/video_context_driver.c @@ -89,7 +89,7 @@ static const gfx_ctx_driver_t *current_video_context = NULL; static void *video_context_data = NULL; /** - * find_video_driver_context_driver_index: + * find_video_context_driver_driver_index: * @ident : Identifier of resampler driver to find. * * Finds graphics context driver index by @ident name. @@ -97,7 +97,7 @@ static void *video_context_data = NULL; * Returns: graphics context driver index if driver was found, otherwise * -1. **/ -static int find_video_driver_context_index(const char *ident) +static int find_video_context_driver_index(const char *ident) { unsigned i; for (i = 0; gfx_ctx_drivers[i]; i++) @@ -111,10 +111,10 @@ static int find_video_driver_context_index(const char *ident) * * Finds previous driver in graphics context driver array. **/ -static bool video_driver_context_find_prev_driver(void) +bool video_context_driver_find_prev_driver(void) { settings_t *settings = config_get_ptr(); - int i = find_video_driver_context_index( + int i = find_video_context_driver_index( settings->video.context_driver); if (i > 0) @@ -134,10 +134,10 @@ static bool video_driver_context_find_prev_driver(void) * * Finds next driver in graphics context driver array. **/ -static bool video_driver_context_find_next_driver(void) +bool video_context_driver_find_next_driver(void) { settings_t *settings = config_get_ptr(); - int i = find_video_driver_context_index(settings->video.context_driver); + int i = find_video_context_driver_index(settings->video.context_driver); if (i >= 0 && gfx_ctx_drivers[i + 1]) { @@ -152,7 +152,7 @@ static bool video_driver_context_find_next_driver(void) } /** - * video_driver_context_init: + * video_context_driver_init: * @data : Input data. * @ctx : Graphics context driver to initialize. * @ident : Identifier of graphics context driver to find. @@ -166,7 +166,7 @@ static bool video_driver_context_find_next_driver(void) * * Returns: graphics context driver if successfully initialized, otherwise NULL. **/ -static const gfx_ctx_driver_t *video_driver_context_init( +static const gfx_ctx_driver_t *video_context_driver_init( void *data, const gfx_ctx_driver_t *ctx, const char *ident, @@ -186,7 +186,7 @@ static const gfx_ctx_driver_t *video_driver_context_init( ctx->bind_hw_render(ctx_data, settings->video.shared_context && hw_render_ctx); - gfx_ctx_ctl(GFX_CTL_SET_VIDEO_CONTEXT_DATA, ctx_data); + video_context_driver_set_data(ctx_data); return ctx; } @@ -199,7 +199,7 @@ static const gfx_ctx_driver_t *video_driver_context_init( } /** - * video_driver_context_find_driver: + * video_context_driver_find_driver: * @data : Input data. * @ident : Identifier of graphics context driver to find. * @api : API of higher-level graphics API. @@ -212,21 +212,21 @@ static const gfx_ctx_driver_t *video_driver_context_init( * * Returns: graphics context driver if found, otherwise NULL. **/ -static const gfx_ctx_driver_t *video_driver_context_find_driver(void *data, +static const gfx_ctx_driver_t *video_context_driver_find_driver(void *data, const char *ident, enum gfx_ctx_api api, unsigned major, unsigned minor, bool hw_render_ctx) { - int i = find_video_driver_context_index(ident); + int i = find_video_context_driver_index(ident); if (i >= 0) - return video_driver_context_init(data, gfx_ctx_drivers[i], ident, + return video_context_driver_init(data, gfx_ctx_drivers[i], ident, api, major, minor, hw_render_ctx); for (i = 0; gfx_ctx_drivers[i]; i++) { const gfx_ctx_driver_t *ctx = - video_driver_context_init(data, gfx_ctx_drivers[i], ident, + video_context_driver_init(data, gfx_ctx_drivers[i], ident, api, major, minor, hw_render_ctx); if (ctx) @@ -237,7 +237,7 @@ static const gfx_ctx_driver_t *video_driver_context_find_driver(void *data, } /** - * video_driver_context_init_first: + * video_context_driver_init_first: * @data : Input data. * @ident : Identifier of graphics context driver to find. * @api : API of higher-level graphics API. @@ -250,257 +250,280 @@ static const gfx_ctx_driver_t *video_driver_context_find_driver(void *data, * * Returns: graphics context driver if found, otherwise NULL. **/ -const gfx_ctx_driver_t *video_driver_context_init_first(void *data, +const gfx_ctx_driver_t *video_context_driver_init_first(void *data, const char *ident, enum gfx_ctx_api api, unsigned major, unsigned minor, bool hw_render_ctx) { - return video_driver_context_find_driver(data, ident, api, + return video_context_driver_find_driver(data, ident, api, major, minor, hw_render_ctx); } -bool gfx_ctx_ctl(enum gfx_ctx_ctl_state state, void *data) +bool video_context_driver_check_window(gfx_ctx_size_t *size_data) { + uint64_t *frame_count = NULL; + frame_count = video_driver_get_frame_count_ptr(); - switch (state) - { - case GFX_CTL_CHECK_WINDOW: - { - uint64_t *frame_count = NULL; - gfx_ctx_size_t *size_data = (gfx_ctx_size_t*)data; - frame_count = video_driver_get_frame_count_ptr(); + if (!video_context_data || !size_data) + return false; + if (!current_video_context || !current_video_context->check_window) + return false; - if (!video_context_data || !size_data) - return false; - if (!current_video_context || !current_video_context->check_window) - return false; + current_video_context->check_window(video_context_data, + size_data->quit, + size_data->resize, + size_data->width, + size_data->height, (unsigned int)*frame_count); + return true; +} - current_video_context->check_window(video_context_data, - size_data->quit, - size_data->resize, - size_data->width, - size_data->height, (unsigned int)*frame_count); - } - break; - case GFX_CTL_FIND_PREV_DRIVER: - if (!video_driver_context_find_prev_driver()) - return false; - break; - case GFX_CTL_FIND_NEXT_DRIVER: - if (!video_driver_context_find_next_driver()) - return false; - break; - case GFX_CTL_IMAGE_BUFFER_INIT: - if (!current_video_context || !current_video_context->image_buffer_init) - return false; - if (!current_video_context->image_buffer_init(video_context_data, - (const video_info_t*)data)) - return false; - break; - case GFX_CTL_IMAGE_BUFFER_WRITE: - { - gfx_ctx_image_t *img = (gfx_ctx_image_t*)data; +bool video_context_driver_init_image_buffer(const video_info_t *data) +{ + if (!current_video_context || !current_video_context->image_buffer_init) + return false; + if (!current_video_context->image_buffer_init(video_context_data, data)) + return false; + return true; +} - if (!current_video_context || !current_video_context->image_buffer_write) - return false; - if (!current_video_context->image_buffer_write(video_context_data, - img->frame, img->width, img->height, img->pitch, - img->rgb32, img->index, img->handle)) - return false; - } - break; - case GFX_CTL_GET_VIDEO_OUTPUT_PREV: - if (!current_video_context - || !current_video_context->get_video_output_prev) - return false; - current_video_context->get_video_output_prev(video_context_data); - break; - case GFX_CTL_GET_VIDEO_OUTPUT_NEXT: - if (!current_video_context || - !current_video_context->get_video_output_next) - return false; - current_video_context->get_video_output_next(video_context_data); - break; - case GFX_CTL_BIND_HW_RENDER: - { - bool *enable = (bool*)data; - if (!current_video_context || !current_video_context->bind_hw_render) - return false; - current_video_context->bind_hw_render(video_context_data, *enable); - } - break; - case GFX_CTL_SET: - if (!data) - return false; - current_video_context = (const gfx_ctx_driver_t*)data; - break; - case GFX_CTL_DESTROY: - current_video_context = NULL; - break; - case GFX_CTL_UPDATE_WINDOW_TITLE: - if (!current_video_context || !current_video_context->update_window_title) - return false; - current_video_context->update_window_title(video_context_data); - break; - case GFX_CTL_SWAP_BUFFERS: - if (!current_video_context || !current_video_context->swap_buffers) - return false; - current_video_context->swap_buffers(video_context_data); - break; - case GFX_CTL_FOCUS: - if (!video_context_data || !current_video_context->has_focus) - return false; - if (!current_video_context->has_focus(video_context_data)) - return false; - break; - case GFX_CTL_HAS_WINDOWED: - if (!video_context_data) - return false; - if (!current_video_context->has_windowed(video_context_data)) - return false; - break; - case GFX_CTL_FREE: - if (current_video_context->destroy) - current_video_context->destroy(video_context_data); - current_video_context = NULL; - video_context_data = NULL; - break; - case GFX_CTL_GET_VIDEO_OUTPUT_SIZE: - { - gfx_ctx_size_t *size_data = (gfx_ctx_size_t*)data; - if (!size_data) - return false; - if (!current_video_context || !current_video_context->get_video_output_size) - return false; - current_video_context->get_video_output_size(video_context_data, - size_data->width, size_data->height); - } - break; - case GFX_CTL_SWAP_INTERVAL: - { - unsigned *interval = (unsigned*)data; - if (!current_video_context || !current_video_context->swap_interval) - return false; - current_video_context->swap_interval(video_context_data, *interval); - } - break; - case GFX_CTL_PROC_ADDRESS_GET: - { - gfx_ctx_proc_address_t *proc = (gfx_ctx_proc_address_t*)data; - if (!current_video_context || !current_video_context->get_proc_address) - return false; +bool video_context_driver_write_to_image_buffer(gfx_ctx_image_t *img) +{ + if (!current_video_context || !current_video_context->image_buffer_write) + return false; + if (!current_video_context->image_buffer_write(video_context_data, + img->frame, img->width, img->height, img->pitch, + img->rgb32, img->index, img->handle)) + return false; + return true; +} - proc->addr = current_video_context->get_proc_address(proc->sym); - } - break; - case GFX_CTL_GET_METRICS: - { - gfx_ctx_metrics_t *metrics = (gfx_ctx_metrics_t*)data; - if (!current_video_context || !current_video_context->get_metrics) - return false; - if (!current_video_context->get_metrics(video_context_data, - metrics->type, - metrics->value)) - return false; - } - break; - case GFX_CTL_INPUT_DRIVER: - { - gfx_ctx_input_t *inp = (gfx_ctx_input_t*)data; - if (!current_video_context || !current_video_context->input_driver) - return false; - current_video_context->input_driver( - video_context_data, inp->input, inp->input_data); - } - break; - case GFX_CTL_SUPPRESS_SCREENSAVER: - { - bool *bool_data = (bool*)data; - if (!video_context_data || !current_video_context) - return false; - if (!current_video_context->suppress_screensaver( - video_context_data, *bool_data)) - return false; - } - break; - case GFX_CTL_IDENT_GET: - { - gfx_ctx_ident_t *ident = (gfx_ctx_ident_t*)data; - ident->ident = NULL; - if (current_video_context) - ident->ident = current_video_context->ident; - } - break; - case GFX_CTL_SET_VIDEO_MODE: - { - gfx_ctx_mode_t *mode_info = (gfx_ctx_mode_t*)data; - if (!current_video_context || !current_video_context->set_video_mode) - return false; - if (!current_video_context->set_video_mode( - video_context_data, mode_info->width, - mode_info->height, mode_info->fullscreen)) - return false; - } - break; - case GFX_CTL_SET_RESIZE: - { - gfx_ctx_mode_t *mode_info = (gfx_ctx_mode_t*)data; - if (!current_video_context) - return false; - if (!current_video_context->set_resize( - video_context_data, mode_info->width, mode_info->height)) - return false; - } - break; - case GFX_CTL_GET_VIDEO_SIZE: - { - gfx_ctx_mode_t *mode_info = (gfx_ctx_mode_t*)data; - if (!current_video_context || !current_video_context->get_video_size) - return false; - current_video_context->get_video_size(video_context_data, &mode_info->width, &mode_info->height); - } - break; - case GFX_CTL_GET_CONTEXT_DATA: - { - if (!current_video_context || !current_video_context->get_context_data) - return false; - *(void**)data = current_video_context->get_context_data(video_context_data); - } - break; - case GFX_CTL_SHOW_MOUSE: - { - bool *bool_data = (bool*)data; - if (!current_video_context || !current_video_context->show_mouse) - return false; - current_video_context->show_mouse(video_context_data, *bool_data); - } - break; - case GFX_CTL_SET_VIDEO_CONTEXT_DATA: - video_context_data = data; - break; - case GFX_CTL_GET_FLAGS: - { - gfx_ctx_flags_t *flags = (gfx_ctx_flags_t*)data; - if (!flags) - return false; - if (!current_video_context || !current_video_context->get_flags) - return false; - flags->flags = current_video_context->get_flags(video_context_data); - } - break; - case GFX_CTL_SET_FLAGS: - { - gfx_ctx_flags_t *flags = (gfx_ctx_flags_t*)data; - if (!flags) - return false; - if (!current_video_context || !current_video_context->set_flags) - return false; - current_video_context->set_flags(video_context_data, flags->flags); - } - break; - case GFX_CTL_NONE: - default: - break; - } +bool video_context_driver_get_video_output_prev(void) +{ + if (!current_video_context + || !current_video_context->get_video_output_prev) + return false; + current_video_context->get_video_output_prev(video_context_data); + return true; +} + +bool video_context_driver_get_video_output_next(void) +{ + if (!current_video_context || + !current_video_context->get_video_output_next) + return false; + current_video_context->get_video_output_next(video_context_data); + return true; +} + +bool video_context_driver_bind_hw_render(bool *enable) +{ + if (!current_video_context || !current_video_context->bind_hw_render) + return false; + current_video_context->bind_hw_render(video_context_data, *enable); + return true; +} + +bool video_context_driver_set(const gfx_ctx_driver_t *data) +{ + if (!data) + return false; + current_video_context = data; + return true; +} + +void video_context_driver_destroy(void) +{ + current_video_context = NULL; +} + +bool video_context_driver_update_window_title(void) +{ + if (!current_video_context || !current_video_context->update_window_title) + return false; + current_video_context->update_window_title(video_context_data); + return true; +} + +bool video_context_driver_swap_buffers(void) +{ + if (!current_video_context || !current_video_context->swap_buffers) + return false; + current_video_context->swap_buffers(video_context_data); + return true; +} + +bool video_context_driver_focus(void) +{ + if (!video_context_data || !current_video_context->has_focus) + return false; + if (!current_video_context->has_focus(video_context_data)) + return false; + return true; +} + +bool video_context_driver_translate_aspect(gfx_ctx_aspect_t *aspect) +{ + if (!video_context_data || !aspect) + return false; + if (!current_video_context->translate_aspect) + return false; + *aspect->aspect = current_video_context->translate_aspect( + video_context_data, aspect->width, aspect->height); + return true; +} + +bool video_context_driver_has_windowed(void) +{ + if (!video_context_data) + return false; + if (!current_video_context->has_windowed(video_context_data)) + return false; + return true; +} + +void video_context_driver_free(void) +{ + if (current_video_context->destroy) + current_video_context->destroy(video_context_data); + current_video_context = NULL; + video_context_data = NULL; +} + +bool video_context_driver_get_video_output_size(gfx_ctx_size_t *size_data) +{ + if (!size_data) + return false; + if (!current_video_context || !current_video_context->get_video_output_size) + return false; + current_video_context->get_video_output_size(video_context_data, + size_data->width, size_data->height); + return true; +} + +bool video_context_driver_swap_interval(unsigned *interval) +{ + if (!current_video_context || !current_video_context->swap_interval) + return false; + current_video_context->swap_interval(video_context_data, *interval); + return true; +} + +bool video_context_driver_get_proc_address(gfx_ctx_proc_address_t *proc) +{ + if (!current_video_context || !current_video_context->get_proc_address) + return false; + + proc->addr = current_video_context->get_proc_address(proc->sym); return true; } + +bool video_context_driver_get_metrics(gfx_ctx_metrics_t *metrics) +{ + if (!current_video_context || !current_video_context->get_metrics) + return false; + if (!current_video_context->get_metrics(video_context_data, + metrics->type, + metrics->value)) + return false; + return true; +} + +bool video_context_driver_input_driver(gfx_ctx_input_t *inp) +{ + if (!current_video_context || !current_video_context->input_driver) + return false; + current_video_context->input_driver( + video_context_data, inp->input, inp->input_data); + return true; +} + +bool video_context_driver_suppress_screensaver(bool *bool_data) +{ + if (!video_context_data || !current_video_context) + return false; + if (!current_video_context->suppress_screensaver( + video_context_data, *bool_data)) + return false; + return true; +} + +bool video_context_driver_get_ident(gfx_ctx_ident_t *ident) +{ + if (!ident) + return false; + ident->ident = NULL; + if (current_video_context) + ident->ident = current_video_context->ident; + return true; +} + +bool video_context_driver_set_video_mode(gfx_ctx_mode_t *mode_info) +{ + if (!current_video_context || !current_video_context->set_video_mode) + return false; + if (!current_video_context->set_video_mode( + video_context_data, mode_info->width, + mode_info->height, mode_info->fullscreen)) + return false; + return true; +} + +bool video_context_driver_set_resize(gfx_ctx_mode_t *mode_info) +{ + if (!current_video_context) + return false; + if (!current_video_context->set_resize( + video_context_data, mode_info->width, mode_info->height)) + return false; + return true; +} + +bool video_context_driver_get_video_size(gfx_ctx_mode_t *mode_info) +{ + if (!current_video_context || !current_video_context->get_video_size) + return false; + current_video_context->get_video_size(video_context_data, + &mode_info->width, &mode_info->height); + return true; +} + +bool video_context_driver_get_context_data(void *data) +{ + if (!current_video_context || !current_video_context->get_context_data) + return false; + *(void**)data = current_video_context->get_context_data(video_context_data); + return true; +} + +bool video_context_driver_show_mouse(bool *bool_data) +{ + if (!current_video_context || !current_video_context->show_mouse) + return false; + current_video_context->show_mouse(video_context_data, *bool_data); + return true; +} + +void video_context_driver_set_data(void *data) +{ + video_context_data = data; +} + +bool video_context_driver_get_flags(gfx_ctx_flags_t *flags) +{ + if (!flags) + return false; + if (!current_video_context || !current_video_context->get_flags) + return false; + flags->flags = current_video_context->get_flags(video_context_data); + return true; +} + +bool video_context_driver_set_flags(gfx_ctx_flags_t *flags) +{ + if (!flags) + return false; + if (!current_video_context || !current_video_context->set_flags) + return false; + current_video_context->set_flags(video_context_data, flags->flags); + return true; +} diff --git a/gfx/video_context_driver.h b/gfx/video_context_driver.h index 279674fa9a..d288ae73ef 100644 --- a/gfx/video_context_driver.h +++ b/gfx/video_context_driver.h @@ -58,44 +58,6 @@ enum display_flags GFX_CTX_FLAGS_GL_CORE_CONTEXT }; -enum gfx_ctx_ctl_state -{ - GFX_CTL_NONE = 0, - GFX_CTL_CHECK_WINDOW, - GFX_CTL_FOCUS, - GFX_CTL_DESTROY, - GFX_CTL_FREE, - GFX_CTL_SWAP_BUFFERS, - GFX_CTL_HAS_WINDOWED, - GFX_CTL_UPDATE_WINDOW_TITLE, - GFX_CTL_SHOW_MOUSE, - GFX_CTL_SET, - GFX_CTL_BIND_HW_RENDER, - GFX_CTL_GET_VIDEO_OUTPUT_PREV, - GFX_CTL_GET_VIDEO_OUTPUT_NEXT, - GFX_CTL_IMAGE_BUFFER_INIT, - GFX_CTL_IMAGE_BUFFER_WRITE, - /* Finds next driver in graphics context driver array. */ - GFX_CTL_FIND_NEXT_DRIVER, - /* Finds previous driver in graphics context driver array. */ - GFX_CTL_FIND_PREV_DRIVER, - GFX_CTL_GET_VIDEO_OUTPUT_SIZE, - GFX_CTL_SWAP_INTERVAL, - GFX_CTL_PROC_ADDRESS_GET, - GFX_CTL_TRANSLATE_ASPECT, - GFX_CTL_GET_FLAGS, - GFX_CTL_SET_FLAGS, - GFX_CTL_GET_METRICS, - GFX_CTL_INPUT_DRIVER, - GFX_CTL_SUPPRESS_SCREENSAVER, - GFX_CTL_IDENT_GET, - GFX_CTL_SET_VIDEO_MODE, - GFX_CTL_SET_RESIZE, - GFX_CTL_GET_VIDEO_SIZE, - GFX_CTL_SET_VIDEO_CONTEXT_DATA, - GFX_CTL_GET_CONTEXT_DATA -}; - typedef void (*gfx_ctx_proc_t)(void); typedef struct gfx_ctx_driver @@ -284,7 +246,7 @@ extern const gfx_ctx_driver_t gfx_ctx_opendingux_fbdev; extern const gfx_ctx_driver_t gfx_ctx_null; /** - * video_driver_context_init_first: + * video_context_driver_init_first: * @data : Input data. * @ident : Identifier of graphics context driver to find. * @api : API of higher-level graphics API. @@ -297,10 +259,70 @@ extern const gfx_ctx_driver_t gfx_ctx_null; * * Returns: graphics context driver if found, otherwise NULL. **/ -const gfx_ctx_driver_t *video_driver_context_init_first(void *data, const char *ident, +const gfx_ctx_driver_t *video_context_driver_init_first(void *data, const char *ident, enum gfx_ctx_api api, unsigned major, unsigned minor, bool hw_render_ctx); -bool gfx_ctx_ctl(enum gfx_ctx_ctl_state state, void *data); +bool video_context_driver_check_window(gfx_ctx_size_t *size_data); + +bool video_context_driver_find_prev_driver(void); + +bool video_context_driver_find_next_driver(void); + +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); + +bool video_context_driver_get_video_output_prev(void); + +bool video_context_driver_get_video_output_next(void); + +bool video_context_driver_bind_hw_render(bool *enable); + +bool video_context_driver_set(const gfx_ctx_driver_t *data); + +void video_context_driver_destroy(void); + +bool video_context_driver_update_window_title(void); + +bool video_context_driver_swap_buffers(void); + +bool video_context_driver_focus(void); + +bool video_context_driver_get_video_output_size(gfx_ctx_size_t *size_data); + +bool video_context_driver_swap_interval(unsigned *interval); + +bool video_context_driver_get_proc_address(gfx_ctx_proc_address_t *proc); + +bool video_context_driver_suppress_screensaver(bool *bool_data); + +bool video_context_driver_get_ident(gfx_ctx_ident_t *ident); + +bool video_context_driver_set_video_mode(gfx_ctx_mode_t *mode_info); + +bool video_context_driver_set_resize(gfx_ctx_mode_t *mode_info); + +bool video_context_driver_get_video_size(gfx_ctx_mode_t *mode_info); + +bool video_context_driver_get_context_data(void *data); + +bool video_context_driver_show_mouse(bool *bool_data); + +void video_context_driver_set_data(void *data); + +bool video_context_driver_get_flags(gfx_ctx_flags_t *flags); + +bool video_context_driver_set_flags(gfx_ctx_flags_t *flags); + +bool video_context_driver_get_metrics(gfx_ctx_metrics_t *metrics); + +bool video_context_driver_translate_aspect(gfx_ctx_aspect_t *aspect); + +bool video_context_driver_input_driver(gfx_ctx_input_t *inp); + +bool video_context_driver_has_windowed(void); + +void video_context_driver_free(void); #ifdef __cplusplus } diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 0040216cb7..65acf70351 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -792,7 +792,7 @@ bool video_driver_set_video_mode(unsigned width, mode.height = height; mode.fullscreen = fullscreen; - return gfx_ctx_ctl(GFX_CTL_SET_VIDEO_MODE, &mode); + return video_context_driver_set_video_mode(&mode); } bool video_driver_get_video_output_size(unsigned *width, unsigned *height) @@ -1496,7 +1496,7 @@ bool video_driver_get_next_video_out(void) return false; if (!video_driver_poke->get_video_output_next) - return gfx_ctx_ctl(GFX_CTL_GET_VIDEO_OUTPUT_NEXT, NULL); + return video_context_driver_get_video_output_next(); video_driver_poke->get_video_output_next(video_driver_data); return true; } @@ -1507,7 +1507,7 @@ bool video_driver_get_prev_video_out(void) return false; if (!video_driver_poke->get_video_output_prev) - return gfx_ctx_ctl(GFX_CTL_GET_VIDEO_OUTPUT_NEXT, NULL); + return video_context_driver_get_video_output_prev(); video_driver_poke->get_video_output_prev(video_driver_data); return true; } diff --git a/gfx/video_shader_driver.c b/gfx/video_shader_driver.c index a0b91cf0e6..6257da50f7 100644 --- a/gfx/video_shader_driver.c +++ b/gfx/video_shader_driver.c @@ -43,7 +43,7 @@ static const shader_backend_t *video_shader_set_backend(enum rarch_shader_type t #ifdef HAVE_CG gfx_ctx_flags_t flags; - gfx_ctx_ctl(GFX_CTL_GET_FLAGS, &flags); + video_context_driver_get_flags(&flags); if (BIT32_GET(flags.flags, GFX_CTX_FLAGS_GL_CORE_CONTEXT)) { diff --git a/menu/menu_display.c b/menu/menu_display.c index bb8bc842ca..f023be7260 100644 --- a/menu/menu_display.c +++ b/menu/menu_display.c @@ -411,7 +411,7 @@ float menu_display_get_dpi(void) if (settings->menu.dpi.override_enable) return settings->menu.dpi.override_value; - else if (!gfx_ctx_ctl(GFX_CTL_GET_METRICS, &metrics) || !dpi) + else if (!video_context_driver_get_metrics(&metrics) || !dpi) return menu_dpi_override_value; return dpi; diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 922d7d0bfa..8ee67182b9 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -776,7 +776,7 @@ static int menu_displaylist_parse_system_info(menu_displaylist_info_t *info) } #if defined(HAVE_OPENGL) || defined(HAVE_GLES) - gfx_ctx_ctl(GFX_CTL_IDENT_GET, &ident_info); + video_context_driver_get_ident(&ident_info); tmp_string = ident_info.ident; strlcpy(tmp, @@ -797,7 +797,7 @@ static int menu_displaylist_parse_system_info(menu_displaylist_info_t *info) metrics.type = DISPLAY_METRIC_MM_WIDTH; metrics.value = &val; - if (gfx_ctx_ctl(GFX_CTL_GET_METRICS, &metrics)) + if (video_context_driver_get_metrics(&metrics)) { snprintf(tmp, sizeof(tmp), "%s: %.2f", menu_hash_to_str( @@ -809,7 +809,7 @@ static int menu_displaylist_parse_system_info(menu_displaylist_info_t *info) metrics.type = DISPLAY_METRIC_MM_HEIGHT; - if (gfx_ctx_ctl(GFX_CTL_GET_METRICS, &metrics)) + if (video_context_driver_get_metrics(&metrics)) { snprintf(tmp, sizeof(tmp), "%s: %.2f", menu_hash_to_str( @@ -821,7 +821,7 @@ static int menu_displaylist_parse_system_info(menu_displaylist_info_t *info) metrics.type = DISPLAY_METRIC_DPI; - if (gfx_ctx_ctl(GFX_CTL_GET_METRICS, &metrics)) + if (video_context_driver_get_metrics(&metrics)) { snprintf(tmp, sizeof(tmp), "%s: %.2f", menu_hash_to_str( diff --git a/menu/menu_input.c b/menu/menu_input.c index 78f8581592..950f71ac19 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -1108,7 +1108,7 @@ static int menu_input_pointer_post_iterate( metrics.type = DISPLAY_METRIC_DPI; metrics.value = &dpi; - gfx_ctx_ctl(GFX_CTL_GET_METRICS, &metrics); + video_context_driver_get_metrics(&metrics); if (!pointer_oldpressed[0]) { From ed5954420b643b015d04a0f908be80ecb7c92a95 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 20:40:42 +0200 Subject: [PATCH 290/498] (MSVC) Buildfixes --- gfx/d3d/d3d.cpp | 2 +- gfx/drivers/gl.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index fb525f343e..5eb7950be2 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -1154,7 +1154,7 @@ static void *d3d_init(const video_info_t *info, #endif #endif - video_context_driver_set((void*)ctx_driver); + video_context_driver_set((const gfx_ctx_driver_t*)ctx_driver); if (!d3d_construct(d3d, info, input, input_data)) { diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 65dfe0bcab..43594f8ae3 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -2610,7 +2610,7 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo if (!gl || !ctx_driver) goto error; - video_context_driver_set((void*)ctx_driver); + video_context_driver_set((const gfx_ctx_driver_t*)ctx_driver); gl->video_info = *video; From 1b8e8ac22a74124c8717f58d14fde3c8dbd1c7d8 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 21:11:27 +0200 Subject: [PATCH 291/498] Remove video_shader_driver_ctl --- gfx/d3d/render_chain_xdk.cpp | 6 +- gfx/drivers/gl.c | 109 +++--- gfx/drivers_font/gl_raster_font.c | 6 +- gfx/video_shader_driver.c | 447 +++++++++++----------- gfx/video_shader_driver.h | 65 ++-- menu/cbs/menu_cbs_get_value.c | 2 +- menu/cbs/menu_cbs_left.c | 2 +- menu/cbs/menu_cbs_right.c | 2 +- menu/cbs/menu_cbs_start.c | 2 +- menu/drivers/nk_common.c | 4 +- menu/drivers/nk_menu.c | 2 +- menu/drivers_display/menu_display_d3d.cpp | 4 +- menu/drivers_display/menu_display_gl.c | 10 +- menu/menu_displaylist.c | 2 +- ui/drivers/ui_win32.c | 8 +- 15 files changed, 331 insertions(+), 340 deletions(-) diff --git a/gfx/d3d/render_chain_xdk.cpp b/gfx/d3d/render_chain_xdk.cpp index 3f1a4dc6a2..ac4c7d494d 100644 --- a/gfx/d3d/render_chain_xdk.cpp +++ b/gfx/d3d/render_chain_xdk.cpp @@ -50,7 +50,7 @@ static void renderchain_set_mvp(void *data, unsigned vp_width, mvp.data = d3d; mvp.matrix = NULL; - video_shader_driver_ctl(SHADER_CTL_SET_MVP, &mvp); + video_shadser_driver_set_mvp(&mvp); #elif defined(HAVE_D3D8) D3DXMATRIX p_out, p_rotate, mat; D3DXMatrixOrthoOffCenterLH(&mat, 0, vp_width, vp_height, 0, 0.0f, 1.0f); @@ -224,7 +224,7 @@ static void renderchain_set_vertices(void *data, unsigned pass, shader_info.idx = pass; shader_info.set_active = true; - video_shader_driver_ctl(SHADER_CTL_USE, &shader_info); + video_shader_driver_use(&shader_info); params.data = d3d; params.width = vert_width; @@ -240,7 +240,7 @@ static void renderchain_set_vertices(void *data, unsigned pass, params.fbo_info = NULL; params.fbo_info_cnt = 0; - video_shader_driver_ctl(SHADER_CTL_SET_PARAMS, ¶ms); + video_shader_driver_set_parameters(¶ms); #endif #endif } diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 43594f8ae3..ed30f4e671 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -275,7 +275,7 @@ static bool gl_shader_init(gl_t *gl) init_data.data = gl; init_data.path = shader_path; - if (video_shader_driver_ctl(SHADER_CTL_INIT, &init_data)) + if (video_shader_driver_init(&init_data)) return true; RARCH_ERR("[GL]: Failed to initialize shader, falling back to stock.\n"); @@ -283,12 +283,7 @@ static bool gl_shader_init(gl_t *gl) init_data.shader = NULL; init_data.path = NULL; - return video_shader_driver_ctl(SHADER_CTL_INIT, &init_data); -} - -static void gl_shader_deinit(gl_t *gl) -{ - video_shader_driver_ctl(SHADER_CTL_DEINIT, NULL); + return video_shader_driver_init(&init_data); } #ifndef NO_GL_FF_VERTEX @@ -441,12 +436,12 @@ static void gl_create_fbo_texture(gl_t *gl, unsigned i, GLuint texture) glBindTexture(GL_TEXTURE_2D, texture); mip_level = i + 2; - mipmapped = video_shader_driver_ctl(SHADER_CTL_MIPMAP_INPUT, &mip_level); + mipmapped = video_shader_driver_mipmap_input(&mip_level); min_filter = mipmapped ? base_mip_filt : base_filt; filter_type.index = i + 2; filter_type.smooth = &smooth; - if (video_shader_driver_ctl(SHADER_CTL_FILTER_TYPE, &filter_type)) + if (video_shader_driver_filter_type(&filter_type)) { min_filter = mipmapped ? (smooth ? GL_LINEAR_MIPMAP_LINEAR : GL_NEAREST_MIPMAP_NEAREST) @@ -456,7 +451,7 @@ static void gl_create_fbo_texture(gl_t *gl, unsigned i, GLuint texture) mag_filter = min_filter_to_mag(min_filter); wrap.idx = i + 2; - video_shader_driver_ctl(SHADER_CTL_WRAP_TYPE, &wrap); + video_shader_driver_wrap_type(&wrap); wrap_enum = gl_wrap_type_to_enum(wrap.type); @@ -635,7 +630,7 @@ static void gl_init_fbo(gl_t *gl, unsigned fbo_width, unsigned fbo_height) video_shader_ctx_info_t shader_info; struct gfx_fbo_scale scale, scale_last; - if (!video_shader_driver_ctl(SHADER_CTL_INFO, &shader_info)) + if (!video_shader_driver_info(&shader_info)) return; if (!gl || shader_info.num == 0) @@ -646,12 +641,12 @@ static void gl_init_fbo(gl_t *gl, unsigned fbo_width, unsigned fbo_height) scaler.idx = 1; scaler.scale = &scale; - video_shader_driver_ctl(SHADER_CTL_SCALE, &scaler); + video_shader_driver_scale(&scaler); scaler.idx = shader_info.num; scaler.scale = &scale_last; - video_shader_driver_ctl(SHADER_CTL_SCALE, &scaler); + video_shader_driver_scale(&scaler); /* we always want FBO to be at least initialized on startup for consoles */ if (shader_info.num == 1 && !scale.valid) @@ -682,7 +677,7 @@ static void gl_init_fbo(gl_t *gl, unsigned fbo_width, unsigned fbo_height) scaler.idx = i + 1; scaler.scale = &gl->fbo_scale[i]; - video_shader_driver_ctl(SHADER_CTL_SCALE, &scaler); + video_shader_driver_scale(&scaler); if (!gl->fbo_scale[i].valid) { @@ -703,8 +698,8 @@ static void gl_init_fbo(gl_t *gl, unsigned fbo_width, unsigned fbo_height) gl->fbo_rect[i].width, gl->fbo_rect[i].height); } - gl->fbo_feedback_enable = video_shader_driver_ctl( - SHADER_CTL_GET_FEEDBACK_PASS, &gl->fbo_feedback_pass); + gl->fbo_feedback_enable = video_shader_driver_get_feedback_pass( + &gl->fbo_feedback_pass); if (gl->fbo_feedback_enable && gl->fbo_feedback_pass < (unsigned)gl->fbo_pass) @@ -1157,12 +1152,12 @@ static void gl_frame_fbo(gl_t *gl, uint64_t frame_count, shader_info.idx = i + 1; shader_info.set_active = true; - video_shader_driver_ctl(SHADER_CTL_USE, &shader_info); + video_shader_driver_use(&shader_info); glBindTexture(GL_TEXTURE_2D, gl->fbo_texture[i - 1]); mip_level = i + 1; - if (video_shader_driver_ctl(SHADER_CTL_MIPMAP_INPUT, &mip_level)) + if (video_shader_driver_mipmap_input(&mip_level)) glGenerateMipmap(GL_TEXTURE_2D); glClear(GL_COLOR_BUFFER_BIT); @@ -1184,19 +1179,19 @@ static void gl_frame_fbo(gl_t *gl, uint64_t frame_count, params.fbo_info = fbo_tex_info; params.fbo_info_cnt = fbo_tex_info_cnt; - video_shader_driver_ctl(SHADER_CTL_SET_PARAMS, ¶ms); + video_shader_driver_set_parameters(¶ms); gl->coords.vertices = 4; coords.handle_data = NULL; coords.data = &gl->coords; - video_shader_driver_ctl(SHADER_CTL_SET_COORDS, &coords); + video_shader_driver_set_coords(&coords); mvp.data = gl; mvp.matrix = &gl->mvp; - video_shader_driver_ctl(SHADER_CTL_SET_MVP, &mvp); + video_shader_driver_set_mvp(&mvp); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); } @@ -1231,13 +1226,13 @@ static void gl_frame_fbo(gl_t *gl, uint64_t frame_count, shader_info.idx = gl->fbo_pass + 1; shader_info.set_active = true; - video_shader_driver_ctl(SHADER_CTL_USE, &shader_info); + video_shader_driver_use(&shader_info); glBindTexture(GL_TEXTURE_2D, gl->fbo_texture[gl->fbo_pass - 1]); mip_level = gl->fbo_pass + 1; - if (video_shader_driver_ctl(SHADER_CTL_MIPMAP_INPUT, &mip_level)) + if (video_shader_driver_mipmap_input(&mip_level)) glGenerateMipmap(GL_TEXTURE_2D); glClear(GL_COLOR_BUFFER_BIT); @@ -1257,7 +1252,7 @@ static void gl_frame_fbo(gl_t *gl, uint64_t frame_count, params.fbo_info = fbo_tex_info; params.fbo_info_cnt = fbo_tex_info_cnt; - video_shader_driver_ctl(SHADER_CTL_SET_PARAMS, ¶ms); + video_shader_driver_set_parameters(¶ms); gl->coords.vertex = gl->vertex_ptr; @@ -1266,12 +1261,12 @@ static void gl_frame_fbo(gl_t *gl, uint64_t frame_count, coords.handle_data = NULL; coords.data = &gl->coords; - video_shader_driver_ctl(SHADER_CTL_SET_COORDS, &coords); + video_shader_driver_set_coords(&coords); mvp.data = gl; mvp.matrix = &gl->mvp; - video_shader_driver_ctl(SHADER_CTL_SET_MVP, &mvp); + video_shader_driver_set_mvp(&mvp); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); gl->coords.tex_coord = gl->tex_info.coord; @@ -1617,7 +1612,7 @@ static INLINE void gl_set_shader_viewport(gl_t *gl, unsigned idx) shader_info.idx = idx; shader_info.set_active = true; - video_shader_driver_ctl(SHADER_CTL_USE, &shader_info); + video_shader_driver_use(&shader_info); gl_set_viewport(gl, width, height, false, true); } @@ -1696,19 +1691,19 @@ static INLINE void gl_draw_texture(gl_t *gl) shader_info.idx = VIDEO_SHADER_STOCK_BLEND; shader_info.set_active = true; - video_shader_driver_ctl(SHADER_CTL_USE, &shader_info); + video_shader_driver_use(&shader_info); gl->coords.vertices = 4; coords.handle_data = NULL; coords.data = &gl->coords; - video_shader_driver_ctl(SHADER_CTL_SET_COORDS, &coords); + video_shader_driver_set_coords(&coords); mvp.data = gl; mvp.matrix = &gl->mvp_no_rot; - video_shader_driver_ctl(SHADER_CTL_SET_MVP, &mvp); + video_shader_driver_set_mvp(&mvp); glEnable(GL_BLEND); @@ -1767,7 +1762,7 @@ static bool gl_frame(void *data, const void *frame, shader_info.idx = 1; shader_info.set_active = true; - video_shader_driver_ctl(SHADER_CTL_USE, &shader_info); + video_shader_driver_use(&shader_info); #ifdef IOS /* Apparently the viewport is lost each frame, thanks Apple. */ @@ -1899,18 +1894,18 @@ static bool gl_frame(void *data, const void *frame, params.fbo_info = NULL; params.fbo_info_cnt = 0; - video_shader_driver_ctl(SHADER_CTL_SET_PARAMS, ¶ms); + video_shader_driver_set_parameters(¶ms); gl->coords.vertices = 4; coords.handle_data = NULL; coords.data = &gl->coords; - video_shader_driver_ctl(SHADER_CTL_SET_COORDS, &coords); + video_shader_driver_set_coords(&coords); mvp.data = gl; mvp.matrix = &gl->mvp; - video_shader_driver_ctl(SHADER_CTL_SET_MVP, &mvp); + video_shader_driver_set_mvp(&mvp); glDrawArrays(GL_TRIANGLE_STRIP, 0, 4); @@ -1950,7 +1945,7 @@ static bool gl_frame(void *data, const void *frame, shader_info.idx = 0; shader_info.set_active = true; - video_shader_driver_ctl(SHADER_CTL_USE, &shader_info); + video_shader_driver_use(&shader_info); glBindTexture(GL_TEXTURE_2D, 0); #ifndef NO_GL_FF_VERTEX @@ -2076,7 +2071,7 @@ static void gl_free(void *data) if (font_driver_has_render_msg()) font_driver_free(NULL); - gl_shader_deinit(gl); + video_shader_driver_deinit(); #ifndef NO_GL_FF_VERTEX gl_disable_client_arrays(gl); @@ -2727,10 +2722,10 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo hwr->version_major, hwr->version_minor); #endif - if (!video_shader_driver_ctl(SHADER_CTL_INIT_FIRST, NULL)) + if (!video_shader_driver_init_first()) goto error; - video_shader_driver_ctl(SHADER_CTL_GET_IDENT, &ident_info); + video_shader_driver_get_ident(&ident_info); RARCH_LOG("[GL]: Default shader backend found: %s.\n", ident_info.ident); @@ -2744,13 +2739,13 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo unsigned minimum; video_shader_ctx_texture_t texture_info; - video_shader_driver_ctl(SHADER_CTL_GET_PREV_TEXTURES, &texture_info); + video_shader_driver_get_prev_textures(&texture_info); minimum = texture_info.id; gl->textures = MAX(minimum + 1, gl->textures); } - if (!video_shader_driver_ctl(SHADER_CTL_INFO, &shader_info)) + if (!video_shader_driver_info(&shader_info)) goto error; RARCH_LOG("[GL]: Using %u textures.\n", gl->textures); @@ -2766,13 +2761,11 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo gl_set_shader_viewport(gl, 1); mip_level = 1; - gl->tex_mipmap = video_shader_driver_ctl(SHADER_CTL_MIPMAP_INPUT, - &mip_level); - + gl->tex_mipmap = video_shader_driver_mipmap_input(&mip_level); shader_filter.index = 1; shader_filter.smooth = &force_smooth; - if (video_shader_driver_ctl(SHADER_CTL_FILTER_TYPE, &shader_filter)) + if (video_shader_driver_filter_type(&shader_filter)) gl->tex_min_filter = gl->tex_mipmap ? (force_smooth ? GL_LINEAR_MIPMAP_LINEAR : GL_NEAREST_MIPMAP_NEAREST) : (force_smooth ? GL_LINEAR : GL_NEAREST); @@ -2785,7 +2778,7 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo wrap_info.idx = 1; - video_shader_driver_ctl(SHADER_CTL_WRAP_TYPE, &wrap_info); + video_shader_driver_wrap_type(&wrap_info); gl->wrap_mode = gl_wrap_type_to_enum(wrap_info.type); @@ -2926,18 +2919,16 @@ static void gl_update_tex_filter_frame(gl_t *gl) shader_filter.index = 1; shader_filter.smooth = &smooth; - if (!video_shader_driver_ctl(SHADER_CTL_FILTER_TYPE, &shader_filter)) + if (!video_shader_driver_filter_type(&shader_filter)) smooth = settings->video.smooth; mip_level = 1; wrap_info.idx = 1; - video_shader_driver_ctl(SHADER_CTL_WRAP_TYPE, &wrap_info); + video_shader_driver_wrap_type(&wrap_info); - wrap_mode = gl_wrap_type_to_enum(wrap_info.type); - - gl->tex_mipmap = video_shader_driver_ctl(SHADER_CTL_MIPMAP_INPUT, - &mip_level); + wrap_mode = gl_wrap_type_to_enum(wrap_info.type); + gl->tex_mipmap = video_shader_driver_mipmap_input(&mip_level); gl->video_info.smooth = smooth; new_filt = gl->tex_mipmap ? (smooth ? @@ -2984,7 +2975,7 @@ static bool gl_set_shader(void *data, if (type == RARCH_SHADER_NONE) return false; - gl_shader_deinit(gl); + video_shader_driver_deinit(); switch (type) { @@ -3013,11 +3004,11 @@ static bool gl_set_shader(void *data, init_data.data = gl; init_data.path = path; - if (!video_shader_driver_ctl(SHADER_CTL_INIT, &init_data)) + if (!video_shader_driver_init(&init_data)) { init_data.path = NULL; - video_shader_driver_ctl(SHADER_CTL_INIT, &init_data); + video_shader_driver_init(&init_data); RARCH_WARN("[GL]: Failed to set multipass shader. Falling back to stock.\n"); @@ -3026,7 +3017,7 @@ static bool gl_set_shader(void *data, gl_update_tex_filter_frame(gl); - video_shader_driver_ctl(SHADER_CTL_GET_PREV_TEXTURES, &texture_info); + video_shader_driver_get_prev_textures(&texture_info); textures = texture_info.id + 1; @@ -3514,7 +3505,7 @@ static void gl_render_overlay(gl_t *gl) shader_info.idx = VIDEO_SHADER_STOCK_BLEND; shader_info.set_active = true; - video_shader_driver_ctl(SHADER_CTL_USE, &shader_info); + video_shader_driver_use(&shader_info); gl->coords.vertex = gl->overlay_vertex_coord; gl->coords.tex_coord = gl->overlay_tex_coord; @@ -3524,12 +3515,12 @@ static void gl_render_overlay(gl_t *gl) coords.handle_data = NULL; coords.data = &gl->coords; - video_shader_driver_ctl(SHADER_CTL_SET_COORDS, &coords); + video_shader_driver_set_coords(&coords); mvp.data = gl; mvp.matrix = &gl->mvp_no_rot; - video_shader_driver_ctl(SHADER_CTL_SET_MVP, &mvp); + video_shader_driver_set_mvp(&mvp); for (i = 0; i < gl->overlays; i++) { @@ -3684,7 +3675,7 @@ static struct video_shader *gl_get_current_shader(void *data) { video_shader_ctx_t shader_info; - video_shader_driver_ctl(SHADER_CTL_DIRECT_GET_CURRENT_SHADER, &shader_info); + video_shader_driver_direct_get_current_shader(&shader_info); return shader_info.data; } diff --git a/gfx/drivers_font/gl_raster_font.c b/gfx/drivers_font/gl_raster_font.c index ba730f413c..911a2541e9 100644 --- a/gfx/drivers_font/gl_raster_font.c +++ b/gfx/drivers_font/gl_raster_font.c @@ -237,12 +237,12 @@ static void gl_raster_font_draw_vertices(gl_t *gl, const gfx_coords_t *coords) coords_data.handle_data = NULL; coords_data.data = coords; - video_shader_driver_ctl(SHADER_CTL_SET_COORDS, &coords_data); + video_shader_driver_set_coords(&coords_data); mvp.data = gl; mvp.matrix = &gl->mvp_no_rot; - video_shader_driver_ctl(SHADER_CTL_SET_MVP, &mvp); + video_shader_driver_set_mvp(&mvp); glDrawArrays(GL_TRIANGLES, 0, coords->vertices); } @@ -406,7 +406,7 @@ static void gl_raster_font_setup_viewport(gl_raster_t *font, bool full_screen) shader_info.idx = VIDEO_SHADER_STOCK_BLEND; shader_info.set_active = true; - video_shader_driver_ctl(SHADER_CTL_USE, &shader_info); + video_shader_driver_use(&shader_info); } static void gl_raster_font_restore_viewport(gl_t *gl) diff --git a/gfx/video_shader_driver.c b/gfx/video_shader_driver.c index 6257da50f7..68beed7855 100644 --- a/gfx/video_shader_driver.c +++ b/gfx/video_shader_driver.c @@ -34,6 +34,9 @@ static const shader_backend_t *shader_ctx_drivers[] = { NULL }; +static const shader_backend_t *current_shader = NULL; +static void *shader_data = NULL; + static const shader_backend_t *video_shader_set_backend(enum rarch_shader_type type) { switch (type) @@ -72,238 +75,224 @@ static const shader_backend_t *video_shader_set_backend(enum rarch_shader_type t return NULL; } -bool video_shader_driver_ctl(enum video_shader_driver_ctl_state state, void *data) +bool video_shader_driver_get_prev_textures(video_shader_ctx_texture_t *texture) { - static const shader_backend_t *current_shader = NULL; - static void *shader_data = NULL; - - switch (state) + if (!!texture || !current_shader) { - case SHADER_CTL_GET_PREV_TEXTURES: - { - video_shader_ctx_texture_t *texture = (video_shader_ctx_texture_t*)data; - if (!!texture || !current_shader) - { - texture->id = 0; - return false; - } - texture->id = current_shader->get_prev_textures(shader_data); - } - break; - case SHADER_CTL_GET_IDENT: - { - video_shader_ctx_ident_t *ident = (video_shader_ctx_ident_t*)data; - if (!current_shader || !ident) - return false; - ident->ident = current_shader->ident; - } - break; - case SHADER_CTL_GET_CURRENT_SHADER: - { - video_shader_ctx_t *shader = (video_shader_ctx_t*)data; - void *video_driver = video_driver_get_ptr(false); - const video_poke_interface_t *video_poke = video_driver_get_poke(); - - shader->data = NULL; - if (!video_poke || !video_driver) - return false; - if (!video_poke->get_current_shader) - return false; - shader->data = video_poke->get_current_shader(video_driver); - } - break; - case SHADER_CTL_DIRECT_GET_CURRENT_SHADER: - { - video_shader_ctx_t *shader = (video_shader_ctx_t*)data; - - shader->data = NULL; - if (!current_shader || !current_shader->get_current_shader) - return false; - - shader->data = current_shader->get_current_shader(shader_data); - } - break; - case SHADER_CTL_DEINIT: - if (!current_shader) - return false; - - if (current_shader->deinit) - current_shader->deinit(shader_data); - - shader_data = NULL; - current_shader = NULL; - break; - case SHADER_CTL_SET_PARAMETER: - { - struct uniform_info *param = (struct uniform_info*)data; - - if (!current_shader || !param) - return false; - current_shader->set_uniform_parameter(shader_data, - param, NULL); - } - break; - case SHADER_CTL_SET_PARAMS: - { - video_shader_ctx_params_t *params = - (video_shader_ctx_params_t*)data; - - if (!current_shader || !current_shader->set_params) - return false; - current_shader->set_params( - params->data, - shader_data, - params->width, - params->height, - params->tex_width, - params->tex_height, - params->out_width, - params->out_height, - params->frame_counter, - params->info, - params->prev_info, - params->feedback_info, - params->fbo_info, - params->fbo_info_cnt); - } - break; - /* Finds first suitable shader context driver. */ - case SHADER_CTL_INIT_FIRST: - { - unsigned i; - - for (i = 0; shader_ctx_drivers[i]; i++) - { - current_shader = shader_ctx_drivers[i]; - return true; - } - } - return false; - case SHADER_CTL_INIT: - { - video_shader_ctx_init_t *init = (video_shader_ctx_init_t*)data; - void *tmp = NULL; - - if (!init->shader || !init->shader->init) - { - init->shader = video_shader_set_backend(init->shader_type); - - if (!init->shader) - return false; - } - - tmp = init->shader->init(init->data, init->path); - - if (!tmp) - return false; - - shader_data = tmp; - current_shader = init->shader; - } - break; - case SHADER_CTL_GET_FEEDBACK_PASS: - if (!current_shader || !current_shader->get_feedback_pass) - return false; - if (!current_shader->get_feedback_pass(shader_data, - (unsigned*)data)) - return false; - break; - case SHADER_CTL_MIPMAP_INPUT: - if (!current_shader) - return false; - { - unsigned *index = (unsigned*)data; - if (!current_shader->mipmap_input(shader_data, *index)) - return false; - } - break; - case SHADER_CTL_SET_COORDS: - { - video_shader_ctx_coords_t *coords = (video_shader_ctx_coords_t*) - data; - if (!current_shader || !current_shader->set_coords) - return false; - if (!current_shader->set_coords(coords->handle_data, - shader_data, (const struct gfx_coords*)coords->data)) - return false; - } - break; - case SHADER_CTL_SCALE: - { - video_shader_ctx_scale_t *scaler = (video_shader_ctx_scale_t*)data; - if (!scaler || !scaler->scale) - return false; - - scaler->scale->valid = false; - - if (!current_shader || !current_shader->shader_scale) - return false; - - current_shader->shader_scale(shader_data, scaler->idx, scaler->scale); - } - break; - case SHADER_CTL_INFO: - { - video_shader_ctx_info_t *shader_info = - (video_shader_ctx_info_t*)data; - if (!shader_info || !current_shader) - return false; - - shader_info->num = 0; - if (current_shader->num_shaders) - shader_info->num = current_shader->num_shaders(shader_data); - } - break; - case SHADER_CTL_SET_MVP: - { - video_shader_ctx_mvp_t *mvp = (video_shader_ctx_mvp_t*)data; - if (!current_shader || !current_shader->set_mvp) - return false; - if (!mvp || !mvp->matrix) - return false; - if (!current_shader->set_mvp(mvp->data, shader_data, mvp->matrix)) - return false; - } - break; - case SHADER_CTL_FILTER_TYPE: - { - video_shader_ctx_filter_t *filter = - (video_shader_ctx_filter_t*)data; - if (!current_shader || !current_shader->filter_type || !filter) - return false; - if (!current_shader->filter_type(shader_data, - filter->index, filter->smooth)) - return false; - } - break; - case SHADER_CTL_COMPILE_PROGRAM: - { - struct shader_program_info *program_info = (struct shader_program_info*)data; - if (!current_shader || !program_info) - return false; - return current_shader->compile_program(program_info->data, - program_info->idx, NULL, program_info); - } - case SHADER_CTL_USE: - { - video_shader_ctx_info_t *shader_info = (video_shader_ctx_info_t*)data; - if (!current_shader || !shader_info) - return false; - current_shader->use(shader_info->data, shader_data, shader_info->idx, shader_info->set_active); - } - break; - case SHADER_CTL_WRAP_TYPE: - { - video_shader_ctx_wrap_t *wrap = (video_shader_ctx_wrap_t*)data; - if (!current_shader || !current_shader->wrap_type) - return false; - wrap->type = current_shader->wrap_type(shader_data, wrap->idx); - } - break; - case SHADER_CTL_NONE: - default: - break; + texture->id = 0; + return false; } + texture->id = current_shader->get_prev_textures(shader_data); return true; } + +bool video_shader_driver_get_ident(video_shader_ctx_ident_t *ident) +{ + if (!current_shader || !ident) + return false; + ident->ident = current_shader->ident; + return true; +} + +bool video_shader_driver_get_current_shader(video_shader_ctx_t *shader) +{ + void *video_driver = video_driver_get_ptr(false); + const video_poke_interface_t *video_poke = video_driver_get_poke(); + + shader->data = NULL; + if (!video_poke || !video_driver) + return false; + if (!video_poke->get_current_shader) + return false; + shader->data = video_poke->get_current_shader(video_driver); + return true; +} + +bool video_shader_driver_direct_get_current_shader(video_shader_ctx_t *shader) +{ + shader->data = NULL; + if (!current_shader || !current_shader->get_current_shader) + return false; + + shader->data = current_shader->get_current_shader(shader_data); + return true; +} + +bool video_shader_driver_deinit(void) +{ + if (!current_shader) + return false; + + if (current_shader->deinit) + current_shader->deinit(shader_data); + + shader_data = NULL; + current_shader = NULL; + return true; +} + +bool video_shader_driver_set_parameter(struct uniform_info *param) +{ + if (!current_shader || !param) + return false; + current_shader->set_uniform_parameter(shader_data, + param, NULL); + return true; +} + +bool video_shader_driver_set_parameters(video_shader_ctx_params_t *params) +{ + if (!current_shader || !current_shader->set_params) + return false; + current_shader->set_params( + params->data, + shader_data, + params->width, + params->height, + params->tex_width, + params->tex_height, + params->out_width, + params->out_height, + params->frame_counter, + params->info, + params->prev_info, + params->feedback_info, + params->fbo_info, + params->fbo_info_cnt); + return true; +} + +/* Finds first suitable shader context driver. */ +bool video_shader_driver_init_first(void) +{ + unsigned i; + + for (i = 0; shader_ctx_drivers[i]; i++) + { + current_shader = shader_ctx_drivers[i]; + return true; + } + return false; +} + +bool video_shader_driver_init(video_shader_ctx_init_t *init) +{ + void *tmp = NULL; + + if (!init->shader || !init->shader->init) + { + init->shader = video_shader_set_backend(init->shader_type); + + if (!init->shader) + return false; + } + + tmp = init->shader->init(init->data, init->path); + + if (!tmp) + return false; + + shader_data = tmp; + current_shader = init->shader; + + return true; +} + +bool video_shader_driver_get_feedback_pass(unsigned *data) +{ + if (!current_shader || !current_shader->get_feedback_pass) + return false; + if (!current_shader->get_feedback_pass(shader_data, data)) + return false; + return true; +} + +bool video_shader_driver_mipmap_input(unsigned *index) +{ + if (!current_shader) + return false; + if (!current_shader->mipmap_input(shader_data, *index)) + return false; + return true; +} + +bool video_shader_driver_set_coords(video_shader_ctx_coords_t *coords) +{ + if (!current_shader || !current_shader->set_coords) + return false; + if (!current_shader->set_coords(coords->handle_data, + shader_data, (const struct gfx_coords*)coords->data)) + return false; + return true; +} + +bool video_shader_driver_scale(video_shader_ctx_scale_t *scaler) +{ + if (!scaler || !scaler->scale) + return false; + + scaler->scale->valid = false; + + if (!current_shader || !current_shader->shader_scale) + return false; + + current_shader->shader_scale(shader_data, scaler->idx, scaler->scale); + return true; +} + +bool video_shader_driver_info(video_shader_ctx_info_t *shader_info) +{ + if (!shader_info || !current_shader) + return false; + + shader_info->num = 0; + if (current_shader->num_shaders) + shader_info->num = current_shader->num_shaders(shader_data); + return true; +} + +bool video_shader_driver_set_mvp(video_shader_ctx_mvp_t *mvp) +{ + if (!current_shader || !current_shader->set_mvp) + return false; + if (!mvp || !mvp->matrix) + return false; + if (!current_shader->set_mvp(mvp->data, shader_data, mvp->matrix)) + return false; + return true; +} + +bool video_shader_driver_filter_type(video_shader_ctx_filter_t *filter) +{ + if (!current_shader || !current_shader->filter_type || !filter) + return false; + if (!current_shader->filter_type(shader_data, + filter->index, filter->smooth)) + return false; + return true; +} + +bool video_shader_driver_compile_program(struct shader_program_info *program_info) +{ + if (!current_shader || !program_info) + return false; + return current_shader->compile_program(program_info->data, + program_info->idx, NULL, program_info); +} + +bool video_shader_driver_use(video_shader_ctx_info_t *shader_info) +{ + if (!current_shader || !shader_info) + return false; + current_shader->use(shader_info->data, shader_data, shader_info->idx, shader_info->set_active); + return true; +} + +bool video_shader_driver_wrap_type(video_shader_ctx_wrap_t *wrap) +{ + if (!current_shader || !current_shader->wrap_type) + return false; + wrap->type = current_shader->wrap_type(shader_data, wrap->idx); + return true; +} diff --git a/gfx/video_shader_driver.h b/gfx/video_shader_driver.h index ad8ad4b6dc..426f3ac567 100644 --- a/gfx/video_shader_driver.h +++ b/gfx/video_shader_driver.h @@ -55,31 +55,6 @@ extern "C" { #endif -enum video_shader_driver_ctl_state -{ - SHADER_CTL_NONE = 0, - SHADER_CTL_DEINIT, - SHADER_CTL_INIT, - /* Finds first suitable shader context driver. */ - SHADER_CTL_INIT_FIRST, - SHADER_CTL_SET_PARAMETER, - SHADER_CTL_SET_PARAMS, - SHADER_CTL_GET_FEEDBACK_PASS, - SHADER_CTL_MIPMAP_INPUT, - SHADER_CTL_SET_COORDS, - SHADER_CTL_COMPILE_PROGRAM, - SHADER_CTL_SCALE, - SHADER_CTL_INFO, - SHADER_CTL_SET_MVP, - SHADER_CTL_FILTER_TYPE, - SHADER_CTL_USE, - SHADER_CTL_WRAP_TYPE, - SHADER_CTL_GET_CURRENT_SHADER, - SHADER_CTL_DIRECT_GET_CURRENT_SHADER, - SHADER_CTL_GET_IDENT, - SHADER_CTL_GET_PREV_TEXTURES -}; - enum shader_uniform_type { UNIFORM_1F = 0, @@ -283,13 +258,49 @@ typedef struct video_shader_ctx_texture unsigned id; } video_shader_ctx_texture_t; +bool video_shader_driver_get_prev_textures(video_shader_ctx_texture_t *texture); + +bool video_shader_driver_get_ident(video_shader_ctx_ident_t *ident); + +bool video_shader_driver_get_current_shader(video_shader_ctx_t *shader); + +bool video_shader_driver_direct_get_current_shader(video_shader_ctx_t *shader); + +bool video_shader_driver_deinit(void); + +bool video_shader_driver_set_parameter(struct uniform_info *param); + +bool video_shader_driver_set_parameters(video_shader_ctx_params_t *params); + +bool video_shader_driver_init_first(void); + +bool video_shader_driver_init(video_shader_ctx_init_t *init); + +bool video_shader_driver_get_feedback_pass(unsigned *data); + +bool video_shader_driver_mipmap_input(unsigned *index); + +bool video_shader_driver_set_coords(video_shader_ctx_coords_t *coords); + +bool video_shader_driver_scale(video_shader_ctx_scale_t *scaler); + +bool video_shader_driver_info(video_shader_ctx_info_t *shader_info); + +bool video_shader_driver_set_mvp(video_shader_ctx_mvp_t *mvp); + +bool video_shader_driver_filter_type(video_shader_ctx_filter_t *filter); + +bool video_shader_driver_compile_program(struct shader_program_info *program_info); + +bool video_shader_driver_use(video_shader_ctx_info_t *shader_info); + +bool video_shader_driver_wrap_type(video_shader_ctx_wrap_t *wrap); + extern const shader_backend_t gl_glsl_backend; extern const shader_backend_t hlsl_backend; extern const shader_backend_t gl_cg_backend; extern const shader_backend_t shader_null_backend; -bool video_shader_driver_ctl(enum video_shader_driver_ctl_state state, void *data); - #ifdef __cplusplus } #endif diff --git a/menu/cbs/menu_cbs_get_value.c b/menu/cbs/menu_cbs_get_value.c index 9669054084..c5650962d3 100644 --- a/menu/cbs/menu_cbs_get_value.c +++ b/menu/cbs/menu_cbs_get_value.c @@ -296,7 +296,7 @@ static void menu_action_setting_disp_set_label_shader_parameter( strlcpy(s2, path, len2); #if defined(HAVE_CG) || defined(HAVE_GLSL) || defined(HAVE_HLSL) - video_shader_driver_ctl(SHADER_CTL_GET_CURRENT_SHADER, &shader_info); + video_shader_driver_get_current_shader(&shader_info); if (!shader_info.data) return; diff --git a/menu/cbs/menu_cbs_left.c b/menu/cbs/menu_cbs_left.c index ab23bbe1bc..b550379054 100644 --- a/menu/cbs/menu_cbs_left.c +++ b/menu/cbs/menu_cbs_left.c @@ -56,7 +56,7 @@ static int shader_action_parameter_left(unsigned type, const char *label, video_shader_ctx_t shader_info; struct video_shader_parameter *param = NULL; - video_shader_driver_ctl(SHADER_CTL_GET_CURRENT_SHADER, &shader_info); + video_shader_driver_get_current_shader(&shader_info); param = &shader_info.data->parameters[type - MENU_SETTINGS_SHADER_PARAMETER_0]; return generic_shader_action_parameter_left(shader_info.data, param, type, label, wraparound); diff --git a/menu/cbs/menu_cbs_right.c b/menu/cbs/menu_cbs_right.c index 47b865482b..d17a4442dd 100644 --- a/menu/cbs/menu_cbs_right.c +++ b/menu/cbs/menu_cbs_right.c @@ -59,7 +59,7 @@ int shader_action_parameter_right(unsigned type, const char *label, bool wraparo video_shader_ctx_t shader_info; struct video_shader_parameter *param = NULL; - video_shader_driver_ctl(SHADER_CTL_GET_CURRENT_SHADER, &shader_info); + video_shader_driver_get_current_shader(&shader_info); param = &shader_info.data->parameters[type - MENU_SETTINGS_SHADER_PARAMETER_0]; return generic_shader_action_parameter_right(shader_info.data, param, type, label, wraparound); diff --git a/menu/cbs/menu_cbs_start.c b/menu/cbs/menu_cbs_start.c index a03248fe32..e74b324271 100644 --- a/menu/cbs/menu_cbs_start.c +++ b/menu/cbs/menu_cbs_start.c @@ -119,7 +119,7 @@ static int action_start_shader_action_parameter(unsigned type, const char *label video_shader_ctx_t shader_info; struct video_shader_parameter *param = NULL; - video_shader_driver_ctl(SHADER_CTL_GET_CURRENT_SHADER, &shader_info); + video_shader_driver_get_current_shader(&shader_info); if (!shader_info.data) return 0; diff --git a/menu/drivers/nk_common.c b/menu/drivers/nk_common.c index 1edd4f6e16..9ecd9ed46a 100644 --- a/menu/drivers/nk_common.c +++ b/menu/drivers/nk_common.c @@ -190,7 +190,7 @@ void nk_common_device_draw(struct nk_device *dev, shader_info.data = NULL; shader_info.idx = dev->prog; shader_info.set_active = false; - video_shader_driver_ctl(SHADER_CTL_USE, &shader_info); + video_shader_driver_use(&shader_info); #if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) glUniformMatrix4fv(dev->uniform_proj, 1, GL_FALSE, &ortho[0][0]); @@ -253,7 +253,7 @@ void nk_common_device_draw(struct nk_device *dev, shader_info.data = NULL; shader_info.idx = (GLint)last_prog; shader_info.set_active = false; - video_shader_driver_ctl(SHADER_CTL_USE, &shader_info); + video_shader_driver_use(&shader_info); #if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) glBindTexture(GL_TEXTURE_2D, (GLuint)last_tex); diff --git a/menu/drivers/nk_menu.c b/menu/drivers/nk_menu.c index f741f6f8c6..bf16cf3c89 100644 --- a/menu/drivers/nk_menu.c +++ b/menu/drivers/nk_menu.c @@ -314,7 +314,7 @@ void nk_menu_wnd_shader_parameters(nk_menu_handle_t *zr) nk_layout_row_dynamic(ctx, 30, 1); - video_shader_driver_ctl(SHADER_CTL_GET_CURRENT_SHADER, &shader_info); + video_shader_driver_get_current_shader(&shader_info); if (shader_info.data) { diff --git a/menu/drivers_display/menu_display_d3d.cpp b/menu/drivers_display/menu_display_d3d.cpp index fe00476e51..dd7336b4f2 100644 --- a/menu/drivers_display/menu_display_d3d.cpp +++ b/menu/drivers_display/menu_display_d3d.cpp @@ -201,7 +201,7 @@ static void menu_display_d3d_draw_pipeline(void *data) shader_info.idx = draw->pipeline.id; shader_info.set_active = true; - video_shader_driver_ctl(SHADER_CTL_USE, &shader_info); + video_shader_driver_use(&shader_info); t += 0.01; @@ -214,7 +214,7 @@ static void menu_display_d3d_draw_pipeline(void *data) uniform_param.lookup.ident = "time"; uniform_param.result.f.v0 = t; - video_shader_driver_ctl(SHADER_CTL_SET_PARAMETER, &uniform_param); + video_shader_driver_set_parameter(&uniform_param); break; } #endif diff --git a/menu/drivers_display/menu_display_gl.c b/menu/drivers_display/menu_display_gl.c index 13bb13beb0..93f41b37e0 100644 --- a/menu/drivers_display/menu_display_gl.c +++ b/menu/drivers_display/menu_display_gl.c @@ -86,7 +86,7 @@ static void menu_display_gl_blend_begin(void) shader_info.idx = VIDEO_SHADER_STOCK_BLEND; shader_info.set_active = true; - video_shader_driver_ctl(SHADER_CTL_USE, &shader_info); + video_shader_driver_use(&shader_info); } static void menu_display_gl_blend_end(void) @@ -137,13 +137,13 @@ static void menu_display_gl_draw(void *data) coords.handle_data = gl; coords.data = draw->coords; - video_shader_driver_ctl(SHADER_CTL_SET_COORDS, &coords); + video_shader_driver_set_coords(&coords); mvp.data = gl; mvp.matrix = draw->matrix_data ? (math_matrix_4x4*)draw->matrix_data : (math_matrix_4x4*)menu_display_gl_get_default_mvp(); - video_shader_driver_ctl(SHADER_CTL_SET_MVP, &mvp); + video_shader_driver_set_mvp(&mvp); glDrawArrays(menu_display_prim_to_gl_enum( draw->prim_type), 0, draw->coords->vertices); @@ -175,7 +175,7 @@ static void menu_display_gl_draw_pipeline(void *data) shader_info.idx = draw->pipeline.id; shader_info.set_active = true; - video_shader_driver_ctl(SHADER_CTL_USE, &shader_info); + video_shader_driver_use(&shader_info); t += 0.01; @@ -188,7 +188,7 @@ static void menu_display_gl_draw_pipeline(void *data) uniform_param.lookup.ident = "time"; uniform_param.result.f.v0 = t; - video_shader_driver_ctl(SHADER_CTL_SET_PARAMETER, &uniform_param); + video_shader_driver_set_parameter(&uniform_param); break; } #endif diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 8ee67182b9..965d5eaaf6 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -3620,7 +3620,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) case DISPLAYLIST_SHADER_PARAMETERS: case DISPLAYLIST_SHADER_PARAMETERS_PRESET: #ifdef HAVE_SHADER_MANAGER - video_shader_driver_ctl(SHADER_CTL_GET_CURRENT_SHADER, &shader_info); + video_shader_driver_get_current_shader(&shader_info); if (shader_info.data) ret = deferred_push_video_shader_parameters_common( diff --git a/ui/drivers/ui_win32.c b/ui/drivers/ui_win32.c index 3f35adcdb2..c433833b73 100644 --- a/ui/drivers/ui_win32.c +++ b/ui/drivers/ui_win32.c @@ -121,7 +121,7 @@ static void shader_dlg_refresh_trackbar_label(int index) video_shader_ctx_t shader_info; char val_buffer[32] = {0}; - video_shader_driver_ctl(SHADER_CTL_GET_CURRENT_SHADER, &shader_info); + video_shader_driver_get_current_shader(&shader_info); if (floorf(shader_info.data->parameters[index].current) == shader_info.data->parameters[index].current) @@ -141,7 +141,7 @@ static void shader_dlg_params_refresh(void) int i; video_shader_ctx_t shader_info; - video_shader_driver_ctl(SHADER_CTL_GET_CURRENT_SHADER, &shader_info); + video_shader_driver_get_current_shader(&shader_info); for (i = 0; i < GFX_MAX_PARAMETERS; i++) { @@ -218,7 +218,7 @@ void shader_dlg_params_reload(void) int i, pos_x, pos_y; video_shader_ctx_t shader_info; - video_shader_driver_ctl(SHADER_CTL_GET_CURRENT_SHADER, &shader_info); + video_shader_driver_get_current_shader(&shader_info); shader_dlg_params_clear(); @@ -353,7 +353,7 @@ static LRESULT CALLBACK ShaderDlgWndProc(HWND hwnd, UINT message, int i, pos; video_shader_ctx_t shader_info; - video_shader_driver_ctl(SHADER_CTL_GET_CURRENT_SHADER, &shader_info); + video_shader_driver_get_current_shader(&shader_info); switch (message) { From 3002777196a11a034af8330c306b621c363d262e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 21:30:06 +0200 Subject: [PATCH 292/498] Bugfix --- command_event.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/command_event.c b/command_event.c index eed8c4fdf8..cb1325601c 100644 --- a/command_event.c +++ b/command_event.c @@ -1218,7 +1218,7 @@ bool event_cmd_ctl(enum event_command cmd, void *data) return false; break; case EVENT_CMD_AUDIO_START: - if (!audio_driver_alive()) + if (audio_driver_alive()) return false; if (!settings->audio.mute_enable && !audio_driver_start()) From 737e2832f2469ca541f57419332ee2e35ef34424 Mon Sep 17 00:00:00 2001 From: Torsten Paul Date: Sun, 8 May 2016 21:55:46 +0200 Subject: [PATCH 293/498] Fix typos in VideoCore driver causing compile error on Raspberry Pi. --- gfx/drivers/vg.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/gfx/drivers/vg.c b/gfx/drivers/vg.c index ba1e91198c..59bc5831c1 100644 --- a/gfx/drivers/vg.c +++ b/gfx/drivers/vg.c @@ -70,7 +70,7 @@ static PFNVGCREATEEGLIMAGETARGETKHRPROC pvgCreateEGLImageTargetKHR; static void vg_set_nonblock_state(void *data, bool state) { unsigned interval = state ? 0 : 1; - video_context_driver_set_swap_interval(&interval); + video_context_driver_swap_interval(&interval); } static INLINE bool vg_query_extension(const char *ext) @@ -137,7 +137,7 @@ static void *vg_init(const video_info_t *video, mode.height = win_height; mode.fullscreen = video->fullscreen; - if (!vidoe_context_driver_set_video_mode(&mode)) + if (!video_context_driver_set_video_mode(&mode)) goto error; video_driver_get_size(&temp_width, &temp_height); From 7341501e7e69d8759cbc8a919636bdd25f33b26f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Mon, 9 May 2016 02:58:35 +0700 Subject: [PATCH 294/498] (XMB) Disable an optimization bug fixes a display bug --- menu/drivers/xmb.c | 7 ------- 1 file changed, 7 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 51f80e8b15..c13fe39a03 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -737,7 +737,6 @@ static void xmb_update_thumbnail_image(void *data) static void xmb_selection_pointer_changed( xmb_handle_t *xmb, bool allow_animations) { - size_t skip; unsigned i, end, height, depth; menu_animation_ctx_tag_t tag; size_t selection, num = 0; @@ -761,7 +760,6 @@ static void xmb_selection_pointer_changed( menu_animation_ctl(MENU_ANIMATION_CTL_KILL_BY_TAG, &tag); menu_entries_ctl(MENU_ENTRIES_CTL_SET_START, &num); - skip = 0; for (i = 0; i < end; i++) { @@ -790,9 +788,6 @@ static void xmb_selection_pointer_changed( } } - if (real_iy < -threshold) - skip++; - if ( (!allow_animations) || (real_iy < -threshold || real_iy > height+threshold)) @@ -829,8 +824,6 @@ static void xmb_selection_pointer_changed( menu_animation_ctl(MENU_ANIMATION_CTL_PUSH, &entry); } } - - menu_entries_ctl(MENU_ENTRIES_CTL_SET_START, &skip); } static void xmb_list_open_old(xmb_handle_t *xmb, From 9c1885a46ea3dd5a34e1ad885f6961b18a31ece0 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 22:00:30 +0200 Subject: [PATCH 295/498] Fix Display FPS --- 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 430a1891e5..69e362e189 100644 --- a/gfx/common/x11_common.c +++ b/gfx/common/x11_common.c @@ -554,7 +554,7 @@ void x11_update_window_title(void *data) char buf_fps[128] = {0}; settings_t *settings = config_get_ptr(); - if (video_monitor_get_fps(buf, sizeof(buf), NULL, 0)) + if (video_monitor_get_fps(buf, sizeof(buf), buf_fps, sizeof(buf_fps))) XStoreName(g_x11_dpy, g_x11_win, buf); if (settings->fps_show) runloop_msg_queue_push(buf_fps, 1, 1, false); From 464ed074e2256089bbb55a08f9675b201a1068dd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Mon, 9 May 2016 03:12:54 +0700 Subject: [PATCH 296/498] (XMB) Unhardcode shadow offset --- menu/drivers/xmb.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index c13fe39a03..7c9be4e574 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -71,6 +71,8 @@ #define XMB_ITEM_ACTIVE_ALPHA 1.0 #define XMB_ITEM_PASSIVE_ALPHA 0.85 +#define XMB_SHADOW_OFFSET 2.0 + typedef struct { float alpha; @@ -508,8 +510,8 @@ static void xmb_draw_icon( menu_display_set_alpha(shadow, color[3] * 0.35f); coords.color = shadow; - draw.x = x + 2; - draw.y = height - y - 2; + draw.x = x + XMB_SHADOW_OFFSET; + draw.y = height - y - XMB_SHADOW_OFFSET; menu_display_draw(&draw); } @@ -565,8 +567,8 @@ static void xmb_draw_thumbnail(xmb_handle_t *xmb, float *color, menu_display_set_alpha(shadow, color[3] * 0.35f); coords.color = shadow; - draw.x = x + 2; - draw.y = height - y - 2; + draw.x = x + XMB_SHADOW_OFFSET; + draw.y = height - y - XMB_SHADOW_OFFSET; menu_display_draw(&draw); } @@ -612,8 +614,8 @@ static void xmb_draw_text(xmb_handle_t *xmb, if (settings->menu.xmb_shadows_enable) { - params.drop_x = 2.0f; - params.drop_y = -2.0f; + params.drop_x = XMB_SHADOW_OFFSET; + params.drop_y = -XMB_SHADOW_OFFSET; params.drop_alpha = 0.35f; } From ea53567520a7ee3da5ee6cd190d85f5d31651a3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Mon, 9 May 2016 03:45:38 +0700 Subject: [PATCH 297/498] (XMB) Initial support for the Pixel theme, for Gamegirl --- menu/cbs/menu_cbs_get_value.c | 3 +++ menu/drivers/xmb.c | 2 ++ menu/menu_setting.c | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/menu/cbs/menu_cbs_get_value.c b/menu/cbs/menu_cbs_get_value.c index c5650962d3..d8d95a3b8b 100644 --- a/menu/cbs/menu_cbs_get_value.c +++ b/menu/cbs/menu_cbs_get_value.c @@ -645,6 +645,9 @@ static void menu_action_setting_disp_set_label_xmb_theme( snprintf(s, len, "%s", "RetroActive"); break; case 3: + snprintf(s, len, "%s", "Pixel"); + break; + case 4: snprintf(s, len, "%s", "Custom"); break; } diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 7c9be4e574..5bdbf14f76 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -307,6 +307,8 @@ static const char *xmb_theme_ident(void) case 2: return "retroactive"; case 3: + return "pixel"; + case 4: return "custom"; case 0: default: diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 4d21434843..4082d89f68 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -5958,7 +5958,7 @@ static bool setting_append_list( parent_group, general_write_handler, general_read_handler); - menu_settings_list_current_add_range(list, list_info, 0, 3, 1, true, true); + menu_settings_list_current_add_range(list, list_info, 0, 4, 1, true, true); CONFIG_BOOL( list, list_info, From 08de0c75ebaed111900555f01a19d65e7028940e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Mon, 9 May 2016 03:57:02 +0700 Subject: [PATCH 298/498] (XMB) Variable shadow offset --- menu/drivers/xmb.c | 38 ++++++++++++++++++++++++-------------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 5bdbf14f76..8853d66351 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -71,8 +71,6 @@ #define XMB_ITEM_ACTIVE_ALPHA 1.0 #define XMB_ITEM_PASSIVE_ALPHA 0.85 -#define XMB_SHADOW_OFFSET 2.0 - typedef struct { float alpha; @@ -182,6 +180,8 @@ typedef struct xmb_handle } label; } margins; + float shadow_offset; + char title_name[256]; struct @@ -476,7 +476,8 @@ static void xmb_draw_icon( float alpha, float rotation, float scale_factor, - float *color) + float *color, + float shadow_offset) { menu_display_ctx_draw_t draw; struct gfx_coords coords; @@ -512,8 +513,8 @@ static void xmb_draw_icon( menu_display_set_alpha(shadow, color[3] * 0.35f); coords.color = shadow; - draw.x = x + XMB_SHADOW_OFFSET; - draw.y = height - y - XMB_SHADOW_OFFSET; + draw.x = x + shadow_offset; + draw.y = height - y - shadow_offset; menu_display_draw(&draw); } @@ -569,8 +570,8 @@ static void xmb_draw_thumbnail(xmb_handle_t *xmb, float *color, menu_display_set_alpha(shadow, color[3] * 0.35f); coords.color = shadow; - draw.x = x + XMB_SHADOW_OFFSET; - draw.y = height - y - XMB_SHADOW_OFFSET; + draw.x = x + xmb->shadow_offset; + draw.y = height - y - xmb->shadow_offset; menu_display_draw(&draw); } @@ -616,8 +617,8 @@ static void xmb_draw_text(xmb_handle_t *xmb, if (settings->menu.xmb_shadows_enable) { - params.drop_x = XMB_SHADOW_OFFSET; - params.drop_y = -XMB_SHADOW_OFFSET; + params.drop_x = xmb->shadow_offset; + params.drop_y = -xmb->shadow_offset; params.drop_alpha = 0.35f; } @@ -1835,7 +1836,8 @@ static void xmb_draw_items(xmb_handle_t *xmb, 1.0, rotation, scale_factor, - &color[0]); + &color[0], + xmb->shadow_offset); } menu_display_set_alpha(color, MIN(node->alpha, xmb->alpha)); @@ -1852,7 +1854,9 @@ static void xmb_draw_items(xmb_handle_t *xmb, width, height, node->alpha, 0, - 1, &color[0]); + 1, + &color[0], + xmb->shadow_offset); } menu_display_blend_end(); @@ -2107,7 +2111,8 @@ static void xmb_frame(void *data) 1, 0, 1, - &coord_white[0]); + &coord_white[0], + xmb->shadow_offset); if (settings->menu.timedate_enable) { @@ -2143,7 +2148,9 @@ static void xmb_frame(void *data) height, xmb->textures.arrow.alpha, 0, - 1, &coord_white[0]); + 1, + &coord_white[0], + xmb->shadow_offset); menu_display_blend_begin(); @@ -2190,7 +2197,8 @@ static void xmb_frame(void *data) 1.0, rotation, scale_factor, - &item_color[0]); + &item_color[0], + xmb->shadow_offset); } } @@ -2315,6 +2323,7 @@ static void xmb_layout(xmb_handle_t *xmb) scale_factor = (settings->menu.xmb_scale_factor * width) / (1920.0 * 100); new_font_size = 32.0 * scale_factor; xmb->margins.screen.left = 336.0 * scale_factor; + xmb->shadow_offset = 2.0; /* Mimic the layout of the PSP instead of the PS3 on tiny screens */ if (width <= 640) @@ -2322,6 +2331,7 @@ static void xmb_layout(xmb_handle_t *xmb) scale_factor = scale_factor * 1.5; xmb->margins.screen.left = 136.0 * scale_factor; new_font_size = 42.0 * scale_factor; + xmb->shadow_offset = 1.0; } new_header_height = 128.0 * scale_factor; From dfe9419522707967b43e5e6ec53f3b5741caceaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Mon, 9 May 2016 04:05:11 +0700 Subject: [PATCH 299/498] (XMB) Use variables instead of defines for icon placement --- menu/drivers/xmb.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 8853d66351..9957d83760 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -56,11 +56,6 @@ #define XMB_DELAY 10 #endif -#define XMB_ABOVE_OFFSET_SUBITEM 1.5 -#define XMB_ABOVE_OFFSET_ITEM -1.0 -#define XMB_ITEM_ACTIVE_FACTOR 3.0 -#define XMB_UNDER_OFFSET_ITEM 5.0 - #define XMB_CATEGORIES_ACTIVE_ZOOM 1.0 #define XMB_CATEGORIES_PASSIVE_ZOOM 0.5 #define XMB_ITEM_ACTIVE_ZOOM 1.0 @@ -180,6 +175,10 @@ typedef struct xmb_handle } label; } margins; + float above_subitem_offset; + float above_item_offset; + float active_item_factor; + float under_item_offset; float shadow_offset; char title_name[256]; @@ -453,14 +452,14 @@ static float xmb_item_y(xmb_handle_t *xmb, int i, size_t current) if (i < (int)current) if (xmb->depth > 1) - iy *= (i - (int)current + XMB_ABOVE_OFFSET_SUBITEM); + iy *= (i - (int)current + xmb->above_subitem_offset); else - iy *= (i - (int)current + XMB_ABOVE_OFFSET_ITEM); + iy *= (i - (int)current + xmb->above_item_offset); else - iy *= (i - (int)current + XMB_UNDER_OFFSET_ITEM); + iy *= (i - (int)current + xmb->under_item_offset); if (i == (int)current) - iy = xmb->icon.spacing.vertical * XMB_ITEM_ACTIVE_FACTOR; + iy = xmb->icon.spacing.vertical * xmb->active_item_factor; return iy; } @@ -2143,7 +2142,7 @@ static void xmb_frame(void *data) xmb->icon.spacing.horizontal - xmb->icon.size / 2.0 + xmb->icon.size, xmb->margins.screen.top + xmb->icon.size / 2.0 + xmb->icon.spacing.vertical - * XMB_ITEM_ACTIVE_FACTOR, + * xmb->active_item_factor, width, height, xmb->textures.arrow.alpha, @@ -2325,6 +2324,11 @@ static void xmb_layout(xmb_handle_t *xmb) xmb->margins.screen.left = 336.0 * scale_factor; xmb->shadow_offset = 2.0; + xmb->above_subitem_offset = 1.5; + xmb->above_item_offset = -1.0; + xmb->active_item_factor = 3.0; + xmb->under_item_offset = 5.0; + /* Mimic the layout of the PSP instead of the PS3 on tiny screens */ if (width <= 640) { From aa32b5cc6e6521f73f0666a5b16e11551af1019e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Mon, 9 May 2016 04:09:52 +0700 Subject: [PATCH 300/498] (XMB) Use variables instead of defines for icon zoom. --- menu/drivers/xmb.c | 56 +++++++++++++++++++++++++--------------------- 1 file changed, 31 insertions(+), 25 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 9957d83760..df7dc973f6 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -56,11 +56,6 @@ #define XMB_DELAY 10 #endif -#define XMB_CATEGORIES_ACTIVE_ZOOM 1.0 -#define XMB_CATEGORIES_PASSIVE_ZOOM 0.5 -#define XMB_ITEM_ACTIVE_ZOOM 1.0 -#define XMB_ITEM_PASSIVE_ZOOM 0.5 - #define XMB_CATEGORIES_ACTIVE_ALPHA 1.0 #define XMB_CATEGORIES_PASSIVE_ALPHA 0.85 #define XMB_ITEM_ACTIVE_ALPHA 1.0 @@ -179,6 +174,12 @@ typedef struct xmb_handle float above_item_offset; float active_item_factor; float under_item_offset; + + float categories_active_zoom; + float categories_passive_zoom; + float item_active_alpha; + float item_passive_alpha; + float shadow_offset; char title_name[256]; @@ -769,7 +770,7 @@ static void xmb_selection_pointer_changed( { float iy, real_iy; float ia = XMB_ITEM_PASSIVE_ALPHA; - float iz = XMB_ITEM_PASSIVE_ZOOM; + float iz = xmb->item_passive_alpha; xmb_node_t *node = (xmb_node_t*) menu_entries_get_userdata_at_offset(selection_buf, i); @@ -782,7 +783,7 @@ static void xmb_selection_pointer_changed( if (i == selection) { ia = XMB_ITEM_ACTIVE_ALPHA; - iz = XMB_ITEM_ACTIVE_ZOOM; + iz = xmb->item_active_alpha; depth = xmb_list_get_size(xmb, MENU_LIST_PLAIN); if (strcmp(xmb_thumbnails_ident(), "OFF") && depth == 1) @@ -918,12 +919,12 @@ static void xmb_list_open_new(xmb_handle_t *xmb, node->x = xmb->icon.size * dir * 2; node->y = xmb_item_y(xmb, i, current); - node->zoom = XMB_CATEGORIES_PASSIVE_ZOOM; + node->zoom = xmb->categories_passive_zoom; real_y = node->y + xmb->margins.screen.top; if (i == current) - node->zoom = XMB_CATEGORIES_ACTIVE_ZOOM; + node->zoom = xmb->categories_active_zoom;; ia = XMB_ITEM_PASSIVE_ALPHA; if (i == current) @@ -973,12 +974,12 @@ static xmb_node_t *xmb_node_allocate_userdata(xmb_handle_t *xmb, unsigned i) } node->alpha = XMB_CATEGORIES_PASSIVE_ALPHA; - node->zoom = XMB_CATEGORIES_PASSIVE_ZOOM; + node->zoom = xmb->categories_passive_zoom; if ((i + XMB_SYSTEM_TAB_END) == xmb->categories.active.idx) { node->alpha = XMB_CATEGORIES_ACTIVE_ALPHA; - node->zoom = XMB_CATEGORIES_ACTIVE_ZOOM; + node->zoom = xmb->categories_active_zoom;; } file_list_free_actiondata(xmb->horizontal_list, i); @@ -1150,7 +1151,7 @@ static void xmb_list_switch_horizontal_list(xmb_handle_t *xmb) { menu_animation_ctx_entry_t entry; float ia = XMB_CATEGORIES_PASSIVE_ALPHA; - float iz = XMB_CATEGORIES_PASSIVE_ZOOM; + float iz = xmb->categories_passive_zoom; xmb_node_t *node = xmb_get_node(xmb, j); if (!node) @@ -1159,7 +1160,7 @@ static void xmb_list_switch_horizontal_list(xmb_handle_t *xmb) if (j == xmb->categories.active.idx) { ia = XMB_CATEGORIES_ACTIVE_ALPHA; - iz = XMB_CATEGORIES_ACTIVE_ZOOM; + iz = xmb->categories_active_zoom;; } entry.duration = XMB_DELAY; @@ -1316,12 +1317,12 @@ static void xmb_toggle_horizontal_list(xmb_handle_t *xmb) continue; node->alpha = 0; - node->zoom = XMB_CATEGORIES_PASSIVE_ZOOM; + node->zoom = xmb->categories_passive_zoom; if (i == xmb->categories.active.idx) { node->alpha = XMB_CATEGORIES_ACTIVE_ALPHA; - node->zoom = XMB_CATEGORIES_ACTIVE_ZOOM; + node->zoom = xmb->categories_active_zoom;; } else if (xmb->depth <= 1) node->alpha = XMB_CATEGORIES_PASSIVE_ALPHA; @@ -2329,6 +2330,11 @@ static void xmb_layout(xmb_handle_t *xmb) xmb->active_item_factor = 3.0; xmb->under_item_offset = 5.0; + xmb->categories_active_zoom = 1.0; + xmb->categories_passive_zoom = 0.5; + xmb->item_active_alpha = 1.0; + xmb->item_passive_alpha = 0.5; + /* Mimic the layout of the PSP instead of the PS3 on tiny screens */ if (width <= 640) { @@ -2364,7 +2370,7 @@ static void xmb_layout(xmb_handle_t *xmb) for (i = 0; i < end; i++) { float ia = XMB_ITEM_PASSIVE_ALPHA; - float iz = XMB_ITEM_PASSIVE_ZOOM; + float iz = xmb->item_passive_alpha; xmb_node_t *node = (xmb_node_t*)menu_entries_get_userdata_at_offset( selection_buf, i); @@ -2374,7 +2380,7 @@ static void xmb_layout(xmb_handle_t *xmb) if (i == current) { ia = XMB_ITEM_ACTIVE_ALPHA; - iz = XMB_ITEM_ACTIVE_ZOOM; + iz = xmb->item_active_alpha; } node->alpha = ia; @@ -2392,7 +2398,7 @@ static void xmb_layout(xmb_handle_t *xmb) for (i = 0; i < end; i++) { float ia = 0; - float iz = XMB_ITEM_PASSIVE_ZOOM; + float iz = xmb->item_passive_alpha; xmb_node_t *node = (xmb_node_t*)menu_entries_get_userdata_at_offset( xmb->selection_buf_old, i); @@ -2402,7 +2408,7 @@ static void xmb_layout(xmb_handle_t *xmb) if (i == current) { ia = XMB_ITEM_ACTIVE_ALPHA; - iz = XMB_ITEM_ACTIVE_ZOOM; + iz = xmb->item_active_alpha; } node->alpha = ia; @@ -2702,19 +2708,19 @@ static void xmb_context_reset_textures( xmb->main_menu_node.icon = xmb->textures.list[XMB_TEXTURE_MAIN_MENU]; xmb->main_menu_node.alpha = XMB_CATEGORIES_ACTIVE_ALPHA; - xmb->main_menu_node.zoom = XMB_CATEGORIES_ACTIVE_ZOOM; + xmb->main_menu_node.zoom = xmb->categories_active_zoom;; xmb->settings_tab_node.icon = xmb->textures.list[XMB_TEXTURE_SETTINGS]; xmb->settings_tab_node.alpha = XMB_CATEGORIES_ACTIVE_ALPHA; - xmb->settings_tab_node.zoom = XMB_CATEGORIES_ACTIVE_ZOOM; + xmb->settings_tab_node.zoom = xmb->categories_active_zoom;; xmb->history_tab_node.icon = xmb->textures.list[XMB_TEXTURE_HISTORY]; xmb->history_tab_node.alpha = XMB_CATEGORIES_ACTIVE_ALPHA; - xmb->history_tab_node.zoom = XMB_CATEGORIES_ACTIVE_ZOOM; + xmb->history_tab_node.zoom = xmb->categories_active_zoom;; xmb->add_tab_node.icon = xmb->textures.list[XMB_TEXTURE_ADD]; xmb->add_tab_node.alpha = XMB_CATEGORIES_ACTIVE_ALPHA; - xmb->add_tab_node.zoom = XMB_CATEGORIES_ACTIVE_ZOOM; + xmb->add_tab_node.zoom = xmb->categories_active_zoom;; } static void xmb_context_reset_background(const char *iconpath) @@ -2818,7 +2824,7 @@ static void xmb_list_insert(void *userdata, current = selection; node->alpha = XMB_ITEM_PASSIVE_ALPHA; - node->zoom = XMB_ITEM_PASSIVE_ZOOM; + node->zoom = xmb->item_passive_alpha; node->label_alpha = node->alpha; node->y = xmb_item_y(xmb, i, current); node->x = 0; @@ -2827,7 +2833,7 @@ static void xmb_list_insert(void *userdata, { node->alpha = XMB_ITEM_ACTIVE_ALPHA; node->label_alpha = XMB_ITEM_ACTIVE_ALPHA; - node->zoom = XMB_ITEM_ACTIVE_ZOOM; + node->zoom = xmb->item_active_alpha; } file_list_set_userdata(list, i, node); From 725c20249850a804e7dc7526befd00d7b55a0ff6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 23:12:04 +0200 Subject: [PATCH 301/498] Remove input_driver_ctl --- command_event.c | 14 +- driver.c | 15 +- dynamic.c | 2 +- gfx/drivers/gl.c | 2 +- gfx/video_driver.c | 10 +- gfx/video_state_python.c | 2 +- gfx/video_state_tracker.c | 2 +- input/drivers/android_input.c | 2 +- input/input_driver.c | 534 +++++++++++++++++++--------------- input/input_driver.h | 148 ++++++---- input/input_joypad_driver.h | 34 +-- input/input_overlay.c | 5 +- menu/menu_display.c | 10 +- menu/menu_driver.c | 2 +- menu/menu_input.c | 6 +- netplay/netplay.c | 5 +- runloop.c | 30 +- tasks/task_overlay.c | 3 +- 18 files changed, 462 insertions(+), 364 deletions(-) diff --git a/command_event.c b/command_event.c index cb1325601c..bf1a0defdb 100644 --- a/command_event.c +++ b/command_event.c @@ -1144,7 +1144,7 @@ bool event_cmd_ctl(enum event_command cmd, void *data) video_driver_unset_video_cache_context(); /* Poll input to avoid possibly stale data to corrupt things. */ - input_driver_ctl(RARCH_INPUT_CTL_POLL, NULL); + input_driver_poll(); #ifdef HAVE_MENU menu_display_set_framebuffer_dirty_flag(); @@ -1566,18 +1566,18 @@ bool event_cmd_ctl(enum event_command cmd, void *data) event_cmd_ctl(EVENT_CMD_REINIT, NULL); break; case EVENT_CMD_COMMAND_DEINIT: - input_driver_ctl(RARCH_INPUT_CTL_COMMAND_DEINIT, NULL); + input_driver_deinit_command(); break; case EVENT_CMD_COMMAND_INIT: event_cmd_ctl(EVENT_CMD_COMMAND_DEINIT, NULL); - input_driver_ctl(RARCH_INPUT_CTL_COMMAND_INIT, NULL); + input_driver_init_command(); break; case EVENT_CMD_REMOTE_DEINIT: - input_driver_ctl(RARCH_INPUT_CTL_REMOTE_DEINIT, NULL); + input_driver_deinit_remote(); break; case EVENT_CMD_REMOTE_INIT: event_cmd_ctl(EVENT_CMD_REMOTE_DEINIT, NULL); - input_driver_ctl(RARCH_INPUT_CTL_REMOTE_INIT, NULL); + input_driver_init_remote(); break; case EVENT_CMD_TEMPORARY_CONTENT_DEINIT: content_deinit(); @@ -1676,9 +1676,9 @@ bool event_cmd_ctl(enum event_command cmd, void *data) grab_mouse_state = !grab_mouse_state; if (grab_mouse_state) - ret = input_driver_ctl(RARCH_INPUT_CTL_GRAB_MOUSE, NULL); + ret = input_driver_grab_mouse(); else - ret = input_driver_ctl(RARCH_INPUT_CTL_UNGRAB_MOUSE, NULL); + ret = input_driver_ungrab_mouse(); if (!ret) return false; diff --git a/driver.c b/driver.c index 3da72edf97..c5bbe04d08 100644 --- a/driver.c +++ b/driver.c @@ -223,8 +223,7 @@ static void driver_adjust_system_rates(void) static void driver_set_nonblock_state(void) { settings_t *settings = config_get_ptr(); - bool enable = input_driver_ctl( - RARCH_INPUT_CTL_IS_NONBLOCK_STATE, NULL); + bool enable = input_driver_is_nonblock_state(); /* Only apply non-block-state for video if we're using vsync. */ if (video_driver_is_active() && video_driver_get_ptr(false)) @@ -306,7 +305,7 @@ static void init_drivers(int flags) if (flags & DRIVER_AUDIO) audio_driver_unset_own_driver(); if (flags & DRIVER_INPUT) - input_driver_ctl(RARCH_INPUT_CTL_UNSET_OWN_DRIVER, NULL); + input_driver_unset_own_driver(); if (flags & DRIVER_CAMERA) camera_driver_ctl(RARCH_CAMERA_CTL_UNSET_OWN_DRIVER, NULL); if (flags & DRIVER_LOCATION) @@ -363,7 +362,7 @@ static void init_drivers(int flags) if (flags & (DRIVER_VIDEO | DRIVER_AUDIO)) { /* Keep non-throttled state as good as possible. */ - if (input_driver_ctl(RARCH_INPUT_CTL_IS_NONBLOCK_STATE, NULL)) + if (input_driver_is_nonblock_state()) driver_ctl(RARCH_DRIVER_CTL_SET_NONBLOCK_STATE, NULL); } } @@ -415,8 +414,8 @@ static void uninit_drivers(int flags) if ((flags & DRIVER_VIDEO) && !video_driver_owns_driver()) video_driver_destroy_data(); - if ((flags & DRIVER_INPUT) && !input_driver_ctl(RARCH_INPUT_CTL_OWNS_DRIVER, NULL)) - input_driver_ctl(RARCH_INPUT_CTL_DESTROY_DATA, NULL); + if ((flags & DRIVER_INPUT) && !input_driver_owns_driver()) + input_driver_destroy_data(); if ((flags & DRIVER_AUDIO) && !audio_driver_owns_driver()) audio_driver_destroy_data(); @@ -429,7 +428,7 @@ bool driver_ctl(enum driver_ctl_state state, void *data) case RARCH_DRIVER_CTL_DEINIT: video_driver_destroy(); audio_driver_destroy(); - input_driver_ctl(RARCH_INPUT_CTL_DESTROY, NULL); + input_driver_destroy(); #ifdef HAVE_MENU menu_driver_ctl(RARCH_MENU_CTL_DESTROY, NULL); #endif @@ -466,7 +465,7 @@ bool driver_ctl(enum driver_ctl_state state, void *data) case RARCH_DRIVER_CTL_INIT_PRE: audio_driver_find_driver(); video_driver_find_driver(); - input_driver_ctl(RARCH_INPUT_CTL_FIND_DRIVER, NULL); + input_driver_find_driver(); camera_driver_ctl(RARCH_CAMERA_CTL_FIND_DRIVER, NULL); find_location_driver(); #ifdef HAVE_MENU diff --git a/dynamic.c b/dynamic.c index 2fc5a5fa7a..37c7aee991 100644 --- a/dynamic.c +++ b/dynamic.c @@ -1056,7 +1056,7 @@ bool rarch_environment_cb(unsigned cmd, void *data) uint64_t *mask = (uint64_t*)data; RARCH_LOG("Environ GET_INPUT_DEVICE_CAPABILITIES.\n"); - if (input_driver_ctl(RARCH_INPUT_CTL_HAS_CAPABILITIES, NULL)) + if (input_driver_has_capabilities()) *mask = input_driver_get_capabilities(); else return false; diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index ed30f4e671..776c67fd1f 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -1980,7 +1980,7 @@ static bool gl_frame(void *data, const void *frame, * and pause to prevent flicker. */ if ( settings->video.black_frame_insertion - && !input_driver_ctl(RARCH_INPUT_CTL_IS_NONBLOCK_STATE, NULL) + && !input_driver_is_nonblock_state() && !runloop_ctl(RUNLOOP_CTL_IS_SLOWMOTION, NULL) && !runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL)) { diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 65acf70351..b9259e7c23 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -433,7 +433,7 @@ static void init_video_input(const input_driver_t *tmp) if (tmp) *input = tmp; else - input_driver_ctl(RARCH_INPUT_CTL_FIND_DRIVER, NULL); + input_driver_find_driver(); /* This should never really happen as tmp (driver.input) is always * found before this in find_driver_input(), or we have aborted @@ -441,7 +441,7 @@ static void init_video_input(const input_driver_t *tmp) if (!input_get_ptr()) goto error; - if (input_driver_ctl(RARCH_INPUT_CTL_INIT, NULL)) + if (input_driver_init()) return; error: @@ -511,10 +511,10 @@ static bool uninit_video_input(void) video_driver_deinit_hw_context(); if ( - !input_driver_ctl(RARCH_INPUT_CTL_OWNS_DRIVER, NULL) && - !input_driver_ctl(RARCH_INPUT_CTL_IS_DATA_PTR_SAME, video_driver_data) + !input_driver_owns_driver() && + !input_driver_is_data_ptr_same(video_driver_data) ) - input_driver_ctl(RARCH_INPUT_CTL_DEINIT, NULL); + input_driver_deinit(); if ( !video_driver_owns_driver() diff --git a/gfx/video_state_python.c b/gfx/video_state_python.c index 891a01c804..2ad9fd1dd7 100644 --- a/gfx/video_state_python.c +++ b/gfx/video_state_python.c @@ -120,7 +120,7 @@ static PyObject *py_read_input(PyObject *self, PyObject *args) if (user > MAX_USERS || user < 1 || key >= RARCH_FIRST_META_KEY) return NULL; - if (!input_driver_ctl(RARCH_INPUT_CTL_IS_LIBRETRO_INPUT_BLOCKED, NULL)) + if (!input_driver_is_libretro_input_blocked()) res = input_driver_state(py_binds, user - 1, RETRO_DEVICE_JOYPAD, 0, key); return PyBool_FromLong(res); } diff --git a/gfx/video_state_tracker.c b/gfx/video_state_tracker.c index 1bbb77c7ab..6926b4bc6e 100644 --- a/gfx/video_state_tracker.c +++ b/gfx/video_state_tracker.c @@ -289,7 +289,7 @@ static void state_tracker_update_input(state_tracker_t *tracker) input_push_analog_dpad(settings->input.autoconf_binds[i], settings->input.analog_dpad_mode[i]); - if (!input_driver_ctl(RARCH_INPUT_CTL_IS_LIBRETRO_INPUT_BLOCKED, NULL)) + if (!input_driver_is_libretro_input_blocked()) { for (i = 4; i < 16; i++) { diff --git a/input/drivers/android_input.c b/input/drivers/android_input.c index c3f450a9cc..980ecdc1b0 100644 --- a/input/drivers/android_input.c +++ b/input/drivers/android_input.c @@ -1041,7 +1041,7 @@ static void android_input_poll(void *data) struct android_app *android_app = (struct android_app*)g_android; while ((ident = - ALooper_pollAll((input_driver_ctl(RARCH_INPUT_CTL_KEY_PRESSED, &key)) + ALooper_pollAll((input_driver_key_pressed(&key)) ? -1 : 1, NULL, NULL, NULL)) >= 0) { diff --git a/input/input_driver.c b/input/input_driver.c index 7c2bd548ae..3998dacf2e 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -96,13 +96,19 @@ struct turbo_buttons static turbo_buttons_t input_driver_turbo_btns; #ifdef HAVE_COMMAND -static rarch_cmd_t *input_driver_command = NULL; +static rarch_cmd_t *input_driver_command = NULL; #endif #ifdef HAVE_NETWORK_GAMEPAD -static rarch_remote_t *input_driver_remote = NULL; +static rarch_remote_t *input_driver_remote = NULL; #endif -static const input_driver_t *current_input = NULL; -static void *current_input_data = NULL; +static const input_driver_t *current_input = NULL; +static void *current_input_data = NULL; +static bool input_driver_block_hotkey = false; +static bool input_driver_block_libretro_input = false; +static bool input_driver_osk_enabled = false; +static bool input_driver_nonblock_state = false; +static bool input_driver_flushing_input = false; +static bool input_driver_data_own = false; /** * input_driver_find_handle: @@ -210,7 +216,7 @@ void input_driver_set(const input_driver_t **input, void **input_data) *input_data = current_input_data; } - input_driver_ctl(RARCH_INPUT_CTL_SET_OWN_DRIVER, NULL); + input_driver_set_own_driver(); } void input_driver_keyboard_mapping_set_block(bool value) @@ -255,9 +261,9 @@ static retro_input_t input_driver_keys_pressed(void) for (key = 0; key < RARCH_BIND_LIST_END; key++) { bool state = false; - if ((!input_driver_ctl(RARCH_INPUT_CTL_IS_LIBRETRO_INPUT_BLOCKED, NULL) && ((key < RARCH_FIRST_META_KEY))) - || !input_driver_ctl(RARCH_INPUT_CTL_IS_HOTKEY_BLOCKED, NULL)) - state = input_driver_ctl(RARCH_INPUT_CTL_KEY_PRESSED, &key); + if ((!input_driver_is_libretro_input_blocked() && ((key < RARCH_FIRST_META_KEY))) + || !input_driver_is_hotkey_blocked()) + state = input_driver_key_pressed(&key); if (key >= RARCH_FIRST_META_KEY) state |= current_input->meta_key_pressed(current_input_data, key); @@ -419,7 +425,7 @@ void input_poll(void) size_t i; settings_t *settings = config_get_ptr(); - input_driver_ctl(RARCH_INPUT_CTL_POLL, NULL); + input_driver_poll(); for (i = 0; i < MAX_USERS; i++) libretro_input_binds[i] = settings->input.binds[i]; @@ -472,8 +478,8 @@ int16_t input_state(unsigned port, unsigned device, if (settings->input.remap_binds_enable) input_remapping_state(port, &device, &idx, &id); - if (!input_driver_ctl(RARCH_INPUT_CTL_IS_FLUSHING_INPUT, NULL) - && !input_driver_ctl(RARCH_INPUT_CTL_IS_LIBRETRO_INPUT_BLOCKED, NULL)) + if (!input_driver_is_flushing_input() + && !input_driver_is_libretro_input_blocked()) { if (((id < RARCH_FIRST_META_KEY) || (device == RETRO_DEVICE_KEYBOARD))) res = current_input->input_state( @@ -533,15 +539,14 @@ static bool check_input_driver_block_hotkey(bool enable_hotkey) &settings->input.binds[0][RARCH_ENABLE_HOTKEY]; const struct retro_keybind *autoconf_bind = &settings->input.autoconf_binds[0][RARCH_ENABLE_HOTKEY]; - bool kb_mapping_is_blocked = input_driver_ctl( - RARCH_INPUT_CTL_KB_MAPPING_IS_BLOCKED, NULL); + bool kb_mapping_is_blocked = input_driver_keyboard_mapping_is_blocked(); /* Don't block the check to RARCH_ENABLE_HOTKEY * unless we're really supposed to. */ if (kb_mapping_is_blocked) - input_driver_ctl(RARCH_INPUT_CTL_SET_HOTKEY_BLOCK, NULL); + input_driver_set_hotkey_block(); else - input_driver_ctl(RARCH_INPUT_CTL_UNSET_HOTKEY_BLOCK, NULL); + input_driver_unset_hotkey_block(); /* If we haven't bound anything to this, * always allow hotkeys. */ @@ -554,9 +559,9 @@ static bool check_input_driver_block_hotkey(bool enable_hotkey) || (autoconf_bind->joyaxis != AXIS_NONE); if (kb_mapping_is_blocked || (use_hotkey_enable && !enable_hotkey)) - input_driver_ctl(RARCH_INPUT_CTL_SET_HOTKEY_BLOCK, NULL); + input_driver_set_hotkey_block(); else - input_driver_ctl(RARCH_INPUT_CTL_UNSET_HOTKEY_BLOCK, NULL); + input_driver_unset_hotkey_block(); /* If we hold ENABLE_HOTKEY button, block all libretro input to allow * hotkeys to be bound to same keys as RetroPad. */ @@ -591,10 +596,10 @@ retro_input_t input_keys_pressed(void) key = RARCH_ENABLE_HOTKEY; - if (check_input_driver_block_hotkey(input_driver_ctl(RARCH_INPUT_CTL_KEY_PRESSED, &key))) - input_driver_ctl(RARCH_INPUT_CTL_SET_LIBRETRO_INPUT_BLOCKED, NULL); + if (check_input_driver_block_hotkey(input_driver_key_pressed(&key))) + input_driver_set_libretro_input_blocked(); else - input_driver_ctl(RARCH_INPUT_CTL_UNSET_LIBRETRO_INPUT_BLOCKED, NULL); + input_driver_unset_libretro_input_blocked(); for (i = 0; i < settings->input.max_users; i++) { @@ -606,7 +611,7 @@ retro_input_t input_keys_pressed(void) input_driver_turbo_btns.frame_enable[i] = 0; } - if (!input_driver_ctl(RARCH_INPUT_CTL_IS_LIBRETRO_INPUT_BLOCKED, NULL)) + if (!input_driver_is_libretro_input_blocked()) { for (i = 0; i < settings->input.max_users; i++) input_driver_turbo_btns.frame_enable[i] = input_driver_state(binds, @@ -634,219 +639,292 @@ void **input_driver_get_data_ptr(void) return (void**)¤t_input_data; } -bool input_driver_ctl(enum rarch_input_ctl_state state, void *data) +bool input_driver_key_pressed(unsigned *key) { - static bool input_driver_block_hotkey = false; - static bool input_driver_block_libretro_input = false; - static bool input_driver_osk_enabled = false; - static bool input_driver_nonblock_state = false; - static bool input_driver_flushing_input = false; - static bool input_driver_data_own = false; - settings_t *settings = config_get_ptr(); + if (key && current_input->key_pressed) + return current_input->key_pressed(current_input_data, *key); + return true; +} - switch (state) +bool input_driver_has_capabilities(void) +{ + if (!current_input->get_capabilities || !current_input_data) + return false; + return true; +} + +void input_driver_poll(void) +{ + current_input->poll(current_input_data); +} + +bool input_driver_init(void) +{ + if (current_input) + current_input_data = current_input->init(); + + if (!current_input_data) + return false; + return true; +} + +void input_driver_deinit(void) +{ + if (current_input && current_input->free) + current_input->free(current_input_data); + current_input_data = NULL; +} + +void input_driver_destroy_data(void) +{ + current_input_data = NULL; +} + +void input_driver_destroy(void) +{ + input_keyboard_ctl(RARCH_INPUT_KEYBOARD_CTL_DESTROY, NULL); + input_driver_block_hotkey = false; + input_driver_block_libretro_input = false; + input_driver_nonblock_state = false; + input_driver_flushing_input = false; + input_driver_data_own = false; + memset(&input_driver_turbo_btns, 0, sizeof(turbo_buttons_t)); + current_input = NULL; +} + +bool input_driver_grab_stdin(void) +{ + if (!current_input->grab_stdin) + return false; + return current_input->grab_stdin(current_input_data); +} + +bool input_driver_keyboard_mapping_is_blocked(void) +{ + if (!current_input->keyboard_mapping_is_blocked) + return false; + return current_input->keyboard_mapping_is_blocked( + current_input_data); +} + +bool input_driver_find_driver(void) +{ + int i; + driver_ctx_info_t drv; + settings_t *settings = config_get_ptr(); + + drv.label = "input_driver"; + drv.s = settings->input.driver; + + driver_ctl(RARCH_DRIVER_CTL_FIND_INDEX, &drv); + + i = drv.len; + + if (i >= 0) + current_input = (const input_driver_t*) + input_driver_find_handle(i); + else { - case RARCH_INPUT_CTL_KEY_PRESSED: - { - unsigned *key = (unsigned*)data; - if (key && current_input->key_pressed) - return current_input->key_pressed(current_input_data, *key); - } - return false; - case RARCH_INPUT_CTL_HAS_CAPABILITIES: - if (!current_input->get_capabilities || !current_input_data) - return false; - break; - case RARCH_INPUT_CTL_POLL: - current_input->poll(current_input_data); - break; - case RARCH_INPUT_CTL_INIT: - if (current_input) - current_input_data = current_input->init(); + unsigned d; + RARCH_ERR("Couldn't find any input driver named \"%s\"\n", + settings->input.driver); + RARCH_LOG_OUTPUT("Available input drivers are:\n"); + for (d = 0; input_driver_find_handle(d); d++) + RARCH_LOG_OUTPUT("\t%s\n", input_driver_find_ident(d)); + RARCH_WARN("Going to default to first input driver...\n"); - if (!current_input_data) - return false; - break; - case RARCH_INPUT_CTL_DEINIT: - if (current_input && current_input->free) - current_input->free(current_input_data); - current_input_data = NULL; - break; - case RARCH_INPUT_CTL_DESTROY_DATA: - current_input_data = NULL; - break; - case RARCH_INPUT_CTL_DESTROY: - input_keyboard_ctl(RARCH_INPUT_KEYBOARD_CTL_DESTROY, NULL); - input_driver_block_hotkey = false; - input_driver_block_libretro_input = false; - input_driver_nonblock_state = false; - input_driver_flushing_input = false; - input_driver_data_own = false; - memset(&input_driver_turbo_btns, 0, sizeof(turbo_buttons_t)); - current_input = NULL; - break; - case RARCH_INPUT_CTL_GRAB_STDIN: - if (!current_input->grab_stdin) - return false; - return current_input->grab_stdin(current_input_data); - case RARCH_INPUT_CTL_KB_MAPPING_IS_BLOCKED: - if (!current_input->keyboard_mapping_is_blocked) - return false; - return current_input->keyboard_mapping_is_blocked( - current_input_data); - case RARCH_INPUT_CTL_FIND_DRIVER: - { - int i; - driver_ctx_info_t drv; + current_input = (const input_driver_t*) + input_driver_find_handle(0); - drv.label = "input_driver"; - drv.s = settings->input.driver; - - driver_ctl(RARCH_DRIVER_CTL_FIND_INDEX, &drv); - - i = drv.len; - - if (i >= 0) - current_input = (const input_driver_t*) - input_driver_find_handle(i); - else - { - unsigned d; - RARCH_ERR("Couldn't find any input driver named \"%s\"\n", - settings->input.driver); - RARCH_LOG_OUTPUT("Available input drivers are:\n"); - for (d = 0; input_driver_find_handle(d); d++) - RARCH_LOG_OUTPUT("\t%s\n", input_driver_find_ident(d)); - RARCH_WARN("Going to default to first input driver...\n"); - - current_input = (const input_driver_t*) - input_driver_find_handle(0); - - if (current_input) - return true; - retro_fail(1, "find_input_driver()"); - return false; - } - } - break; - case RARCH_INPUT_CTL_SET_FLUSHING_INPUT: - input_driver_flushing_input = true; - break; - case RARCH_INPUT_CTL_UNSET_FLUSHING_INPUT: - input_driver_flushing_input = false; - break; - case RARCH_INPUT_CTL_IS_FLUSHING_INPUT: - return input_driver_flushing_input; - case RARCH_INPUT_CTL_SET_HOTKEY_BLOCK: - input_driver_block_hotkey = true; - break; - case RARCH_INPUT_CTL_UNSET_HOTKEY_BLOCK: - input_driver_block_hotkey = false; - break; - case RARCH_INPUT_CTL_IS_HOTKEY_BLOCKED: - return input_driver_block_hotkey; - case RARCH_INPUT_CTL_SET_LIBRETRO_INPUT_BLOCKED: - input_driver_block_libretro_input = true; - break; - case RARCH_INPUT_CTL_UNSET_LIBRETRO_INPUT_BLOCKED: - input_driver_block_libretro_input = false; - break; - case RARCH_INPUT_CTL_IS_LIBRETRO_INPUT_BLOCKED: - return input_driver_block_libretro_input; - case RARCH_INPUT_CTL_SET_NONBLOCK_STATE: - input_driver_nonblock_state = true; - break; - case RARCH_INPUT_CTL_UNSET_NONBLOCK_STATE: - input_driver_nonblock_state = false; - break; - case RARCH_INPUT_CTL_IS_NONBLOCK_STATE: - return input_driver_nonblock_state; - case RARCH_INPUT_CTL_SET_OWN_DRIVER: - input_driver_data_own = true; - break; - case RARCH_INPUT_CTL_UNSET_OWN_DRIVER: - input_driver_data_own = false; - break; - case RARCH_INPUT_CTL_OWNS_DRIVER: - return input_driver_data_own; - case RARCH_INPUT_CTL_SET_OSK_ENABLED: - input_driver_osk_enabled = true; - break; - case RARCH_INPUT_CTL_UNSET_OSK_ENABLED: - input_driver_osk_enabled = false; - break; - case RARCH_INPUT_CTL_IS_OSK_ENABLED: - return input_driver_osk_enabled; - case RARCH_INPUT_CTL_COMMAND_INIT: -#ifdef HAVE_COMMAND - if (!settings->stdin_cmd_enable && !settings->network_cmd_enable) - return false; - - if (settings->stdin_cmd_enable - && input_driver_ctl(RARCH_INPUT_CTL_GRAB_STDIN, NULL)) - { - RARCH_WARN("stdin command interface is desired, but input driver has already claimed stdin.\n" - "Cannot use this command interface.\n"); - } - - input_driver_command = rarch_cmd_new(settings->stdin_cmd_enable - && !input_driver_ctl(RARCH_INPUT_CTL_GRAB_STDIN, NULL), - settings->network_cmd_enable, settings->network_cmd_port); - - if (!input_driver_command) - { - RARCH_ERR("Failed to initialize command interface.\n"); - return false; - } -#endif - break; - case RARCH_INPUT_CTL_COMMAND_DEINIT: -#ifdef HAVE_COMMAND - if (input_driver_command) - rarch_cmd_free(input_driver_command); - input_driver_command = NULL; -#endif - break; - case RARCH_INPUT_CTL_REMOTE_DEINIT: -#ifdef HAVE_NETWORK_GAMEPAD - if (input_driver_remote) - rarch_remote_free(input_driver_remote); - input_driver_remote = NULL; -#endif - break; - case RARCH_INPUT_CTL_REMOTE_INIT: -#ifdef HAVE_NETWORK_GAMEPAD - if (settings->network_remote_enable) - { - input_driver_remote - = rarch_remote_new(settings->network_remote_base_port); - - if (!input_driver_remote) - { - RARCH_ERR("Failed to initialize remote gamepad interface.\n"); - return false; - } - } -#endif - break; - case RARCH_INPUT_CTL_GRAB_MOUSE: - if (!current_input || !current_input->grab_mouse) - return false; - - current_input->grab_mouse(current_input_data, true); - break; - case RARCH_INPUT_CTL_UNGRAB_MOUSE: - if (!current_input || !current_input->grab_mouse) - return false; - - current_input->grab_mouse(current_input_data, false); - break; - case RARCH_INPUT_CTL_IS_DATA_PTR_SAME: - return (current_input_data == data); - case RARCH_INPUT_CTL_NONE: - default: - break; + if (current_input) + return true; + retro_fail(1, "find_input_driver()"); + return false; } return true; } + +void input_driver_set_flushing_input(void) +{ + input_driver_flushing_input = true; +} + +void input_driver_unset_flushing_input(void) +{ + input_driver_flushing_input = false; +} + +bool input_driver_is_flushing_input(void) +{ + return input_driver_flushing_input; +} + +void input_driver_set_hotkey_block(void) +{ + input_driver_block_hotkey = true; +} + +void input_driver_unset_hotkey_block(void) +{ + input_driver_block_hotkey = false; +} + +bool input_driver_is_hotkey_blocked(void) +{ + return input_driver_block_hotkey; +} + +void input_driver_set_libretro_input_blocked(void) +{ + input_driver_block_libretro_input = true; +} + +void input_driver_unset_libretro_input_blocked(void) +{ + input_driver_block_libretro_input = false; +} + +bool input_driver_is_libretro_input_blocked(void) +{ + return input_driver_block_libretro_input; +} + +void input_driver_set_nonblock_state(void) +{ + input_driver_nonblock_state = true; +} + +void input_driver_unset_nonblock_state(void) +{ + input_driver_nonblock_state = false; +} + +bool input_driver_is_nonblock_state(void) +{ + return input_driver_nonblock_state; +} + +void input_driver_set_own_driver(void) +{ + input_driver_data_own = true; +} + +void input_driver_unset_own_driver(void) +{ + input_driver_data_own = false; +} + +bool input_driver_owns_driver(void) +{ + return input_driver_data_own; +} + +void input_driver_set_onscreen_keyboard_enabled(void) +{ + input_driver_osk_enabled = true; +} + +void input_driver_unset_onscreen_keyboard_enabled(void) +{ + input_driver_osk_enabled = false; +} + +bool input_driver_is_onscreen_keyboard_enabled(void) +{ + return input_driver_osk_enabled; +} + +bool input_driver_init_command(void) +{ +#ifdef HAVE_COMMAND + settings_t *settings = config_get_ptr(); + if (!settings->stdin_cmd_enable && !settings->network_cmd_enable) + return false; + + if (settings->stdin_cmd_enable + && input_driver_grab_stdin()) + { + RARCH_WARN("stdin command interface is desired, but input driver has already claimed stdin.\n" + "Cannot use this command interface.\n"); + } + + input_driver_command = rarch_cmd_new(settings->stdin_cmd_enable + && !input_driver_grab_stdin(), + settings->network_cmd_enable, settings->network_cmd_port); + + if (!input_driver_command) + { + RARCH_ERR("Failed to initialize command interface.\n"); + return false; + } + + return true; +#else + return false; +#endif +} + +void input_driver_deinit_command(void) +{ +#ifdef HAVE_COMMAND + if (input_driver_command) + rarch_cmd_free(input_driver_command); + input_driver_command = NULL; +#endif +} + +void input_driver_deinit_remote(void) +{ +#ifdef HAVE_NETWORK_GAMEPAD + if (input_driver_remote) + rarch_remote_free(input_driver_remote); + input_driver_remote = NULL; +#endif +} + +bool input_driver_init_remote(void) +{ +#ifdef HAVE_NETWORK_GAMEPAD + settings_t *settings = config_get_ptr(); + + if (!settings->network_remote_enable) + return false; + + input_driver_remote + = rarch_remote_new(settings->network_remote_base_port); + + if (!input_driver_remote) + { + RARCH_ERR("Failed to initialize remote gamepad interface.\n"); + return false; + } + + return true; +#else + return false +#endif +} + +bool input_driver_grab_mouse(void) +{ + if (!current_input || !current_input->grab_mouse) + return false; + + current_input->grab_mouse(current_input_data, true); + return true; +} + +bool input_driver_ungrab_mouse(void) +{ + if (!current_input || !current_input->grab_mouse) + return false; + + current_input->grab_mouse(current_input_data, false); + return true; +} + +bool input_driver_is_data_ptr_same(void *data) +{ + return (current_input_data == data); +} diff --git a/input/input_driver.h b/input/input_driver.h index 207893c612..13c84c2bb7 100644 --- a/input/input_driver.h +++ b/input/input_driver.h @@ -45,46 +45,6 @@ enum input_device_type INPUT_DEVICE_TYPE_JOYPAD }; -enum rarch_input_ctl_state -{ - RARCH_INPUT_CTL_NONE = 0, - RARCH_INPUT_CTL_INIT, - RARCH_INPUT_CTL_DEINIT, - RARCH_INPUT_CTL_DESTROY, - RARCH_INPUT_CTL_DESTROY_DATA, - RARCH_INPUT_CTL_HAS_CAPABILITIES, - RARCH_INPUT_CTL_POLL, - RARCH_INPUT_CTL_FIND_DRIVER, - RARCH_INPUT_CTL_GRAB_STDIN, - RARCH_INPUT_CTL_KB_MAPPING_IS_BLOCKED, - RARCH_INPUT_CTL_SET_FLUSHING_INPUT, - RARCH_INPUT_CTL_UNSET_FLUSHING_INPUT, - RARCH_INPUT_CTL_IS_FLUSHING_INPUT, - RARCH_INPUT_CTL_SET_HOTKEY_BLOCK, - RARCH_INPUT_CTL_UNSET_HOTKEY_BLOCK, - RARCH_INPUT_CTL_IS_HOTKEY_BLOCKED, - RARCH_INPUT_CTL_SET_LIBRETRO_INPUT_BLOCKED, - RARCH_INPUT_CTL_UNSET_LIBRETRO_INPUT_BLOCKED, - RARCH_INPUT_CTL_IS_LIBRETRO_INPUT_BLOCKED, - RARCH_INPUT_CTL_SET_NONBLOCK_STATE, - RARCH_INPUT_CTL_UNSET_NONBLOCK_STATE, - RARCH_INPUT_CTL_IS_NONBLOCK_STATE, - RARCH_INPUT_CTL_SET_OWN_DRIVER, - RARCH_INPUT_CTL_UNSET_OWN_DRIVER, - RARCH_INPUT_CTL_OWNS_DRIVER, - RARCH_INPUT_CTL_SET_OSK_ENABLED, - RARCH_INPUT_CTL_UNSET_OSK_ENABLED, - RARCH_INPUT_CTL_IS_OSK_ENABLED, - RARCH_INPUT_CTL_COMMAND_INIT, - RARCH_INPUT_CTL_COMMAND_DEINIT, - RARCH_INPUT_CTL_REMOTE_INIT, - RARCH_INPUT_CTL_REMOTE_DEINIT, - RARCH_INPUT_CTL_KEY_PRESSED, - RARCH_INPUT_CTL_GRAB_MOUSE, - RARCH_INPUT_CTL_UNGRAB_MOUSE, - RARCH_INPUT_CTL_IS_DATA_PTR_SAME -}; - struct retro_keybind { bool valid; @@ -132,24 +92,6 @@ typedef struct input_driver void (*keyboard_mapping_set_block)(void *data, bool value); } input_driver_t; -extern input_driver_t input_android; -extern input_driver_t input_sdl; -extern input_driver_t input_dinput; -extern input_driver_t input_x; -extern input_driver_t input_wayland; -extern input_driver_t input_ps3; -extern input_driver_t input_psp; -extern input_driver_t input_ctr; -extern input_driver_t input_xenon360; -extern input_driver_t input_gx; -extern input_driver_t input_xinput; -extern input_driver_t input_linuxraw; -extern input_driver_t input_udev; -extern input_driver_t input_cocoa; -extern input_driver_t input_qnx; -extern input_driver_t input_rwebinput; -extern input_driver_t input_null; - /** * input_driver_find_handle: * @index : index of driver to get handle to. @@ -279,8 +221,6 @@ int16_t input_state(unsigned port, unsigned device, retro_input_t input_keys_pressed(void); -bool input_driver_ctl(enum rarch_input_ctl_state state, void *data); - void *input_driver_get_data(void); const input_driver_t *input_get_ptr(void); @@ -289,8 +229,96 @@ const input_driver_t **input_get_double_ptr(void); void **input_driver_get_data_ptr(void); +bool input_driver_key_pressed(unsigned *key); + +bool input_driver_has_capabilities(void); + +void input_driver_poll(void); + +bool input_driver_init(void); + +void input_driver_deinit(void); + +void input_driver_destroy_data(void); + +void input_driver_destroy(void); + +bool input_driver_grab_stdin(void); + +bool input_driver_keyboard_mapping_is_blocked(void); + +bool input_driver_find_driver(void); + +void input_driver_set_flushing_input(void); + +void input_driver_unset_flushing_input(void); + +bool input_driver_is_flushing_input(void); + +void input_driver_set_hotkey_block(void); + +void input_driver_unset_hotkey_block(void); + +bool input_driver_is_hotkey_blocked(void); + +void input_driver_set_libretro_input_blocked(void); + +void input_driver_unset_libretro_input_blocked(void); + +bool input_driver_is_libretro_input_blocked(void); + +void input_driver_set_nonblock_state(void); + +void input_driver_unset_nonblock_state(void); + +bool input_driver_is_nonblock_state(void); + +void input_driver_set_own_driver(void); + +void input_driver_unset_own_driver(void); + +bool input_driver_owns_driver(void); + +void input_driver_set_onscreen_keyboard_enabled(void); + +void input_driver_unset_onscreen_keyboard_enabled(void); + +bool input_driver_is_onscreen_keyboard_enabled(void); + +void input_driver_deinit_command(void); + +bool input_driver_init_command(void); + +void input_driver_deinit_remote(void); + +bool input_driver_init_remote(void); + +bool input_driver_grab_mouse(void); + +bool input_driver_ungrab_mouse(void); + +bool input_driver_is_data_ptr_same(void *data); + extern const struct retro_keybind *libretro_input_binds[MAX_USERS]; +extern input_driver_t input_android; +extern input_driver_t input_sdl; +extern input_driver_t input_dinput; +extern input_driver_t input_x; +extern input_driver_t input_wayland; +extern input_driver_t input_ps3; +extern input_driver_t input_psp; +extern input_driver_t input_ctr; +extern input_driver_t input_xenon360; +extern input_driver_t input_gx; +extern input_driver_t input_xinput; +extern input_driver_t input_linuxraw; +extern input_driver_t input_udev; +extern input_driver_t input_cocoa; +extern input_driver_t input_qnx; +extern input_driver_t input_rwebinput; +extern input_driver_t input_null; + #ifdef __cplusplus } #endif diff --git a/input/input_joypad_driver.h b/input/input_joypad_driver.h index e8346953ea..1e1a5edca6 100644 --- a/input/input_joypad_driver.h +++ b/input/input_joypad_driver.h @@ -43,23 +43,6 @@ struct rarch_joypad_driver const char *ident; }; -extern input_device_driver_t dinput_joypad; -extern input_device_driver_t linuxraw_joypad; -extern input_device_driver_t parport_joypad; -extern input_device_driver_t udev_joypad; -extern input_device_driver_t xinput_joypad; -extern input_device_driver_t sdl_joypad; -extern input_device_driver_t ps3_joypad; -extern input_device_driver_t psp_joypad; -extern input_device_driver_t ctr_joypad; -extern input_device_driver_t xdk_joypad; -extern input_device_driver_t gx_joypad; -extern input_device_driver_t hid_joypad; -extern input_device_driver_t android_joypad; -extern input_device_driver_t qnx_joypad; -extern input_device_driver_t null_joypad; -extern input_device_driver_t mfi_joypad; - /** * joypad_driver_find_handle: * @index : index of driver to get handle to. @@ -226,6 +209,23 @@ bool input_joypad_hat_raw(const input_device_driver_t *driver, const char *input_joypad_name(const input_device_driver_t *driver, unsigned port); +extern input_device_driver_t dinput_joypad; +extern input_device_driver_t linuxraw_joypad; +extern input_device_driver_t parport_joypad; +extern input_device_driver_t udev_joypad; +extern input_device_driver_t xinput_joypad; +extern input_device_driver_t sdl_joypad; +extern input_device_driver_t ps3_joypad; +extern input_device_driver_t psp_joypad; +extern input_device_driver_t ctr_joypad; +extern input_device_driver_t xdk_joypad; +extern input_device_driver_t gx_joypad; +extern input_device_driver_t hid_joypad; +extern input_device_driver_t android_joypad; +extern input_device_driver_t qnx_joypad; +extern input_device_driver_t null_joypad; +extern input_device_driver_t mfi_joypad; + #ifdef __cplusplus } #endif diff --git a/input/input_overlay.c b/input/input_overlay.c index 96baf89304..93cbbe2f1a 100644 --- a/input/input_overlay.c +++ b/input/input_overlay.c @@ -548,8 +548,7 @@ static void input_overlay_loaded(void *task_data, void *user_data, const char *e /* We can't display when the menu is up */ if (settings->input.overlay_hide_in_menu && menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL)) { - if (!input_driver_ctl(RARCH_INPUT_CTL_IS_OSK_ENABLED, NULL) - && settings->input.overlay_enable) + if (!input_driver_is_onscreen_keyboard_enabled() && settings->input.overlay_enable) goto abort_load; } #endif @@ -573,7 +572,7 @@ static void input_overlay_loaded(void *task_data, void *user_data, const char *e overlay_ptr = ol; input_overlay_load_active(settings->input.overlay_opacity); - input_overlay_enable(input_driver_ctl(RARCH_INPUT_CTL_IS_OSK_ENABLED, NULL) ? settings->osk.enable : settings->input.overlay_enable); + input_overlay_enable(input_driver_is_onscreen_keyboard_enabled() ? settings->osk.enable : settings->input.overlay_enable); input_overlay_set_scale_factor(settings->input.overlay_scale); ol->next_index = (ol->index + 1) % ol->size; diff --git a/menu/menu_display.c b/menu/menu_display.c index f023be7260..21074abdac 100644 --- a/menu/menu_display.c +++ b/menu/menu_display.c @@ -271,18 +271,14 @@ bool menu_display_libretro(void) if (menu_display_libretro_running()) { - bool libretro_input_is_blocked = - input_driver_ctl( - RARCH_INPUT_CTL_IS_LIBRETRO_INPUT_BLOCKED, NULL); + bool libretro_input_is_blocked = input_driver_is_libretro_input_blocked(); if (!libretro_input_is_blocked) - input_driver_ctl( - RARCH_INPUT_CTL_SET_LIBRETRO_INPUT_BLOCKED, NULL); + input_driver_set_libretro_input_blocked(); core_run(); - input_driver_ctl( - RARCH_INPUT_CTL_UNSET_LIBRETRO_INPUT_BLOCKED, NULL); + input_driver_unset_libretro_input_blocked(); return true; } diff --git a/menu/menu_driver.c b/menu/menu_driver.c index 13c08da017..dfba2df776 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -272,7 +272,7 @@ static void menu_driver_toggle(bool latch) event_cmd_ctl(EVENT_CMD_AUDIO_START, NULL); /* Prevent stray input from going to libretro core */ - input_driver_ctl(RARCH_INPUT_CTL_SET_FLUSHING_INPUT, NULL); + input_driver_set_flushing_input(); /* Restore libretro keyboard callback. */ if (key_event && frontend_key_event) diff --git a/menu/menu_input.c b/menu/menu_input.c index 950f71ac19..65d37d66a1 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -140,7 +140,7 @@ static void menu_input_key_end_line(void) menu_input_ctl(MENU_INPUT_CTL_UNSET_KEYBOARD_LABEL_SETTING, NULL); /* Avoid triggering states on pressing return. */ - input_driver_ctl(RARCH_INPUT_CTL_SET_FLUSHING_INPUT, NULL); + input_driver_set_flushing_input(); } static void menu_input_search_cb(void *userdata, const char *str) @@ -599,7 +599,7 @@ static bool menu_input_key_bind_iterate(char *s, size_t len) if (menu_input->binds.begin > menu_input->binds.last) { /* Avoid new binds triggering things right away. */ - input_driver_ctl(RARCH_INPUT_CTL_SET_FLUSHING_INPUT, NULL); + input_driver_set_flushing_input(); /* We won't be getting any key events, so just cancel early. */ if (timed_out) @@ -619,7 +619,7 @@ static bool menu_input_key_bind_iterate(char *s, size_t len) input_driver_keyboard_mapping_set_block(false); /* Avoid new binds triggering things right away. */ - input_driver_ctl(RARCH_INPUT_CTL_SET_FLUSHING_INPUT, NULL); + input_driver_set_flushing_input(); binds.begin++; diff --git a/netplay/netplay.c b/netplay/netplay.c index 78c5b7feba..7158455c74 100644 --- a/netplay/netplay.c +++ b/netplay/netplay.c @@ -135,12 +135,11 @@ static bool get_self_input_state(netplay_t *netplay) { uint32_t state[UDP_WORDS_PER_FRAME - 1] = {0}; struct delta_frame *ptr = &netplay->buffer[netplay->self_ptr]; - settings_t *settings = config_get_ptr(); - if (!input_driver_ctl(RARCH_INPUT_CTL_IS_LIBRETRO_INPUT_BLOCKED, NULL) - && netplay->frame_count > 0) + if (!input_driver_is_libretro_input_blocked() && netplay->frame_count > 0) { unsigned i; + settings_t *settings = config_get_ptr(); /* First frame we always give zero input since relying on * input from first frame screws up when we use -F 0. */ diff --git a/runloop.c b/runloop.c index 32ce249a2e..279aac1c02 100644 --- a/runloop.c +++ b/runloop.c @@ -259,7 +259,7 @@ static bool runloop_cmd_get_state_menu_toggle_button_combo( break; } - input_driver_ctl(RARCH_INPUT_CTL_SET_FLUSHING_INPUT, NULL); + input_driver_set_flushing_input(); return true; } #endif @@ -321,17 +321,17 @@ static void check_fast_forward_button(bool fastforward_pressed, */ if (fastforward_pressed) { - if (input_driver_ctl(RARCH_INPUT_CTL_IS_NONBLOCK_STATE, NULL)) - input_driver_ctl(RARCH_INPUT_CTL_UNSET_NONBLOCK_STATE, NULL); + if (input_driver_is_nonblock_state()) + input_driver_unset_nonblock_state(); else - input_driver_ctl(RARCH_INPUT_CTL_SET_NONBLOCK_STATE, NULL); + input_driver_set_nonblock_state(); } else if (old_hold_pressed != hold_pressed) { if (hold_pressed) - input_driver_ctl(RARCH_INPUT_CTL_SET_NONBLOCK_STATE, NULL); + input_driver_set_nonblock_state(); else - input_driver_ctl(RARCH_INPUT_CTL_UNSET_NONBLOCK_STATE, NULL); + input_driver_unset_nonblock_state(); } else return; @@ -1205,19 +1205,19 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) static void runloop_iterate_linefeed_overlay(settings_t *settings) { static char prev_overlay_restore = false; - bool osk_enable = input_driver_ctl(RARCH_INPUT_CTL_IS_OSK_ENABLED, NULL); + bool osk_enable = input_driver_is_onscreen_keyboard_enabled(); if (osk_enable && !input_keyboard_ctl( RARCH_INPUT_KEYBOARD_CTL_IS_LINEFEED_ENABLED, NULL)) { - input_driver_ctl(RARCH_INPUT_CTL_UNSET_OSK_ENABLED, NULL); + input_driver_unset_onscreen_keyboard_enabled(); prev_overlay_restore = true; event_cmd_ctl(EVENT_CMD_OVERLAY_DEINIT, NULL); } else if (!osk_enable && input_keyboard_ctl( RARCH_INPUT_KEYBOARD_CTL_IS_LINEFEED_ENABLED, NULL)) { - input_driver_ctl(RARCH_INPUT_CTL_SET_OSK_ENABLED, NULL); + input_driver_set_onscreen_keyboard_enabled(); prev_overlay_restore = false; event_cmd_ctl(EVENT_CMD_OVERLAY_INIT, NULL); } @@ -1322,9 +1322,9 @@ int runloop_iterate(unsigned *sleep_ms) runloop_ctl(RUNLOOP_CTL_UNSET_FRAME_LIMIT, NULL); } - if (input_driver_ctl(RARCH_INPUT_CTL_IS_FLUSHING_INPUT, NULL)) + if (input_driver_is_flushing_input()) { - input_driver_ctl(RARCH_INPUT_CTL_UNSET_FLUSHING_INPUT, NULL); + input_driver_unset_flushing_input(); if (cmd.state[0]) { cmd.state[0] = 0; @@ -1333,7 +1333,7 @@ int runloop_iterate(unsigned *sleep_ms) * pause toggle to wake it up. */ if (runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL)) BIT64_SET(cmd.state[0], RARCH_PAUSE_TOGGLE); - input_driver_ctl(RARCH_INPUT_CTL_SET_FLUSHING_INPUT, NULL); + input_driver_set_flushing_input(); } } @@ -1345,8 +1345,8 @@ int runloop_iterate(unsigned *sleep_ms) retro_time_t current = retro_get_time_usec(); retro_time_t delta = current - runloop_frame_time_last; bool is_locked_fps = (runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL) || - input_driver_ctl(RARCH_INPUT_CTL_IS_NONBLOCK_STATE, NULL)) | - !!recording_driver_get_data_ptr(); + input_driver_is_nonblock_state()) | + !!recording_driver_get_data_ptr(); if (!runloop_frame_time_last || is_locked_fps) @@ -1477,7 +1477,7 @@ int runloop_iterate(unsigned *sleep_ms) } if ((settings->video.frame_delay > 0) && - !input_driver_ctl(RARCH_INPUT_CTL_IS_NONBLOCK_STATE, NULL)) + !input_driver_is_nonblock_state()) retro_sleep(settings->video.frame_delay); core_run(); diff --git a/tasks/task_overlay.c b/tasks/task_overlay.c index 277d8be133..4427038171 100644 --- a/tasks/task_overlay.c +++ b/tasks/task_overlay.c @@ -755,8 +755,7 @@ bool rarch_task_push_overlay_load_default( retro_task_callback_t cb, void *user_data) { settings_t *settings = config_get_ptr(); - bool osk_enable = - input_driver_ctl(RARCH_INPUT_CTL_IS_OSK_ENABLED, NULL); + bool osk_enable = input_driver_is_onscreen_keyboard_enabled(); if (osk_enable) { From 8ac6d05e55d2de2ea4d7d23b7c634ae448fc1dcf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Mon, 9 May 2016 04:16:23 +0700 Subject: [PATCH 302/498] (XMB) Use variables instead of defines for icon alpha. --- menu/drivers/xmb.c | 79 ++++++++++++++++++++++++---------------------- 1 file changed, 42 insertions(+), 37 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index df7dc973f6..a4f6116330 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -56,11 +56,6 @@ #define XMB_DELAY 10 #endif -#define XMB_CATEGORIES_ACTIVE_ALPHA 1.0 -#define XMB_CATEGORIES_PASSIVE_ALPHA 0.85 -#define XMB_ITEM_ACTIVE_ALPHA 1.0 -#define XMB_ITEM_PASSIVE_ALPHA 0.85 - typedef struct { float alpha; @@ -177,6 +172,11 @@ typedef struct xmb_handle float categories_active_zoom; float categories_passive_zoom; + float item_active_zoom; + float item_passive_zoom; + + float categories_active_alpha; + float categories_passive_alpha; float item_active_alpha; float item_passive_alpha; @@ -769,8 +769,8 @@ static void xmb_selection_pointer_changed( for (i = 0; i < end; i++) { float iy, real_iy; - float ia = XMB_ITEM_PASSIVE_ALPHA; - float iz = xmb->item_passive_alpha; + float ia = xmb->item_passive_alpha; + float iz = xmb->item_passive_zoom; xmb_node_t *node = (xmb_node_t*) menu_entries_get_userdata_at_offset(selection_buf, i); @@ -782,8 +782,8 @@ static void xmb_selection_pointer_changed( if (i == selection) { - ia = XMB_ITEM_ACTIVE_ALPHA; - iz = xmb->item_active_alpha; + ia = xmb->item_active_alpha; + iz = xmb->item_active_zoom; depth = xmb_list_get_size(xmb, MENU_LIST_PLAIN); if (strcmp(xmb_thumbnails_ident(), "OFF") && depth == 1) @@ -853,7 +853,7 @@ static void xmb_list_open_old(xmb_handle_t *xmb, continue; if (i == current) - ia = XMB_ITEM_ACTIVE_ALPHA; + ia = xmb->item_active_alpha; if (dir == -1) ia = 0; @@ -926,9 +926,9 @@ static void xmb_list_open_new(xmb_handle_t *xmb, if (i == current) node->zoom = xmb->categories_active_zoom;; - ia = XMB_ITEM_PASSIVE_ALPHA; + ia = xmb->item_passive_alpha; if (i == current) - ia = XMB_ITEM_ACTIVE_ALPHA; + ia = xmb->item_active_alpha; if (real_y < -threshold || real_y > height+threshold) { @@ -973,12 +973,12 @@ static xmb_node_t *xmb_node_allocate_userdata(xmb_handle_t *xmb, unsigned i) return NULL; } - node->alpha = XMB_CATEGORIES_PASSIVE_ALPHA; + node->alpha = xmb->categories_passive_alpha; node->zoom = xmb->categories_passive_zoom; if ((i + XMB_SYSTEM_TAB_END) == xmb->categories.active.idx) { - node->alpha = XMB_CATEGORIES_ACTIVE_ALPHA; + node->alpha = xmb->categories_active_alpha; node->zoom = xmb->categories_active_zoom;; } @@ -1083,7 +1083,7 @@ static void xmb_list_switch_new(xmb_handle_t *xmb, { xmb_node_t *node = (xmb_node_t*) menu_entries_get_userdata_at_offset(list, i); - float ia = XMB_ITEM_PASSIVE_ALPHA; + float ia = xmb->item_passive_alpha; if (!node) continue; @@ -1093,7 +1093,7 @@ static void xmb_list_switch_new(xmb_handle_t *xmb, node->label_alpha = 0; if (i == current) - ia = XMB_ITEM_ACTIVE_ALPHA; + ia = xmb->item_active_alpha; xmb_push_animations(node, ia, 0); } @@ -1150,7 +1150,7 @@ static void xmb_list_switch_horizontal_list(xmb_handle_t *xmb) for (j = 0; j <= list_size; j++) { menu_animation_ctx_entry_t entry; - float ia = XMB_CATEGORIES_PASSIVE_ALPHA; + float ia = xmb->categories_passive_alpha; float iz = xmb->categories_passive_zoom; xmb_node_t *node = xmb_get_node(xmb, j); @@ -1159,7 +1159,7 @@ static void xmb_list_switch_horizontal_list(xmb_handle_t *xmb) if (j == xmb->categories.active.idx) { - ia = XMB_CATEGORIES_ACTIVE_ALPHA; + ia = xmb->categories_active_alpha; iz = xmb->categories_active_zoom;; } @@ -1237,9 +1237,9 @@ static void xmb_list_open_horizontal_list(xmb_handle_t *xmb) continue; if (j == xmb->categories.active.idx) - ia = XMB_CATEGORIES_ACTIVE_ALPHA; + ia = xmb->categories_active_alpha; else if (xmb->depth <= 1) - ia = XMB_CATEGORIES_PASSIVE_ALPHA; + ia = xmb->categories_passive_alpha; entry.duration = XMB_DELAY; entry.target_value = ia; @@ -1321,11 +1321,11 @@ static void xmb_toggle_horizontal_list(xmb_handle_t *xmb) if (i == xmb->categories.active.idx) { - node->alpha = XMB_CATEGORIES_ACTIVE_ALPHA; + node->alpha = xmb->categories_active_alpha; node->zoom = xmb->categories_active_zoom;; } else if (xmb->depth <= 1) - node->alpha = XMB_CATEGORIES_PASSIVE_ALPHA; + node->alpha = xmb->categories_passive_alpha; } } @@ -2332,8 +2332,13 @@ static void xmb_layout(xmb_handle_t *xmb) xmb->categories_active_zoom = 1.0; xmb->categories_passive_zoom = 0.5; - xmb->item_active_alpha = 1.0; - xmb->item_passive_alpha = 0.5; + xmb->item_active_zoom = 1.0; + xmb->item_passive_zoom = 0.5; + + xmb->categories_active_alpha = 1.0; + xmb->categories_passive_alpha = 0.85; + xmb->item_active_alpha = 1.0; + xmb->item_passive_alpha = 0.85; /* Mimic the layout of the PSP instead of the PS3 on tiny screens */ if (width <= 640) @@ -2369,8 +2374,8 @@ static void xmb_layout(xmb_handle_t *xmb) for (i = 0; i < end; i++) { - float ia = XMB_ITEM_PASSIVE_ALPHA; - float iz = xmb->item_passive_alpha; + float ia = xmb->item_passive_alpha; + float iz = xmb->item_passive_zoom; xmb_node_t *node = (xmb_node_t*)menu_entries_get_userdata_at_offset( selection_buf, i); @@ -2379,7 +2384,7 @@ static void xmb_layout(xmb_handle_t *xmb) if (i == current) { - ia = XMB_ITEM_ACTIVE_ALPHA; + ia = xmb->item_active_alpha; iz = xmb->item_active_alpha; } @@ -2398,7 +2403,7 @@ static void xmb_layout(xmb_handle_t *xmb) for (i = 0; i < end; i++) { float ia = 0; - float iz = xmb->item_passive_alpha; + float iz = xmb->item_passive_zoom; xmb_node_t *node = (xmb_node_t*)menu_entries_get_userdata_at_offset( xmb->selection_buf_old, i); @@ -2407,7 +2412,7 @@ static void xmb_layout(xmb_handle_t *xmb) if (i == current) { - ia = XMB_ITEM_ACTIVE_ALPHA; + ia = xmb->item_active_alpha; iz = xmb->item_active_alpha; } @@ -2707,19 +2712,19 @@ static void xmb_context_reset_textures( menu_display_allocate_white_texture(); xmb->main_menu_node.icon = xmb->textures.list[XMB_TEXTURE_MAIN_MENU]; - xmb->main_menu_node.alpha = XMB_CATEGORIES_ACTIVE_ALPHA; + xmb->main_menu_node.alpha = xmb->categories_active_alpha; xmb->main_menu_node.zoom = xmb->categories_active_zoom;; xmb->settings_tab_node.icon = xmb->textures.list[XMB_TEXTURE_SETTINGS]; - xmb->settings_tab_node.alpha = XMB_CATEGORIES_ACTIVE_ALPHA; + xmb->settings_tab_node.alpha = xmb->categories_active_alpha; xmb->settings_tab_node.zoom = xmb->categories_active_zoom;; xmb->history_tab_node.icon = xmb->textures.list[XMB_TEXTURE_HISTORY]; - xmb->history_tab_node.alpha = XMB_CATEGORIES_ACTIVE_ALPHA; + xmb->history_tab_node.alpha = xmb->categories_active_alpha; xmb->history_tab_node.zoom = xmb->categories_active_zoom;; xmb->add_tab_node.icon = xmb->textures.list[XMB_TEXTURE_ADD]; - xmb->add_tab_node.alpha = XMB_CATEGORIES_ACTIVE_ALPHA; + xmb->add_tab_node.alpha = xmb->categories_active_alpha; xmb->add_tab_node.zoom = xmb->categories_active_zoom;; } @@ -2823,16 +2828,16 @@ static void xmb_list_insert(void *userdata, } current = selection; - node->alpha = XMB_ITEM_PASSIVE_ALPHA; - node->zoom = xmb->item_passive_alpha; + node->alpha = xmb->item_passive_alpha; + node->zoom = xmb->item_passive_zoom; node->label_alpha = node->alpha; node->y = xmb_item_y(xmb, i, current); node->x = 0; if (i == current) { - node->alpha = XMB_ITEM_ACTIVE_ALPHA; - node->label_alpha = XMB_ITEM_ACTIVE_ALPHA; + node->alpha = xmb->item_active_alpha; + node->label_alpha = xmb->item_active_alpha; node->zoom = xmb->item_active_alpha; } From a5f06e9250af7ed8ae0745076300d09eca1b874b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Mon, 9 May 2016 04:19:34 +0700 Subject: [PATCH 303/498] (XMB) Refactor variable names --- menu/drivers/xmb.c | 68 ++++++++++++++++++++++++---------------------- 1 file changed, 36 insertions(+), 32 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index a4f6116330..eec72b2419 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -170,13 +170,9 @@ typedef struct xmb_handle float active_item_factor; float under_item_offset; - float categories_active_zoom; - float categories_passive_zoom; float item_active_zoom; float item_passive_zoom; - float categories_active_alpha; - float categories_passive_alpha; float item_active_alpha; float item_passive_alpha; @@ -218,8 +214,16 @@ typedef struct xmb_handle { unsigned idx; unsigned idx_old; + float alpha; + float zoom; } active; + struct + { + float alpha; + float zoom; + } passive; + float x_pos; size_t selection_ptr_old; size_t selection_ptr; @@ -919,12 +923,12 @@ static void xmb_list_open_new(xmb_handle_t *xmb, node->x = xmb->icon.size * dir * 2; node->y = xmb_item_y(xmb, i, current); - node->zoom = xmb->categories_passive_zoom; + node->zoom = xmb->categories.passive.zoom; real_y = node->y + xmb->margins.screen.top; if (i == current) - node->zoom = xmb->categories_active_zoom;; + node->zoom = xmb->categories.active.zoom; ia = xmb->item_passive_alpha; if (i == current) @@ -973,13 +977,13 @@ static xmb_node_t *xmb_node_allocate_userdata(xmb_handle_t *xmb, unsigned i) return NULL; } - node->alpha = xmb->categories_passive_alpha; - node->zoom = xmb->categories_passive_zoom; + node->alpha = xmb->categories.passive.alpha; + node->zoom = xmb->categories.passive.zoom; if ((i + XMB_SYSTEM_TAB_END) == xmb->categories.active.idx) { - node->alpha = xmb->categories_active_alpha; - node->zoom = xmb->categories_active_zoom;; + node->alpha = xmb->categories.active.alpha; + node->zoom = xmb->categories.active.zoom; } file_list_free_actiondata(xmb->horizontal_list, i); @@ -1150,8 +1154,8 @@ static void xmb_list_switch_horizontal_list(xmb_handle_t *xmb) for (j = 0; j <= list_size; j++) { menu_animation_ctx_entry_t entry; - float ia = xmb->categories_passive_alpha; - float iz = xmb->categories_passive_zoom; + float ia = xmb->categories.passive.alpha; + float iz = xmb->categories.passive.zoom; xmb_node_t *node = xmb_get_node(xmb, j); if (!node) @@ -1159,8 +1163,8 @@ static void xmb_list_switch_horizontal_list(xmb_handle_t *xmb) if (j == xmb->categories.active.idx) { - ia = xmb->categories_active_alpha; - iz = xmb->categories_active_zoom;; + ia = xmb->categories.active.alpha; + iz = xmb->categories.active.zoom; } entry.duration = XMB_DELAY; @@ -1237,9 +1241,9 @@ static void xmb_list_open_horizontal_list(xmb_handle_t *xmb) continue; if (j == xmb->categories.active.idx) - ia = xmb->categories_active_alpha; + ia = xmb->categories.active.alpha; else if (xmb->depth <= 1) - ia = xmb->categories_passive_alpha; + ia = xmb->categories.passive.alpha; entry.duration = XMB_DELAY; entry.target_value = ia; @@ -1317,15 +1321,15 @@ static void xmb_toggle_horizontal_list(xmb_handle_t *xmb) continue; node->alpha = 0; - node->zoom = xmb->categories_passive_zoom; + node->zoom = xmb->categories.passive.zoom; if (i == xmb->categories.active.idx) { - node->alpha = xmb->categories_active_alpha; - node->zoom = xmb->categories_active_zoom;; + node->alpha = xmb->categories.active.alpha; + node->zoom = xmb->categories.active.zoom; } else if (xmb->depth <= 1) - node->alpha = xmb->categories_passive_alpha; + node->alpha = xmb->categories.passive.alpha; } } @@ -2330,13 +2334,13 @@ static void xmb_layout(xmb_handle_t *xmb) xmb->active_item_factor = 3.0; xmb->under_item_offset = 5.0; - xmb->categories_active_zoom = 1.0; - xmb->categories_passive_zoom = 0.5; + xmb->categories.active.zoom = 1.0; + xmb->categories.passive.zoom = 0.5; xmb->item_active_zoom = 1.0; xmb->item_passive_zoom = 0.5; - xmb->categories_active_alpha = 1.0; - xmb->categories_passive_alpha = 0.85; + xmb->categories.active.alpha = 1.0; + xmb->categories.passive.alpha = 0.85; xmb->item_active_alpha = 1.0; xmb->item_passive_alpha = 0.85; @@ -2712,20 +2716,20 @@ static void xmb_context_reset_textures( menu_display_allocate_white_texture(); xmb->main_menu_node.icon = xmb->textures.list[XMB_TEXTURE_MAIN_MENU]; - xmb->main_menu_node.alpha = xmb->categories_active_alpha; - xmb->main_menu_node.zoom = xmb->categories_active_zoom;; + xmb->main_menu_node.alpha = xmb->categories.active.alpha; + xmb->main_menu_node.zoom = xmb->categories.active.zoom; xmb->settings_tab_node.icon = xmb->textures.list[XMB_TEXTURE_SETTINGS]; - xmb->settings_tab_node.alpha = xmb->categories_active_alpha; - xmb->settings_tab_node.zoom = xmb->categories_active_zoom;; + xmb->settings_tab_node.alpha = xmb->categories.active.alpha; + xmb->settings_tab_node.zoom = xmb->categories.active.zoom; xmb->history_tab_node.icon = xmb->textures.list[XMB_TEXTURE_HISTORY]; - xmb->history_tab_node.alpha = xmb->categories_active_alpha; - xmb->history_tab_node.zoom = xmb->categories_active_zoom;; + xmb->history_tab_node.alpha = xmb->categories.active.alpha; + xmb->history_tab_node.zoom = xmb->categories.active.zoom; xmb->add_tab_node.icon = xmb->textures.list[XMB_TEXTURE_ADD]; - xmb->add_tab_node.alpha = xmb->categories_active_alpha; - xmb->add_tab_node.zoom = xmb->categories_active_zoom;; + xmb->add_tab_node.alpha = xmb->categories.active.alpha; + xmb->add_tab_node.zoom = xmb->categories.active.zoom; } static void xmb_context_reset_background(const char *iconpath) From 91835daee857a70673123caf4214af88a91bcb26 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Mon, 9 May 2016 04:22:22 +0700 Subject: [PATCH 304/498] (XMB) Refactor variable names --- menu/drivers/xmb.c | 71 ++++++++++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 31 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index eec72b2419..625c314163 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -170,12 +170,6 @@ typedef struct xmb_handle float active_item_factor; float under_item_offset; - float item_active_zoom; - float item_passive_zoom; - - float item_active_alpha; - float item_passive_alpha; - float shadow_offset; char title_name[256]; @@ -229,6 +223,21 @@ typedef struct xmb_handle size_t selection_ptr; } categories; + struct + { + struct + { + float alpha; + float zoom; + } active; + + struct + { + float alpha; + float zoom; + } passive; + } items; + xmb_node_t main_menu_node; xmb_node_t settings_tab_node; xmb_node_t history_tab_node; @@ -773,8 +782,8 @@ static void xmb_selection_pointer_changed( for (i = 0; i < end; i++) { float iy, real_iy; - float ia = xmb->item_passive_alpha; - float iz = xmb->item_passive_zoom; + float ia = xmb->items.passive.alpha; + float iz = xmb->items.passive.zoom; xmb_node_t *node = (xmb_node_t*) menu_entries_get_userdata_at_offset(selection_buf, i); @@ -786,8 +795,8 @@ static void xmb_selection_pointer_changed( if (i == selection) { - ia = xmb->item_active_alpha; - iz = xmb->item_active_zoom; + ia = xmb->items.active.alpha; + iz = xmb->items.active.zoom; depth = xmb_list_get_size(xmb, MENU_LIST_PLAIN); if (strcmp(xmb_thumbnails_ident(), "OFF") && depth == 1) @@ -857,7 +866,7 @@ static void xmb_list_open_old(xmb_handle_t *xmb, continue; if (i == current) - ia = xmb->item_active_alpha; + ia = xmb->items.active.alpha; if (dir == -1) ia = 0; @@ -930,9 +939,9 @@ static void xmb_list_open_new(xmb_handle_t *xmb, if (i == current) node->zoom = xmb->categories.active.zoom; - ia = xmb->item_passive_alpha; + ia = xmb->items.passive.alpha; if (i == current) - ia = xmb->item_active_alpha; + ia = xmb->items.active.alpha; if (real_y < -threshold || real_y > height+threshold) { @@ -1087,7 +1096,7 @@ static void xmb_list_switch_new(xmb_handle_t *xmb, { xmb_node_t *node = (xmb_node_t*) menu_entries_get_userdata_at_offset(list, i); - float ia = xmb->item_passive_alpha; + float ia = xmb->items.passive.alpha; if (!node) continue; @@ -1097,7 +1106,7 @@ static void xmb_list_switch_new(xmb_handle_t *xmb, node->label_alpha = 0; if (i == current) - ia = xmb->item_active_alpha; + ia = xmb->items.active.alpha; xmb_push_animations(node, ia, 0); } @@ -2336,13 +2345,13 @@ static void xmb_layout(xmb_handle_t *xmb) xmb->categories.active.zoom = 1.0; xmb->categories.passive.zoom = 0.5; - xmb->item_active_zoom = 1.0; - xmb->item_passive_zoom = 0.5; + xmb->items.active.zoom = 1.0; + xmb->items.passive.zoom = 0.5; xmb->categories.active.alpha = 1.0; xmb->categories.passive.alpha = 0.85; - xmb->item_active_alpha = 1.0; - xmb->item_passive_alpha = 0.85; + xmb->items.active.alpha = 1.0; + xmb->items.passive.alpha = 0.85; /* Mimic the layout of the PSP instead of the PS3 on tiny screens */ if (width <= 640) @@ -2378,8 +2387,8 @@ static void xmb_layout(xmb_handle_t *xmb) for (i = 0; i < end; i++) { - float ia = xmb->item_passive_alpha; - float iz = xmb->item_passive_zoom; + float ia = xmb->items.passive.alpha; + float iz = xmb->items.passive.zoom; xmb_node_t *node = (xmb_node_t*)menu_entries_get_userdata_at_offset( selection_buf, i); @@ -2388,8 +2397,8 @@ static void xmb_layout(xmb_handle_t *xmb) if (i == current) { - ia = xmb->item_active_alpha; - iz = xmb->item_active_alpha; + ia = xmb->items.active.alpha; + iz = xmb->items.active.alpha; } node->alpha = ia; @@ -2407,7 +2416,7 @@ static void xmb_layout(xmb_handle_t *xmb) for (i = 0; i < end; i++) { float ia = 0; - float iz = xmb->item_passive_zoom; + float iz = xmb->items.passive.zoom; xmb_node_t *node = (xmb_node_t*)menu_entries_get_userdata_at_offset( xmb->selection_buf_old, i); @@ -2416,8 +2425,8 @@ static void xmb_layout(xmb_handle_t *xmb) if (i == current) { - ia = xmb->item_active_alpha; - iz = xmb->item_active_alpha; + ia = xmb->items.active.alpha; + iz = xmb->items.active.alpha; } node->alpha = ia; @@ -2832,17 +2841,17 @@ static void xmb_list_insert(void *userdata, } current = selection; - node->alpha = xmb->item_passive_alpha; - node->zoom = xmb->item_passive_zoom; + node->alpha = xmb->items.passive.alpha; + node->zoom = xmb->items.passive.zoom; node->label_alpha = node->alpha; node->y = xmb_item_y(xmb, i, current); node->x = 0; if (i == current) { - node->alpha = xmb->item_active_alpha; - node->label_alpha = xmb->item_active_alpha; - node->zoom = xmb->item_active_alpha; + node->alpha = xmb->items.active.alpha; + node->label_alpha = xmb->items.active.alpha; + node->zoom = xmb->items.active.alpha; } file_list_set_userdata(list, i, node); From e07bba66f3f20daadbebf1bdd102ba8fb8915f6b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sun, 8 May 2016 23:52:05 +0200 Subject: [PATCH 305/498] Buildfix --- input/input_driver.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/input/input_driver.c b/input/input_driver.c index 3998dacf2e..f85b05433f 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -902,7 +902,7 @@ bool input_driver_init_remote(void) return true; #else - return false + return false; #endif } From 7bb4af1e6d2c20fe252fc936c8420ccace1d06e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Mon, 9 May 2016 05:12:40 +0700 Subject: [PATCH 306/498] (XMB) separate ps3 and psp displays and start introducing more differences --- menu/drivers/xmb.c | 124 +++++++++++++++++++++++++++++++-------------- 1 file changed, 87 insertions(+), 37 deletions(-) diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index 625c314163..a1b2dd0bcc 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -2319,24 +2319,13 @@ static void xmb_font(xmb_handle_t *xmb) RARCH_WARN("Failed to load font."); } -static void xmb_layout(xmb_handle_t *xmb) +static void xmb_layout_ps3(xmb_handle_t *xmb, int width) { - int new_font_size; - size_t selection; + unsigned new_font_size, new_header_height; float scale_factor; - unsigned width, height, i, current, end, new_header_height; - file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0); settings_t *settings = config_get_ptr(); - if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection)) - return; - - video_driver_get_size(&width, &height); - - scale_factor = (settings->menu.xmb_scale_factor * width) / (1920.0 * 100); - new_font_size = 32.0 * scale_factor; - xmb->margins.screen.left = 336.0 * scale_factor; - xmb->shadow_offset = 2.0; + scale_factor = (settings->menu.xmb_scale_factor * width) / (1920.0 * 100); xmb->above_subitem_offset = 1.5; xmb->above_item_offset = -1.0; @@ -2350,37 +2339,98 @@ static void xmb_layout(xmb_handle_t *xmb) xmb->categories.active.alpha = 1.0; xmb->categories.passive.alpha = 0.85; - xmb->items.active.alpha = 1.0; - xmb->items.passive.alpha = 0.85; + xmb->items.active.alpha = 1.0; + xmb->items.passive.alpha = 0.85; - /* Mimic the layout of the PSP instead of the PS3 on tiny screens */ - if (width <= 640) - { - scale_factor = scale_factor * 1.5; - xmb->margins.screen.left = 136.0 * scale_factor; - new_font_size = 42.0 * scale_factor; - xmb->shadow_offset = 1.0; - } + xmb->shadow_offset = 2.0; - new_header_height = 128.0 * scale_factor; - xmb->margins.screen.top = (256+32) * scale_factor; + new_font_size = 32.0 * scale_factor; + new_header_height = 128.0 * scale_factor; + xmb->margins.screen.top = (256+32) * scale_factor; - xmb->thumbnail_width = 460.0 * scale_factor; - xmb->cursor.size = 64.0; + xmb->thumbnail_width = 460.0 * scale_factor; + xmb->cursor.size = 64.0; - xmb->icon.spacing.horizontal = 200.0 * scale_factor; - xmb->icon.spacing.vertical = 64.0 * scale_factor; + xmb->icon.spacing.horizontal = 200.0 * scale_factor; + xmb->icon.spacing.vertical = 64.0 * scale_factor; - xmb->margins.title.left = 60 * scale_factor; - xmb->margins.title.top = 60 * scale_factor + new_font_size / 3; - xmb->margins.title.bottom = 60 * scale_factor - new_font_size / 3; - xmb->margins.label.left = 85.0 * scale_factor; - xmb->margins.label.top = new_font_size / 3.0; - xmb->margins.setting.left = 600.0 * scale_factor; - xmb->icon.size = 128.0 * scale_factor; + xmb->margins.screen.left = 336.0 * scale_factor; + xmb->margins.title.left = 60 * scale_factor; + xmb->margins.title.top = 60 * scale_factor + new_font_size / 3; + xmb->margins.title.bottom = 60 * scale_factor - new_font_size / 3; + xmb->margins.label.left = 85.0 * scale_factor; + xmb->margins.label.top = new_font_size / 3.0; + xmb->margins.setting.left = 600.0 * scale_factor; + xmb->icon.size = 128.0 * scale_factor; menu_display_set_font_size(new_font_size); menu_display_set_header_height(new_header_height); +} + +static void xmb_layout_psp(xmb_handle_t *xmb, int width) +{ + unsigned new_font_size, new_header_height; + float scale_factor; + settings_t *settings = config_get_ptr(); + + scale_factor = ((settings->menu.xmb_scale_factor * width) / (1920.0 * 100)) * 1.5; + + xmb->above_subitem_offset = 1.5; + xmb->above_item_offset = -1.0; + xmb->active_item_factor = 2.0; + xmb->under_item_offset = 3.0; + + xmb->categories.active.zoom = 1.0; + xmb->categories.passive.zoom = 1.0; + xmb->items.active.zoom = 1.0; + xmb->items.passive.zoom = 1.0; + + xmb->categories.active.alpha = 1.0; + xmb->categories.passive.alpha = 0.85; + xmb->items.active.alpha = 1.0; + xmb->items.passive.alpha = 0.85; + + xmb->shadow_offset = 1.0; + + new_font_size = 32.0 * scale_factor; + new_header_height = 128.0 * scale_factor; + xmb->margins.screen.top = (256+32) * scale_factor; + + xmb->thumbnail_width = 460.0 * scale_factor; + xmb->cursor.size = 64.0; + + xmb->icon.spacing.horizontal = 250.0 * scale_factor; + xmb->icon.spacing.vertical = 108.0 * scale_factor; + + xmb->margins.screen.left = 136.0 * scale_factor; + xmb->margins.title.left = 60 * scale_factor; + xmb->margins.title.top = 60 * scale_factor + new_font_size / 3; + xmb->margins.title.bottom = 60 * scale_factor - new_font_size / 3; + xmb->margins.label.left = 85.0 * scale_factor; + xmb->margins.label.top = new_font_size / 3.0; + xmb->margins.setting.left = 600.0 * scale_factor; + xmb->icon.size = 128.0 * scale_factor; + + menu_display_set_font_size(new_font_size); + menu_display_set_header_height(new_header_height); +} + +static void xmb_layout(xmb_handle_t *xmb) +{ + size_t selection; + unsigned width, height, i, current, end; + file_list_t *selection_buf = menu_entries_get_selection_buf_ptr(0); + + if (!menu_navigation_ctl(MENU_NAVIGATION_CTL_GET_SELECTION, &selection)) + return; + + video_driver_get_size(&width, &height); + + /* Mimic the layout of the PSP instead of the PS3 on tiny screens */ + if (width > 320) + xmb_layout_ps3(xmb, width); + else + xmb_layout_psp(xmb, width); current = selection; end = menu_entries_get_end(); From 3f3adf0c0ece38c600a6f1fa90a303dc07a23146 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 May 2016 02:50:02 +0200 Subject: [PATCH 307/498] Add return value for inet_aton --- libretro-common/net/net_compat.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libretro-common/net/net_compat.c b/libretro-common/net/net_compat.c index 452fb04dcc..744955fbd4 100644 --- a/libretro-common/net/net_compat.c +++ b/libretro-common/net/net_compat.c @@ -152,6 +152,7 @@ int inet_aton(const char *cp, struct in_addr *inp) return -1; inp->s_addr = addr; + return 1; } #endif From d57395effb35f5c17d0affb486944fee0e4e6443 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 May 2016 02:51:51 +0200 Subject: [PATCH 308/498] Define HAVE_ZLIB_DEFLATE --- pkg/android/phoenix/jni/Android.mk | 2 +- pkg/android/phoenix/jni/Android2.mk | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/android/phoenix/jni/Android.mk b/pkg/android/phoenix/jni/Android.mk index 9e485d03fc..fac9cf6e7e 100644 --- a/pkg/android/phoenix/jni/Android.mk +++ b/pkg/android/phoenix/jni/Android.mk @@ -52,7 +52,7 @@ else GLES_LIB := -lGLESv2 endif -DEFINES += -DRARCH_MOBILE -DHAVE_GRIFFIN -DANDROID -DHAVE_DYNAMIC -DHAVE_OPENGL -DHAVE_FBO -DHAVE_OVERLAY -DHAVE_OPENGLES -DHAVE_OPENGLES2 -DGLSL_DEBUG -DHAVE_DYLIB -DHAVE_EGL -DHAVE_GLSL -DHAVE_MENU -DHAVE_RGUI -DHAVE_ZLIB -DHAVE_RPNG -DINLINE=inline -DHAVE_THREADS -D__LIBRETRO__ -DHAVE_RSOUND -DHAVE_NETPLAY -DHAVE_NETWORKING -DRARCH_INTERNAL -DHAVE_FILTERS_BUILTIN -DHAVE_MATERIALUI -DHAVE_XMB -DHAVE_LIBRETRODB -DHAVE_STB_FONT +DEFINES += -DRARCH_MOBILE -DHAVE_GRIFFIN -DANDROID -DHAVE_DYNAMIC -DHAVE_OPENGL -DHAVE_FBO -DHAVE_OVERLAY -DHAVE_OPENGLES -DHAVE_OPENGLES2 -DGLSL_DEBUG -DHAVE_DYLIB -DHAVE_EGL -DHAVE_GLSL -DHAVE_MENU -DHAVE_RGUI -DHAVE_ZLIB -DHAVE_ZLIB_DEFLATE -DHAVE_RPNG -DINLINE=inline -DHAVE_THREADS -D__LIBRETRO__ -DHAVE_RSOUND -DHAVE_NETPLAY -DHAVE_NETWORKING -DRARCH_INTERNAL -DHAVE_FILTERS_BUILTIN -DHAVE_MATERIALUI -DHAVE_XMB -DHAVE_LIBRETRODB -DHAVE_STB_FONT DEFINES += -DWANT_IFADDRS ifeq ($(HAVE_VULKAN),1) diff --git a/pkg/android/phoenix/jni/Android2.mk b/pkg/android/phoenix/jni/Android2.mk index e17a379890..06ec713d76 100644 --- a/pkg/android/phoenix/jni/Android2.mk +++ b/pkg/android/phoenix/jni/Android2.mk @@ -52,7 +52,7 @@ else GLES_LIB := -lGLESv2 endif -DEFINES += -DRARCH_MOBILE -DHAVE_GRIFFIN -DANDROID -DHAVE_DYNAMIC -DHAVE_OPENGL -DHAVE_FBO -DHAVE_OVERLAY -DHAVE_OPENGLES -DHAVE_OPENGLES2 -DGLSL_DEBUG -DHAVE_DYLIB -DHAVE_GLSL -DHAVE_MENU -DHAVE_RGUI -DHAVE_ZLIB -DHAVE_RPNG -DINLINE=inline -DHAVE_THREADS -D__LIBRETRO__ -DHAVE_RSOUND -DHAVE_NETPLAY -DHAVE_NETWORKING -DRARCH_INTERNAL -DHAVE_FILTERS_BUILTIN -DHAVE_MATERIALUI -DHAVE_XMB -std=gnu99 -DHAVE_LIBRETRODB -DHAVE_STB_FONT +DEFINES += -DRARCH_MOBILE -DHAVE_GRIFFIN -DANDROID -DHAVE_DYNAMIC -DHAVE_OPENGL -DHAVE_FBO -DHAVE_OVERLAY -DHAVE_OPENGLES -DHAVE_OPENGLES2 -DGLSL_DEBUG -DHAVE_DYLIB -DHAVE_GLSL -DHAVE_MENU -DHAVE_RGUI -DHAVE_ZLIB -DHAVE_ZLIB_DEFLATE -DHAVE_RPNG -DINLINE=inline -DHAVE_THREADS -D__LIBRETRO__ -DHAVE_RSOUND -DHAVE_NETPLAY -DHAVE_NETWORKING -DRARCH_INTERNAL -DHAVE_FILTERS_BUILTIN -DHAVE_MATERIALUI -DHAVE_XMB -std=gnu99 -DHAVE_LIBRETRODB -DHAVE_STB_FONT DEFINES += -DWANT_IFADDRS ifeq ($(HAVE_VULKAN),1) From 4e535f77c63915581d75807e7fe4197e2556d470 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 May 2016 03:40:59 +0200 Subject: [PATCH 309/498] Add gl_check_mipmap --- gfx/drivers/gl.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 776c67fd1f..525f3a64e3 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -182,6 +182,14 @@ static bool gl_check_sync_proc(gl_t *gl) } #endif +static bool gl_check_mipmap(gl_t *gl) +{ + if (!gl_query_extension(gl, "ARB_framebuffer_object")) + return false; + + return glGenerateMipmap; +} + #ifndef HAVE_OPENGLES static bool gl_init_vao(gl_t *gl) { @@ -1157,7 +1165,8 @@ static void gl_frame_fbo(gl_t *gl, uint64_t frame_count, mip_level = i + 1; - if (video_shader_driver_mipmap_input(&mip_level)) + if (video_shader_driver_mipmap_input(&mip_level) + && gl_check_mipmap(gl)) glGenerateMipmap(GL_TEXTURE_2D); glClear(GL_COLOR_BUFFER_BIT); @@ -1232,7 +1241,8 @@ static void gl_frame_fbo(gl_t *gl, uint64_t frame_count, mip_level = gl->fbo_pass + 1; - if (video_shader_driver_mipmap_input(&mip_level)) + if (video_shader_driver_mipmap_input(&mip_level) + && gl_check_mipmap(gl)) glGenerateMipmap(GL_TEXTURE_2D); glClear(GL_COLOR_BUFFER_BIT); @@ -1822,7 +1832,7 @@ static bool gl_frame(void *data, const void *frame, /* No point regenerating mipmaps * if there are no new frames. */ - if (gl->tex_mipmap) + if (gl->tex_mipmap && gl_check_mipmap(gl)) glGenerateMipmap(GL_TEXTURE_2D); } From ca976aeda9772d97237b5871e51b7356db858694 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 May 2016 03:44:46 +0200 Subject: [PATCH 310/498] Make gl_load_texture_data a static function --- gfx/common/gl_common.c | 56 ------------------------------------------ gfx/drivers/gl.c | 52 ++++++++++++++++++++++++++++++++++++++- 2 files changed, 51 insertions(+), 57 deletions(-) diff --git a/gfx/common/gl_common.c b/gfx/common/gl_common.c index 30ebd6d982..7c78c63d46 100644 --- a/gfx/common/gl_common.c +++ b/gfx/common/gl_common.c @@ -16,13 +16,6 @@ #include "gl_common.h" -extern void gl_load_texture_data(uint32_t id_data, - enum gfx_wrap_type wrap_type, - enum texture_filter_type filter_type, - unsigned alignment, - unsigned width, unsigned height, - const void *frame, unsigned base_size); - void gl_ff_vertex(const struct gfx_coords *coords) { #ifndef NO_GL_FF_VERTEX @@ -53,52 +46,3 @@ void gl_ff_matrix(const math_matrix_4x4 *mat) glLoadMatrixf(ident.data); #endif } - -bool gl_load_luts(const struct video_shader *shader, - GLuint *textures_lut) -{ - unsigned i; - unsigned num_luts = MIN(shader->luts, GFX_MAX_TEXTURES); - - if (!shader->luts) - return true; - - glGenTextures(num_luts, textures_lut); - - for (i = 0; i < num_luts; i++) - { - struct texture_image img = {0}; - enum texture_filter_type filter_type = TEXTURE_FILTER_LINEAR; - - RARCH_LOG("Loading texture image from: \"%s\" ...\n", - shader->lut[i].path); - - if (!video_texture_image_load(&img, shader->lut[i].path)) - { - RARCH_ERR("Failed to load texture image from: \"%s\"\n", - shader->lut[i].path); - return false; - } - - if (shader->lut[i].filter == RARCH_FILTER_NEAREST) - filter_type = TEXTURE_FILTER_NEAREST; - - if (shader->lut[i].mipmap) - { - if (filter_type == TEXTURE_FILTER_NEAREST) - filter_type = TEXTURE_FILTER_MIPMAP_NEAREST; - else - filter_type = TEXTURE_FILTER_MIPMAP_LINEAR; - } - - gl_load_texture_data(textures_lut[i], - shader->lut[i].wrap, - filter_type, 4, - img.width, img.height, - img.pixels, sizeof(uint32_t)); - video_texture_image_free(&img); - } - - glBindTexture(GL_TEXTURE_2D, 0); - return true; -} diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 525f3a64e3..6e2c6ea007 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -3259,7 +3259,8 @@ unsigned *height_p, size_t *pitch_p) } #endif -void gl_load_texture_data(uint32_t id_data, +static void gl_load_texture_data( + uint32_t id_data, enum gfx_wrap_type wrap_type, enum texture_filter_type filter_type, unsigned alignment, @@ -3330,6 +3331,55 @@ void gl_load_texture_data(uint32_t id_data, glGenerateMipmap(GL_TEXTURE_2D); } +bool gl_load_luts(const struct video_shader *shader, + GLuint *textures_lut) +{ + unsigned i; + unsigned num_luts = MIN(shader->luts, GFX_MAX_TEXTURES); + + if (!shader->luts) + return true; + + glGenTextures(num_luts, textures_lut); + + for (i = 0; i < num_luts; i++) + { + struct texture_image img = {0}; + enum texture_filter_type filter_type = TEXTURE_FILTER_LINEAR; + + RARCH_LOG("Loading texture image from: \"%s\" ...\n", + shader->lut[i].path); + + if (!video_texture_image_load(&img, shader->lut[i].path)) + { + RARCH_ERR("Failed to load texture image from: \"%s\"\n", + shader->lut[i].path); + return false; + } + + if (shader->lut[i].filter == RARCH_FILTER_NEAREST) + filter_type = TEXTURE_FILTER_NEAREST; + + if (shader->lut[i].mipmap) + { + if (filter_type == TEXTURE_FILTER_NEAREST) + filter_type = TEXTURE_FILTER_MIPMAP_NEAREST; + else + filter_type = TEXTURE_FILTER_MIPMAP_LINEAR; + } + + gl_load_texture_data(textures_lut[i], + shader->lut[i].wrap, + filter_type, 4, + img.width, img.height, + img.pixels, sizeof(uint32_t)); + video_texture_image_free(&img); + } + + glBindTexture(GL_TEXTURE_2D, 0); + return true; +} + #ifdef HAVE_OVERLAY static void gl_free_overlay(gl_t *gl); static bool gl_overlay_load(void *data, From 3e40b771089c52e2ce458697fec14f3e0e57a43c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 May 2016 03:49:57 +0200 Subject: [PATCH 311/498] Improve check for gl_check_mipmap --- gfx/drivers/gl.c | 49 ++++++++++++++++++++++++++++++------------------ 1 file changed, 31 insertions(+), 18 deletions(-) diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 6e2c6ea007..43bd5e556b 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -182,9 +182,19 @@ static bool gl_check_sync_proc(gl_t *gl) } #endif -static bool gl_check_mipmap(gl_t *gl) +static bool gl_check_mipmap(void) { - if (!gl_query_extension(gl, "ARB_framebuffer_object")) + static bool extension_queried = false; + static bool extension = false; + + if (!extension_queried) + { + gl_t *gl = (gl_t*)video_driver_get_ptr(false); + extension = gl_query_extension(gl, "ARB_framebuffer_object"); + extension_queried = true; + } + + if (!extension) return false; return glGenerateMipmap; @@ -1166,7 +1176,7 @@ static void gl_frame_fbo(gl_t *gl, uint64_t frame_count, mip_level = i + 1; if (video_shader_driver_mipmap_input(&mip_level) - && gl_check_mipmap(gl)) + && gl_check_mipmap()) glGenerateMipmap(GL_TEXTURE_2D); glClear(GL_COLOR_BUFFER_BIT); @@ -1242,7 +1252,7 @@ static void gl_frame_fbo(gl_t *gl, uint64_t frame_count, mip_level = gl->fbo_pass + 1; if (video_shader_driver_mipmap_input(&mip_level) - && gl_check_mipmap(gl)) + && gl_check_mipmap()) glGenerateMipmap(GL_TEXTURE_2D); glClear(GL_COLOR_BUFFER_BIT); @@ -1832,7 +1842,7 @@ static bool gl_frame(void *data, const void *frame, /* No point regenerating mipmaps * if there are no new frames. */ - if (gl->tex_mipmap && gl_check_mipmap(gl)) + if (gl->tex_mipmap && gl_check_mipmap()) glGenerateMipmap(GL_TEXTURE_2D); } @@ -3278,20 +3288,23 @@ static void gl_load_texture_data( glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, wrap); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, wrap); -#if defined(HAVE_OPENGLES2) || defined(HAVE_PSGL) || defined(OSX_PPC) - /* Assume no mipmapping support. */ - switch (filter_type) + if (!gl_check_mipmap()) { - case TEXTURE_FILTER_MIPMAP_LINEAR: - filter_type = TEXTURE_FILTER_LINEAR; - break; - case TEXTURE_FILTER_MIPMAP_NEAREST: - filter_type = TEXTURE_FILTER_NEAREST; - break; - default: - break; - } +#if defined(HAVE_OPENGLES2) || defined(HAVE_PSGL) || defined(OSX_PPC) + /* Assume no mipmapping support. */ + switch (filter_type) + { + case TEXTURE_FILTER_MIPMAP_LINEAR: + filter_type = TEXTURE_FILTER_LINEAR; + break; + case TEXTURE_FILTER_MIPMAP_NEAREST: + filter_type = TEXTURE_FILTER_NEAREST; + break; + default: + break; + } #endif + } switch (filter_type) { @@ -3327,7 +3340,7 @@ static void gl_load_texture_data( (use_rgba || !rgb32) ? GL_RGBA : RARCH_GL_TEXTURE_TYPE32, (rgb32) ? RARCH_GL_FORMAT32 : GL_UNSIGNED_SHORT_4_4_4_4, frame); - if (want_mipmap) + if (want_mipmap && gl_check_mipmap()) glGenerateMipmap(GL_TEXTURE_2D); } From 3dfd8a058420fd3b5c2844f434d1a0fcd496ecca Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 May 2016 04:31:21 +0200 Subject: [PATCH 312/498] Split up vertex/fragment shader conditionals for XMB ribbon --- ...=> legacy_pipeline_xmb_ribbon.glsl.vert.h} | 7 +-- ...cy_pipeline_xmb_ribbon_simple.glsl.vert.h} | 7 +-- .../modern_pipeline_xmb_ribbon.glsl.vert.h | 45 +++++++++++++++++++ ...ern_pipeline_xmb_ribbon_simple.glsl.vert.h | 29 ++++++++++++ gfx/drivers_shader/shader_glsl.c | 12 ++--- 5 files changed, 83 insertions(+), 17 deletions(-) rename gfx/drivers/gl_shaders/{pipeline_xmb_ribbon.glsl.vert.h => legacy_pipeline_xmb_ribbon.glsl.vert.h} (88%) rename gfx/drivers/gl_shaders/{pipeline_xmb_ribbon_simple.glsl.vert.h => legacy_pipeline_xmb_ribbon_simple.glsl.vert.h} (84%) create mode 100644 gfx/drivers/gl_shaders/modern_pipeline_xmb_ribbon.glsl.vert.h create mode 100644 gfx/drivers/gl_shaders/modern_pipeline_xmb_ribbon_simple.glsl.vert.h diff --git a/gfx/drivers/gl_shaders/pipeline_xmb_ribbon.glsl.vert.h b/gfx/drivers/gl_shaders/legacy_pipeline_xmb_ribbon.glsl.vert.h similarity index 88% rename from gfx/drivers/gl_shaders/pipeline_xmb_ribbon.glsl.vert.h rename to gfx/drivers/gl_shaders/legacy_pipeline_xmb_ribbon.glsl.vert.h index 7cbf564448..f3f6954d6d 100644 --- a/gfx/drivers/gl_shaders/pipeline_xmb_ribbon.glsl.vert.h +++ b/gfx/drivers/gl_shaders/legacy_pipeline_xmb_ribbon.glsl.vert.h @@ -1,11 +1,6 @@ -static const char *stock_vertex_xmb = - "#if __VERSION__ >= 130\n" - "#define COMPAT_VARYING out\n" - "#define COMPAT_ATTRIBUTE in\n" - "#else\n" +static const char *stock_vertex_xmb_legacy = "#define COMPAT_VARYING varying\n" "#define COMPAT_ATTRIBUTE attribute\n" - "#endif\n" "COMPAT_ATTRIBUTE vec3 VertexCoord;\n" "uniform float time;\n" "COMPAT_VARYING vec3 fragVertexEc;\n" diff --git a/gfx/drivers/gl_shaders/pipeline_xmb_ribbon_simple.glsl.vert.h b/gfx/drivers/gl_shaders/legacy_pipeline_xmb_ribbon_simple.glsl.vert.h similarity index 84% rename from gfx/drivers/gl_shaders/pipeline_xmb_ribbon_simple.glsl.vert.h rename to gfx/drivers/gl_shaders/legacy_pipeline_xmb_ribbon_simple.glsl.vert.h index d57edd8fac..41c26eef18 100644 --- a/gfx/drivers/gl_shaders/pipeline_xmb_ribbon_simple.glsl.vert.h +++ b/gfx/drivers/gl_shaders/legacy_pipeline_xmb_ribbon_simple.glsl.vert.h @@ -1,11 +1,6 @@ -static const char *stock_vertex_xmb_simple = - "#if __VERSION__ >= 130\n" - "#define COMPAT_VARYING out\n" - "#define COMPAT_ATTRIBUTE in\n" - "#else\n" +static const char *stock_vertex_xmb_simple_legacy = "#define COMPAT_VARYING varying\n" "#define COMPAT_ATTRIBUTE attribute\n" - "#endif\n" "COMPAT_ATTRIBUTE vec3 VertexCoord;\n" "uniform float time;\n" "float iqhash( float n )\n" diff --git a/gfx/drivers/gl_shaders/modern_pipeline_xmb_ribbon.glsl.vert.h b/gfx/drivers/gl_shaders/modern_pipeline_xmb_ribbon.glsl.vert.h new file mode 100644 index 0000000000..2bd5e2ddbf --- /dev/null +++ b/gfx/drivers/gl_shaders/modern_pipeline_xmb_ribbon.glsl.vert.h @@ -0,0 +1,45 @@ +static const char *stock_vertex_xmb_modern = + "#define COMPAT_VARYING out\n" + "#define COMPAT_ATTRIBUTE in\n" + "COMPAT_ATTRIBUTE vec3 VertexCoord;\n" + "uniform float time;\n" + "COMPAT_VARYING vec3 fragVertexEc;\n" + "float iqhash( float n )\n" + "{\n" + " return fract(sin(n)*43758.5453);\n" + "}\n" + "float noise( vec3 x )\n" + "{\n" + " vec3 p = floor(x);\n" + " vec3 f = fract(x);\n" + " f = f*f*(3.0-2.0*f);\n" + " float n = p.x + p.y*57.0 + 113.0*p.z;\n" + " return mix(mix(mix( iqhash(n+0.0 ), iqhash(n+1.0 ),f.x),\n" + " mix( iqhash(n+57.0 ), iqhash(n+58.0 ),f.x),f.y),\n" + " mix(mix( iqhash(n+113.0), iqhash(n+114.0),f.x),\n" + " mix( iqhash(n+170.0), iqhash(n+171.0),f.x),f.y),f.z);\n" + "}\n" + "float xmb_noise2( vec3 x )\n" + "{\n" + " return cos((x.z*1.0)*2.0);" + "}\n" + "void main()\n" + "{\n" + " vec3 v = vec3(VertexCoord.x, 0.0, VertexCoord.y);\n" + " vec3 v2 = v;\n" + " vec3 v3 = v;\n" + + " v.y = xmb_noise2(v2)/6.0;\n" + + " v3.x = v3.x + time/5.0;\n" + " v3.x = v3.x / 2.0;\n" + + " v3.z = v3.z + time/10.0;\n" + " v3.y = v3.y + time/100.0;\n" + + " v.z = v.z + noise(v3*7.0)/15.0;\n" + " v.y = v.y + noise(v3*7.0)/15.0 + cos(v.x*2.0-time/5.0)/5.0 - 0.3;\n" + + " gl_Position = vec4(v, 1.0);\n" + " fragVertexEc = gl_Position.xyz;\n" + "}\n"; diff --git a/gfx/drivers/gl_shaders/modern_pipeline_xmb_ribbon_simple.glsl.vert.h b/gfx/drivers/gl_shaders/modern_pipeline_xmb_ribbon_simple.glsl.vert.h new file mode 100644 index 0000000000..b57c396586 --- /dev/null +++ b/gfx/drivers/gl_shaders/modern_pipeline_xmb_ribbon_simple.glsl.vert.h @@ -0,0 +1,29 @@ +static const char *stock_vertex_xmb_simple_modern = + "#define COMPAT_VARYING out\n" + "#define COMPAT_ATTRIBUTE in\n" + "COMPAT_ATTRIBUTE vec3 VertexCoord;\n" + "uniform float time;\n" + "float iqhash( float n )\n" + "{\n" + " return fract(sin(n)*43758.5453);\n" + "}\n" + "float noise( vec3 x )\n" + "{\n" + " vec3 p = floor(x);\n" + " vec3 f = fract(x);\n" + " f = f*f*(3.0-2.0*f);\n" + " float n = p.x + p.y*57.0 + 113.0*p.z;\n" + " return mix(mix(mix( iqhash(n+0.0 ), iqhash(n+1.0 ),f.x),\n" + " mix( iqhash(n+57.0 ), iqhash(n+58.0 ),f.x),f.y),\n" + " mix(mix( iqhash(n+113.0), iqhash(n+114.0),f.x),\n" + " mix( iqhash(n+170.0), iqhash(n+171.0),f.x),f.y),f.z);\n" + "}\n" + "void main()\n" + "{\n" + " vec3 v = vec3(VertexCoord.x, 0.0, VertexCoord.y);\n" + " vec3 v2 = v;\n" + " v2.x = v2.x + time/2.0;\n" + " v2.z = v.z * 3.0;\n" + " v.y = -cos((v.x+v.z/3.0+time)*2.0)/10.0 - noise(v2.xyz)/4.0;\n" + " gl_Position = vec4(v, 1.0);\n" + "}\n"; diff --git a/gfx/drivers_shader/shader_glsl.c b/gfx/drivers_shader/shader_glsl.c index f93413bf8e..bde5eafe1e 100644 --- a/gfx/drivers_shader/shader_glsl.c +++ b/gfx/drivers_shader/shader_glsl.c @@ -124,10 +124,12 @@ static const char *glsl_prefixes[] = { #include "../drivers/gl_shaders/core_alpha_blend.glsl.vert.h" #include "../drivers/gl_shaders/core_alpha_blend.glsl.frag.h" -#include "../drivers/gl_shaders/pipeline_xmb_ribbon_simple.glsl.vert.h" +#include "../drivers/gl_shaders/legacy_pipeline_xmb_ribbon_simple.glsl.vert.h" +#include "../drivers/gl_shaders/modern_pipeline_xmb_ribbon_simple.glsl.vert.h" #include "../drivers/gl_shaders/pipeline_xmb_ribbon_simple.glsl.frag.h" #if !defined(HAVE_OPENGLES2) -#include "../drivers/gl_shaders/pipeline_xmb_ribbon.glsl.vert.h" +#include "../drivers/gl_shaders/legacy_pipeline_xmb_ribbon.glsl.vert.h" +#include "../drivers/gl_shaders/modern_pipeline_xmb_ribbon.glsl.vert.h" #include "../drivers/gl_shaders/pipeline_xmb_ribbon.glsl.frag.h" #endif @@ -900,10 +902,10 @@ static void *gl_glsl_init(void *data, const char *path) } #if defined(HAVE_OPENGLES2) - shader_prog_info.vertex = stock_vertex_xmb_simple; + shader_prog_info.vertex = stock_vertex_xmb_simple_legacy; shader_prog_info.fragment = stock_fragment_xmb_simple; #else - shader_prog_info.vertex = stock_vertex_xmb; + shader_prog_info.vertex = glsl_core ? stock_vertex_xmb_modern : stock_vertex_xmb_legacy; shader_prog_info.fragment = stock_fragment_xmb; #endif shader_prog_info.is_file = false; @@ -916,7 +918,7 @@ static void *gl_glsl_init(void *data, const char *path) gl_glsl_find_uniforms(glsl, 0, glsl->prg[VIDEO_SHADER_MENU].id, &glsl->uniforms[VIDEO_SHADER_MENU]); - shader_prog_info.vertex = stock_vertex_xmb_simple; + shader_prog_info.vertex = glsl_core ? stock_vertex_xmb_simple_modern : stock_vertex_xmb_simple_legacy; shader_prog_info.fragment = stock_fragment_xmb_simple; gl_glsl_compile_program( From 9c1d1f3af8bbda9855f9fb815ba620579a712a76 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 May 2016 04:38:20 +0200 Subject: [PATCH 313/498] (GL) Remove these conditionals - mipmap support should be detected at runtime --- gfx/drivers/gl.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 43bd5e556b..57f3b774f7 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -3290,7 +3290,6 @@ static void gl_load_texture_data( if (!gl_check_mipmap()) { -#if defined(HAVE_OPENGLES2) || defined(HAVE_PSGL) || defined(OSX_PPC) /* Assume no mipmapping support. */ switch (filter_type) { @@ -3303,7 +3302,6 @@ static void gl_load_texture_data( default: break; } -#endif } switch (filter_type) From e1d04737cb3dac004ebc42632626f13fbaad1777 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 May 2016 04:51:18 +0200 Subject: [PATCH 314/498] (OSX PPC) Add line to libretro-common/include/compat/zlib.h --- libretro-common/include/compat/zlib.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libretro-common/include/compat/zlib.h b/libretro-common/include/compat/zlib.h index bf3d53db40..b6cd5ed263 100644 --- a/libretro-common/include/compat/zlib.h +++ b/libretro-common/include/compat/zlib.h @@ -3,6 +3,10 @@ #ifdef WANT_ZLIB +#ifdef RARCH_INTERNAL +#include "../../../deps/zlib/zconf.h.in" +#endif + /* zlib.h -- interface of the 'zlib' general purpose compression library version 1.2.8, April 28th, 2013 From 7272a3fdaf34547623207bdc9fc7a4d65d9a26a7 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 May 2016 04:54:25 +0200 Subject: [PATCH 315/498] Prevent some warnings --- gfx/drivers/gl.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 57f3b774f7..d279bdfb1d 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -440,15 +440,15 @@ static void gl_compute_fbo_geometry(gl_t *gl, static void gl_create_fbo_texture(gl_t *gl, unsigned i, GLuint texture) { unsigned mip_level; - video_shader_ctx_wrap_t wrap; bool fp_fbo; GLenum min_filter, mag_filter, wrap_enum; video_shader_ctx_filter_t filter_type; - bool mipmapped = false; - bool smooth = false; - settings_t *settings = config_get_ptr(); - GLuint base_filt = settings->video.smooth ? GL_LINEAR : GL_NEAREST; - GLuint base_mip_filt = settings->video.smooth ? + video_shader_ctx_wrap_t wrap = {0}; + bool mipmapped = false; + bool smooth = false; + settings_t *settings = config_get_ptr(); + GLuint base_filt = settings->video.smooth ? GL_LINEAR : GL_NEAREST; + GLuint base_mip_filt = settings->video.smooth ? GL_LINEAR_MIPMAP_LINEAR : GL_NEAREST_MIPMAP_NEAREST; glBindTexture(GL_TEXTURE_2D, texture); @@ -2606,10 +2606,10 @@ static void *gl_init(const video_info_t *video, const input_driver_t **input, vo gfx_ctx_input_t inp; unsigned interval, mip_level; unsigned full_x, full_y; - video_shader_ctx_wrap_t wrap_info; video_shader_ctx_filter_t shader_filter; video_shader_ctx_info_t shader_info; video_shader_ctx_ident_t ident_info; + video_shader_ctx_wrap_t wrap_info = {0}; unsigned win_width = 0; unsigned win_height = 0; unsigned temp_width = 0; @@ -2923,13 +2923,13 @@ static bool gl_has_windowed(void *data) static void gl_update_tex_filter_frame(gl_t *gl) { - video_shader_ctx_wrap_t wrap_info; video_shader_ctx_filter_t shader_filter; unsigned i, mip_level; GLenum wrap_mode; GLuint new_filt; - bool smooth = false; - settings_t *settings = config_get_ptr(); + video_shader_ctx_wrap_t wrap_info = {0}; + bool smooth = false; + settings_t *settings = config_get_ptr(); if (!gl) return; @@ -3637,7 +3637,7 @@ static uintptr_t gl_get_current_framebuffer(void *data) static retro_proc_address_t gl_get_proc_address(void *data, const char *sym) { - gfx_ctx_proc_address_t proc_address; + gfx_ctx_proc_address_t proc_address = {0}; proc_address.sym = sym; From d50109f60ac605204265f6325cc1558eb55c5b3d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 May 2016 04:56:41 +0200 Subject: [PATCH 316/498] video_texture_image.c - prevent warning --- gfx/video_texture_image.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfx/video_texture_image.c b/gfx/video_texture_image.c index 966ac7812d..349a4332f7 100644 --- a/gfx/video_texture_image.c +++ b/gfx/video_texture_image.c @@ -233,8 +233,8 @@ static enum video_image_format video_texture_image_get_type(const char *path) bool video_texture_image_load(struct texture_image *out_img, const char *path) { - size_t file_len; unsigned r_shift, g_shift, b_shift, a_shift; + size_t file_len = 0; struct nbio_t *handle = NULL; void *ptr = NULL; enum video_image_format fmt = video_texture_image_get_type(path); From 44ed8d1116e165b470e2e1d0b80b237090b2832b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 May 2016 05:48:47 +0200 Subject: [PATCH 317/498] CXX_BUILD fixes --- command_event.c | 2 +- gfx/drivers/vulkan.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/command_event.c b/command_event.c index bf1a0defdb..969cebc8ac 100644 --- a/command_event.c +++ b/command_event.c @@ -1313,7 +1313,7 @@ bool event_cmd_ctl(enum event_command cmd, void *data) case EVENT_CMD_CORE_DEINIT: { struct retro_hw_render_callback *hwr = - hwr = video_driver_get_hw_context(); + video_driver_get_hw_context(); event_deinit_core(true); if (hwr) diff --git a/gfx/drivers/vulkan.c b/gfx/drivers/vulkan.c index e02995fac4..412529d79b 100644 --- a/gfx/drivers/vulkan.c +++ b/gfx/drivers/vulkan.c @@ -980,7 +980,7 @@ static void *vulkan_init(const video_info_t *video, if (!ctx_driver) goto error; - video_context_driver_set((void*)ctx_driver); + video_context_driver_set((const gfx_ctx_driver_t*)ctx_driver); video_context_driver_get_video_size(&mode); full_x = mode.width; From e87f030246640a89fa4042ad5c8b8e9336162edb Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 May 2016 05:50:08 +0200 Subject: [PATCH 318/498] C89_BUILD fixes --- gfx/video_driver.c | 3 ++- libretro-common/formats/jpeg/rjpeg.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/gfx/video_driver.c b/gfx/video_driver.c index b9259e7c23..04aea3453e 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -1574,9 +1574,10 @@ bool video_driver_find_driver(void) if (video_driver_is_hw_context()) { - current_video = NULL; struct retro_hw_render_callback *hwr = video_driver_get_hw_context(); + current_video = NULL; + if (hwr && hw_render_context_is_vulkan(hwr->context_type)) { #if defined(HAVE_VULKAN) diff --git a/libretro-common/formats/jpeg/rjpeg.c b/libretro-common/formats/jpeg/rjpeg.c index df45b8ffb5..d17673bf5d 100644 --- a/libretro-common/formats/jpeg/rjpeg.c +++ b/libretro-common/formats/jpeg/rjpeg.c @@ -41,7 +41,7 @@ enum CF3Y = (27), CF3Z = (-3), CF2A = (139), - CF2B = (-11), + CF2B = (-11) }; enum @@ -51,7 +51,7 @@ enum W3 = 2408, W5 = 1609, W6 = 1108, - W7 = 565, + W7 = 565 }; struct rjpeg_vlc_code From 87b83ecf560802c4fbe228d7054995fe6d946c33 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 May 2016 06:40:51 +0200 Subject: [PATCH 319/498] (RetroPad) Use socket_set_target --- cores/retropad/retropad.c | 15 ++++++--------- libretro-common/include/net/net_socket.h | 2 ++ 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/cores/retropad/retropad.c b/cores/retropad/retropad.c index f1648588f5..e2fd0f7c4a 100644 --- a/cores/retropad/retropad.c +++ b/cores/retropad/retropad.c @@ -234,7 +234,8 @@ void retro_run(void) bool retro_load_game(const struct retro_game_info *info) { - (void)info; + socket_target_t in_target; + check_variables(); s = socket_create( @@ -249,15 +250,11 @@ bool retro_load_game(const struct retro_game_info *info) /* setup address structure */ memset((char *) &si_other, 0, sizeof(si_other)); - si_other.sin_family = AF_INET; - si_other.sin_port = inet_htons(port); -#if defined(_WIN32) || defined(HAVE_SOCKET_LEGACY) - si_other.sin_addr.S_un.S_addr = inet_addr(server); -#else - si_other.sin_addr.s_addr = inet_addr(server); + in_target.port = port; + in_target.server = server; + in_target.domain = SOCKET_DOMAIN_INET; - inet_aton(server , &si_other.sin_addr); -#endif + socket_set_target(&si_other, &in_target); log_cb(RETRO_LOG_INFO, "Server IP Address: %s\n" , server); diff --git a/libretro-common/include/net/net_socket.h b/libretro-common/include/net/net_socket.h index c7a0524596..d2e73d33e4 100644 --- a/libretro-common/include/net/net_socket.h +++ b/libretro-common/include/net/net_socket.h @@ -84,6 +84,8 @@ int socket_create( enum socket_type socket_type, enum socket_protocol protocol_type); +void socket_set_target(void *data, socket_target_t *in_addr); + RETRO_END_DECLS #endif From a66aa1c50d1c8680725512043a9db113b7e73284 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 May 2016 06:42:59 +0200 Subject: [PATCH 320/498] Cleanups --- cores/retropad/retropad.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/cores/retropad/retropad.c b/cores/retropad/retropad.c index e2fd0f7c4a..608866b57d 100644 --- a/cores/retropad/retropad.c +++ b/cores/retropad/retropad.c @@ -46,15 +46,16 @@ #define SOCKET_ERROR -1 #endif +int s; +int port; +char message[64]; +char server[64]; +struct sockaddr_in si_other; struct retro_log_callback logger; retro_log_printf_t log_cb; static uint16_t *frame_buf; -struct sockaddr_in si_other; -int s, slen=sizeof(si_other); -char message[64]; -char server[64]; -int port; + int input_state = 0; void retro_init(void) @@ -224,7 +225,7 @@ void retro_run(void) snprintf(message, sizeof(message), "%d", input_state); /* send the message */ - if (sendto(s, message, strlen(message) , 0 , (struct sockaddr *) &si_other, slen)==-1) + if (sendto(s, message, strlen(message) , 0 , (struct sockaddr *) &si_other, sizeof(si_other))==-1) log_cb(RETRO_LOG_INFO, "Error sending data\n"); for (i = 0; i < 320 * 240; i++) From 3b344257d784dcc13f1d4cfd08eaa46f2a274aa6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 May 2016 06:46:08 +0200 Subject: [PATCH 321/498] (netplay.c) Refactor --- netplay/netplay.c | 45 ++++++++++++++++++++++++++------------------- 1 file changed, 26 insertions(+), 19 deletions(-) diff --git a/netplay/netplay.c b/netplay/netplay.c index 7158455c74..d7e39ef0a9 100644 --- a/netplay/netplay.c +++ b/netplay/netplay.c @@ -604,31 +604,38 @@ void np_log_connection(const struct sockaddr_storage *their_addr, u.storage = their_addr; - if (their_addr->ss_family == AF_INET) + switch (their_addr->ss_family) { - struct sockaddr_in in; + case AF_INET: + { + struct sockaddr_in in; - str = buf_v4; + memset(&in, 0, sizeof(in)); - memset(&in, 0, sizeof(in)); - in.sin_family = AF_INET; - memcpy(&in.sin_addr, &u.v4->sin_addr, sizeof(struct in_addr)); + str = buf_v4; + in.sin_family = AF_INET; + memcpy(&in.sin_addr, &u.v4->sin_addr, sizeof(struct in_addr)); - getnameinfo((struct sockaddr*)&in, sizeof(struct sockaddr_in), - buf_v4, sizeof(buf_v4), - NULL, 0, NI_NUMERICHOST); - } - else if (their_addr->ss_family == AF_INET6) - { - struct sockaddr_in6 in; + getnameinfo((struct sockaddr*)&in, sizeof(struct sockaddr_in), + buf_v4, sizeof(buf_v4), + NULL, 0, NI_NUMERICHOST); + } + break; + case AF_INET6: + { + struct sockaddr_in6 in; + memset(&in, 0, sizeof(in)); - str = buf_v6; - memset(&in, 0, sizeof(in)); - in.sin6_family = AF_INET6; - memcpy(&in.sin6_addr, &u.v6->sin6_addr, sizeof(struct in6_addr)); + str = buf_v6; + in.sin6_family = AF_INET6; + memcpy(&in.sin6_addr, &u.v6->sin6_addr, sizeof(struct in6_addr)); - getnameinfo((struct sockaddr*)&in, sizeof(struct sockaddr_in6), - buf_v6, sizeof(buf_v6), NULL, 0, NI_NUMERICHOST); + getnameinfo((struct sockaddr*)&in, sizeof(struct sockaddr_in6), + buf_v6, sizeof(buf_v6), NULL, 0, NI_NUMERICHOST); + } + break; + default: + break; } if (str) From f8a71545570f3ac070fdb4395d6461b059dc6fc2 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 May 2016 07:09:26 +0200 Subject: [PATCH 322/498] Rename rarch_ functions --- audio/audio_driver.c | 4 +- camera/camera_driver.c | 2 +- content.c | 3 +- dynamic.c | 10 ++--- gfx/video_driver.c | 6 +-- input/input_driver.c | 2 +- location/location_driver.c | 2 +- menu/cbs/menu_cbs_ok.c | 2 +- menu/menu_displaylist.c | 6 +-- menu/menu_driver.c | 6 +-- movie.c | 2 +- record/record_driver.c | 2 +- retroarch.c | 77 +++++++++++++++++++------------------- retroarch.h | 12 +++--- runloop.c | 2 +- 15 files changed, 69 insertions(+), 69 deletions(-) diff --git a/audio/audio_driver.c b/audio/audio_driver.c index 6c91324ea6..18ef6ae84c 100644 --- a/audio/audio_driver.c +++ b/audio/audio_driver.c @@ -355,7 +355,7 @@ static bool audio_driver_init_internal(bool audio_cb_inited) current_audio)) { RARCH_ERR("Cannot open threaded audio driver ... Exiting ...\n"); - retro_fail(1, "audio_driver_init_internal()"); + retroarch_fail(1, "audio_driver_init_internal()"); } } else @@ -775,7 +775,7 @@ bool audio_driver_find_driver(void) current_audio = (const audio_driver_t*)audio_driver_find_handle(0); if (!current_audio) - retro_fail(1, "audio_driver_find()"); + retroarch_fail(1, "audio_driver_find()"); } return true; diff --git a/camera/camera_driver.c b/camera/camera_driver.c index 673393f581..ae11e1b40b 100644 --- a/camera/camera_driver.c +++ b/camera/camera_driver.c @@ -153,7 +153,7 @@ bool camera_driver_ctl(enum rarch_camera_ctl_state state, void *data) camera_driver = (const camera_driver_t*)camera_driver_find_handle(0); if (!camera_driver) - retro_fail(1, "find_camera_driver()"); + retroarch_fail(1, "find_camera_driver()"); } } break; diff --git a/content.c b/content.c index 2957233816..6f10332dbc 100644 --- a/content.c +++ b/content.c @@ -855,7 +855,8 @@ static void content_load_init_wrap( * If no content file can be loaded, will start up RetroArch * as-is. * - * Returns: false (0) if rarch_main_init failed, otherwise true (1). + * Returns: false (0) if retroarch_main_init failed, + * otherwise true (1). **/ bool content_load(content_ctx_info_t *info) { diff --git a/dynamic.c b/dynamic.c index 37c7aee991..df878f5628 100644 --- a/dynamic.c +++ b/dynamic.c @@ -54,7 +54,7 @@ #define SYMBOL(x) do { \ function_t func = dylib_proc(lib_handle, #x); \ memcpy(¤t_core->x, &func, sizeof(func)); \ - if (current_core->x == NULL) { RARCH_ERR("Failed to load symbol: \"%s\"\n", #x); retro_fail(1, "init_libretro_sym()"); } \ + if (current_core->x == NULL) { RARCH_ERR("Failed to load symbol: \"%s\"\n", #x); retroarch_fail(1, "init_libretro_sym()"); } \ } while (0) static dylib_t lib_handle; @@ -307,14 +307,14 @@ static void load_dynamic_core(void) RARCH_ERR("This could happen if other modules RetroArch depends on " "link against libretro directly.\n"); RARCH_ERR("Proceeding could cause a crash. Aborting ...\n"); - retro_fail(1, "init_libretro_sym()"); + retroarch_fail(1, "init_libretro_sym()"); } if (!*settings->path.libretro) { RARCH_ERR("RetroArch is built for dynamic libretro cores, but " "libretro_path is not set. Cannot continue.\n"); - retro_fail(1, "init_libretro_sym()"); + retroarch_fail(1, "init_libretro_sym()"); } /* Need to use absolute path for this setting. It can be @@ -330,7 +330,7 @@ static void load_dynamic_core(void) RARCH_ERR("Failed to open libretro core: \"%s\"\n", settings->path.libretro); RARCH_ERR("Error(s): %s\n", dylib_error()); - retro_fail(1, "load_dynamic()"); + retroarch_fail(1, "load_dynamic()"); } } #endif @@ -740,7 +740,7 @@ bool rarch_environment_cb(unsigned cmd, void *data) break; case RETRO_ENVIRONMENT_GET_SAVE_DIRECTORY: - *(const char**)data = rarch_get_current_savefile_dir(); + *(const char**)data = retroarch_get_current_savefile_dir(); break; case RETRO_ENVIRONMENT_GET_USERNAME: diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 04aea3453e..70ca893c41 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -446,7 +446,7 @@ static void init_video_input(const input_driver_t *tmp) error: RARCH_ERR("Cannot initialize input driver. Exiting ...\n"); - retro_fail(1, "init_video_input()"); + retroarch_fail(1, "init_video_input()"); } /** @@ -754,7 +754,7 @@ static bool init_video(void) return true; error: - retro_fail(1, "init_video()"); + retroarch_fail(1, "init_video()"); return false; } @@ -1629,7 +1629,7 @@ bool video_driver_find_driver(void) current_video = (video_driver_t*)video_driver_find_handle(0); if (!current_video) - retro_fail(1, "find_video_driver()"); + retroarch_fail(1, "find_video_driver()"); } return true; } diff --git a/input/input_driver.c b/input/input_driver.c index f85b05433f..e4ebc63bfd 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -738,7 +738,7 @@ bool input_driver_find_driver(void) if (current_input) return true; - retro_fail(1, "find_input_driver()"); + retroarch_fail(1, "find_input_driver()"); return false; } diff --git a/location/location_driver.c b/location/location_driver.c index 18a4108ddc..4921fb1a92 100644 --- a/location/location_driver.c +++ b/location/location_driver.c @@ -114,7 +114,7 @@ void find_location_driver(void) location_driver = (const location_driver_t*)location_driver_find_handle(0); if (!location_driver) - retro_fail(1, "find_location_driver()"); + retroarch_fail(1, "find_location_driver()"); } } diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 0b84e6e4b3..be6dce1f11 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -1602,7 +1602,7 @@ static int action_ok_option_create(const char *path, char game_path[PATH_MAX_LENGTH]; config_file_t *conf = NULL; - if (!rarch_game_options_validate(game_path, sizeof(game_path), true)) + if (!retroarch_validate_game_options(game_path, sizeof(game_path), true)) { runloop_msg_queue_push("Error saving core options file", 1, 100, true); diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 965d5eaaf6..98134ed5c6 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -624,7 +624,7 @@ static int menu_displaylist_parse_system_info(menu_displaylist_info_t *info) MENU_SETTINGS_CORE_INFO_NONE, 0, 0); #endif - rarch_info_get_capabilities(RARCH_CAPABILITIES_COMPILER, tmp, sizeof(tmp)); + retroarch_get_capabilities(RARCH_CAPABILITIES_COMPILER, tmp, sizeof(tmp)); menu_entries_add(info->list, tmp, "", MENU_SETTINGS_CORE_INFO_NONE, 0, 0); #ifdef ANDROID @@ -644,7 +644,7 @@ static int menu_displaylist_parse_system_info(menu_displaylist_info_t *info) sizeof(cpu_str)); strlcat(cpu_str, ": ", sizeof(cpu_str)); - rarch_info_get_capabilities(RARCH_CAPABILITIES_CPU, + retroarch_get_capabilities(RARCH_CAPABILITIES_CPU, cpu_str, sizeof(cpu_str)); menu_entries_add(info->list, cpu_str, "", MENU_SETTINGS_CORE_INFO_NONE, 0, 0); @@ -2767,7 +2767,7 @@ static int menu_displaylist_parse_generic( if (settings->multimedia.builtin_mediaplayer_enable || settings->multimedia.builtin_imageviewer_enable) { - switch (rarch_path_is_media_type(path)) + switch (retroarch_path_is_media_type(path)) { case RARCH_CONTENT_MOVIE: #ifdef HAVE_FFMPEG diff --git a/menu/menu_driver.c b/menu/menu_driver.c index dfba2df776..3df92f0333 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -391,7 +391,7 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data) if (!menu_driver_ctx) { - retro_fail(1, "find_menu_driver()"); + retroarch_fail(1, "find_menu_driver()"); return false; } } @@ -583,7 +583,7 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data) if (!menu_driver_data || !menu_init(menu_driver_data)) { - retro_fail(1, "init_menu()"); + retroarch_fail(1, "init_menu()"); return false; } @@ -594,7 +594,7 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data) { if (!menu_driver_ctx->lists_init(menu_driver_data)) { - retro_fail(1, "init_menu()"); + retroarch_fail(1, "init_menu()"); return false; } } diff --git a/movie.c b/movie.c index 6d092322b7..933a3eadbe 100644 --- a/movie.c +++ b/movie.c @@ -310,7 +310,7 @@ static void bsv_movie_init_state(void) RARCH_ERR("%s: \"%s\".\n", msg_hash_to_str(MSG_FAILED_TO_LOAD_MOVIE_FILE), bsv_movie_state.movie_start_path); - retro_fail(1, "event_init_movie()"); + retroarch_fail(1, "event_init_movie()"); } bsv_movie_state.movie_playback = true; diff --git a/record/record_driver.c b/record/record_driver.c index d5e0bb71ad..e8ba91c8ce 100644 --- a/record/record_driver.c +++ b/record/record_driver.c @@ -116,7 +116,7 @@ void find_record_driver(void) recording_driver = (const record_driver_t*)record_driver_find_handle(0); if (!recording_driver) - retro_fail(1, "find_record_driver()"); + retroarch_fail(1, "find_record_driver()"); } } diff --git a/retroarch.c b/retroarch.c index 824243fee8..8d2fffd7be 100644 --- a/retroarch.c +++ b/retroarch.c @@ -168,7 +168,7 @@ static void print_features(void) } #undef _PSUPP -static void print_version(void) +static void retroarch_print_version(void) { char str[PATH_MAX_LENGTH] = {0}; @@ -177,20 +177,20 @@ static void print_version(void) #ifdef HAVE_GIT_VERSION printf(" -- %s --\n", rarch_git_version); #endif - rarch_info_get_capabilities(RARCH_CAPABILITIES_COMPILER, str, sizeof(str)); + retroarch_get_capabilities(RARCH_CAPABILITIES_COMPILER, str, sizeof(str)); fprintf(stdout, "%s", str); fprintf(stdout, "Built: %s\n", __DATE__); } /** - * print_help: + * retroarch_print_help: * * Prints help message explaining the program's commandline switches. **/ -static void print_help(const char *arg0) +static void retroarch_print_help(const char *arg0) { puts("==================================================================="); - print_version(); + retroarch_print_version(); puts("==================================================================="); printf("Usage: %s [OPTIONS]... [FILE]\n", arg0); @@ -386,7 +386,7 @@ static void set_special_paths(char **argv, unsigned num_content) RARCH_WARN("SYSTEM DIR is empty, assume CONTENT DIR %s\n",argv[0]); } -const char *rarch_get_current_savefile_dir(void) +const char *retroarch_get_current_savefile_dir(void) { global_t *global = global_get_ptr(); @@ -533,7 +533,7 @@ static void set_paths_redirect(const char *path) -enum rarch_content_type rarch_path_is_media_type(const char *path) +enum rarch_content_type retroarch_path_is_media_type(const char *path) { uint32_t hash_ext = msg_hash_calculate(path_get_extension(path)); @@ -724,7 +724,7 @@ static void parse_input(int argc, char *argv[]) switch (c) { case 'h': - print_help(argv[0]); + retroarch_print_help(argv[0]); exit(0); case 'd': @@ -744,8 +744,8 @@ static void parse_input(int argc, char *argv[]) if (port < 1 || port > MAX_USERS) { RARCH_ERR("Connect device to a valid port.\n"); - print_help(argv[0]); - retro_fail(1, "parse_input()"); + retroarch_print_help(argv[0]); + retroarch_fail(1, "parse_input()"); } settings->input.libretro_device[port - 1] = id; global->has_set.libretro_device[port - 1] = true; @@ -757,8 +757,8 @@ static void parse_input(int argc, char *argv[]) if (port < 1 || port > MAX_USERS) { RARCH_ERR("Connect dualanalog to a valid port.\n"); - print_help(argv[0]); - retro_fail(1, "parse_input()"); + retroarch_print_help(argv[0]); + retroarch_fail(1, "parse_input()"); } settings->input.libretro_device[port - 1] = RETRO_DEVICE_ANALOG; global->has_set.libretro_device[port - 1] = true; @@ -794,8 +794,8 @@ static void parse_input(int argc, char *argv[]) if (port < 1 || port > MAX_USERS) { RARCH_ERR("Disconnect device from a valid port.\n"); - print_help(argv[0]); - retro_fail(1, "parse_input()"); + retroarch_print_help(argv[0]); + retroarch_fail(1, "parse_input()"); } settings->input.libretro_device[port - 1] = RETRO_DEVICE_NONE; global->has_set.libretro_device[port - 1] = true; @@ -874,8 +874,8 @@ static void parse_input(int argc, char *argv[]) else if (!string_is_equal(optarg, "load-save")) { RARCH_ERR("Invalid argument in --sram-mode.\n"); - print_help(argv[0]); - retro_fail(1, "parse_input()"); + retroarch_print_help(argv[0]); + retroarch_fail(1, "parse_input()"); } break; @@ -957,7 +957,7 @@ static void parse_input(int argc, char *argv[]) if (rarch_cmd_send((const char*)optarg)) exit(0); else - retro_fail(1, "network_cmd_send()"); + retroarch_fail(1, "network_cmd_send()"); break; #endif @@ -972,8 +972,8 @@ static void parse_input(int argc, char *argv[]) &global->record.height) != 2) { RARCH_ERR("Wrong format for --size.\n"); - print_help(argv[0]); - retro_fail(1, "parse_input()"); + retroarch_print_help(argv[0]); + retroarch_fail(1, "parse_input()"); } break; } @@ -1003,7 +1003,7 @@ static void parse_input(int argc, char *argv[]) break; case RA_OPT_VERSION: - print_version(); + retroarch_print_version(); exit(0); #ifdef HAVE_FILE_LOGGER @@ -1013,12 +1013,12 @@ static void parse_input(int argc, char *argv[]) #endif case '?': - print_help(argv[0]); - retro_fail(1, "parse_input()"); + retroarch_print_help(argv[0]); + retroarch_fail(1, "parse_input()"); default: RARCH_ERR("Error parsing arguments.\n"); - retro_fail(1, "parse_input()"); + retroarch_fail(1, "parse_input()"); } } @@ -1027,7 +1027,7 @@ static void parse_input(int argc, char *argv[]) if (optind < argc) { RARCH_ERR("--menu was used, but content file was passed as well.\n"); - retro_fail(1, "parse_input()"); + retroarch_fail(1, "parse_input()"); } else { @@ -1155,7 +1155,7 @@ static void rarch_init_savefile_paths(void) } } -static bool init_state(void) +static bool retroarch_init_state(void) { video_driver_set_active(); audio_driver_set_active(); @@ -1165,7 +1165,7 @@ static bool init_state(void) return true; } -bool rarch_game_options_validate(char *s, size_t len, bool mkdir) +bool retroarch_validate_game_options(char *s, size_t len, bool mkdir) { char core_path[PATH_MAX_LENGTH]; char config_directory[PATH_MAX_LENGTH]; @@ -1213,7 +1213,7 @@ bool rarch_game_options_validate(char *s, size_t len, bool mkdir) } /** - * rarch_main_init: + * retroarch_main_init: * @argc : Count of (commandline) arguments. * @argv : (Commandline) arguments. * @@ -1221,12 +1221,12 @@ bool rarch_game_options_validate(char *s, size_t len, bool mkdir) * * Returns: 0 on success, otherwise 1 if there was an error. **/ -static int rarch_main_init(int argc, char *argv[]) +static int retroarch_main_init(int argc, char *argv[]) { int sjlj_ret; bool *verbosity = NULL; - init_state(); + retroarch_init_state(); if ((sjlj_ret = setjmp(error_sjlj_context)) > 0) { @@ -1245,7 +1245,7 @@ static int rarch_main_init(int argc, char *argv[]) char str[PATH_MAX_LENGTH] = {0}; RARCH_LOG_OUTPUT("=== Build ======================================="); - rarch_info_get_capabilities(RARCH_CAPABILITIES_CPU, str, sizeof(str)); + retroarch_get_capabilities(RARCH_CAPABILITIES_CPU, str, sizeof(str)); fprintf(stderr, "%s", str); fprintf(stderr, "Built: %s\n", __DATE__); RARCH_LOG_OUTPUT("Version: %s\n", PACKAGE_VERSION); @@ -1273,7 +1273,7 @@ static int rarch_main_init(int argc, char *argv[]) runloop_ctl(RUNLOOP_CTL_GET_CONTENT_PATH, &fullpath); - switch (rarch_path_is_media_type(fullpath)) + switch (retroarch_path_is_media_type(fullpath)) { case RARCH_CONTENT_MOVIE: case RARCH_CONTENT_MUSIC: @@ -1326,7 +1326,7 @@ error: #define FAIL_CPU(simd_type) do { \ RARCH_ERR(simd_type " code is compiled in, but CPU does not support this feature. Cannot continue.\n"); \ - retro_fail(1, "validate_cpu_features()"); \ + retroarch_fail(1, "validate_cpu_features()"); \ } while(0) bool rarch_ctl(enum rarch_ctl_state state, void *data) @@ -1434,13 +1434,13 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data) case RARCH_CTL_MAIN_INIT: { struct rarch_main_wrap *wrap = (struct rarch_main_wrap*)data; - if (rarch_main_init(wrap->argc, wrap->argv)) + if (retroarch_main_init(wrap->argc, wrap->argv)) return false; } break; case RARCH_CTL_INIT: rarch_ctl(RARCH_CTL_DEINIT, NULL); - init_state(); + retroarch_init_state(); { unsigned i; for (i = 0; i < MAX_USERS; i++) @@ -1589,8 +1589,7 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data) return true; } - -int rarch_info_get_capabilities(enum rarch_capabilities type, +int retroarch_get_capabilities(enum rarch_capabilities type, char *s, size_t len) { switch (type) @@ -1665,15 +1664,15 @@ int rarch_info_get_capabilities(enum rarch_capabilities type, } /** - * retro_fail: + * retroarch_fail: * @error_code : Error code. * @error : Error message to show. * * Sanely kills the program. **/ -void retro_fail(int error_code, const char *error) +void retroarch_fail(int error_code, const char *error) { - /* We cannot longjmp unless we're in rarch_main_init(). + /* We cannot longjmp unless we're in retroarch_main_init(). * If not, something went very wrong, and we should * just exit right away. */ retro_assert(rarch_ctl(RARCH_CTL_IS_ERROR_ON_INIT, NULL)); diff --git a/retroarch.h b/retroarch.h index 6305227873..253c659105 100644 --- a/retroarch.h +++ b/retroarch.h @@ -170,23 +170,23 @@ struct rarch_main_wrap bool rarch_ctl(enum rarch_ctl_state state, void *data); -int rarch_info_get_capabilities(enum rarch_capabilities type, +int retroarch_get_capabilities(enum rarch_capabilities type, char *s, size_t len); -enum rarch_content_type rarch_path_is_media_type(const char *path); +enum rarch_content_type retroarch_path_is_media_type(const char *path); -const char *rarch_get_current_savefile_dir(void); +const char *retroarch_get_current_savefile_dir(void); -bool rarch_game_options_validate(char *s, size_t len, bool mkdir); +bool retroarch_validate_game_options(char *s, size_t len, bool mkdir); /** - * retro_fail: + * retroarch_fail: * @error_code : Error code. * @error : Error message to show. * * Sanely kills the program. **/ -void retro_fail(int error_code, const char *error); +void retroarch_fail(int error_code, const char *error); #ifdef __cplusplus } diff --git a/runloop.c b/runloop.c index 279aac1c02..3154be7a65 100644 --- a/runloop.c +++ b/runloop.c @@ -493,7 +493,7 @@ static bool rarch_game_specific_options(char **output) char game_path[PATH_MAX_LENGTH]; config_file_t *option_file = NULL; - if (!rarch_game_options_validate(game_path, sizeof(game_path), false)) + if (!retroarch_validate_game_options(game_path, sizeof(game_path), false)) return false; option_file = config_file_new(game_path); From 372e7d94cdd6d20ae8b5fe23b6181bcdd4e7f713 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 May 2016 07:14:10 +0200 Subject: [PATCH 323/498] Rename rewind.c to state_manager --- Makefile.common | 2 +- command_event.c | 4 ++-- core_impl.c | 2 +- gfx/drivers_shader/shader_gl_cg.c | 2 +- gfx/drivers_shader/shader_glsl.c | 2 +- gfx/drivers_shader/shader_hlsl.c | 2 +- griffin/griffin.c | 4 ++-- runloop.c | 2 +- rewind.c => state_manager.c | 5 ++--- rewind.h => state_manager.h | 8 ++++---- 10 files changed, 16 insertions(+), 17 deletions(-) rename rewind.c => state_manager.c (99%) rename rewind.h => state_manager.h (93%) diff --git a/Makefile.common b/Makefile.common index 39c1b13713..6293255e73 100644 --- a/Makefile.common +++ b/Makefile.common @@ -157,7 +157,7 @@ OBJ += frontend/frontend.o \ dynamic.o \ cores/dynamic_dummy.o \ libretro-common/queues/message_queue.o \ - rewind.o \ + state_manager.o \ gfx/drivers_font_renderer/bitmapfont.o \ input/input_autodetect.o \ input/input_joypad_driver.o \ diff --git a/command_event.c b/command_event.c index 969cebc8ac..d7fe441311 100644 --- a/command_event.c +++ b/command_event.c @@ -37,7 +37,7 @@ #include "screenshot.h" #include "msg_hash.h" #include "retroarch.h" -#include "rewind.h" +#include "state_manager.h" #include "system.h" #include "ui/ui_companion_driver.h" #include "list_special.h" @@ -1183,7 +1183,7 @@ bool event_cmd_ctl(enum event_command cmd, void *data) #ifdef HAVE_NETPLAY if (!netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_DATA_INITED, NULL)) #endif - init_rewind(); + state_manager_event_init(); break; case EVENT_CMD_REWIND_TOGGLE: if (settings->rewind_enable) diff --git a/core_impl.c b/core_impl.c index 0f6671cac4..f494381b5e 100644 --- a/core_impl.c +++ b/core_impl.c @@ -30,7 +30,7 @@ #include "core.h" #include "general.h" #include "msg_hash.h" -#include "rewind.h" +#include "state_manager.h" #include "system.h" #include "gfx/video_driver.h" #include "audio/audio_driver.h" diff --git a/gfx/drivers_shader/shader_gl_cg.c b/gfx/drivers_shader/shader_gl_cg.c index ab1eb44872..b74363bf67 100644 --- a/gfx/drivers_shader/shader_gl_cg.c +++ b/gfx/drivers_shader/shader_gl_cg.c @@ -40,7 +40,7 @@ #include "../video_shader_parse.h" #include "../../core.h" #include "../../dynamic.h" -#include "../../rewind.h" +#include "../../state_manager.h" #include "../video_state_tracker.h" #include "../drivers/gl_shaders/pipeline_xmb_ribbon_simple.cg.h" diff --git a/gfx/drivers_shader/shader_glsl.c b/gfx/drivers_shader/shader_glsl.c index bde5eafe1e..0cbf335aa6 100644 --- a/gfx/drivers_shader/shader_glsl.c +++ b/gfx/drivers_shader/shader_glsl.c @@ -27,7 +27,7 @@ #include "shader_glsl.h" #include "../video_state_tracker.h" #include "../../dynamic.h" -#include "../../rewind.h" +#include "../../state_manager.h" #include "../../core.h" #ifdef HAVE_CONFIG_H diff --git a/gfx/drivers_shader/shader_hlsl.c b/gfx/drivers_shader/shader_hlsl.c index cd24d4674b..5fbf0ae3aa 100644 --- a/gfx/drivers_shader/shader_hlsl.c +++ b/gfx/drivers_shader/shader_hlsl.c @@ -20,7 +20,7 @@ #include "../video_shader_parse.h" #include "../d3d/d3d.h" -#include "../../rewind.h" +#include "../../state_manager.h" #include "../drivers/d3d_shaders/opaque.hlsl.d3d9.h" diff --git a/griffin/griffin.c b/griffin/griffin.c index e9e4060fae..9aa38f3899 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -668,9 +668,9 @@ CONFIGURATION #include "../configuration.c" /*============================================================ -REWIND +STATE MANAGER ============================================================ */ -#include "../rewind.c" +#include "../state_manager.c" /*============================================================ FRONTEND diff --git a/runloop.c b/runloop.c index 3154be7a65..400719d3b3 100644 --- a/runloop.c +++ b/runloop.c @@ -44,7 +44,7 @@ #include "movie.h" #include "retroarch.h" #include "runloop.h" -#include "rewind.h" +#include "state_manager.h" #include "system.h" #include "list_special.h" #include "audio/audio_driver.h" diff --git a/rewind.c b/state_manager.c similarity index 99% rename from rewind.c rename to state_manager.c index e0b2a05e87..cd7ee598d7 100644 --- a/rewind.c +++ b/state_manager.c @@ -21,7 +21,7 @@ #include -#include "rewind.h" +#include "state_manager.h" #include "configuration.h" #include "msg_hash.h" #include "movie.h" @@ -132,7 +132,6 @@ static size_t state_manager_raw_maxsize(size_t uncomp) static void *state_manager_raw_alloc(size_t len, uint16_t uniq) { size_t len16 = (len + sizeof(uint16_t) - 1) & -sizeof(uint16_t); - uint16_t *ret = (uint16_t*)calloc(len16 + sizeof(uint16_t) * 4 + 16, 1); /* Force in a different byte at the end, so we don't need to check @@ -621,7 +620,7 @@ static void state_manager_capacity(state_manager_t *state, } #endif -void init_rewind(void) +void state_manager_event_init(void) { retro_ctx_serialize_info_t serial_info; retro_ctx_size_info_t info; diff --git a/rewind.h b/state_manager.h similarity index 93% rename from rewind.h rename to state_manager.h index acd63177da..e023d55f2d 100644 --- a/rewind.h +++ b/state_manager.h @@ -15,8 +15,8 @@ * If not, see . */ -#ifndef __RARCH_REWIND_H -#define __RARCH_REWIND_H +#ifndef __STATE_MANAGER_H +#define __STATE_MANAGER_H #ifdef __cplusplus extern "C" { @@ -28,12 +28,12 @@ extern "C" { typedef struct state_manager state_manager_t; -void init_rewind(void); - bool state_manager_frame_is_reversed(void); void state_manager_event_deinit(void); +void state_manager_event_init(void); + /** * check_rewind: * @pressed : was rewind key pressed or held? From 685b234350935c180def77d9c396e1a6393394d5 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 May 2016 07:19:18 +0200 Subject: [PATCH 324/498] (remote.c) Rename functions --- input/input_driver.c | 11 +++++------ remote.c | 27 +++++++++++++++------------ remote.h | 19 +++++++++++-------- 3 files changed, 31 insertions(+), 26 deletions(-) diff --git a/input/input_driver.c b/input/input_driver.c index e4ebc63bfd..ac6284c62a 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -99,7 +99,7 @@ static turbo_buttons_t input_driver_turbo_btns; static rarch_cmd_t *input_driver_command = NULL; #endif #ifdef HAVE_NETWORK_GAMEPAD -static rarch_remote_t *input_driver_remote = NULL; +static input_remote_t *input_driver_remote = NULL; #endif static const input_driver_t *current_input = NULL; static void *current_input_data = NULL; @@ -441,7 +441,7 @@ void input_poll(void) #ifdef HAVE_NETWORK_GAMEPAD if (input_driver_remote) - rarch_remote_poll(input_driver_remote); + input_remote_poll(input_driver_remote); #endif } @@ -490,7 +490,7 @@ int16_t input_state(unsigned port, unsigned device, #endif #ifdef HAVE_NETWORK_GAMEPAD - input_state_remote(&res, port, device, idx, id); + input_remote_state(&res, port, device, idx, id); #endif } @@ -878,7 +878,7 @@ void input_driver_deinit_remote(void) { #ifdef HAVE_NETWORK_GAMEPAD if (input_driver_remote) - rarch_remote_free(input_driver_remote); + input_remote_free(input_driver_remote); input_driver_remote = NULL; #endif } @@ -891,8 +891,7 @@ bool input_driver_init_remote(void) if (!settings->network_remote_enable) return false; - input_driver_remote - = rarch_remote_new(settings->network_remote_base_port); + input_driver_remote = input_remote_new(settings->network_remote_base_port); if (!input_driver_remote) { diff --git a/remote.c b/remote.c index 2aeb6bd576..6c5c021b6d 100644 --- a/remote.c +++ b/remote.c @@ -38,7 +38,7 @@ #define DEFAULT_NETWORK_GAMEPAD_PORT 55400 #define UDP_FRAME_PACKETS 16 -struct rarch_remote +struct input_remote { #if defined(HAVE_NETWORK_GAMEPAD) && defined(HAVE_NETPLAY) @@ -64,7 +64,7 @@ static input_remote_state_t *input_remote_get_state_ptr(void) } #if defined(HAVE_NETWORK_GAMEPAD) && defined(HAVE_NETPLAY) -static bool remote_init_network(rarch_remote_t *handle, +static bool input_remote_init_network(input_remote_t *handle, uint16_t port, unsigned user) { int fd; @@ -104,13 +104,13 @@ error: } #endif -rarch_remote_t *rarch_remote_new(uint16_t port) +input_remote_t *input_remote_new(uint16_t port) { unsigned user; #if defined(HAVE_NETWORK_GAMEPAD) && defined(HAVE_NETPLAY) settings_t *settings = config_get_ptr(); #endif - rarch_remote_t *handle = (rarch_remote_t*) + input_remote_t *handle = (input_remote_t*) calloc(1, sizeof(*handle)); if (!handle) @@ -123,7 +123,7 @@ rarch_remote_t *rarch_remote_new(uint16_t port) { handle->net_fd[user] = -1; if(settings->network_remote_enable_user[user]) - if (!remote_init_network(handle, port, user)) + if (!input_remote_init_network(handle, port, user)) goto error; } #endif @@ -132,12 +132,12 @@ rarch_remote_t *rarch_remote_new(uint16_t port) #if defined(HAVE_NETWORK_GAMEPAD) && defined(HAVE_NETPLAY) error: - rarch_remote_free(handle); + input_remote_free(handle); return NULL; #endif } -void rarch_remote_free(rarch_remote_t *handle) +void input_remote_free(input_remote_t *handle) { unsigned user; #if defined(HAVE_NETWORK_GAMEPAD) && defined(HAVE_NETPLAY) @@ -151,7 +151,7 @@ void rarch_remote_free(rarch_remote_t *handle) } #if defined(HAVE_NETWORK_GAMEPAD) && defined(HAVE_NETPLAY) -static void parse_packet(char *buffer, unsigned size, unsigned user) +static void input_remote_parse_packet(char *buffer, unsigned size, unsigned user) { input_remote_state_t *ol_state = input_remote_get_state_ptr(); /* todo implement parsing of input_state from the packet */ @@ -159,8 +159,11 @@ static void parse_packet(char *buffer, unsigned size, unsigned user) } #endif -void input_state_remote(int16_t *ret, - unsigned port, unsigned device, unsigned idx, +void input_remote_state( + int16_t *ret, + unsigned port, + unsigned device, + unsigned idx, unsigned id) { input_remote_state_t *ol_state = input_remote_get_state_ptr(); @@ -199,7 +202,7 @@ bool input_remote_key_pressed(int key, unsigned port) return (ol_state->buttons[port] & (UINT64_C(1) << key)); } -void rarch_remote_poll(rarch_remote_t *handle) +void input_remote_poll(input_remote_t *handle) { unsigned user; settings_t *settings = config_get_ptr(); @@ -225,7 +228,7 @@ void rarch_remote_poll(rarch_remote_t *handle) sizeof(buf) - 1, 0, NULL, NULL); if (ret > 0) - parse_packet(buf, sizeof(buf), user); + input_remote_parse_packet(buf, sizeof(buf), user); else #endif ol_state->buttons[user] = 0; diff --git a/remote.h b/remote.h index 83f1a9845c..da9ab4875b 100644 --- a/remote.h +++ b/remote.h @@ -14,8 +14,8 @@ * If not, see . */ -#ifndef REMOTE_H__ -#define REMOTE_H__ +#ifndef INPUT_REMOTE_H__ +#define INPUT_REMOTE_H__ #ifdef HAVE_CONFIG_H #include "config.h" @@ -28,18 +28,21 @@ extern "C" { #endif -typedef struct rarch_remote rarch_remote_t; +typedef struct input_remote input_remote_t; -rarch_remote_t *rarch_remote_new(uint16_t port); +input_remote_t *input_remote_new(uint16_t port); -void rarch_remote_free(rarch_remote_t *handle); +void input_remote_free(input_remote_t *handle); -void rarch_remote_poll(rarch_remote_t *handle); +void input_remote_poll(input_remote_t *handle); bool input_remote_key_pressed(int key, unsigned port); -void input_state_remote(int16_t *ret, - unsigned port, unsigned device, unsigned idx, +void input_remote_state( + int16_t *ret, + unsigned port, + unsigned device, + unsigned idx, unsigned id); #ifdef __cplusplus From b72f7001de1ad602fd6905d9566c212f5fa6500d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 May 2016 07:24:28 +0200 Subject: [PATCH 325/498] (retroarch.c) Rename functions --- retroarch.c | 52 +++++++++++++++++++++++++--------------------------- 1 file changed, 25 insertions(+), 27 deletions(-) diff --git a/retroarch.c b/retroarch.c index 8d2fffd7be..88c55ae5df 100644 --- a/retroarch.c +++ b/retroarch.c @@ -112,7 +112,7 @@ static jmp_buf error_sjlj_context; #define _PSUPP(var, name, desc) printf(" %s:\n\t\t%s: %s\n", name, desc, _##var##_supp ? "yes" : "no") -static void print_features(void) +static void retroarch_print_features(void) { puts(""); puts("Features:"); @@ -307,7 +307,7 @@ static void retroarch_print_help(const char *arg0) "then exits.\n"); } -static void set_basename(const char *path) +static void retroarch_set_basename(const char *path) { char *dst = NULL; global_t *global = global_get_ptr(); @@ -343,7 +343,7 @@ static void set_basename(const char *path) *dst = '\0'; } -static void set_special_paths(char **argv, unsigned num_content) +static void retroarch_set_special_paths(char **argv, unsigned num_content) { unsigned i; union string_list_elem_attr attr; @@ -351,7 +351,7 @@ static void set_special_paths(char **argv, unsigned num_content) settings_t *settings = config_get_ptr(); /* First content file is the significant one. */ - set_basename(argv[0]); + retroarch_set_basename(argv[0]); global->subsystem_fullpaths = string_list_new(); retro_assert(global->subsystem_fullpaths); @@ -402,7 +402,7 @@ const char *retroarch_get_current_savefile_dir(void) return ret; } -static void set_paths_redirect(const char *path) +static void retroarch_set_paths_redirect(const char *path) { char current_savestate_dir[PATH_MAX_LENGTH]; uint32_t global_library_name_hash = 0; @@ -414,7 +414,7 @@ static void set_paths_redirect(const char *path) runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); if (!global) { - RARCH_WARN("set_paths_redirect was sent a NULL \"global\" pointer."); + RARCH_WARN("retroarch_set_paths_redirect was sent a NULL \"global\" pointer."); return; } if (info->info.library_name && @@ -531,8 +531,6 @@ static void set_paths_redirect(const char *path) } } - - enum rarch_content_type retroarch_path_is_media_type(const char *path) { uint32_t hash_ext = msg_hash_calculate(path_get_extension(path)); @@ -596,14 +594,14 @@ enum rarch_content_type retroarch_path_is_media_type(const char *path) #define BSV_MOVIE_ARG "P:R:M:" /** - * parse_input: + * retroarch_parse_input: * @argc : Count of (commandline) arguments. * @argv : (Commandline) arguments. * * Parses (commandline) arguments passed to program. * **/ -static void parse_input(int argc, char *argv[]) +static void retroarch_parse_input(int argc, char *argv[]) { const char *optstring = NULL; global_t *global = global_get_ptr(); @@ -708,7 +706,7 @@ static void parse_input(int argc, char *argv[]) runloop_ctl(RUNLOOP_CTL_UNSET_OVERRIDES_ACTIVE, NULL); - /* Make sure we can call parse_input several times ... */ + /* Make sure we can call retroarch_parse_input several times ... */ optind = 0; optstring = "hs:fvS:A:c:U:DN:d:" BSV_MOVIE_ARG NETPLAY_ARG DYNAMIC_ARG FFMPEG_RECORD_ARG; @@ -745,7 +743,7 @@ static void parse_input(int argc, char *argv[]) { RARCH_ERR("Connect device to a valid port.\n"); retroarch_print_help(argv[0]); - retroarch_fail(1, "parse_input()"); + retroarch_fail(1, "retroarch_parse_input()"); } settings->input.libretro_device[port - 1] = id; global->has_set.libretro_device[port - 1] = true; @@ -758,7 +756,7 @@ static void parse_input(int argc, char *argv[]) { RARCH_ERR("Connect dualanalog to a valid port.\n"); retroarch_print_help(argv[0]); - retroarch_fail(1, "parse_input()"); + retroarch_fail(1, "retroarch_parse_input()"); } settings->input.libretro_device[port - 1] = RETRO_DEVICE_ANALOG; global->has_set.libretro_device[port - 1] = true; @@ -795,7 +793,7 @@ static void parse_input(int argc, char *argv[]) { RARCH_ERR("Disconnect device from a valid port.\n"); retroarch_print_help(argv[0]); - retroarch_fail(1, "parse_input()"); + retroarch_fail(1, "retroarch_parse_input()"); } settings->input.libretro_device[port - 1] = RETRO_DEVICE_NONE; global->has_set.libretro_device[port - 1] = true; @@ -875,7 +873,7 @@ static void parse_input(int argc, char *argv[]) { RARCH_ERR("Invalid argument in --sram-mode.\n"); retroarch_print_help(argv[0]); - retroarch_fail(1, "parse_input()"); + retroarch_fail(1, "retroarch_parse_input()"); } break; @@ -973,7 +971,7 @@ static void parse_input(int argc, char *argv[]) { RARCH_ERR("Wrong format for --size.\n"); retroarch_print_help(argv[0]); - retroarch_fail(1, "parse_input()"); + retroarch_fail(1, "retroarch_parse_input()"); } break; } @@ -995,7 +993,7 @@ static void parse_input(int argc, char *argv[]) break; case RA_OPT_FEATURES: - print_features(); + retroarch_print_features(); exit(0); case RA_OPT_EOF_EXIT: @@ -1014,11 +1012,11 @@ static void parse_input(int argc, char *argv[]) case '?': retroarch_print_help(argv[0]); - retroarch_fail(1, "parse_input()"); + retroarch_fail(1, "retroarch_parse_input()"); default: RARCH_ERR("Error parsing arguments.\n"); - retroarch_fail(1, "parse_input()"); + retroarch_fail(1, "retroarch_parse_input()"); } } @@ -1027,7 +1025,7 @@ static void parse_input(int argc, char *argv[]) if (optind < argc) { RARCH_ERR("--menu was used, but content file was passed as well.\n"); - retroarch_fail(1, "parse_input()"); + retroarch_fail(1, "retroarch_parse_input()"); } else { @@ -1047,7 +1045,7 @@ static void parse_input(int argc, char *argv[]) { /* We requested explicit ROM, so use PLAIN core type. */ current_core_type = CORE_TYPE_PLAIN; - set_special_paths(argv + optind, argc - optind); + retroarch_set_special_paths(argv + optind, argc - optind); } else content_set_does_not_need_content(); @@ -1064,7 +1062,7 @@ static void parse_input(int argc, char *argv[]) sizeof(global->dir.savestate)); } -static void rarch_init_savefile_paths(void) +static void retroarch_init_savefile_paths(void) { global_t *global = global_get_ptr(); rarch_system_info_t *system = NULL; @@ -1236,7 +1234,7 @@ static int retroarch_main_init(int argc, char *argv[]) rarch_ctl(RARCH_CTL_SET_ERROR_ON_INIT, NULL); retro_main_log_file_init(NULL); - parse_input(argc, argv); + retroarch_parse_input(argc, argv); verbosity = retro_main_verbosity(); @@ -1342,7 +1340,7 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data) switch(state) { case RARCH_CTL_SET_PATHS: - set_basename((const char*)data); + retroarch_set_basename((const char*)data); if (!global->has_set.save_path) fill_pathname_noext(global->name.savefile, global->name.base, @@ -1353,7 +1351,7 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data) fill_pathname_noext(global->name.cheatfile, global->name.base, ".cht", sizeof(global->name.cheatfile)); - set_paths_redirect((const char*)data); + retroarch_set_paths_redirect((const char*)data); break; case RARCH_CTL_IS_PLAIN_CORE: return (current_core_type == CORE_TYPE_PLAIN); @@ -1453,7 +1451,7 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data) { if (content_does_not_need_content()) return false; - set_paths_redirect(global->name.base); + retroarch_set_paths_redirect(global->name.base); } break; case RARCH_CTL_SET_SRAM_ENABLE: @@ -1565,7 +1563,7 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data) } break; case RARCH_CTL_FILL_PATHNAMES: - rarch_init_savefile_paths(); + retroarch_init_savefile_paths(); bsv_movie_set_path(global->name.savefile); if (!*global->name.base) From c82505ed9eb4a686164de18fcf6769b32f4de415 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 May 2016 07:44:13 +0200 Subject: [PATCH 326/498] Show FPS in title bar only when 'Display Framerate' is enabled --- gfx/video_driver.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 70ca893c41..8b1492f762 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -998,12 +998,29 @@ bool video_monitor_get_fps(char *buf, size_t size, if ((video_driver_frame_count % FPS_UPDATE_INTERVAL) == 0) { + char frames_text[64]; + settings_t *settings = config_get_ptr(); + last_fps = TIME_TO_FPS(curr_time, new_time, FPS_UPDATE_INTERVAL); curr_time = new_time; - snprintf(buf, size, "%s || FPS: %6.1f || Frames: " U64_SIGN, - video_driver_title_buf, last_fps, + strlcpy(buf, video_driver_title_buf, size); + strlcat(buf, " || ", size); + + if (settings->fps_show) + { + char fps_text[64]; + snprintf(fps_text, sizeof(fps_text), " FPS: %6.1f", last_fps); + strlcat(buf, fps_text, size); + strlcat(buf, " || ", size); + } + + strlcat(buf, "Frames: ", size); + + snprintf(frames_text, sizeof(frames_text), U64_SIGN, (unsigned long long)video_driver_frame_count); + + strlcat(buf, frames_text, size); ret = true; } From 8bcc889d908c14614e2670daa08aa9e928addd36 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 May 2016 07:54:45 +0200 Subject: [PATCH 327/498] Comment this out - makes all tasks way too slow --- libretro-common/queues/task_queue.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libretro-common/queues/task_queue.c b/libretro-common/queues/task_queue.c index bddaf435ef..a52c7d6105 100644 --- a/libretro-common/queues/task_queue.c +++ b/libretro-common/queues/task_queue.c @@ -437,7 +437,9 @@ static void threaded_worker(void *userdata) slock_unlock(finished_lock); } +#if 0 retro_sleep(10); +#endif } slock_unlock(running_lock); From 5f3f5783119432ee9cf31d6bac6dcb2d3164c415 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 May 2016 08:03:36 +0200 Subject: [PATCH 328/498] Further otpimization --- 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 8b1492f762..aafe362853 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -990,6 +990,7 @@ bool video_monitor_get_fps(char *buf, size_t size, { static float last_fps; bool ret = false; + settings_t *settings = config_get_ptr(); unsigned write_index = video_driver_state.frame_time.count++ & (MEASURE_FRAME_TIME_SAMPLES_COUNT - 1); @@ -999,7 +1000,6 @@ bool video_monitor_get_fps(char *buf, size_t size, if ((video_driver_frame_count % FPS_UPDATE_INTERVAL) == 0) { char frames_text[64]; - settings_t *settings = config_get_ptr(); last_fps = TIME_TO_FPS(curr_time, new_time, FPS_UPDATE_INTERVAL); curr_time = new_time; @@ -1024,7 +1024,7 @@ bool video_monitor_get_fps(char *buf, size_t size, ret = true; } - if (buf_fps) + if (buf_fps && settings->fps_show) snprintf(buf_fps, size_fps, "FPS: %6.1f || Frames: " U64_SIGN, last_fps, (unsigned long long)video_driver_frame_count); From d57574a2ca3219d8ad389b806cd652f0e602d8d1 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 May 2016 08:17:35 +0200 Subject: [PATCH 329/498] Rename some autosve functions --- autosave.c | 12 ++++++------ autosave.h | 12 ++++++------ command_event.c | 4 ++-- netplay/netplay_net.c | 4 ++-- runloop.c | 4 ++-- 5 files changed, 18 insertions(+), 18 deletions(-) diff --git a/autosave.c b/autosave.c index 6a09e9cb05..de4c659d22 100644 --- a/autosave.c +++ b/autosave.c @@ -186,11 +186,11 @@ static void autosave_free(autosave_t *handle) } /** - * lock_autosave: + * autosave_lock: * * Lock autosave. **/ -void lock_autosave(void) +void autosave_lock(void) { unsigned i; @@ -202,11 +202,11 @@ void lock_autosave(void) } /** - * unlock_autosave: + * autosave_unlock: * * Unlocks autosave. **/ -void unlock_autosave(void) +void autosave_unlock(void) { unsigned i; @@ -217,7 +217,7 @@ void unlock_autosave(void) } } -void autosave_event_init(void) +void autosave_init(void) { unsigned i; autosave_t **list = NULL; @@ -258,7 +258,7 @@ void autosave_event_init(void) } } -void autosave_event_deinit(void) +void autosave_deinit(void) { unsigned i; diff --git a/autosave.h b/autosave.h index e4aee14f81..2385115671 100644 --- a/autosave.h +++ b/autosave.h @@ -26,22 +26,22 @@ extern "C" { typedef struct autosave autosave_t; /** - * lock_autosave: + * autosave_lock: * * Lock autosave. **/ -void lock_autosave(void); +void autosave_lock(void); /** - * unlock_autosave: + * autosave_unlock: * * Unlocks autosave. **/ -void unlock_autosave(void); +void autosave_unlock(void); -void autosave_event_init(void); +void autosave_init(void); -void autosave_event_deinit(void); +void autosave_deinit(void); #ifdef __cplusplus } diff --git a/command_event.c b/command_event.c index d7fe441311..bda2c88936 100644 --- a/command_event.c +++ b/command_event.c @@ -1197,14 +1197,14 @@ bool event_cmd_ctl(enum event_command cmd, void *data) global_t *global = global_get_ptr(); if (!global->sram.use) return false; - autosave_event_deinit(); + autosave_deinit(); } #endif break; case EVENT_CMD_AUTOSAVE_INIT: event_cmd_ctl(EVENT_CMD_AUTOSAVE_DEINIT, NULL); #ifdef HAVE_THREADS - autosave_event_init(); + autosave_init(); #endif break; case EVENT_CMD_AUTOSAVE_STATE: diff --git a/netplay/netplay_net.c b/netplay/netplay_net.c index fa64b6f880..42a224f77a 100644 --- a/netplay/netplay_net.c +++ b/netplay/netplay_net.c @@ -88,11 +88,11 @@ static void netplay_net_post_frame(netplay_t *netplay) core_serialize(&serial_info); #if defined(HAVE_THREADS) - lock_autosave(); + autosave_lock(); #endif core_run(); #if defined(HAVE_THREADS) - unlock_autosave(); + autosave_unlock(); #endif netplay->tmp_ptr = NEXT_PTR(netplay->tmp_ptr); netplay->tmp_frame_count++; diff --git a/runloop.c b/runloop.c index 400719d3b3..1afee7ec94 100644 --- a/runloop.c +++ b/runloop.c @@ -1452,7 +1452,7 @@ int runloop_iterate(unsigned *sleep_ms) } #if defined(HAVE_THREADS) - lock_autosave(); + autosave_lock(); #endif #ifdef HAVE_NETPLAY @@ -1503,7 +1503,7 @@ int runloop_iterate(unsigned *sleep_ms) #endif #if defined(HAVE_THREADS) - unlock_autosave(); + autosave_unlock(); #endif if (!settings->fastforward_ratio) From 344d1bf9497207a29af5656365b4850f2707749e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 May 2016 17:37:29 +0200 Subject: [PATCH 330/498] move remote.c to input/ --- Makefile.common | 2 +- griffin/griffin.c | 2 +- input/input_driver.c | 2 +- remote.c => input/input_remote.c | 2 +- remote.h => input/input_remote.h | 0 5 files changed, 4 insertions(+), 4 deletions(-) rename remote.c => input/input_remote.c (99%) rename remote.h => input/input_remote.h (100%) diff --git a/Makefile.common b/Makefile.common index 6293255e73..590d463b70 100644 --- a/Makefile.common +++ b/Makefile.common @@ -987,7 +987,7 @@ ifeq ($(HAVE_NETWORKING), 1) endif ifeq ($(HAVE_NETWORK_GAMEPAD), 1) - OBJ += remote.o + OBJ += input/input_remote.o endif endif diff --git a/griffin/griffin.c b/griffin/griffin.c index 9aa38f3899..88d7530623 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -914,7 +914,7 @@ MENU #endif #ifdef HAVE_NETWORK_GAMEPAD -#include "../remote.c" +#include "../input/input_remote.c" #endif #include "../command_event.c" diff --git a/input/input_driver.c b/input/input_driver.c index ac6284c62a..58779019d9 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -31,7 +31,7 @@ #endif #ifdef HAVE_NETWORK_GAMEPAD -#include "../remote.h" +#include "input_remote.h" #endif static const input_driver_t *input_drivers[] = { diff --git a/remote.c b/input/input_remote.c similarity index 99% rename from remote.c rename to input/input_remote.c index 6c5c021b6d..2f20c0d8db 100644 --- a/remote.c +++ b/input/input_remote.c @@ -29,7 +29,7 @@ #include #include -#include "remote.h" +#include "input_remote.h" #include "msg_hash.h" #include "runloop.h" diff --git a/remote.h b/input/input_remote.h similarity index 100% rename from remote.h rename to input/input_remote.h From 3722826e0a470c96309496f560cce6407a6b0ce8 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 May 2016 17:43:38 +0200 Subject: [PATCH 331/498] Rename netplay/ to network/ --- Makefile.common | 2 +- command_event.c | 2 +- core_impl.c | 2 +- griffin/griffin.c | 8 ++++---- {netplay => network}/netplay.c | 0 {netplay => network}/netplay.h | 0 {netplay => network}/netplay_common.c | 0 {netplay => network}/netplay_net.c | 0 {netplay => network}/netplay_private.h | 0 {netplay => network}/netplay_spectate.c | 0 runloop.c | 2 +- 11 files changed, 8 insertions(+), 8 deletions(-) rename {netplay => network}/netplay.c (100%) rename {netplay => network}/netplay.h (100%) rename {netplay => network}/netplay_common.c (100%) rename {netplay => network}/netplay_net.c (100%) rename {netplay => network}/netplay_private.h (100%) rename {netplay => network}/netplay_spectate.c (100%) diff --git a/Makefile.common b/Makefile.common index 590d463b70..55355dc46e 100644 --- a/Makefile.common +++ b/Makefile.common @@ -974,7 +974,7 @@ ifeq ($(HAVE_NETWORKING), 1) ifeq ($(HAVE_NETPLAY), 1) DEFINES += -DHAVE_NETPLAY -DHAVE_NETWORK_CMD -DHAVE_NETWORK_GAMEPAD - OBJ += netplay/netplay_net.o netplay/netplay_spectate.o netplay/netplay_common.o netplay/netplay.o + OBJ += network/netplay_net.o network/netplay_spectate.o network/netplay_common.o network/netplay.o endif # Retro Achievements (also depends on threads) diff --git a/command_event.c b/command_event.c index bda2c88936..db0f9d2378 100644 --- a/command_event.c +++ b/command_event.c @@ -59,7 +59,7 @@ #endif #ifdef HAVE_NETPLAY -#include "netplay/netplay.h" +#include "network/netplay.h" #endif #ifdef HAVE_NETWORKING diff --git a/core_impl.c b/core_impl.c index f494381b5e..46941813cc 100644 --- a/core_impl.c +++ b/core_impl.c @@ -36,7 +36,7 @@ #include "audio/audio_driver.h" #ifdef HAVE_NETPLAY -#include "netplay/netplay.h" +#include "network/netplay.h" #endif static struct retro_core_t core; diff --git a/griffin/griffin.c b/griffin/griffin.c index 88d7530623..a8bbd49e97 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -785,10 +785,10 @@ THREAD NETPLAY ============================================================ */ #ifdef HAVE_NETPLAY -#include "../netplay/netplay_net.c" -#include "../netplay/netplay_spectate.c" -#include "../netplay/netplay_common.c" -#include "../netplay/netplay.c" +#include "../network/netplay_net.c" +#include "../network/netplay_spectate.c" +#include "../network/netplay_common.c" +#include "../network/netplay.c" #include "../libretro-common/net/net_compat.c" #include "../libretro-common/net/net_socket.c" #include "../libretro-common/net/net_http.c" diff --git a/netplay/netplay.c b/network/netplay.c similarity index 100% rename from netplay/netplay.c rename to network/netplay.c diff --git a/netplay/netplay.h b/network/netplay.h similarity index 100% rename from netplay/netplay.h rename to network/netplay.h diff --git a/netplay/netplay_common.c b/network/netplay_common.c similarity index 100% rename from netplay/netplay_common.c rename to network/netplay_common.c diff --git a/netplay/netplay_net.c b/network/netplay_net.c similarity index 100% rename from netplay/netplay_net.c rename to network/netplay_net.c diff --git a/netplay/netplay_private.h b/network/netplay_private.h similarity index 100% rename from netplay/netplay_private.h rename to network/netplay_private.h diff --git a/netplay/netplay_spectate.c b/network/netplay_spectate.c similarity index 100% rename from netplay/netplay_spectate.c rename to network/netplay_spectate.c diff --git a/runloop.c b/runloop.c index 1afee7ec94..a61dc2f21a 100644 --- a/runloop.c +++ b/runloop.c @@ -63,7 +63,7 @@ #endif #ifdef HAVE_NETPLAY -#include "netplay/netplay.h" +#include "network/netplay.h" #endif #include "verbosity.h" From 751872afa4c0ea5abb99e928db0dce6450792af7 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 May 2016 17:45:21 +0200 Subject: [PATCH 332/498] Move netlogger.c to network/ --- Makefile.ps3.salamander | 2 +- Makefile.psl1ght | 1 - Makefile.wii.salamander | 2 +- griffin/griffin.c | 2 +- netlogger.c => network/netlogger.c | 0 5 files changed, 3 insertions(+), 4 deletions(-) rename netlogger.c => network/netlogger.c (100%) diff --git a/Makefile.ps3.salamander b/Makefile.ps3.salamander index 2ace35ff76..d2ef7e9124 100644 --- a/Makefile.ps3.salamander +++ b/Makefile.ps3.salamander @@ -37,7 +37,7 @@ PPU_SRCS = frontend/frontend_salamander.c \ ifeq ($(HAVE_LOGGER), 1) PPU_CFLAGS += -DHAVE_LOGGER -PPU_SRCS += netlogger.c \ +PPU_SRCS += network/netlogger.c \ libretro-common/net/net_compat.c \ libretro-common/net/net_socket.c endif diff --git a/Makefile.psl1ght b/Makefile.psl1ght index 3a15014ecd..aec9fe76b5 100644 --- a/Makefile.psl1ght +++ b/Makefile.psl1ght @@ -83,7 +83,6 @@ OBJ = griffin/griffin.o ifeq ($(HAVE_LOGGER), 1) CFLAGS += -DHAVE_LOGGER -CFLAGS += -Ilogger/netlogger endif ifeq ($(HAVE_FILE_LOGGER), 1) diff --git a/Makefile.wii.salamander b/Makefile.wii.salamander index 5601f19455..935d81c101 100644 --- a/Makefile.wii.salamander +++ b/Makefile.wii.salamander @@ -60,7 +60,7 @@ OBJ = frontend/frontend_salamander.o \ ifeq ($(HAVE_LOGGER), 1) CFLAGS += -DHAVE_LOGGER CFLAGS += -DPC_DEVELOPMENT_IP_ADDRESS=\"$(PC_DEVELOPMENT_IP_ADDRESS)\" -DPC_DEVELOPMENT_UDP_PORT=$(PC_DEVELOPMENT_UDP_PORT) -OBJ += logger/netlogger.o \ +OBJ += network/netlogger.o \ libretro-common/net/net_compat.o \ libretro-common/net/net_socket.o endif diff --git a/griffin/griffin.c b/griffin/griffin.c index a8bbd49e97..5ab715be78 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -31,7 +31,7 @@ #include "../verbosity.c" #if defined(HAVE_LOGGER) && !defined(ANDROID) -#include "../netlogger.c" +#include "../network/netlogger.c" #endif /*============================================================ diff --git a/netlogger.c b/network/netlogger.c similarity index 100% rename from netlogger.c rename to network/netlogger.c From 7ca75d46f87f384c2f91862e86cf48051de74807 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 May 2016 17:47:45 +0200 Subject: [PATCH 333/498] Move net_http_special to network/ --- Makefile.common | 2 +- cheevos.c | 2 +- griffin/griffin.c | 2 +- net_http_special.c => network/net_http_special.c | 0 net_http_special.h => network/net_http_special.h | 0 5 files changed, 3 insertions(+), 3 deletions(-) rename net_http_special.c => network/net_http_special.c (100%) rename net_http_special.h => network/net_http_special.h (100%) diff --git a/Makefile.common b/Makefile.common index 55355dc46e..ccdaf3d510 100644 --- a/Makefile.common +++ b/Makefile.common @@ -954,7 +954,7 @@ ifeq ($(HAVE_NETWORKING), 1) OBJ += libretro-common/net/net_compat.o \ libretro-common/net/net_http.o \ libretro-common/net/net_socket.o \ - net_http_special.o \ + network/net_http_special.o \ tasks/task_http.o ifneq ($(HAVE_SOCKET_LEGACY),1) diff --git a/cheevos.c b/cheevos.c index 31a38f4ae3..de23ba515b 100644 --- a/cheevos.c +++ b/cheevos.c @@ -24,7 +24,7 @@ #include "cheevos.h" #include "dynamic.h" #include "libretro.h" -#include "net_http_special.h" +#include "network/net_http_special.h" #include "configuration.h" #include "performance.h" #include "msg_hash.h" diff --git a/griffin/griffin.c b/griffin/griffin.c index 5ab715be78..e6f0a632ec 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -113,7 +113,7 @@ ACHIEVEMENTS #include "../libretro-common/formats/json/jsonsax.c" #include "../libretro-common/utils/md5.c" -#include "../net_http_special.c" +#include "../network/net_http_special.c" #include "../cheevos.c" #endif diff --git a/net_http_special.c b/network/net_http_special.c similarity index 100% rename from net_http_special.c rename to network/net_http_special.c diff --git a/net_http_special.h b/network/net_http_special.h similarity index 100% rename from net_http_special.h rename to network/net_http_special.h From 7ba97e87036a4473c4e636d9ce77bd516e4021d4 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 May 2016 18:11:17 +0200 Subject: [PATCH 334/498] Remove core_info_ctl --- command_event.c | 6 +- core_info.c | 733 +++++++++++++++--------------- core_info.h | 32 +- list_special.c | 6 +- menu/cbs/menu_cbs_deferred_push.c | 2 +- menu/cbs/menu_cbs_get_value.c | 2 +- menu/cbs/menu_cbs_left.c | 2 +- menu/cbs/menu_cbs_ok.c | 6 +- menu/cbs/menu_cbs_right.c | 2 +- menu/cbs/menu_cbs_start.c | 2 +- menu/drivers/materialui.c | 2 +- menu/drivers/zarch.c | 4 +- menu/menu_content.c | 2 +- menu/menu_displaylist.c | 8 +- menu/menu_driver.c | 6 +- 15 files changed, 409 insertions(+), 406 deletions(-) diff --git a/command_event.c b/command_event.c index db0f9d2378..96b6e1cf7a 100644 --- a/command_event.c +++ b/command_event.c @@ -1026,7 +1026,7 @@ bool event_cmd_ctl(enum event_command cmd, void *data) #endif info_find.path = settings->path.libretro; - if (!core_info_ctl(CORE_INFO_CTL_LOAD, &info_find)) + if (!core_info_load(&info_find)) return false; } #endif @@ -1302,13 +1302,13 @@ bool event_cmd_ctl(enum event_command cmd, void *data) settings->content_history_size); break; case EVENT_CMD_CORE_INFO_DEINIT: - core_info_ctl(CORE_INFO_CTL_LIST_DEINIT, NULL); + core_info_deinit_list(); break; case EVENT_CMD_CORE_INFO_INIT: event_cmd_ctl(EVENT_CMD_CORE_INFO_DEINIT, NULL); if (*settings->directory.libretro) - core_info_ctl(CORE_INFO_CTL_LIST_INIT, NULL); + core_info_init_list(); break; case EVENT_CMD_CORE_DEINIT: { diff --git a/core_info.c b/core_info.c index 3d4a4bc112..afb8dd519c 100644 --- a/core_info.c +++ b/core_info.c @@ -31,8 +31,10 @@ #include "config.h" #endif -static const char *core_info_tmp_path = NULL; +static const char *core_info_tmp_path = NULL; static const struct string_list *core_info_tmp_list = NULL; +static core_info_t *core_info_current = NULL; +static core_info_list_t *core_info_curr_list = NULL; static void core_info_list_resolve_all_extensions( core_info_list_t *core_info_list) @@ -188,57 +190,6 @@ static config_file_t *core_info_list_iterate( return config_file_new(info_path); } -void core_info_get_name(const char *path, char *s, size_t len) -{ - size_t i; - core_info_t *core_info = NULL; - core_info_list_t *core_info_list = NULL; - struct string_list *contents = dir_list_new_special( - NULL, DIR_LIST_CORES, NULL); - - if (!contents) - return; - - core_info_list = (core_info_list_t*)calloc(1, sizeof(*core_info_list)); - if (!core_info_list) - goto error; - - core_info = (core_info_t*)calloc(contents->size, sizeof(*core_info)); - if (!core_info) - goto error; - - core_info_list->list = core_info; - core_info_list->count = contents->size; - - for (i = 0; i < contents->size; i++) - { - config_file_t *conf = NULL; - - if (!string_is_equal(contents->elems[i].data, path)) - continue; - - conf = core_info_list_iterate(contents, i); - - if (conf) - { - config_get_string(conf, "corename", - &core_info[i].core_name); - core_info[i].config_data = (void*)conf; - } - - core_info[i].path = strdup(contents->elems[i].data); - - strlcpy(s, core_info[i].core_name, len); - } - -error: - if (contents) - dir_list_free(contents); - contents = NULL; - core_info_list_free(core_info_list); -} - - static core_info_list_t *core_info_list_new(void) { size_t i; @@ -346,6 +297,370 @@ error: return NULL; } +/* Shallow-copies internal state. + * + * Data in *info is invalidated when the + * core_info_list is freed. */ +static bool core_info_list_get_info(core_info_list_t *core_info_list, + core_info_t *out_info, const char *path) +{ + size_t i; + if (!core_info_list || !out_info) + return false; + + memset(out_info, 0, sizeof(*out_info)); + + for (i = 0; i < core_info_list->count; i++) + { + const core_info_t *info = &core_info_list->list[i]; + + if (string_is_equal(path_basename(info->path), + path_basename(path))) + { + *out_info = *info; + return true; + } + } + + return false; +} + +static bool core_info_does_support_any_file(const core_info_t *core, + const struct string_list *list) +{ + size_t i; + if (!list || !core || !core->supported_extensions_list) + return false; + + for (i = 0; i < list->size; i++) + if (string_list_find_elem_prefix(core->supported_extensions_list, + ".", path_get_extension(list->elems[i].data))) + return true; + return false; +} + +static bool core_info_does_support_file( + const core_info_t *core, const char *path) +{ + if (!path || !core || !core->supported_extensions_list) + return false; + return string_list_find_elem_prefix( + core->supported_extensions_list, ".", path_get_extension(path)); +} + +/* qsort_r() is not in standard C, sadly. */ + +static int core_info_qsort_cmp(const void *a_, const void *b_) +{ + const core_info_t *a = (const core_info_t*)a_; + const core_info_t *b = (const core_info_t*)b_; + int support_a = + core_info_does_support_any_file(a, core_info_tmp_list) + || core_info_does_support_file(a, core_info_tmp_path); + int support_b = + core_info_does_support_any_file(b, core_info_tmp_list) + || core_info_does_support_file(b, core_info_tmp_path); + + if (support_a != support_b) + return support_b - support_a; + return strcasecmp(a->display_name, b->display_name); +} + +static core_info_t *core_info_find_internal( + core_info_list_t *list, + const char *core) +{ + size_t i; + + for (i = 0; i < list->count; i++) + { + core_info_t *info = core_info_get(list, i); + + if (!info) + continue; + if (string_is_equal(info->path, core)) + return info; + } + + return NULL; +} + +static bool core_info_list_update_missing_firmware_internal( + core_info_list_t *core_info_list, + const char *core, + const char *systemdir) +{ + size_t i; + char path[PATH_MAX_LENGTH] = {0}; + core_info_t *info = NULL; + + if (!core_info_list || !core) + return false; + + info = core_info_find_internal(core_info_list, core); + + if (!info) + return false; + + for (i = 0; i < info->firmware_count; i++) + { + if (!info->firmware[i].path) + continue; + + fill_pathname_join(path, systemdir, + info->firmware[i].path, sizeof(path)); + info->firmware[i].missing = !path_file_exists(path); + } + + return true; +} + +#if 0 +static int core_info_firmware_cmp(const void *a_, const void *b_) +{ + const core_info_firmware_t *a = (const core_info_firmware_t*)a_; + const core_info_firmware_t *b = (const core_info_firmware_t*)b_; + int order = b->missing - a->missing; + + if (order) + return order; + return strcasecmp(a->path, b->path); +} + +/* Non-reentrant, does not allocate. Returns pointer to internal state. */ + +static void core_info_list_get_missing_firmware( + core_info_list_t *core_info_list, + const char *core, const char *systemdir, + const core_info_firmware_t **firmware, size_t *num_firmware) +{ + size_t i; + char path[PATH_MAX_LENGTH] = {0}; + core_info_t *info = NULL; + + if (!core_info_list || !core) + return; + + *firmware = NULL; + *num_firmware = 0; + + if (!(info = core_info_find_internal(core_info_list, core))) + return; + + *firmware = info->firmware; + + for (i = 1; i < info->firmware_count; i++) + { + fill_pathname_join(path, systemdir, + info->firmware[i].path, sizeof(path)); + info->firmware[i].missing = !path_file_exists(path); + *num_firmware += info->firmware[i].missing; + } + + qsort(info->firmware, info->firmware_count, sizeof(*info->firmware), + core_info_firmware_cmp); +} +#endif + +void core_info_free_current_core(void) +{ + if (core_info_current) + free(core_info_current); + core_info_current = NULL; +} + +bool core_info_init_current_core(void) +{ + core_info_current = (core_info_t*)calloc(1, sizeof(core_info_t)); + if (!core_info_current) + return false; + return true; +} + +bool core_info_get_current_core(core_info_t **core) +{ + if (!core) + return false; + *core = core_info_current; + return true; +} + +void core_info_deinit_list(void) +{ + if (core_info_curr_list) + core_info_list_free(core_info_curr_list); + core_info_curr_list = NULL; +} + +bool core_info_init_list(void) +{ + core_info_curr_list = core_info_list_new(); + + if (!core_info_curr_list) + return false; + return true; +} + +bool core_info_get_list(core_info_list_t **core) +{ + if (!core) + return false; + *core = core_info_curr_list; + return true; +} + +bool core_info_list_update_missing_firmware(core_info_ctx_firmware_t *info) +{ + if (!info) + return false; + + return core_info_list_update_missing_firmware_internal( + core_info_curr_list, + info->path, info->directory.system); +} + +bool core_info_load(core_info_ctx_find_t *info) +{ + core_info_t *core_info = NULL; + + if (!info) + return false; + + core_info_get_current_core(&core_info); + + if (!core_info_curr_list) + return false; + + if (!core_info_list_get_info(core_info_curr_list, + core_info, info->path)) + return false; + + return true; +} + +bool core_info_find(core_info_ctx_find_t *info) +{ + if (!info || !core_info_curr_list) + return false; + info->inf = core_info_find_internal(core_info_curr_list, info->path); + if (!info->inf) + return false; + return true; +} + +core_info_t *core_info_get(core_info_list_t *list, size_t i) +{ + core_info_t *info = NULL; + + if (!list) + return NULL; + info = (core_info_t*)&list->list[i]; + if (!info || !info->path) + return NULL; + + return info; +} + +void core_info_list_get_supported_cores(core_info_list_t *core_info_list, + const char *path, const core_info_t **infos, size_t *num_infos) +{ +#ifdef HAVE_ZLIB + struct string_list *list = NULL; +#endif + size_t supported = 0, i; + + if (!core_info_list) + return; + + core_info_tmp_path = path; + +#ifdef HAVE_ZLIB + if (string_is_equal_noncase(path_get_extension(path), "zip")) + list = file_archive_get_file_list(path, NULL); + core_info_tmp_list = list; +#endif + + /* Let supported core come first in list so we can return + * a pointer to them. */ + qsort(core_info_list->list, core_info_list->count, + sizeof(core_info_t), core_info_qsort_cmp); + + for (i = 0; i < core_info_list->count; i++, supported++) + { + const core_info_t *core = &core_info_list->list[i]; + + if (!core) + continue; + + if (core_info_does_support_file(core, path)) + continue; + +#ifdef HAVE_ZLIB + if (core_info_does_support_any_file(core, list)) + continue; +#endif + + break; + } + +#ifdef HAVE_ZLIB + if (list) + string_list_free(list); +#endif + + *infos = core_info_list->list; + *num_infos = supported; +} + +void core_info_get_name(const char *path, char *s, size_t len) +{ + size_t i; + core_info_t *core_info = NULL; + core_info_list_t *core_info_list = NULL; + struct string_list *contents = dir_list_new_special( + NULL, DIR_LIST_CORES, NULL); + + if (!contents) + return; + + core_info_list = (core_info_list_t*)calloc(1, sizeof(*core_info_list)); + if (!core_info_list) + goto error; + + core_info = (core_info_t*)calloc(contents->size, sizeof(*core_info)); + if (!core_info) + goto error; + + core_info_list->list = core_info; + core_info_list->count = contents->size; + + for (i = 0; i < contents->size; i++) + { + config_file_t *conf = NULL; + + if (!string_is_equal(contents->elems[i].data, path)) + continue; + + conf = core_info_list_iterate(contents, i); + + if (conf) + { + config_get_string(conf, "corename", + &core_info[i].core_name); + core_info[i].config_data = (void*)conf; + } + + core_info[i].path = strdup(contents->elems[i].data); + + strlcpy(s, core_info[i].core_name, len); + } + +error: + if (contents) + dir_list_free(contents); + contents = NULL; + core_info_list_free(core_info_list); +} size_t core_info_list_num_info_files(core_info_list_t *core_info_list) { @@ -425,317 +740,3 @@ error: free(core_name); return false; } - -/* Shallow-copies internal state. - * - * Data in *info is invalidated when the - * core_info_list is freed. */ -static bool core_info_list_get_info(core_info_list_t *core_info_list, - core_info_t *out_info, const char *path) -{ - size_t i; - if (!core_info_list || !out_info) - return false; - - memset(out_info, 0, sizeof(*out_info)); - - for (i = 0; i < core_info_list->count; i++) - { - const core_info_t *info = &core_info_list->list[i]; - - if (string_is_equal(path_basename(info->path), - path_basename(path))) - { - *out_info = *info; - return true; - } - } - - return false; -} - -static bool core_info_does_support_any_file(const core_info_t *core, - const struct string_list *list) -{ - size_t i; - if (!list || !core || !core->supported_extensions_list) - return false; - - for (i = 0; i < list->size; i++) - if (string_list_find_elem_prefix(core->supported_extensions_list, - ".", path_get_extension(list->elems[i].data))) - return true; - return false; -} - -static bool core_info_does_support_file( - const core_info_t *core, const char *path) -{ - if (!path || !core || !core->supported_extensions_list) - return false; - return string_list_find_elem_prefix( - core->supported_extensions_list, ".", path_get_extension(path)); -} - -/* qsort_r() is not in standard C, sadly. */ - -static int core_info_qsort_cmp(const void *a_, const void *b_) -{ - const core_info_t *a = (const core_info_t*)a_; - const core_info_t *b = (const core_info_t*)b_; - int support_a = - core_info_does_support_any_file(a, core_info_tmp_list) - || core_info_does_support_file(a, core_info_tmp_path); - int support_b = - core_info_does_support_any_file(b, core_info_tmp_list) - || core_info_does_support_file(b, core_info_tmp_path); - - if (support_a != support_b) - return support_b - support_a; - return strcasecmp(a->display_name, b->display_name); -} - -void core_info_list_get_supported_cores(core_info_list_t *core_info_list, - const char *path, const core_info_t **infos, size_t *num_infos) -{ -#ifdef HAVE_ZLIB - struct string_list *list = NULL; -#endif - size_t supported = 0, i; - - if (!core_info_list) - return; - - core_info_tmp_path = path; - -#ifdef HAVE_ZLIB - if (string_is_equal_noncase(path_get_extension(path), "zip")) - list = file_archive_get_file_list(path, NULL); - core_info_tmp_list = list; -#endif - - /* Let supported core come first in list so we can return - * a pointer to them. */ - qsort(core_info_list->list, core_info_list->count, - sizeof(core_info_t), core_info_qsort_cmp); - - for (i = 0; i < core_info_list->count; i++, supported++) - { - const core_info_t *core = &core_info_list->list[i]; - - if (!core) - continue; - - if (core_info_does_support_file(core, path)) - continue; - -#ifdef HAVE_ZLIB - if (core_info_does_support_any_file(core, list)) - continue; -#endif - - break; - } - -#ifdef HAVE_ZLIB - if (list) - string_list_free(list); -#endif - - *infos = core_info_list->list; - *num_infos = supported; -} - -core_info_t *core_info_get(core_info_list_t *list, size_t i) -{ - core_info_t *info = NULL; - - if (!list) - return NULL; - info = (core_info_t*)&list->list[i]; - if (!info || !info->path) - return NULL; - - return info; -} - -static core_info_t *core_info_find(core_info_list_t *list, - const char *core) -{ - size_t i; - - for (i = 0; i < list->count; i++) - { - core_info_t *info = core_info_get(list, i); - - if (!info) - continue; - if (string_is_equal(info->path, core)) - return info; - } - - return NULL; -} - - -static bool core_info_list_update_missing_firmware( - core_info_list_t *core_info_list, - const char *core, const char *systemdir) -{ - size_t i; - char path[PATH_MAX_LENGTH] = {0}; - core_info_t *info = NULL; - - if (!core_info_list || !core) - return false; - - info = core_info_find(core_info_list, core); - - if (!info) - return false; - - for (i = 0; i < info->firmware_count; i++) - { - if (!info->firmware[i].path) - continue; - - fill_pathname_join(path, systemdir, - info->firmware[i].path, sizeof(path)); - info->firmware[i].missing = !path_file_exists(path); - } - - return true; -} - -#if 0 -static int core_info_firmware_cmp(const void *a_, const void *b_) -{ - const core_info_firmware_t *a = (const core_info_firmware_t*)a_; - const core_info_firmware_t *b = (const core_info_firmware_t*)b_; - int order = b->missing - a->missing; - - if (order) - return order; - return strcasecmp(a->path, b->path); -} - -/* Non-reentrant, does not allocate. Returns pointer to internal state. */ - -static void core_info_list_get_missing_firmware( - core_info_list_t *core_info_list, - const char *core, const char *systemdir, - const core_info_firmware_t **firmware, size_t *num_firmware) -{ - size_t i; - char path[PATH_MAX_LENGTH] = {0}; - core_info_t *info = NULL; - - if (!core_info_list || !core) - return; - - *firmware = NULL; - *num_firmware = 0; - - if (!(info = core_info_find(core_info_list, core))) - return; - - *firmware = info->firmware; - - for (i = 1; i < info->firmware_count; i++) - { - fill_pathname_join(path, systemdir, - info->firmware[i].path, sizeof(path)); - info->firmware[i].missing = !path_file_exists(path); - *num_firmware += info->firmware[i].missing; - } - - qsort(info->firmware, info->firmware_count, sizeof(*info->firmware), - core_info_firmware_cmp); -} -#endif - -bool core_info_ctl(enum core_info_state state, void *data) -{ - static core_info_t *core_info_current = NULL; - static core_info_list_t *core_info_curr_list = NULL; - - switch (state) - { - case CORE_INFO_CTL_CURRENT_CORE_FREE: - if (core_info_current) - free(core_info_current); - core_info_current = NULL; - break; - case CORE_INFO_CTL_CURRENT_CORE_INIT: - core_info_current = (core_info_t*)calloc(1, sizeof(core_info_t)); - if (!core_info_current) - return false; - break; - case CORE_INFO_CTL_CURRENT_CORE_GET: - { - core_info_t **core = (core_info_t**)data; - if (!core) - return false; - *core = core_info_current; - } - break; - case CORE_INFO_CTL_LIST_DEINIT: - if (core_info_curr_list) - core_info_list_free(core_info_curr_list); - core_info_curr_list = NULL; - break; - case CORE_INFO_CTL_LIST_INIT: - core_info_curr_list = core_info_list_new(); - break; - case CORE_INFO_CTL_LIST_GET: - { - core_info_list_t **core = (core_info_list_t**)data; - if (!core) - return false; - *core = core_info_curr_list; - } - break; - case CORE_INFO_CTL_LIST_UPDATE_MISSING_FIRMWARE: - { - core_info_ctx_firmware_t *info = (core_info_ctx_firmware_t*)data; - if (!info) - return false; - - return core_info_list_update_missing_firmware(core_info_curr_list, - info->path, info->directory.system); - } - case CORE_INFO_CTL_FIND: - { - core_info_ctx_find_t *info = (core_info_ctx_find_t*)data; - if (!info || !core_info_curr_list) - return false; - info->inf = core_info_find(core_info_curr_list, info->path); - if (!info->inf) - return false; - } - break; - case CORE_INFO_CTL_LOAD: - { - core_info_t *core_info = NULL; - core_info_ctx_find_t *info = (core_info_ctx_find_t*)data; - - if (!info) - return false; - - core_info_ctl(CORE_INFO_CTL_CURRENT_CORE_GET, &core_info); - - if (!core_info_curr_list) - return false; - - if (!core_info_list_get_info(core_info_curr_list, - core_info, info->path)) - return false; - } - break; - case CORE_INFO_CTL_NONE: - default: - break; - } - - return true; -} diff --git a/core_info.h b/core_info.h index 234b6ce831..502248ce69 100644 --- a/core_info.h +++ b/core_info.h @@ -26,20 +26,6 @@ extern "C" { #endif -enum core_info_state -{ - CORE_INFO_CTL_NONE = 0, - CORE_INFO_CTL_LIST_DEINIT, - CORE_INFO_CTL_LIST_INIT, - CORE_INFO_CTL_LIST_GET, - CORE_INFO_CTL_LIST_UPDATE_MISSING_FIRMWARE, - CORE_INFO_CTL_CURRENT_CORE_FREE, - CORE_INFO_CTL_CURRENT_CORE_INIT, - CORE_INFO_CTL_CURRENT_CORE_GET, - CORE_INFO_CTL_LOAD, - CORE_INFO_CTL_FIND -}; - typedef struct { char *path; @@ -116,7 +102,23 @@ void core_info_get_name(const char *path, char *s, size_t len); core_info_t *core_info_get(core_info_list_t *list, size_t i); -bool core_info_ctl(enum core_info_state action, void *data); +void core_info_free_current_core(void); + +bool core_info_init_current_core(void); + +bool core_info_get_current_core(core_info_t **core); + +void core_info_deinit_list(void); + +bool core_info_init_list(void); + +bool core_info_get_list(core_info_list_t **core); + +bool core_info_list_update_missing_firmware(core_info_ctx_firmware_t *info); + +bool core_info_find(core_info_ctx_find_t *info); + +bool core_info_load(core_info_ctx_find_t *info); #ifdef __cplusplus } diff --git a/list_special.c b/list_special.c index cce644eb91..1dbdde0abb 100644 --- a/list_special.c +++ b/list_special.c @@ -73,7 +73,7 @@ struct string_list *dir_list_new_special(const char *input_dir, case DIR_LIST_CORE_INFO: { core_info_list_t *list = NULL; - core_info_ctl(CORE_INFO_CTL_LIST_GET, &list); + core_info_get_list(&list); dir = input_dir; exts = list->all_ext; @@ -225,7 +225,7 @@ struct string_list *string_list_new_special(enum string_list_type type, } break; case STRING_LIST_SUPPORTED_CORES_PATHS: - core_info_ctl(CORE_INFO_CTL_LIST_GET, &core_info_list); + core_info_get_list(&core_info_list); core_info_list_get_supported_cores(core_info_list, (const char*)data, &core_info, list_size); @@ -247,7 +247,7 @@ struct string_list *string_list_new_special(enum string_list_type type, } break; case STRING_LIST_SUPPORTED_CORES_NAMES: - core_info_ctl(CORE_INFO_CTL_LIST_GET, &core_info_list); + core_info_get_list(&core_info_list); core_info_list_get_supported_cores(core_info_list, (const char*)data, &core_info, list_size); diff --git a/menu/cbs/menu_cbs_deferred_push.c b/menu/cbs/menu_cbs_deferred_push.c index 5d17c50439..afa343df23 100644 --- a/menu/cbs/menu_cbs_deferred_push.c +++ b/menu/cbs/menu_cbs_deferred_push.c @@ -342,7 +342,7 @@ static int general_push(menu_displaylist_info_t *info, if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu)) return menu_cbs_exit(); - core_info_ctl(CORE_INFO_CTL_LIST_GET, &list); + core_info_get_list(&list); menu_driver_ctl(RARCH_MENU_CTL_SYSTEM_INFO_GET, &system_menu); runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); diff --git a/menu/cbs/menu_cbs_get_value.c b/menu/cbs/menu_cbs_get_value.c index d8d95a3b8b..78a96ea09a 100644 --- a/menu/cbs/menu_cbs_get_value.c +++ b/menu/cbs/menu_cbs_get_value.c @@ -1245,7 +1245,7 @@ static void menu_action_setting_disp_set_label(file_list_t* list, char buf[PATH_MAX_LENGTH]; core_info_list_t *list = NULL; - core_info_ctl(CORE_INFO_CTL_LIST_GET, &list); + core_info_get_list(&list); if (core_info_list_get_display_name(list, s, buf, sizeof(buf))) strlcpy(s, buf, len); diff --git a/menu/cbs/menu_cbs_left.c b/menu/cbs/menu_cbs_left.c index b550379054..a33c3aa7ca 100644 --- a/menu/cbs/menu_cbs_left.c +++ b/menu/cbs/menu_cbs_left.c @@ -317,7 +317,7 @@ static int playlist_association_left(unsigned type, const char *label, const char *path = path_basename(label); core_info_list_t *list = NULL; - core_info_ctl(CORE_INFO_CTL_LIST_GET, &list); + core_info_get_list(&list); if (!list) return menu_cbs_exit(); diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index be6dce1f11..e071edb3c3 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -482,7 +482,7 @@ static int file_load_with_detect_core_wrapper(size_t idx, size_t entry_idx, fill_pathname_join(menu_path_new, menu->scratch2_buf, menu->scratch_buf, sizeof(menu_path_new)); - core_info_ctl(CORE_INFO_CTL_LIST_GET, &list); + core_info_get_list(&list); def_info.data = list; def_info.dir = menu_path_new; @@ -641,7 +641,7 @@ static int action_ok_playlist_entry(const char *path, core_info.inf = NULL; core_info.path = new_core_path; - if (!core_info_ctl(CORE_INFO_CTL_FIND, &core_info)) + if (!core_info_find(&core_info)) found_associated_core = false; if (!found_associated_core) @@ -2135,7 +2135,7 @@ static int action_ok_load_archive_detect_core(const char *path, menu_path = menu->scratch2_buf; content_path = menu->scratch_buf; - core_info_ctl(CORE_INFO_CTL_LIST_GET, &list); + core_info_get_list(&list); def_info.data = list; def_info.dir = menu_path; diff --git a/menu/cbs/menu_cbs_right.c b/menu/cbs/menu_cbs_right.c index d17a4442dd..e2d334a7f3 100644 --- a/menu/cbs/menu_cbs_right.c +++ b/menu/cbs/menu_cbs_right.c @@ -339,7 +339,7 @@ static int playlist_association_right(unsigned type, const char *label, const char *path = path_basename(label); core_info_list_t *list = NULL; - core_info_ctl(CORE_INFO_CTL_LIST_GET, &list); + core_info_get_list(&list); if (!list) return menu_cbs_exit(); diff --git a/menu/cbs/menu_cbs_start.c b/menu/cbs/menu_cbs_start.c index e74b324271..c9731b385e 100644 --- a/menu/cbs/menu_cbs_start.c +++ b/menu/cbs/menu_cbs_start.c @@ -274,7 +274,7 @@ static int action_start_playlist_association(unsigned type, const char *label) settings_t *settings = config_get_ptr(); const char *path = path_basename(label); - core_info_ctl(CORE_INFO_CTL_LIST_GET, &list); + core_info_get_list(&list); if (!list) return -1; diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index 3d27c90ab0..23f614cfa6 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -1373,7 +1373,7 @@ static int mui_list_push(void *data, void *userdata, menu_hash_to_str(MENU_LABEL_LOAD_CONTENT), MENU_SETTING_ACTION, 0, 0); - core_info_ctl(CORE_INFO_CTL_LIST_GET, &list); + core_info_get_list(&list); if (core_info_list_num_info_files(list)) { menu_entries_add(info->list, diff --git a/menu/drivers/zarch.c b/menu/drivers/zarch.c index 6ed851130c..64b1971d99 100644 --- a/menu/drivers/zarch.c +++ b/menu/drivers/zarch.c @@ -604,7 +604,7 @@ static int zarch_zui_render_lay_root_load(zui_t *zui, if (!zui->load_dlist) { core_info_t *core_info = NULL; - core_info_ctl(CORE_INFO_CTL_CURRENT_CORE_GET, &core_info); + core_info_get_current_core(&core_info); zui->load_dlist = dir_list_new(zui->load_cwd, core_info->supported_extensions, true, true); @@ -686,7 +686,7 @@ static int zarch_zui_render_lay_root_load(zui_t *zui, strlcpy(zui->pick_content, path, sizeof(zui->pick_content)); - core_info_ctl(CORE_INFO_CTL_LIST_GET, &list); + core_info_get_list(&list); core_info_list_get_supported_cores(list, path, &zui->pick_cores, &zui->pick_supported); diff --git a/menu/menu_content.c b/menu/menu_content.c index 61ec905824..c2b2d812aa 100644 --- a/menu/menu_content.c +++ b/menu/menu_content.c @@ -259,7 +259,7 @@ static bool menu_content_find_first_core(void *data) * going to use the current core to load this. */ if (menu_label_hash == MENU_LABEL_LOAD_CONTENT) { - core_info_ctl(CORE_INFO_CTL_CURRENT_CORE_GET, (void*)&info); + core_info_get_current_core((void*)&info); if (info) { RARCH_LOG("Use the current core (%s) to load this content...\n", diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 98134ed5c6..30e84a6727 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -286,7 +286,7 @@ static int menu_displaylist_parse_core_info(menu_displaylist_info_t *info) settings_t *settings = config_get_ptr(); core_info_t *core_info = NULL; - core_info_ctl(CORE_INFO_CTL_CURRENT_CORE_GET, &core_info); + core_info_get_current_core(&core_info); if (!core_info || !core_info->config_data) { @@ -401,7 +401,7 @@ static int menu_displaylist_parse_core_info(menu_displaylist_info_t *info) firmware_info.path = core_info->path; firmware_info.directory.system = settings->directory.system; - if (core_info_ctl(CORE_INFO_CTL_LIST_UPDATE_MISSING_FIRMWARE, &firmware_info)) + if (core_info_list_update_missing_firmware(&firmware_info)) { strlcpy(tmp, menu_hash_to_str(MENU_LABEL_VALUE_CORE_INFO_FIRMWARE), sizeof(tmp)); @@ -2589,7 +2589,7 @@ static int menu_displaylist_parse_generic( settings_t *settings = config_get_ptr(); uint32_t hash_label = menu_hash_calculate(info->label); - core_info_ctl(CORE_INFO_CTL_LIST_GET, &list); + core_info_get_list(&list); if (!*info->path) { @@ -3115,7 +3115,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) settings = config_get_ptr(); - core_info_ctl(CORE_INFO_CTL_LIST_GET, &list); + core_info_get_list(&list); disp_list.info = info; disp_list.type = type; diff --git a/menu/menu_driver.c b/menu/menu_driver.c index 3df92f0333..bd58fc6234 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -148,7 +148,7 @@ static bool menu_init(menu_handle_t *menu_data) if (!menu_entries_ctl(MENU_ENTRIES_CTL_INIT, NULL)) return false; - if (!core_info_ctl(CORE_INFO_CTL_CURRENT_CORE_INIT, NULL)) + if (!core_info_init_current_core()) return false; if (!menu_driver_ctl(RARCH_MENU_CTL_SHADER_INIT, NULL)) @@ -567,8 +567,8 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data) event_cmd_ctl(EVENT_CMD_HISTORY_DEINIT, NULL); - core_info_ctl(CORE_INFO_CTL_LIST_DEINIT, NULL); - core_info_ctl(CORE_INFO_CTL_CURRENT_CORE_FREE, NULL); + core_info_deinit_list(); + core_info_free_current_core(); free(menu_driver_data); } From 6ae20f201673f7225ce88e4ddadc58eeeebcc3e3 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 May 2016 18:20:52 +0200 Subject: [PATCH 335/498] Create managers/ dir - move cheats.c and state_manager.c to it --- Makefile.common | 4 ++-- command_event.c | 4 ++-- core_impl.c | 2 +- gfx/drivers_shader/shader_gl_cg.c | 2 +- gfx/drivers_shader/shader_glsl.c | 2 +- gfx/drivers_shader/shader_hlsl.c | 2 +- griffin/griffin.c | 4 ++-- cheats.c => managers/cheat_manager.c | 14 +++++++------- cheats.h => managers/cheat_manager.h | 0 state_manager.c => managers/state_manager.c | 21 ++++++++++++--------- state_manager.h => managers/state_manager.h | 0 menu/cbs/menu_cbs_get_value.c | 2 +- menu/cbs/menu_cbs_left.c | 2 +- menu/cbs/menu_cbs_ok.c | 2 +- menu/cbs/menu_cbs_right.c | 2 +- menu/cbs/menu_cbs_start.c | 2 +- menu/menu_displaylist.c | 2 +- menu/menu_input.c | 2 +- retroarch.c | 2 +- runloop.c | 4 ++-- 20 files changed, 39 insertions(+), 36 deletions(-) rename cheats.c => managers/cheat_manager.c (98%) rename cheats.h => managers/cheat_manager.h (100%) rename state_manager.c => managers/state_manager.c (98%) rename state_manager.h => managers/state_manager.h (100%) diff --git a/Makefile.common b/Makefile.common index ccdaf3d510..7781a4f074 100644 --- a/Makefile.common +++ b/Makefile.common @@ -157,7 +157,7 @@ OBJ += frontend/frontend.o \ dynamic.o \ cores/dynamic_dummy.o \ libretro-common/queues/message_queue.o \ - state_manager.o \ + managers/state_manager.o \ gfx/drivers_font_renderer/bitmapfont.o \ input/input_autodetect.o \ input/input_joypad_driver.o \ @@ -171,7 +171,7 @@ OBJ += frontend/frontend.o \ core_options.o \ libretro-common/compat/compat_fnmatch.o \ libretro-common/compat/compat_posix_string.o \ - cheats.o \ + managers/cheat_manager.o \ core_info.o \ libretro-common/file/config_file.o \ config_file_userdata.o \ diff --git a/command_event.c b/command_event.c index 96b6e1cf7a..9e76c7e979 100644 --- a/command_event.c +++ b/command_event.c @@ -29,7 +29,6 @@ #include "autosave.h" #include "core_info.h" #include "core_type.h" -#include "cheats.h" #include "performance.h" #include "dynamic.h" #include "content.h" @@ -37,7 +36,8 @@ #include "screenshot.h" #include "msg_hash.h" #include "retroarch.h" -#include "state_manager.h" +#include "managers/cheat_manager.h" +#include "managers/state_manager.h" #include "system.h" #include "ui/ui_companion_driver.h" #include "list_special.h" diff --git a/core_impl.c b/core_impl.c index 46941813cc..163ed55396 100644 --- a/core_impl.c +++ b/core_impl.c @@ -30,7 +30,7 @@ #include "core.h" #include "general.h" #include "msg_hash.h" -#include "state_manager.h" +#include "managers/state_manager.h" #include "system.h" #include "gfx/video_driver.h" #include "audio/audio_driver.h" diff --git a/gfx/drivers_shader/shader_gl_cg.c b/gfx/drivers_shader/shader_gl_cg.c index b74363bf67..c54ac7366d 100644 --- a/gfx/drivers_shader/shader_gl_cg.c +++ b/gfx/drivers_shader/shader_gl_cg.c @@ -40,7 +40,7 @@ #include "../video_shader_parse.h" #include "../../core.h" #include "../../dynamic.h" -#include "../../state_manager.h" +#include "../../managers/state_manager.h" #include "../video_state_tracker.h" #include "../drivers/gl_shaders/pipeline_xmb_ribbon_simple.cg.h" diff --git a/gfx/drivers_shader/shader_glsl.c b/gfx/drivers_shader/shader_glsl.c index 0cbf335aa6..632806c3ba 100644 --- a/gfx/drivers_shader/shader_glsl.c +++ b/gfx/drivers_shader/shader_glsl.c @@ -27,7 +27,7 @@ #include "shader_glsl.h" #include "../video_state_tracker.h" #include "../../dynamic.h" -#include "../../state_manager.h" +#include "../../managers/state_manager.h" #include "../../core.h" #ifdef HAVE_CONFIG_H diff --git a/gfx/drivers_shader/shader_hlsl.c b/gfx/drivers_shader/shader_hlsl.c index 5fbf0ae3aa..26467efafa 100644 --- a/gfx/drivers_shader/shader_hlsl.c +++ b/gfx/drivers_shader/shader_hlsl.c @@ -20,7 +20,7 @@ #include "../video_shader_parse.h" #include "../d3d/d3d.h" -#include "../../state_manager.h" +#include "../../managers/state_manager.h" #include "../drivers/d3d_shaders/opaque.hlsl.d3d9.h" diff --git a/griffin/griffin.c b/griffin/griffin.c index e6f0a632ec..040ae67b99 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -120,7 +120,7 @@ ACHIEVEMENTS /*============================================================ CHEATS ============================================================ */ -#include "../cheats.c" +#include "../managers/cheat_manager.c" #include "../libretro-common/hash/rhash.c" /*============================================================ @@ -670,7 +670,7 @@ CONFIGURATION /*============================================================ STATE MANAGER ============================================================ */ -#include "../state_manager.c" +#include "../managers/state_manager.c" /*============================================================ FRONTEND diff --git a/cheats.c b/managers/cheat_manager.c similarity index 98% rename from cheats.c rename to managers/cheat_manager.c index 65a7785b3a..1ef5afb63c 100644 --- a/cheats.c +++ b/managers/cheat_manager.c @@ -23,18 +23,18 @@ #include #include -#include "cheats.h" -#include "runloop.h" -#include "dynamic.h" -#include "core.h" -#include "verbosity.h" +#include "cheat_manager.h" +#include "../runloop.h" +#include "../dynamic.h" +#include "../core.h" +#include "../verbosity.h" #ifdef HAVE_CONFIG_H -#include "config.h" +#include "../config.h" #endif #ifdef HAVE_CHEEVOS -#include "cheevos.h" +#include "../cheevos.h" #endif struct item_cheat diff --git a/cheats.h b/managers/cheat_manager.h similarity index 100% rename from cheats.h rename to managers/cheat_manager.h diff --git a/state_manager.c b/managers/state_manager.c similarity index 98% rename from state_manager.c rename to managers/state_manager.c index cd7ee598d7..e47e8ca500 100644 --- a/state_manager.c +++ b/managers/state_manager.c @@ -19,17 +19,21 @@ #include #include +#if __SSE2__ +#include +#endif + #include #include "state_manager.h" -#include "configuration.h" -#include "msg_hash.h" -#include "movie.h" -#include "core.h" -#include "runloop.h" -#include "performance.h" -#include "verbosity.h" -#include "audio/audio_driver.h" +#include "../configuration.h" +#include "../msg_hash.h" +#include "../movie.h" +#include "../core.h" +#include "../runloop.h" +#include "../performance.h" +#include "../verbosity.h" +#include "../audio/audio_driver.h" /* This makes Valgrind throw errors if a core overflows its savestate size. */ /* Keep it off unless you're chasing a core bug, it slows things down. */ @@ -175,7 +179,6 @@ static INLINE int compat_ctz(unsigned x) } #endif -#include /* There's no equivalent in libc, you'd think so ... * std::mismatch exists, but it's not optimized at all. */ diff --git a/state_manager.h b/managers/state_manager.h similarity index 100% rename from state_manager.h rename to managers/state_manager.h diff --git a/menu/cbs/menu_cbs_get_value.c b/menu/cbs/menu_cbs_get_value.c index 78a96ea09a..00a89387e4 100644 --- a/menu/cbs/menu_cbs_get_value.c +++ b/menu/cbs/menu_cbs_get_value.c @@ -28,7 +28,7 @@ #include "../../core_info.h" #include "../../core_options.h" -#include "../../cheats.h" +#include "../../managers/cheat_manager.h" #include "../../general.h" #include "../../performance.h" #include "../../system.h" diff --git a/menu/cbs/menu_cbs_left.c b/menu/cbs/menu_cbs_left.c index a33c3aa7ca..cbcb4763c3 100644 --- a/menu/cbs/menu_cbs_left.c +++ b/menu/cbs/menu_cbs_left.c @@ -26,7 +26,7 @@ #include "../menu_navigation.h" #include "../../core_info.h" -#include "../../cheats.h" +#include "../../managers/cheat_manager.h" #include "../../general.h" #include "../../retroarch.h" #include "../../system.h" diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index e071edb3c3..59d9f1696c 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -32,7 +32,7 @@ #include "../../core_info.h" #include "../../frontend/frontend_driver.h" #include "../../defaults.h" -#include "../../cheats.h" +#include "../../managers/cheat_manager.h" #include "../../general.h" #include "../../tasks/tasks_internal.h" #include "../../input/input_remapping.h" diff --git a/menu/cbs/menu_cbs_right.c b/menu/cbs/menu_cbs_right.c index e2d334a7f3..f57a1be697 100644 --- a/menu/cbs/menu_cbs_right.c +++ b/menu/cbs/menu_cbs_right.c @@ -26,7 +26,7 @@ #include "../menu_navigation.h" #include "../../core_info.h" -#include "../../cheats.h" +#include "../../managers/cheat_manager.h" #include "../../general.h" #include "../../retroarch.h" #include "../../system.h" diff --git a/menu/cbs/menu_cbs_start.c b/menu/cbs/menu_cbs_start.c index c9731b385e..f6b467546a 100644 --- a/menu/cbs/menu_cbs_start.c +++ b/menu/cbs/menu_cbs_start.c @@ -26,7 +26,7 @@ #include "../../core_info.h" #include "../../core_options.h" -#include "../../cheats.h" +#include "../../managers/cheat_manager.h" #include "../../general.h" #include "../../retroarch.h" #include "../../system.h" diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 30e84a6727..7383c4ecdd 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -31,7 +31,7 @@ #endif #include "../defaults.h" -#include "../cheats.h" +#include "../managers/cheat_manager.h" #include "../general.h" #include "../retroarch.h" #include "../system.h" diff --git a/menu/menu_input.c b/menu/menu_input.c index 65d37d66a1..a8d76940be 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -38,7 +38,7 @@ #include "menu_hash.h" #include "../general.h" -#include "../cheats.h" +#include "../managers/cheat_manager.h" #include "../performance.h" #include "../core.h" #include "../input/input_joypad_driver.h" diff --git a/retroarch.c b/retroarch.c index 88c55ae5df..2552f43d77 100644 --- a/retroarch.c +++ b/retroarch.c @@ -59,7 +59,7 @@ #include "general.h" #include "runloop.h" #include "performance.h" -#include "cheats.h" +#include "managers/cheat_manager.h" #include "system.h" #include "git_version.h" diff --git a/runloop.c b/runloop.c index a61dc2f21a..214f8c053e 100644 --- a/runloop.c +++ b/runloop.c @@ -38,13 +38,13 @@ #include "autosave.h" #include "core_info.h" #include "core_options.h" -#include "cheats.h" #include "configuration.h" #include "performance.h" #include "movie.h" #include "retroarch.h" #include "runloop.h" -#include "state_manager.h" +#include "managers/cheat_manager.h" +#include "managers/state_manager.h" #include "system.h" #include "list_special.h" #include "audio/audio_driver.h" From 1cd98f1cf7ac08d22943f1b77a625006002509b4 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 May 2016 19:21:40 +0200 Subject: [PATCH 336/498] (Androd) Buildfix --- network/net_http_special.c | 3 +-- network/net_http_special.h | 2 +- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/network/net_http_special.c b/network/net_http_special.c index 371e8b114b..3eec1fb230 100644 --- a/network/net_http_special.c +++ b/network/net_http_special.c @@ -18,8 +18,7 @@ #include -#include "libretro.h" -#include "performance.h" +#include "../performance.h" #include "net_http_special.h" int net_http_get(const char **result, size_t *size, const char *url, retro_time_t *timeout) diff --git a/network/net_http_special.h b/network/net_http_special.h index c22e5f01f8..de8c305153 100644 --- a/network/net_http_special.h +++ b/network/net_http_special.h @@ -17,7 +17,7 @@ #ifndef __NET_HTTP_SPECIAL_H #define __NET_HTTP_SPECIAL_H -#include "libretro.h" +#include "../libretro.h" enum { From 6bbe5fb83a865be8aca397825ba07fd4f996de3c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 May 2016 19:24:10 +0200 Subject: [PATCH 337/498] Avoid warning --- gfx/drivers/gl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index d279bdfb1d..182f12edf8 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -197,7 +197,7 @@ static bool gl_check_mipmap(void) if (!extension) return false; - return glGenerateMipmap; + return true; } #ifndef HAVE_OPENGLES From 1e87fed4480b8bb21f35732298ea7eb3a8822c71 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 May 2016 20:05:09 +0200 Subject: [PATCH 338/498] Change ifdef --- managers/cheat_manager.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/managers/cheat_manager.h b/managers/cheat_manager.h index cbd694c40f..af1a167c7b 100644 --- a/managers/cheat_manager.h +++ b/managers/cheat_manager.h @@ -14,8 +14,8 @@ * If not, see . */ -#ifndef __RARCH_CHEATS_H -#define __RARCH_CHEATS_H +#ifndef __CHEAT_MANAGER_H +#define __CHEAT_MANAGER_H #include From 3c74031c2f6b048e418c621dba2952dd8f26c62b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 May 2016 20:10:08 +0200 Subject: [PATCH 339/498] Rename rarch_cmd to command --- command.c | 30 +++++++++++++++--------------- command.h | 20 ++++++++++---------- input/input_driver.c | 12 ++++++------ retroarch.c | 2 +- 4 files changed, 32 insertions(+), 32 deletions(-) diff --git a/command.c b/command.c index fafe0291cf..633ae5205b 100644 --- a/command.c +++ b/command.c @@ -46,7 +46,7 @@ #define COMMAND_EXT_SLANG 0x105ce63aU #define COMMAND_EXT_SLANGP 0x1bf9adeaU -struct rarch_cmd +struct command { #ifdef HAVE_STDIN_CMD bool stdin_enable; @@ -121,7 +121,7 @@ static const struct cmd_map map[] = { }; #if defined(HAVE_NETWORK_CMD) && defined(HAVE_NETPLAY) -static bool cmd_init_network(rarch_cmd_t *handle, uint16_t port) +static bool cmd_init_network(command_t *handle, uint16_t port) { int fd; struct addrinfo *res = NULL; @@ -156,7 +156,7 @@ error: #endif #ifdef HAVE_STDIN_CMD -static bool cmd_init_stdin(rarch_cmd_t *handle) +static bool cmd_init_stdin(command_t *handle) { #ifndef _WIN32 #ifdef HAVE_NETPLAY @@ -170,10 +170,10 @@ static bool cmd_init_stdin(rarch_cmd_t *handle) } #endif -rarch_cmd_t *rarch_cmd_new(bool stdin_enable, +command_t *command_new(bool stdin_enable, bool network_enable, uint16_t port) { - rarch_cmd_t *handle = (rarch_cmd_t*)calloc(1, sizeof(*handle)); + command_t *handle = (command_t*)calloc(1, sizeof(*handle)); if (!handle) return NULL; @@ -197,7 +197,7 @@ rarch_cmd_t *rarch_cmd_new(bool stdin_enable, #if (defined(HAVE_NETWORK_CMD) && defined(HAVE_NETPLAY)) || defined(HAVE_STDIN_CMD) error: - rarch_cmd_free(handle); + command_free(handle); return NULL; #endif } @@ -277,7 +277,7 @@ static bool command_get_arg(const char *tok, return false; } -static void parse_sub_msg(rarch_cmd_t *handle, const char *tok) +static void parse_sub_msg(command_t *handle, const char *tok) { const char *arg = NULL; unsigned index = 0; @@ -299,7 +299,7 @@ static void parse_sub_msg(rarch_cmd_t *handle, const char *tok) msg_hash_to_str(MSG_RECEIVED)); } -static void parse_msg(rarch_cmd_t *handle, char *buf) +static void parse_msg(command_t *handle, char *buf) { char *save = NULL; const char *tok = strtok_r(buf, "\n", &save); @@ -312,7 +312,7 @@ static void parse_msg(rarch_cmd_t *handle, char *buf) } #if defined(HAVE_NETWORK_CMD) && defined(HAVE_NETPLAY) -static void network_cmd_poll(rarch_cmd_t *handle) +static void network_cmd_poll(command_t *handle) { fd_set fds; struct timeval tmp_tv = {0}; @@ -451,7 +451,7 @@ static size_t read_stdin(char *buf, size_t size) } #endif -static void stdin_cmd_poll(rarch_cmd_t *handle) +static void stdin_cmd_poll(command_t *handle) { char *last_newline; ssize_t ret; @@ -564,7 +564,7 @@ static bool verify_command(const char *cmd) return false; } -bool rarch_cmd_send(const char *cmd_) +bool command_send(const char *cmd_) { bool ret; char *command = NULL; @@ -609,7 +609,7 @@ bool rarch_cmd_send(const char *cmd_) } #endif -bool rarch_cmd_poll(rarch_cmd_t *handle) +bool command_poll(command_t *handle) { memset(handle->state, 0, sizeof(handle->state)); @@ -624,7 +624,7 @@ bool rarch_cmd_poll(rarch_cmd_t *handle) return true; } -bool rarch_cmd_set(rarch_cmd_handle_t *handle) +bool command_set(command_handle_t *handle) { if (!handle || !handle->handle) return false; @@ -633,7 +633,7 @@ bool rarch_cmd_set(rarch_cmd_handle_t *handle) return true; } -bool rarch_cmd_free(rarch_cmd_t *handle) +bool command_free(command_t *handle) { #if defined(HAVE_NETWORK_CMD) && defined(HAVE_NETPLAY) if (handle && handle->net_fd >= 0) @@ -645,7 +645,7 @@ bool rarch_cmd_free(rarch_cmd_t *handle) return true; } -bool rarch_cmd_get(rarch_cmd_handle_t *handle) +bool command_get(command_handle_t *handle) { if (!handle || !handle->handle) return false; diff --git a/command.h b/command.h index 4f6647a144..2787a651f4 100644 --- a/command.h +++ b/command.h @@ -28,28 +28,28 @@ extern "C" { #endif -typedef struct rarch_cmd rarch_cmd_t; +typedef struct command command_t; -typedef struct rarch_cmd_handle +typedef struct command_handle { - rarch_cmd_t *handle; + command_t *handle; unsigned id; -} rarch_cmd_handle_t; +} command_handle_t; -rarch_cmd_t *rarch_cmd_new(bool stdin_enable, +command_t *command_new(bool stdin_enable, bool network_enable, uint16_t port); #if defined(HAVE_NETWORK_CMD) && defined(HAVE_NETPLAY) -bool rarch_cmd_send(const char *cmd_); +bool command_send(const char *cmd_); #endif -bool rarch_cmd_poll(rarch_cmd_t *handle); +bool command_poll(command_t *handle); -bool rarch_cmd_set(rarch_cmd_handle_t *handle); +bool command_set(command_handle_t *handle); -bool rarch_cmd_get(rarch_cmd_handle_t *handle); +bool command_get(command_handle_t *handle); -bool rarch_cmd_free(rarch_cmd_t *handle); +bool command_free(command_t *handle); #ifdef __cplusplus } diff --git a/input/input_driver.c b/input/input_driver.c index 58779019d9..d44efbbb23 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -96,7 +96,7 @@ struct turbo_buttons static turbo_buttons_t input_driver_turbo_btns; #ifdef HAVE_COMMAND -static rarch_cmd_t *input_driver_command = NULL; +static command_t *input_driver_command = NULL; #endif #ifdef HAVE_NETWORK_GAMEPAD static input_remote_t *input_driver_remote = NULL; @@ -275,12 +275,12 @@ static retro_input_t input_driver_keys_pressed(void) #ifdef HAVE_COMMAND if (input_driver_command) { - rarch_cmd_handle_t handle; + command_handle_t handle; handle.handle = input_driver_command; handle.id = key; - state |= rarch_cmd_get(&handle); + state |= command_get(&handle); } #endif @@ -436,7 +436,7 @@ void input_poll(void) #ifdef HAVE_COMMAND if (input_driver_command) - rarch_cmd_poll(input_driver_command); + command_poll(input_driver_command); #endif #ifdef HAVE_NETWORK_GAMEPAD @@ -849,7 +849,7 @@ bool input_driver_init_command(void) "Cannot use this command interface.\n"); } - input_driver_command = rarch_cmd_new(settings->stdin_cmd_enable + input_driver_command = command_new(settings->stdin_cmd_enable && !input_driver_grab_stdin(), settings->network_cmd_enable, settings->network_cmd_port); @@ -869,7 +869,7 @@ void input_driver_deinit_command(void) { #ifdef HAVE_COMMAND if (input_driver_command) - rarch_cmd_free(input_driver_command); + command_free(input_driver_command); input_driver_command = NULL; #endif } diff --git a/retroarch.c b/retroarch.c index 2552f43d77..6e3338d67c 100644 --- a/retroarch.c +++ b/retroarch.c @@ -952,7 +952,7 @@ static void retroarch_parse_input(int argc, char *argv[]) #if defined(HAVE_NETWORK_CMD) && defined(HAVE_NETPLAY) case RA_OPT_COMMAND: - if (rarch_cmd_send((const char*)optarg)) + if (command_send((const char*)optarg)) exit(0); else retroarch_fail(1, "network_cmd_send()"); From a98ef36d360f23b927265a5bd45216fd66eb6859 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 May 2016 20:20:50 +0200 Subject: [PATCH 340/498] Rename event_cmd_ctl to command_event --- audio/audio_driver.c | 10 +-- cheevos.c | 6 +- command_event.c | 84 +++++++++++++------------- command_event.h | 2 +- content.c | 6 +- driver.c | 12 ++-- dynamic.c | 2 +- frontend/drivers/platform_ctr.c | 2 +- frontend/drivers/platform_emscripten.c | 8 +-- frontend/drivers/platform_psp.c | 2 +- frontend/frontend.c | 4 +- gfx/drivers/ctr_gfx.c | 4 +- gfx/video_driver.c | 10 +-- input/drivers/android_input.c | 4 +- input/drivers_joypad/ctr_joypad.c | 2 +- menu/cbs/menu_cbs_left.c | 2 +- menu/cbs/menu_cbs_ok.c | 26 ++++---- menu/cbs/menu_cbs_right.c | 2 +- menu/cbs/menu_cbs_start.c | 2 +- menu/drivers/nuklear.c | 2 +- menu/drivers/zarch.c | 2 +- menu/menu_content.c | 4 +- menu/menu_displaylist.c | 2 +- menu/menu_driver.c | 16 ++--- menu/menu_setting.c | 12 ++-- network/netplay.c | 6 +- record/record_driver.c | 8 +-- retroarch.c | 58 +++++++++--------- runloop.c | 50 +++++++-------- tasks/task_content.c | 4 +- ui/drivers/ui_cocoa.m | 2 +- ui/drivers/ui_cocoatouch.m | 2 +- ui/drivers/ui_qt.c | 2 +- ui/drivers/ui_win32.c | 2 +- 34 files changed, 181 insertions(+), 181 deletions(-) diff --git a/audio/audio_driver.c b/audio/audio_driver.c index 18ef6ae84c..7d74c0b9a5 100644 --- a/audio/audio_driver.c +++ b/audio/audio_driver.c @@ -297,7 +297,7 @@ static bool uninit_audio(void) free(audio_driver_data.output_samples.buf); audio_driver_data.output_samples.buf = NULL; - event_cmd_ctl(EVENT_CMD_DSP_FILTER_DEINIT, NULL); + command_event(EVENT_CMD_DSP_FILTER_DEINIT, NULL); compute_audio_buffer_statistics(); @@ -380,7 +380,7 @@ static bool audio_driver_init_internal(bool audio_cb_inited) if (!settings->audio.sync && audio_driver_is_active()) { - event_cmd_ctl(EVENT_CMD_AUDIO_SET_NONBLOCKING_STATE, NULL); + command_event(EVENT_CMD_AUDIO_SET_NONBLOCKING_STATE, NULL); audio_driver_data.chunk.size = audio_driver_data.chunk.nonblock_size; } @@ -438,7 +438,7 @@ static bool audio_driver_init_internal(bool audio_cb_inited) RARCH_WARN("Audio rate control was desired, but driver does not support needed features.\n"); } - event_cmd_ctl(EVENT_CMD_DSP_FILTER_INIT, NULL); + command_event(EVENT_CMD_DSP_FILTER_INIT, NULL); audio_driver_data.free_samples.count = 0; @@ -928,8 +928,8 @@ bool audio_driver_toggle_mute(void) settings->audio.mute_enable = !settings->audio.mute_enable; if (settings->audio.mute_enable) - event_cmd_ctl(EVENT_CMD_AUDIO_STOP, NULL); - else if (!event_cmd_ctl(EVENT_CMD_AUDIO_START, NULL)) + command_event(EVENT_CMD_AUDIO_STOP, NULL); + else if (!command_event(EVENT_CMD_AUDIO_START, NULL)) { audio_driver_unset_active(); return false; diff --git a/cheevos.c b/cheevos.c index de23ba515b..c3bc001a5f 100644 --- a/cheevos.c +++ b/cheevos.c @@ -2214,9 +2214,9 @@ bool cheevos_toggle_hardcore_mode(void) if (settings->cheevos.hardcore_mode_enable) { /* send reset core cmd to avoid any user savestate previusly loaded */ - event_cmd_ctl(EVENT_CMD_RESET, NULL); + command_event(EVENT_CMD_RESET, NULL); if (settings->rewind_enable) - event_cmd_ctl(EVENT_CMD_REWIND_DEINIT, NULL); + command_event(EVENT_CMD_REWIND_DEINIT, NULL); RARCH_LOG("%s\n", msg_hash_to_str(MSG_CHEEVOS_HARDCORE_MODE_ENABLE)); runloop_msg_queue_push(msg_hash_to_str(MSG_CHEEVOS_HARDCORE_MODE_ENABLE), 0, 3 * 60, true); @@ -2224,7 +2224,7 @@ bool cheevos_toggle_hardcore_mode(void) else { if (settings->rewind_enable) - event_cmd_ctl(EVENT_CMD_REWIND_INIT, NULL); + command_event(EVENT_CMD_REWIND_INIT, NULL); } return true; diff --git a/command_event.c b/command_event.c index 9e76c7e979..7f03348b73 100644 --- a/command_event.c +++ b/command_event.c @@ -212,7 +212,7 @@ static bool event_disk_control_append_image(const char *path) RARCH_LOG("%s\n", msg); runloop_msg_queue_push(msg, 0, 180, true); - event_cmd_ctl(EVENT_CMD_AUTOSAVE_DEINIT, NULL); + command_event(EVENT_CMD_AUTOSAVE_DEINIT, NULL); /* TODO: Need to figure out what to do with subsystems case. */ if (!*global->subsystem) @@ -225,7 +225,7 @@ static bool event_disk_control_append_image(const char *path) rarch_ctl(RARCH_CTL_FILL_PATHNAMES, NULL); } - event_cmd_ctl(EVENT_CMD_AUTOSAVE_INIT, NULL); + command_event(EVENT_CMD_AUTOSAVE_INIT, NULL); event_disk_control_set_index(new_idx); event_disk_control_set_eject(false, false); @@ -571,8 +571,8 @@ static bool event_init_content(void) msg_hash_to_str(MSG_SKIPPING_SRAM_LOAD)); event_load_auto_state(); - event_cmd_ctl(EVENT_CMD_BSV_MOVIE_INIT, NULL); - event_cmd_ctl(EVENT_CMD_NETPLAY_INIT, NULL); + command_event(EVENT_CMD_BSV_MOVIE_INIT, NULL); + command_event(EVENT_CMD_NETPLAY_INIT, NULL); return true; } @@ -921,14 +921,14 @@ static bool event_cmd_exec(void *data) } /** - * event_cmd_ctl: + * command_event: * @cmd : Event command index. * * Performs program event command with index @cmd. * * Returns: true (1) on success, otherwise false (0). **/ -bool event_cmd_ctl(enum event_command cmd, void *data) +bool command_event(enum event_command cmd, void *data) { unsigned i = 0; bool boolean = false; @@ -951,7 +951,7 @@ bool event_cmd_ctl(enum event_command cmd, void *data) { unsigned width = 0, height = 0; - event_cmd_ctl(EVENT_CMD_VIDEO_SET_ASPECT_RATIO, NULL); + command_event(EVENT_CMD_VIDEO_SET_ASPECT_RATIO, NULL); if (video_driver_get_video_output_size(&width, &height)) { @@ -970,7 +970,7 @@ bool event_cmd_ctl(enum event_command cmd, void *data) break; case EVENT_CMD_LOAD_CONTENT_PERSIST: #ifdef HAVE_DYNAMIC - event_cmd_ctl(EVENT_CMD_LOAD_CORE, NULL); + command_event(EVENT_CMD_LOAD_CORE, NULL); #endif rarch_ctl(RARCH_CTL_LOAD_CONTENT, NULL); break; @@ -985,13 +985,13 @@ bool event_cmd_ctl(enum event_command cmd, void *data) case EVENT_CMD_LOAD_CONTENT: { #ifdef HAVE_DYNAMIC - event_cmd_ctl(EVENT_CMD_LOAD_CONTENT_PERSIST, NULL); + command_event(EVENT_CMD_LOAD_CONTENT_PERSIST, NULL); #else char *fullpath = NULL; runloop_ctl(RUNLOOP_CTL_GET_CONTENT_PATH, &fullpath); runloop_ctl(RUNLOOP_CTL_SET_LIBRETRO_PATH, settings->path.libretro); - event_cmd_ctl(EVENT_CMD_EXEC, (void*)fullpath); - event_cmd_ctl(EVENT_CMD_QUIT, NULL); + command_event(EVENT_CMD_EXEC, (void*)fullpath); + command_event(EVENT_CMD_QUIT, NULL); #endif } break; @@ -1001,7 +1001,7 @@ bool event_cmd_ctl(enum event_command cmd, void *data) #endif break; case EVENT_CMD_LOAD_CORE_PERSIST: - event_cmd_ctl(EVENT_CMD_LOAD_CORE_DEINIT, NULL); + command_event(EVENT_CMD_LOAD_CORE_DEINIT, NULL); { #ifdef HAVE_MENU bool *ptr = NULL; @@ -1033,9 +1033,9 @@ bool event_cmd_ctl(enum event_command cmd, void *data) } break; case EVENT_CMD_LOAD_CORE: - event_cmd_ctl(EVENT_CMD_LOAD_CORE_PERSIST, NULL); + command_event(EVENT_CMD_LOAD_CORE_PERSIST, NULL); #ifndef HAVE_DYNAMIC - event_cmd_ctl(EVENT_CMD_QUIT, NULL); + command_event(EVENT_CMD_QUIT, NULL); #endif break; case EVENT_CMD_LOAD_STATE: @@ -1069,7 +1069,7 @@ bool event_cmd_ctl(enum event_command cmd, void *data) settings->video.scale = *window_scale; if (!settings->video.fullscreen) - event_cmd_ctl(EVENT_CMD_REINIT, NULL); + command_event(EVENT_CMD_REINIT, NULL); runloop_ctl(RUNLOOP_CTL_SET_WINDOWED_SCALE, &idx); } @@ -1119,7 +1119,7 @@ bool event_cmd_ctl(enum event_command cmd, void *data) break; case EVENT_CMD_UNLOAD_CORE: runloop_ctl(RUNLOOP_CTL_PREPARE_DUMMY, NULL); - event_cmd_ctl(EVENT_CMD_LOAD_CORE_DEINIT, NULL); + command_event(EVENT_CMD_LOAD_CORE_DEINIT, NULL); break; case EVENT_CMD_QUIT: rarch_ctl(RARCH_CTL_QUIT, NULL); @@ -1140,7 +1140,7 @@ bool event_cmd_ctl(enum event_command cmd, void *data) video_driver_unset_video_cache_context(); video_driver_unset_video_cache_context_ack(); - event_cmd_ctl(EVENT_CMD_RESET_CONTEXT, NULL); + command_event(EVENT_CMD_RESET_CONTEXT, NULL); video_driver_unset_video_cache_context(); /* Poll input to avoid possibly stale data to corrupt things. */ @@ -1149,7 +1149,7 @@ bool event_cmd_ctl(enum event_command cmd, void *data) #ifdef HAVE_MENU menu_display_set_framebuffer_dirty_flag(); if (menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL)) - event_cmd_ctl(EVENT_CMD_VIDEO_SET_BLOCKING_STATE, NULL); + command_event(EVENT_CMD_VIDEO_SET_BLOCKING_STATE, NULL); #endif } break; @@ -1157,7 +1157,7 @@ bool event_cmd_ctl(enum event_command cmd, void *data) cheat_manager_state_free(); break; case EVENT_CMD_CHEATS_INIT: - event_cmd_ctl(EVENT_CMD_CHEATS_DEINIT, NULL); + command_event(EVENT_CMD_CHEATS_DEINIT, NULL); event_init_cheats(); break; case EVENT_CMD_CHEATS_APPLY: @@ -1187,9 +1187,9 @@ bool event_cmd_ctl(enum event_command cmd, void *data) break; case EVENT_CMD_REWIND_TOGGLE: if (settings->rewind_enable) - event_cmd_ctl(EVENT_CMD_REWIND_INIT, NULL); + command_event(EVENT_CMD_REWIND_INIT, NULL); else - event_cmd_ctl(EVENT_CMD_REWIND_DEINIT, NULL); + command_event(EVENT_CMD_REWIND_DEINIT, NULL); break; case EVENT_CMD_AUTOSAVE_DEINIT: #ifdef HAVE_THREADS @@ -1202,7 +1202,7 @@ bool event_cmd_ctl(enum event_command cmd, void *data) #endif break; case EVENT_CMD_AUTOSAVE_INIT: - event_cmd_ctl(EVENT_CMD_AUTOSAVE_DEINIT, NULL); + command_event(EVENT_CMD_AUTOSAVE_DEINIT, NULL); #ifdef HAVE_THREADS autosave_init(); #endif @@ -1251,7 +1251,7 @@ bool event_cmd_ctl(enum event_command cmd, void *data) #endif break; case EVENT_CMD_OVERLAY_INIT: - event_cmd_ctl(EVENT_CMD_OVERLAY_DEINIT, NULL); + command_event(EVENT_CMD_OVERLAY_DEINIT, NULL); #ifdef HAVE_OVERLAY input_overlay_init(); #endif @@ -1265,7 +1265,7 @@ bool event_cmd_ctl(enum event_command cmd, void *data) audio_driver_dsp_filter_free(); break; case EVENT_CMD_DSP_FILTER_INIT: - event_cmd_ctl(EVENT_CMD_DSP_FILTER_DEINIT, NULL); + command_event(EVENT_CMD_DSP_FILTER_DEINIT, NULL); if (!*settings->path.audio_dsp_plugin) break; audio_driver_dsp_filter_init(settings->path.audio_dsp_plugin); @@ -1278,7 +1278,7 @@ bool event_cmd_ctl(enum event_command cmd, void *data) return false; break; case EVENT_CMD_RECORD_INIT: - event_cmd_ctl(EVENT_CMD_HISTORY_DEINIT, NULL); + command_event(EVENT_CMD_HISTORY_DEINIT, NULL); if (!recording_init()) return false; break; @@ -1291,7 +1291,7 @@ bool event_cmd_ctl(enum event_command cmd, void *data) g_defaults.history = NULL; break; case EVENT_CMD_HISTORY_INIT: - event_cmd_ctl(EVENT_CMD_HISTORY_DEINIT, NULL); + command_event(EVENT_CMD_HISTORY_DEINIT, NULL); if (!settings->history_list_enable) return false; RARCH_LOG("%s: [%s].\n", @@ -1305,7 +1305,7 @@ bool event_cmd_ctl(enum event_command cmd, void *data) core_info_deinit_list(); break; case EVENT_CMD_CORE_INFO_INIT: - event_cmd_ctl(EVENT_CMD_CORE_INFO_DEINIT, NULL); + command_event(EVENT_CMD_CORE_INFO_DEINIT, NULL); if (*settings->directory.libretro) core_info_init_list(); @@ -1418,7 +1418,7 @@ bool event_cmd_ctl(enum event_command cmd, void *data) if (runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL)) { RARCH_LOG("%s\n", msg_hash_to_str(MSG_PAUSED)); - event_cmd_ctl(EVENT_CMD_AUDIO_STOP, NULL); + command_event(EVENT_CMD_AUDIO_STOP, NULL); if (settings->video.black_frame_insertion) video_driver_cached_frame_render(); @@ -1426,40 +1426,40 @@ bool event_cmd_ctl(enum event_command cmd, void *data) else { RARCH_LOG("%s\n", msg_hash_to_str(MSG_UNPAUSED)); - event_cmd_ctl(EVENT_CMD_AUDIO_START, NULL); + command_event(EVENT_CMD_AUDIO_START, NULL); } break; case EVENT_CMD_PAUSE_TOGGLE: boolean = runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL); boolean = !boolean; runloop_ctl(RUNLOOP_CTL_SET_PAUSED, &boolean); - event_cmd_ctl(EVENT_CMD_PAUSE_CHECKS, NULL); + command_event(EVENT_CMD_PAUSE_CHECKS, NULL); break; case EVENT_CMD_UNPAUSE: boolean = false; runloop_ctl(RUNLOOP_CTL_SET_PAUSED, &boolean); - event_cmd_ctl(EVENT_CMD_PAUSE_CHECKS, NULL); + command_event(EVENT_CMD_PAUSE_CHECKS, NULL); break; case EVENT_CMD_PAUSE: boolean = true; runloop_ctl(RUNLOOP_CTL_SET_PAUSED, &boolean); - event_cmd_ctl(EVENT_CMD_PAUSE_CHECKS, NULL); + command_event(EVENT_CMD_PAUSE_CHECKS, NULL); break; case EVENT_CMD_MENU_PAUSE_LIBRETRO: #ifdef HAVE_MENU if (menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL)) { if (settings->menu.pause_libretro) - event_cmd_ctl(EVENT_CMD_AUDIO_STOP, NULL); + command_event(EVENT_CMD_AUDIO_STOP, NULL); else - event_cmd_ctl(EVENT_CMD_AUDIO_START, NULL); + command_event(EVENT_CMD_AUDIO_START, NULL); } else { if (settings->menu.pause_libretro) - event_cmd_ctl(EVENT_CMD_AUDIO_START, NULL); + command_event(EVENT_CMD_AUDIO_START, NULL); } #endif break; @@ -1467,7 +1467,7 @@ bool event_cmd_ctl(enum event_command cmd, void *data) runloop_ctl(RUNLOOP_CTL_SHADER_DIR_DEINIT, NULL); break; case EVENT_CMD_SHADER_DIR_INIT: - event_cmd_ctl(EVENT_CMD_SHADER_DIR_DEINIT, NULL); + command_event(EVENT_CMD_SHADER_DIR_DEINIT, NULL); if (!runloop_ctl(RUNLOOP_CTL_SHADER_DIR_INIT, NULL)) return false; @@ -1519,14 +1519,14 @@ bool event_cmd_ctl(enum event_command cmd, void *data) msg_hash_to_str(MSG_SRAM_WILL_NOT_BE_SAVED)); if (global->sram.use) - event_cmd_ctl(EVENT_CMD_AUTOSAVE_INIT, NULL); + command_event(EVENT_CMD_AUTOSAVE_INIT, NULL); } break; case EVENT_CMD_BSV_MOVIE_DEINIT: bsv_movie_ctl(BSV_MOVIE_CTL_DEINIT, NULL); break; case EVENT_CMD_BSV_MOVIE_INIT: - event_cmd_ctl(EVENT_CMD_BSV_MOVIE_DEINIT, NULL); + command_event(EVENT_CMD_BSV_MOVIE_DEINIT, NULL); bsv_movie_ctl(BSV_MOVIE_CTL_INIT, NULL); break; case EVENT_CMD_NETPLAY_DEINIT: @@ -1545,7 +1545,7 @@ bool event_cmd_ctl(enum event_command cmd, void *data) #endif break; case EVENT_CMD_NETPLAY_INIT: - event_cmd_ctl(EVENT_CMD_NETPLAY_DEINIT, NULL); + command_event(EVENT_CMD_NETPLAY_DEINIT, NULL); #ifdef HAVE_NETPLAY if (!init_netplay()) return false; @@ -1563,20 +1563,20 @@ bool event_cmd_ctl(enum event_command cmd, void *data) /* If we go fullscreen we drop all drivers and * reinitialize to be safe. */ settings->video.fullscreen = !settings->video.fullscreen; - event_cmd_ctl(EVENT_CMD_REINIT, NULL); + command_event(EVENT_CMD_REINIT, NULL); break; case EVENT_CMD_COMMAND_DEINIT: input_driver_deinit_command(); break; case EVENT_CMD_COMMAND_INIT: - event_cmd_ctl(EVENT_CMD_COMMAND_DEINIT, NULL); + command_event(EVENT_CMD_COMMAND_DEINIT, NULL); input_driver_init_command(); break; case EVENT_CMD_REMOTE_DEINIT: input_driver_deinit_remote(); break; case EVENT_CMD_REMOTE_INIT: - event_cmd_ctl(EVENT_CMD_REMOTE_DEINIT, NULL); + command_event(EVENT_CMD_REMOTE_DEINIT, NULL); input_driver_init_remote(); break; case EVENT_CMD_TEMPORARY_CONTENT_DEINIT: diff --git a/command_event.h b/command_event.h index 28d74b7558..d51832314a 100644 --- a/command_event.h +++ b/command_event.h @@ -216,7 +216,7 @@ enum event_command * * Returns: true (1) on success, otherwise false (0). **/ -bool event_cmd_ctl(enum event_command action, void *data); +bool command_event(enum event_command action, void *data); #ifdef __cplusplus } diff --git a/content.c b/content.c index 6f10332dbc..82c58b81a1 100644 --- a/content.c +++ b/content.c @@ -901,9 +901,9 @@ bool content_load(content_ctx_info_t *info) #ifdef HAVE_MENU menu_driver_ctl(RARCH_MENU_CTL_SHADER_MANAGER_INIT, NULL); #endif - event_cmd_ctl(EVENT_CMD_HISTORY_INIT, NULL); - event_cmd_ctl(EVENT_CMD_RESUME, NULL); - event_cmd_ctl(EVENT_CMD_VIDEO_SET_ASPECT_RATIO, NULL); + command_event(EVENT_CMD_HISTORY_INIT, NULL); + command_event(EVENT_CMD_RESUME, NULL); + command_event(EVENT_CMD_VIDEO_SET_ASPECT_RATIO, NULL); check_default_dirs(); diff --git a/driver.c b/driver.c index c5bbe04d08..c5c4c05378 100644 --- a/driver.c +++ b/driver.c @@ -207,7 +207,7 @@ static void driver_adjust_system_rates(void) return; if (runloop_ctl(RUNLOOP_CTL_IS_NONBLOCK_FORCED, NULL)) - event_cmd_ctl(EVENT_CMD_VIDEO_SET_NONBLOCKING_STATE, NULL); + command_event(EVENT_CMD_VIDEO_SET_NONBLOCKING_STATE, NULL); else driver_ctl(RARCH_DRIVER_CTL_SET_NONBLOCK_STATE, NULL); } @@ -254,7 +254,7 @@ static bool driver_update_system_av_info(const struct retro_system_av_info *info struct retro_system_av_info *av_info = video_viewport_get_system_av_info(); memcpy(av_info, info, sizeof(*av_info)); - event_cmd_ctl(EVENT_CMD_REINIT, NULL); + command_event(EVENT_CMD_REINIT, NULL); /* Cannot continue recording with different parameters. * Take the easiest route out and just restart the recording. */ @@ -263,8 +263,8 @@ static bool driver_update_system_av_info(const struct retro_system_av_info *info runloop_msg_queue_push( msg_hash_to_str(MSG_RESTARTING_RECORDING_DUE_TO_DRIVER_REINIT), 2, 180, false); - event_cmd_ctl(EVENT_CMD_RECORD_DEINIT, NULL); - event_cmd_ctl(EVENT_CMD_RECORD_INIT, NULL); + command_event(EVENT_CMD_RECORD_DEINIT, NULL); + command_event(EVENT_CMD_RECORD_INIT, NULL); } return true; @@ -286,8 +286,8 @@ static void menu_update_libretro_info(void) if (!info) return; - event_cmd_ctl(EVENT_CMD_CORE_INFO_INIT, NULL); - event_cmd_ctl(EVENT_CMD_LOAD_CORE_PERSIST, NULL); + command_event(EVENT_CMD_CORE_INFO_INIT, NULL); + command_event(EVENT_CMD_LOAD_CORE_PERSIST, NULL); } #endif diff --git a/dynamic.c b/dynamic.c index df878f5628..395f24cf52 100644 --- a/dynamic.c +++ b/dynamic.c @@ -1245,7 +1245,7 @@ bool rarch_environment_cb(unsigned cmd, void *data) /* Forces recomputation of aspect ratios if * using core-dependent aspect ratios. */ - event_cmd_ctl(EVENT_CMD_VIDEO_SET_ASPECT_RATIO, NULL); + command_event(EVENT_CMD_VIDEO_SET_ASPECT_RATIO, NULL); /* TODO: Figure out what to do, if anything, with recording. */ } diff --git a/frontend/drivers/platform_ctr.c b/frontend/drivers/platform_ctr.c index 7ba3ee9447..b7cb60c86a 100644 --- a/frontend/drivers/platform_ctr.c +++ b/frontend/drivers/platform_ctr.c @@ -95,7 +95,7 @@ static void frontend_ctr_deinit(void *data) *verbose = true; #ifdef HAVE_FILE_LOGGER - event_cmd_ctl(EVENT_CMD_LOG_FILE_DEINIT, NULL); + command_event(EVENT_CMD_LOG_FILE_DEINIT, NULL); #endif if(gfxBottomFramebuffers[0] == (u8*)currentConsole->frameBuffer) diff --git a/frontend/drivers/platform_emscripten.c b/frontend/drivers/platform_emscripten.c index e0a9a33105..9d9d43bdaa 100644 --- a/frontend/drivers/platform_emscripten.c +++ b/frontend/drivers/platform_emscripten.c @@ -44,22 +44,22 @@ static void emscripten_mainloop(void) void cmd_savefiles(void) { - event_cmd_ctl(EVENT_CMD_SAVEFILES, NULL); + command_event(EVENT_CMD_SAVEFILES, NULL); } void cmd_save_state(void) { - event_cmd_ctl(EVENT_CMD_SAVE_STATE, NULL); + command_event(EVENT_CMD_SAVE_STATE, NULL); } void cmd_load_state(void) { - event_cmd_ctl(EVENT_CMD_LOAD_STATE, NULL); + command_event(EVENT_CMD_LOAD_STATE, NULL); } void cmd_take_screenshot(void) { - event_cmd_ctl(EVENT_CMD_TAKE_SCREENSHOT, NULL); + command_event(EVENT_CMD_TAKE_SCREENSHOT, NULL); } diff --git a/frontend/drivers/platform_psp.c b/frontend/drivers/platform_psp.c index b998ecdcd9..97cbadfd7a 100644 --- a/frontend/drivers/platform_psp.c +++ b/frontend/drivers/platform_psp.c @@ -163,7 +163,7 @@ static void frontend_psp_deinit(void *data) *verbose = false; #ifdef HAVE_FILE_LOGGER - event_cmd_ctl(EVENT_CMD_LOG_FILE_DEINIT, NULL); + command_event(EVENT_CMD_LOG_FILE_DEINIT, NULL); #endif #endif diff --git a/frontend/frontend.c b/frontend/frontend.c index 7922589f47..ac23b047a9 100644 --- a/frontend/frontend.c +++ b/frontend/frontend.c @@ -59,7 +59,7 @@ void main_exit(void *args) { settings_t *settings = config_get_ptr(); - event_cmd_ctl(EVENT_CMD_MENU_SAVE_CURRENT_CONFIG, NULL); + command_event(EVENT_CMD_MENU_SAVE_CURRENT_CONFIG, NULL); #ifdef HAVE_MENU /* Do not want menu context to live any more. */ @@ -67,7 +67,7 @@ void main_exit(void *args) #endif rarch_ctl(RARCH_CTL_MAIN_DEINIT, NULL); - event_cmd_ctl(EVENT_CMD_PERFCNT_REPORT_FRONTEND_LOG, NULL); + command_event(EVENT_CMD_PERFCNT_REPORT_FRONTEND_LOG, NULL); #if defined(HAVE_LOGGER) && !defined(ANDROID) logger_shutdown(); diff --git a/gfx/drivers/ctr_gfx.c b/gfx/drivers/ctr_gfx.c index 31919122f2..a9cae9880a 100644 --- a/gfx/drivers/ctr_gfx.c +++ b/gfx/drivers/ctr_gfx.c @@ -512,13 +512,13 @@ static bool ctr_frame(void* data, const void* frame, if(!aptMainLoop()) { - event_cmd_ctl(EVENT_CMD_QUIT, NULL); + command_event(EVENT_CMD_QUIT, NULL); return true; } if (select_pressed) { - event_cmd_ctl(EVENT_CMD_QUIT, NULL); + command_event(EVENT_CMD_QUIT, NULL); return true; } diff --git a/gfx/video_driver.c b/gfx/video_driver.c index aafe362853..c711fa2cd5 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -505,7 +505,7 @@ static void deinit_pixel_converter(void) static bool uninit_video_input(void) { - event_cmd_ctl(EVENT_CMD_OVERLAY_DEINIT, NULL); + command_event(EVENT_CMD_OVERLAY_DEINIT, NULL); if (!video_driver_is_video_cache_context()) video_driver_deinit_hw_context(); @@ -526,7 +526,7 @@ static bool uninit_video_input(void) deinit_pixel_converter(); deinit_video_filter(); - event_cmd_ctl(EVENT_CMD_SHADER_DIR_DEINIT, NULL); + command_event(EVENT_CMD_SHADER_DIR_DEINIT, NULL); video_monitor_compute_fps_statistics(); return true; @@ -600,7 +600,7 @@ static bool init_video(void) runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); init_video_filter(video_driver_state.pix_fmt); - event_cmd_ctl(EVENT_CMD_SHADER_DIR_INIT, NULL); + command_event(EVENT_CMD_SHADER_DIR_INIT, NULL); if (av_info) geom = (const struct retro_game_geometry*)&av_info->geometry; @@ -742,8 +742,8 @@ static bool init_video(void) init_video_input(tmp); - event_cmd_ctl(EVENT_CMD_OVERLAY_DEINIT, NULL); - event_cmd_ctl(EVENT_CMD_OVERLAY_INIT, NULL); + command_event(EVENT_CMD_OVERLAY_DEINIT, NULL); + command_event(EVENT_CMD_OVERLAY_INIT, NULL); video_driver_cached_frame_set(&dummy_pixels, 4, 4, 8); diff --git a/input/drivers/android_input.c b/input/drivers/android_input.c index 980ecdc1b0..312e9972d2 100644 --- a/input/drivers/android_input.c +++ b/input/drivers/android_input.c @@ -1067,7 +1067,7 @@ static void android_input_poll(void *data) if (android_app->reinitRequested != 0) { if (runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL)) - event_cmd_ctl(EVENT_CMD_REINIT, NULL); + command_event(EVENT_CMD_REINIT, NULL); android_app_write_cmd(android_app, APP_CMD_REINIT_DONE); return; } @@ -1094,7 +1094,7 @@ bool android_run_events(void *data) if (android_app->reinitRequested != 0) { if (runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL)) - event_cmd_ctl(EVENT_CMD_REINIT, NULL); + command_event(EVENT_CMD_REINIT, NULL); android_app_write_cmd(android_app, APP_CMD_REINIT_DONE); } diff --git a/input/drivers_joypad/ctr_joypad.c b/input/drivers_joypad/ctr_joypad.c index 803339ffbf..8f8621f523 100644 --- a/input/drivers_joypad/ctr_joypad.c +++ b/input/drivers_joypad/ctr_joypad.c @@ -170,7 +170,7 @@ static void ctr_joypad_poll(void) (state_tmp & KEY_SELECT) && (state_tmp & KEY_L) && (state_tmp & KEY_R)) - event_cmd_ctl(EVENT_CMD_QUIT, NULL); + command_event(EVENT_CMD_QUIT, NULL); } diff --git a/menu/cbs/menu_cbs_left.c b/menu/cbs/menu_cbs_left.c index cbcb4763c3..9ae34ab732 100644 --- a/menu/cbs/menu_cbs_left.c +++ b/menu/cbs/menu_cbs_left.c @@ -369,7 +369,7 @@ static int core_setting_left(unsigned type, const char *label, static int disk_options_disk_idx_left(unsigned type, const char *label, bool wraparound) { - event_cmd_ctl(EVENT_CMD_DISK_PREV, NULL); + command_event(EVENT_CMD_DISK_PREV, NULL); return 0; } diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 59d9f1696c..44feb5477c 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -506,7 +506,7 @@ static int file_load_with_detect_core_wrapper(size_t idx, size_t entry_idx, switch (ret) { case -1: - event_cmd_ctl(EVENT_CMD_LOAD_CORE, NULL); + command_event(EVENT_CMD_LOAD_CORE, NULL); rarch_task_push_content_load_default(NULL, NULL, false, CORE_TYPE_PLAIN, NULL, NULL); @@ -695,7 +695,7 @@ static int action_ok_playlist_entry(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) { - event_cmd_ctl(EVENT_CMD_CHEATS_APPLY, NULL); + command_event(EVENT_CMD_CHEATS_APPLY, NULL); return 0; } @@ -758,7 +758,7 @@ static int generic_action_ok(const char *path, flush_char = NULL; flush_type = MENU_SETTINGS; runloop_ctl(RUNLOOP_CTL_SET_LIBRETRO_PATH, action_path); - if (event_cmd_ctl(EVENT_CMD_LOAD_CORE, NULL)) + if (command_event(EVENT_CMD_LOAD_CORE, NULL)) { #ifndef HAVE_DYNAMIC if (frontend_driver_set_fork(FRONTEND_FORK_CORE)) @@ -818,8 +818,8 @@ static int generic_action_ok(const char *path, case ACTION_OK_APPEND_DISK_IMAGE: flush_char = NULL; flush_type = 49; - event_cmd_ctl(EVENT_CMD_DISK_APPEND_IMAGE, action_path); - event_cmd_ctl(EVENT_CMD_RESUME, NULL); + command_event(EVENT_CMD_DISK_APPEND_IMAGE, action_path); + command_event(EVENT_CMD_RESUME, NULL); break; case ACTION_OK_SET_PATH: flush_char = NULL; @@ -1236,7 +1236,7 @@ static int action_ok_file_load(const char *path, static int generic_action_ok_command(enum event_command cmd) { - if (!event_cmd_ctl(cmd, NULL)) + if (!command_event(cmd, NULL)) return menu_cbs_exit(); return 0; } @@ -1269,10 +1269,10 @@ static void cb_decompressed(void *task_data, void *user_data, const char *err) switch (type_hash) { case CB_CORE_UPDATER_DOWNLOAD: - event_cmd_ctl(EVENT_CMD_CORE_INFO_INIT, NULL); + command_event(EVENT_CMD_CORE_INFO_INIT, NULL); break; case CB_UPDATE_ASSETS: - event_cmd_ctl(EVENT_CMD_REINIT, NULL); + command_event(EVENT_CMD_REINIT, NULL); break; } } @@ -1414,7 +1414,7 @@ static void cb_generic_download(void *task_data, switch (transf->type_hash) { case CB_CORE_UPDATER_DOWNLOAD: - event_cmd_ctl(EVENT_CMD_CORE_INFO_INIT, NULL); + command_event(EVENT_CMD_CORE_INFO_INIT, NULL); break; } #endif @@ -1708,7 +1708,7 @@ static int generic_action_ok_network(const char *path, if (string_is_empty(settings->network.buildbot_url)) return menu_cbs_exit(); - event_cmd_ctl(EVENT_CMD_NETWORK_INIT, NULL); + command_event(EVENT_CMD_NETWORK_INIT, NULL); switch (type_id) { @@ -2109,7 +2109,7 @@ static int action_ok_load_archive(const char *path, fill_pathname_join(detect_content_path, menu_path, content_path, sizeof(detect_content_path)); - event_cmd_ctl(EVENT_CMD_LOAD_CORE, NULL); + command_event(EVENT_CMD_LOAD_CORE, NULL); rarch_task_push_content_load_default( NULL, detect_content_path, false, CORE_TYPE_PLAIN, NULL, NULL); @@ -2153,7 +2153,7 @@ static int action_ok_load_archive_detect_core(const char *path, switch (ret) { case -1: - event_cmd_ctl(EVENT_CMD_LOAD_CORE, NULL); + command_event(EVENT_CMD_LOAD_CORE, NULL); rarch_task_push_content_load_default(NULL, NULL, false, CORE_TYPE_PLAIN, NULL, NULL); return 0; @@ -2228,7 +2228,7 @@ static int action_ok_video_resolution(const char *path, { char msg[PATH_MAX_LENGTH] = {0}; #ifdef __CELLOS_LV2__ - event_cmd_ctl(EVENT_CMD_REINIT, NULL); + command_event(EVENT_CMD_REINIT, NULL); #endif video_driver_set_video_mode(width, height, true); #ifdef GEKKO diff --git a/menu/cbs/menu_cbs_right.c b/menu/cbs/menu_cbs_right.c index f57a1be697..f760cdc3d1 100644 --- a/menu/cbs/menu_cbs_right.c +++ b/menu/cbs/menu_cbs_right.c @@ -391,7 +391,7 @@ int core_setting_right(unsigned type, const char *label, static int disk_options_disk_idx_right(unsigned type, const char *label, bool wraparound) { - event_cmd_ctl(EVENT_CMD_DISK_NEXT, NULL); + command_event(EVENT_CMD_DISK_NEXT, NULL); return 0; } diff --git a/menu/cbs/menu_cbs_start.c b/menu/cbs/menu_cbs_start.c index f6b467546a..e8f2b6ff59 100644 --- a/menu/cbs/menu_cbs_start.c +++ b/menu/cbs/menu_cbs_start.c @@ -62,7 +62,7 @@ static int action_start_video_filter_file_load(unsigned type, const char *label) return -1; settings->path.softfilter_plugin[0] = '\0'; - event_cmd_ctl(EVENT_CMD_REINIT, NULL); + command_event(EVENT_CMD_REINIT, NULL); return 0; } diff --git a/menu/drivers/nuklear.c b/menu/drivers/nuklear.c index 598c5f9cca..88a946f272 100644 --- a/menu/drivers/nuklear.c +++ b/menu/drivers/nuklear.c @@ -389,7 +389,7 @@ static bool nk_menu_init_list(void *data) menu_entries_add(menu_stack, info.path, info.label, info.type, info.flags, 0); - event_cmd_ctl(EVENT_CMD_HISTORY_INIT, NULL); + command_event(EVENT_CMD_HISTORY_INIT, NULL); info.list = selection_buf; diff --git a/menu/drivers/zarch.c b/menu/drivers/zarch.c index 64b1971d99..64b21b98e7 100644 --- a/menu/drivers/zarch.c +++ b/menu/drivers/zarch.c @@ -1156,7 +1156,7 @@ static bool zarch_menu_init_list(void *data) menu_entries_add(menu_stack, info.path, info.label, info.type, info.flags, 0); - event_cmd_ctl(EVENT_CMD_HISTORY_INIT, NULL); + command_event(EVENT_CMD_HISTORY_INIT, NULL); info.list = selection_buf; diff --git a/menu/menu_content.c b/menu/menu_content.c index c2b2d812aa..37785abe9c 100644 --- a/menu/menu_content.c +++ b/menu/menu_content.c @@ -195,10 +195,10 @@ static bool menu_content_load_from_playlist(void *data) else menu_driver_ctl(RARCH_MENU_CTL_SET_LOAD_NO_CONTENT, NULL); - if (!event_cmd_ctl(EVENT_CMD_EXEC, (void*)path)) + if (!command_event(EVENT_CMD_EXEC, (void*)path)) return false; - event_cmd_ctl(EVENT_CMD_LOAD_CORE, NULL); + command_event(EVENT_CMD_LOAD_CORE, NULL); return true; diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 7383c4ecdd..5853b338c1 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -3775,7 +3775,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) content_playlist_t *playlist = g_defaults.history; if (!playlist) - event_cmd_ctl(EVENT_CMD_HISTORY_INIT, NULL); + command_event(EVENT_CMD_HISTORY_INIT, NULL); strlcpy(path_playlist, "history", sizeof(path_playlist)); diff --git a/menu/menu_driver.c b/menu/menu_driver.c index bd58fc6234..3d3d89c9e0 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -115,7 +115,7 @@ static void bundle_decompressed(void *task_data, decompress_task_data_t *dec = (decompress_task_data_t*)task_data; if (dec && !err) - event_cmd_ctl(EVENT_CMD_REINIT, NULL); + command_event(EVENT_CMD_REINIT, NULL); if (err) RARCH_ERR("%s", err); @@ -159,7 +159,7 @@ static bool menu_init(menu_handle_t *menu_data) menu_data->push_help_screen = true; menu_data->help_screen_type = MENU_HELP_WELCOME; settings->menu_show_start_screen = false; - event_cmd_ctl(EVENT_CMD_MENU_SAVE_CURRENT_CONFIG, NULL); + command_event(EVENT_CMD_MENU_SAVE_CURRENT_CONFIG, NULL); } if ( settings->bundle_assets_extract_enable @@ -245,12 +245,12 @@ static void menu_driver_toggle(bool latch) menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh); /* Menu should always run with vsync on. */ - event_cmd_ctl(EVENT_CMD_VIDEO_SET_BLOCKING_STATE, NULL); + command_event(EVENT_CMD_VIDEO_SET_BLOCKING_STATE, NULL); /* Stop all rumbling before entering the menu. */ - event_cmd_ctl(EVENT_CMD_RUMBLE_STOP, NULL); + command_event(EVENT_CMD_RUMBLE_STOP, NULL); if (settings->menu.pause_libretro) - event_cmd_ctl(EVENT_CMD_AUDIO_STOP, NULL); + command_event(EVENT_CMD_AUDIO_STOP, NULL); /* Override keyboard callback to redirect to menu instead. * We'll use this later for something ... */ @@ -269,7 +269,7 @@ static void menu_driver_toggle(bool latch) driver_ctl(RARCH_DRIVER_CTL_SET_NONBLOCK_STATE, NULL); if (settings && settings->menu.pause_libretro) - event_cmd_ctl(EVENT_CMD_AUDIO_START, NULL); + command_event(EVENT_CMD_AUDIO_START, NULL); /* Prevent stray input from going to libretro core */ input_driver_set_flushing_input(); @@ -565,7 +565,7 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data) menu_display_deinit(); menu_entries_ctl(MENU_ENTRIES_CTL_DEINIT, NULL); - event_cmd_ctl(EVENT_CMD_HISTORY_DEINIT, NULL); + command_event(EVENT_CMD_HISTORY_DEINIT, NULL); core_info_deinit_list(); core_info_free_current_core(); @@ -860,7 +860,7 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data) if (menu_driver_ctl(RARCH_MENU_CTL_IS_PENDING_SHUTDOWN, NULL)) { menu_driver_ctl(RARCH_MENU_CTL_UNSET_PENDING_SHUTDOWN, NULL); - if (!event_cmd_ctl(EVENT_CMD_QUIT, NULL)) + if (!command_event(EVENT_CMD_QUIT, NULL)) return false; return true; } diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 4082d89f68..7b61ef6ce6 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -2690,7 +2690,7 @@ static int setting_action_ok_video_refresh_rate_auto(void *data, bool wraparound float video_refresh_rate_float = (float)video_refresh_rate; driver_ctl(RARCH_DRIVER_CTL_SET_REFRESH_RATE, &video_refresh_rate_float); /* Incase refresh rate update forced non-block video. */ - event_cmd_ctl(EVENT_CMD_VIDEO_SET_BLOCKING_STATE, NULL); + command_event(EVENT_CMD_VIDEO_SET_BLOCKING_STATE, NULL); } if (setting_generic_action_ok_default(setting, wraparound) != 0) @@ -2750,7 +2750,7 @@ static int setting_action_action_ok(void *data, bool wraparound) (void)wraparound; if (setting->cmd_trigger.idx != EVENT_CMD_NONE) - event_cmd_ctl(setting->cmd_trigger.idx, NULL); + command_event(setting->cmd_trigger.idx, NULL); return 0; } @@ -3063,7 +3063,7 @@ void general_write_handler(void *data) } if (rarch_cmd || setting->cmd_trigger.triggered) - event_cmd_ctl(rarch_cmd, NULL); + command_event(rarch_cmd, NULL); } static void setting_add_special_callbacks( @@ -3116,14 +3116,14 @@ static void overlay_enable_toggle_change_handler(void *data) if (settings && settings->input.overlay_hide_in_menu) { - event_cmd_ctl(EVENT_CMD_OVERLAY_DEINIT, NULL); + command_event(EVENT_CMD_OVERLAY_DEINIT, NULL); return; } if (setting->value.target.boolean) - event_cmd_ctl(EVENT_CMD_OVERLAY_INIT, NULL); + command_event(EVENT_CMD_OVERLAY_INIT, NULL); else - event_cmd_ctl(EVENT_CMD_OVERLAY_DEINIT, NULL); + command_event(EVENT_CMD_OVERLAY_DEINIT, NULL); } #endif diff --git a/network/netplay.c b/network/netplay.c index d7e39ef0a9..7b5a848a03 100644 --- a/network/netplay.c +++ b/network/netplay.c @@ -276,11 +276,11 @@ static bool netplay_get_cmd(netplay_t *netplay) return netplay_cmd_nak(netplay); case NETPLAY_CMD_PAUSE: - event_cmd_ctl(EVENT_CMD_PAUSE, NULL); + command_event(EVENT_CMD_PAUSE, NULL); return netplay_cmd_ack(netplay); case NETPLAY_CMD_RESUME: - event_cmd_ctl(EVENT_CMD_UNPAUSE, NULL); + command_event(EVENT_CMD_UNPAUSE, NULL); return netplay_cmd_ack(netplay); default: break; @@ -1163,7 +1163,7 @@ bool netplay_driver_ctl(enum rarch_netplay_ctl_state state, void *data) { bool *state = (bool*)data; if (*state) - event_cmd_ctl(EVENT_CMD_FULLSCREEN_TOGGLE, NULL); + command_event(EVENT_CMD_FULLSCREEN_TOGGLE, NULL); } break; default: diff --git a/record/record_driver.c b/record/record_driver.c index e8ba91c8ce..625bfbdca7 100644 --- a/record/record_driver.c +++ b/record/record_driver.c @@ -198,7 +198,7 @@ void recording_dump_frame(const void *data, unsigned width, { RARCH_WARN("%s \n", msg_hash_to_str(MSG_VIEWPORT_SIZE_CALCULATION_FAILED)); - event_cmd_ctl(EVENT_CMD_GPU_RECORD_DEINIT, NULL); + command_event(EVENT_CMD_GPU_RECORD_DEINIT, NULL); recording_dump_frame(data, width, height, pitch); return; @@ -213,7 +213,7 @@ void recording_dump_frame(const void *data, unsigned width, runloop_msg_queue_push( msg_hash_to_str(MSG_RECORDING_TERMINATED_DUE_TO_RESIZE), 1, 180, true); - event_cmd_ctl(EVENT_CMD_RECORD_DEINIT, NULL); + command_event(EVENT_CMD_RECORD_DEINIT, NULL); return; } @@ -256,7 +256,7 @@ bool recording_deinit(void) recording_data = NULL; recording_driver = NULL; - event_cmd_ctl(EVENT_CMD_GPU_RECORD_DEINIT, NULL); + command_event(EVENT_CMD_GPU_RECORD_DEINIT, NULL); return true; } @@ -425,7 +425,7 @@ bool recording_init(void) if (!record_driver_init_first(&recording_driver, &recording_data, ¶ms)) { RARCH_ERR("%s\n", msg_hash_to_str(MSG_FAILED_TO_START_RECORDING)); - event_cmd_ctl(EVENT_CMD_GPU_RECORD_DEINIT, NULL); + command_event(EVENT_CMD_GPU_RECORD_DEINIT, NULL); return false; } diff --git a/retroarch.c b/retroarch.c index 6e3338d67c..cb2862d1c8 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1069,7 +1069,7 @@ static void retroarch_init_savefile_paths(void) runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); - event_cmd_ctl(EVENT_CMD_SAVEFILES_DEINIT, NULL); + command_event(EVENT_CMD_SAVEFILES_DEINIT, NULL); global->savefiles = string_list_new(); retro_assert(global->savefiles); @@ -1299,25 +1299,25 @@ static int retroarch_main_init(int argc, char *argv[]) } driver_ctl(RARCH_DRIVER_CTL_INIT_PRE, NULL); - if (!event_cmd_ctl(EVENT_CMD_CORE_INIT, ¤t_core_type)) + if (!command_event(EVENT_CMD_CORE_INIT, ¤t_core_type)) goto error; driver_ctl(RARCH_DRIVER_CTL_INIT_ALL, NULL); - event_cmd_ctl(EVENT_CMD_COMMAND_INIT, NULL); - event_cmd_ctl(EVENT_CMD_REMOTE_INIT, NULL); - event_cmd_ctl(EVENT_CMD_REWIND_INIT, NULL); - event_cmd_ctl(EVENT_CMD_CONTROLLERS_INIT, NULL); - event_cmd_ctl(EVENT_CMD_RECORD_INIT, NULL); - event_cmd_ctl(EVENT_CMD_CHEATS_INIT, NULL); - event_cmd_ctl(EVENT_CMD_SAVEFILES_INIT, NULL); - event_cmd_ctl(EVENT_CMD_SET_PER_GAME_RESOLUTION, NULL); + command_event(EVENT_CMD_COMMAND_INIT, NULL); + command_event(EVENT_CMD_REMOTE_INIT, NULL); + command_event(EVENT_CMD_REWIND_INIT, NULL); + command_event(EVENT_CMD_CONTROLLERS_INIT, NULL); + command_event(EVENT_CMD_RECORD_INIT, NULL); + command_event(EVENT_CMD_CHEATS_INIT, NULL); + command_event(EVENT_CMD_SAVEFILES_INIT, NULL); + command_event(EVENT_CMD_SET_PER_GAME_RESOLUTION, NULL); rarch_ctl(RARCH_CTL_UNSET_ERROR_ON_INIT, NULL); rarch_ctl(RARCH_CTL_SET_INITED, NULL); return 0; error: - event_cmd_ctl(EVENT_CMD_CORE_DEINIT, NULL); + command_event(EVENT_CMD_CORE_DEINIT, NULL); rarch_ctl(RARCH_CTL_UNSET_INITED, NULL); return 1; } @@ -1382,7 +1382,7 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data) runloop_ctl(RUNLOOP_CTL_MSG_QUEUE_DEINIT, NULL); driver_ctl(RARCH_DRIVER_CTL_UNINIT_ALL, NULL); - event_cmd_ctl(EVENT_CMD_LOG_FILE_DEINIT, NULL); + command_event(EVENT_CMD_LOG_FILE_DEINIT, NULL); runloop_ctl(RUNLOOP_CTL_STATE_FREE, NULL); runloop_ctl(RUNLOOP_CTL_GLOBAL_FREE, NULL); @@ -1399,33 +1399,33 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data) if (!config_realloc()) return false; - event_cmd_ctl(EVENT_CMD_HISTORY_DEINIT, NULL); + command_event(EVENT_CMD_HISTORY_DEINIT, NULL); runloop_ctl(RUNLOOP_CTL_CLEAR_STATE, NULL); break; case RARCH_CTL_MAIN_DEINIT: if (!rarch_ctl(RARCH_CTL_IS_INITED, NULL)) return false; - event_cmd_ctl(EVENT_CMD_NETPLAY_DEINIT, NULL); - event_cmd_ctl(EVENT_CMD_COMMAND_DEINIT, NULL); - event_cmd_ctl(EVENT_CMD_REMOTE_DEINIT, NULL); + command_event(EVENT_CMD_NETPLAY_DEINIT, NULL); + command_event(EVENT_CMD_COMMAND_DEINIT, NULL); + command_event(EVENT_CMD_REMOTE_DEINIT, NULL); - event_cmd_ctl(EVENT_CMD_AUTOSAVE_DEINIT, NULL); + command_event(EVENT_CMD_AUTOSAVE_DEINIT, NULL); - event_cmd_ctl(EVENT_CMD_RECORD_DEINIT, NULL); - event_cmd_ctl(EVENT_CMD_SAVEFILES, NULL); + command_event(EVENT_CMD_RECORD_DEINIT, NULL); + command_event(EVENT_CMD_SAVEFILES, NULL); - event_cmd_ctl(EVENT_CMD_REWIND_DEINIT, NULL); - event_cmd_ctl(EVENT_CMD_CHEATS_DEINIT, NULL); - event_cmd_ctl(EVENT_CMD_BSV_MOVIE_DEINIT, NULL); + command_event(EVENT_CMD_REWIND_DEINIT, NULL); + command_event(EVENT_CMD_CHEATS_DEINIT, NULL); + command_event(EVENT_CMD_BSV_MOVIE_DEINIT, NULL); - event_cmd_ctl(EVENT_CMD_AUTOSAVE_STATE, NULL); + command_event(EVENT_CMD_AUTOSAVE_STATE, NULL); - event_cmd_ctl(EVENT_CMD_CORE_DEINIT, NULL); + command_event(EVENT_CMD_CORE_DEINIT, NULL); - event_cmd_ctl(EVENT_CMD_TEMPORARY_CONTENT_DEINIT, NULL); - event_cmd_ctl(EVENT_CMD_SUBSYSTEM_FULLPATHS_DEINIT, NULL); - event_cmd_ctl(EVENT_CMD_SAVEFILES_DEINIT, NULL); + command_event(EVENT_CMD_TEMPORARY_CONTENT_DEINIT, NULL); + command_event(EVENT_CMD_SUBSYSTEM_FULLPATHS_DEINIT, NULL); + command_event(EVENT_CMD_SAVEFILES_DEINIT, NULL); rarch_ctl(RARCH_CTL_UNSET_INITED, NULL); break; @@ -1511,7 +1511,7 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data) #endif #ifdef HAVE_OVERLAY if (settings->input.overlay_hide_in_menu) - event_cmd_ctl(EVENT_CMD_OVERLAY_DEINIT, NULL); + command_event(EVENT_CMD_OVERLAY_DEINIT, NULL); #endif break; case RARCH_CTL_LOAD_CONTENT: @@ -1533,7 +1533,7 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data) video_driver_set_texture_enable(false, false); #ifdef HAVE_OVERLAY if (settings && settings->input.overlay_hide_in_menu) - event_cmd_ctl(EVENT_CMD_OVERLAY_INIT, NULL); + command_event(EVENT_CMD_OVERLAY_INIT, NULL); #endif break; case RARCH_CTL_QUIT: diff --git a/runloop.c b/runloop.c index 214f8c053e..0653374ba0 100644 --- a/runloop.c +++ b/runloop.c @@ -186,7 +186,7 @@ static bool runloop_check_movie_playback(void) msg_hash_to_str(MSG_MOVIE_PLAYBACK_ENDED), 1, 180, false); RARCH_LOG("%s\n", msg_hash_to_str(MSG_MOVIE_PLAYBACK_ENDED)); - event_cmd_ctl(EVENT_CMD_BSV_MOVIE_DEINIT, NULL); + command_event(EVENT_CMD_BSV_MOVIE_DEINIT, NULL); bsv_movie_ctl(BSV_MOVIE_CTL_UNSET_END, NULL); bsv_movie_ctl(BSV_MOVIE_CTL_UNSET_PLAYBACK, NULL); @@ -204,7 +204,7 @@ static bool runloop_check_movie_record(void) msg_hash_to_str(MSG_MOVIE_RECORD_STOPPED), 2, 180, true); RARCH_LOG("%s\n", msg_hash_to_str(MSG_MOVIE_RECORD_STOPPED)); - event_cmd_ctl(EVENT_CMD_BSV_MOVIE_DEINIT, NULL); + command_event(EVENT_CMD_BSV_MOVIE_DEINIT, NULL); return true; } @@ -295,7 +295,7 @@ static bool check_pause(settings_t *settings, old_focus = focus; if (cmd != EVENT_CMD_NONE) - event_cmd_ctl(cmd, NULL); + command_event(cmd, NULL); if (runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL) == old_is_paused) return false; @@ -394,7 +394,7 @@ static bool shader_dir_init(rarch_dir_list_t *dir_list) if (!dir_list->list || dir_list->list->size == 0) { - event_cmd_ctl(EVENT_CMD_SHADER_DIR_DEINIT, NULL); + command_event(EVENT_CMD_SHADER_DIR_DEINIT, NULL); return false; } @@ -517,10 +517,10 @@ static bool runloop_check_state(event_cmd_state_t *cmd, rarch_dir_list_t *shader return false; if (runloop_cmd_triggered(cmd, RARCH_SCREENSHOT)) - event_cmd_ctl(EVENT_CMD_TAKE_SCREENSHOT, NULL); + command_event(EVENT_CMD_TAKE_SCREENSHOT, NULL); if (runloop_cmd_triggered(cmd, RARCH_MUTE)) - event_cmd_ctl(EVENT_CMD_AUDIO_MUTE_TOGGLE, NULL); + command_event(EVENT_CMD_AUDIO_MUTE_TOGGLE, NULL); if (runloop_cmd_triggered(cmd, RARCH_OSK)) { @@ -534,9 +534,9 @@ static bool runloop_check_state(event_cmd_state_t *cmd, rarch_dir_list_t *shader } if (runloop_cmd_press(cmd, RARCH_VOLUME_UP)) - event_cmd_ctl(EVENT_CMD_VOLUME_UP, NULL); + command_event(EVENT_CMD_VOLUME_UP, NULL); else if (runloop_cmd_press(cmd, RARCH_VOLUME_DOWN)) - event_cmd_ctl(EVENT_CMD_VOLUME_DOWN, NULL); + command_event(EVENT_CMD_VOLUME_DOWN, NULL); #ifdef HAVE_NETPLAY tmp = runloop_cmd_triggered(cmd, RARCH_NETPLAY_FLIP); @@ -557,9 +557,9 @@ static bool runloop_check_state(event_cmd_state_t *cmd, rarch_dir_list_t *shader ); if (runloop_cmd_triggered(cmd, RARCH_SAVE_STATE_KEY)) - event_cmd_ctl(EVENT_CMD_SAVE_STATE, NULL); + command_event(EVENT_CMD_SAVE_STATE, NULL); else if (runloop_cmd_triggered(cmd, RARCH_LOAD_STATE_KEY)) - event_cmd_ctl(EVENT_CMD_LOAD_STATE, NULL); + command_event(EVENT_CMD_LOAD_STATE, NULL); #ifdef HAVE_CHEEVOS if(!settings->cheevos.hardcore_mode_enable) @@ -578,14 +578,14 @@ static bool runloop_check_state(event_cmd_state_t *cmd, rarch_dir_list_t *shader runloop_cmd_triggered(cmd, RARCH_SHADER_PREV)); if (runloop_cmd_triggered(cmd, RARCH_DISK_EJECT_TOGGLE)) - event_cmd_ctl(EVENT_CMD_DISK_EJECT_TOGGLE, NULL); + command_event(EVENT_CMD_DISK_EJECT_TOGGLE, NULL); else if (runloop_cmd_triggered(cmd, RARCH_DISK_NEXT)) - event_cmd_ctl(EVENT_CMD_DISK_NEXT, NULL); + command_event(EVENT_CMD_DISK_NEXT, NULL); else if (runloop_cmd_triggered(cmd, RARCH_DISK_PREV)) - event_cmd_ctl(EVENT_CMD_DISK_PREV, NULL); + command_event(EVENT_CMD_DISK_PREV, NULL); if (runloop_cmd_triggered(cmd, RARCH_RESET)) - event_cmd_ctl(EVENT_CMD_RESET, NULL); + command_event(EVENT_CMD_RESET, NULL); cheat_manager_state_checks( runloop_cmd_triggered(cmd, RARCH_CHEAT_INDEX_PLUS), @@ -611,7 +611,7 @@ static bool runloop_check_pause_state(event_cmd_state_t *cmd) if (runloop_cmd_triggered(cmd, RARCH_FULLSCREEN_TOGGLE_KEY)) { - event_cmd_ctl(EVENT_CMD_FULLSCREEN_TOGGLE, NULL); + command_event(EVENT_CMD_FULLSCREEN_TOGGLE, NULL); video_driver_cached_frame_render(); } @@ -909,10 +909,10 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) case RUNLOOP_CTL_GLOBAL_FREE: { global_t *global = NULL; - event_cmd_ctl(EVENT_CMD_TEMPORARY_CONTENT_DEINIT, NULL); - event_cmd_ctl(EVENT_CMD_SUBSYSTEM_FULLPATHS_DEINIT, NULL); - event_cmd_ctl(EVENT_CMD_RECORD_DEINIT, NULL); - event_cmd_ctl(EVENT_CMD_LOG_FILE_DEINIT, NULL); + command_event(EVENT_CMD_TEMPORARY_CONTENT_DEINIT, NULL); + command_event(EVENT_CMD_SUBSYSTEM_FULLPATHS_DEINIT, NULL); + command_event(EVENT_CMD_RECORD_DEINIT, NULL); + command_event(EVENT_CMD_LOG_FILE_DEINIT, NULL); rarch_ctl(RARCH_CTL_UNSET_BLOCK_CONFIG_READ, NULL); runloop_ctl(RUNLOOP_CTL_CLEAR_CONTENT_PATH, NULL); @@ -1212,19 +1212,19 @@ static void runloop_iterate_linefeed_overlay(settings_t *settings) { input_driver_unset_onscreen_keyboard_enabled(); prev_overlay_restore = true; - event_cmd_ctl(EVENT_CMD_OVERLAY_DEINIT, NULL); + command_event(EVENT_CMD_OVERLAY_DEINIT, NULL); } else if (!osk_enable && input_keyboard_ctl( RARCH_INPUT_KEYBOARD_CTL_IS_LINEFEED_ENABLED, NULL)) { input_driver_set_onscreen_keyboard_enabled(); prev_overlay_restore = false; - event_cmd_ctl(EVENT_CMD_OVERLAY_INIT, NULL); + command_event(EVENT_CMD_OVERLAY_INIT, NULL); } else if (prev_overlay_restore) { if (!settings->input.overlay_hide_in_menu) - event_cmd_ctl(EVENT_CMD_OVERLAY_INIT, NULL); + command_event(EVENT_CMD_OVERLAY_INIT, NULL); prev_overlay_restore = false; } } @@ -1366,7 +1366,7 @@ int runloop_iterate(unsigned *sleep_ms) cmd.state[2] = cmd.state[0] & ~cmd.state[1]; /* trigger */ if (runloop_cmd_triggered(cmd_ptr, RARCH_OVERLAY_NEXT)) - event_cmd_ctl(EVENT_CMD_OVERLAY_NEXT, NULL); + command_event(EVENT_CMD_OVERLAY_NEXT, NULL); if (runloop_cmd_triggered(cmd_ptr, RARCH_FULLSCREEN_TOGGLE_KEY)) { @@ -1377,11 +1377,11 @@ int runloop_iterate(unsigned *sleep_ms) #endif if (fullscreen_toggled) - event_cmd_ctl(EVENT_CMD_FULLSCREEN_TOGGLE, NULL); + command_event(EVENT_CMD_FULLSCREEN_TOGGLE, NULL); } if (runloop_cmd_triggered(cmd_ptr, RARCH_GRAB_MOUSE_TOGGLE)) - event_cmd_ctl(EVENT_CMD_GRAB_MOUSE_TOGGLE, NULL); + command_event(EVENT_CMD_GRAB_MOUSE_TOGGLE, NULL); #ifdef HAVE_MENU if (runloop_cmd_menu_press(cmd_ptr) || diff --git a/tasks/task_content.c b/tasks/task_content.c index 5169bb4f2e..c374098572 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -35,7 +35,7 @@ bool rarch_task_push_content_load_default( if (core_path) { runloop_ctl(RUNLOOP_CTL_SET_LIBRETRO_PATH, (void*)core_path); - event_cmd_ctl(EVENT_CMD_LOAD_CORE, NULL); + command_event(EVENT_CMD_LOAD_CORE, NULL); } if (fullpath) @@ -60,7 +60,7 @@ bool rarch_task_push_content_load_default( } if (cmd != EVENT_CMD_NONE) - event_cmd_ctl(cmd, NULL); + command_event(cmd, NULL); #ifdef HAVE_MENU menu_driver_ctl(RARCH_MENU_CTL_SET_PENDING_QUIT, NULL); diff --git a/ui/drivers/ui_cocoa.m b/ui/drivers/ui_cocoa.m index bce6069f9f..c6479608d8 100644 --- a/ui/drivers/ui_cocoa.m +++ b/ui/drivers/ui_cocoa.m @@ -568,7 +568,7 @@ static void *ui_companion_cocoa_init(void) static void ui_companion_cocoa_event_command(void *data, enum event_command cmd) { (void)data; - event_cmd_ctl(cmd, NULL); + command_event(cmd, NULL); } static void ui_companion_cocoa_notify_list_pushed(void *data, diff --git a/ui/drivers/ui_cocoatouch.m b/ui/drivers/ui_cocoatouch.m index 51e06cdd5f..59e24c9922 100644 --- a/ui/drivers/ui_cocoatouch.m +++ b/ui/drivers/ui_cocoatouch.m @@ -76,7 +76,7 @@ static void ui_companion_cocoatouch_event_command( void *data, enum event_command cmd) { (void)data; - event_cmd_ctl(cmd, NULL); + command_event(cmd, NULL); } static void rarch_draw_observer(CFRunLoopObserverRef observer, diff --git a/ui/drivers/ui_qt.c b/ui/drivers/ui_qt.c index b10ffa08e0..1ef89dfec0 100644 --- a/ui/drivers/ui_qt.c +++ b/ui/drivers/ui_qt.c @@ -108,7 +108,7 @@ static void ui_companion_qt_event_command(void *data, enum event_command cmd) return; slock_lock(handle->lock); - event_cmd_ctl(cmd, NULL); + command_event(cmd, NULL); slock_unlock(handle->lock); } diff --git a/ui/drivers/ui_win32.c b/ui/drivers/ui_win32.c index c433833b73..8d06d1ec53 100644 --- a/ui/drivers/ui_win32.c +++ b/ui/drivers/ui_win32.c @@ -645,7 +645,7 @@ LRESULT win32_menu_loop(HWND owner, WPARAM wparam) } if (cmd != EVENT_CMD_NONE) - event_cmd_ctl(cmd, NULL); + command_event(cmd, NULL); if (do_wm_close) PostMessage(owner, WM_CLOSE, 0, 0); From 523ebed112898558790f0db672009d41428ddcf2 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 May 2016 20:30:47 +0200 Subject: [PATCH 341/498] Combine command_event.c and command.c --- Makefile.common | 6 +- audio/audio_driver.c | 2 +- command.c | 1709 ++++++++++++++++++++++- command.h | 197 +++ command_event.c | 1716 ------------------------ command_event.h | 225 ---- content.c | 2 +- dynamic.c | 2 +- frontend/drivers/platform_emscripten.c | 2 +- gfx/drivers/ctr_gfx.c | 2 +- gfx/video_driver.c | 2 +- griffin/griffin.c | 6 +- input/drivers_joypad/ctr_joypad.c | 2 +- menu/menu_setting.h | 2 +- network/netplay_private.h | 4 +- record/record_driver.c | 2 +- retroarch.c | 2 +- tasks/task_content.c | 2 +- ui/ui_companion_driver.h | 2 +- 19 files changed, 1917 insertions(+), 1970 deletions(-) delete mode 100644 command_event.c delete mode 100644 command_event.h diff --git a/Makefile.common b/Makefile.common index 7781a4f074..955a636de1 100644 --- a/Makefile.common +++ b/Makefile.common @@ -111,7 +111,7 @@ OBJ += frontend/frontend.o \ core_impl.o \ retroarch.o \ input/input_keyboard.o \ - command_event.o \ + command.o \ msg_hash.o \ intl/msg_hash_de.o \ intl/msg_hash_eo.o \ @@ -509,10 +509,6 @@ ifeq ($(HAVE_THREADS), 1) endif endif -ifeq ($(HAVE_COMMAND), 1) - OBJ += command.o -endif - ifeq ($(HAVE_WAYLAND), 1) OBJ += gfx/drivers_context/wayland_ctx.o DEFINES += $(WAYLAND_CFLAGS) diff --git a/audio/audio_driver.c b/audio/audio_driver.c index 7d74c0b9a5..1ef8145a3c 100644 --- a/audio/audio_driver.c +++ b/audio/audio_driver.c @@ -26,7 +26,7 @@ #include "audio_utils.h" #include "audio_thread_wrapper.h" -#include "../command_event.h" +#include "../command.h" #include "../configuration.h" #include "../retroarch.h" #include "../runloop.h" diff --git a/command.c b/command.c index 633ae5205b..c1e5140e0a 100644 --- a/command.c +++ b/command.c @@ -1,5 +1,4 @@ /* 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 @@ -14,28 +13,76 @@ * If not, see . */ - #include #include +#include -#ifndef _WIN32 +#ifdef _WIN32 +#include +#else #include #endif #include #include #include +#include +#include + +#ifdef HAVE_COMMAND #include #include #include - -#include "msg_hash.h" +#endif #include "command.h" +#include "defaults.h" +#include "frontend/frontend_driver.h" +#include "audio/audio_driver.h" +#include "record/record_driver.h" +#include "autosave.h" +#include "core_info.h" +#include "core_type.h" +#include "performance.h" +#include "dynamic.h" +#include "content.h" +#include "movie.h" #include "general.h" -#include "verbosity.h" +#include "screenshot.h" +#include "msg_hash.h" +#include "retroarch.h" +#include "managers/cheat_manager.h" +#include "managers/state_manager.h" +#include "system.h" +#include "ui/ui_companion_driver.h" +#include "list_special.h" +#ifdef HAVE_CHEEVOS +#include "cheevos.h" +#endif + +#include "core.h" +#include "verbosity.h" +#include "runloop.h" +#include "configuration.h" +#include "input/input_remapping.h" + +#ifdef HAVE_MENU +#include "menu/menu_driver.h" +#include "menu/menu_display.h" +#include "menu/menu_shader.h" +#endif + +#ifdef HAVE_NETPLAY +#include "network/netplay.h" +#endif + +#ifdef HAVE_NETWORKING +#include +#endif + +#ifdef HAVE_COMMAND #define DEFAULT_NETWORK_CMD_PORT 55355 #define STDIN_BUF_SIZE 4096 @@ -652,3 +699,1653 @@ bool command_get(command_handle_t *handle) return handle->id < RARCH_BIND_LIST_END && handle->handle->state[handle->id]; } +#endif + +/** + * event_disk_control_set_eject: + * @new_state : Eject or close the virtual drive tray. + * false (0) : Close + * true (1) : Eject + * @print_log : Show message onscreen. + * + * Ejects/closes of the virtual drive tray. + **/ +static void event_disk_control_set_eject(bool new_state, bool print_log) +{ + char msg[128] = {0}; + bool error = false; + rarch_system_info_t *info = NULL; + const struct retro_disk_control_callback *control = NULL; + + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); + + if (info) + control = (const struct retro_disk_control_callback*)&info->disk_control_cb; + + if (!control || !control->get_num_images) + return; + + if (control->set_eject_state(new_state)) + snprintf(msg, sizeof(msg), "%s %s", + new_state ? "Ejected" : "Closed", + msg_hash_to_str(MSG_VIRTUAL_DISK_TRAY)); + else + { + error = true; + snprintf(msg, sizeof(msg), "%s %s %s", + msg_hash_to_str(MSG_FAILED_TO), + new_state ? "eject" : "close", + msg_hash_to_str(MSG_VIRTUAL_DISK_TRAY)); + } + + if (*msg) + { + if (error) + RARCH_ERR("%s\n", msg); + else + RARCH_LOG("%s\n", msg); + + /* Only noise in menu. */ + if (print_log) + runloop_msg_queue_push(msg, 1, 180, true); + } +} + +/** + * event_disk_control_set_index: + * @idx : Index of disk to set as current. + * + * Sets current disk to @index. + **/ +static void event_disk_control_set_index(unsigned idx) +{ + unsigned num_disks; + bool error = false; + char msg[128] = {0}; + rarch_system_info_t *info = NULL; + const struct retro_disk_control_callback *control = NULL; + + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); + + if (info) + control = (const struct retro_disk_control_callback*)&info->disk_control_cb; + + if (!control || !control->get_num_images) + return; + + num_disks = control->get_num_images(); + + if (control->set_image_index(idx)) + { + if (idx < num_disks) + snprintf(msg, sizeof(msg), "Setting disk %u of %u in tray.", + idx + 1, num_disks); + else + strlcpy(msg, + msg_hash_to_str(MSG_REMOVED_DISK_FROM_TRAY), + sizeof(msg)); + } + else + { + if (idx < num_disks) + snprintf(msg, sizeof(msg), "Failed to set disk %u of %u.", + idx + 1, num_disks); + else + strlcpy(msg, + msg_hash_to_str(MSG_FAILED_TO_REMOVE_DISK_FROM_TRAY), + sizeof(msg)); + error = true; + } + + if (*msg) + { + if (error) + RARCH_ERR("%s\n", msg); + else + RARCH_LOG("%s\n", msg); + runloop_msg_queue_push(msg, 1, 180, true); + } +} + +/** + * event_disk_control_append_image: + * @path : Path to disk image. + * + * Appends disk image to disk image list. + **/ +static bool event_disk_control_append_image(const char *path) +{ + unsigned new_idx; + char msg[128] = {0}; + struct retro_game_info info = {0}; + global_t *global = global_get_ptr(); + const struct retro_disk_control_callback *control = NULL; + rarch_system_info_t *sysinfo = NULL; + + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &sysinfo); + + if (sysinfo) + control = (const struct retro_disk_control_callback*) + &sysinfo->disk_control_cb; + + if (!control) + return false; + + event_disk_control_set_eject(true, false); + + control->add_image_index(); + new_idx = control->get_num_images(); + if (!new_idx) + return false; + new_idx--; + + info.path = path; + control->replace_image_index(new_idx, &info); + + snprintf(msg, sizeof(msg), "%s: ", msg_hash_to_str(MSG_APPENDED_DISK)); + strlcat(msg, path, sizeof(msg)); + RARCH_LOG("%s\n", msg); + runloop_msg_queue_push(msg, 0, 180, true); + + command_event(EVENT_CMD_AUTOSAVE_DEINIT, NULL); + + /* TODO: Need to figure out what to do with subsystems case. */ + if (!*global->subsystem) + { + /* Update paths for our new image. + * If we actually use append_image, we assume that we + * started out in a single disk case, and that this way + * of doing it makes the most sense. */ + rarch_ctl(RARCH_CTL_SET_PATHS, (void*)path); + rarch_ctl(RARCH_CTL_FILL_PATHNAMES, NULL); + } + + command_event(EVENT_CMD_AUTOSAVE_INIT, NULL); + event_disk_control_set_index(new_idx); + event_disk_control_set_eject(false, false); + + return true; +} + +/** + * event_check_disk_prev: + * @control : Handle to disk control handle. + * + * Perform disk cycle to previous index action (Core Disk Options). + **/ +static void event_check_disk_prev( + const struct retro_disk_control_callback *control) +{ + unsigned num_disks = 0; + unsigned current = 0; + bool disk_prev_enable = false; + + if (!control || !control->get_num_images) + return; + if (!control->get_image_index) + return; + + num_disks = control->get_num_images(); + current = control->get_image_index(); + disk_prev_enable = num_disks && num_disks != UINT_MAX; + + if (!disk_prev_enable) + { + RARCH_ERR("%s.\n", msg_hash_to_str(MSG_GOT_INVALID_DISK_INDEX)); + return; + } + + if (current > 0) + current--; + event_disk_control_set_index(current); +} + +/** + * event_check_disk_next: + * @control : Handle to disk control handle. + * + * Perform disk cycle to next index action (Core Disk Options). + **/ +static void event_check_disk_next( + const struct retro_disk_control_callback *control) +{ + unsigned num_disks = 0; + unsigned current = 0; + bool disk_next_enable = false; + + if (!control || !control->get_num_images) + return; + if (!control->get_image_index) + return; + + num_disks = control->get_num_images(); + current = control->get_image_index(); + disk_next_enable = num_disks && num_disks != UINT_MAX; + + if (!disk_next_enable) + { + RARCH_ERR("%s.\n", msg_hash_to_str(MSG_GOT_INVALID_DISK_INDEX)); + return; + } + + if (current < num_disks - 1) + current++; + event_disk_control_set_index(current); +} + +/** + * event_set_volume: + * @gain : amount of gain to be applied to current volume level. + * + * Adjusts the current audio volume level. + * + **/ +static void event_set_volume(float gain) +{ + char msg[128]; + settings_t *settings = config_get_ptr(); + + settings->audio.volume += gain; + settings->audio.volume = MAX(settings->audio.volume, -80.0f); + settings->audio.volume = MIN(settings->audio.volume, 12.0f); + + snprintf(msg, sizeof(msg), "Volume: %.1f dB", settings->audio.volume); + runloop_msg_queue_push(msg, 1, 180, true); + RARCH_LOG("%s\n", msg); + + audio_driver_set_volume_gain(db_to_gain(settings->audio.volume)); +} + +/** + * event_init_controllers: + * + * Initialize libretro controllers. + **/ +static void event_init_controllers(void) +{ + unsigned i; + settings_t *settings = config_get_ptr(); + rarch_system_info_t *info = NULL; + + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); + + for (i = 0; i < MAX_USERS; i++) + { + retro_ctx_controller_info_t pad; + const char *ident = NULL; + bool set_controller = false; + const struct retro_controller_description *desc = NULL; + unsigned device = settings->input.libretro_device[i]; + + if (i < info->ports.size) + desc = libretro_find_controller_description( + &info->ports.data[i], device); + + if (desc) + ident = desc->desc; + + if (!ident) + { + /* If we're trying to connect a completely unknown device, + * revert back to JOYPAD. */ + + if (device != RETRO_DEVICE_JOYPAD && device != RETRO_DEVICE_NONE) + { + /* Do not fix settings->input.libretro_device[i], + * because any use of dummy core will reset this, + * which is not a good idea. */ + RARCH_WARN("Input device ID %u is unknown to this " + "libretro implementation. Using RETRO_DEVICE_JOYPAD.\n", + device); + device = RETRO_DEVICE_JOYPAD; + } + ident = "Joypad"; + } + + switch (device) + { + case RETRO_DEVICE_NONE: + RARCH_LOG("Disconnecting device from port %u.\n", i + 1); + set_controller = true; + break; + case RETRO_DEVICE_JOYPAD: + break; + default: + /* Some cores do not properly range check port argument. + * This is broken behavior of course, but avoid breaking + * cores needlessly. */ + RARCH_LOG("Connecting %s (ID: %u) to port %u.\n", ident, + device, i + 1); + set_controller = true; + break; + } + + if (set_controller) + { + pad.device = device; + pad.port = i; + core_set_controller_port_device(&pad); + } + } +} + +static void event_deinit_core(bool reinit) +{ +#ifdef HAVE_CHEEVOS + cheevos_unload(); +#endif + + core_unload_game(); + core_unload(); + + if (reinit) + { + int flags = DRIVERS_CMD_ALL; + driver_ctl(RARCH_DRIVER_CTL_UNINIT, &flags); + } + + /* auto overrides: reload the original config */ + if (runloop_ctl(RUNLOOP_CTL_IS_OVERRIDES_ACTIVE, NULL)) + { + config_unload_override(); + runloop_ctl(RUNLOOP_CTL_UNSET_OVERRIDES_ACTIVE, NULL); + } +} + +static void event_init_cheats(void) +{ + bool allow_cheats = true; +#ifdef HAVE_NETPLAY + allow_cheats &= !netplay_driver_ctl( + RARCH_NETPLAY_CTL_IS_DATA_INITED, NULL); +#endif + allow_cheats &= !bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL); + + if (!allow_cheats) + return; + + /* TODO/FIXME - add some stuff here. */ +} + +static bool event_load_save_files(void) +{ + unsigned i; + global_t *global = global_get_ptr(); + + if (!global) + return false; + if (!global->savefiles || global->sram.load_disable) + return false; + + for (i = 0; i < global->savefiles->size; i++) + { + ram_type_t ram; + ram.path = global->savefiles->elems[i].data; + ram.type = global->savefiles->elems[i].attr.i; + + content_load_ram_file(&ram); + } + + return true; +} + +static void event_load_auto_state(void) +{ + bool ret; + char msg[128] = {0}; + char savestate_name_auto[PATH_MAX_LENGTH] = {0}; + settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); + +#ifdef HAVE_NETPLAY + if (global->netplay.enable && !global->netplay.is_spectate) + return; +#endif + +#ifdef HAVE_CHEEVOS + if (settings->cheevos.hardcore_mode_enable) + return; +#endif + + if (!settings->savestate_auto_load) + return; + + fill_pathname_noext(savestate_name_auto, global->name.savestate, + ".auto", sizeof(savestate_name_auto)); + + if (!path_file_exists(savestate_name_auto)) + return; + + ret = content_load_state(savestate_name_auto); + + RARCH_LOG("Found auto savestate in: %s\n", savestate_name_auto); + + snprintf(msg, sizeof(msg), "Auto-loading savestate from \"%s\" %s.", + savestate_name_auto, ret ? "succeeded" : "failed"); + runloop_msg_queue_push(msg, 1, 180, false); + RARCH_LOG("%s\n", msg); +} + +static void event_set_savestate_auto_index(void) +{ + size_t i; + char state_dir[PATH_MAX_LENGTH] = {0}; + char state_base[PATH_MAX_LENGTH] = {0}; + struct string_list *dir_list = NULL; + unsigned max_idx = 0; + settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); + + if (!settings->savestate_auto_index) + return; + + /* Find the file in the same directory as global->savestate_name + * with the largest numeral suffix. + * + * E.g. /foo/path/content.state, will try to find + * /foo/path/content.state%d, where %d is the largest number available. + */ + + fill_pathname_basedir(state_dir, global->name.savestate, + sizeof(state_dir)); + fill_pathname_base(state_base, global->name.savestate, + sizeof(state_base)); + + if (!(dir_list = dir_list_new_special(state_dir, DIR_LIST_PLAIN, NULL))) + return; + + for (i = 0; i < dir_list->size; i++) + { + unsigned idx; + char elem_base[128] = {0}; + const char *end = NULL; + const char *dir_elem = dir_list->elems[i].data; + + fill_pathname_base(elem_base, dir_elem, sizeof(elem_base)); + + if (strstr(elem_base, state_base) != elem_base) + continue; + + end = dir_elem + strlen(dir_elem); + while ((end > dir_elem) && isdigit((int)end[-1])) + end--; + + idx = strtoul(end, NULL, 0); + if (idx > max_idx) + max_idx = idx; + } + + dir_list_free(dir_list); + + settings->state_slot = max_idx; + RARCH_LOG("Found last state slot: #%d\n", settings->state_slot); +} + +static bool event_init_content(void) +{ + rarch_ctl(RARCH_CTL_SET_SRAM_ENABLE, NULL); + + /* No content to be loaded for dummy core, + * just successfully exit. */ + if (rarch_ctl(RARCH_CTL_IS_DUMMY_CORE, NULL)) + return true; + + if (!content_does_not_need_content()) + rarch_ctl(RARCH_CTL_FILL_PATHNAMES, NULL); + + if (!content_init()) + return false; + + if (content_does_not_need_content()) + return true; + + event_set_savestate_auto_index(); + + if (event_load_save_files()) + RARCH_LOG("%s.\n", + msg_hash_to_str(MSG_SKIPPING_SRAM_LOAD)); + + event_load_auto_state(); + command_event(EVENT_CMD_BSV_MOVIE_INIT, NULL); + command_event(EVENT_CMD_NETPLAY_INIT, NULL); + + return true; +} + +static bool event_init_core(enum rarch_core_type *data) +{ + retro_ctx_environ_info_t info; + settings_t *settings = config_get_ptr(); + + if (!core_init_symbols(data)) + return false; + + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_INIT, NULL); + + /* auto overrides: apply overrides */ + if(settings->auto_overrides_enable) + { + if (config_load_override()) + runloop_ctl(RUNLOOP_CTL_SET_OVERRIDES_ACTIVE, NULL); + else + runloop_ctl(RUNLOOP_CTL_UNSET_OVERRIDES_ACTIVE, NULL); + } + + /* reset video format to libretro's default */ + video_driver_set_pixel_format(RETRO_PIXEL_FORMAT_0RGB1555); + + info.env = rarch_environment_cb; + core_set_environment(&info); + + /* Auto-remap: apply remap files */ + if(settings->auto_remaps_enable) + config_load_remap(); + + /* Per-core saves: reset redirection paths */ + rarch_ctl(RARCH_CTL_SET_PATHS_REDIRECT, NULL); + + if (!core_init()) + return false; + + if (!event_init_content()) + return false; + + if (!core_load()) + return false; + + return true; +} + +static bool event_save_auto_state(void) +{ + bool ret; + char savestate_name_auto[PATH_MAX_LENGTH] = {0}; + settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); + + if (!settings->savestate_auto_save) + return false; + if (rarch_ctl(RARCH_CTL_IS_DUMMY_CORE, NULL)) + return false; + if (content_does_not_need_content()) + return false; + +#ifdef HAVE_CHEEVOS + if (settings->cheevos.hardcore_mode_enable) + return false; +#endif + + fill_pathname_noext(savestate_name_auto, global->name.savestate, + ".auto", sizeof(savestate_name_auto)); + + ret = content_save_state((const char*)savestate_name_auto); + RARCH_LOG("Auto save state to \"%s\" %s.\n", savestate_name_auto, ret ? + "succeeded" : "failed"); + + return true; +} + +/** + * event_save_core_config: + * + * Saves a new (core) configuration to a file. Filename is based + * on heuristics to avoid typing. + * + * Returns: true (1) on success, otherwise false (0). + **/ +static bool event_save_core_config(void) +{ + char config_dir[PATH_MAX_LENGTH] = {0}; + char config_name[PATH_MAX_LENGTH] = {0}; + char config_path[PATH_MAX_LENGTH] = {0}; + char msg[128] = {0}; + bool ret = false; + bool found_path = false; + bool overrides_active = false; + settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); + + *config_dir = '\0'; + if (!string_is_empty(settings->directory.menu_config)) + strlcpy(config_dir, settings->directory.menu_config, + sizeof(config_dir)); + else if (!string_is_empty(global->path.config)) /* Fallback */ + fill_pathname_basedir(config_dir, global->path.config, + sizeof(config_dir)); + else + { + runloop_msg_queue_push(msg_hash_to_str(MSG_CONFIG_DIRECTORY_NOT_SET), 1, 180, true); + RARCH_ERR("%s\n", msg_hash_to_str(MSG_CONFIG_DIRECTORY_NOT_SET)); + return false; + } + + /* Infer file name based on libretro core. */ + if (!string_is_empty(settings->path.libretro) + && path_file_exists(settings->path.libretro)) + { + unsigned i; + RARCH_LOG("Using core name for new config\n"); + /* In case of collision, find an alternative name. */ + for (i = 0; i < 16; i++) + { + char tmp[64]; + + fill_pathname_base( + config_name, + settings->path.libretro, + sizeof(config_name)); + + path_remove_extension(config_name); + fill_pathname_join(config_path, config_dir, config_name, + sizeof(config_path)); + if (i) + snprintf(tmp, sizeof(tmp), "-%u.cfg", i); + else + strlcpy(tmp, ".cfg", sizeof(tmp)); + + strlcat(config_path, tmp, sizeof(config_path)); + if (!path_file_exists(config_path)) + { + found_path = true; + break; + } + } + } + + /* Fallback to system time... */ + if (!found_path) + { + RARCH_WARN("Cannot infer new config path. Use current time.\n"); + fill_dated_filename(config_name, "cfg", sizeof(config_name)); + fill_pathname_join(config_path, config_dir, config_name, + sizeof(config_path)); + } + + /* Overrides block config file saving, make it appear as overrides + * weren't enabled for a manual save */ + if (runloop_ctl(RUNLOOP_CTL_IS_OVERRIDES_ACTIVE, NULL)) + { + runloop_ctl(RUNLOOP_CTL_UNSET_OVERRIDES_ACTIVE, NULL); + overrides_active = true; + } + + if ((ret = config_save_file(config_path))) + { + strlcpy(global->path.config, config_path, + sizeof(global->path.config)); + snprintf(msg, sizeof(msg), "Saved new config to \"%s\".", + config_path); + RARCH_LOG("%s\n", msg); + } + else + { + snprintf(msg, sizeof(msg), "Failed saving config to \"%s\".", + config_path); + RARCH_ERR("%s\n", msg); + } + + runloop_msg_queue_push(msg, 1, 180, true); + + if (overrides_active) + runloop_ctl(RUNLOOP_CTL_SET_OVERRIDES_ACTIVE, NULL); + else + runloop_ctl(RUNLOOP_CTL_UNSET_OVERRIDES_ACTIVE, NULL); + return ret; +} + +/** + * event_save_current_config: + * + * Saves current configuration file to disk, and (optionally) + * autosave state. + **/ +void event_save_current_config(void) +{ + char msg[128]; + settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); + bool ret = false; + + if (settings->config_save_on_exit && !string_is_empty(global->path.config)) + { + /* Save last core-specific config to the default config location, + * needed on consoles for core switching and reusing last good + * config for new cores. + */ + + /* Flush out the core specific config. */ + if (*global->path.core_specific_config && + settings->core_specific_config) + ret = config_save_file(global->path.core_specific_config); + else + ret = config_save_file(global->path.config); + if (ret) + { + snprintf(msg, sizeof(msg), "Saved new config to \"%s\".", + global->path.config); + RARCH_LOG("%s\n", msg); + } + else + { + snprintf(msg, sizeof(msg), "Failed saving config to \"%s\".", + global->path.config); + RARCH_ERR("%s\n", msg); + } + + runloop_msg_queue_push(msg, 1, 180, true); + } +} + +/** + * event_save_state + * @path : Path to state. + * @s : Message. + * @len : Size of @s. + * + * Saves a state with path being @path. + **/ +static void event_save_state(const char *path, + char *s, size_t len) +{ + settings_t *settings = config_get_ptr(); + + if (!content_save_state(path)) + { + snprintf(s, len, "%s \"%s\".", + msg_hash_to_str(MSG_FAILED_TO_SAVE_STATE_TO), + path); + return; + } + + if (settings->state_slot < 0) + snprintf(s, len, "%s #-1 (auto).", + msg_hash_to_str(MSG_SAVED_STATE_TO_SLOT)); + else + snprintf(s, len, "%s #%d.", msg_hash_to_str(MSG_SAVED_STATE_TO_SLOT), + settings->state_slot); +} + +/** + * event_load_state + * @path : Path to state. + * @s : Message. + * @len : Size of @s. + * + * Loads a state with path being @path. + **/ +static void event_load_state(const char *path, char *s, size_t len) +{ + settings_t *settings = config_get_ptr(); + + if (!content_load_state(path)) + { + snprintf(s, len, "%s \"%s\".", + msg_hash_to_str(MSG_FAILED_TO_LOAD_STATE), + path); + return; + } + + if (settings->state_slot < 0) + snprintf(s, len, "%s #-1 (auto).", + msg_hash_to_str(MSG_LOADED_STATE_FROM_SLOT)); + else + snprintf(s, len, "%s #%d.", msg_hash_to_str(MSG_LOADED_STATE_FROM_SLOT), + settings->state_slot); +} + +static void event_main_state(unsigned cmd) +{ + retro_ctx_size_info_t info; + char path[PATH_MAX_LENGTH] = {0}; + char msg[128] = {0}; + global_t *global = global_get_ptr(); + settings_t *settings = config_get_ptr(); + + if (settings->state_slot > 0) + snprintf(path, sizeof(path), "%s%d", + global->name.savestate, settings->state_slot); + else if (settings->state_slot < 0) + fill_pathname_join_delim(path, + global->name.savestate, "auto", '.', sizeof(path)); + else + strlcpy(path, global->name.savestate, sizeof(path)); + + core_serialize_size(&info); + + if (info.size) + { + switch (cmd) + { + case EVENT_CMD_SAVE_STATE: + event_save_state(path, msg, sizeof(msg)); + break; + case EVENT_CMD_LOAD_STATE: + event_load_state(path, msg, sizeof(msg)); + break; + } + } + else + strlcpy(msg, msg_hash_to_str( + MSG_CORE_DOES_NOT_SUPPORT_SAVESTATES), sizeof(msg)); + + runloop_msg_queue_push(msg, 2, 180, true); + RARCH_LOG("%s\n", msg); +} + +static bool event_cmd_exec(void *data) +{ + char *fullpath = NULL; + + runloop_ctl(RUNLOOP_CTL_GET_CONTENT_PATH, &fullpath); + + if (fullpath != data) + { + runloop_ctl(RUNLOOP_CTL_CLEAR_CONTENT_PATH, NULL); + if (data) + runloop_ctl(RUNLOOP_CTL_SET_CONTENT_PATH, data); + } + +#if defined(HAVE_DYNAMIC) + if (!rarch_ctl(RARCH_CTL_LOAD_CONTENT, NULL)) + return false; +#else + frontend_driver_set_fork(FRONTEND_FORK_CORE_WITH_ARGS); +#endif + + return true; +} + +/** + * command_event: + * @cmd : Event command index. + * + * Performs program event command with index @cmd. + * + * Returns: true (1) on success, otherwise false (0). + **/ +bool command_event(enum event_command cmd, void *data) +{ + unsigned i = 0; + bool boolean = false; + settings_t *settings = config_get_ptr(); + rarch_system_info_t *info = NULL; + + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); + + (void)i; + + switch (cmd) + { + case EVENT_CMD_MENU_REFRESH: +#ifdef HAVE_MENU + menu_driver_ctl(RARCH_MENU_CTL_REFRESH, NULL); +#endif + break; + case EVENT_CMD_SET_PER_GAME_RESOLUTION: +#if defined(GEKKO) + { + unsigned width = 0, height = 0; + + command_event(EVENT_CMD_VIDEO_SET_ASPECT_RATIO, NULL); + + if (video_driver_get_video_output_size(&width, &height)) + { + char msg[128] = {0}; + + video_driver_set_video_mode(width, height, true); + + if (width == 0 || height == 0) + strlcpy(msg, "Resolution: DEFAULT", sizeof(msg)); + else + snprintf(msg, sizeof(msg),"Resolution: %dx%d",width, height); + runloop_msg_queue_push(msg, 1, 100, true); + } + } +#endif + break; + case EVENT_CMD_LOAD_CONTENT_PERSIST: +#ifdef HAVE_DYNAMIC + command_event(EVENT_CMD_LOAD_CORE, NULL); +#endif + rarch_ctl(RARCH_CTL_LOAD_CONTENT, NULL); + break; +#ifdef HAVE_FFMPEG + case EVENT_CMD_LOAD_CONTENT_FFMPEG: + rarch_ctl(RARCH_CTL_LOAD_CONTENT_FFMPEG, NULL); + break; +#endif + case EVENT_CMD_LOAD_CONTENT_IMAGEVIEWER: + rarch_ctl(RARCH_CTL_LOAD_CONTENT_IMAGEVIEWER, NULL); + break; + case EVENT_CMD_LOAD_CONTENT: + { +#ifdef HAVE_DYNAMIC + command_event(EVENT_CMD_LOAD_CONTENT_PERSIST, NULL); +#else + char *fullpath = NULL; + runloop_ctl(RUNLOOP_CTL_GET_CONTENT_PATH, &fullpath); + runloop_ctl(RUNLOOP_CTL_SET_LIBRETRO_PATH, settings->path.libretro); + command_event(EVENT_CMD_EXEC, (void*)fullpath); + command_event(EVENT_CMD_QUIT, NULL); +#endif + } + break; + case EVENT_CMD_LOAD_CORE_DEINIT: +#ifdef HAVE_MENU + menu_driver_ctl(RARCH_MENU_CTL_SYSTEM_INFO_DEINIT, NULL); +#endif + break; + case EVENT_CMD_LOAD_CORE_PERSIST: + command_event(EVENT_CMD_LOAD_CORE_DEINIT, NULL); + { +#ifdef HAVE_MENU + bool *ptr = NULL; + struct retro_system_info *system = NULL; + + menu_driver_ctl(RARCH_MENU_CTL_SYSTEM_INFO_GET, &system); + + if (menu_driver_ctl(RARCH_MENU_CTL_LOAD_NO_CONTENT_GET, &ptr)) + { + core_info_ctx_find_t info_find; + +#if defined(HAVE_DYNAMIC) + if (!(*settings->path.libretro)) + return false; + + libretro_get_system_info( + settings->path.libretro, + system, + ptr); +#else + libretro_get_system_info_static(system, ptr); +#endif + info_find.path = settings->path.libretro; + + if (!core_info_load(&info_find)) + return false; + } +#endif + } + break; + case EVENT_CMD_LOAD_CORE: + command_event(EVENT_CMD_LOAD_CORE_PERSIST, NULL); +#ifndef HAVE_DYNAMIC + command_event(EVENT_CMD_QUIT, NULL); +#endif + break; + case EVENT_CMD_LOAD_STATE: + /* Immutable - disallow savestate load when + * we absolutely cannot change game state. */ + if (bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL)) + return false; + +#ifdef HAVE_NETPLAY + if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_DATA_INITED, NULL)) + return false; +#endif + +#ifdef HAVE_CHEEVOS + if (settings->cheevos.hardcore_mode_enable) + return false; +#endif + + event_main_state(cmd); + break; + case EVENT_CMD_RESIZE_WINDOWED_SCALE: + { + unsigned idx = 0; + unsigned *window_scale = NULL; + + runloop_ctl(RUNLOOP_CTL_GET_WINDOWED_SCALE, &window_scale); + + if (*window_scale == 0) + return false; + + settings->video.scale = *window_scale; + + if (!settings->video.fullscreen) + command_event(EVENT_CMD_REINIT, NULL); + + runloop_ctl(RUNLOOP_CTL_SET_WINDOWED_SCALE, &idx); + } + break; + case EVENT_CMD_MENU_TOGGLE: +#ifdef HAVE_MENU + if (menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL)) + rarch_ctl(RARCH_CTL_MENU_RUNNING_FINISHED, NULL); + else + rarch_ctl(RARCH_CTL_MENU_RUNNING, NULL); +#endif + break; + case EVENT_CMD_CONTROLLERS_INIT: + event_init_controllers(); + break; + case EVENT_CMD_RESET: + RARCH_LOG("%s.\n", msg_hash_to_str(MSG_RESET)); + runloop_msg_queue_push(msg_hash_to_str(MSG_RESET), 1, 120, true); + +#ifdef HAVE_CHEEVOS + cheevos_set_cheats(); +#endif + core_reset(); + break; + case EVENT_CMD_SAVE_STATE: +#ifdef HAVE_CHEEVOS + if (settings->cheevos.hardcore_mode_enable) + return false; +#endif + + if (settings->savestate_auto_index) + settings->state_slot++; + + event_main_state(cmd); + break; + case EVENT_CMD_SAVE_STATE_DECREMENT: + /* Slot -1 is (auto) slot. */ + if (settings->state_slot >= 0) + settings->state_slot--; + break; + case EVENT_CMD_SAVE_STATE_INCREMENT: + settings->state_slot++; + break; + case EVENT_CMD_TAKE_SCREENSHOT: + if (!take_screenshot()) + return false; + break; + case EVENT_CMD_UNLOAD_CORE: + runloop_ctl(RUNLOOP_CTL_PREPARE_DUMMY, NULL); + command_event(EVENT_CMD_LOAD_CORE_DEINIT, NULL); + break; + case EVENT_CMD_QUIT: + rarch_ctl(RARCH_CTL_QUIT, NULL); + break; + case EVENT_CMD_CHEEVOS_HARDCORE_MODE_TOGGLE: +#ifdef HAVE_CHEEVOS + cheevos_toggle_hardcore_mode(); +#endif + break; + case EVENT_CMD_REINIT: + { + struct retro_hw_render_callback *hwr = + video_driver_get_hw_context(); + + if (hwr->cache_context) + video_driver_set_video_cache_context(); + else + video_driver_unset_video_cache_context(); + + video_driver_unset_video_cache_context_ack(); + command_event(EVENT_CMD_RESET_CONTEXT, NULL); + video_driver_unset_video_cache_context(); + + /* Poll input to avoid possibly stale data to corrupt things. */ + input_driver_poll(); + +#ifdef HAVE_MENU + menu_display_set_framebuffer_dirty_flag(); + if (menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL)) + command_event(EVENT_CMD_VIDEO_SET_BLOCKING_STATE, NULL); +#endif + } + break; + case EVENT_CMD_CHEATS_DEINIT: + cheat_manager_state_free(); + break; + case EVENT_CMD_CHEATS_INIT: + command_event(EVENT_CMD_CHEATS_DEINIT, NULL); + event_init_cheats(); + break; + case EVENT_CMD_CHEATS_APPLY: + cheat_manager_apply_cheats(); + break; + case EVENT_CMD_REWIND_DEINIT: +#ifdef HAVE_NETPLAY + if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_DATA_INITED, NULL)) + return false; +#endif +#ifdef HAVE_CHEEVOS + if (settings->cheevos.hardcore_mode_enable) + return false; +#endif + + state_manager_event_deinit(); + break; + case EVENT_CMD_REWIND_INIT: +#ifdef HAVE_CHEEVOS + if (settings->cheevos.hardcore_mode_enable) + return false; +#endif +#ifdef HAVE_NETPLAY + if (!netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_DATA_INITED, NULL)) +#endif + state_manager_event_init(); + break; + case EVENT_CMD_REWIND_TOGGLE: + if (settings->rewind_enable) + command_event(EVENT_CMD_REWIND_INIT, NULL); + else + command_event(EVENT_CMD_REWIND_DEINIT, NULL); + break; + case EVENT_CMD_AUTOSAVE_DEINIT: +#ifdef HAVE_THREADS + { + global_t *global = global_get_ptr(); + if (!global->sram.use) + return false; + autosave_deinit(); + } +#endif + break; + case EVENT_CMD_AUTOSAVE_INIT: + command_event(EVENT_CMD_AUTOSAVE_DEINIT, NULL); +#ifdef HAVE_THREADS + autosave_init(); +#endif + break; + case EVENT_CMD_AUTOSAVE_STATE: + event_save_auto_state(); + break; + case EVENT_CMD_AUDIO_STOP: + if (!audio_driver_alive()) + return false; + + if (!audio_driver_stop()) + return false; + break; + case EVENT_CMD_AUDIO_START: + if (audio_driver_alive()) + return false; + + if (!settings->audio.mute_enable && !audio_driver_start()) + { + RARCH_ERR("Failed to start audio driver. " + "Will continue without audio.\n"); + audio_driver_unset_active(); + } + break; + case EVENT_CMD_AUDIO_MUTE_TOGGLE: + { + const char *msg = !settings->audio.mute_enable ? + msg_hash_to_str(MSG_AUDIO_MUTED): + msg_hash_to_str(MSG_AUDIO_UNMUTED); + + if (!audio_driver_toggle_mute()) + { + RARCH_ERR("%s.\n", + msg_hash_to_str(MSG_FAILED_TO_UNMUTE_AUDIO)); + return false; + } + + runloop_msg_queue_push(msg, 1, 180, true); + RARCH_LOG("%s\n", msg); + } + break; + case EVENT_CMD_OVERLAY_DEINIT: +#ifdef HAVE_OVERLAY + input_overlay_free(); +#endif + break; + case EVENT_CMD_OVERLAY_INIT: + command_event(EVENT_CMD_OVERLAY_DEINIT, NULL); +#ifdef HAVE_OVERLAY + input_overlay_init(); +#endif + break; + case EVENT_CMD_OVERLAY_NEXT: +#ifdef HAVE_OVERLAY + input_overlay_next(settings->input.overlay_opacity); +#endif + break; + case EVENT_CMD_DSP_FILTER_DEINIT: + audio_driver_dsp_filter_free(); + break; + case EVENT_CMD_DSP_FILTER_INIT: + command_event(EVENT_CMD_DSP_FILTER_DEINIT, NULL); + if (!*settings->path.audio_dsp_plugin) + break; + audio_driver_dsp_filter_init(settings->path.audio_dsp_plugin); + break; + case EVENT_CMD_GPU_RECORD_DEINIT: + video_driver_gpu_record_deinit(); + break; + case EVENT_CMD_RECORD_DEINIT: + if (!recording_deinit()) + return false; + break; + case EVENT_CMD_RECORD_INIT: + command_event(EVENT_CMD_HISTORY_DEINIT, NULL); + if (!recording_init()) + return false; + break; + case EVENT_CMD_HISTORY_DEINIT: + if (g_defaults.history) + { + content_playlist_write_file(g_defaults.history); + content_playlist_free(g_defaults.history); + } + g_defaults.history = NULL; + break; + case EVENT_CMD_HISTORY_INIT: + command_event(EVENT_CMD_HISTORY_DEINIT, NULL); + if (!settings->history_list_enable) + return false; + RARCH_LOG("%s: [%s].\n", + msg_hash_to_str(MSG_LOADING_HISTORY_FILE), + settings->path.content_history); + g_defaults.history = content_playlist_init( + settings->path.content_history, + settings->content_history_size); + break; + case EVENT_CMD_CORE_INFO_DEINIT: + core_info_deinit_list(); + break; + case EVENT_CMD_CORE_INFO_INIT: + command_event(EVENT_CMD_CORE_INFO_DEINIT, NULL); + + if (*settings->directory.libretro) + core_info_init_list(); + break; + case EVENT_CMD_CORE_DEINIT: + { + struct retro_hw_render_callback *hwr = + video_driver_get_hw_context(); + event_deinit_core(true); + + if (hwr) + memset(hwr, 0, sizeof(*hwr)); + + break; + } + case EVENT_CMD_CORE_INIT: + if (!event_init_core((enum rarch_core_type*)data)) + return false; + break; + case EVENT_CMD_VIDEO_APPLY_STATE_CHANGES: + video_driver_apply_state_changes(); + break; + case EVENT_CMD_VIDEO_SET_NONBLOCKING_STATE: + boolean = true; /* fall-through */ + case EVENT_CMD_VIDEO_SET_BLOCKING_STATE: + video_driver_set_nonblock_state(boolean); + break; + case EVENT_CMD_VIDEO_SET_ASPECT_RATIO: + video_driver_set_aspect_ratio(); + break; + case EVENT_CMD_AUDIO_SET_NONBLOCKING_STATE: + boolean = true; /* fall-through */ + case EVENT_CMD_AUDIO_SET_BLOCKING_STATE: + audio_driver_set_nonblocking_state(boolean); + break; + case EVENT_CMD_OVERLAY_SET_SCALE_FACTOR: +#ifdef HAVE_OVERLAY + input_overlay_set_scale_factor(settings->input.overlay_scale); +#endif + break; + case EVENT_CMD_OVERLAY_SET_ALPHA_MOD: +#ifdef HAVE_OVERLAY + input_overlay_set_alpha_mod(settings->input.overlay_opacity); +#endif + break; + case EVENT_CMD_AUDIO_REINIT: + { + int flags = DRIVER_AUDIO; + driver_ctl(RARCH_DRIVER_CTL_UNINIT, &flags); + driver_ctl(RARCH_DRIVER_CTL_INIT, &flags); + } + break; + case EVENT_CMD_RESET_CONTEXT: + { + /* RARCH_DRIVER_CTL_UNINIT clears the callback struct so we + * need to make sure to keep a copy */ + struct retro_hw_render_callback *hwr = NULL; + struct retro_hw_render_callback hwr_copy; + int flags = DRIVERS_CMD_ALL; + + hwr = video_driver_get_hw_context(); + memcpy(&hwr_copy, hwr, sizeof(hwr_copy)); + + driver_ctl(RARCH_DRIVER_CTL_UNINIT, &flags); + + memcpy(hwr, &hwr_copy, sizeof(*hwr)); + + driver_ctl(RARCH_DRIVER_CTL_INIT, &flags); + } + break; + case EVENT_CMD_QUIT_RETROARCH: + rarch_ctl(RARCH_CTL_FORCE_QUIT, NULL); + break; + case EVENT_CMD_SHUTDOWN: +#if defined(__linux__) && !defined(ANDROID) + runloop_msg_queue_push("Shutting down...", 1, 180, true); + rarch_ctl(RARCH_CTL_FORCE_QUIT, NULL); + system("shutdown -P now"); +#endif + break; + case EVENT_CMD_REBOOT: +#if defined(__linux__) && !defined(ANDROID) + runloop_msg_queue_push("Rebooting...", 1, 180, true); + rarch_ctl(RARCH_CTL_FORCE_QUIT, NULL); + system("shutdown -r now"); +#endif + break; + case EVENT_CMD_RESUME: + rarch_ctl(RARCH_CTL_MENU_RUNNING_FINISHED, NULL); + if (ui_companion_is_on_foreground()) + ui_companion_driver_toggle(); + break; + case EVENT_CMD_RESTART_RETROARCH: + if (!frontend_driver_set_fork(FRONTEND_FORK_RESTART)) + return false; + break; + case EVENT_CMD_MENU_SAVE_CURRENT_CONFIG: + event_save_current_config(); + break; + case EVENT_CMD_MENU_SAVE_CONFIG: + if (!event_save_core_config()) + return false; + break; + case EVENT_CMD_SHADERS_APPLY_CHANGES: +#ifdef HAVE_MENU + menu_shader_manager_apply_changes(); +#endif + break; + case EVENT_CMD_PAUSE_CHECKS: + if (runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL)) + { + RARCH_LOG("%s\n", msg_hash_to_str(MSG_PAUSED)); + command_event(EVENT_CMD_AUDIO_STOP, NULL); + + if (settings->video.black_frame_insertion) + video_driver_cached_frame_render(); + } + else + { + RARCH_LOG("%s\n", msg_hash_to_str(MSG_UNPAUSED)); + command_event(EVENT_CMD_AUDIO_START, NULL); + } + break; + case EVENT_CMD_PAUSE_TOGGLE: + boolean = runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL); + boolean = !boolean; + runloop_ctl(RUNLOOP_CTL_SET_PAUSED, &boolean); + command_event(EVENT_CMD_PAUSE_CHECKS, NULL); + break; + case EVENT_CMD_UNPAUSE: + boolean = false; + + runloop_ctl(RUNLOOP_CTL_SET_PAUSED, &boolean); + command_event(EVENT_CMD_PAUSE_CHECKS, NULL); + break; + case EVENT_CMD_PAUSE: + boolean = true; + + runloop_ctl(RUNLOOP_CTL_SET_PAUSED, &boolean); + command_event(EVENT_CMD_PAUSE_CHECKS, NULL); + break; + case EVENT_CMD_MENU_PAUSE_LIBRETRO: +#ifdef HAVE_MENU + if (menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL)) + { + if (settings->menu.pause_libretro) + command_event(EVENT_CMD_AUDIO_STOP, NULL); + else + command_event(EVENT_CMD_AUDIO_START, NULL); + } + else + { + if (settings->menu.pause_libretro) + command_event(EVENT_CMD_AUDIO_START, NULL); + } +#endif + break; + case EVENT_CMD_SHADER_DIR_DEINIT: + runloop_ctl(RUNLOOP_CTL_SHADER_DIR_DEINIT, NULL); + break; + case EVENT_CMD_SHADER_DIR_INIT: + command_event(EVENT_CMD_SHADER_DIR_DEINIT, NULL); + + if (!runloop_ctl(RUNLOOP_CTL_SHADER_DIR_INIT, NULL)) + return false; + break; + case EVENT_CMD_SAVEFILES: + { + global_t *global = global_get_ptr(); + if (!global->savefiles || !global->sram.use) + return false; + + for (i = 0; i < global->savefiles->size; i++) + { + ram_type_t ram; + ram.type = global->savefiles->elems[i].attr.i; + ram.path = global->savefiles->elems[i].data; + + RARCH_LOG("%s #%u %s \"%s\".\n", + msg_hash_to_str(MSG_SAVING_RAM_TYPE), + ram.type, + msg_hash_to_str(MSG_TO), + ram.path); + content_save_ram_file(&ram); + } + } + return true; + case EVENT_CMD_SAVEFILES_DEINIT: + { + global_t *global = global_get_ptr(); + if (!global) + break; + + if (global->savefiles) + string_list_free(global->savefiles); + global->savefiles = NULL; + } + break; + case EVENT_CMD_SAVEFILES_INIT: + { + global_t *global = global_get_ptr(); + global->sram.use = global->sram.use && !global->sram.save_disable; +#ifdef HAVE_NETPLAY + global->sram.use = global->sram.use && + (!netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_DATA_INITED, NULL) + || !global->netplay.is_client); +#endif + + if (!global->sram.use) + RARCH_LOG("%s\n", + msg_hash_to_str(MSG_SRAM_WILL_NOT_BE_SAVED)); + + if (global->sram.use) + command_event(EVENT_CMD_AUTOSAVE_INIT, NULL); + } + break; + case EVENT_CMD_BSV_MOVIE_DEINIT: + bsv_movie_ctl(BSV_MOVIE_CTL_DEINIT, NULL); + break; + case EVENT_CMD_BSV_MOVIE_INIT: + command_event(EVENT_CMD_BSV_MOVIE_DEINIT, NULL); + bsv_movie_ctl(BSV_MOVIE_CTL_INIT, NULL); + break; + case EVENT_CMD_NETPLAY_DEINIT: +#ifdef HAVE_NETPLAY + deinit_netplay(); +#endif + break; + case EVENT_CMD_NETWORK_DEINIT: +#ifdef HAVE_NETWORKING + network_deinit(); +#endif + break; + case EVENT_CMD_NETWORK_INIT: +#ifdef HAVE_NETWORKING + network_init(); +#endif + break; + case EVENT_CMD_NETPLAY_INIT: + command_event(EVENT_CMD_NETPLAY_DEINIT, NULL); +#ifdef HAVE_NETPLAY + if (!init_netplay()) + return false; +#endif + break; + case EVENT_CMD_NETPLAY_FLIP_PLAYERS: +#ifdef HAVE_NETPLAY + netplay_driver_ctl(RARCH_NETPLAY_CTL_FLIP_PLAYERS, NULL); +#endif + break; + case EVENT_CMD_FULLSCREEN_TOGGLE: + if (!video_driver_has_windowed()) + return false; + + /* If we go fullscreen we drop all drivers and + * reinitialize to be safe. */ + settings->video.fullscreen = !settings->video.fullscreen; + command_event(EVENT_CMD_REINIT, NULL); + break; + case EVENT_CMD_COMMAND_DEINIT: + input_driver_deinit_command(); + break; + case EVENT_CMD_COMMAND_INIT: + command_event(EVENT_CMD_COMMAND_DEINIT, NULL); + input_driver_init_command(); + break; + case EVENT_CMD_REMOTE_DEINIT: + input_driver_deinit_remote(); + break; + case EVENT_CMD_REMOTE_INIT: + command_event(EVENT_CMD_REMOTE_DEINIT, NULL); + input_driver_init_remote(); + break; + case EVENT_CMD_TEMPORARY_CONTENT_DEINIT: + content_deinit(); + break; + case EVENT_CMD_SUBSYSTEM_FULLPATHS_DEINIT: + { + global_t *global = global_get_ptr(); + if (!global) + break; + + if (global->subsystem_fullpaths) + string_list_free(global->subsystem_fullpaths); + global->subsystem_fullpaths = NULL; + } + break; + case EVENT_CMD_LOG_FILE_DEINIT: + retro_main_log_file_deinit(); + break; + case EVENT_CMD_DISK_APPEND_IMAGE: + { + const char *path = (const char*)data; + if (string_is_empty(path)) + return false; + return event_disk_control_append_image(path); + } + case EVENT_CMD_DISK_EJECT_TOGGLE: + if (info && info->disk_control_cb.get_num_images) + { + const struct retro_disk_control_callback *control = + (const struct retro_disk_control_callback*) + &info->disk_control_cb; + + if (control) + { + bool new_state = !control->get_eject_state(); + event_disk_control_set_eject(new_state, true); + } + } + else + runloop_msg_queue_push( + msg_hash_to_str(MSG_CORE_DOES_NOT_SUPPORT_DISK_OPTIONS), + 1, 120, true); + break; + case EVENT_CMD_DISK_NEXT: + if (info && info->disk_control_cb.get_num_images) + { + const struct retro_disk_control_callback *control = + (const struct retro_disk_control_callback*) + &info->disk_control_cb; + + if (!control) + return false; + + if (!control->get_eject_state()) + return false; + + event_check_disk_next(control); + } + else + runloop_msg_queue_push( + msg_hash_to_str(MSG_CORE_DOES_NOT_SUPPORT_DISK_OPTIONS), + 1, 120, true); + break; + case EVENT_CMD_DISK_PREV: + if (info && info->disk_control_cb.get_num_images) + { + const struct retro_disk_control_callback *control = + (const struct retro_disk_control_callback*) + &info->disk_control_cb; + + if (!control) + return false; + + if (!control->get_eject_state()) + return false; + + event_check_disk_prev(control); + } + else + runloop_msg_queue_push( + msg_hash_to_str(MSG_CORE_DOES_NOT_SUPPORT_DISK_OPTIONS), + 1, 120, true); + break; + case EVENT_CMD_RUMBLE_STOP: + for (i = 0; i < MAX_USERS; i++) + { + input_driver_set_rumble_state(i, RETRO_RUMBLE_STRONG, 0); + input_driver_set_rumble_state(i, RETRO_RUMBLE_WEAK, 0); + } + break; + case EVENT_CMD_GRAB_MOUSE_TOGGLE: + { + bool ret = false; + static bool grab_mouse_state = false; + + grab_mouse_state = !grab_mouse_state; + + if (grab_mouse_state) + ret = input_driver_grab_mouse(); + else + ret = input_driver_ungrab_mouse(); + + if (!ret) + return false; + + RARCH_LOG("%s: %s.\n", + msg_hash_to_str(MSG_GRAB_MOUSE_STATE), + grab_mouse_state ? "yes" : "no"); + + if (grab_mouse_state) + video_driver_hide_mouse(); + else + video_driver_show_mouse(); + } + break; + case EVENT_CMD_PERFCNT_REPORT_FRONTEND_LOG: + rarch_perf_log(); + break; + case EVENT_CMD_VOLUME_UP: + event_set_volume(0.5f); + break; + case EVENT_CMD_VOLUME_DOWN: + event_set_volume(-0.5f); + break; + case EVENT_CMD_SET_FRAME_LIMIT: + runloop_ctl(RUNLOOP_CTL_SET_FRAME_LIMIT, NULL); + break; + case EVENT_CMD_EXEC: + return event_cmd_exec(data); + case EVENT_CMD_NONE: + default: + return false; + } + + return true; +} diff --git a/command.h b/command.h index 2787a651f4..522395b4b6 100644 --- a/command.h +++ b/command.h @@ -30,12 +30,198 @@ extern "C" { typedef struct command command_t; +enum event_command +{ + EVENT_CMD_NONE = 0, + /* Resets RetroArch. */ + EVENT_CMD_RESET, + /* Loads content file. */ + EVENT_CMD_LOAD_CONTENT, + EVENT_CMD_LOAD_CONTENT_PERSIST, +#ifdef HAVE_FFMPEG + EVENT_CMD_LOAD_CONTENT_FFMPEG, +#endif + EVENT_CMD_LOAD_CONTENT_IMAGEVIEWER, + EVENT_CMD_SET_PER_GAME_RESOLUTION, + EVENT_CMD_SET_FRAME_LIMIT, + /* Loads core. */ + EVENT_CMD_LOAD_CORE_DEINIT, + EVENT_CMD_LOAD_CORE, + EVENT_CMD_LOAD_CORE_PERSIST, + EVENT_CMD_UNLOAD_CORE, + EVENT_CMD_LOAD_STATE, + EVENT_CMD_SAVE_STATE, + EVENT_CMD_SAVE_STATE_DECREMENT, + EVENT_CMD_SAVE_STATE_INCREMENT, + /* Takes screenshot. */ + EVENT_CMD_TAKE_SCREENSHOT, + /* Quits RetroArch. */ + EVENT_CMD_QUIT, + /* Reinitialize all drivers. */ + EVENT_CMD_REINIT, + /* Toggles cheevos hardcore mode. */ + EVENT_CMD_CHEEVOS_HARDCORE_MODE_TOGGLE, + /* Deinitialize rewind. */ + EVENT_CMD_REWIND_DEINIT, + /* Initializes rewind. */ + EVENT_CMD_REWIND_INIT, + /* Toggles rewind. */ + EVENT_CMD_REWIND_TOGGLE, + /* Deinitializes autosave. */ + EVENT_CMD_AUTOSAVE_DEINIT, + /* Initializes autosave. */ + EVENT_CMD_AUTOSAVE_INIT, + EVENT_CMD_AUTOSAVE_STATE, + /* Stops audio. */ + EVENT_CMD_AUDIO_STOP, + /* Starts audio. */ + EVENT_CMD_AUDIO_START, + /* Mutes audio. */ + EVENT_CMD_AUDIO_MUTE_TOGGLE, + /* Initializes overlay. */ + EVENT_CMD_OVERLAY_INIT, + /* Deinitializes overlay. */ + EVENT_CMD_OVERLAY_DEINIT, + /* Sets current scale factor for overlay. */ + EVENT_CMD_OVERLAY_SET_SCALE_FACTOR, + /* Sets current alpha modulation for overlay. */ + EVENT_CMD_OVERLAY_SET_ALPHA_MOD, + /* Cycle to next overlay. */ + EVENT_CMD_OVERLAY_NEXT, + /* Deinitializes overlay. */ + EVENT_CMD_DSP_FILTER_INIT, + /* Deinitializes graphics filter. */ + EVENT_CMD_DSP_FILTER_DEINIT, + /* Deinitializes GPU recoring. */ + EVENT_CMD_GPU_RECORD_DEINIT, + /* Initializes recording system. */ + EVENT_CMD_RECORD_INIT, + /* Deinitializes recording system. */ + EVENT_CMD_RECORD_DEINIT, + /* Deinitializes history playlist. */ + EVENT_CMD_HISTORY_DEINIT, + /* Initializes history playlist. */ + EVENT_CMD_HISTORY_INIT, + /* Deinitializes core information. */ + EVENT_CMD_CORE_INFO_DEINIT, + /* Initializes core information. */ + EVENT_CMD_CORE_INFO_INIT, + /* Deinitializes core. */ + EVENT_CMD_CORE_DEINIT, + /* Initializes core. */ + EVENT_CMD_CORE_INIT, + /* Set audio blocking state. */ + EVENT_CMD_AUDIO_SET_BLOCKING_STATE, + /* Set audio nonblocking state. */ + EVENT_CMD_AUDIO_SET_NONBLOCKING_STATE, + /* Apply video state changes. */ + EVENT_CMD_VIDEO_APPLY_STATE_CHANGES, + /* Set video blocking state. */ + EVENT_CMD_VIDEO_SET_BLOCKING_STATE, + /* Set video nonblocking state. */ + EVENT_CMD_VIDEO_SET_NONBLOCKING_STATE, + /* Sets current aspect ratio index. */ + EVENT_CMD_VIDEO_SET_ASPECT_RATIO, + EVENT_CMD_RESET_CONTEXT, + /* Restarts RetroArch. */ + EVENT_CMD_RESTART_RETROARCH, + /* Force-quit RetroArch. */ + EVENT_CMD_QUIT_RETROARCH, + /* Shutdown the OS */ + EVENT_CMD_SHUTDOWN, + /* Reboot the OS */ + EVENT_CMD_REBOOT, + /* Resume RetroArch when in menu. */ + EVENT_CMD_RESUME, + /* Toggles pause. */ + EVENT_CMD_PAUSE_TOGGLE, + /* Pauses RetroArch. */ + EVENT_CMD_UNPAUSE, + /* Unpauses retroArch. */ + EVENT_CMD_PAUSE, + EVENT_CMD_PAUSE_CHECKS, + EVENT_CMD_MENU_SAVE_CURRENT_CONFIG, + EVENT_CMD_MENU_SAVE_CONFIG, + EVENT_CMD_MENU_PAUSE_LIBRETRO, + /* Toggles menu on/off. */ + EVENT_CMD_MENU_TOGGLE, + EVENT_CMD_MENU_REFRESH, + /* Applies shader changes. */ + EVENT_CMD_SHADERS_APPLY_CHANGES, + /* Initializes shader directory. */ + EVENT_CMD_SHADER_DIR_INIT, + /* Deinitializes shader directory. */ + EVENT_CMD_SHADER_DIR_DEINIT, + /* Initializes controllers. */ + EVENT_CMD_CONTROLLERS_INIT, + EVENT_CMD_SAVEFILES, + /* Initializes savefiles. */ + EVENT_CMD_SAVEFILES_INIT, + /* Deinitializes savefiles. */ + EVENT_CMD_SAVEFILES_DEINIT, + /* Initializes cheats. */ + EVENT_CMD_CHEATS_INIT, + /* Deinitializes cheats. */ + EVENT_CMD_CHEATS_DEINIT, + /* Apply cheats. */ + EVENT_CMD_CHEATS_APPLY, + /* Deinitializes network system. */ + EVENT_CMD_NETWORK_DEINIT, + /* Initializes network system. */ + EVENT_CMD_NETWORK_INIT, + /* Initializes netplay system. */ + EVENT_CMD_NETPLAY_INIT, + /* Deinitializes netplay system. */ + EVENT_CMD_NETPLAY_DEINIT, + /* Flip netplay players. */ + EVENT_CMD_NETPLAY_FLIP_PLAYERS, + /* Initializes BSV movie. */ + EVENT_CMD_BSV_MOVIE_INIT, + /* Deinitializes BSV movie. */ + EVENT_CMD_BSV_MOVIE_DEINIT, + /* Initializes command interface. */ + EVENT_CMD_COMMAND_INIT, + /* Deinitialize command interface. */ + EVENT_CMD_COMMAND_DEINIT, + /* Initializes remote gamepad interface. */ + EVENT_CMD_REMOTE_INIT, + /* Deinitializes remote gamepad interface. */ + EVENT_CMD_REMOTE_DEINIT, + /* Reinitializes audio driver. */ + EVENT_CMD_AUDIO_REINIT, + /* Resizes windowed scale. Will reinitialize video driver. */ + EVENT_CMD_RESIZE_WINDOWED_SCALE, + /* Deinitializes temporary content. */ + EVENT_CMD_TEMPORARY_CONTENT_DEINIT, + EVENT_CMD_SUBSYSTEM_FULLPATHS_DEINIT, + EVENT_CMD_LOG_FILE_DEINIT, + /* Toggles disk eject. */ + EVENT_CMD_DISK_EJECT_TOGGLE, + /* Cycle to next disk. */ + EVENT_CMD_DISK_NEXT, + /* Cycle to previous disk. */ + EVENT_CMD_DISK_PREV, + /* Appends disk image to disk image list. */ + EVENT_CMD_DISK_APPEND_IMAGE, + /* Stops rumbling. */ + EVENT_CMD_RUMBLE_STOP, + /* Toggles mouse grab. */ + EVENT_CMD_GRAB_MOUSE_TOGGLE, + /* Toggles fullscreen mode. */ + EVENT_CMD_FULLSCREEN_TOGGLE, + EVENT_CMD_PERFCNT_REPORT_FRONTEND_LOG, + EVENT_CMD_VOLUME_UP, + EVENT_CMD_VOLUME_DOWN, + EVENT_CMD_EXEC +}; + typedef struct command_handle { command_t *handle; unsigned id; } command_handle_t; +#ifdef HAVE_COMMAND command_t *command_new(bool stdin_enable, bool network_enable, uint16_t port); @@ -50,6 +236,17 @@ bool command_set(command_handle_t *handle); bool command_get(command_handle_t *handle); bool command_free(command_t *handle); +#endif + +/** + * event_command: + * @cmd : Command index. + * + * Performs RetroArch command with index @cmd. + * + * Returns: true (1) on success, otherwise false (0). + **/ +bool command_event(enum event_command action, void *data); #ifdef __cplusplus } diff --git a/command_event.c b/command_event.c deleted file mode 100644 index 7f03348b73..0000000000 --- a/command_event.c +++ /dev/null @@ -1,1716 +0,0 @@ -/* RetroArch - A frontend for libretro. - * 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. - * - * 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 -#include -#include -#include - -#include "command_event.h" - -#include "defaults.h" -#include "frontend/frontend_driver.h" -#include "audio/audio_driver.h" -#include "record/record_driver.h" -#include "autosave.h" -#include "core_info.h" -#include "core_type.h" -#include "performance.h" -#include "dynamic.h" -#include "content.h" -#include "movie.h" -#include "screenshot.h" -#include "msg_hash.h" -#include "retroarch.h" -#include "managers/cheat_manager.h" -#include "managers/state_manager.h" -#include "system.h" -#include "ui/ui_companion_driver.h" -#include "list_special.h" - -#ifdef HAVE_CHEEVOS -#include "cheevos.h" -#endif - -#include "core.h" -#include "verbosity.h" -#include "runloop.h" -#include "configuration.h" -#include "input/input_remapping.h" - -#ifdef HAVE_MENU -#include "menu/menu_driver.h" -#include "menu/menu_display.h" -#include "menu/menu_shader.h" -#endif - -#ifdef HAVE_NETPLAY -#include "network/netplay.h" -#endif - -#ifdef HAVE_NETWORKING -#include -#endif - -/** - * event_disk_control_set_eject: - * @new_state : Eject or close the virtual drive tray. - * false (0) : Close - * true (1) : Eject - * @print_log : Show message onscreen. - * - * Ejects/closes of the virtual drive tray. - **/ -static void event_disk_control_set_eject(bool new_state, bool print_log) -{ - char msg[128] = {0}; - bool error = false; - rarch_system_info_t *info = NULL; - const struct retro_disk_control_callback *control = NULL; - - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); - - if (info) - control = (const struct retro_disk_control_callback*)&info->disk_control_cb; - - if (!control || !control->get_num_images) - return; - - if (control->set_eject_state(new_state)) - snprintf(msg, sizeof(msg), "%s %s", - new_state ? "Ejected" : "Closed", - msg_hash_to_str(MSG_VIRTUAL_DISK_TRAY)); - else - { - error = true; - snprintf(msg, sizeof(msg), "%s %s %s", - msg_hash_to_str(MSG_FAILED_TO), - new_state ? "eject" : "close", - msg_hash_to_str(MSG_VIRTUAL_DISK_TRAY)); - } - - if (*msg) - { - if (error) - RARCH_ERR("%s\n", msg); - else - RARCH_LOG("%s\n", msg); - - /* Only noise in menu. */ - if (print_log) - runloop_msg_queue_push(msg, 1, 180, true); - } -} - -/** - * event_disk_control_set_index: - * @idx : Index of disk to set as current. - * - * Sets current disk to @index. - **/ -static void event_disk_control_set_index(unsigned idx) -{ - unsigned num_disks; - bool error = false; - char msg[128] = {0}; - rarch_system_info_t *info = NULL; - const struct retro_disk_control_callback *control = NULL; - - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); - - if (info) - control = (const struct retro_disk_control_callback*)&info->disk_control_cb; - - if (!control || !control->get_num_images) - return; - - num_disks = control->get_num_images(); - - if (control->set_image_index(idx)) - { - if (idx < num_disks) - snprintf(msg, sizeof(msg), "Setting disk %u of %u in tray.", - idx + 1, num_disks); - else - strlcpy(msg, - msg_hash_to_str(MSG_REMOVED_DISK_FROM_TRAY), - sizeof(msg)); - } - else - { - if (idx < num_disks) - snprintf(msg, sizeof(msg), "Failed to set disk %u of %u.", - idx + 1, num_disks); - else - strlcpy(msg, - msg_hash_to_str(MSG_FAILED_TO_REMOVE_DISK_FROM_TRAY), - sizeof(msg)); - error = true; - } - - if (*msg) - { - if (error) - RARCH_ERR("%s\n", msg); - else - RARCH_LOG("%s\n", msg); - runloop_msg_queue_push(msg, 1, 180, true); - } -} - -/** - * event_disk_control_append_image: - * @path : Path to disk image. - * - * Appends disk image to disk image list. - **/ -static bool event_disk_control_append_image(const char *path) -{ - unsigned new_idx; - char msg[128] = {0}; - struct retro_game_info info = {0}; - global_t *global = global_get_ptr(); - const struct retro_disk_control_callback *control = NULL; - rarch_system_info_t *sysinfo = NULL; - - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &sysinfo); - - if (sysinfo) - control = (const struct retro_disk_control_callback*) - &sysinfo->disk_control_cb; - - if (!control) - return false; - - event_disk_control_set_eject(true, false); - - control->add_image_index(); - new_idx = control->get_num_images(); - if (!new_idx) - return false; - new_idx--; - - info.path = path; - control->replace_image_index(new_idx, &info); - - snprintf(msg, sizeof(msg), "%s: ", msg_hash_to_str(MSG_APPENDED_DISK)); - strlcat(msg, path, sizeof(msg)); - RARCH_LOG("%s\n", msg); - runloop_msg_queue_push(msg, 0, 180, true); - - command_event(EVENT_CMD_AUTOSAVE_DEINIT, NULL); - - /* TODO: Need to figure out what to do with subsystems case. */ - if (!*global->subsystem) - { - /* Update paths for our new image. - * If we actually use append_image, we assume that we - * started out in a single disk case, and that this way - * of doing it makes the most sense. */ - rarch_ctl(RARCH_CTL_SET_PATHS, (void*)path); - rarch_ctl(RARCH_CTL_FILL_PATHNAMES, NULL); - } - - command_event(EVENT_CMD_AUTOSAVE_INIT, NULL); - event_disk_control_set_index(new_idx); - event_disk_control_set_eject(false, false); - - return true; -} - -/** - * event_check_disk_prev: - * @control : Handle to disk control handle. - * - * Perform disk cycle to previous index action (Core Disk Options). - **/ -static void event_check_disk_prev( - const struct retro_disk_control_callback *control) -{ - unsigned num_disks = 0; - unsigned current = 0; - bool disk_prev_enable = false; - - if (!control || !control->get_num_images) - return; - if (!control->get_image_index) - return; - - num_disks = control->get_num_images(); - current = control->get_image_index(); - disk_prev_enable = num_disks && num_disks != UINT_MAX; - - if (!disk_prev_enable) - { - RARCH_ERR("%s.\n", msg_hash_to_str(MSG_GOT_INVALID_DISK_INDEX)); - return; - } - - if (current > 0) - current--; - event_disk_control_set_index(current); -} - -/** - * event_check_disk_next: - * @control : Handle to disk control handle. - * - * Perform disk cycle to next index action (Core Disk Options). - **/ -static void event_check_disk_next( - const struct retro_disk_control_callback *control) -{ - unsigned num_disks = 0; - unsigned current = 0; - bool disk_next_enable = false; - - if (!control || !control->get_num_images) - return; - if (!control->get_image_index) - return; - - num_disks = control->get_num_images(); - current = control->get_image_index(); - disk_next_enable = num_disks && num_disks != UINT_MAX; - - if (!disk_next_enable) - { - RARCH_ERR("%s.\n", msg_hash_to_str(MSG_GOT_INVALID_DISK_INDEX)); - return; - } - - if (current < num_disks - 1) - current++; - event_disk_control_set_index(current); -} - -/** - * event_set_volume: - * @gain : amount of gain to be applied to current volume level. - * - * Adjusts the current audio volume level. - * - **/ -static void event_set_volume(float gain) -{ - char msg[128]; - settings_t *settings = config_get_ptr(); - - settings->audio.volume += gain; - settings->audio.volume = MAX(settings->audio.volume, -80.0f); - settings->audio.volume = MIN(settings->audio.volume, 12.0f); - - snprintf(msg, sizeof(msg), "Volume: %.1f dB", settings->audio.volume); - runloop_msg_queue_push(msg, 1, 180, true); - RARCH_LOG("%s\n", msg); - - audio_driver_set_volume_gain(db_to_gain(settings->audio.volume)); -} - -/** - * event_init_controllers: - * - * Initialize libretro controllers. - **/ -static void event_init_controllers(void) -{ - unsigned i; - settings_t *settings = config_get_ptr(); - rarch_system_info_t *info = NULL; - - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); - - for (i = 0; i < MAX_USERS; i++) - { - retro_ctx_controller_info_t pad; - const char *ident = NULL; - bool set_controller = false; - const struct retro_controller_description *desc = NULL; - unsigned device = settings->input.libretro_device[i]; - - if (i < info->ports.size) - desc = libretro_find_controller_description( - &info->ports.data[i], device); - - if (desc) - ident = desc->desc; - - if (!ident) - { - /* If we're trying to connect a completely unknown device, - * revert back to JOYPAD. */ - - if (device != RETRO_DEVICE_JOYPAD && device != RETRO_DEVICE_NONE) - { - /* Do not fix settings->input.libretro_device[i], - * because any use of dummy core will reset this, - * which is not a good idea. */ - RARCH_WARN("Input device ID %u is unknown to this " - "libretro implementation. Using RETRO_DEVICE_JOYPAD.\n", - device); - device = RETRO_DEVICE_JOYPAD; - } - ident = "Joypad"; - } - - switch (device) - { - case RETRO_DEVICE_NONE: - RARCH_LOG("Disconnecting device from port %u.\n", i + 1); - set_controller = true; - break; - case RETRO_DEVICE_JOYPAD: - break; - default: - /* Some cores do not properly range check port argument. - * This is broken behavior of course, but avoid breaking - * cores needlessly. */ - RARCH_LOG("Connecting %s (ID: %u) to port %u.\n", ident, - device, i + 1); - set_controller = true; - break; - } - - if (set_controller) - { - pad.device = device; - pad.port = i; - core_set_controller_port_device(&pad); - } - } -} - -static void event_deinit_core(bool reinit) -{ -#ifdef HAVE_CHEEVOS - cheevos_unload(); -#endif - - core_unload_game(); - core_unload(); - - if (reinit) - { - int flags = DRIVERS_CMD_ALL; - driver_ctl(RARCH_DRIVER_CTL_UNINIT, &flags); - } - - /* auto overrides: reload the original config */ - if (runloop_ctl(RUNLOOP_CTL_IS_OVERRIDES_ACTIVE, NULL)) - { - config_unload_override(); - runloop_ctl(RUNLOOP_CTL_UNSET_OVERRIDES_ACTIVE, NULL); - } -} - -static void event_init_cheats(void) -{ - bool allow_cheats = true; -#ifdef HAVE_NETPLAY - allow_cheats &= !netplay_driver_ctl( - RARCH_NETPLAY_CTL_IS_DATA_INITED, NULL); -#endif - allow_cheats &= !bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL); - - if (!allow_cheats) - return; - - /* TODO/FIXME - add some stuff here. */ -} - -static bool event_load_save_files(void) -{ - unsigned i; - global_t *global = global_get_ptr(); - - if (!global) - return false; - if (!global->savefiles || global->sram.load_disable) - return false; - - for (i = 0; i < global->savefiles->size; i++) - { - ram_type_t ram; - ram.path = global->savefiles->elems[i].data; - ram.type = global->savefiles->elems[i].attr.i; - - content_load_ram_file(&ram); - } - - return true; -} - -static void event_load_auto_state(void) -{ - bool ret; - char msg[128] = {0}; - char savestate_name_auto[PATH_MAX_LENGTH] = {0}; - settings_t *settings = config_get_ptr(); - global_t *global = global_get_ptr(); - -#ifdef HAVE_NETPLAY - if (global->netplay.enable && !global->netplay.is_spectate) - return; -#endif - -#ifdef HAVE_CHEEVOS - if (settings->cheevos.hardcore_mode_enable) - return; -#endif - - if (!settings->savestate_auto_load) - return; - - fill_pathname_noext(savestate_name_auto, global->name.savestate, - ".auto", sizeof(savestate_name_auto)); - - if (!path_file_exists(savestate_name_auto)) - return; - - ret = content_load_state(savestate_name_auto); - - RARCH_LOG("Found auto savestate in: %s\n", savestate_name_auto); - - snprintf(msg, sizeof(msg), "Auto-loading savestate from \"%s\" %s.", - savestate_name_auto, ret ? "succeeded" : "failed"); - runloop_msg_queue_push(msg, 1, 180, false); - RARCH_LOG("%s\n", msg); -} - -static void event_set_savestate_auto_index(void) -{ - size_t i; - char state_dir[PATH_MAX_LENGTH] = {0}; - char state_base[PATH_MAX_LENGTH] = {0}; - struct string_list *dir_list = NULL; - unsigned max_idx = 0; - settings_t *settings = config_get_ptr(); - global_t *global = global_get_ptr(); - - if (!settings->savestate_auto_index) - return; - - /* Find the file in the same directory as global->savestate_name - * with the largest numeral suffix. - * - * E.g. /foo/path/content.state, will try to find - * /foo/path/content.state%d, where %d is the largest number available. - */ - - fill_pathname_basedir(state_dir, global->name.savestate, - sizeof(state_dir)); - fill_pathname_base(state_base, global->name.savestate, - sizeof(state_base)); - - if (!(dir_list = dir_list_new_special(state_dir, DIR_LIST_PLAIN, NULL))) - return; - - for (i = 0; i < dir_list->size; i++) - { - unsigned idx; - char elem_base[128] = {0}; - const char *end = NULL; - const char *dir_elem = dir_list->elems[i].data; - - fill_pathname_base(elem_base, dir_elem, sizeof(elem_base)); - - if (strstr(elem_base, state_base) != elem_base) - continue; - - end = dir_elem + strlen(dir_elem); - while ((end > dir_elem) && isdigit((int)end[-1])) - end--; - - idx = strtoul(end, NULL, 0); - if (idx > max_idx) - max_idx = idx; - } - - dir_list_free(dir_list); - - settings->state_slot = max_idx; - RARCH_LOG("Found last state slot: #%d\n", settings->state_slot); -} - -static bool event_init_content(void) -{ - rarch_ctl(RARCH_CTL_SET_SRAM_ENABLE, NULL); - - /* No content to be loaded for dummy core, - * just successfully exit. */ - if (rarch_ctl(RARCH_CTL_IS_DUMMY_CORE, NULL)) - return true; - - if (!content_does_not_need_content()) - rarch_ctl(RARCH_CTL_FILL_PATHNAMES, NULL); - - if (!content_init()) - return false; - - if (content_does_not_need_content()) - return true; - - event_set_savestate_auto_index(); - - if (event_load_save_files()) - RARCH_LOG("%s.\n", - msg_hash_to_str(MSG_SKIPPING_SRAM_LOAD)); - - event_load_auto_state(); - command_event(EVENT_CMD_BSV_MOVIE_INIT, NULL); - command_event(EVENT_CMD_NETPLAY_INIT, NULL); - - return true; -} - -static bool event_init_core(enum rarch_core_type *data) -{ - retro_ctx_environ_info_t info; - settings_t *settings = config_get_ptr(); - - if (!core_init_symbols(data)) - return false; - - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_INIT, NULL); - - /* auto overrides: apply overrides */ - if(settings->auto_overrides_enable) - { - if (config_load_override()) - runloop_ctl(RUNLOOP_CTL_SET_OVERRIDES_ACTIVE, NULL); - else - runloop_ctl(RUNLOOP_CTL_UNSET_OVERRIDES_ACTIVE, NULL); - } - - /* reset video format to libretro's default */ - video_driver_set_pixel_format(RETRO_PIXEL_FORMAT_0RGB1555); - - info.env = rarch_environment_cb; - core_set_environment(&info); - - /* Auto-remap: apply remap files */ - if(settings->auto_remaps_enable) - config_load_remap(); - - /* Per-core saves: reset redirection paths */ - rarch_ctl(RARCH_CTL_SET_PATHS_REDIRECT, NULL); - - if (!core_init()) - return false; - - if (!event_init_content()) - return false; - - if (!core_load()) - return false; - - return true; -} - -static bool event_save_auto_state(void) -{ - bool ret; - char savestate_name_auto[PATH_MAX_LENGTH] = {0}; - settings_t *settings = config_get_ptr(); - global_t *global = global_get_ptr(); - - if (!settings->savestate_auto_save) - return false; - if (rarch_ctl(RARCH_CTL_IS_DUMMY_CORE, NULL)) - return false; - if (content_does_not_need_content()) - return false; - -#ifdef HAVE_CHEEVOS - if (settings->cheevos.hardcore_mode_enable) - return false; -#endif - - fill_pathname_noext(savestate_name_auto, global->name.savestate, - ".auto", sizeof(savestate_name_auto)); - - ret = content_save_state((const char*)savestate_name_auto); - RARCH_LOG("Auto save state to \"%s\" %s.\n", savestate_name_auto, ret ? - "succeeded" : "failed"); - - return true; -} - -/** - * event_save_core_config: - * - * Saves a new (core) configuration to a file. Filename is based - * on heuristics to avoid typing. - * - * Returns: true (1) on success, otherwise false (0). - **/ -static bool event_save_core_config(void) -{ - char config_dir[PATH_MAX_LENGTH] = {0}; - char config_name[PATH_MAX_LENGTH] = {0}; - char config_path[PATH_MAX_LENGTH] = {0}; - char msg[128] = {0}; - bool ret = false; - bool found_path = false; - bool overrides_active = false; - settings_t *settings = config_get_ptr(); - global_t *global = global_get_ptr(); - - *config_dir = '\0'; - if (!string_is_empty(settings->directory.menu_config)) - strlcpy(config_dir, settings->directory.menu_config, - sizeof(config_dir)); - else if (!string_is_empty(global->path.config)) /* Fallback */ - fill_pathname_basedir(config_dir, global->path.config, - sizeof(config_dir)); - else - { - runloop_msg_queue_push(msg_hash_to_str(MSG_CONFIG_DIRECTORY_NOT_SET), 1, 180, true); - RARCH_ERR("%s\n", msg_hash_to_str(MSG_CONFIG_DIRECTORY_NOT_SET)); - return false; - } - - /* Infer file name based on libretro core. */ - if (!string_is_empty(settings->path.libretro) - && path_file_exists(settings->path.libretro)) - { - unsigned i; - RARCH_LOG("Using core name for new config\n"); - /* In case of collision, find an alternative name. */ - for (i = 0; i < 16; i++) - { - char tmp[64]; - - fill_pathname_base( - config_name, - settings->path.libretro, - sizeof(config_name)); - - path_remove_extension(config_name); - fill_pathname_join(config_path, config_dir, config_name, - sizeof(config_path)); - if (i) - snprintf(tmp, sizeof(tmp), "-%u.cfg", i); - else - strlcpy(tmp, ".cfg", sizeof(tmp)); - - strlcat(config_path, tmp, sizeof(config_path)); - if (!path_file_exists(config_path)) - { - found_path = true; - break; - } - } - } - - /* Fallback to system time... */ - if (!found_path) - { - RARCH_WARN("Cannot infer new config path. Use current time.\n"); - fill_dated_filename(config_name, "cfg", sizeof(config_name)); - fill_pathname_join(config_path, config_dir, config_name, - sizeof(config_path)); - } - - /* Overrides block config file saving, make it appear as overrides - * weren't enabled for a manual save */ - if (runloop_ctl(RUNLOOP_CTL_IS_OVERRIDES_ACTIVE, NULL)) - { - runloop_ctl(RUNLOOP_CTL_UNSET_OVERRIDES_ACTIVE, NULL); - overrides_active = true; - } - - if ((ret = config_save_file(config_path))) - { - strlcpy(global->path.config, config_path, - sizeof(global->path.config)); - snprintf(msg, sizeof(msg), "Saved new config to \"%s\".", - config_path); - RARCH_LOG("%s\n", msg); - } - else - { - snprintf(msg, sizeof(msg), "Failed saving config to \"%s\".", - config_path); - RARCH_ERR("%s\n", msg); - } - - runloop_msg_queue_push(msg, 1, 180, true); - - if (overrides_active) - runloop_ctl(RUNLOOP_CTL_SET_OVERRIDES_ACTIVE, NULL); - else - runloop_ctl(RUNLOOP_CTL_UNSET_OVERRIDES_ACTIVE, NULL); - return ret; -} - -/** - * event_save_current_config: - * - * Saves current configuration file to disk, and (optionally) - * autosave state. - **/ -void event_save_current_config(void) -{ - char msg[128]; - settings_t *settings = config_get_ptr(); - global_t *global = global_get_ptr(); - bool ret = false; - - if (settings->config_save_on_exit && !string_is_empty(global->path.config)) - { - /* Save last core-specific config to the default config location, - * needed on consoles for core switching and reusing last good - * config for new cores. - */ - - /* Flush out the core specific config. */ - if (*global->path.core_specific_config && - settings->core_specific_config) - ret = config_save_file(global->path.core_specific_config); - else - ret = config_save_file(global->path.config); - if (ret) - { - snprintf(msg, sizeof(msg), "Saved new config to \"%s\".", - global->path.config); - RARCH_LOG("%s\n", msg); - } - else - { - snprintf(msg, sizeof(msg), "Failed saving config to \"%s\".", - global->path.config); - RARCH_ERR("%s\n", msg); - } - - runloop_msg_queue_push(msg, 1, 180, true); - } -} - -/** - * event_save_state - * @path : Path to state. - * @s : Message. - * @len : Size of @s. - * - * Saves a state with path being @path. - **/ -static void event_save_state(const char *path, - char *s, size_t len) -{ - settings_t *settings = config_get_ptr(); - - if (!content_save_state(path)) - { - snprintf(s, len, "%s \"%s\".", - msg_hash_to_str(MSG_FAILED_TO_SAVE_STATE_TO), - path); - return; - } - - if (settings->state_slot < 0) - snprintf(s, len, "%s #-1 (auto).", - msg_hash_to_str(MSG_SAVED_STATE_TO_SLOT)); - else - snprintf(s, len, "%s #%d.", msg_hash_to_str(MSG_SAVED_STATE_TO_SLOT), - settings->state_slot); -} - -/** - * event_load_state - * @path : Path to state. - * @s : Message. - * @len : Size of @s. - * - * Loads a state with path being @path. - **/ -static void event_load_state(const char *path, char *s, size_t len) -{ - settings_t *settings = config_get_ptr(); - - if (!content_load_state(path)) - { - snprintf(s, len, "%s \"%s\".", - msg_hash_to_str(MSG_FAILED_TO_LOAD_STATE), - path); - return; - } - - if (settings->state_slot < 0) - snprintf(s, len, "%s #-1 (auto).", - msg_hash_to_str(MSG_LOADED_STATE_FROM_SLOT)); - else - snprintf(s, len, "%s #%d.", msg_hash_to_str(MSG_LOADED_STATE_FROM_SLOT), - settings->state_slot); -} - -static void event_main_state(unsigned cmd) -{ - retro_ctx_size_info_t info; - char path[PATH_MAX_LENGTH] = {0}; - char msg[128] = {0}; - global_t *global = global_get_ptr(); - settings_t *settings = config_get_ptr(); - - if (settings->state_slot > 0) - snprintf(path, sizeof(path), "%s%d", - global->name.savestate, settings->state_slot); - else if (settings->state_slot < 0) - fill_pathname_join_delim(path, - global->name.savestate, "auto", '.', sizeof(path)); - else - strlcpy(path, global->name.savestate, sizeof(path)); - - core_serialize_size(&info); - - if (info.size) - { - switch (cmd) - { - case EVENT_CMD_SAVE_STATE: - event_save_state(path, msg, sizeof(msg)); - break; - case EVENT_CMD_LOAD_STATE: - event_load_state(path, msg, sizeof(msg)); - break; - } - } - else - strlcpy(msg, msg_hash_to_str( - MSG_CORE_DOES_NOT_SUPPORT_SAVESTATES), sizeof(msg)); - - runloop_msg_queue_push(msg, 2, 180, true); - RARCH_LOG("%s\n", msg); -} - -static bool event_cmd_exec(void *data) -{ - char *fullpath = NULL; - - runloop_ctl(RUNLOOP_CTL_GET_CONTENT_PATH, &fullpath); - - if (fullpath != data) - { - runloop_ctl(RUNLOOP_CTL_CLEAR_CONTENT_PATH, NULL); - if (data) - runloop_ctl(RUNLOOP_CTL_SET_CONTENT_PATH, data); - } - -#if defined(HAVE_DYNAMIC) - if (!rarch_ctl(RARCH_CTL_LOAD_CONTENT, NULL)) - return false; -#else - frontend_driver_set_fork(FRONTEND_FORK_CORE_WITH_ARGS); -#endif - - return true; -} - -/** - * command_event: - * @cmd : Event command index. - * - * Performs program event command with index @cmd. - * - * Returns: true (1) on success, otherwise false (0). - **/ -bool command_event(enum event_command cmd, void *data) -{ - unsigned i = 0; - bool boolean = false; - settings_t *settings = config_get_ptr(); - rarch_system_info_t *info = NULL; - - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); - - (void)i; - - switch (cmd) - { - case EVENT_CMD_MENU_REFRESH: -#ifdef HAVE_MENU - menu_driver_ctl(RARCH_MENU_CTL_REFRESH, NULL); -#endif - break; - case EVENT_CMD_SET_PER_GAME_RESOLUTION: -#if defined(GEKKO) - { - unsigned width = 0, height = 0; - - command_event(EVENT_CMD_VIDEO_SET_ASPECT_RATIO, NULL); - - if (video_driver_get_video_output_size(&width, &height)) - { - char msg[128] = {0}; - - video_driver_set_video_mode(width, height, true); - - if (width == 0 || height == 0) - strlcpy(msg, "Resolution: DEFAULT", sizeof(msg)); - else - snprintf(msg, sizeof(msg),"Resolution: %dx%d",width, height); - runloop_msg_queue_push(msg, 1, 100, true); - } - } -#endif - break; - case EVENT_CMD_LOAD_CONTENT_PERSIST: -#ifdef HAVE_DYNAMIC - command_event(EVENT_CMD_LOAD_CORE, NULL); -#endif - rarch_ctl(RARCH_CTL_LOAD_CONTENT, NULL); - break; -#ifdef HAVE_FFMPEG - case EVENT_CMD_LOAD_CONTENT_FFMPEG: - rarch_ctl(RARCH_CTL_LOAD_CONTENT_FFMPEG, NULL); - break; -#endif - case EVENT_CMD_LOAD_CONTENT_IMAGEVIEWER: - rarch_ctl(RARCH_CTL_LOAD_CONTENT_IMAGEVIEWER, NULL); - break; - case EVENT_CMD_LOAD_CONTENT: - { -#ifdef HAVE_DYNAMIC - command_event(EVENT_CMD_LOAD_CONTENT_PERSIST, NULL); -#else - char *fullpath = NULL; - runloop_ctl(RUNLOOP_CTL_GET_CONTENT_PATH, &fullpath); - runloop_ctl(RUNLOOP_CTL_SET_LIBRETRO_PATH, settings->path.libretro); - command_event(EVENT_CMD_EXEC, (void*)fullpath); - command_event(EVENT_CMD_QUIT, NULL); -#endif - } - break; - case EVENT_CMD_LOAD_CORE_DEINIT: -#ifdef HAVE_MENU - menu_driver_ctl(RARCH_MENU_CTL_SYSTEM_INFO_DEINIT, NULL); -#endif - break; - case EVENT_CMD_LOAD_CORE_PERSIST: - command_event(EVENT_CMD_LOAD_CORE_DEINIT, NULL); - { -#ifdef HAVE_MENU - bool *ptr = NULL; - struct retro_system_info *system = NULL; - - menu_driver_ctl(RARCH_MENU_CTL_SYSTEM_INFO_GET, &system); - - if (menu_driver_ctl(RARCH_MENU_CTL_LOAD_NO_CONTENT_GET, &ptr)) - { - core_info_ctx_find_t info_find; - -#if defined(HAVE_DYNAMIC) - if (!(*settings->path.libretro)) - return false; - - libretro_get_system_info( - settings->path.libretro, - system, - ptr); -#else - libretro_get_system_info_static(system, ptr); -#endif - info_find.path = settings->path.libretro; - - if (!core_info_load(&info_find)) - return false; - } -#endif - } - break; - case EVENT_CMD_LOAD_CORE: - command_event(EVENT_CMD_LOAD_CORE_PERSIST, NULL); -#ifndef HAVE_DYNAMIC - command_event(EVENT_CMD_QUIT, NULL); -#endif - break; - case EVENT_CMD_LOAD_STATE: - /* Immutable - disallow savestate load when - * we absolutely cannot change game state. */ - if (bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL)) - return false; - -#ifdef HAVE_NETPLAY - if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_DATA_INITED, NULL)) - return false; -#endif - -#ifdef HAVE_CHEEVOS - if (settings->cheevos.hardcore_mode_enable) - return false; -#endif - - event_main_state(cmd); - break; - case EVENT_CMD_RESIZE_WINDOWED_SCALE: - { - unsigned idx = 0; - unsigned *window_scale = NULL; - - runloop_ctl(RUNLOOP_CTL_GET_WINDOWED_SCALE, &window_scale); - - if (*window_scale == 0) - return false; - - settings->video.scale = *window_scale; - - if (!settings->video.fullscreen) - command_event(EVENT_CMD_REINIT, NULL); - - runloop_ctl(RUNLOOP_CTL_SET_WINDOWED_SCALE, &idx); - } - break; - case EVENT_CMD_MENU_TOGGLE: -#ifdef HAVE_MENU - if (menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL)) - rarch_ctl(RARCH_CTL_MENU_RUNNING_FINISHED, NULL); - else - rarch_ctl(RARCH_CTL_MENU_RUNNING, NULL); -#endif - break; - case EVENT_CMD_CONTROLLERS_INIT: - event_init_controllers(); - break; - case EVENT_CMD_RESET: - RARCH_LOG("%s.\n", msg_hash_to_str(MSG_RESET)); - runloop_msg_queue_push(msg_hash_to_str(MSG_RESET), 1, 120, true); - -#ifdef HAVE_CHEEVOS - cheevos_set_cheats(); -#endif - core_reset(); - break; - case EVENT_CMD_SAVE_STATE: -#ifdef HAVE_CHEEVOS - if (settings->cheevos.hardcore_mode_enable) - return false; -#endif - - if (settings->savestate_auto_index) - settings->state_slot++; - - event_main_state(cmd); - break; - case EVENT_CMD_SAVE_STATE_DECREMENT: - /* Slot -1 is (auto) slot. */ - if (settings->state_slot >= 0) - settings->state_slot--; - break; - case EVENT_CMD_SAVE_STATE_INCREMENT: - settings->state_slot++; - break; - case EVENT_CMD_TAKE_SCREENSHOT: - if (!take_screenshot()) - return false; - break; - case EVENT_CMD_UNLOAD_CORE: - runloop_ctl(RUNLOOP_CTL_PREPARE_DUMMY, NULL); - command_event(EVENT_CMD_LOAD_CORE_DEINIT, NULL); - break; - case EVENT_CMD_QUIT: - rarch_ctl(RARCH_CTL_QUIT, NULL); - break; - case EVENT_CMD_CHEEVOS_HARDCORE_MODE_TOGGLE: -#ifdef HAVE_CHEEVOS - cheevos_toggle_hardcore_mode(); -#endif - break; - case EVENT_CMD_REINIT: - { - struct retro_hw_render_callback *hwr = - video_driver_get_hw_context(); - - if (hwr->cache_context) - video_driver_set_video_cache_context(); - else - video_driver_unset_video_cache_context(); - - video_driver_unset_video_cache_context_ack(); - command_event(EVENT_CMD_RESET_CONTEXT, NULL); - video_driver_unset_video_cache_context(); - - /* Poll input to avoid possibly stale data to corrupt things. */ - input_driver_poll(); - -#ifdef HAVE_MENU - menu_display_set_framebuffer_dirty_flag(); - if (menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL)) - command_event(EVENT_CMD_VIDEO_SET_BLOCKING_STATE, NULL); -#endif - } - break; - case EVENT_CMD_CHEATS_DEINIT: - cheat_manager_state_free(); - break; - case EVENT_CMD_CHEATS_INIT: - command_event(EVENT_CMD_CHEATS_DEINIT, NULL); - event_init_cheats(); - break; - case EVENT_CMD_CHEATS_APPLY: - cheat_manager_apply_cheats(); - break; - case EVENT_CMD_REWIND_DEINIT: -#ifdef HAVE_NETPLAY - if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_DATA_INITED, NULL)) - return false; -#endif -#ifdef HAVE_CHEEVOS - if (settings->cheevos.hardcore_mode_enable) - return false; -#endif - - state_manager_event_deinit(); - break; - case EVENT_CMD_REWIND_INIT: -#ifdef HAVE_CHEEVOS - if (settings->cheevos.hardcore_mode_enable) - return false; -#endif -#ifdef HAVE_NETPLAY - if (!netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_DATA_INITED, NULL)) -#endif - state_manager_event_init(); - break; - case EVENT_CMD_REWIND_TOGGLE: - if (settings->rewind_enable) - command_event(EVENT_CMD_REWIND_INIT, NULL); - else - command_event(EVENT_CMD_REWIND_DEINIT, NULL); - break; - case EVENT_CMD_AUTOSAVE_DEINIT: -#ifdef HAVE_THREADS - { - global_t *global = global_get_ptr(); - if (!global->sram.use) - return false; - autosave_deinit(); - } -#endif - break; - case EVENT_CMD_AUTOSAVE_INIT: - command_event(EVENT_CMD_AUTOSAVE_DEINIT, NULL); -#ifdef HAVE_THREADS - autosave_init(); -#endif - break; - case EVENT_CMD_AUTOSAVE_STATE: - event_save_auto_state(); - break; - case EVENT_CMD_AUDIO_STOP: - if (!audio_driver_alive()) - return false; - - if (!audio_driver_stop()) - return false; - break; - case EVENT_CMD_AUDIO_START: - if (audio_driver_alive()) - return false; - - if (!settings->audio.mute_enable && !audio_driver_start()) - { - RARCH_ERR("Failed to start audio driver. " - "Will continue without audio.\n"); - audio_driver_unset_active(); - } - break; - case EVENT_CMD_AUDIO_MUTE_TOGGLE: - { - const char *msg = !settings->audio.mute_enable ? - msg_hash_to_str(MSG_AUDIO_MUTED): - msg_hash_to_str(MSG_AUDIO_UNMUTED); - - if (!audio_driver_toggle_mute()) - { - RARCH_ERR("%s.\n", - msg_hash_to_str(MSG_FAILED_TO_UNMUTE_AUDIO)); - return false; - } - - runloop_msg_queue_push(msg, 1, 180, true); - RARCH_LOG("%s\n", msg); - } - break; - case EVENT_CMD_OVERLAY_DEINIT: -#ifdef HAVE_OVERLAY - input_overlay_free(); -#endif - break; - case EVENT_CMD_OVERLAY_INIT: - command_event(EVENT_CMD_OVERLAY_DEINIT, NULL); -#ifdef HAVE_OVERLAY - input_overlay_init(); -#endif - break; - case EVENT_CMD_OVERLAY_NEXT: -#ifdef HAVE_OVERLAY - input_overlay_next(settings->input.overlay_opacity); -#endif - break; - case EVENT_CMD_DSP_FILTER_DEINIT: - audio_driver_dsp_filter_free(); - break; - case EVENT_CMD_DSP_FILTER_INIT: - command_event(EVENT_CMD_DSP_FILTER_DEINIT, NULL); - if (!*settings->path.audio_dsp_plugin) - break; - audio_driver_dsp_filter_init(settings->path.audio_dsp_plugin); - break; - case EVENT_CMD_GPU_RECORD_DEINIT: - video_driver_gpu_record_deinit(); - break; - case EVENT_CMD_RECORD_DEINIT: - if (!recording_deinit()) - return false; - break; - case EVENT_CMD_RECORD_INIT: - command_event(EVENT_CMD_HISTORY_DEINIT, NULL); - if (!recording_init()) - return false; - break; - case EVENT_CMD_HISTORY_DEINIT: - if (g_defaults.history) - { - content_playlist_write_file(g_defaults.history); - content_playlist_free(g_defaults.history); - } - g_defaults.history = NULL; - break; - case EVENT_CMD_HISTORY_INIT: - command_event(EVENT_CMD_HISTORY_DEINIT, NULL); - if (!settings->history_list_enable) - return false; - RARCH_LOG("%s: [%s].\n", - msg_hash_to_str(MSG_LOADING_HISTORY_FILE), - settings->path.content_history); - g_defaults.history = content_playlist_init( - settings->path.content_history, - settings->content_history_size); - break; - case EVENT_CMD_CORE_INFO_DEINIT: - core_info_deinit_list(); - break; - case EVENT_CMD_CORE_INFO_INIT: - command_event(EVENT_CMD_CORE_INFO_DEINIT, NULL); - - if (*settings->directory.libretro) - core_info_init_list(); - break; - case EVENT_CMD_CORE_DEINIT: - { - struct retro_hw_render_callback *hwr = - video_driver_get_hw_context(); - event_deinit_core(true); - - if (hwr) - memset(hwr, 0, sizeof(*hwr)); - - break; - } - case EVENT_CMD_CORE_INIT: - if (!event_init_core((enum rarch_core_type*)data)) - return false; - break; - case EVENT_CMD_VIDEO_APPLY_STATE_CHANGES: - video_driver_apply_state_changes(); - break; - case EVENT_CMD_VIDEO_SET_NONBLOCKING_STATE: - boolean = true; /* fall-through */ - case EVENT_CMD_VIDEO_SET_BLOCKING_STATE: - video_driver_set_nonblock_state(boolean); - break; - case EVENT_CMD_VIDEO_SET_ASPECT_RATIO: - video_driver_set_aspect_ratio(); - break; - case EVENT_CMD_AUDIO_SET_NONBLOCKING_STATE: - boolean = true; /* fall-through */ - case EVENT_CMD_AUDIO_SET_BLOCKING_STATE: - audio_driver_set_nonblocking_state(boolean); - break; - case EVENT_CMD_OVERLAY_SET_SCALE_FACTOR: -#ifdef HAVE_OVERLAY - input_overlay_set_scale_factor(settings->input.overlay_scale); -#endif - break; - case EVENT_CMD_OVERLAY_SET_ALPHA_MOD: -#ifdef HAVE_OVERLAY - input_overlay_set_alpha_mod(settings->input.overlay_opacity); -#endif - break; - case EVENT_CMD_AUDIO_REINIT: - { - int flags = DRIVER_AUDIO; - driver_ctl(RARCH_DRIVER_CTL_UNINIT, &flags); - driver_ctl(RARCH_DRIVER_CTL_INIT, &flags); - } - break; - case EVENT_CMD_RESET_CONTEXT: - { - /* RARCH_DRIVER_CTL_UNINIT clears the callback struct so we - * need to make sure to keep a copy */ - struct retro_hw_render_callback *hwr = NULL; - struct retro_hw_render_callback hwr_copy; - int flags = DRIVERS_CMD_ALL; - - hwr = video_driver_get_hw_context(); - memcpy(&hwr_copy, hwr, sizeof(hwr_copy)); - - driver_ctl(RARCH_DRIVER_CTL_UNINIT, &flags); - - memcpy(hwr, &hwr_copy, sizeof(*hwr)); - - driver_ctl(RARCH_DRIVER_CTL_INIT, &flags); - } - break; - case EVENT_CMD_QUIT_RETROARCH: - rarch_ctl(RARCH_CTL_FORCE_QUIT, NULL); - break; - case EVENT_CMD_SHUTDOWN: -#if defined(__linux__) && !defined(ANDROID) - runloop_msg_queue_push("Shutting down...", 1, 180, true); - rarch_ctl(RARCH_CTL_FORCE_QUIT, NULL); - system("shutdown -P now"); -#endif - break; - case EVENT_CMD_REBOOT: -#if defined(__linux__) && !defined(ANDROID) - runloop_msg_queue_push("Rebooting...", 1, 180, true); - rarch_ctl(RARCH_CTL_FORCE_QUIT, NULL); - system("shutdown -r now"); -#endif - break; - case EVENT_CMD_RESUME: - rarch_ctl(RARCH_CTL_MENU_RUNNING_FINISHED, NULL); - if (ui_companion_is_on_foreground()) - ui_companion_driver_toggle(); - break; - case EVENT_CMD_RESTART_RETROARCH: - if (!frontend_driver_set_fork(FRONTEND_FORK_RESTART)) - return false; - break; - case EVENT_CMD_MENU_SAVE_CURRENT_CONFIG: - event_save_current_config(); - break; - case EVENT_CMD_MENU_SAVE_CONFIG: - if (!event_save_core_config()) - return false; - break; - case EVENT_CMD_SHADERS_APPLY_CHANGES: -#ifdef HAVE_MENU - menu_shader_manager_apply_changes(); -#endif - break; - case EVENT_CMD_PAUSE_CHECKS: - if (runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL)) - { - RARCH_LOG("%s\n", msg_hash_to_str(MSG_PAUSED)); - command_event(EVENT_CMD_AUDIO_STOP, NULL); - - if (settings->video.black_frame_insertion) - video_driver_cached_frame_render(); - } - else - { - RARCH_LOG("%s\n", msg_hash_to_str(MSG_UNPAUSED)); - command_event(EVENT_CMD_AUDIO_START, NULL); - } - break; - case EVENT_CMD_PAUSE_TOGGLE: - boolean = runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL); - boolean = !boolean; - runloop_ctl(RUNLOOP_CTL_SET_PAUSED, &boolean); - command_event(EVENT_CMD_PAUSE_CHECKS, NULL); - break; - case EVENT_CMD_UNPAUSE: - boolean = false; - - runloop_ctl(RUNLOOP_CTL_SET_PAUSED, &boolean); - command_event(EVENT_CMD_PAUSE_CHECKS, NULL); - break; - case EVENT_CMD_PAUSE: - boolean = true; - - runloop_ctl(RUNLOOP_CTL_SET_PAUSED, &boolean); - command_event(EVENT_CMD_PAUSE_CHECKS, NULL); - break; - case EVENT_CMD_MENU_PAUSE_LIBRETRO: -#ifdef HAVE_MENU - if (menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL)) - { - if (settings->menu.pause_libretro) - command_event(EVENT_CMD_AUDIO_STOP, NULL); - else - command_event(EVENT_CMD_AUDIO_START, NULL); - } - else - { - if (settings->menu.pause_libretro) - command_event(EVENT_CMD_AUDIO_START, NULL); - } -#endif - break; - case EVENT_CMD_SHADER_DIR_DEINIT: - runloop_ctl(RUNLOOP_CTL_SHADER_DIR_DEINIT, NULL); - break; - case EVENT_CMD_SHADER_DIR_INIT: - command_event(EVENT_CMD_SHADER_DIR_DEINIT, NULL); - - if (!runloop_ctl(RUNLOOP_CTL_SHADER_DIR_INIT, NULL)) - return false; - break; - case EVENT_CMD_SAVEFILES: - { - global_t *global = global_get_ptr(); - if (!global->savefiles || !global->sram.use) - return false; - - for (i = 0; i < global->savefiles->size; i++) - { - ram_type_t ram; - ram.type = global->savefiles->elems[i].attr.i; - ram.path = global->savefiles->elems[i].data; - - RARCH_LOG("%s #%u %s \"%s\".\n", - msg_hash_to_str(MSG_SAVING_RAM_TYPE), - ram.type, - msg_hash_to_str(MSG_TO), - ram.path); - content_save_ram_file(&ram); - } - } - return true; - case EVENT_CMD_SAVEFILES_DEINIT: - { - global_t *global = global_get_ptr(); - if (!global) - break; - - if (global->savefiles) - string_list_free(global->savefiles); - global->savefiles = NULL; - } - break; - case EVENT_CMD_SAVEFILES_INIT: - { - global_t *global = global_get_ptr(); - global->sram.use = global->sram.use && !global->sram.save_disable; -#ifdef HAVE_NETPLAY - global->sram.use = global->sram.use && - (!netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_DATA_INITED, NULL) - || !global->netplay.is_client); -#endif - - if (!global->sram.use) - RARCH_LOG("%s\n", - msg_hash_to_str(MSG_SRAM_WILL_NOT_BE_SAVED)); - - if (global->sram.use) - command_event(EVENT_CMD_AUTOSAVE_INIT, NULL); - } - break; - case EVENT_CMD_BSV_MOVIE_DEINIT: - bsv_movie_ctl(BSV_MOVIE_CTL_DEINIT, NULL); - break; - case EVENT_CMD_BSV_MOVIE_INIT: - command_event(EVENT_CMD_BSV_MOVIE_DEINIT, NULL); - bsv_movie_ctl(BSV_MOVIE_CTL_INIT, NULL); - break; - case EVENT_CMD_NETPLAY_DEINIT: -#ifdef HAVE_NETPLAY - deinit_netplay(); -#endif - break; - case EVENT_CMD_NETWORK_DEINIT: -#ifdef HAVE_NETWORKING - network_deinit(); -#endif - break; - case EVENT_CMD_NETWORK_INIT: -#ifdef HAVE_NETWORKING - network_init(); -#endif - break; - case EVENT_CMD_NETPLAY_INIT: - command_event(EVENT_CMD_NETPLAY_DEINIT, NULL); -#ifdef HAVE_NETPLAY - if (!init_netplay()) - return false; -#endif - break; - case EVENT_CMD_NETPLAY_FLIP_PLAYERS: -#ifdef HAVE_NETPLAY - netplay_driver_ctl(RARCH_NETPLAY_CTL_FLIP_PLAYERS, NULL); -#endif - break; - case EVENT_CMD_FULLSCREEN_TOGGLE: - if (!video_driver_has_windowed()) - return false; - - /* If we go fullscreen we drop all drivers and - * reinitialize to be safe. */ - settings->video.fullscreen = !settings->video.fullscreen; - command_event(EVENT_CMD_REINIT, NULL); - break; - case EVENT_CMD_COMMAND_DEINIT: - input_driver_deinit_command(); - break; - case EVENT_CMD_COMMAND_INIT: - command_event(EVENT_CMD_COMMAND_DEINIT, NULL); - input_driver_init_command(); - break; - case EVENT_CMD_REMOTE_DEINIT: - input_driver_deinit_remote(); - break; - case EVENT_CMD_REMOTE_INIT: - command_event(EVENT_CMD_REMOTE_DEINIT, NULL); - input_driver_init_remote(); - break; - case EVENT_CMD_TEMPORARY_CONTENT_DEINIT: - content_deinit(); - break; - case EVENT_CMD_SUBSYSTEM_FULLPATHS_DEINIT: - { - global_t *global = global_get_ptr(); - if (!global) - break; - - if (global->subsystem_fullpaths) - string_list_free(global->subsystem_fullpaths); - global->subsystem_fullpaths = NULL; - } - break; - case EVENT_CMD_LOG_FILE_DEINIT: - retro_main_log_file_deinit(); - break; - case EVENT_CMD_DISK_APPEND_IMAGE: - { - const char *path = (const char*)data; - if (string_is_empty(path)) - return false; - return event_disk_control_append_image(path); - } - case EVENT_CMD_DISK_EJECT_TOGGLE: - if (info && info->disk_control_cb.get_num_images) - { - const struct retro_disk_control_callback *control = - (const struct retro_disk_control_callback*) - &info->disk_control_cb; - - if (control) - { - bool new_state = !control->get_eject_state(); - event_disk_control_set_eject(new_state, true); - } - } - else - runloop_msg_queue_push( - msg_hash_to_str(MSG_CORE_DOES_NOT_SUPPORT_DISK_OPTIONS), - 1, 120, true); - break; - case EVENT_CMD_DISK_NEXT: - if (info && info->disk_control_cb.get_num_images) - { - const struct retro_disk_control_callback *control = - (const struct retro_disk_control_callback*) - &info->disk_control_cb; - - if (!control) - return false; - - if (!control->get_eject_state()) - return false; - - event_check_disk_next(control); - } - else - runloop_msg_queue_push( - msg_hash_to_str(MSG_CORE_DOES_NOT_SUPPORT_DISK_OPTIONS), - 1, 120, true); - break; - case EVENT_CMD_DISK_PREV: - if (info && info->disk_control_cb.get_num_images) - { - const struct retro_disk_control_callback *control = - (const struct retro_disk_control_callback*) - &info->disk_control_cb; - - if (!control) - return false; - - if (!control->get_eject_state()) - return false; - - event_check_disk_prev(control); - } - else - runloop_msg_queue_push( - msg_hash_to_str(MSG_CORE_DOES_NOT_SUPPORT_DISK_OPTIONS), - 1, 120, true); - break; - case EVENT_CMD_RUMBLE_STOP: - for (i = 0; i < MAX_USERS; i++) - { - input_driver_set_rumble_state(i, RETRO_RUMBLE_STRONG, 0); - input_driver_set_rumble_state(i, RETRO_RUMBLE_WEAK, 0); - } - break; - case EVENT_CMD_GRAB_MOUSE_TOGGLE: - { - bool ret = false; - static bool grab_mouse_state = false; - - grab_mouse_state = !grab_mouse_state; - - if (grab_mouse_state) - ret = input_driver_grab_mouse(); - else - ret = input_driver_ungrab_mouse(); - - if (!ret) - return false; - - RARCH_LOG("%s: %s.\n", - msg_hash_to_str(MSG_GRAB_MOUSE_STATE), - grab_mouse_state ? "yes" : "no"); - - if (grab_mouse_state) - video_driver_hide_mouse(); - else - video_driver_show_mouse(); - } - break; - case EVENT_CMD_PERFCNT_REPORT_FRONTEND_LOG: - rarch_perf_log(); - break; - case EVENT_CMD_VOLUME_UP: - event_set_volume(0.5f); - break; - case EVENT_CMD_VOLUME_DOWN: - event_set_volume(-0.5f); - break; - case EVENT_CMD_SET_FRAME_LIMIT: - runloop_ctl(RUNLOOP_CTL_SET_FRAME_LIMIT, NULL); - break; - case EVENT_CMD_EXEC: - return event_cmd_exec(data); - case EVENT_CMD_NONE: - default: - return false; - } - - return true; -} diff --git a/command_event.h b/command_event.h deleted file mode 100644 index d51832314a..0000000000 --- a/command_event.h +++ /dev/null @@ -1,225 +0,0 @@ -/* RetroArch - A frontend for libretro. - * 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. - * - * 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 COMMAND_EVENT_H__ -#define COMMAND_EVENT_H__ - -#include -#include - -#ifdef __cplusplus -extern "C" { -#endif - -enum event_command -{ - EVENT_CMD_NONE = 0, - /* Resets RetroArch. */ - EVENT_CMD_RESET, - /* Loads content file. */ - EVENT_CMD_LOAD_CONTENT, - EVENT_CMD_LOAD_CONTENT_PERSIST, -#ifdef HAVE_FFMPEG - EVENT_CMD_LOAD_CONTENT_FFMPEG, -#endif - EVENT_CMD_LOAD_CONTENT_IMAGEVIEWER, - EVENT_CMD_SET_PER_GAME_RESOLUTION, - EVENT_CMD_SET_FRAME_LIMIT, - /* Loads core. */ - EVENT_CMD_LOAD_CORE_DEINIT, - EVENT_CMD_LOAD_CORE, - EVENT_CMD_LOAD_CORE_PERSIST, - EVENT_CMD_UNLOAD_CORE, - EVENT_CMD_LOAD_STATE, - EVENT_CMD_SAVE_STATE, - EVENT_CMD_SAVE_STATE_DECREMENT, - EVENT_CMD_SAVE_STATE_INCREMENT, - /* Takes screenshot. */ - EVENT_CMD_TAKE_SCREENSHOT, - /* Quits RetroArch. */ - EVENT_CMD_QUIT, - /* Reinitialize all drivers. */ - EVENT_CMD_REINIT, - /* Toggles cheevos hardcore mode. */ - EVENT_CMD_CHEEVOS_HARDCORE_MODE_TOGGLE, - /* Deinitialize rewind. */ - EVENT_CMD_REWIND_DEINIT, - /* Initializes rewind. */ - EVENT_CMD_REWIND_INIT, - /* Toggles rewind. */ - EVENT_CMD_REWIND_TOGGLE, - /* Deinitializes autosave. */ - EVENT_CMD_AUTOSAVE_DEINIT, - /* Initializes autosave. */ - EVENT_CMD_AUTOSAVE_INIT, - EVENT_CMD_AUTOSAVE_STATE, - /* Stops audio. */ - EVENT_CMD_AUDIO_STOP, - /* Starts audio. */ - EVENT_CMD_AUDIO_START, - /* Mutes audio. */ - EVENT_CMD_AUDIO_MUTE_TOGGLE, - /* Initializes overlay. */ - EVENT_CMD_OVERLAY_INIT, - /* Deinitializes overlay. */ - EVENT_CMD_OVERLAY_DEINIT, - /* Sets current scale factor for overlay. */ - EVENT_CMD_OVERLAY_SET_SCALE_FACTOR, - /* Sets current alpha modulation for overlay. */ - EVENT_CMD_OVERLAY_SET_ALPHA_MOD, - /* Cycle to next overlay. */ - EVENT_CMD_OVERLAY_NEXT, - /* Deinitializes overlay. */ - EVENT_CMD_DSP_FILTER_INIT, - /* Deinitializes graphics filter. */ - EVENT_CMD_DSP_FILTER_DEINIT, - /* Deinitializes GPU recoring. */ - EVENT_CMD_GPU_RECORD_DEINIT, - /* Initializes recording system. */ - EVENT_CMD_RECORD_INIT, - /* Deinitializes recording system. */ - EVENT_CMD_RECORD_DEINIT, - /* Deinitializes history playlist. */ - EVENT_CMD_HISTORY_DEINIT, - /* Initializes history playlist. */ - EVENT_CMD_HISTORY_INIT, - /* Deinitializes core information. */ - EVENT_CMD_CORE_INFO_DEINIT, - /* Initializes core information. */ - EVENT_CMD_CORE_INFO_INIT, - /* Deinitializes core. */ - EVENT_CMD_CORE_DEINIT, - /* Initializes core. */ - EVENT_CMD_CORE_INIT, - /* Set audio blocking state. */ - EVENT_CMD_AUDIO_SET_BLOCKING_STATE, - /* Set audio nonblocking state. */ - EVENT_CMD_AUDIO_SET_NONBLOCKING_STATE, - /* Apply video state changes. */ - EVENT_CMD_VIDEO_APPLY_STATE_CHANGES, - /* Set video blocking state. */ - EVENT_CMD_VIDEO_SET_BLOCKING_STATE, - /* Set video nonblocking state. */ - EVENT_CMD_VIDEO_SET_NONBLOCKING_STATE, - /* Sets current aspect ratio index. */ - EVENT_CMD_VIDEO_SET_ASPECT_RATIO, - EVENT_CMD_RESET_CONTEXT, - /* Restarts RetroArch. */ - EVENT_CMD_RESTART_RETROARCH, - /* Force-quit RetroArch. */ - EVENT_CMD_QUIT_RETROARCH, - /* Shutdown the OS */ - EVENT_CMD_SHUTDOWN, - /* Reboot the OS */ - EVENT_CMD_REBOOT, - /* Resume RetroArch when in menu. */ - EVENT_CMD_RESUME, - /* Toggles pause. */ - EVENT_CMD_PAUSE_TOGGLE, - /* Pauses RetroArch. */ - EVENT_CMD_UNPAUSE, - /* Unpauses retroArch. */ - EVENT_CMD_PAUSE, - EVENT_CMD_PAUSE_CHECKS, - EVENT_CMD_MENU_SAVE_CURRENT_CONFIG, - EVENT_CMD_MENU_SAVE_CONFIG, - EVENT_CMD_MENU_PAUSE_LIBRETRO, - /* Toggles menu on/off. */ - EVENT_CMD_MENU_TOGGLE, - EVENT_CMD_MENU_REFRESH, - /* Applies shader changes. */ - EVENT_CMD_SHADERS_APPLY_CHANGES, - /* Initializes shader directory. */ - EVENT_CMD_SHADER_DIR_INIT, - /* Deinitializes shader directory. */ - EVENT_CMD_SHADER_DIR_DEINIT, - /* Initializes controllers. */ - EVENT_CMD_CONTROLLERS_INIT, - EVENT_CMD_SAVEFILES, - /* Initializes savefiles. */ - EVENT_CMD_SAVEFILES_INIT, - /* Deinitializes savefiles. */ - EVENT_CMD_SAVEFILES_DEINIT, - /* Initializes cheats. */ - EVENT_CMD_CHEATS_INIT, - /* Deinitializes cheats. */ - EVENT_CMD_CHEATS_DEINIT, - /* Apply cheats. */ - EVENT_CMD_CHEATS_APPLY, - /* Deinitializes network system. */ - EVENT_CMD_NETWORK_DEINIT, - /* Initializes network system. */ - EVENT_CMD_NETWORK_INIT, - /* Initializes netplay system. */ - EVENT_CMD_NETPLAY_INIT, - /* Deinitializes netplay system. */ - EVENT_CMD_NETPLAY_DEINIT, - /* Flip netplay players. */ - EVENT_CMD_NETPLAY_FLIP_PLAYERS, - /* Initializes BSV movie. */ - EVENT_CMD_BSV_MOVIE_INIT, - /* Deinitializes BSV movie. */ - EVENT_CMD_BSV_MOVIE_DEINIT, - /* Initializes command interface. */ - EVENT_CMD_COMMAND_INIT, - /* Deinitialize command interface. */ - EVENT_CMD_COMMAND_DEINIT, - /* Initializes remote gamepad interface. */ - EVENT_CMD_REMOTE_INIT, - /* Deinitializes remote gamepad interface. */ - EVENT_CMD_REMOTE_DEINIT, - /* Reinitializes audio driver. */ - EVENT_CMD_AUDIO_REINIT, - /* Resizes windowed scale. Will reinitialize video driver. */ - EVENT_CMD_RESIZE_WINDOWED_SCALE, - /* Deinitializes temporary content. */ - EVENT_CMD_TEMPORARY_CONTENT_DEINIT, - EVENT_CMD_SUBSYSTEM_FULLPATHS_DEINIT, - EVENT_CMD_LOG_FILE_DEINIT, - /* Toggles disk eject. */ - EVENT_CMD_DISK_EJECT_TOGGLE, - /* Cycle to next disk. */ - EVENT_CMD_DISK_NEXT, - /* Cycle to previous disk. */ - EVENT_CMD_DISK_PREV, - /* Appends disk image to disk image list. */ - EVENT_CMD_DISK_APPEND_IMAGE, - /* Stops rumbling. */ - EVENT_CMD_RUMBLE_STOP, - /* Toggles mouse grab. */ - EVENT_CMD_GRAB_MOUSE_TOGGLE, - /* Toggles fullscreen mode. */ - EVENT_CMD_FULLSCREEN_TOGGLE, - EVENT_CMD_PERFCNT_REPORT_FRONTEND_LOG, - EVENT_CMD_VOLUME_UP, - EVENT_CMD_VOLUME_DOWN, - EVENT_CMD_EXEC -}; - -/** - * event_command: - * @cmd : Command index. - * - * Performs RetroArch command with index @cmd. - * - * Returns: true (1) on success, otherwise false (0). - **/ -bool command_event(enum event_command action, void *data); - -#ifdef __cplusplus -} -#endif - -#endif diff --git a/content.c b/content.c index 82c58b81a1..c41c3e4e2d 100644 --- a/content.c +++ b/content.c @@ -61,7 +61,7 @@ #include "patch.h" #include "system.h" #include "retroarch.h" -#include "command_event.h" +#include "command.h" #include "file_path_special.h" #include "core.h" #include "verbosity.h" diff --git a/dynamic.c b/dynamic.c index 395f24cf52..5a857cd33a 100644 --- a/dynamic.c +++ b/dynamic.c @@ -30,7 +30,7 @@ #endif #include "dynamic.h" -#include "command_event.h" +#include "command.h" #include "audio/audio_driver.h" #include "camera/camera_driver.h" diff --git a/frontend/drivers/platform_emscripten.c b/frontend/drivers/platform_emscripten.c index 9d9d43bdaa..4deee94655 100644 --- a/frontend/drivers/platform_emscripten.c +++ b/frontend/drivers/platform_emscripten.c @@ -26,7 +26,7 @@ #include "../../retroarch.h" #include "../../runloop.h" #include "../frontend_driver.h" -#include "../../command_event.h" +#include "../../command.h" static void emscripten_mainloop(void) { diff --git a/gfx/drivers/ctr_gfx.c b/gfx/drivers/ctr_gfx.c index a9cae9880a..c24358bfeb 100644 --- a/gfx/drivers/ctr_gfx.c +++ b/gfx/drivers/ctr_gfx.c @@ -23,7 +23,7 @@ #include "ctr_gu.h" -#include "../../command_event.h" +#include "../../command.h" #include "../../general.h" #include "../../driver.h" diff --git a/gfx/video_driver.c b/gfx/video_driver.c index c711fa2cd5..cbfbecd223 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -37,7 +37,7 @@ #include "../list_special.h" #include "../core.h" #include "../system.h" -#include "../command_event.h" +#include "../command.h" #include "../msg_hash.h" #ifdef HAVE_MENU diff --git a/griffin/griffin.c b/griffin/griffin.c index 040ae67b99..62be59e8da 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -909,15 +909,11 @@ MENU #endif -#ifdef HAVE_COMMAND -#include "../command.c" -#endif - #ifdef HAVE_NETWORK_GAMEPAD #include "../input/input_remote.c" #endif -#include "../command_event.c" +#include "../command.c" #ifdef __cplusplus extern "C" { diff --git a/input/drivers_joypad/ctr_joypad.c b/input/drivers_joypad/ctr_joypad.c index 8f8621f523..dbe7e278b8 100644 --- a/input/drivers_joypad/ctr_joypad.c +++ b/input/drivers_joypad/ctr_joypad.c @@ -20,7 +20,7 @@ #include "../../general.h" #include "../../configuration.h" #include "../../retroarch.h" -#include "../../command_event.h" +#include "../../command.h" #include "string.h" #include "3ds.h" diff --git a/menu/menu_setting.h b/menu/menu_setting.h index 7f0c72394c..770821dc0e 100644 --- a/menu/menu_setting.h +++ b/menu/menu_setting.h @@ -21,7 +21,7 @@ #include #include -#include "../command_event.h" +#include "../command.h" #include "../input/input_driver.h" #ifdef __cplusplus diff --git a/network/netplay_private.h b/network/netplay_private.h index de6497b5d7..d1d7e8b489 100644 --- a/network/netplay_private.h +++ b/network/netplay_private.h @@ -17,9 +17,11 @@ #ifndef __RARCH_NETPLAY_PRIVATE_H #define __RARCH_NETPLAY_PRIVATE_H #include "netplay.h" + #include #include -#include "../command_event.h" + +#include "../command.h" #include "../general.h" #include "../autosave.h" #include "../dynamic.h" diff --git a/record/record_driver.c b/record/record_driver.c index 625bfbdca7..83ac334275 100644 --- a/record/record_driver.c +++ b/record/record_driver.c @@ -21,7 +21,7 @@ #include "record_driver.h" -#include "../command_event.h" +#include "../command.h" #include "../general.h" #include "../retroarch.h" #include "../verbosity.h" diff --git a/retroarch.c b/retroarch.c index cb2862d1c8..3ca465fa95 100644 --- a/retroarch.c +++ b/retroarch.c @@ -77,7 +77,7 @@ #endif #include "config.features.h" -#include "command_event.h" +#include "command.h" /* Descriptive names for options without short variant. * diff --git a/tasks/task_content.c b/tasks/task_content.c index c374098572..6bf6045a96 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -21,7 +21,7 @@ #include "tasks_internal.h" -#include "../command_event.h" +#include "../command.h" /* TODO/FIXME - turn this into actual task */ diff --git a/ui/ui_companion_driver.h b/ui/ui_companion_driver.h index 39f0cc31c8..b2467d31cd 100644 --- a/ui/ui_companion_driver.h +++ b/ui/ui_companion_driver.h @@ -26,7 +26,7 @@ #include "../config.h" #endif -#include "../command_event.h" +#include "../command.h" #ifdef __cplusplus extern "C" { From c6e65e16696bc53f5c91a4d898cbd7c747928e23 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 May 2016 20:41:59 +0200 Subject: [PATCH 342/498] Rename functions --- command.c | 94 +++++++++++++++++++++++++++---------------------------- 1 file changed, 47 insertions(+), 47 deletions(-) diff --git a/command.c b/command.c index c1e5140e0a..57b688764c 100644 --- a/command.c +++ b/command.c @@ -702,7 +702,7 @@ bool command_get(command_handle_t *handle) #endif /** - * event_disk_control_set_eject: + * command_event_disk_control_set_eject: * @new_state : Eject or close the virtual drive tray. * false (0) : Close * true (1) : Eject @@ -710,7 +710,7 @@ bool command_get(command_handle_t *handle) * * Ejects/closes of the virtual drive tray. **/ -static void event_disk_control_set_eject(bool new_state, bool print_log) +static void command_event_disk_control_set_eject(bool new_state, bool print_log) { char msg[128] = {0}; bool error = false; @@ -752,12 +752,12 @@ static void event_disk_control_set_eject(bool new_state, bool print_log) } /** - * event_disk_control_set_index: + * command_event_disk_control_set_index: * @idx : Index of disk to set as current. * * Sets current disk to @index. **/ -static void event_disk_control_set_index(unsigned idx) +static void command_event_disk_control_set_index(unsigned idx) { unsigned num_disks; bool error = false; @@ -808,12 +808,12 @@ static void event_disk_control_set_index(unsigned idx) } /** - * event_disk_control_append_image: + * command_event_disk_control_append_image: * @path : Path to disk image. * * Appends disk image to disk image list. **/ -static bool event_disk_control_append_image(const char *path) +static bool command_event_disk_control_append_image(const char *path) { unsigned new_idx; char msg[128] = {0}; @@ -831,7 +831,7 @@ static bool event_disk_control_append_image(const char *path) if (!control) return false; - event_disk_control_set_eject(true, false); + command_event_disk_control_set_eject(true, false); control->add_image_index(); new_idx = control->get_num_images(); @@ -861,19 +861,19 @@ static bool event_disk_control_append_image(const char *path) } command_event(EVENT_CMD_AUTOSAVE_INIT, NULL); - event_disk_control_set_index(new_idx); - event_disk_control_set_eject(false, false); + command_event_disk_control_set_index(new_idx); + command_event_disk_control_set_eject(false, false); return true; } /** - * event_check_disk_prev: + * command_event_check_disk_prev: * @control : Handle to disk control handle. * * Perform disk cycle to previous index action (Core Disk Options). **/ -static void event_check_disk_prev( +static void command_event_check_disk_prev( const struct retro_disk_control_callback *control) { unsigned num_disks = 0; @@ -897,16 +897,16 @@ static void event_check_disk_prev( if (current > 0) current--; - event_disk_control_set_index(current); + command_event_disk_control_set_index(current); } /** - * event_check_disk_next: + * command_event_check_disk_next: * @control : Handle to disk control handle. * * Perform disk cycle to next index action (Core Disk Options). **/ -static void event_check_disk_next( +static void command_event_check_disk_next( const struct retro_disk_control_callback *control) { unsigned num_disks = 0; @@ -930,7 +930,7 @@ static void event_check_disk_next( if (current < num_disks - 1) current++; - event_disk_control_set_index(current); + command_event_disk_control_set_index(current); } /** @@ -940,7 +940,7 @@ static void event_check_disk_next( * Adjusts the current audio volume level. * **/ -static void event_set_volume(float gain) +static void command_event_set_volume(float gain) { char msg[128]; settings_t *settings = config_get_ptr(); @@ -957,11 +957,11 @@ static void event_set_volume(float gain) } /** - * event_init_controllers: + * command_event_init_controllers: * * Initialize libretro controllers. **/ -static void event_init_controllers(void) +static void command_event_init_controllers(void) { unsigned i; settings_t *settings = config_get_ptr(); @@ -1029,7 +1029,7 @@ static void event_init_controllers(void) } } -static void event_deinit_core(bool reinit) +static void command_event_deinit_core(bool reinit) { #ifdef HAVE_CHEEVOS cheevos_unload(); @@ -1052,7 +1052,7 @@ static void event_deinit_core(bool reinit) } } -static void event_init_cheats(void) +static void command_event_init_cheats(void) { bool allow_cheats = true; #ifdef HAVE_NETPLAY @@ -1089,7 +1089,7 @@ static bool event_load_save_files(void) return true; } -static void event_load_auto_state(void) +static void command_event_load_auto_state(void) { bool ret; char msg[128] = {0}; @@ -1126,7 +1126,7 @@ static void event_load_auto_state(void) RARCH_LOG("%s\n", msg); } -static void event_set_savestate_auto_index(void) +static void command_event_set_savestate_auto_index(void) { size_t i; char state_dir[PATH_MAX_LENGTH] = {0}; @@ -1199,13 +1199,13 @@ static bool event_init_content(void) if (content_does_not_need_content()) return true; - event_set_savestate_auto_index(); + command_event_set_savestate_auto_index(); if (event_load_save_files()) RARCH_LOG("%s.\n", msg_hash_to_str(MSG_SKIPPING_SRAM_LOAD)); - event_load_auto_state(); + command_event_load_auto_state(); command_event(EVENT_CMD_BSV_MOVIE_INIT, NULL); command_event(EVENT_CMD_NETPLAY_INIT, NULL); @@ -1286,14 +1286,14 @@ static bool event_save_auto_state(void) } /** - * event_save_core_config: + * command_event_save_core_config: * * Saves a new (core) configuration to a file. Filename is based * on heuristics to avoid typing. * * Returns: true (1) on success, otherwise false (0). **/ -static bool event_save_core_config(void) +static bool command_event_save_core_config(void) { char config_dir[PATH_MAX_LENGTH] = {0}; char config_name[PATH_MAX_LENGTH] = {0}; @@ -1399,7 +1399,7 @@ static bool event_save_core_config(void) * Saves current configuration file to disk, and (optionally) * autosave state. **/ -void event_save_current_config(void) +void command_event_save_current_config(void) { char msg[128]; settings_t *settings = config_get_ptr(); @@ -1444,7 +1444,7 @@ void event_save_current_config(void) * * Saves a state with path being @path. **/ -static void event_save_state(const char *path, +static void command_event_save_state(const char *path, char *s, size_t len) { settings_t *settings = config_get_ptr(); @@ -1473,7 +1473,7 @@ static void event_save_state(const char *path, * * Loads a state with path being @path. **/ -static void event_load_state(const char *path, char *s, size_t len) +static void command_event_load_state(const char *path, char *s, size_t len) { settings_t *settings = config_get_ptr(); @@ -1493,7 +1493,7 @@ static void event_load_state(const char *path, char *s, size_t len) settings->state_slot); } -static void event_main_state(unsigned cmd) +static void command_event_main_state(unsigned cmd) { retro_ctx_size_info_t info; char path[PATH_MAX_LENGTH] = {0}; @@ -1517,10 +1517,10 @@ static void event_main_state(unsigned cmd) switch (cmd) { case EVENT_CMD_SAVE_STATE: - event_save_state(path, msg, sizeof(msg)); + command_event_save_state(path, msg, sizeof(msg)); break; case EVENT_CMD_LOAD_STATE: - event_load_state(path, msg, sizeof(msg)); + command_event_load_state(path, msg, sizeof(msg)); break; } } @@ -1532,7 +1532,7 @@ static void event_main_state(unsigned cmd) RARCH_LOG("%s\n", msg); } -static bool event_cmd_exec(void *data) +static bool command_event_cmd_exec(void *data) { char *fullpath = NULL; @@ -1689,7 +1689,7 @@ bool command_event(enum event_command cmd, void *data) return false; #endif - event_main_state(cmd); + command_event_main_state(cmd); break; case EVENT_CMD_RESIZE_WINDOWED_SCALE: { @@ -1718,7 +1718,7 @@ bool command_event(enum event_command cmd, void *data) #endif break; case EVENT_CMD_CONTROLLERS_INIT: - event_init_controllers(); + command_event_init_controllers(); break; case EVENT_CMD_RESET: RARCH_LOG("%s.\n", msg_hash_to_str(MSG_RESET)); @@ -1738,7 +1738,7 @@ bool command_event(enum event_command cmd, void *data) if (settings->savestate_auto_index) settings->state_slot++; - event_main_state(cmd); + command_event_main_state(cmd); break; case EVENT_CMD_SAVE_STATE_DECREMENT: /* Slot -1 is (auto) slot. */ @@ -1793,7 +1793,7 @@ bool command_event(enum event_command cmd, void *data) break; case EVENT_CMD_CHEATS_INIT: command_event(EVENT_CMD_CHEATS_DEINIT, NULL); - event_init_cheats(); + command_event_init_cheats(); break; case EVENT_CMD_CHEATS_APPLY: cheat_manager_apply_cheats(); @@ -1949,7 +1949,7 @@ bool command_event(enum event_command cmd, void *data) { struct retro_hw_render_callback *hwr = video_driver_get_hw_context(); - event_deinit_core(true); + command_event_deinit_core(true); if (hwr) memset(hwr, 0, sizeof(*hwr)); @@ -2038,10 +2038,10 @@ bool command_event(enum event_command cmd, void *data) return false; break; case EVENT_CMD_MENU_SAVE_CURRENT_CONFIG: - event_save_current_config(); + command_event_save_current_config(); break; case EVENT_CMD_MENU_SAVE_CONFIG: - if (!event_save_core_config()) + if (!command_event_save_core_config()) return false; break; case EVENT_CMD_SHADERS_APPLY_CHANGES: @@ -2236,7 +2236,7 @@ bool command_event(enum event_command cmd, void *data) const char *path = (const char*)data; if (string_is_empty(path)) return false; - return event_disk_control_append_image(path); + return command_event_disk_control_append_image(path); } case EVENT_CMD_DISK_EJECT_TOGGLE: if (info && info->disk_control_cb.get_num_images) @@ -2248,7 +2248,7 @@ bool command_event(enum event_command cmd, void *data) if (control) { bool new_state = !control->get_eject_state(); - event_disk_control_set_eject(new_state, true); + command_event_disk_control_set_eject(new_state, true); } } else @@ -2269,7 +2269,7 @@ bool command_event(enum event_command cmd, void *data) if (!control->get_eject_state()) return false; - event_check_disk_next(control); + command_event_check_disk_next(control); } else runloop_msg_queue_push( @@ -2289,7 +2289,7 @@ bool command_event(enum event_command cmd, void *data) if (!control->get_eject_state()) return false; - event_check_disk_prev(control); + command_event_check_disk_prev(control); } else runloop_msg_queue_push( @@ -2332,16 +2332,16 @@ bool command_event(enum event_command cmd, void *data) rarch_perf_log(); break; case EVENT_CMD_VOLUME_UP: - event_set_volume(0.5f); + command_event_set_volume(0.5f); break; case EVENT_CMD_VOLUME_DOWN: - event_set_volume(-0.5f); + command_event_set_volume(-0.5f); break; case EVENT_CMD_SET_FRAME_LIMIT: runloop_ctl(RUNLOOP_CTL_SET_FRAME_LIMIT, NULL); break; case EVENT_CMD_EXEC: - return event_cmd_exec(data); + return command_event_cmd_exec(data); case EVENT_CMD_NONE: default: return false; From 2691ab0c7d93c541a14162658c6f11e433c86bd7 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 May 2016 20:51:53 +0200 Subject: [PATCH 343/498] Rename command_event enums --- audio/audio_driver.c | 10 +- cheevos.c | 6 +- command.c | 290 ++++++++++++------------- command.h | 208 +++++++++--------- content.c | 6 +- driver.c | 12 +- dynamic.c | 2 +- frontend/drivers/platform_ctr.c | 2 +- frontend/drivers/platform_emscripten.c | 8 +- frontend/drivers/platform_psp.c | 2 +- frontend/frontend.c | 4 +- gfx/drivers/ctr_gfx.c | 4 +- gfx/video_driver.c | 14 +- input/drivers/android_input.c | 4 +- input/drivers_joypad/ctr_joypad.c | 2 +- menu/cbs/menu_cbs_left.c | 2 +- menu/cbs/menu_cbs_ok.c | 48 ++-- menu/cbs/menu_cbs_right.c | 2 +- menu/cbs/menu_cbs_start.c | 2 +- menu/drivers/nuklear.c | 2 +- menu/drivers/zarch.c | 2 +- menu/menu_content.c | 4 +- menu/menu_displaylist.c | 2 +- menu/menu_driver.c | 16 +- menu/menu_setting.c | 88 ++++---- network/netplay.c | 6 +- record/record_driver.c | 8 +- retroarch.c | 58 ++--- runloop.c | 58 ++--- tasks/task_content.c | 12 +- ui/drivers/ui_cocoa.m | 32 +-- ui/drivers/ui_cocoatouch.m | 8 +- ui/drivers/ui_win32.c | 34 +-- 33 files changed, 479 insertions(+), 479 deletions(-) diff --git a/audio/audio_driver.c b/audio/audio_driver.c index 1ef8145a3c..0239b80e00 100644 --- a/audio/audio_driver.c +++ b/audio/audio_driver.c @@ -297,7 +297,7 @@ static bool uninit_audio(void) free(audio_driver_data.output_samples.buf); audio_driver_data.output_samples.buf = NULL; - command_event(EVENT_CMD_DSP_FILTER_DEINIT, NULL); + command_event(CMD_EVENT_DSP_FILTER_DEINIT, NULL); compute_audio_buffer_statistics(); @@ -380,7 +380,7 @@ static bool audio_driver_init_internal(bool audio_cb_inited) if (!settings->audio.sync && audio_driver_is_active()) { - command_event(EVENT_CMD_AUDIO_SET_NONBLOCKING_STATE, NULL); + command_event(CMD_EVENT_AUDIO_SET_NONBLOCKING_STATE, NULL); audio_driver_data.chunk.size = audio_driver_data.chunk.nonblock_size; } @@ -438,7 +438,7 @@ static bool audio_driver_init_internal(bool audio_cb_inited) RARCH_WARN("Audio rate control was desired, but driver does not support needed features.\n"); } - command_event(EVENT_CMD_DSP_FILTER_INIT, NULL); + command_event(CMD_EVENT_DSP_FILTER_INIT, NULL); audio_driver_data.free_samples.count = 0; @@ -928,8 +928,8 @@ bool audio_driver_toggle_mute(void) settings->audio.mute_enable = !settings->audio.mute_enable; if (settings->audio.mute_enable) - command_event(EVENT_CMD_AUDIO_STOP, NULL); - else if (!command_event(EVENT_CMD_AUDIO_START, NULL)) + command_event(CMD_EVENT_AUDIO_STOP, NULL); + else if (!command_event(CMD_EVENT_AUDIO_START, NULL)) { audio_driver_unset_active(); return false; diff --git a/cheevos.c b/cheevos.c index c3bc001a5f..e4358f8b7d 100644 --- a/cheevos.c +++ b/cheevos.c @@ -2214,9 +2214,9 @@ bool cheevos_toggle_hardcore_mode(void) if (settings->cheevos.hardcore_mode_enable) { /* send reset core cmd to avoid any user savestate previusly loaded */ - command_event(EVENT_CMD_RESET, NULL); + command_event(CMD_EVENT_RESET, NULL); if (settings->rewind_enable) - command_event(EVENT_CMD_REWIND_DEINIT, NULL); + command_event(CMD_EVENT_REWIND_DEINIT, NULL); RARCH_LOG("%s\n", msg_hash_to_str(MSG_CHEEVOS_HARDCORE_MODE_ENABLE)); runloop_msg_queue_push(msg_hash_to_str(MSG_CHEEVOS_HARDCORE_MODE_ENABLE), 0, 3 * 60, true); @@ -2224,7 +2224,7 @@ bool cheevos_toggle_hardcore_mode(void) else { if (settings->rewind_enable) - command_event(EVENT_CMD_REWIND_INIT, NULL); + command_event(CMD_EVENT_REWIND_INIT, NULL); } return true; diff --git a/command.c b/command.c index 57b688764c..9052d64947 100644 --- a/command.c +++ b/command.c @@ -847,7 +847,7 @@ static bool command_event_disk_control_append_image(const char *path) RARCH_LOG("%s\n", msg); runloop_msg_queue_push(msg, 0, 180, true); - command_event(EVENT_CMD_AUTOSAVE_DEINIT, NULL); + command_event(CMD_EVENT_AUTOSAVE_DEINIT, NULL); /* TODO: Need to figure out what to do with subsystems case. */ if (!*global->subsystem) @@ -860,7 +860,7 @@ static bool command_event_disk_control_append_image(const char *path) rarch_ctl(RARCH_CTL_FILL_PATHNAMES, NULL); } - command_event(EVENT_CMD_AUTOSAVE_INIT, NULL); + command_event(CMD_EVENT_AUTOSAVE_INIT, NULL); command_event_disk_control_set_index(new_idx); command_event_disk_control_set_eject(false, false); @@ -1206,8 +1206,8 @@ static bool event_init_content(void) msg_hash_to_str(MSG_SKIPPING_SRAM_LOAD)); command_event_load_auto_state(); - command_event(EVENT_CMD_BSV_MOVIE_INIT, NULL); - command_event(EVENT_CMD_NETPLAY_INIT, NULL); + command_event(CMD_EVENT_BSV_MOVIE_INIT, NULL); + command_event(CMD_EVENT_NETPLAY_INIT, NULL); return true; } @@ -1516,10 +1516,10 @@ static void command_event_main_state(unsigned cmd) { switch (cmd) { - case EVENT_CMD_SAVE_STATE: + case CMD_EVENT_SAVE_STATE: command_event_save_state(path, msg, sizeof(msg)); break; - case EVENT_CMD_LOAD_STATE: + case CMD_EVENT_LOAD_STATE: command_event_load_state(path, msg, sizeof(msg)); break; } @@ -1576,17 +1576,17 @@ bool command_event(enum event_command cmd, void *data) switch (cmd) { - case EVENT_CMD_MENU_REFRESH: + case CMD_EVENT_MENU_REFRESH: #ifdef HAVE_MENU menu_driver_ctl(RARCH_MENU_CTL_REFRESH, NULL); #endif break; - case EVENT_CMD_SET_PER_GAME_RESOLUTION: + case CMD_EVENT_SET_PER_GAME_RESOLUTION: #if defined(GEKKO) { unsigned width = 0, height = 0; - command_event(EVENT_CMD_VIDEO_SET_ASPECT_RATIO, NULL); + command_event(CMD_EVENT_VIDEO_SET_ASPECT_RATIO, NULL); if (video_driver_get_video_output_size(&width, &height)) { @@ -1603,40 +1603,40 @@ bool command_event(enum event_command cmd, void *data) } #endif break; - case EVENT_CMD_LOAD_CONTENT_PERSIST: + case CMD_EVENT_LOAD_CONTENT_PERSIST: #ifdef HAVE_DYNAMIC - command_event(EVENT_CMD_LOAD_CORE, NULL); + command_event(CMD_EVENT_LOAD_CORE, NULL); #endif rarch_ctl(RARCH_CTL_LOAD_CONTENT, NULL); break; #ifdef HAVE_FFMPEG - case EVENT_CMD_LOAD_CONTENT_FFMPEG: + case CMD_EVENT_LOAD_CONTENT_FFMPEG: rarch_ctl(RARCH_CTL_LOAD_CONTENT_FFMPEG, NULL); break; #endif - case EVENT_CMD_LOAD_CONTENT_IMAGEVIEWER: + case CMD_EVENT_LOAD_CONTENT_IMAGEVIEWER: rarch_ctl(RARCH_CTL_LOAD_CONTENT_IMAGEVIEWER, NULL); break; - case EVENT_CMD_LOAD_CONTENT: + case CMD_EVENT_LOAD_CONTENT: { #ifdef HAVE_DYNAMIC - command_event(EVENT_CMD_LOAD_CONTENT_PERSIST, NULL); + command_event(CMD_EVENT_LOAD_CONTENT_PERSIST, NULL); #else char *fullpath = NULL; runloop_ctl(RUNLOOP_CTL_GET_CONTENT_PATH, &fullpath); runloop_ctl(RUNLOOP_CTL_SET_LIBRETRO_PATH, settings->path.libretro); - command_event(EVENT_CMD_EXEC, (void*)fullpath); - command_event(EVENT_CMD_QUIT, NULL); + command_event(CMD_EVENT_EXEC, (void*)fullpath); + command_event(CMD_EVENT_QUIT, NULL); #endif } break; - case EVENT_CMD_LOAD_CORE_DEINIT: + case CMD_EVENT_LOAD_CORE_DEINIT: #ifdef HAVE_MENU menu_driver_ctl(RARCH_MENU_CTL_SYSTEM_INFO_DEINIT, NULL); #endif break; - case EVENT_CMD_LOAD_CORE_PERSIST: - command_event(EVENT_CMD_LOAD_CORE_DEINIT, NULL); + case CMD_EVENT_LOAD_CORE_PERSIST: + command_event(CMD_EVENT_LOAD_CORE_DEINIT, NULL); { #ifdef HAVE_MENU bool *ptr = NULL; @@ -1667,13 +1667,13 @@ bool command_event(enum event_command cmd, void *data) #endif } break; - case EVENT_CMD_LOAD_CORE: - command_event(EVENT_CMD_LOAD_CORE_PERSIST, NULL); + case CMD_EVENT_LOAD_CORE: + command_event(CMD_EVENT_LOAD_CORE_PERSIST, NULL); #ifndef HAVE_DYNAMIC - command_event(EVENT_CMD_QUIT, NULL); + command_event(CMD_EVENT_QUIT, NULL); #endif break; - case EVENT_CMD_LOAD_STATE: + case CMD_EVENT_LOAD_STATE: /* Immutable - disallow savestate load when * we absolutely cannot change game state. */ if (bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL)) @@ -1691,7 +1691,7 @@ bool command_event(enum event_command cmd, void *data) command_event_main_state(cmd); break; - case EVENT_CMD_RESIZE_WINDOWED_SCALE: + case CMD_EVENT_RESIZE_WINDOWED_SCALE: { unsigned idx = 0; unsigned *window_scale = NULL; @@ -1704,12 +1704,12 @@ bool command_event(enum event_command cmd, void *data) settings->video.scale = *window_scale; if (!settings->video.fullscreen) - command_event(EVENT_CMD_REINIT, NULL); + command_event(CMD_EVENT_REINIT, NULL); runloop_ctl(RUNLOOP_CTL_SET_WINDOWED_SCALE, &idx); } break; - case EVENT_CMD_MENU_TOGGLE: + case CMD_EVENT_MENU_TOGGLE: #ifdef HAVE_MENU if (menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL)) rarch_ctl(RARCH_CTL_MENU_RUNNING_FINISHED, NULL); @@ -1717,10 +1717,10 @@ bool command_event(enum event_command cmd, void *data) rarch_ctl(RARCH_CTL_MENU_RUNNING, NULL); #endif break; - case EVENT_CMD_CONTROLLERS_INIT: + case CMD_EVENT_CONTROLLERS_INIT: command_event_init_controllers(); break; - case EVENT_CMD_RESET: + case CMD_EVENT_RESET: RARCH_LOG("%s.\n", msg_hash_to_str(MSG_RESET)); runloop_msg_queue_push(msg_hash_to_str(MSG_RESET), 1, 120, true); @@ -1729,7 +1729,7 @@ bool command_event(enum event_command cmd, void *data) #endif core_reset(); break; - case EVENT_CMD_SAVE_STATE: + case CMD_EVENT_SAVE_STATE: #ifdef HAVE_CHEEVOS if (settings->cheevos.hardcore_mode_enable) return false; @@ -1740,31 +1740,31 @@ bool command_event(enum event_command cmd, void *data) command_event_main_state(cmd); break; - case EVENT_CMD_SAVE_STATE_DECREMENT: + case CMD_EVENT_SAVE_STATE_DECREMENT: /* Slot -1 is (auto) slot. */ if (settings->state_slot >= 0) settings->state_slot--; break; - case EVENT_CMD_SAVE_STATE_INCREMENT: + case CMD_EVENT_SAVE_STATE_INCREMENT: settings->state_slot++; break; - case EVENT_CMD_TAKE_SCREENSHOT: + case CMD_EVENT_TAKE_SCREENSHOT: if (!take_screenshot()) return false; break; - case EVENT_CMD_UNLOAD_CORE: + case CMD_EVENT_UNLOAD_CORE: runloop_ctl(RUNLOOP_CTL_PREPARE_DUMMY, NULL); - command_event(EVENT_CMD_LOAD_CORE_DEINIT, NULL); + command_event(CMD_EVENT_LOAD_CORE_DEINIT, NULL); break; - case EVENT_CMD_QUIT: + case CMD_EVENT_QUIT: rarch_ctl(RARCH_CTL_QUIT, NULL); break; - case EVENT_CMD_CHEEVOS_HARDCORE_MODE_TOGGLE: + case CMD_EVENT_CHEEVOS_HARDCORE_MODE_TOGGLE: #ifdef HAVE_CHEEVOS cheevos_toggle_hardcore_mode(); #endif break; - case EVENT_CMD_REINIT: + case CMD_EVENT_REINIT: { struct retro_hw_render_callback *hwr = video_driver_get_hw_context(); @@ -1775,7 +1775,7 @@ bool command_event(enum event_command cmd, void *data) video_driver_unset_video_cache_context(); video_driver_unset_video_cache_context_ack(); - command_event(EVENT_CMD_RESET_CONTEXT, NULL); + command_event(CMD_EVENT_RESET_CONTEXT, NULL); video_driver_unset_video_cache_context(); /* Poll input to avoid possibly stale data to corrupt things. */ @@ -1784,21 +1784,21 @@ bool command_event(enum event_command cmd, void *data) #ifdef HAVE_MENU menu_display_set_framebuffer_dirty_flag(); if (menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL)) - command_event(EVENT_CMD_VIDEO_SET_BLOCKING_STATE, NULL); + command_event(CMD_EVENT_VIDEO_SET_BLOCKING_STATE, NULL); #endif } break; - case EVENT_CMD_CHEATS_DEINIT: + case CMD_EVENT_CHEATS_DEINIT: cheat_manager_state_free(); break; - case EVENT_CMD_CHEATS_INIT: - command_event(EVENT_CMD_CHEATS_DEINIT, NULL); + case CMD_EVENT_CHEATS_INIT: + command_event(CMD_EVENT_CHEATS_DEINIT, NULL); command_event_init_cheats(); break; - case EVENT_CMD_CHEATS_APPLY: + case CMD_EVENT_CHEATS_APPLY: cheat_manager_apply_cheats(); break; - case EVENT_CMD_REWIND_DEINIT: + case CMD_EVENT_REWIND_DEINIT: #ifdef HAVE_NETPLAY if (netplay_driver_ctl(RARCH_NETPLAY_CTL_IS_DATA_INITED, NULL)) return false; @@ -1810,7 +1810,7 @@ bool command_event(enum event_command cmd, void *data) state_manager_event_deinit(); break; - case EVENT_CMD_REWIND_INIT: + case CMD_EVENT_REWIND_INIT: #ifdef HAVE_CHEEVOS if (settings->cheevos.hardcore_mode_enable) return false; @@ -1820,13 +1820,13 @@ bool command_event(enum event_command cmd, void *data) #endif state_manager_event_init(); break; - case EVENT_CMD_REWIND_TOGGLE: + case CMD_EVENT_REWIND_TOGGLE: if (settings->rewind_enable) - command_event(EVENT_CMD_REWIND_INIT, NULL); + command_event(CMD_EVENT_REWIND_INIT, NULL); else - command_event(EVENT_CMD_REWIND_DEINIT, NULL); + command_event(CMD_EVENT_REWIND_DEINIT, NULL); break; - case EVENT_CMD_AUTOSAVE_DEINIT: + case CMD_EVENT_AUTOSAVE_DEINIT: #ifdef HAVE_THREADS { global_t *global = global_get_ptr(); @@ -1836,23 +1836,23 @@ bool command_event(enum event_command cmd, void *data) } #endif break; - case EVENT_CMD_AUTOSAVE_INIT: - command_event(EVENT_CMD_AUTOSAVE_DEINIT, NULL); + case CMD_EVENT_AUTOSAVE_INIT: + command_event(CMD_EVENT_AUTOSAVE_DEINIT, NULL); #ifdef HAVE_THREADS autosave_init(); #endif break; - case EVENT_CMD_AUTOSAVE_STATE: + case CMD_EVENT_AUTOSAVE_STATE: event_save_auto_state(); break; - case EVENT_CMD_AUDIO_STOP: + case CMD_EVENT_AUDIO_STOP: if (!audio_driver_alive()) return false; if (!audio_driver_stop()) return false; break; - case EVENT_CMD_AUDIO_START: + case CMD_EVENT_AUDIO_START: if (audio_driver_alive()) return false; @@ -1863,7 +1863,7 @@ bool command_event(enum event_command cmd, void *data) audio_driver_unset_active(); } break; - case EVENT_CMD_AUDIO_MUTE_TOGGLE: + case CMD_EVENT_AUDIO_MUTE_TOGGLE: { const char *msg = !settings->audio.mute_enable ? msg_hash_to_str(MSG_AUDIO_MUTED): @@ -1880,44 +1880,44 @@ bool command_event(enum event_command cmd, void *data) RARCH_LOG("%s\n", msg); } break; - case EVENT_CMD_OVERLAY_DEINIT: + case CMD_EVENT_OVERLAY_DEINIT: #ifdef HAVE_OVERLAY input_overlay_free(); #endif break; - case EVENT_CMD_OVERLAY_INIT: - command_event(EVENT_CMD_OVERLAY_DEINIT, NULL); + case CMD_EVENT_OVERLAY_INIT: + command_event(CMD_EVENT_OVERLAY_DEINIT, NULL); #ifdef HAVE_OVERLAY input_overlay_init(); #endif break; - case EVENT_CMD_OVERLAY_NEXT: + case CMD_EVENT_OVERLAY_NEXT: #ifdef HAVE_OVERLAY input_overlay_next(settings->input.overlay_opacity); #endif break; - case EVENT_CMD_DSP_FILTER_DEINIT: + case CMD_EVENT_DSP_FILTER_DEINIT: audio_driver_dsp_filter_free(); break; - case EVENT_CMD_DSP_FILTER_INIT: - command_event(EVENT_CMD_DSP_FILTER_DEINIT, NULL); + case CMD_EVENT_DSP_FILTER_INIT: + command_event(CMD_EVENT_DSP_FILTER_DEINIT, NULL); if (!*settings->path.audio_dsp_plugin) break; audio_driver_dsp_filter_init(settings->path.audio_dsp_plugin); break; - case EVENT_CMD_GPU_RECORD_DEINIT: + case CMD_EVENT_GPU_RECORD_DEINIT: video_driver_gpu_record_deinit(); break; - case EVENT_CMD_RECORD_DEINIT: + case CMD_EVENT_RECORD_DEINIT: if (!recording_deinit()) return false; break; - case EVENT_CMD_RECORD_INIT: - command_event(EVENT_CMD_HISTORY_DEINIT, NULL); + case CMD_EVENT_RECORD_INIT: + command_event(CMD_EVENT_HISTORY_DEINIT, NULL); if (!recording_init()) return false; break; - case EVENT_CMD_HISTORY_DEINIT: + case CMD_EVENT_HISTORY_DEINIT: if (g_defaults.history) { content_playlist_write_file(g_defaults.history); @@ -1925,8 +1925,8 @@ bool command_event(enum event_command cmd, void *data) } g_defaults.history = NULL; break; - case EVENT_CMD_HISTORY_INIT: - command_event(EVENT_CMD_HISTORY_DEINIT, NULL); + case CMD_EVENT_HISTORY_INIT: + command_event(CMD_EVENT_HISTORY_DEINIT, NULL); if (!settings->history_list_enable) return false; RARCH_LOG("%s: [%s].\n", @@ -1936,16 +1936,16 @@ bool command_event(enum event_command cmd, void *data) settings->path.content_history, settings->content_history_size); break; - case EVENT_CMD_CORE_INFO_DEINIT: + case CMD_EVENT_CORE_INFO_DEINIT: core_info_deinit_list(); break; - case EVENT_CMD_CORE_INFO_INIT: - command_event(EVENT_CMD_CORE_INFO_DEINIT, NULL); + case CMD_EVENT_CORE_INFO_INIT: + command_event(CMD_EVENT_CORE_INFO_DEINIT, NULL); if (*settings->directory.libretro) core_info_init_list(); break; - case EVENT_CMD_CORE_DEINIT: + case CMD_EVENT_CORE_DEINIT: { struct retro_hw_render_callback *hwr = video_driver_get_hw_context(); @@ -1956,44 +1956,44 @@ bool command_event(enum event_command cmd, void *data) break; } - case EVENT_CMD_CORE_INIT: + case CMD_EVENT_CORE_INIT: if (!event_init_core((enum rarch_core_type*)data)) return false; break; - case EVENT_CMD_VIDEO_APPLY_STATE_CHANGES: + case CMD_EVENT_VIDEO_APPLY_STATE_CHANGES: video_driver_apply_state_changes(); break; - case EVENT_CMD_VIDEO_SET_NONBLOCKING_STATE: + case CMD_EVENT_VIDEO_SET_NONBLOCKING_STATE: boolean = true; /* fall-through */ - case EVENT_CMD_VIDEO_SET_BLOCKING_STATE: + case CMD_EVENT_VIDEO_SET_BLOCKING_STATE: video_driver_set_nonblock_state(boolean); break; - case EVENT_CMD_VIDEO_SET_ASPECT_RATIO: + case CMD_EVENT_VIDEO_SET_ASPECT_RATIO: video_driver_set_aspect_ratio(); break; - case EVENT_CMD_AUDIO_SET_NONBLOCKING_STATE: + case CMD_EVENT_AUDIO_SET_NONBLOCKING_STATE: boolean = true; /* fall-through */ - case EVENT_CMD_AUDIO_SET_BLOCKING_STATE: + case CMD_EVENT_AUDIO_SET_BLOCKING_STATE: audio_driver_set_nonblocking_state(boolean); break; - case EVENT_CMD_OVERLAY_SET_SCALE_FACTOR: + case CMD_EVENT_OVERLAY_SET_SCALE_FACTOR: #ifdef HAVE_OVERLAY input_overlay_set_scale_factor(settings->input.overlay_scale); #endif break; - case EVENT_CMD_OVERLAY_SET_ALPHA_MOD: + case CMD_EVENT_OVERLAY_SET_ALPHA_MOD: #ifdef HAVE_OVERLAY input_overlay_set_alpha_mod(settings->input.overlay_opacity); #endif break; - case EVENT_CMD_AUDIO_REINIT: + case CMD_EVENT_AUDIO_REINIT: { int flags = DRIVER_AUDIO; driver_ctl(RARCH_DRIVER_CTL_UNINIT, &flags); driver_ctl(RARCH_DRIVER_CTL_INIT, &flags); } break; - case EVENT_CMD_RESET_CONTEXT: + case CMD_EVENT_RESET_CONTEXT: { /* RARCH_DRIVER_CTL_UNINIT clears the callback struct so we * need to make sure to keep a copy */ @@ -2011,49 +2011,49 @@ bool command_event(enum event_command cmd, void *data) driver_ctl(RARCH_DRIVER_CTL_INIT, &flags); } break; - case EVENT_CMD_QUIT_RETROARCH: + case CMD_EVENT_QUIT_RETROARCH: rarch_ctl(RARCH_CTL_FORCE_QUIT, NULL); break; - case EVENT_CMD_SHUTDOWN: + case CMD_EVENT_SHUTDOWN: #if defined(__linux__) && !defined(ANDROID) runloop_msg_queue_push("Shutting down...", 1, 180, true); rarch_ctl(RARCH_CTL_FORCE_QUIT, NULL); system("shutdown -P now"); #endif break; - case EVENT_CMD_REBOOT: + case CMD_EVENT_REBOOT: #if defined(__linux__) && !defined(ANDROID) runloop_msg_queue_push("Rebooting...", 1, 180, true); rarch_ctl(RARCH_CTL_FORCE_QUIT, NULL); system("shutdown -r now"); #endif break; - case EVENT_CMD_RESUME: + case CMD_EVENT_RESUME: rarch_ctl(RARCH_CTL_MENU_RUNNING_FINISHED, NULL); if (ui_companion_is_on_foreground()) ui_companion_driver_toggle(); break; - case EVENT_CMD_RESTART_RETROARCH: + case CMD_EVENT_RESTART_RETROARCH: if (!frontend_driver_set_fork(FRONTEND_FORK_RESTART)) return false; break; - case EVENT_CMD_MENU_SAVE_CURRENT_CONFIG: + case CMD_EVENT_MENU_SAVE_CURRENT_CONFIG: command_event_save_current_config(); break; - case EVENT_CMD_MENU_SAVE_CONFIG: + case CMD_EVENT_MENU_SAVE_CONFIG: if (!command_event_save_core_config()) return false; break; - case EVENT_CMD_SHADERS_APPLY_CHANGES: + case CMD_EVENT_SHADERS_APPLY_CHANGES: #ifdef HAVE_MENU menu_shader_manager_apply_changes(); #endif break; - case EVENT_CMD_PAUSE_CHECKS: + case CMD_EVENT_PAUSE_CHECKS: if (runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL)) { RARCH_LOG("%s\n", msg_hash_to_str(MSG_PAUSED)); - command_event(EVENT_CMD_AUDIO_STOP, NULL); + command_event(CMD_EVENT_AUDIO_STOP, NULL); if (settings->video.black_frame_insertion) video_driver_cached_frame_render(); @@ -2061,53 +2061,53 @@ bool command_event(enum event_command cmd, void *data) else { RARCH_LOG("%s\n", msg_hash_to_str(MSG_UNPAUSED)); - command_event(EVENT_CMD_AUDIO_START, NULL); + command_event(CMD_EVENT_AUDIO_START, NULL); } break; - case EVENT_CMD_PAUSE_TOGGLE: + case CMD_EVENT_PAUSE_TOGGLE: boolean = runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL); boolean = !boolean; runloop_ctl(RUNLOOP_CTL_SET_PAUSED, &boolean); - command_event(EVENT_CMD_PAUSE_CHECKS, NULL); + command_event(CMD_EVENT_PAUSE_CHECKS, NULL); break; - case EVENT_CMD_UNPAUSE: + case CMD_EVENT_UNPAUSE: boolean = false; runloop_ctl(RUNLOOP_CTL_SET_PAUSED, &boolean); - command_event(EVENT_CMD_PAUSE_CHECKS, NULL); + command_event(CMD_EVENT_PAUSE_CHECKS, NULL); break; - case EVENT_CMD_PAUSE: + case CMD_EVENT_PAUSE: boolean = true; runloop_ctl(RUNLOOP_CTL_SET_PAUSED, &boolean); - command_event(EVENT_CMD_PAUSE_CHECKS, NULL); + command_event(CMD_EVENT_PAUSE_CHECKS, NULL); break; - case EVENT_CMD_MENU_PAUSE_LIBRETRO: + case CMD_EVENT_MENU_PAUSE_LIBRETRO: #ifdef HAVE_MENU if (menu_driver_ctl(RARCH_MENU_CTL_IS_ALIVE, NULL)) { if (settings->menu.pause_libretro) - command_event(EVENT_CMD_AUDIO_STOP, NULL); + command_event(CMD_EVENT_AUDIO_STOP, NULL); else - command_event(EVENT_CMD_AUDIO_START, NULL); + command_event(CMD_EVENT_AUDIO_START, NULL); } else { if (settings->menu.pause_libretro) - command_event(EVENT_CMD_AUDIO_START, NULL); + command_event(CMD_EVENT_AUDIO_START, NULL); } #endif break; - case EVENT_CMD_SHADER_DIR_DEINIT: + case CMD_EVENT_SHADER_DIR_DEINIT: runloop_ctl(RUNLOOP_CTL_SHADER_DIR_DEINIT, NULL); break; - case EVENT_CMD_SHADER_DIR_INIT: - command_event(EVENT_CMD_SHADER_DIR_DEINIT, NULL); + case CMD_EVENT_SHADER_DIR_INIT: + command_event(CMD_EVENT_SHADER_DIR_DEINIT, NULL); if (!runloop_ctl(RUNLOOP_CTL_SHADER_DIR_INIT, NULL)) return false; break; - case EVENT_CMD_SAVEFILES: + case CMD_EVENT_SAVEFILES: { global_t *global = global_get_ptr(); if (!global->savefiles || !global->sram.use) @@ -2128,7 +2128,7 @@ bool command_event(enum event_command cmd, void *data) } } return true; - case EVENT_CMD_SAVEFILES_DEINIT: + case CMD_EVENT_SAVEFILES_DEINIT: { global_t *global = global_get_ptr(); if (!global) @@ -2139,7 +2139,7 @@ bool command_event(enum event_command cmd, void *data) global->savefiles = NULL; } break; - case EVENT_CMD_SAVEFILES_INIT: + case CMD_EVENT_SAVEFILES_INIT: { global_t *global = global_get_ptr(); global->sram.use = global->sram.use && !global->sram.save_disable; @@ -2154,70 +2154,70 @@ bool command_event(enum event_command cmd, void *data) msg_hash_to_str(MSG_SRAM_WILL_NOT_BE_SAVED)); if (global->sram.use) - command_event(EVENT_CMD_AUTOSAVE_INIT, NULL); + command_event(CMD_EVENT_AUTOSAVE_INIT, NULL); } break; - case EVENT_CMD_BSV_MOVIE_DEINIT: + case CMD_EVENT_BSV_MOVIE_DEINIT: bsv_movie_ctl(BSV_MOVIE_CTL_DEINIT, NULL); break; - case EVENT_CMD_BSV_MOVIE_INIT: - command_event(EVENT_CMD_BSV_MOVIE_DEINIT, NULL); + case CMD_EVENT_BSV_MOVIE_INIT: + command_event(CMD_EVENT_BSV_MOVIE_DEINIT, NULL); bsv_movie_ctl(BSV_MOVIE_CTL_INIT, NULL); break; - case EVENT_CMD_NETPLAY_DEINIT: + case CMD_EVENT_NETPLAY_DEINIT: #ifdef HAVE_NETPLAY deinit_netplay(); #endif break; - case EVENT_CMD_NETWORK_DEINIT: + case CMD_EVENT_NETWORK_DEINIT: #ifdef HAVE_NETWORKING network_deinit(); #endif break; - case EVENT_CMD_NETWORK_INIT: + case CMD_EVENT_NETWORK_INIT: #ifdef HAVE_NETWORKING network_init(); #endif break; - case EVENT_CMD_NETPLAY_INIT: - command_event(EVENT_CMD_NETPLAY_DEINIT, NULL); + case CMD_EVENT_NETPLAY_INIT: + command_event(CMD_EVENT_NETPLAY_DEINIT, NULL); #ifdef HAVE_NETPLAY if (!init_netplay()) return false; #endif break; - case EVENT_CMD_NETPLAY_FLIP_PLAYERS: + case CMD_EVENT_NETPLAY_FLIP_PLAYERS: #ifdef HAVE_NETPLAY netplay_driver_ctl(RARCH_NETPLAY_CTL_FLIP_PLAYERS, NULL); #endif break; - case EVENT_CMD_FULLSCREEN_TOGGLE: + case CMD_EVENT_FULLSCREEN_TOGGLE: if (!video_driver_has_windowed()) return false; /* If we go fullscreen we drop all drivers and * reinitialize to be safe. */ settings->video.fullscreen = !settings->video.fullscreen; - command_event(EVENT_CMD_REINIT, NULL); + command_event(CMD_EVENT_REINIT, NULL); break; - case EVENT_CMD_COMMAND_DEINIT: + case CMD_EVENT_COMMAND_DEINIT: input_driver_deinit_command(); break; - case EVENT_CMD_COMMAND_INIT: - command_event(EVENT_CMD_COMMAND_DEINIT, NULL); + case CMD_EVENT_COMMAND_INIT: + command_event(CMD_EVENT_COMMAND_DEINIT, NULL); input_driver_init_command(); break; - case EVENT_CMD_REMOTE_DEINIT: + case CMD_EVENT_REMOTE_DEINIT: input_driver_deinit_remote(); break; - case EVENT_CMD_REMOTE_INIT: - command_event(EVENT_CMD_REMOTE_DEINIT, NULL); + case CMD_EVENT_REMOTE_INIT: + command_event(CMD_EVENT_REMOTE_DEINIT, NULL); input_driver_init_remote(); break; - case EVENT_CMD_TEMPORARY_CONTENT_DEINIT: + case CMD_EVENT_TEMPORARY_CONTENT_DEINIT: content_deinit(); break; - case EVENT_CMD_SUBSYSTEM_FULLPATHS_DEINIT: + case CMD_EVENT_SUBSYSTEM_FULLPATHS_DEINIT: { global_t *global = global_get_ptr(); if (!global) @@ -2228,17 +2228,17 @@ bool command_event(enum event_command cmd, void *data) global->subsystem_fullpaths = NULL; } break; - case EVENT_CMD_LOG_FILE_DEINIT: + case CMD_EVENT_LOG_FILE_DEINIT: retro_main_log_file_deinit(); break; - case EVENT_CMD_DISK_APPEND_IMAGE: + case CMD_EVENT_DISK_APPEND_IMAGE: { const char *path = (const char*)data; if (string_is_empty(path)) return false; return command_event_disk_control_append_image(path); } - case EVENT_CMD_DISK_EJECT_TOGGLE: + case CMD_EVENT_DISK_EJECT_TOGGLE: if (info && info->disk_control_cb.get_num_images) { const struct retro_disk_control_callback *control = @@ -2256,7 +2256,7 @@ bool command_event(enum event_command cmd, void *data) msg_hash_to_str(MSG_CORE_DOES_NOT_SUPPORT_DISK_OPTIONS), 1, 120, true); break; - case EVENT_CMD_DISK_NEXT: + case CMD_EVENT_DISK_NEXT: if (info && info->disk_control_cb.get_num_images) { const struct retro_disk_control_callback *control = @@ -2276,7 +2276,7 @@ bool command_event(enum event_command cmd, void *data) msg_hash_to_str(MSG_CORE_DOES_NOT_SUPPORT_DISK_OPTIONS), 1, 120, true); break; - case EVENT_CMD_DISK_PREV: + case CMD_EVENT_DISK_PREV: if (info && info->disk_control_cb.get_num_images) { const struct retro_disk_control_callback *control = @@ -2296,14 +2296,14 @@ bool command_event(enum event_command cmd, void *data) msg_hash_to_str(MSG_CORE_DOES_NOT_SUPPORT_DISK_OPTIONS), 1, 120, true); break; - case EVENT_CMD_RUMBLE_STOP: + case CMD_EVENT_RUMBLE_STOP: for (i = 0; i < MAX_USERS; i++) { input_driver_set_rumble_state(i, RETRO_RUMBLE_STRONG, 0); input_driver_set_rumble_state(i, RETRO_RUMBLE_WEAK, 0); } break; - case EVENT_CMD_GRAB_MOUSE_TOGGLE: + case CMD_EVENT_GRAB_MOUSE_TOGGLE: { bool ret = false; static bool grab_mouse_state = false; @@ -2328,21 +2328,21 @@ bool command_event(enum event_command cmd, void *data) video_driver_show_mouse(); } break; - case EVENT_CMD_PERFCNT_REPORT_FRONTEND_LOG: + case CMD_EVENT_PERFCNT_REPORT_FRONTEND_LOG: rarch_perf_log(); break; - case EVENT_CMD_VOLUME_UP: + case CMD_EVENT_VOLUME_UP: command_event_set_volume(0.5f); break; - case EVENT_CMD_VOLUME_DOWN: + case CMD_EVENT_VOLUME_DOWN: command_event_set_volume(-0.5f); break; - case EVENT_CMD_SET_FRAME_LIMIT: + case CMD_EVENT_SET_FRAME_LIMIT: runloop_ctl(RUNLOOP_CTL_SET_FRAME_LIMIT, NULL); break; - case EVENT_CMD_EXEC: + case CMD_EVENT_EXEC: return command_event_cmd_exec(data); - case EVENT_CMD_NONE: + case CMD_EVENT_NONE: default: return false; } diff --git a/command.h b/command.h index 522395b4b6..1df2d737aa 100644 --- a/command.h +++ b/command.h @@ -32,187 +32,187 @@ typedef struct command command_t; enum event_command { - EVENT_CMD_NONE = 0, + CMD_EVENT_NONE = 0, /* Resets RetroArch. */ - EVENT_CMD_RESET, + CMD_EVENT_RESET, /* Loads content file. */ - EVENT_CMD_LOAD_CONTENT, - EVENT_CMD_LOAD_CONTENT_PERSIST, + CMD_EVENT_LOAD_CONTENT, + CMD_EVENT_LOAD_CONTENT_PERSIST, #ifdef HAVE_FFMPEG - EVENT_CMD_LOAD_CONTENT_FFMPEG, + CMD_EVENT_LOAD_CONTENT_FFMPEG, #endif - EVENT_CMD_LOAD_CONTENT_IMAGEVIEWER, - EVENT_CMD_SET_PER_GAME_RESOLUTION, - EVENT_CMD_SET_FRAME_LIMIT, + CMD_EVENT_LOAD_CONTENT_IMAGEVIEWER, + CMD_EVENT_SET_PER_GAME_RESOLUTION, + CMD_EVENT_SET_FRAME_LIMIT, /* Loads core. */ - EVENT_CMD_LOAD_CORE_DEINIT, - EVENT_CMD_LOAD_CORE, - EVENT_CMD_LOAD_CORE_PERSIST, - EVENT_CMD_UNLOAD_CORE, - EVENT_CMD_LOAD_STATE, - EVENT_CMD_SAVE_STATE, - EVENT_CMD_SAVE_STATE_DECREMENT, - EVENT_CMD_SAVE_STATE_INCREMENT, + CMD_EVENT_LOAD_CORE_DEINIT, + CMD_EVENT_LOAD_CORE, + CMD_EVENT_LOAD_CORE_PERSIST, + CMD_EVENT_UNLOAD_CORE, + CMD_EVENT_LOAD_STATE, + CMD_EVENT_SAVE_STATE, + CMD_EVENT_SAVE_STATE_DECREMENT, + CMD_EVENT_SAVE_STATE_INCREMENT, /* Takes screenshot. */ - EVENT_CMD_TAKE_SCREENSHOT, + CMD_EVENT_TAKE_SCREENSHOT, /* Quits RetroArch. */ - EVENT_CMD_QUIT, + CMD_EVENT_QUIT, /* Reinitialize all drivers. */ - EVENT_CMD_REINIT, + CMD_EVENT_REINIT, /* Toggles cheevos hardcore mode. */ - EVENT_CMD_CHEEVOS_HARDCORE_MODE_TOGGLE, + CMD_EVENT_CHEEVOS_HARDCORE_MODE_TOGGLE, /* Deinitialize rewind. */ - EVENT_CMD_REWIND_DEINIT, + CMD_EVENT_REWIND_DEINIT, /* Initializes rewind. */ - EVENT_CMD_REWIND_INIT, + CMD_EVENT_REWIND_INIT, /* Toggles rewind. */ - EVENT_CMD_REWIND_TOGGLE, + CMD_EVENT_REWIND_TOGGLE, /* Deinitializes autosave. */ - EVENT_CMD_AUTOSAVE_DEINIT, + CMD_EVENT_AUTOSAVE_DEINIT, /* Initializes autosave. */ - EVENT_CMD_AUTOSAVE_INIT, - EVENT_CMD_AUTOSAVE_STATE, + CMD_EVENT_AUTOSAVE_INIT, + CMD_EVENT_AUTOSAVE_STATE, /* Stops audio. */ - EVENT_CMD_AUDIO_STOP, + CMD_EVENT_AUDIO_STOP, /* Starts audio. */ - EVENT_CMD_AUDIO_START, + CMD_EVENT_AUDIO_START, /* Mutes audio. */ - EVENT_CMD_AUDIO_MUTE_TOGGLE, + CMD_EVENT_AUDIO_MUTE_TOGGLE, /* Initializes overlay. */ - EVENT_CMD_OVERLAY_INIT, + CMD_EVENT_OVERLAY_INIT, /* Deinitializes overlay. */ - EVENT_CMD_OVERLAY_DEINIT, + CMD_EVENT_OVERLAY_DEINIT, /* Sets current scale factor for overlay. */ - EVENT_CMD_OVERLAY_SET_SCALE_FACTOR, + CMD_EVENT_OVERLAY_SET_SCALE_FACTOR, /* Sets current alpha modulation for overlay. */ - EVENT_CMD_OVERLAY_SET_ALPHA_MOD, + CMD_EVENT_OVERLAY_SET_ALPHA_MOD, /* Cycle to next overlay. */ - EVENT_CMD_OVERLAY_NEXT, + CMD_EVENT_OVERLAY_NEXT, /* Deinitializes overlay. */ - EVENT_CMD_DSP_FILTER_INIT, + CMD_EVENT_DSP_FILTER_INIT, /* Deinitializes graphics filter. */ - EVENT_CMD_DSP_FILTER_DEINIT, + CMD_EVENT_DSP_FILTER_DEINIT, /* Deinitializes GPU recoring. */ - EVENT_CMD_GPU_RECORD_DEINIT, + CMD_EVENT_GPU_RECORD_DEINIT, /* Initializes recording system. */ - EVENT_CMD_RECORD_INIT, + CMD_EVENT_RECORD_INIT, /* Deinitializes recording system. */ - EVENT_CMD_RECORD_DEINIT, + CMD_EVENT_RECORD_DEINIT, /* Deinitializes history playlist. */ - EVENT_CMD_HISTORY_DEINIT, + CMD_EVENT_HISTORY_DEINIT, /* Initializes history playlist. */ - EVENT_CMD_HISTORY_INIT, + CMD_EVENT_HISTORY_INIT, /* Deinitializes core information. */ - EVENT_CMD_CORE_INFO_DEINIT, + CMD_EVENT_CORE_INFO_DEINIT, /* Initializes core information. */ - EVENT_CMD_CORE_INFO_INIT, + CMD_EVENT_CORE_INFO_INIT, /* Deinitializes core. */ - EVENT_CMD_CORE_DEINIT, + CMD_EVENT_CORE_DEINIT, /* Initializes core. */ - EVENT_CMD_CORE_INIT, + CMD_EVENT_CORE_INIT, /* Set audio blocking state. */ - EVENT_CMD_AUDIO_SET_BLOCKING_STATE, + CMD_EVENT_AUDIO_SET_BLOCKING_STATE, /* Set audio nonblocking state. */ - EVENT_CMD_AUDIO_SET_NONBLOCKING_STATE, + CMD_EVENT_AUDIO_SET_NONBLOCKING_STATE, /* Apply video state changes. */ - EVENT_CMD_VIDEO_APPLY_STATE_CHANGES, + CMD_EVENT_VIDEO_APPLY_STATE_CHANGES, /* Set video blocking state. */ - EVENT_CMD_VIDEO_SET_BLOCKING_STATE, + CMD_EVENT_VIDEO_SET_BLOCKING_STATE, /* Set video nonblocking state. */ - EVENT_CMD_VIDEO_SET_NONBLOCKING_STATE, + CMD_EVENT_VIDEO_SET_NONBLOCKING_STATE, /* Sets current aspect ratio index. */ - EVENT_CMD_VIDEO_SET_ASPECT_RATIO, - EVENT_CMD_RESET_CONTEXT, + CMD_EVENT_VIDEO_SET_ASPECT_RATIO, + CMD_EVENT_RESET_CONTEXT, /* Restarts RetroArch. */ - EVENT_CMD_RESTART_RETROARCH, + CMD_EVENT_RESTART_RETROARCH, /* Force-quit RetroArch. */ - EVENT_CMD_QUIT_RETROARCH, + CMD_EVENT_QUIT_RETROARCH, /* Shutdown the OS */ - EVENT_CMD_SHUTDOWN, + CMD_EVENT_SHUTDOWN, /* Reboot the OS */ - EVENT_CMD_REBOOT, + CMD_EVENT_REBOOT, /* Resume RetroArch when in menu. */ - EVENT_CMD_RESUME, + CMD_EVENT_RESUME, /* Toggles pause. */ - EVENT_CMD_PAUSE_TOGGLE, + CMD_EVENT_PAUSE_TOGGLE, /* Pauses RetroArch. */ - EVENT_CMD_UNPAUSE, + CMD_EVENT_UNPAUSE, /* Unpauses retroArch. */ - EVENT_CMD_PAUSE, - EVENT_CMD_PAUSE_CHECKS, - EVENT_CMD_MENU_SAVE_CURRENT_CONFIG, - EVENT_CMD_MENU_SAVE_CONFIG, - EVENT_CMD_MENU_PAUSE_LIBRETRO, + CMD_EVENT_PAUSE, + CMD_EVENT_PAUSE_CHECKS, + CMD_EVENT_MENU_SAVE_CURRENT_CONFIG, + CMD_EVENT_MENU_SAVE_CONFIG, + CMD_EVENT_MENU_PAUSE_LIBRETRO, /* Toggles menu on/off. */ - EVENT_CMD_MENU_TOGGLE, - EVENT_CMD_MENU_REFRESH, + CMD_EVENT_MENU_TOGGLE, + CMD_EVENT_MENU_REFRESH, /* Applies shader changes. */ - EVENT_CMD_SHADERS_APPLY_CHANGES, + CMD_EVENT_SHADERS_APPLY_CHANGES, /* Initializes shader directory. */ - EVENT_CMD_SHADER_DIR_INIT, + CMD_EVENT_SHADER_DIR_INIT, /* Deinitializes shader directory. */ - EVENT_CMD_SHADER_DIR_DEINIT, + CMD_EVENT_SHADER_DIR_DEINIT, /* Initializes controllers. */ - EVENT_CMD_CONTROLLERS_INIT, - EVENT_CMD_SAVEFILES, + CMD_EVENT_CONTROLLERS_INIT, + CMD_EVENT_SAVEFILES, /* Initializes savefiles. */ - EVENT_CMD_SAVEFILES_INIT, + CMD_EVENT_SAVEFILES_INIT, /* Deinitializes savefiles. */ - EVENT_CMD_SAVEFILES_DEINIT, + CMD_EVENT_SAVEFILES_DEINIT, /* Initializes cheats. */ - EVENT_CMD_CHEATS_INIT, + CMD_EVENT_CHEATS_INIT, /* Deinitializes cheats. */ - EVENT_CMD_CHEATS_DEINIT, + CMD_EVENT_CHEATS_DEINIT, /* Apply cheats. */ - EVENT_CMD_CHEATS_APPLY, + CMD_EVENT_CHEATS_APPLY, /* Deinitializes network system. */ - EVENT_CMD_NETWORK_DEINIT, + CMD_EVENT_NETWORK_DEINIT, /* Initializes network system. */ - EVENT_CMD_NETWORK_INIT, + CMD_EVENT_NETWORK_INIT, /* Initializes netplay system. */ - EVENT_CMD_NETPLAY_INIT, + CMD_EVENT_NETPLAY_INIT, /* Deinitializes netplay system. */ - EVENT_CMD_NETPLAY_DEINIT, + CMD_EVENT_NETPLAY_DEINIT, /* Flip netplay players. */ - EVENT_CMD_NETPLAY_FLIP_PLAYERS, + CMD_EVENT_NETPLAY_FLIP_PLAYERS, /* Initializes BSV movie. */ - EVENT_CMD_BSV_MOVIE_INIT, + CMD_EVENT_BSV_MOVIE_INIT, /* Deinitializes BSV movie. */ - EVENT_CMD_BSV_MOVIE_DEINIT, + CMD_EVENT_BSV_MOVIE_DEINIT, /* Initializes command interface. */ - EVENT_CMD_COMMAND_INIT, + CMD_EVENT_COMMAND_INIT, /* Deinitialize command interface. */ - EVENT_CMD_COMMAND_DEINIT, + CMD_EVENT_COMMAND_DEINIT, /* Initializes remote gamepad interface. */ - EVENT_CMD_REMOTE_INIT, + CMD_EVENT_REMOTE_INIT, /* Deinitializes remote gamepad interface. */ - EVENT_CMD_REMOTE_DEINIT, + CMD_EVENT_REMOTE_DEINIT, /* Reinitializes audio driver. */ - EVENT_CMD_AUDIO_REINIT, + CMD_EVENT_AUDIO_REINIT, /* Resizes windowed scale. Will reinitialize video driver. */ - EVENT_CMD_RESIZE_WINDOWED_SCALE, + CMD_EVENT_RESIZE_WINDOWED_SCALE, /* Deinitializes temporary content. */ - EVENT_CMD_TEMPORARY_CONTENT_DEINIT, - EVENT_CMD_SUBSYSTEM_FULLPATHS_DEINIT, - EVENT_CMD_LOG_FILE_DEINIT, + CMD_EVENT_TEMPORARY_CONTENT_DEINIT, + CMD_EVENT_SUBSYSTEM_FULLPATHS_DEINIT, + CMD_EVENT_LOG_FILE_DEINIT, /* Toggles disk eject. */ - EVENT_CMD_DISK_EJECT_TOGGLE, + CMD_EVENT_DISK_EJECT_TOGGLE, /* Cycle to next disk. */ - EVENT_CMD_DISK_NEXT, + CMD_EVENT_DISK_NEXT, /* Cycle to previous disk. */ - EVENT_CMD_DISK_PREV, + CMD_EVENT_DISK_PREV, /* Appends disk image to disk image list. */ - EVENT_CMD_DISK_APPEND_IMAGE, + CMD_EVENT_DISK_APPEND_IMAGE, /* Stops rumbling. */ - EVENT_CMD_RUMBLE_STOP, + CMD_EVENT_RUMBLE_STOP, /* Toggles mouse grab. */ - EVENT_CMD_GRAB_MOUSE_TOGGLE, + CMD_EVENT_GRAB_MOUSE_TOGGLE, /* Toggles fullscreen mode. */ - EVENT_CMD_FULLSCREEN_TOGGLE, - EVENT_CMD_PERFCNT_REPORT_FRONTEND_LOG, - EVENT_CMD_VOLUME_UP, - EVENT_CMD_VOLUME_DOWN, - EVENT_CMD_EXEC + CMD_EVENT_FULLSCREEN_TOGGLE, + CMD_EVENT_PERFCNT_REPORT_FRONTEND_LOG, + CMD_EVENT_VOLUME_UP, + CMD_EVENT_VOLUME_DOWN, + CMD_EVENT_EXEC }; typedef struct command_handle @@ -239,7 +239,7 @@ bool command_free(command_t *handle); #endif /** - * event_command: + * command_event: * @cmd : Command index. * * Performs RetroArch command with index @cmd. diff --git a/content.c b/content.c index c41c3e4e2d..73c0f6ba94 100644 --- a/content.c +++ b/content.c @@ -901,9 +901,9 @@ bool content_load(content_ctx_info_t *info) #ifdef HAVE_MENU menu_driver_ctl(RARCH_MENU_CTL_SHADER_MANAGER_INIT, NULL); #endif - command_event(EVENT_CMD_HISTORY_INIT, NULL); - command_event(EVENT_CMD_RESUME, NULL); - command_event(EVENT_CMD_VIDEO_SET_ASPECT_RATIO, NULL); + command_event(CMD_EVENT_HISTORY_INIT, NULL); + command_event(CMD_EVENT_RESUME, NULL); + command_event(CMD_EVENT_VIDEO_SET_ASPECT_RATIO, NULL); check_default_dirs(); diff --git a/driver.c b/driver.c index c5c4c05378..5e6c076363 100644 --- a/driver.c +++ b/driver.c @@ -207,7 +207,7 @@ static void driver_adjust_system_rates(void) return; if (runloop_ctl(RUNLOOP_CTL_IS_NONBLOCK_FORCED, NULL)) - command_event(EVENT_CMD_VIDEO_SET_NONBLOCKING_STATE, NULL); + command_event(CMD_EVENT_VIDEO_SET_NONBLOCKING_STATE, NULL); else driver_ctl(RARCH_DRIVER_CTL_SET_NONBLOCK_STATE, NULL); } @@ -254,7 +254,7 @@ static bool driver_update_system_av_info(const struct retro_system_av_info *info struct retro_system_av_info *av_info = video_viewport_get_system_av_info(); memcpy(av_info, info, sizeof(*av_info)); - command_event(EVENT_CMD_REINIT, NULL); + command_event(CMD_EVENT_REINIT, NULL); /* Cannot continue recording with different parameters. * Take the easiest route out and just restart the recording. */ @@ -263,8 +263,8 @@ static bool driver_update_system_av_info(const struct retro_system_av_info *info runloop_msg_queue_push( msg_hash_to_str(MSG_RESTARTING_RECORDING_DUE_TO_DRIVER_REINIT), 2, 180, false); - command_event(EVENT_CMD_RECORD_DEINIT, NULL); - command_event(EVENT_CMD_RECORD_INIT, NULL); + command_event(CMD_EVENT_RECORD_DEINIT, NULL); + command_event(CMD_EVENT_RECORD_INIT, NULL); } return true; @@ -286,8 +286,8 @@ static void menu_update_libretro_info(void) if (!info) return; - command_event(EVENT_CMD_CORE_INFO_INIT, NULL); - command_event(EVENT_CMD_LOAD_CORE_PERSIST, NULL); + command_event(CMD_EVENT_CORE_INFO_INIT, NULL); + command_event(CMD_EVENT_LOAD_CORE_PERSIST, NULL); } #endif diff --git a/dynamic.c b/dynamic.c index 5a857cd33a..cf8afb23b4 100644 --- a/dynamic.c +++ b/dynamic.c @@ -1245,7 +1245,7 @@ bool rarch_environment_cb(unsigned cmd, void *data) /* Forces recomputation of aspect ratios if * using core-dependent aspect ratios. */ - command_event(EVENT_CMD_VIDEO_SET_ASPECT_RATIO, NULL); + command_event(CMD_EVENT_VIDEO_SET_ASPECT_RATIO, NULL); /* TODO: Figure out what to do, if anything, with recording. */ } diff --git a/frontend/drivers/platform_ctr.c b/frontend/drivers/platform_ctr.c index b7cb60c86a..7551b1c124 100644 --- a/frontend/drivers/platform_ctr.c +++ b/frontend/drivers/platform_ctr.c @@ -95,7 +95,7 @@ static void frontend_ctr_deinit(void *data) *verbose = true; #ifdef HAVE_FILE_LOGGER - command_event(EVENT_CMD_LOG_FILE_DEINIT, NULL); + command_event(CMD_EVENT_LOG_FILE_DEINIT, NULL); #endif if(gfxBottomFramebuffers[0] == (u8*)currentConsole->frameBuffer) diff --git a/frontend/drivers/platform_emscripten.c b/frontend/drivers/platform_emscripten.c index 4deee94655..dab55da49e 100644 --- a/frontend/drivers/platform_emscripten.c +++ b/frontend/drivers/platform_emscripten.c @@ -44,22 +44,22 @@ static void emscripten_mainloop(void) void cmd_savefiles(void) { - command_event(EVENT_CMD_SAVEFILES, NULL); + command_event(CMD_EVENT_SAVEFILES, NULL); } void cmd_save_state(void) { - command_event(EVENT_CMD_SAVE_STATE, NULL); + command_event(CMD_EVENT_SAVE_STATE, NULL); } void cmd_load_state(void) { - command_event(EVENT_CMD_LOAD_STATE, NULL); + command_event(CMD_EVENT_LOAD_STATE, NULL); } void cmd_take_screenshot(void) { - command_event(EVENT_CMD_TAKE_SCREENSHOT, NULL); + command_event(CMD_EVENT_TAKE_SCREENSHOT, NULL); } diff --git a/frontend/drivers/platform_psp.c b/frontend/drivers/platform_psp.c index 97cbadfd7a..2b796f691d 100644 --- a/frontend/drivers/platform_psp.c +++ b/frontend/drivers/platform_psp.c @@ -163,7 +163,7 @@ static void frontend_psp_deinit(void *data) *verbose = false; #ifdef HAVE_FILE_LOGGER - command_event(EVENT_CMD_LOG_FILE_DEINIT, NULL); + command_event(CMD_EVENT_LOG_FILE_DEINIT, NULL); #endif #endif diff --git a/frontend/frontend.c b/frontend/frontend.c index ac23b047a9..3708bb64d9 100644 --- a/frontend/frontend.c +++ b/frontend/frontend.c @@ -59,7 +59,7 @@ void main_exit(void *args) { settings_t *settings = config_get_ptr(); - command_event(EVENT_CMD_MENU_SAVE_CURRENT_CONFIG, NULL); + command_event(CMD_EVENT_MENU_SAVE_CURRENT_CONFIG, NULL); #ifdef HAVE_MENU /* Do not want menu context to live any more. */ @@ -67,7 +67,7 @@ void main_exit(void *args) #endif rarch_ctl(RARCH_CTL_MAIN_DEINIT, NULL); - command_event(EVENT_CMD_PERFCNT_REPORT_FRONTEND_LOG, NULL); + command_event(CMD_EVENT_PERFCNT_REPORT_FRONTEND_LOG, NULL); #if defined(HAVE_LOGGER) && !defined(ANDROID) logger_shutdown(); diff --git a/gfx/drivers/ctr_gfx.c b/gfx/drivers/ctr_gfx.c index c24358bfeb..e254216539 100644 --- a/gfx/drivers/ctr_gfx.c +++ b/gfx/drivers/ctr_gfx.c @@ -512,13 +512,13 @@ static bool ctr_frame(void* data, const void* frame, if(!aptMainLoop()) { - command_event(EVENT_CMD_QUIT, NULL); + command_event(CMD_EVENT_QUIT, NULL); return true; } if (select_pressed) { - command_event(EVENT_CMD_QUIT, NULL); + command_event(CMD_EVENT_QUIT, NULL); return true; } diff --git a/gfx/video_driver.c b/gfx/video_driver.c index cbfbecd223..673b0266c0 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -505,7 +505,7 @@ static void deinit_pixel_converter(void) static bool uninit_video_input(void) { - command_event(EVENT_CMD_OVERLAY_DEINIT, NULL); + command_event(CMD_EVENT_OVERLAY_DEINIT, NULL); if (!video_driver_is_video_cache_context()) video_driver_deinit_hw_context(); @@ -526,7 +526,7 @@ static bool uninit_video_input(void) deinit_pixel_converter(); deinit_video_filter(); - command_event(EVENT_CMD_SHADER_DIR_DEINIT, NULL); + command_event(CMD_EVENT_SHADER_DIR_DEINIT, NULL); video_monitor_compute_fps_statistics(); return true; @@ -600,7 +600,7 @@ static bool init_video(void) runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); init_video_filter(video_driver_state.pix_fmt); - command_event(EVENT_CMD_SHADER_DIR_INIT, NULL); + command_event(CMD_EVENT_SHADER_DIR_INIT, NULL); if (av_info) geom = (const struct retro_game_geometry*)&av_info->geometry; @@ -742,8 +742,8 @@ static bool init_video(void) init_video_input(tmp); - command_event(EVENT_CMD_OVERLAY_DEINIT, NULL); - command_event(EVENT_CMD_OVERLAY_INIT, NULL); + command_event(CMD_EVENT_OVERLAY_DEINIT, NULL); + command_event(CMD_EVENT_OVERLAY_INIT, NULL); video_driver_cached_frame_set(&dummy_pixels, 4, 4, 8); @@ -1221,7 +1221,7 @@ void video_driver_menu_settings(void **list_data, void *list_info_data, menu_settings_list_current_add_cmd( list, list_info, - EVENT_CMD_VIDEO_APPLY_STATE_CHANGES); + CMD_EVENT_VIDEO_APPLY_STATE_CHANGES); menu_settings_list_current_add_range( list, list_info, @@ -1250,7 +1250,7 @@ void video_driver_menu_settings(void **list_data, void *list_info_data, menu_settings_list_current_add_cmd( list, list_info, - EVENT_CMD_VIDEO_APPLY_STATE_CHANGES); + CMD_EVENT_VIDEO_APPLY_STATE_CHANGES); #endif #ifdef _XBOX1 CONFIG_UINT( diff --git a/input/drivers/android_input.c b/input/drivers/android_input.c index 312e9972d2..d27b7b3206 100644 --- a/input/drivers/android_input.c +++ b/input/drivers/android_input.c @@ -1067,7 +1067,7 @@ static void android_input_poll(void *data) if (android_app->reinitRequested != 0) { if (runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL)) - command_event(EVENT_CMD_REINIT, NULL); + command_event(CMD_EVENT_REINIT, NULL); android_app_write_cmd(android_app, APP_CMD_REINIT_DONE); return; } @@ -1094,7 +1094,7 @@ bool android_run_events(void *data) if (android_app->reinitRequested != 0) { if (runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL)) - command_event(EVENT_CMD_REINIT, NULL); + command_event(CMD_EVENT_REINIT, NULL); android_app_write_cmd(android_app, APP_CMD_REINIT_DONE); } diff --git a/input/drivers_joypad/ctr_joypad.c b/input/drivers_joypad/ctr_joypad.c index dbe7e278b8..aaf4db24d0 100644 --- a/input/drivers_joypad/ctr_joypad.c +++ b/input/drivers_joypad/ctr_joypad.c @@ -170,7 +170,7 @@ static void ctr_joypad_poll(void) (state_tmp & KEY_SELECT) && (state_tmp & KEY_L) && (state_tmp & KEY_R)) - command_event(EVENT_CMD_QUIT, NULL); + command_event(CMD_EVENT_QUIT, NULL); } diff --git a/menu/cbs/menu_cbs_left.c b/menu/cbs/menu_cbs_left.c index 9ae34ab732..5175e44217 100644 --- a/menu/cbs/menu_cbs_left.c +++ b/menu/cbs/menu_cbs_left.c @@ -369,7 +369,7 @@ static int core_setting_left(unsigned type, const char *label, static int disk_options_disk_idx_left(unsigned type, const char *label, bool wraparound) { - command_event(EVENT_CMD_DISK_PREV, NULL); + command_event(CMD_EVENT_DISK_PREV, NULL); return 0; } diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 44feb5477c..c129b1d76c 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -506,7 +506,7 @@ static int file_load_with_detect_core_wrapper(size_t idx, size_t entry_idx, switch (ret) { case -1: - command_event(EVENT_CMD_LOAD_CORE, NULL); + command_event(CMD_EVENT_LOAD_CORE, NULL); rarch_task_push_content_load_default(NULL, NULL, false, CORE_TYPE_PLAIN, NULL, NULL); @@ -695,7 +695,7 @@ static int action_ok_playlist_entry(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(EVENT_CMD_CHEATS_APPLY, NULL); + command_event(CMD_EVENT_CHEATS_APPLY, NULL); return 0; } @@ -758,7 +758,7 @@ static int generic_action_ok(const char *path, flush_char = NULL; flush_type = MENU_SETTINGS; runloop_ctl(RUNLOOP_CTL_SET_LIBRETRO_PATH, action_path); - if (command_event(EVENT_CMD_LOAD_CORE, NULL)) + if (command_event(CMD_EVENT_LOAD_CORE, NULL)) { #ifndef HAVE_DYNAMIC if (frontend_driver_set_fork(FRONTEND_FORK_CORE)) @@ -818,8 +818,8 @@ static int generic_action_ok(const char *path, case ACTION_OK_APPEND_DISK_IMAGE: flush_char = NULL; flush_type = 49; - command_event(EVENT_CMD_DISK_APPEND_IMAGE, action_path); - command_event(EVENT_CMD_RESUME, NULL); + command_event(CMD_EVENT_DISK_APPEND_IMAGE, action_path); + command_event(CMD_EVENT_RESUME, NULL); break; case ACTION_OK_SET_PATH: flush_char = NULL; @@ -1244,18 +1244,18 @@ static int generic_action_ok_command(enum event_command cmd) static int action_ok_load_state(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { - if (generic_action_ok_command(EVENT_CMD_LOAD_STATE) == -1) + if (generic_action_ok_command(CMD_EVENT_LOAD_STATE) == -1) return menu_cbs_exit(); - return generic_action_ok_command(EVENT_CMD_RESUME); + return generic_action_ok_command(CMD_EVENT_RESUME); } static int action_ok_save_state(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { - if (generic_action_ok_command(EVENT_CMD_SAVE_STATE) == -1) + if (generic_action_ok_command(CMD_EVENT_SAVE_STATE) == -1) return menu_cbs_exit(); - return generic_action_ok_command(EVENT_CMD_RESUME); + return generic_action_ok_command(CMD_EVENT_RESUME); } #ifdef HAVE_NETWORKING @@ -1269,10 +1269,10 @@ static void cb_decompressed(void *task_data, void *user_data, const char *err) switch (type_hash) { case CB_CORE_UPDATER_DOWNLOAD: - command_event(EVENT_CMD_CORE_INFO_INIT, NULL); + command_event(CMD_EVENT_CORE_INFO_INIT, NULL); break; case CB_UPDATE_ASSETS: - command_event(EVENT_CMD_REINIT, NULL); + command_event(CMD_EVENT_REINIT, NULL); break; } } @@ -1414,7 +1414,7 @@ static void cb_generic_download(void *task_data, switch (transf->type_hash) { case CB_CORE_UPDATER_DOWNLOAD: - command_event(EVENT_CMD_CORE_INFO_INIT, NULL); + command_event(CMD_EVENT_CORE_INFO_INIT, NULL); break; } #endif @@ -1592,7 +1592,7 @@ static int action_ok_update_autoconfig_profiles_hid(const char *path, static int action_ok_disk_cycle_tray_status(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { - return generic_action_ok_command(EVENT_CMD_DISK_EJECT_TOGGLE); + return generic_action_ok_command(CMD_EVENT_DISK_EJECT_TOGGLE); } /* creates folder and core options stub file for subsequent runs */ @@ -1637,43 +1637,43 @@ static int action_ok_option_create(const char *path, static int action_ok_close_content(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { - return generic_action_ok_command(EVENT_CMD_UNLOAD_CORE); + return generic_action_ok_command(CMD_EVENT_UNLOAD_CORE); } static int action_ok_quit(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { - return generic_action_ok_command(EVENT_CMD_QUIT); + return generic_action_ok_command(CMD_EVENT_QUIT); } static int action_ok_save_new_config(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { - return generic_action_ok_command(EVENT_CMD_MENU_SAVE_CONFIG); + return generic_action_ok_command(CMD_EVENT_MENU_SAVE_CONFIG); } static int action_ok_resume_content(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { - return generic_action_ok_command(EVENT_CMD_RESUME); + return generic_action_ok_command(CMD_EVENT_RESUME); } static int action_ok_restart_content(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { - return generic_action_ok_command(EVENT_CMD_RESET); + return generic_action_ok_command(CMD_EVENT_RESET); } static int action_ok_screenshot(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { - return generic_action_ok_command(EVENT_CMD_TAKE_SCREENSHOT); + return generic_action_ok_command(CMD_EVENT_TAKE_SCREENSHOT); } static int action_ok_shader_apply_changes(const char *path, const char *label, unsigned type, size_t idx, size_t entry_idx) { - return generic_action_ok_command(EVENT_CMD_SHADERS_APPLY_CHANGES); + return generic_action_ok_command(CMD_EVENT_SHADERS_APPLY_CHANGES); } static int action_ok_lookup_setting(const char *path, @@ -1708,7 +1708,7 @@ static int generic_action_ok_network(const char *path, if (string_is_empty(settings->network.buildbot_url)) return menu_cbs_exit(); - command_event(EVENT_CMD_NETWORK_INIT, NULL); + command_event(CMD_EVENT_NETWORK_INIT, NULL); switch (type_id) { @@ -2109,7 +2109,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(EVENT_CMD_LOAD_CORE, NULL); + command_event(CMD_EVENT_LOAD_CORE, NULL); rarch_task_push_content_load_default( NULL, detect_content_path, false, CORE_TYPE_PLAIN, NULL, NULL); @@ -2153,7 +2153,7 @@ static int action_ok_load_archive_detect_core(const char *path, switch (ret) { case -1: - command_event(EVENT_CMD_LOAD_CORE, NULL); + command_event(CMD_EVENT_LOAD_CORE, NULL); rarch_task_push_content_load_default(NULL, NULL, false, CORE_TYPE_PLAIN, NULL, NULL); return 0; @@ -2228,7 +2228,7 @@ static int action_ok_video_resolution(const char *path, { char msg[PATH_MAX_LENGTH] = {0}; #ifdef __CELLOS_LV2__ - command_event(EVENT_CMD_REINIT, NULL); + command_event(CMD_EVENT_REINIT, NULL); #endif video_driver_set_video_mode(width, height, true); #ifdef GEKKO diff --git a/menu/cbs/menu_cbs_right.c b/menu/cbs/menu_cbs_right.c index f760cdc3d1..2dbc0dd861 100644 --- a/menu/cbs/menu_cbs_right.c +++ b/menu/cbs/menu_cbs_right.c @@ -391,7 +391,7 @@ int core_setting_right(unsigned type, const char *label, static int disk_options_disk_idx_right(unsigned type, const char *label, bool wraparound) { - command_event(EVENT_CMD_DISK_NEXT, NULL); + command_event(CMD_EVENT_DISK_NEXT, NULL); return 0; } diff --git a/menu/cbs/menu_cbs_start.c b/menu/cbs/menu_cbs_start.c index e8f2b6ff59..e29750ad36 100644 --- a/menu/cbs/menu_cbs_start.c +++ b/menu/cbs/menu_cbs_start.c @@ -62,7 +62,7 @@ static int action_start_video_filter_file_load(unsigned type, const char *label) return -1; settings->path.softfilter_plugin[0] = '\0'; - command_event(EVENT_CMD_REINIT, NULL); + command_event(CMD_EVENT_REINIT, NULL); return 0; } diff --git a/menu/drivers/nuklear.c b/menu/drivers/nuklear.c index 88a946f272..27bc4f0b55 100644 --- a/menu/drivers/nuklear.c +++ b/menu/drivers/nuklear.c @@ -389,7 +389,7 @@ static bool nk_menu_init_list(void *data) menu_entries_add(menu_stack, info.path, info.label, info.type, info.flags, 0); - command_event(EVENT_CMD_HISTORY_INIT, NULL); + command_event(CMD_EVENT_HISTORY_INIT, NULL); info.list = selection_buf; diff --git a/menu/drivers/zarch.c b/menu/drivers/zarch.c index 64b21b98e7..24ecf16868 100644 --- a/menu/drivers/zarch.c +++ b/menu/drivers/zarch.c @@ -1156,7 +1156,7 @@ static bool zarch_menu_init_list(void *data) menu_entries_add(menu_stack, info.path, info.label, info.type, info.flags, 0); - command_event(EVENT_CMD_HISTORY_INIT, NULL); + command_event(CMD_EVENT_HISTORY_INIT, NULL); info.list = selection_buf; diff --git a/menu/menu_content.c b/menu/menu_content.c index 37785abe9c..759da171de 100644 --- a/menu/menu_content.c +++ b/menu/menu_content.c @@ -195,10 +195,10 @@ static bool menu_content_load_from_playlist(void *data) else menu_driver_ctl(RARCH_MENU_CTL_SET_LOAD_NO_CONTENT, NULL); - if (!command_event(EVENT_CMD_EXEC, (void*)path)) + if (!command_event(CMD_EVENT_EXEC, (void*)path)) return false; - command_event(EVENT_CMD_LOAD_CORE, NULL); + command_event(CMD_EVENT_LOAD_CORE, NULL); return true; diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 5853b338c1..5adcc3c8b2 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -3775,7 +3775,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) content_playlist_t *playlist = g_defaults.history; if (!playlist) - command_event(EVENT_CMD_HISTORY_INIT, NULL); + command_event(CMD_EVENT_HISTORY_INIT, NULL); strlcpy(path_playlist, "history", sizeof(path_playlist)); diff --git a/menu/menu_driver.c b/menu/menu_driver.c index 3d3d89c9e0..a7ebcfac2a 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -115,7 +115,7 @@ static void bundle_decompressed(void *task_data, decompress_task_data_t *dec = (decompress_task_data_t*)task_data; if (dec && !err) - command_event(EVENT_CMD_REINIT, NULL); + command_event(CMD_EVENT_REINIT, NULL); if (err) RARCH_ERR("%s", err); @@ -159,7 +159,7 @@ static bool menu_init(menu_handle_t *menu_data) menu_data->push_help_screen = true; menu_data->help_screen_type = MENU_HELP_WELCOME; settings->menu_show_start_screen = false; - command_event(EVENT_CMD_MENU_SAVE_CURRENT_CONFIG, NULL); + command_event(CMD_EVENT_MENU_SAVE_CURRENT_CONFIG, NULL); } if ( settings->bundle_assets_extract_enable @@ -245,12 +245,12 @@ static void menu_driver_toggle(bool latch) menu_entries_ctl(MENU_ENTRIES_CTL_SET_REFRESH, &refresh); /* Menu should always run with vsync on. */ - command_event(EVENT_CMD_VIDEO_SET_BLOCKING_STATE, NULL); + command_event(CMD_EVENT_VIDEO_SET_BLOCKING_STATE, NULL); /* Stop all rumbling before entering the menu. */ - command_event(EVENT_CMD_RUMBLE_STOP, NULL); + command_event(CMD_EVENT_RUMBLE_STOP, NULL); if (settings->menu.pause_libretro) - command_event(EVENT_CMD_AUDIO_STOP, NULL); + command_event(CMD_EVENT_AUDIO_STOP, NULL); /* Override keyboard callback to redirect to menu instead. * We'll use this later for something ... */ @@ -269,7 +269,7 @@ static void menu_driver_toggle(bool latch) driver_ctl(RARCH_DRIVER_CTL_SET_NONBLOCK_STATE, NULL); if (settings && settings->menu.pause_libretro) - command_event(EVENT_CMD_AUDIO_START, NULL); + command_event(CMD_EVENT_AUDIO_START, NULL); /* Prevent stray input from going to libretro core */ input_driver_set_flushing_input(); @@ -565,7 +565,7 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data) menu_display_deinit(); menu_entries_ctl(MENU_ENTRIES_CTL_DEINIT, NULL); - command_event(EVENT_CMD_HISTORY_DEINIT, NULL); + command_event(CMD_EVENT_HISTORY_DEINIT, NULL); core_info_deinit_list(); core_info_free_current_core(); @@ -860,7 +860,7 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data) if (menu_driver_ctl(RARCH_MENU_CTL_IS_PENDING_SHUTDOWN, NULL)) { menu_driver_ctl(RARCH_MENU_CTL_UNSET_PENDING_SHUTDOWN, NULL); - if (!command_event(EVENT_CMD_QUIT, NULL)) + if (!command_event(CMD_EVENT_QUIT, NULL)) return false; return true; } diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 7b61ef6ce6..ea9d339edc 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -1336,7 +1336,7 @@ static int setting_generic_action_ok_default(void *data, bool wraparound) (void)wraparound; - if (setting->cmd_trigger.idx != EVENT_CMD_NONE) + if (setting->cmd_trigger.idx != CMD_EVENT_NONE) setting->cmd_trigger.triggered = true; return 0; @@ -2690,7 +2690,7 @@ static int setting_action_ok_video_refresh_rate_auto(void *data, bool wraparound float video_refresh_rate_float = (float)video_refresh_rate; driver_ctl(RARCH_DRIVER_CTL_SET_REFRESH_RATE, &video_refresh_rate_float); /* Incase refresh rate update forced non-block video. */ - command_event(EVENT_CMD_VIDEO_SET_BLOCKING_STATE, NULL); + command_event(CMD_EVENT_VIDEO_SET_BLOCKING_STATE, NULL); } if (setting_generic_action_ok_default(setting, wraparound) != 0) @@ -2749,7 +2749,7 @@ static int setting_action_action_ok(void *data, bool wraparound) (void)wraparound; - if (setting->cmd_trigger.idx != EVENT_CMD_NONE) + if (setting->cmd_trigger.idx != CMD_EVENT_NONE) command_event(setting->cmd_trigger.idx, NULL); return 0; @@ -2878,7 +2878,7 @@ void general_read_handler(void *data) void general_write_handler(void *data) { - enum event_command rarch_cmd = EVENT_CMD_NONE; + enum event_command rarch_cmd = CMD_EVENT_NONE; menu_displaylist_info_t info = {0}; rarch_setting_t *setting = (rarch_setting_t*)data; settings_t *settings = config_get_ptr(); @@ -2893,7 +2893,7 @@ void general_write_handler(void *data) if (!setting) return; - if (setting->cmd_trigger.idx != EVENT_CMD_NONE) + if (setting->cmd_trigger.idx != CMD_EVENT_NONE) { if (flags & SD_FLAG_EXIT) { @@ -2972,13 +2972,13 @@ void general_write_handler(void *data) driver_ctl(RARCH_DRIVER_CTL_SET_REFRESH_RATE, setting->value.target.fraction); /* In case refresh rate update forced non-block video. */ - rarch_cmd = EVENT_CMD_VIDEO_SET_BLOCKING_STATE; + rarch_cmd = CMD_EVENT_VIDEO_SET_BLOCKING_STATE; break; case MENU_LABEL_VIDEO_SCALE: settings->video.scale = roundf(*setting->value.target.fraction); if (!settings->video.fullscreen) - rarch_cmd = EVENT_CMD_REINIT; + rarch_cmd = CMD_EVENT_REINIT; break; case MENU_LABEL_INPUT_PLAYER1_JOYPAD_INDEX: settings->input.joypad_map[0] = *setting->value.target.integer; @@ -3015,11 +3015,11 @@ void general_write_handler(void *data) audio_driver_set_volume_gain(db_to_gain(*setting->value.target.fraction)); break; case MENU_LABEL_AUDIO_LATENCY: - rarch_cmd = EVENT_CMD_AUDIO_REINIT; + rarch_cmd = CMD_EVENT_AUDIO_REINIT; break; case MENU_LABEL_PAL60_ENABLE: if (*setting->value.target.boolean && global->console.screen.pal_enable) - rarch_cmd = EVENT_CMD_REINIT; + rarch_cmd = CMD_EVENT_REINIT; else menu_setting_set_with_string_representation(setting, "false"); break; @@ -3116,14 +3116,14 @@ static void overlay_enable_toggle_change_handler(void *data) if (settings && settings->input.overlay_hide_in_menu) { - command_event(EVENT_CMD_OVERLAY_DEINIT, NULL); + command_event(CMD_EVENT_OVERLAY_DEINIT, NULL); return; } if (setting->value.target.boolean) - command_event(EVENT_CMD_OVERLAY_INIT, NULL); + command_event(CMD_EVENT_OVERLAY_INIT, NULL); else - command_event(EVENT_CMD_OVERLAY_DEINIT, NULL); + command_event(CMD_EVENT_OVERLAY_DEINIT, NULL); } #endif @@ -3522,7 +3522,7 @@ static bool setting_append_list( (*list)[list_info->index - 1].size = sizeof(settings->path.libretro); (*list)[list_info->index - 1].value.target.string = settings->path.libretro; (*list)[list_info->index - 1].values = ext_name; - menu_settings_list_current_add_cmd(list, list_info, EVENT_CMD_LOAD_CORE); + menu_settings_list_current_add_cmd(list, list_info, CMD_EVENT_LOAD_CORE); settings_data_list_current_add_flags(list, list_info, SD_FLAG_BROWSER_ACTION); } } @@ -3592,7 +3592,7 @@ static bool setting_append_list( &group_info, &subgroup_info, parent_group); - menu_settings_list_current_add_cmd(list, list_info, EVENT_CMD_RESTART_RETROARCH); + menu_settings_list_current_add_cmd(list, list_info, CMD_EVENT_RESTART_RETROARCH); #endif CONFIG_ACTION( @@ -3610,7 +3610,7 @@ static bool setting_append_list( &group_info, &subgroup_info, parent_group); - menu_settings_list_current_add_cmd(list, list_info, EVENT_CMD_MENU_SAVE_CURRENT_CONFIG); + menu_settings_list_current_add_cmd(list, list_info, CMD_EVENT_MENU_SAVE_CURRENT_CONFIG); CONFIG_ACTION( list, list_info, @@ -3619,7 +3619,7 @@ static bool setting_append_list( &group_info, &subgroup_info, parent_group); - menu_settings_list_current_add_cmd(list, list_info, EVENT_CMD_MENU_SAVE_CONFIG); + menu_settings_list_current_add_cmd(list, list_info, CMD_EVENT_MENU_SAVE_CONFIG); CONFIG_ACTION( list, list_info, @@ -3638,7 +3638,7 @@ static bool setting_append_list( &group_info, &subgroup_info, parent_group); - menu_settings_list_current_add_cmd(list, list_info, EVENT_CMD_QUIT_RETROARCH); + menu_settings_list_current_add_cmd(list, list_info, CMD_EVENT_QUIT_RETROARCH); #endif #if defined(HAVE_LAKKA) @@ -3649,7 +3649,7 @@ static bool setting_append_list( &group_info, &subgroup_info, parent_group); - menu_settings_list_current_add_cmd(list, list_info, EVENT_CMD_SHUTDOWN); + menu_settings_list_current_add_cmd(list, list_info, CMD_EVENT_SHUTDOWN); CONFIG_ACTION( list, list_info, @@ -3658,7 +3658,7 @@ static bool setting_append_list( &group_info, &subgroup_info, parent_group); - menu_settings_list_current_add_cmd(list, list_info, EVENT_CMD_REBOOT); + menu_settings_list_current_add_cmd(list, list_info, CMD_EVENT_REBOOT); #endif CONFIG_ACTION( @@ -4131,7 +4131,7 @@ static bool setting_append_list( parent_group, general_write_handler, general_read_handler); - menu_settings_list_current_add_cmd(list, list_info, EVENT_CMD_AUTOSAVE_INIT); + menu_settings_list_current_add_cmd(list, list_info, CMD_EVENT_AUTOSAVE_INIT); menu_settings_list_current_add_range(list, list_info, 0, 0, 10, true, false); settings_data_list_current_add_flags(list, list_info, SD_FLAG_CMD_APPLY_AUTO); (*list)[list_info->index - 1].get_string_representation = @@ -4204,7 +4204,7 @@ static bool setting_append_list( parent_group, general_write_handler, general_read_handler); - menu_settings_list_current_add_cmd(list, list_info, EVENT_CMD_REWIND_TOGGLE); + menu_settings_list_current_add_cmd(list, list_info, CMD_EVENT_REWIND_TOGGLE); settings_data_list_current_add_flags(list, list_info, SD_FLAG_CMD_APPLY_AUTO); #if 0 @@ -4292,7 +4292,7 @@ static bool setting_append_list( parent_group, general_write_handler, general_read_handler); - menu_settings_list_current_add_cmd(list, list_info, EVENT_CMD_REINIT); + menu_settings_list_current_add_cmd(list, list_info, CMD_EVENT_REINIT); menu_settings_list_current_add_range(list, list_info, 0, 1, 1, true, false); (*list)[list_info->index - 1].get_string_representation = &setting_get_string_representation_uint_video_monitor_index; @@ -4313,7 +4313,7 @@ static bool setting_append_list( parent_group, general_write_handler, general_read_handler); - menu_settings_list_current_add_cmd(list, list_info, EVENT_CMD_REINIT); + menu_settings_list_current_add_cmd(list, list_info, CMD_EVENT_REINIT); settings_data_list_current_add_flags(list, list_info, SD_FLAG_CMD_APPLY_AUTO); } if (video_driver_has_windowed()) @@ -4380,7 +4380,7 @@ static bool setting_append_list( parent_group, general_write_handler, general_read_handler); - menu_settings_list_current_add_cmd(list, list_info, EVENT_CMD_REINIT); + menu_settings_list_current_add_cmd(list, list_info, CMD_EVENT_REINIT); settings_data_list_current_add_flags(list, list_info, SD_FLAG_CMD_APPLY_AUTO|SD_FLAG_ADVANCED); } @@ -4400,7 +4400,7 @@ static bool setting_append_list( menu_settings_list_current_add_cmd( list, list_info, - EVENT_CMD_VIDEO_SET_ASPECT_RATIO); + CMD_EVENT_VIDEO_SET_ASPECT_RATIO); menu_settings_list_current_add_range( list, list_info, @@ -4428,7 +4428,7 @@ static bool setting_append_list( menu_settings_list_current_add_cmd( list, list_info, - EVENT_CMD_VIDEO_APPLY_STATE_CHANGES); + CMD_EVENT_VIDEO_APPLY_STATE_CHANGES); CONFIG_INT( list, list_info, @@ -4445,7 +4445,7 @@ static bool setting_append_list( menu_settings_list_current_add_cmd( list, list_info, - EVENT_CMD_VIDEO_APPLY_STATE_CHANGES); + CMD_EVENT_VIDEO_APPLY_STATE_CHANGES); CONFIG_UINT( list, list_info, @@ -4465,7 +4465,7 @@ static bool setting_append_list( menu_settings_list_current_add_cmd( list, list_info, - EVENT_CMD_VIDEO_APPLY_STATE_CHANGES); + CMD_EVENT_VIDEO_APPLY_STATE_CHANGES); CONFIG_UINT( list, list_info, @@ -4485,7 +4485,7 @@ static bool setting_append_list( menu_settings_list_current_add_cmd( list, list_info, - EVENT_CMD_VIDEO_APPLY_STATE_CHANGES); + CMD_EVENT_VIDEO_APPLY_STATE_CHANGES); END_SUB_GROUP(list, list_info, parent_group); START_SUB_GROUP(list, list_info, "Scaling", &group_info, &subgroup_info, parent_group); @@ -4523,7 +4523,7 @@ static bool setting_append_list( menu_settings_list_current_add_cmd( list, list_info, - EVENT_CMD_VIDEO_APPLY_STATE_CHANGES); + CMD_EVENT_VIDEO_APPLY_STATE_CHANGES); #ifdef GEKKO CONFIG_UINT( @@ -4608,7 +4608,7 @@ static bool setting_append_list( parent_group, general_write_handler, general_read_handler); - menu_settings_list_current_add_cmd(list, list_info, EVENT_CMD_REINIT); + menu_settings_list_current_add_cmd(list, list_info, CMD_EVENT_REINIT); settings_data_list_current_add_flags(list, list_info, SD_FLAG_CMD_APPLY_AUTO|SD_FLAG_ADVANCED); #endif @@ -4637,7 +4637,7 @@ static bool setting_append_list( parent_group, general_write_handler, general_read_handler); - menu_settings_list_current_add_cmd(list, list_info, EVENT_CMD_VIDEO_SET_BLOCKING_STATE); + menu_settings_list_current_add_cmd(list, list_info, CMD_EVENT_VIDEO_SET_BLOCKING_STATE); menu_settings_list_current_add_range(list, list_info, 1, 4, 1, true, true); settings_data_list_current_add_flags(list, list_info, SD_FLAG_CMD_APPLY_AUTO|SD_FLAG_ADVANCED); @@ -4765,7 +4765,7 @@ static bool setting_append_list( general_write_handler, general_read_handler); menu_settings_list_current_add_values(list, list_info, "filt"); - menu_settings_list_current_add_cmd(list, list_info, EVENT_CMD_REINIT); + menu_settings_list_current_add_cmd(list, list_info, CMD_EVENT_REINIT); settings_data_list_current_add_flags(list, list_info, SD_FLAG_ALLOW_EMPTY); END_SUB_GROUP(list, list_info, parent_group); @@ -4989,7 +4989,7 @@ static bool setting_append_list( general_write_handler, general_read_handler); menu_settings_list_current_add_values(list, list_info, "dsp"); - menu_settings_list_current_add_cmd(list, list_info, EVENT_CMD_DSP_FILTER_INIT); + menu_settings_list_current_add_cmd(list, list_info, CMD_EVENT_DSP_FILTER_INIT); settings_data_list_current_add_flags(list, list_info, SD_FLAG_ALLOW_EMPTY); END_SUB_GROUP(list, list_info, parent_group); @@ -5408,7 +5408,7 @@ static bool setting_append_list( parent_group, general_write_handler, general_read_handler); - menu_settings_list_current_add_cmd(list, list_info, EVENT_CMD_SET_FRAME_LIMIT); + menu_settings_list_current_add_cmd(list, list_info, CMD_EVENT_SET_FRAME_LIMIT); menu_settings_list_current_add_range(list, list_info, 0, 10, 1.0, true, true); CONFIG_FLOAT( @@ -5611,7 +5611,7 @@ static bool setting_append_list( general_write_handler, general_read_handler); menu_settings_list_current_add_values(list, list_info, "cfg"); - menu_settings_list_current_add_cmd(list, list_info, EVENT_CMD_OVERLAY_INIT); + menu_settings_list_current_add_cmd(list, list_info, CMD_EVENT_OVERLAY_INIT); settings_data_list_current_add_flags(list, list_info, SD_FLAG_ALLOW_EMPTY); CONFIG_FLOAT( @@ -5626,7 +5626,7 @@ static bool setting_append_list( parent_group, general_write_handler, general_read_handler); - menu_settings_list_current_add_cmd(list, list_info, EVENT_CMD_OVERLAY_SET_ALPHA_MOD); + menu_settings_list_current_add_cmd(list, list_info, CMD_EVENT_OVERLAY_SET_ALPHA_MOD); menu_settings_list_current_add_range(list, list_info, 0, 1, 0.01, true, true); settings_data_list_current_add_flags(list, list_info, SD_FLAG_CMD_APPLY_AUTO); @@ -5642,7 +5642,7 @@ static bool setting_append_list( parent_group, general_write_handler, general_read_handler); - menu_settings_list_current_add_cmd(list, list_info, EVENT_CMD_OVERLAY_SET_SCALE_FACTOR); + menu_settings_list_current_add_cmd(list, list_info, CMD_EVENT_OVERLAY_SET_SCALE_FACTOR); menu_settings_list_current_add_range(list, list_info, 0, 2, 0.01, true, true); settings_data_list_current_add_flags(list, list_info, SD_FLAG_CMD_APPLY_AUTO); @@ -5721,7 +5721,7 @@ static bool setting_append_list( parent_group, general_write_handler, general_read_handler); - menu_settings_list_current_add_cmd(list, list_info, EVENT_CMD_MENU_PAUSE_LIBRETRO); + menu_settings_list_current_add_cmd(list, list_info, CMD_EVENT_MENU_PAUSE_LIBRETRO); settings_data_list_current_add_flags(list, list_info, SD_FLAG_CMD_APPLY_AUTO); CONFIG_BOOL( @@ -6152,7 +6152,7 @@ static bool setting_append_list( parent_group, general_write_handler, general_read_handler); - menu_settings_list_current_add_cmd(list, list_info, EVENT_CMD_REINIT); + menu_settings_list_current_add_cmd(list, list_info, CMD_EVENT_REINIT); settings_data_list_current_add_flags(list, list_info, SD_FLAG_CMD_APPLY_AUTO); CONFIG_BOOL( @@ -6308,7 +6308,7 @@ static bool setting_append_list( parent_group, general_write_handler, general_read_handler); - menu_settings_list_current_add_cmd(list, list_info, EVENT_CMD_CHEEVOS_HARDCORE_MODE_TOGGLE); + menu_settings_list_current_add_cmd(list, list_info, CMD_EVENT_CHEEVOS_HARDCORE_MODE_TOGGLE); END_SUB_GROUP(list, list_info, parent_group); END_GROUP(list, list_info, parent_group); @@ -6707,7 +6707,7 @@ static bool setting_append_list( true, true); settings_data_list_current_add_flags(list, list_info, SD_FLAG_ALLOW_INPUT); - menu_settings_list_current_add_cmd(list, list_info, EVENT_CMD_MENU_REFRESH); + menu_settings_list_current_add_cmd(list, list_info, CMD_EVENT_MENU_REFRESH); (*list)[list_info->index - 1].get_string_representation = &setting_get_string_representation_uint_user_language; @@ -6928,7 +6928,7 @@ static bool setting_append_list( parent_group, general_write_handler, general_read_handler); - menu_settings_list_current_add_cmd(list, list_info, EVENT_CMD_CORE_INFO_INIT); + menu_settings_list_current_add_cmd(list, list_info, CMD_EVENT_CORE_INFO_INIT); settings_data_list_current_add_flags( list, list_info, @@ -6947,7 +6947,7 @@ static bool setting_append_list( parent_group, general_write_handler, general_read_handler); - menu_settings_list_current_add_cmd(list, list_info, EVENT_CMD_CORE_INFO_INIT); + menu_settings_list_current_add_cmd(list, list_info, CMD_EVENT_CORE_INFO_INIT); settings_data_list_current_add_flags( list, list_info, diff --git a/network/netplay.c b/network/netplay.c index 7b5a848a03..2a26c5b523 100644 --- a/network/netplay.c +++ b/network/netplay.c @@ -276,11 +276,11 @@ static bool netplay_get_cmd(netplay_t *netplay) return netplay_cmd_nak(netplay); case NETPLAY_CMD_PAUSE: - command_event(EVENT_CMD_PAUSE, NULL); + command_event(CMD_EVENT_PAUSE, NULL); return netplay_cmd_ack(netplay); case NETPLAY_CMD_RESUME: - command_event(EVENT_CMD_UNPAUSE, NULL); + command_event(CMD_EVENT_UNPAUSE, NULL); return netplay_cmd_ack(netplay); default: break; @@ -1163,7 +1163,7 @@ bool netplay_driver_ctl(enum rarch_netplay_ctl_state state, void *data) { bool *state = (bool*)data; if (*state) - command_event(EVENT_CMD_FULLSCREEN_TOGGLE, NULL); + command_event(CMD_EVENT_FULLSCREEN_TOGGLE, NULL); } break; default: diff --git a/record/record_driver.c b/record/record_driver.c index 83ac334275..d99b3fc51c 100644 --- a/record/record_driver.c +++ b/record/record_driver.c @@ -198,7 +198,7 @@ void recording_dump_frame(const void *data, unsigned width, { RARCH_WARN("%s \n", msg_hash_to_str(MSG_VIEWPORT_SIZE_CALCULATION_FAILED)); - command_event(EVENT_CMD_GPU_RECORD_DEINIT, NULL); + command_event(CMD_EVENT_GPU_RECORD_DEINIT, NULL); recording_dump_frame(data, width, height, pitch); return; @@ -213,7 +213,7 @@ void recording_dump_frame(const void *data, unsigned width, runloop_msg_queue_push( msg_hash_to_str(MSG_RECORDING_TERMINATED_DUE_TO_RESIZE), 1, 180, true); - command_event(EVENT_CMD_RECORD_DEINIT, NULL); + command_event(CMD_EVENT_RECORD_DEINIT, NULL); return; } @@ -256,7 +256,7 @@ bool recording_deinit(void) recording_data = NULL; recording_driver = NULL; - command_event(EVENT_CMD_GPU_RECORD_DEINIT, NULL); + command_event(CMD_EVENT_GPU_RECORD_DEINIT, NULL); return true; } @@ -425,7 +425,7 @@ bool recording_init(void) if (!record_driver_init_first(&recording_driver, &recording_data, ¶ms)) { RARCH_ERR("%s\n", msg_hash_to_str(MSG_FAILED_TO_START_RECORDING)); - command_event(EVENT_CMD_GPU_RECORD_DEINIT, NULL); + command_event(CMD_EVENT_GPU_RECORD_DEINIT, NULL); return false; } diff --git a/retroarch.c b/retroarch.c index 3ca465fa95..3cca26e356 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1069,7 +1069,7 @@ static void retroarch_init_savefile_paths(void) runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); - command_event(EVENT_CMD_SAVEFILES_DEINIT, NULL); + command_event(CMD_EVENT_SAVEFILES_DEINIT, NULL); global->savefiles = string_list_new(); retro_assert(global->savefiles); @@ -1299,25 +1299,25 @@ static int retroarch_main_init(int argc, char *argv[]) } driver_ctl(RARCH_DRIVER_CTL_INIT_PRE, NULL); - if (!command_event(EVENT_CMD_CORE_INIT, ¤t_core_type)) + if (!command_event(CMD_EVENT_CORE_INIT, ¤t_core_type)) goto error; driver_ctl(RARCH_DRIVER_CTL_INIT_ALL, NULL); - command_event(EVENT_CMD_COMMAND_INIT, NULL); - command_event(EVENT_CMD_REMOTE_INIT, NULL); - command_event(EVENT_CMD_REWIND_INIT, NULL); - command_event(EVENT_CMD_CONTROLLERS_INIT, NULL); - command_event(EVENT_CMD_RECORD_INIT, NULL); - command_event(EVENT_CMD_CHEATS_INIT, NULL); - command_event(EVENT_CMD_SAVEFILES_INIT, NULL); - command_event(EVENT_CMD_SET_PER_GAME_RESOLUTION, NULL); + command_event(CMD_EVENT_COMMAND_INIT, NULL); + command_event(CMD_EVENT_REMOTE_INIT, NULL); + command_event(CMD_EVENT_REWIND_INIT, NULL); + command_event(CMD_EVENT_CONTROLLERS_INIT, NULL); + command_event(CMD_EVENT_RECORD_INIT, NULL); + command_event(CMD_EVENT_CHEATS_INIT, NULL); + command_event(CMD_EVENT_SAVEFILES_INIT, NULL); + command_event(CMD_EVENT_SET_PER_GAME_RESOLUTION, NULL); rarch_ctl(RARCH_CTL_UNSET_ERROR_ON_INIT, NULL); rarch_ctl(RARCH_CTL_SET_INITED, NULL); return 0; error: - command_event(EVENT_CMD_CORE_DEINIT, NULL); + command_event(CMD_EVENT_CORE_DEINIT, NULL); rarch_ctl(RARCH_CTL_UNSET_INITED, NULL); return 1; } @@ -1382,7 +1382,7 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data) runloop_ctl(RUNLOOP_CTL_MSG_QUEUE_DEINIT, NULL); driver_ctl(RARCH_DRIVER_CTL_UNINIT_ALL, NULL); - command_event(EVENT_CMD_LOG_FILE_DEINIT, NULL); + command_event(CMD_EVENT_LOG_FILE_DEINIT, NULL); runloop_ctl(RUNLOOP_CTL_STATE_FREE, NULL); runloop_ctl(RUNLOOP_CTL_GLOBAL_FREE, NULL); @@ -1399,33 +1399,33 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data) if (!config_realloc()) return false; - command_event(EVENT_CMD_HISTORY_DEINIT, NULL); + command_event(CMD_EVENT_HISTORY_DEINIT, NULL); runloop_ctl(RUNLOOP_CTL_CLEAR_STATE, NULL); break; case RARCH_CTL_MAIN_DEINIT: if (!rarch_ctl(RARCH_CTL_IS_INITED, NULL)) return false; - command_event(EVENT_CMD_NETPLAY_DEINIT, NULL); - command_event(EVENT_CMD_COMMAND_DEINIT, NULL); - command_event(EVENT_CMD_REMOTE_DEINIT, NULL); + command_event(CMD_EVENT_NETPLAY_DEINIT, NULL); + command_event(CMD_EVENT_COMMAND_DEINIT, NULL); + command_event(CMD_EVENT_REMOTE_DEINIT, NULL); - command_event(EVENT_CMD_AUTOSAVE_DEINIT, NULL); + command_event(CMD_EVENT_AUTOSAVE_DEINIT, NULL); - command_event(EVENT_CMD_RECORD_DEINIT, NULL); - command_event(EVENT_CMD_SAVEFILES, NULL); + command_event(CMD_EVENT_RECORD_DEINIT, NULL); + command_event(CMD_EVENT_SAVEFILES, NULL); - command_event(EVENT_CMD_REWIND_DEINIT, NULL); - command_event(EVENT_CMD_CHEATS_DEINIT, NULL); - command_event(EVENT_CMD_BSV_MOVIE_DEINIT, NULL); + command_event(CMD_EVENT_REWIND_DEINIT, NULL); + command_event(CMD_EVENT_CHEATS_DEINIT, NULL); + command_event(CMD_EVENT_BSV_MOVIE_DEINIT, NULL); - command_event(EVENT_CMD_AUTOSAVE_STATE, NULL); + command_event(CMD_EVENT_AUTOSAVE_STATE, NULL); - command_event(EVENT_CMD_CORE_DEINIT, NULL); + command_event(CMD_EVENT_CORE_DEINIT, NULL); - command_event(EVENT_CMD_TEMPORARY_CONTENT_DEINIT, NULL); - command_event(EVENT_CMD_SUBSYSTEM_FULLPATHS_DEINIT, NULL); - command_event(EVENT_CMD_SAVEFILES_DEINIT, NULL); + command_event(CMD_EVENT_TEMPORARY_CONTENT_DEINIT, NULL); + command_event(CMD_EVENT_SUBSYSTEM_FULLPATHS_DEINIT, NULL); + command_event(CMD_EVENT_SAVEFILES_DEINIT, NULL); rarch_ctl(RARCH_CTL_UNSET_INITED, NULL); break; @@ -1511,7 +1511,7 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data) #endif #ifdef HAVE_OVERLAY if (settings->input.overlay_hide_in_menu) - command_event(EVENT_CMD_OVERLAY_DEINIT, NULL); + command_event(CMD_EVENT_OVERLAY_DEINIT, NULL); #endif break; case RARCH_CTL_LOAD_CONTENT: @@ -1533,7 +1533,7 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data) video_driver_set_texture_enable(false, false); #ifdef HAVE_OVERLAY if (settings && settings->input.overlay_hide_in_menu) - command_event(EVENT_CMD_OVERLAY_INIT, NULL); + command_event(CMD_EVENT_OVERLAY_INIT, NULL); #endif break; case RARCH_CTL_QUIT: diff --git a/runloop.c b/runloop.c index 0653374ba0..97be8b4e5d 100644 --- a/runloop.c +++ b/runloop.c @@ -186,7 +186,7 @@ static bool runloop_check_movie_playback(void) msg_hash_to_str(MSG_MOVIE_PLAYBACK_ENDED), 1, 180, false); RARCH_LOG("%s\n", msg_hash_to_str(MSG_MOVIE_PLAYBACK_ENDED)); - command_event(EVENT_CMD_BSV_MOVIE_DEINIT, NULL); + command_event(CMD_EVENT_BSV_MOVIE_DEINIT, NULL); bsv_movie_ctl(BSV_MOVIE_CTL_UNSET_END, NULL); bsv_movie_ctl(BSV_MOVIE_CTL_UNSET_PLAYBACK, NULL); @@ -204,7 +204,7 @@ static bool runloop_check_movie_record(void) msg_hash_to_str(MSG_MOVIE_RECORD_STOPPED), 2, 180, true); RARCH_LOG("%s\n", msg_hash_to_str(MSG_MOVIE_RECORD_STOPPED)); - command_event(EVENT_CMD_BSV_MOVIE_DEINIT, NULL); + command_event(CMD_EVENT_BSV_MOVIE_DEINIT, NULL); return true; } @@ -279,22 +279,22 @@ static bool check_pause(settings_t *settings, bool frameadvance_pressed) { static bool old_focus = true; - enum event_command cmd = EVENT_CMD_NONE; + enum event_command cmd = CMD_EVENT_NONE; bool old_is_paused = runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL); /* FRAMEADVANCE will set us into pause mode. */ pause_pressed |= !old_is_paused && frameadvance_pressed; if (focus && pause_pressed) - cmd = EVENT_CMD_PAUSE_TOGGLE; + cmd = CMD_EVENT_PAUSE_TOGGLE; else if (focus && !old_focus) - cmd = EVENT_CMD_UNPAUSE; + cmd = CMD_EVENT_UNPAUSE; else if (!focus && old_focus) - cmd = EVENT_CMD_PAUSE; + cmd = CMD_EVENT_PAUSE; old_focus = focus; - if (cmd != EVENT_CMD_NONE) + if (cmd != CMD_EVENT_NONE) command_event(cmd, NULL); if (runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL) == old_is_paused) @@ -394,7 +394,7 @@ static bool shader_dir_init(rarch_dir_list_t *dir_list) if (!dir_list->list || dir_list->list->size == 0) { - command_event(EVENT_CMD_SHADER_DIR_DEINIT, NULL); + command_event(CMD_EVENT_SHADER_DIR_DEINIT, NULL); return false; } @@ -517,10 +517,10 @@ static bool runloop_check_state(event_cmd_state_t *cmd, rarch_dir_list_t *shader return false; if (runloop_cmd_triggered(cmd, RARCH_SCREENSHOT)) - command_event(EVENT_CMD_TAKE_SCREENSHOT, NULL); + command_event(CMD_EVENT_TAKE_SCREENSHOT, NULL); if (runloop_cmd_triggered(cmd, RARCH_MUTE)) - command_event(EVENT_CMD_AUDIO_MUTE_TOGGLE, NULL); + command_event(CMD_EVENT_AUDIO_MUTE_TOGGLE, NULL); if (runloop_cmd_triggered(cmd, RARCH_OSK)) { @@ -534,9 +534,9 @@ static bool runloop_check_state(event_cmd_state_t *cmd, rarch_dir_list_t *shader } if (runloop_cmd_press(cmd, RARCH_VOLUME_UP)) - command_event(EVENT_CMD_VOLUME_UP, NULL); + command_event(CMD_EVENT_VOLUME_UP, NULL); else if (runloop_cmd_press(cmd, RARCH_VOLUME_DOWN)) - command_event(EVENT_CMD_VOLUME_DOWN, NULL); + command_event(CMD_EVENT_VOLUME_DOWN, NULL); #ifdef HAVE_NETPLAY tmp = runloop_cmd_triggered(cmd, RARCH_NETPLAY_FLIP); @@ -557,9 +557,9 @@ static bool runloop_check_state(event_cmd_state_t *cmd, rarch_dir_list_t *shader ); if (runloop_cmd_triggered(cmd, RARCH_SAVE_STATE_KEY)) - command_event(EVENT_CMD_SAVE_STATE, NULL); + command_event(CMD_EVENT_SAVE_STATE, NULL); else if (runloop_cmd_triggered(cmd, RARCH_LOAD_STATE_KEY)) - command_event(EVENT_CMD_LOAD_STATE, NULL); + command_event(CMD_EVENT_LOAD_STATE, NULL); #ifdef HAVE_CHEEVOS if(!settings->cheevos.hardcore_mode_enable) @@ -578,14 +578,14 @@ static bool runloop_check_state(event_cmd_state_t *cmd, rarch_dir_list_t *shader runloop_cmd_triggered(cmd, RARCH_SHADER_PREV)); if (runloop_cmd_triggered(cmd, RARCH_DISK_EJECT_TOGGLE)) - command_event(EVENT_CMD_DISK_EJECT_TOGGLE, NULL); + command_event(CMD_EVENT_DISK_EJECT_TOGGLE, NULL); else if (runloop_cmd_triggered(cmd, RARCH_DISK_NEXT)) - command_event(EVENT_CMD_DISK_NEXT, NULL); + command_event(CMD_EVENT_DISK_NEXT, NULL); else if (runloop_cmd_triggered(cmd, RARCH_DISK_PREV)) - command_event(EVENT_CMD_DISK_PREV, NULL); + command_event(CMD_EVENT_DISK_PREV, NULL); if (runloop_cmd_triggered(cmd, RARCH_RESET)) - command_event(EVENT_CMD_RESET, NULL); + command_event(CMD_EVENT_RESET, NULL); cheat_manager_state_checks( runloop_cmd_triggered(cmd, RARCH_CHEAT_INDEX_PLUS), @@ -611,7 +611,7 @@ static bool runloop_check_pause_state(event_cmd_state_t *cmd) if (runloop_cmd_triggered(cmd, RARCH_FULLSCREEN_TOGGLE_KEY)) { - command_event(EVENT_CMD_FULLSCREEN_TOGGLE, NULL); + command_event(CMD_EVENT_FULLSCREEN_TOGGLE, NULL); video_driver_cached_frame_render(); } @@ -909,10 +909,10 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) case RUNLOOP_CTL_GLOBAL_FREE: { global_t *global = NULL; - command_event(EVENT_CMD_TEMPORARY_CONTENT_DEINIT, NULL); - command_event(EVENT_CMD_SUBSYSTEM_FULLPATHS_DEINIT, NULL); - command_event(EVENT_CMD_RECORD_DEINIT, NULL); - command_event(EVENT_CMD_LOG_FILE_DEINIT, NULL); + command_event(CMD_EVENT_TEMPORARY_CONTENT_DEINIT, NULL); + command_event(CMD_EVENT_SUBSYSTEM_FULLPATHS_DEINIT, NULL); + command_event(CMD_EVENT_RECORD_DEINIT, NULL); + command_event(CMD_EVENT_LOG_FILE_DEINIT, NULL); rarch_ctl(RARCH_CTL_UNSET_BLOCK_CONFIG_READ, NULL); runloop_ctl(RUNLOOP_CTL_CLEAR_CONTENT_PATH, NULL); @@ -1212,19 +1212,19 @@ static void runloop_iterate_linefeed_overlay(settings_t *settings) { input_driver_unset_onscreen_keyboard_enabled(); prev_overlay_restore = true; - command_event(EVENT_CMD_OVERLAY_DEINIT, NULL); + command_event(CMD_EVENT_OVERLAY_DEINIT, NULL); } else if (!osk_enable && input_keyboard_ctl( RARCH_INPUT_KEYBOARD_CTL_IS_LINEFEED_ENABLED, NULL)) { input_driver_set_onscreen_keyboard_enabled(); prev_overlay_restore = false; - command_event(EVENT_CMD_OVERLAY_INIT, NULL); + command_event(CMD_EVENT_OVERLAY_INIT, NULL); } else if (prev_overlay_restore) { if (!settings->input.overlay_hide_in_menu) - command_event(EVENT_CMD_OVERLAY_INIT, NULL); + command_event(CMD_EVENT_OVERLAY_INIT, NULL); prev_overlay_restore = false; } } @@ -1366,7 +1366,7 @@ int runloop_iterate(unsigned *sleep_ms) cmd.state[2] = cmd.state[0] & ~cmd.state[1]; /* trigger */ if (runloop_cmd_triggered(cmd_ptr, RARCH_OVERLAY_NEXT)) - command_event(EVENT_CMD_OVERLAY_NEXT, NULL); + command_event(CMD_EVENT_OVERLAY_NEXT, NULL); if (runloop_cmd_triggered(cmd_ptr, RARCH_FULLSCREEN_TOGGLE_KEY)) { @@ -1377,11 +1377,11 @@ int runloop_iterate(unsigned *sleep_ms) #endif if (fullscreen_toggled) - command_event(EVENT_CMD_FULLSCREEN_TOGGLE, NULL); + command_event(CMD_EVENT_FULLSCREEN_TOGGLE, NULL); } if (runloop_cmd_triggered(cmd_ptr, RARCH_GRAB_MOUSE_TOGGLE)) - command_event(EVENT_CMD_GRAB_MOUSE_TOGGLE, NULL); + command_event(CMD_EVENT_GRAB_MOUSE_TOGGLE, NULL); #ifdef HAVE_MENU if (runloop_cmd_menu_press(cmd_ptr) || diff --git a/tasks/task_content.c b/tasks/task_content.c index 6bf6045a96..0d73d769aa 100644 --- a/tasks/task_content.c +++ b/tasks/task_content.c @@ -30,12 +30,12 @@ bool rarch_task_push_content_load_default( bool persist, enum rarch_core_type type, retro_task_callback_t cb, void *user_data) { - enum event_command cmd = EVENT_CMD_NONE; + enum event_command cmd = CMD_EVENT_NONE; if (core_path) { runloop_ctl(RUNLOOP_CTL_SET_LIBRETRO_PATH, (void*)core_path); - command_event(EVENT_CMD_LOAD_CORE, NULL); + command_event(CMD_EVENT_LOAD_CORE, NULL); } if (fullpath) @@ -45,21 +45,21 @@ bool rarch_task_push_content_load_default( { case CORE_TYPE_PLAIN: case CORE_TYPE_DUMMY: - cmd = persist ? EVENT_CMD_LOAD_CONTENT_PERSIST : EVENT_CMD_LOAD_CONTENT; + cmd = persist ? CMD_EVENT_LOAD_CONTENT_PERSIST : CMD_EVENT_LOAD_CONTENT; break; case CORE_TYPE_FFMPEG: #ifdef HAVE_FFMPEG - cmd = EVENT_CMD_LOAD_CONTENT_FFMPEG; + cmd = CMD_EVENT_LOAD_CONTENT_FFMPEG; #endif break; case CORE_TYPE_IMAGEVIEWER: #ifdef HAVE_IMAGEVIEWER - cmd = EVENT_CMD_LOAD_CONTENT_IMAGEVIEWER; + cmd = CMD_EVENT_LOAD_CONTENT_IMAGEVIEWER; #endif break; } - if (cmd != EVENT_CMD_NONE) + if (cmd != CMD_EVENT_NONE) command_event(cmd, NULL); #ifdef HAVE_MENU diff --git a/ui/drivers/ui_cocoa.m b/ui/drivers/ui_cocoa.m index c6479608d8..e186dcb785 100644 --- a/ui/drivers/ui_cocoa.m +++ b/ui/drivers/ui_cocoa.m @@ -258,7 +258,7 @@ static void poll_iteration(void) if (rarch_ctl(RARCH_CTL_IS_INITED, NULL)) reply = NSTerminateCancel; - ui_companion_event_command(EVENT_CMD_QUIT); + ui_companion_event_command(CMD_EVENT_QUIT); return reply; } @@ -280,7 +280,7 @@ static void poll_iteration(void) runloop_ctl(RUNLOOP_CTL_SET_CONTENT_PATH, (void*)__core.UTF8String); if (core_name) - ui_companion_event_command(EVENT_CMD_LOAD_CONTENT); + ui_companion_event_command(CMD_EVENT_LOAD_CONTENT); [sender replyToOpenOrPrint:NSApplicationDelegateReplySuccess]; } @@ -306,7 +306,7 @@ static void open_core_handler(NSOpenPanel *panel, NSInteger result) return; runloop_ctl(RUNLOOP_CTL_SET_LIBRETRO_PATH, (void*)__core.UTF8String); - ui_companion_event_command(EVENT_CMD_LOAD_CORE); + ui_companion_event_command(CMD_EVENT_LOAD_CORE); if (menu_driver_ctl(RARCH_MENU_CTL_HAS_LOAD_NO_CONTENT, NULL) && settings->set_supports_no_game_enable) @@ -343,7 +343,7 @@ static void open_document_handler(NSOpenPanel *panel, NSInteger result) runloop_ctl(RUNLOOP_CTL_SET_CONTENT_PATH, (void*)__core.UTF8String); if (core_name) - ui_companion_event_command(EVENT_CMD_LOAD_CONTENT); + ui_companion_event_command(CMD_EVENT_LOAD_CONTENT); } break; case 0: /* NSCancelButton/NSModalResponseCancel */ @@ -443,37 +443,37 @@ static void open_document_handler(NSOpenPanel *panel, NSInteger result) switch (sender_tag) { case 1: - cmd = EVENT_CMD_RESET; + cmd = CMD_EVENT_RESET; break; case 2: - cmd = EVENT_CMD_LOAD_STATE; + cmd = CMD_EVENT_LOAD_STATE; break; case 3: - cmd = EVENT_CMD_SAVE_STATE; + cmd = CMD_EVENT_SAVE_STATE; break; case 4: - cmd = EVENT_CMD_DISK_EJECT_TOGGLE; + cmd = CMD_EVENT_DISK_EJECT_TOGGLE; break; case 5: - cmd = EVENT_CMD_DISK_PREV; + cmd = CMD_EVENT_DISK_PREV; break; case 6: - cmd = EVENT_CMD_DISK_NEXT; + cmd = CMD_EVENT_DISK_NEXT; break; case 7: - cmd = EVENT_CMD_GRAB_MOUSE_TOGGLE; + cmd = CMD_EVENT_GRAB_MOUSE_TOGGLE; break; case 8: - cmd = EVENT_CMD_MENU_TOGGLE; + cmd = CMD_EVENT_MENU_TOGGLE; break; case 9: - cmd = EVENT_CMD_PAUSE_TOGGLE; + cmd = CMD_EVENT_PAUSE_TOGGLE; break; case 20: - cmd = EVENT_CMD_FULLSCREEN_TOGGLE; + cmd = CMD_EVENT_FULLSCREEN_TOGGLE; break; default: - cmd = EVENT_CMD_NONE; + cmd = CMD_EVENT_NONE; break; } @@ -481,7 +481,7 @@ static void open_document_handler(NSOpenPanel *panel, NSInteger result) { unsigned idx = (sender_tag - (10-1)); runloop_ctl(RUNLOOP_CTL_SET_WINDOWED_SCALE, &idx); - cmd = EVENT_CMD_RESIZE_WINDOWED_SCALE; + cmd = CMD_EVENT_RESIZE_WINDOWED_SCALE; } ui_companion_event_command(cmd); diff --git a/ui/drivers/ui_cocoatouch.m b/ui/drivers/ui_cocoatouch.m index 59e24c9922..586dada58a 100644 --- a/ui/drivers/ui_cocoatouch.m +++ b/ui/drivers/ui_cocoatouch.m @@ -91,7 +91,7 @@ static void rarch_draw_observer(CFRunLoopObserverRef observer, if (ret == -1) { - ui_companion_cocoatouch_event_command(NULL, EVENT_CMD_MENU_SAVE_CURRENT_CONFIG); + ui_companion_cocoatouch_event_command(NULL, CMD_EVENT_MENU_SAVE_CURRENT_CONFIG); main_exit(NULL); return; } @@ -408,7 +408,7 @@ enum #endif dispatch_async(dispatch_get_main_queue(), ^{ - ui_companion_cocoatouch_event_command(NULL, EVENT_CMD_MENU_SAVE_CURRENT_CONFIG); + ui_companion_cocoatouch_event_command(NULL, CMD_EVENT_MENU_SAVE_CURRENT_CONFIG); }); [self showPauseMenu: self]; } @@ -444,14 +444,14 @@ enum [[UIApplication sharedApplication] setIdleTimerDisabled:true]; [self.window setRootViewController:[CocoaView get]]; - ui_companion_cocoatouch_event_command(NULL, EVENT_CMD_AUDIO_START); + ui_companion_cocoatouch_event_command(NULL, CMD_EVENT_AUDIO_START); rarch_disable_ui(); } - (IBAction)showPauseMenu:(id)sender { #ifndef HAVE_AVFOUNDATION - ui_companion_cocoatouch_event_command(NULL, EVENT_CMD_AUDIO_STOP); + ui_companion_cocoatouch_event_command(NULL, CMD_EVENT_AUDIO_STOP); #endif rarch_enable_ui(); diff --git a/ui/drivers/ui_win32.c b/ui/drivers/ui_win32.c index 8d06d1ec53..0983e130b1 100644 --- a/ui/drivers/ui_win32.c +++ b/ui/drivers/ui_win32.c @@ -524,7 +524,7 @@ bool win32_browser( LRESULT win32_menu_loop(HWND owner, WPARAM wparam) { WPARAM mode = wparam & 0xffff; - enum event_command cmd = EVENT_CMD_NONE; + enum event_command cmd = CMD_EVENT_NONE; bool do_wm_close = false; settings_t *settings = config_get_ptr(); @@ -568,11 +568,11 @@ LRESULT win32_menu_loop(HWND owner, WPARAM wparam) { case ID_M_LOAD_CORE: runloop_ctl(RUNLOOP_CTL_SET_LIBRETRO_PATH, win32_file); - cmd = EVENT_CMD_LOAD_CORE; + cmd = CMD_EVENT_LOAD_CORE; break; case ID_M_LOAD_CONTENT: runloop_ctl(RUNLOOP_CTL_SET_CONTENT_PATH, win32_file); - cmd = EVENT_CMD_LOAD_CONTENT; + cmd = CMD_EVENT_LOAD_CONTENT; do_wm_close = true; break; } @@ -580,34 +580,34 @@ LRESULT win32_menu_loop(HWND owner, WPARAM wparam) } break; case ID_M_RESET: - cmd = EVENT_CMD_RESET; + cmd = CMD_EVENT_RESET; break; case ID_M_MUTE_TOGGLE: - cmd = EVENT_CMD_AUDIO_MUTE_TOGGLE; + cmd = CMD_EVENT_AUDIO_MUTE_TOGGLE; break; case ID_M_MENU_TOGGLE: - cmd = EVENT_CMD_MENU_TOGGLE; + cmd = CMD_EVENT_MENU_TOGGLE; break; case ID_M_PAUSE_TOGGLE: - cmd = EVENT_CMD_PAUSE_TOGGLE; + cmd = CMD_EVENT_PAUSE_TOGGLE; break; case ID_M_LOAD_STATE: - cmd = EVENT_CMD_LOAD_STATE; + cmd = CMD_EVENT_LOAD_STATE; break; case ID_M_SAVE_STATE: - cmd = EVENT_CMD_SAVE_STATE; + cmd = CMD_EVENT_SAVE_STATE; break; case ID_M_DISK_CYCLE: - cmd = EVENT_CMD_DISK_EJECT_TOGGLE; + cmd = CMD_EVENT_DISK_EJECT_TOGGLE; break; case ID_M_DISK_NEXT: - cmd = EVENT_CMD_DISK_NEXT; + cmd = CMD_EVENT_DISK_NEXT; break; case ID_M_DISK_PREV: - cmd = EVENT_CMD_DISK_PREV; + cmd = CMD_EVENT_DISK_PREV; break; case ID_M_FULL_SCREEN: - cmd = EVENT_CMD_FULLSCREEN_TOGGLE; + cmd = CMD_EVENT_FULLSCREEN_TOGGLE; break; #ifndef _XBOX case ID_M_SHADER_PARAMETERS: @@ -615,10 +615,10 @@ LRESULT win32_menu_loop(HWND owner, WPARAM wparam) break; #endif case ID_M_MOUSE_GRAB: - cmd = EVENT_CMD_GRAB_MOUSE_TOGGLE; + cmd = CMD_EVENT_GRAB_MOUSE_TOGGLE; break; case ID_M_TAKE_SCREENSHOT: - cmd = EVENT_CMD_TAKE_SCREENSHOT; + cmd = CMD_EVENT_TAKE_SCREENSHOT; break; case ID_M_QUIT: do_wm_close = true; @@ -628,7 +628,7 @@ LRESULT win32_menu_loop(HWND owner, WPARAM wparam) { unsigned idx = (mode - (ID_M_WINDOW_SCALE_1X-1)); runloop_ctl(RUNLOOP_CTL_SET_WINDOWED_SCALE, &idx); - cmd = EVENT_CMD_RESIZE_WINDOWED_SCALE; + cmd = CMD_EVENT_RESIZE_WINDOWED_SCALE; } else if (mode == ID_M_STATE_INDEX_AUTO) { @@ -644,7 +644,7 @@ LRESULT win32_menu_loop(HWND owner, WPARAM wparam) break; } - if (cmd != EVENT_CMD_NONE) + if (cmd != CMD_EVENT_NONE) command_event(cmd, NULL); if (do_wm_close) From f15f28ce02c834497b28989332fb047cea900cb4 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 May 2016 21:23:53 +0200 Subject: [PATCH 344/498] Refactor some command code --- command.c | 152 ++++++++++++++++++++++--------------------- command.h | 31 +++++---- input/input_driver.c | 16 +++-- retroarch.c | 2 +- 4 files changed, 108 insertions(+), 93 deletions(-) diff --git a/command.c b/command.c index 9052d64947..ac47a77451 100644 --- a/command.c +++ b/command.c @@ -82,17 +82,9 @@ #include #endif -#ifdef HAVE_COMMAND #define DEFAULT_NETWORK_CMD_PORT 55355 #define STDIN_BUF_SIZE 4096 -#define COMMAND_EXT_GLSL 0x7c976537U -#define COMMAND_EXT_GLSLP 0x0f840c87U -#define COMMAND_EXT_CG 0x0059776fU -#define COMMAND_EXT_CGP 0x0b8865bfU -#define COMMAND_EXT_SLANG 0x105ce63aU -#define COMMAND_EXT_SLANGP 0x1bf9adeaU - struct command { #ifdef HAVE_STDIN_CMD @@ -121,7 +113,47 @@ struct cmd_action_map const char *arg_desc; }; -static bool cmd_set_shader(const char *arg); +#ifdef HAVE_COMMAND +#define COMMAND_EXT_GLSL 0x7c976537U +#define COMMAND_EXT_GLSLP 0x0f840c87U +#define COMMAND_EXT_CG 0x0059776fU +#define COMMAND_EXT_CGP 0x0b8865bfU +#define COMMAND_EXT_SLANG 0x105ce63aU +#define COMMAND_EXT_SLANGP 0x1bf9adeaU + +static bool cmd_set_shader(const char *arg) +{ + char msg[256]; + enum rarch_shader_type type = RARCH_SHADER_NONE; + const char *ext = path_get_extension(arg); + uint32_t ext_hash = msg_hash_calculate(ext); + + switch (ext_hash) + { + case COMMAND_EXT_GLSL: + case COMMAND_EXT_GLSLP: + type = RARCH_SHADER_GLSL; + break; + case COMMAND_EXT_CG: + case COMMAND_EXT_CGP: + type = RARCH_SHADER_CG; + break; + case COMMAND_EXT_SLANG: + case COMMAND_EXT_SLANGP: + type = RARCH_SHADER_SLANG; + break; + default: + return false; + } + + snprintf(msg, sizeof(msg), "Shader: \"%s\"", arg); + runloop_msg_queue_push(msg, 1, 120, true); + RARCH_LOG("%s \"%s\".\n", + msg_hash_to_str(MSG_APPLYING_SHADER), + arg); + + return video_driver_set_shader(type, arg); +} static const struct cmd_action_map action_map[] = { { "SET_SHADER", cmd_set_shader, "" }, @@ -168,7 +200,7 @@ static const struct cmd_map map[] = { }; #if defined(HAVE_NETWORK_CMD) && defined(HAVE_NETPLAY) -static bool cmd_init_network(command_t *handle, uint16_t port) +static bool command_network_init(command_t *handle, uint16_t port) { int fd; struct addrinfo *res = NULL; @@ -203,7 +235,7 @@ error: #endif #ifdef HAVE_STDIN_CMD -static bool cmd_init_stdin(command_t *handle) +static bool command_stdin_init(command_t *handle) { #ifndef _WIN32 #ifdef HAVE_NETPLAY @@ -217,72 +249,45 @@ static bool cmd_init_stdin(command_t *handle) } #endif -command_t *command_new(bool stdin_enable, - bool network_enable, uint16_t port) +command_t *command_new(void) { command_t *handle = (command_t*)calloc(1, sizeof(*handle)); if (!handle) return NULL; - (void)network_enable; - (void)port; - (void)stdin_enable; + return handle; +} + +bool command_network_new( + command_t *handle, + bool stdin_enable, + bool network_enable, + uint16_t port) +{ + if (!handle) + return false; #if defined(HAVE_NETWORK_CMD) && defined(HAVE_NETPLAY) handle->net_fd = -1; - if (network_enable && !cmd_init_network(handle, port)) + if (network_enable && !command_network_init(handle, port)) goto error; #endif #ifdef HAVE_STDIN_CMD handle->stdin_enable = stdin_enable; - if (stdin_enable && !cmd_init_stdin(handle)) + if (stdin_enable && !command_stdin_init(handle)) goto error; #endif - return handle; + return true; #if (defined(HAVE_NETWORK_CMD) && defined(HAVE_NETPLAY)) || defined(HAVE_STDIN_CMD) error: command_free(handle); - return NULL; + return false; #endif } -static bool cmd_set_shader(const char *arg) -{ - char msg[256]; - enum rarch_shader_type type = RARCH_SHADER_NONE; - const char *ext = path_get_extension(arg); - uint32_t ext_hash = msg_hash_calculate(ext); - - switch (ext_hash) - { - case COMMAND_EXT_GLSL: - case COMMAND_EXT_GLSLP: - type = RARCH_SHADER_GLSL; - break; - case COMMAND_EXT_CG: - case COMMAND_EXT_CGP: - type = RARCH_SHADER_CG; - break; - case COMMAND_EXT_SLANG: - case COMMAND_EXT_SLANGP: - type = RARCH_SHADER_SLANG; - break; - default: - return false; - } - - snprintf(msg, sizeof(msg), "Shader: \"%s\"", arg); - runloop_msg_queue_push(msg, 1, 120, true); - RARCH_LOG("%s \"%s\".\n", - msg_hash_to_str(MSG_APPLYING_SHADER), - arg); - - return video_driver_set_shader(type, arg); -} - static bool command_get_arg(const char *tok, const char **arg, unsigned *index) { @@ -324,7 +329,7 @@ static bool command_get_arg(const char *tok, return false; } -static void parse_sub_msg(command_t *handle, const char *tok) +static void command_parse_sub_msg(command_t *handle, const char *tok) { const char *arg = NULL; unsigned index = 0; @@ -346,20 +351,20 @@ static void parse_sub_msg(command_t *handle, const char *tok) msg_hash_to_str(MSG_RECEIVED)); } -static void parse_msg(command_t *handle, char *buf) +static void command_parse_msg(command_t *handle, char *buf) { char *save = NULL; const char *tok = strtok_r(buf, "\n", &save); while (tok) { - parse_sub_msg(handle, tok); + command_parse_sub_msg(handle, tok); tok = strtok_r(NULL, "\n", &save); } } #if defined(HAVE_NETWORK_CMD) && defined(HAVE_NETPLAY) -static void network_cmd_poll(command_t *handle) +static void command_network_poll(command_t *handle) { fd_set fds; struct timeval tmp_tv = {0}; @@ -386,7 +391,7 @@ static void network_cmd_poll(command_t *handle) break; buf[ret] = '\0'; - parse_msg(handle, buf); + command_parse_msg(handle, buf); } } #endif @@ -498,7 +503,7 @@ static size_t read_stdin(char *buf, size_t size) } #endif -static void stdin_cmd_poll(command_t *handle) +static void command_stdin_poll(command_t *handle) { char *last_newline; ssize_t ret; @@ -533,7 +538,7 @@ static void stdin_cmd_poll(command_t *handle) *last_newline++ = '\0'; msg_len = last_newline - handle->stdin_buf; - parse_msg(handle, handle->stdin_buf); + command_parse_msg(handle, handle->stdin_buf); memmove(handle->stdin_buf, last_newline, handle->stdin_buf_ptr - msg_len); @@ -611,7 +616,7 @@ static bool verify_command(const char *cmd) return false; } -bool command_send(const char *cmd_) +bool command_network_send(const char *cmd_) { bool ret; char *command = NULL; @@ -656,21 +661,31 @@ bool command_send(const char *cmd_) } #endif +#endif + bool command_poll(command_t *handle) { memset(handle->state, 0, sizeof(handle->state)); #if defined(HAVE_NETWORK_CMD) && defined(HAVE_NETPLAY) - network_cmd_poll(handle); + command_network_poll(handle); #endif #ifdef HAVE_STDIN_CMD - stdin_cmd_poll(handle); + command_stdin_poll(handle); #endif return true; } +bool command_get(command_handle_t *handle) +{ + if (!handle || !handle->handle) + return false; + return handle->id < RARCH_BIND_LIST_END + && handle->handle->state[handle->id]; +} + bool command_set(command_handle_t *handle) { if (!handle || !handle->handle) @@ -692,15 +707,6 @@ bool command_free(command_t *handle) return true; } -bool command_get(command_handle_t *handle) -{ - if (!handle || !handle->handle) - return false; - return handle->id < RARCH_BIND_LIST_END - && handle->handle->state[handle->id]; -} -#endif - /** * command_event_disk_control_set_eject: * @new_state : Eject or close the virtual drive tray. diff --git a/command.h b/command.h index 1df2d737aa..efdab9d4d0 100644 --- a/command.h +++ b/command.h @@ -30,6 +30,12 @@ extern "C" { typedef struct command command_t; +typedef struct command_handle +{ + command_t *handle; + unsigned id; +} command_handle_t; + enum event_command { CMD_EVENT_NONE = 0, @@ -215,28 +221,27 @@ enum event_command CMD_EVENT_EXEC }; -typedef struct command_handle -{ - command_t *handle; - unsigned id; -} command_handle_t; - #ifdef HAVE_COMMAND -command_t *command_new(bool stdin_enable, - bool network_enable, uint16_t port); - #if defined(HAVE_NETWORK_CMD) && defined(HAVE_NETPLAY) -bool command_send(const char *cmd_); +bool command_network_send(const char *cmd_); #endif +#endif + +bool command_network_new( + command_t *handle, + bool stdin_enable, + bool network_enable, + uint16_t port); + +command_t *command_new(void); bool command_poll(command_t *handle); -bool command_set(command_handle_t *handle); - bool command_get(command_handle_t *handle); +bool command_set(command_handle_t *handle); + bool command_free(command_t *handle); -#endif /** * command_event: diff --git a/input/input_driver.c b/input/input_driver.c index d44efbbb23..b02e7d1679 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -839,7 +839,8 @@ bool input_driver_init_command(void) { #ifdef HAVE_COMMAND settings_t *settings = config_get_ptr(); - if (!settings->stdin_cmd_enable && !settings->network_cmd_enable) + if ( !settings->stdin_cmd_enable + && !settings->network_cmd_enable) return false; if (settings->stdin_cmd_enable @@ -849,11 +850,14 @@ bool input_driver_init_command(void) "Cannot use this command interface.\n"); } - input_driver_command = command_new(settings->stdin_cmd_enable - && !input_driver_grab_stdin(), - settings->network_cmd_enable, settings->network_cmd_port); - - if (!input_driver_command) + input_driver_command = command_new(); + + if (!command_network_new( + input_driver_command, + settings->stdin_cmd_enable + && !input_driver_grab_stdin(), + settings->network_cmd_enable, + settings->network_cmd_port)) { RARCH_ERR("Failed to initialize command interface.\n"); return false; diff --git a/retroarch.c b/retroarch.c index 3cca26e356..a19faf4fbb 100644 --- a/retroarch.c +++ b/retroarch.c @@ -952,7 +952,7 @@ static void retroarch_parse_input(int argc, char *argv[]) #if defined(HAVE_NETWORK_CMD) && defined(HAVE_NETPLAY) case RA_OPT_COMMAND: - if (command_send((const char*)optarg)) + if (command_network_send((const char*)optarg)) exit(0); else retroarch_fail(1, "network_cmd_send()"); From b3422b33fdf1fa8dc223b06f7de68c88cce15b3b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 May 2016 21:25:37 +0200 Subject: [PATCH 345/498] Add parameter to command_new --- command.c | 5 ++++- command.h | 2 +- input/input_driver.c | 2 +- 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/command.c b/command.c index ac47a77451..75ba4abfda 100644 --- a/command.c +++ b/command.c @@ -87,6 +87,7 @@ struct command { + bool local_enable; #ifdef HAVE_STDIN_CMD bool stdin_enable; char stdin_buf[STDIN_BUF_SIZE]; @@ -249,12 +250,14 @@ static bool command_stdin_init(command_t *handle) } #endif -command_t *command_new(void) +command_t *command_new(bool local_enable) { command_t *handle = (command_t*)calloc(1, sizeof(*handle)); if (!handle) return NULL; + handle->local_enable = local_enable; + return handle; } diff --git a/command.h b/command.h index efdab9d4d0..92dd882916 100644 --- a/command.h +++ b/command.h @@ -233,7 +233,7 @@ bool command_network_new( bool network_enable, uint16_t port); -command_t *command_new(void); +command_t *command_new(bool local_enable); bool command_poll(command_t *handle); diff --git a/input/input_driver.c b/input/input_driver.c index b02e7d1679..593387de3a 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -850,7 +850,7 @@ bool input_driver_init_command(void) "Cannot use this command interface.\n"); } - input_driver_command = command_new(); + input_driver_command = command_new(false); if (!command_network_new( input_driver_command, From 3dc55d4e72bc8bd2e5ad886205a15b1965972f56 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Mon, 9 May 2016 21:36:17 +0200 Subject: [PATCH 346/498] command.c - cleanups --- command.c | 462 ++++++++++++++++++++++--------------------- input/input_driver.c | 3 - 2 files changed, 233 insertions(+), 232 deletions(-) diff --git a/command.c b/command.c index 75ba4abfda..36eae2360a 100644 --- a/command.c +++ b/command.c @@ -122,7 +122,7 @@ struct cmd_action_map #define COMMAND_EXT_SLANG 0x105ce63aU #define COMMAND_EXT_SLANGP 0x1bf9adeaU -static bool cmd_set_shader(const char *arg) +static bool command_set_shader(const char *arg) { char msg[256]; enum rarch_shader_type type = RARCH_SHADER_NONE; @@ -157,7 +157,7 @@ static bool cmd_set_shader(const char *arg) } static const struct cmd_action_map action_map[] = { - { "SET_SHADER", cmd_set_shader, "" }, + { "SET_SHADER", command_set_shader, "" }, }; static const struct cmd_map map[] = { @@ -233,6 +233,226 @@ error: freeaddrinfo_retro(res); return false; } + +static bool command_get_arg(const char *tok, + const char **arg, unsigned *index) +{ + unsigned i; + + for (i = 0; i < ARRAY_SIZE(map); i++) + { + if (string_is_equal(tok, map[i].str)) + { + if (arg) + *arg = NULL; + + if (index) + *index = i; + + return true; + } + } + + for (i = 0; i < ARRAY_SIZE(action_map); i++) + { + const char *str = strstr(tok, action_map[i].str); + if (str == tok) + { + const char *argument = str + strlen(action_map[i].str); + if (*argument != ' ') + return false; + + if (arg) + *arg = argument + 1; + + if (index) + *index = i; + + return true; + } + } + + return false; +} + + +static bool send_udp_packet(const char *host, + uint16_t port, const char *msg) +{ + char port_buf[16] = {0}; + struct addrinfo hints = {0}; + struct addrinfo *res = NULL; + const struct addrinfo *tmp = NULL; + int fd = -1; + bool ret = true; + + hints.ai_socktype = SOCK_DGRAM; + + snprintf(port_buf, sizeof(port_buf), "%hu", (unsigned short)port); + if (getaddrinfo_retro(host, port_buf, &hints, &res) < 0) + return false; + + /* Send to all possible targets. + * "localhost" might resolve to several different IPs. */ + tmp = (const struct addrinfo*)res; + while (tmp) + { + ssize_t len, ret_len; + + fd = socket(tmp->ai_family, tmp->ai_socktype, tmp->ai_protocol); + if (fd < 0) + { + ret = false; + goto end; + } + + len = strlen(msg); + ret_len = sendto(fd, msg, len, 0, tmp->ai_addr, tmp->ai_addrlen); + + if (ret_len < len) + { + ret = false; + goto end; + } + + socket_close(fd); + fd = -1; + tmp = tmp->ai_next; + } + +end: + freeaddrinfo_retro(res); + if (fd >= 0) + socket_close(fd); + return ret; +} + +static bool command_verify(const char *cmd) +{ + unsigned i; + + if (command_get_arg(cmd, NULL, NULL)) + return true; + + RARCH_ERR("Command \"%s\" is not recognized by the program.\n", cmd); + RARCH_ERR("\tValid commands:\n"); + for (i = 0; i < sizeof(map) / sizeof(map[0]); i++) + RARCH_ERR("\t\t%s\n", map[i].str); + + for (i = 0; i < sizeof(action_map) / sizeof(action_map[0]); i++) + RARCH_ERR("\t\t%s %s\n", action_map[i].str, action_map[i].arg_desc); + + return false; +} + +bool command_network_send(const char *cmd_) +{ + bool ret; + char *command = NULL; + char *save = NULL; + const char *cmd = NULL; + const char *host = NULL; + const char *port_ = NULL; + uint16_t port = DEFAULT_NETWORK_CMD_PORT; + + if (!network_init()) + return false; + + if (!(command = strdup(cmd_))) + return false; + + cmd = strtok_r(command, ";", &save); + if (cmd) + host = strtok_r(NULL, ";", &save); + if (host) + port_ = strtok_r(NULL, ";", &save); + + if (!host) + { +#ifdef _WIN32 + host = "127.0.0.1"; +#else + host = "localhost"; +#endif + } + + if (port_) + port = strtoul(port_, NULL, 0); + + RARCH_LOG("%s: \"%s\" to %s:%hu\n", + msg_hash_to_str(MSG_SENDING_COMMAND), + cmd, host, (unsigned short)port); + + ret = command_verify(cmd) && send_udp_packet(host, port, cmd); + free(command); + + return ret; +} + +static void command_parse_sub_msg(command_t *handle, const char *tok) +{ + const char *arg = NULL; + unsigned index = 0; + + if (command_get_arg(tok, &arg, &index)) + { + if (arg) + { + if (!action_map[index].action(arg)) + RARCH_ERR("Command \"%s\" failed.\n", arg); + } + else + handle->state[map[index].id] = true; + } + else + RARCH_WARN("%s \"%s\" %s.\n", + msg_hash_to_str(MSG_UNRECOGNIZED_COMMAND), + tok, + msg_hash_to_str(MSG_RECEIVED)); +} + +static void command_parse_msg(command_t *handle, char *buf) +{ + char *save = NULL; + const char *tok = strtok_r(buf, "\n", &save); + + while (tok) + { + command_parse_sub_msg(handle, tok); + tok = strtok_r(NULL, "\n", &save); + } +} + +static void command_network_poll(command_t *handle) +{ + fd_set fds; + struct timeval tmp_tv = {0}; + + if (handle->net_fd < 0) + return; + + FD_ZERO(&fds); + FD_SET(handle->net_fd, &fds); + + if (socket_select(handle->net_fd + 1, &fds, NULL, NULL, &tmp_tv) <= 0) + return; + + if (!FD_ISSET(handle->net_fd, &fds)) + return; + + for (;;) + { + char buf[1024]; + ssize_t ret = recvfrom(handle->net_fd, buf, + sizeof(buf) - 1, 0, NULL, NULL); + + if (ret <= 0) + break; + + buf[ret] = '\0'; + command_parse_msg(handle, buf); + } +} #endif #ifdef HAVE_STDIN_CMD @@ -291,114 +511,6 @@ error: #endif } -static bool command_get_arg(const char *tok, - const char **arg, unsigned *index) -{ - unsigned i; - - for (i = 0; i < ARRAY_SIZE(map); i++) - { - if (string_is_equal(tok, map[i].str)) - { - if (arg) - *arg = NULL; - - if (index) - *index = i; - - return true; - } - } - - for (i = 0; i < ARRAY_SIZE(action_map); i++) - { - const char *str = strstr(tok, action_map[i].str); - if (str == tok) - { - const char *argument = str + strlen(action_map[i].str); - if (*argument != ' ') - return false; - - if (arg) - *arg = argument + 1; - - if (index) - *index = i; - - return true; - } - } - - return false; -} - -static void command_parse_sub_msg(command_t *handle, const char *tok) -{ - const char *arg = NULL; - unsigned index = 0; - - if (command_get_arg(tok, &arg, &index)) - { - if (arg) - { - if (!action_map[index].action(arg)) - RARCH_ERR("Command \"%s\" failed.\n", arg); - } - else - handle->state[map[index].id] = true; - } - else - RARCH_WARN("%s \"%s\" %s.\n", - msg_hash_to_str(MSG_UNRECOGNIZED_COMMAND), - tok, - msg_hash_to_str(MSG_RECEIVED)); -} - -static void command_parse_msg(command_t *handle, char *buf) -{ - char *save = NULL; - const char *tok = strtok_r(buf, "\n", &save); - - while (tok) - { - command_parse_sub_msg(handle, tok); - tok = strtok_r(NULL, "\n", &save); - } -} - -#if defined(HAVE_NETWORK_CMD) && defined(HAVE_NETPLAY) -static void command_network_poll(command_t *handle) -{ - fd_set fds; - struct timeval tmp_tv = {0}; - - if (handle->net_fd < 0) - return; - - FD_ZERO(&fds); - FD_SET(handle->net_fd, &fds); - - if (socket_select(handle->net_fd + 1, &fds, NULL, NULL, &tmp_tv) <= 0) - return; - - if (!FD_ISSET(handle->net_fd, &fds)) - return; - - for (;;) - { - char buf[1024]; - ssize_t ret = recvfrom(handle->net_fd, buf, - sizeof(buf) - 1, 0, NULL, NULL); - - if (ret <= 0) - break; - - buf[ret] = '\0'; - command_parse_msg(handle, buf); - } -} -#endif - #ifdef HAVE_STDIN_CMD #ifdef _WIN32 @@ -548,123 +660,13 @@ static void command_stdin_poll(command_t *handle) handle->stdin_buf_ptr -= msg_len; } #endif - -#if defined(HAVE_NETWORK_CMD) && defined(HAVE_NETPLAY) -static bool send_udp_packet(const char *host, - uint16_t port, const char *msg) -{ - char port_buf[16] = {0}; - struct addrinfo hints = {0}; - struct addrinfo *res = NULL; - const struct addrinfo *tmp = NULL; - int fd = -1; - bool ret = true; - - hints.ai_socktype = SOCK_DGRAM; - - snprintf(port_buf, sizeof(port_buf), "%hu", (unsigned short)port); - if (getaddrinfo_retro(host, port_buf, &hints, &res) < 0) - return false; - - /* Send to all possible targets. - * "localhost" might resolve to several different IPs. */ - tmp = (const struct addrinfo*)res; - while (tmp) - { - ssize_t len, ret_len; - - fd = socket(tmp->ai_family, tmp->ai_socktype, tmp->ai_protocol); - if (fd < 0) - { - ret = false; - goto end; - } - - len = strlen(msg); - ret_len = sendto(fd, msg, len, 0, tmp->ai_addr, tmp->ai_addrlen); - - if (ret_len < len) - { - ret = false; - goto end; - } - - socket_close(fd); - fd = -1; - tmp = tmp->ai_next; - } - -end: - freeaddrinfo_retro(res); - if (fd >= 0) - socket_close(fd); - return ret; -} - -static bool verify_command(const char *cmd) -{ - unsigned i; - - if (command_get_arg(cmd, NULL, NULL)) - return true; - - RARCH_ERR("Command \"%s\" is not recognized by the program.\n", cmd); - RARCH_ERR("\tValid commands:\n"); - for (i = 0; i < sizeof(map) / sizeof(map[0]); i++) - RARCH_ERR("\t\t%s\n", map[i].str); - - for (i = 0; i < sizeof(action_map) / sizeof(action_map[0]); i++) - RARCH_ERR("\t\t%s %s\n", action_map[i].str, action_map[i].arg_desc); - - return false; -} - -bool command_network_send(const char *cmd_) -{ - bool ret; - char *command = NULL; - char *save = NULL; - const char *cmd = NULL; - const char *host = NULL; - const char *port_ = NULL; - uint16_t port = DEFAULT_NETWORK_CMD_PORT; - - if (!network_init()) - return false; - - if (!(command = strdup(cmd_))) - return false; - - cmd = strtok_r(command, ";", &save); - if (cmd) - host = strtok_r(NULL, ";", &save); - if (host) - port_ = strtok_r(NULL, ";", &save); - - if (!host) - { -#ifdef _WIN32 - host = "127.0.0.1"; -#else - host = "localhost"; -#endif - } - - if (port_) - port = strtoul(port_, NULL, 0); - - RARCH_LOG("%s: \"%s\" to %s:%hu\n", - msg_hash_to_str(MSG_SENDING_COMMAND), - cmd, host, (unsigned short)port); - - ret = verify_command(cmd) && send_udp_packet(host, port, cmd); - free(command); - - return ret; -} #endif -#endif +static void command_local_poll(command_t *handle) +{ + if (!handle->local_enable) + return; +} bool command_poll(command_t *handle) { @@ -678,6 +680,8 @@ bool command_poll(command_t *handle) command_stdin_poll(handle); #endif + command_local_poll(handle); + return true; } @@ -1221,7 +1225,7 @@ static bool event_init_content(void) return true; } -static bool event_init_core(enum rarch_core_type *data) +static bool command_event_init_core(enum rarch_core_type *data) { retro_ctx_environ_info_t info; settings_t *settings = config_get_ptr(); @@ -1265,7 +1269,7 @@ static bool event_init_core(enum rarch_core_type *data) return true; } -static bool event_save_auto_state(void) +static bool command_event_save_auto_state(void) { bool ret; char savestate_name_auto[PATH_MAX_LENGTH] = {0}; @@ -1852,7 +1856,7 @@ bool command_event(enum event_command cmd, void *data) #endif break; case CMD_EVENT_AUTOSAVE_STATE: - event_save_auto_state(); + command_event_save_auto_state(); break; case CMD_EVENT_AUDIO_STOP: if (!audio_driver_alive()) @@ -1966,7 +1970,7 @@ bool command_event(enum event_command cmd, void *data) break; } case CMD_EVENT_CORE_INIT: - if (!event_init_core((enum rarch_core_type*)data)) + if (!command_event_init_core((enum rarch_core_type*)data)) return false; break; case CMD_EVENT_VIDEO_APPLY_STATE_CHANGES: diff --git a/input/input_driver.c b/input/input_driver.c index 593387de3a..8a7ad2e6b7 100644 --- a/input/input_driver.c +++ b/input/input_driver.c @@ -25,10 +25,7 @@ #include "../movie.h" #include "../list_special.h" #include "../verbosity.h" - -#ifdef HAVE_COMMAND #include "../command.h" -#endif #ifdef HAVE_NETWORK_GAMEPAD #include "input_remote.h" From 2c6d6a223c5315d2b59e6cf82baeb2b6155919c5 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 May 2016 01:21:55 +0200 Subject: [PATCH 347/498] Rename core_option functions --- core_options.c | 173 +++++++++++++++++----------------- core_options.h | 48 +++++----- menu/cbs/menu_cbs_get_value.c | 2 +- menu/cbs/menu_cbs_start.c | 2 +- menu/menu_displaylist.c | 2 +- runloop.c | 20 ++-- 6 files changed, 125 insertions(+), 122 deletions(-) diff --git a/core_options.c b/core_options.c index 92cdfdf3b5..7e391bfb10 100644 --- a/core_options.c +++ b/core_options.c @@ -46,66 +46,7 @@ struct core_option_manager bool updated; }; -/** - * core_option_free: - * @opt : options manager handle - * - * Frees core option manager handle. - **/ -void core_option_free(core_option_manager_t *opt) -{ - size_t i; - - if (!opt) - return; - - for (i = 0; i < opt->size; i++) - { - if (opt->opts[i].desc) - free(opt->opts[i].desc); - if (opt->opts[i].key) - free(opt->opts[i].key); - - if (opt->opts[i].vals) - string_list_free(opt->opts[i].vals); - - opt->opts[i].desc = NULL; - opt->opts[i].key = NULL; - opt->opts[i].vals = NULL; - } - - if (opt->conf) - config_file_free(opt->conf); - free(opt->opts); - free(opt); -} - -void core_option_get(core_option_manager_t *opt, void *data) -{ - size_t i; - struct retro_variable *var = (struct retro_variable*)data; - - if (!opt) - return; - - opt->updated = false; - - for (i = 0; i < opt->size; i++) - { - if (string_is_empty(opt->opts[i].key)) - continue; - - if (string_is_equal(opt->opts[i].key, var->key)) - { - var->value = core_option_get_val(opt, i); - return; - } - } - - var->value = NULL; -} - -static bool parse_variable(core_option_manager_t *opt, size_t idx, +static bool core_option_manager_parse_variable(core_option_manager_t *opt, size_t idx, const struct retro_variable *var) { const char *val_start = NULL; @@ -161,7 +102,67 @@ static bool parse_variable(core_option_manager_t *opt, size_t idx, } /** - * core_option_new: + * core_option_manager_free: + * @opt : options manager handle + * + * Frees core option manager handle. + **/ +void core_option_manager_free(core_option_manager_t *opt) +{ + size_t i; + + if (!opt) + return; + + for (i = 0; i < opt->size; i++) + { + if (opt->opts[i].desc) + free(opt->opts[i].desc); + if (opt->opts[i].key) + free(opt->opts[i].key); + + if (opt->opts[i].vals) + string_list_free(opt->opts[i].vals); + + opt->opts[i].desc = NULL; + opt->opts[i].key = NULL; + opt->opts[i].vals = NULL; + } + + if (opt->conf) + config_file_free(opt->conf); + free(opt->opts); + free(opt); +} + +void core_option_manager_get(core_option_manager_t *opt, void *data) +{ + size_t i; + struct retro_variable *var = (struct retro_variable*)data; + + if (!opt) + return; + + opt->updated = false; + + for (i = 0; i < opt->size; i++) + { + if (string_is_empty(opt->opts[i].key)) + continue; + + if (string_is_equal(opt->opts[i].key, var->key)) + { + var->value = core_option_manager_get_val(opt, i); + return; + } + } + + var->value = NULL; +} + + +/** + * core_option_manager_new: * @conf_path : Filesystem path to write core option config file to. * @vars : Pointer to variable array handle. * @@ -169,7 +170,7 @@ static bool parse_variable(core_option_manager_t *opt, size_t idx, * * Returns: handle to new core manager handle, otherwise NULL. **/ -core_option_manager_t *core_option_new(const char *conf_path, +core_option_manager_t *core_option_manager_new(const char *conf_path, const void *data) { const struct retro_variable *var; @@ -203,19 +204,19 @@ core_option_manager_t *core_option_new(const char *conf_path, for (var = vars; var->key && var->value; size++, var++) { - if (!parse_variable(opt, size, var)) + if (!core_option_manager_parse_variable(opt, size, var)) goto error; } return opt; error: - core_option_free(opt); + core_option_manager_free(opt); return NULL; } /** - * core_option_updated: + * core_option_manager_updated: * @opt : options manager handle * * Has a core option been updated? @@ -223,7 +224,7 @@ error: * Returns: true (1) if a core option has been updated, * otherwise false (0). **/ -bool core_option_updated(core_option_manager_t *opt) +bool core_option_manager_updated(core_option_manager_t *opt) { if (!opt) return false; @@ -231,7 +232,7 @@ bool core_option_updated(core_option_manager_t *opt) } /** - * core_option_flush: + * core_option_manager_flush: * @opt : options manager handle * * Writes core option key-pair values to file. @@ -239,7 +240,7 @@ bool core_option_updated(core_option_manager_t *opt) * Returns: true (1) if core option values could be * successfully saved to disk, otherwise false (0). **/ -bool core_option_flush(core_option_manager_t *opt) +bool core_option_manager_flush(core_option_manager_t *opt) { size_t i; @@ -248,14 +249,15 @@ bool core_option_flush(core_option_manager_t *opt) struct core_option *option = (struct core_option*)&opt->opts[i]; if (option) - config_set_string(opt->conf, option->key, core_option_get_val(opt, i)); + config_set_string(opt->conf, option->key, + core_option_manager_get_val(opt, i)); } return config_file_write(opt->conf, opt->conf_path); } /** - * core_option_flush_game_specific: + * core_option_manager_flush_game_specific: * @opt : options manager handle * @path : path for the core options file * @@ -264,7 +266,7 @@ bool core_option_flush(core_option_manager_t *opt) * Returns: true (1) if core option values could be * successfully saved to disk, otherwise false (0). **/ -bool core_option_flush_game_specific(core_option_manager_t *opt, char* path) +bool core_option_manager_flush_game_specific(core_option_manager_t *opt, char* path) { size_t i; for (i = 0; i < opt->size; i++) @@ -272,21 +274,22 @@ bool core_option_flush_game_specific(core_option_manager_t *opt, char* path) struct core_option *option = (struct core_option*)&opt->opts[i]; if (option) - config_set_string(opt->conf, option->key, core_option_get_val(opt, i)); + config_set_string(opt->conf, option->key, + core_option_manager_get_val(opt, i)); } return config_file_write(opt->conf, path); } /** - * core_option_size: + * core_option_manager_size: * @opt : options manager handle * * Gets total number of options. * * Returns: Total number of options. **/ -size_t core_option_size(core_option_manager_t *opt) +size_t core_option_manager_size(core_option_manager_t *opt) { if (!opt) return 0; @@ -294,7 +297,7 @@ size_t core_option_size(core_option_manager_t *opt) } /** - * core_option_get_desc: + * core_option_manager_get_desc: * @opt : options manager handle * @index : index identifier of the option * @@ -302,7 +305,7 @@ size_t core_option_size(core_option_manager_t *opt) * * Returns: Description for an option. **/ -const char *core_option_get_desc(core_option_manager_t *opt, size_t idx) +const char *core_option_manager_get_desc(core_option_manager_t *opt, size_t idx) { if (!opt) return NULL; @@ -310,7 +313,7 @@ const char *core_option_get_desc(core_option_manager_t *opt, size_t idx) } /** - * core_option_get_val: + * core_option_manager_get_val: * @opt : options manager handle * @index : index identifier of the option * @@ -318,7 +321,7 @@ const char *core_option_get_desc(core_option_manager_t *opt, size_t idx) * * Returns: Value for an option. **/ -const char *core_option_get_val(core_option_manager_t *opt, size_t idx) +const char *core_option_manager_get_val(core_option_manager_t *opt, size_t idx) { struct core_option *option = NULL; if (!opt) @@ -329,7 +332,7 @@ const char *core_option_get_val(core_option_manager_t *opt, size_t idx) return option->vals->elems[option->index].data; } -void core_option_set_val(core_option_manager_t *opt, +void core_option_manager_set_val(core_option_manager_t *opt, size_t idx, size_t val_idx) { struct core_option *option= NULL; @@ -347,14 +350,14 @@ void core_option_set_val(core_option_manager_t *opt, } /** - * core_option_next: + * core_option_manager_next: * @opt : pointer to core option manager object. * @idx : index of core option to be reset to defaults. * * Get next value for core option specified by @idx. * Options wrap around. **/ -void core_option_next(core_option_manager_t *opt, size_t idx) +void core_option_manager_next(core_option_manager_t *opt, size_t idx) { struct core_option *option = NULL; @@ -371,7 +374,7 @@ void core_option_next(core_option_manager_t *opt, size_t idx) } /** - * core_option_prev: + * core_option_manager_prev: * @opt : pointer to core option manager object. * @idx : index of core option to be reset to defaults. * Options wrap around. @@ -379,7 +382,7 @@ void core_option_next(core_option_manager_t *opt, size_t idx) * Get previous value for core option specified by @idx. * Options wrap around. **/ -void core_option_prev(core_option_manager_t *opt, size_t idx) +void core_option_manager_prev(core_option_manager_t *opt, size_t idx) { struct core_option *option = NULL; @@ -397,13 +400,13 @@ void core_option_prev(core_option_manager_t *opt, size_t idx) } /** - * core_option_set_default: + * core_option_manager_set_default: * @opt : pointer to core option manager object. * @idx : index of core option to be reset to defaults. * * Reset core option specified by @idx and sets default value for option. **/ -void core_option_set_default(core_option_manager_t *opt, size_t idx) +void core_option_manager_set_default(core_option_manager_t *opt, size_t idx) { if (!opt) return; diff --git a/core_options.h b/core_options.h index c147e92448..ff972434ba 100644 --- a/core_options.h +++ b/core_options.h @@ -28,7 +28,7 @@ extern "C" { typedef struct core_option_manager core_option_manager_t; /** - * core_option_new: + * core_option_manager_new: * @conf_path : Filesystem path to write core option config file to. * @vars : Pointer to variable array handle. * @@ -36,11 +36,11 @@ typedef struct core_option_manager core_option_manager_t; * * Returns: handle to new core manager handle, otherwise NULL. **/ -core_option_manager_t *core_option_new(const char *conf_path, +core_option_manager_t *core_option_manager_new(const char *conf_path, const void *data); /** - * core_option_updated: + * core_option_manager_updated: * @opt : options manager handle * * Has a core option been updated? @@ -48,10 +48,10 @@ core_option_manager_t *core_option_new(const char *conf_path, * Returns: true (1) if a core option has been updated, * otherwise false (0). **/ -bool core_option_updated(core_option_manager_t *opt); +bool core_option_manager_updated(core_option_manager_t *opt); /** - * core_option_flush: + * core_option_manager_flush: * @opt : options manager handle * * Writes core option key-pair values to file. @@ -59,10 +59,10 @@ bool core_option_updated(core_option_manager_t *opt); * Returns: true (1) if core option values could be * successfully saved to disk, otherwise false (0). **/ -bool core_option_flush(core_option_manager_t *opt); +bool core_option_manager_flush(core_option_manager_t *opt); /** - * core_option_flush_game_specific: + * core_option_manager_flush_game_specific: * @opt : options manager handle * @path : path for the core options file * @@ -71,31 +71,31 @@ bool core_option_flush(core_option_manager_t *opt); * Returns: true (1) if core option values could be * successfully saved to disk, otherwise false (0). **/ -bool core_option_flush_game_specific( +bool core_option_manager_flush_game_specific( core_option_manager_t *opt, char* path); /** - * core_option_free: + * core_option_manager_free: * @opt : options manager handle * * Frees core option manager handle. **/ -void core_option_free(core_option_manager_t *opt); +void core_option_manager_free(core_option_manager_t *opt); -void core_option_get(core_option_manager_t *opt, void *data); +void core_option_manager_get(core_option_manager_t *opt, void *data); /** - * core_option_size: + * core_option_manager_size: * @opt : options manager handle * * Gets total number of options. * * Returns: Total number of options. **/ -size_t core_option_size(core_option_manager_t *opt); +size_t core_option_manager_size(core_option_manager_t *opt); /** - * core_option_get_desc: + * core_option_manager_get_desc: * @opt : options manager handle * @idx : idx identifier of the option * @@ -103,11 +103,11 @@ size_t core_option_size(core_option_manager_t *opt); * * Returns: Description for an option. **/ -const char *core_option_get_desc(core_option_manager_t *opt, +const char *core_option_manager_get_desc(core_option_manager_t *opt, size_t idx); /** - * core_option_get_val: + * core_option_manager_get_val: * @opt : options manager handle * @idx : idx identifier of the option * @@ -115,24 +115,24 @@ const char *core_option_get_desc(core_option_manager_t *opt, * * Returns: Value for an option. **/ -const char *core_option_get_val(core_option_manager_t *opt, +const char *core_option_manager_get_val(core_option_manager_t *opt, size_t idx); -void core_option_set_val(core_option_manager_t *opt, +void core_option_manager_set_val(core_option_manager_t *opt, size_t idx, size_t val_idx); /** - * core_option_next: + * core_option_manager_next: * @opt : pointer to core option manager object. * @idx : idx of core option to be reset to defaults. * * Get next value for core option specified by @idx. * Options wrap around. **/ -void core_option_next(core_option_manager_t *opt, size_t idx); +void core_option_manager_next(core_option_manager_t *opt, size_t idx); /** - * core_option_prev: + * core_option_manager_prev: * @opt : pointer to core option manager object. * @idx : idx of core option to be reset to defaults. * Options wrap around. @@ -140,16 +140,16 @@ void core_option_next(core_option_manager_t *opt, size_t idx); * Get previous value for core option specified by @idx. * Options wrap around. **/ -void core_option_prev(core_option_manager_t *opt, size_t idx); +void core_option_manager_prev(core_option_manager_t *opt, size_t idx); /** - * core_option_set_default: + * core_option_manager_set_default: * @opt : pointer to core option manager object. * @idx : idx of core option to be reset to defaults. * * Reset core option specified by @idx and sets default value for option. **/ -void core_option_set_default(core_option_manager_t *opt, size_t idx); +void core_option_manager_set_default(core_option_manager_t *opt, size_t idx); #ifdef __cplusplus } diff --git a/menu/cbs/menu_cbs_get_value.c b/menu/cbs/menu_cbs_get_value.c index 00a89387e4..d9381dcc6c 100644 --- a/menu/cbs/menu_cbs_get_value.c +++ b/menu/cbs/menu_cbs_get_value.c @@ -1258,7 +1258,7 @@ static void menu_action_setting_disp_set_label(file_list_t* list, if (runloop_ctl(RUNLOOP_CTL_COREOPTS_GET, &coreopts)) { - core_opt = core_option_get_val(coreopts, + core_opt = core_option_manager_get_val(coreopts, type - MENU_SETTINGS_CORE_OPTION_START); strlcpy(s, "", len); diff --git a/menu/cbs/menu_cbs_start.c b/menu/cbs/menu_cbs_start.c index e29750ad36..d4a752dc1a 100644 --- a/menu/cbs/menu_cbs_start.c +++ b/menu/cbs/menu_cbs_start.c @@ -259,7 +259,7 @@ static int action_start_core_setting(unsigned type, core_option_manager_t *coreopts = NULL; if (runloop_ctl(RUNLOOP_CTL_COREOPTS_GET, &coreopts)) - core_option_set_default(coreopts, idx); + core_option_manager_set_default(coreopts, idx); return 0; } diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 5adcc3c8b2..6ad28b2c35 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -3934,7 +3934,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) for (i = 0; i < opts; i++) menu_entries_add(info->list, - core_option_get_desc(coreopts, i), "", + core_option_manager_get_desc(coreopts, i), "", MENU_SETTINGS_CORE_OPTION_START + i, 0, 0); } } diff --git a/runloop.c b/runloop.c index 97be8b4e5d..a5d0c87ac8 100644 --- a/runloop.c +++ b/runloop.c @@ -672,7 +672,7 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) unsigned *idx = (unsigned*)data; if (!idx) return false; - *idx = core_option_size(runloop_core_options); + *idx = core_option_manager_size(runloop_core_options); } break; case RUNLOOP_CTL_HAS_CORE_OPTIONS: @@ -1076,13 +1076,13 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) case RUNLOOP_CTL_IS_CORE_OPTION_UPDATED: if (!runloop_core_options) return false; - return core_option_updated(runloop_core_options); + return core_option_manager_updated(runloop_core_options); case RUNLOOP_CTL_CORE_OPTION_PREV: { unsigned *idx = (unsigned*)data; if (!idx) return false; - core_option_prev(runloop_core_options, *idx); + core_option_manager_prev(runloop_core_options, *idx); if (ui_companion_is_on_foreground()) ui_companion_driver_notify_refresh(); } @@ -1092,7 +1092,7 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) unsigned *idx = (unsigned*)data; if (!idx) return false; - core_option_next(runloop_core_options, *idx); + core_option_manager_next(runloop_core_options, *idx); if (ui_companion_is_on_foreground()) ui_companion_driver_notify_refresh(); } @@ -1105,7 +1105,7 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) return false; RARCH_LOG("Environ GET_VARIABLE %s:\n", var->key); - core_option_get(runloop_core_options, var); + core_option_manager_get(runloop_core_options, var); RARCH_LOG("\t%s\n", var->value ? var->value : "N/A"); } break; @@ -1134,21 +1134,21 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) { runloop_ctl(RUNLOOP_CTL_SET_GAME_OPTIONS_ACTIVE, NULL); runloop_core_options = - core_option_new(game_options_path, vars); + core_option_manager_new(game_options_path, vars); free(game_options_path); } else { runloop_ctl(RUNLOOP_CTL_UNSET_GAME_OPTIONS_ACTIVE, NULL); runloop_core_options = - core_option_new(options_path, vars); + core_option_manager_new(options_path, vars); } } break; case RUNLOOP_CTL_CORE_OPTIONS_FREE: if (runloop_core_options) - core_option_free(runloop_core_options); + core_option_manager_free(runloop_core_options); runloop_core_options = NULL; break; case RUNLOOP_CTL_CORE_OPTIONS_DEINIT: @@ -1161,12 +1161,12 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) to that file instead */ if(global && !string_is_empty(global->path.core_options_path)) { - core_option_flush_game_specific(runloop_core_options, + core_option_manager_flush_game_specific(runloop_core_options, global->path.core_options_path); global->path.core_options_path[0] = '\0'; } else - core_option_flush(runloop_core_options); + core_option_manager_flush(runloop_core_options); if (runloop_ctl(RUNLOOP_CTL_IS_GAME_OPTIONS_ACTIVE, NULL)) runloop_ctl(RUNLOOP_CTL_UNSET_GAME_OPTIONS_ACTIVE, NULL); From af2a33a8cb6493dd8bee781c54532a2468f26cd4 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 May 2016 01:25:47 +0200 Subject: [PATCH 348/498] Move core_option_manager to managers/ --- Makefile.common | 2 +- griffin/griffin.c | 2 +- core_options.c => managers/core_option_manager.c | 4 ++-- core_options.h => managers/core_option_manager.h | 4 ++-- menu/cbs/menu_cbs_get_value.c | 2 +- menu/cbs/menu_cbs_start.c | 2 +- menu/menu_displaylist.c | 2 +- runloop.c | 2 +- 8 files changed, 10 insertions(+), 10 deletions(-) rename core_options.c => managers/core_option_manager.c (99%) rename core_options.h => managers/core_option_manager.h (98%) diff --git a/Makefile.common b/Makefile.common index 955a636de1..9d184e89f8 100644 --- a/Makefile.common +++ b/Makefile.common @@ -168,7 +168,7 @@ OBJ += frontend/frontend.o \ input/input_overlay.o \ patch.o \ libretro-common/queues/fifo_queue.o \ - core_options.o \ + managers/core_option_manager.o \ libretro-common/compat/compat_fnmatch.o \ libretro-common/compat/compat_posix_string.o \ managers/cheat_manager.o \ diff --git a/griffin/griffin.c b/griffin/griffin.c index 62be59e8da..8c0d1ab72f 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -101,7 +101,7 @@ CONFIG FILE #include "../libretro-common/file/config_file.c" #include "../config_file_userdata.c" -#include "../core_options.c" +#include "../managers/core_option_manager.c" /*============================================================ ACHIEVEMENTS diff --git a/core_options.c b/managers/core_option_manager.c similarity index 99% rename from core_options.c rename to managers/core_option_manager.c index 7e391bfb10..466f10352d 100644 --- a/core_options.c +++ b/managers/core_option_manager.c @@ -24,9 +24,9 @@ #include #include -#include "libretro.h" +#include "../libretro.h" -#include "core_options.h" +#include "core_option_manager.h" struct core_option { diff --git a/core_options.h b/managers/core_option_manager.h similarity index 98% rename from core_options.h rename to managers/core_option_manager.h index ff972434ba..152e8d19c7 100644 --- a/core_options.h +++ b/managers/core_option_manager.h @@ -14,8 +14,8 @@ * If not, see . */ -#ifndef CORE_OPTIONS_H__ -#define CORE_OPTIONS_H__ +#ifndef CORE_OPTION_MANAGER_H__ +#define CORE_OPTION_MANAGER_H__ #include diff --git a/menu/cbs/menu_cbs_get_value.c b/menu/cbs/menu_cbs_get_value.c index d9381dcc6c..6c49bcfeec 100644 --- a/menu/cbs/menu_cbs_get_value.c +++ b/menu/cbs/menu_cbs_get_value.c @@ -27,7 +27,7 @@ #include "../../input/input_config.h" #include "../../core_info.h" -#include "../../core_options.h" +#include "../../managers/core_option_manager.h" #include "../../managers/cheat_manager.h" #include "../../general.h" #include "../../performance.h" diff --git a/menu/cbs/menu_cbs_start.c b/menu/cbs/menu_cbs_start.c index d4a752dc1a..ed07712099 100644 --- a/menu/cbs/menu_cbs_start.c +++ b/menu/cbs/menu_cbs_start.c @@ -25,7 +25,7 @@ #include "../menu_hash.h" #include "../../core_info.h" -#include "../../core_options.h" +#include "../../managers/core_option_manager.h" #include "../../managers/cheat_manager.h" #include "../../general.h" #include "../../retroarch.h" diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 6ad28b2c35..babe720ea0 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -32,6 +32,7 @@ #include "../defaults.h" #include "../managers/cheat_manager.h" +#include "../managers/core_option_manager.h" #include "../general.h" #include "../retroarch.h" #include "../system.h" @@ -45,7 +46,6 @@ #include "../list_special.h" #include "../performance.h" #include "../core_info.h" -#include "../core_options.h" #ifdef HAVE_CHEEVOS #include "../cheevos.h" diff --git a/runloop.c b/runloop.c index a5d0c87ac8..44a6ba753c 100644 --- a/runloop.c +++ b/runloop.c @@ -37,12 +37,12 @@ #endif #include "autosave.h" #include "core_info.h" -#include "core_options.h" #include "configuration.h" #include "performance.h" #include "movie.h" #include "retroarch.h" #include "runloop.h" +#include "managers/core_option_manager.h" #include "managers/cheat_manager.h" #include "managers/state_manager.h" #include "system.h" From 5d821f42a3a986153145bebe70ff7cc0b4a8dc0b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 May 2016 01:41:58 +0200 Subject: [PATCH 349/498] Turn another runloop_ctl action into a static function --- runloop.c | 37 +++++++++++++++++++------------------ runloop.h | 1 - 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/runloop.c b/runloop.c index 44a6ba753c..90293aaaa9 100644 --- a/runloop.c +++ b/runloop.c @@ -144,6 +144,23 @@ static void runloop_msg_queue_unlock(void) #endif } +static bool runloop_msg_queue_push_internal(runloop_ctx_msg_info_t *msg_info) +{ + if (!msg_info || !runloop_msg_queue) + return false; + msg_queue_push(runloop_msg_queue, msg_info->msg, + msg_info->prio, msg_info->duration); + + if (ui_companion_is_on_foreground()) + { + const ui_companion_driver_t *ui = ui_companion_get_ptr(); + if (ui->msg_queue_push) + ui->msg_queue_push(msg_info->msg, + msg_info->prio, msg_info->duration, msg_info->flush); + } + return true; +} + void runloop_msg_queue_push(const char *msg, unsigned prio, unsigned duration, bool flush) @@ -163,7 +180,7 @@ void runloop_msg_queue_push(const char *msg, msg_info.duration = duration; msg_info.flush = flush; - runloop_ctl(RUNLOOP_CTL_MSG_QUEUE_PUSH, &msg_info); + runloop_msg_queue_push_internal(&msg_info); runloop_msg_queue_unlock(); } @@ -641,6 +658,7 @@ static bool runloop_is_frame_count_end(void) return runloop_max_frames && (*frame_count >= runloop_max_frames); } + bool runloop_ctl(enum runloop_ctl_state state, void *data) { settings_t *settings = config_get_ptr(); @@ -967,23 +985,6 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) break; case RUNLOOP_CTL_IS_PAUSED: return runloop_paused; - case RUNLOOP_CTL_MSG_QUEUE_PUSH: - { - runloop_ctx_msg_info_t *msg_info = (runloop_ctx_msg_info_t*)data; - if (!msg_info || !runloop_msg_queue) - return false; - msg_queue_push(runloop_msg_queue, msg_info->msg, - msg_info->prio, msg_info->duration); - - if (ui_companion_is_on_foreground()) - { - const ui_companion_driver_t *ui = ui_companion_get_ptr(); - if (ui->msg_queue_push) - ui->msg_queue_push(msg_info->msg, - msg_info->prio, msg_info->duration, msg_info->flush); - } - } - break; case RUNLOOP_CTL_MSG_QUEUE_PULL: runloop_msg_queue_lock(); { diff --git a/runloop.h b/runloop.h index e451671cde..46a74d6e9f 100644 --- a/runloop.h +++ b/runloop.h @@ -91,7 +91,6 @@ enum runloop_ctl_state RUNLOOP_CTL_MSG_QUEUE_FREE, RUNLOOP_CTL_MSG_QUEUE_PULL, - RUNLOOP_CTL_MSG_QUEUE_PUSH, RUNLOOP_CTL_MSG_QUEUE_CLEAR, RUNLOOP_CTL_HAS_CORE_OPTIONS, RUNLOOP_CTL_GET_CORE_OPTION_SIZE, From d0f6facc0fd50b769677e8b0e004b76ee056cd53 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 May 2016 01:44:13 +0200 Subject: [PATCH 350/498] (runloop.c) Rename functions --- runloop.c | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/runloop.c b/runloop.c index 90293aaaa9..647e15544a 100644 --- a/runloop.c +++ b/runloop.c @@ -282,7 +282,7 @@ static bool runloop_cmd_get_state_menu_toggle_button_combo( #endif /** - * check_pause: + * runloop_check_pause: * @pressed : was libretro pause key pressed? * @frameadvance_pressed : was frameadvance key pressed? * @@ -291,7 +291,7 @@ static bool runloop_cmd_get_state_menu_toggle_button_combo( * * Returns: true if libretro pause key was toggled, otherwise false. **/ -static bool check_pause(settings_t *settings, +static bool runloop_check_pause(settings_t *settings, bool focus, bool pause_pressed, bool frameadvance_pressed) { @@ -321,7 +321,7 @@ static bool check_pause(settings_t *settings, } /** - * check_fast_forward_button: + * runloop_check_fast_forward_button: * @fastforward_pressed : is fastforward key pressed? * @hold_pressed : is fastforward key pressed and held? * @old_hold_pressed : was fastforward key pressed and held the last frame? @@ -329,7 +329,7 @@ static bool check_pause(settings_t *settings, * Checks if the fast forward key has been pressed for this frame. * **/ -static void check_fast_forward_button(bool fastforward_pressed, +static void runloop_check_fast_forward_button(bool fastforward_pressed, bool hold_pressed, bool old_hold_pressed) { /* To avoid continous switching if we hold the button down, we require @@ -357,14 +357,14 @@ static void check_fast_forward_button(bool fastforward_pressed, } /** - * check_stateslots: + * runloop_check_stateslots: * @pressed_increase : is state slot increase key pressed? * @pressed_decrease : is state slot decrease key pressed? * * Checks if the state increase/decrease keys have been pressed * for this frame. **/ -static void check_stateslots(settings_t *settings, +static void runloop_check_stateslots(settings_t *settings, bool pressed_increase, bool pressed_decrease) { char msg[128]; @@ -426,7 +426,7 @@ static bool shader_dir_init(rarch_dir_list_t *dir_list) } /** - * check_shader_dir: + * runloop_check_shader_dir: * @pressed_next : was next shader key pressed? * @pressed_previous : was previous shader key pressed? * @@ -436,7 +436,7 @@ static bool shader_dir_init(rarch_dir_list_t *dir_list) * * Will also immediately apply the shader. **/ -static void check_shader_dir(rarch_dir_list_t *dir_list, +static void runloop_check_shader_dir(rarch_dir_list_t *dir_list, bool pressed_next, bool pressed_prev) { uint32_t ext_hash; @@ -564,11 +564,11 @@ static bool runloop_check_state(event_cmd_state_t *cmd, rarch_dir_list_t *shader if (!runloop_ctl(RUNLOOP_CTL_CHECK_IDLE_STATE, cmd)) return false; - check_fast_forward_button( + runloop_check_fast_forward_button( runloop_cmd_triggered(cmd, RARCH_FAST_FORWARD_KEY), runloop_cmd_press (cmd, RARCH_FAST_FORWARD_HOLD_KEY), runloop_cmd_pressed (cmd, RARCH_FAST_FORWARD_HOLD_KEY)); - check_stateslots(settings, + runloop_check_stateslots(settings, runloop_cmd_triggered(cmd, RARCH_STATE_SLOT_PLUS), runloop_cmd_triggered(cmd, RARCH_STATE_SLOT_MINUS) ); @@ -590,7 +590,7 @@ static bool runloop_check_state(event_cmd_state_t *cmd, rarch_dir_list_t *shader if (runloop_cmd_triggered(cmd, RARCH_MOVIE_RECORD_TOGGLE)) runloop_ctl(RUNLOOP_CTL_CHECK_MOVIE, NULL); - check_shader_dir(shader_dir, + runloop_check_shader_dir(shader_dir, runloop_cmd_triggered(cmd, RARCH_SHADER_NEXT), runloop_cmd_triggered(cmd, RARCH_SHADER_PREV)); @@ -853,7 +853,7 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) event_cmd_state_t *cmd = (event_cmd_state_t*)data; bool focused = runloop_is_focused(); - check_pause(settings, focused, + runloop_check_pause(settings, focused, runloop_cmd_triggered(cmd, RARCH_PAUSE_TOGGLE), runloop_cmd_triggered(cmd, RARCH_FRAMEADVANCE)); From 938257b1edfc5b9096a41c16f38b1da4d3518fbd Mon Sep 17 00:00:00 2001 From: Andre Leiradella Date: Mon, 9 May 2016 20:44:59 -0300 Subject: [PATCH 351/498] better logging --- cheevos.c | 129 +++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 90 insertions(+), 39 deletions(-) diff --git a/cheevos.c b/cheevos.c index e4358f8b7d..b111776f62 100644 --- a/cheevos.c +++ b/cheevos.c @@ -38,6 +38,12 @@ #include "verbosity.h" +/* Define this macro to deactivate awarded cheevos. */ +#define CHEEVOS_DEACTIVATE + +/* Define this macro to log URLs (will log the user token). */ +#undef CHEEVOS_LOG_URLS + #define JSON_KEY_GAMEID 0xb4960eecU #define JSON_KEY_ACHIEVEMENTS 0x69749ae1U #define JSON_KEY_ID 0x005973f2U @@ -49,10 +55,16 @@ #define JSON_KEY_MODIFIED 0xdcea4fe6U #define JSON_KEY_CREATED 0x3a84721dU #define JSON_KEY_BADGENAME 0x887685d9U - +#define JSON_KEY_CONSOLE_ID 0x071656e5U #define JSON_KEY_TOKEN 0x0e2dbd26U #define JSON_KEY_FLAGS 0x0d2e96b2U +enum +{ + CHEEVOS_CONSOLE_GAMEBOY = 4, + CHEEVOS_CONSOLE_GAMEBOY_COLOR = 6, +}; + enum { CHEEVOS_VAR_SIZE_BIT_0, @@ -176,16 +188,6 @@ typedef struct unsigned count; } cheevoset_t; -typedef struct -{ - int loaded; - - cheevoset_t core; - cheevoset_t unofficial; - - char token[32]; -} cheevos_locals_t; - typedef struct { int is_element; @@ -216,6 +218,7 @@ typedef struct typedef struct { int in_cheevos; + int console_id; unsigned core_count; unsigned unofficial_count; @@ -231,9 +234,20 @@ typedef struct const uint32_t *ext_hashes; } cheevos_finder_t; +typedef struct +{ + int loaded; + int console_id; + + cheevoset_t core; + cheevoset_t unofficial; + + char token[32]; +} cheevos_locals_t; static cheevos_locals_t cheevos_locals = { + 0, 0, {NULL, 0}, {NULL, 0}, @@ -291,12 +305,10 @@ static int cheevos_http_get(const char **result, size_t *size, break; } - RARCH_LOG("CHEEVOS error getting %s: %s\n", url, msg); - RARCH_LOG("CHEEVOS http result was %s\n", *result ? *result : "(null)"); + RARCH_ERR("CHEEVOS error getting %s: %s\n", url, msg); return ret; } - static int cheevos_getvalue__json_key(void *userdata, const char *name, size_t length) { @@ -391,7 +403,6 @@ static int cheevos_get_value(const char *json, unsigned key_hash, Count number of achievements in a JSON file. *****************************************************************************/ - static int cheevos_count__json_end_array(void *userdata) { cheevos_countud_t* ud = (cheevos_countud_t*)userdata; @@ -563,7 +574,7 @@ static unsigned cheevos_parse_operator(const char **memaddr) } else { - /* TODO log the exception */ + RARCH_ERR("CHEEVOS Unknown operator %c\n", *str); op = CHEEVOS_COND_OP_EQUALS; } @@ -710,7 +721,6 @@ static void cheevos_parse_memaddr(cheevos_cond_t *cond, const char *memaddr) Load achievements from a JSON string. *****************************************************************************/ - static INLINE const char *cheevos_dupstr(const cheevos_field_t *field) { char *string = (char*)malloc(field->length + 1); @@ -797,7 +807,6 @@ static int cheevos_new_cheevo(cheevos_readud_t *ud) return 0; } - static int cheevos_read__json_key( void *userdata, const char *name, size_t length) { @@ -808,6 +817,8 @@ static int cheevos_read__json_key( void *userdata, if (hash == JSON_KEY_ACHIEVEMENTS) ud->in_cheevos = 1; + else if (hash == JSON_KEY_CONSOLE_ID) + ud->console_id = 0; else if (ud->in_cheevos) { switch ( hash ) @@ -872,7 +883,9 @@ static int cheevos_read__json_number(void *userdata, ud->field->string = number; ud->field->length = length; } - + else if (ud->console_id == 0) + ud->console_id = strtol(number, NULL, 10); + return 0; } @@ -950,6 +963,7 @@ static int cheevos_parse(const char *json) /* Load the achievements. */ ud.in_cheevos = 0; + ud.console_id = -1; ud.field = NULL; ud.core_count = 0; ud.unofficial_count = 0; @@ -960,6 +974,7 @@ static int cheevos_parse(const char *json) return -1; } + cheevos_locals.console_id = ud.console_id; return 0; } @@ -971,7 +986,8 @@ static const uint8_t *cheevos_get_memory(unsigned offset) { retro_ctx_memory_info_t mem_info; uint8_t *memory = NULL; - + unsigned i; + mem_info.id = RETRO_MEMORY_SYSTEM_RAM; core_get_memory(&mem_info); @@ -1322,7 +1338,7 @@ static int cheevos_login(retro_time_t *timeout) { runloop_msg_queue_push("Missing Retro Achievements account information", 0, 5 * 60, false); runloop_msg_queue_push("Please fill in your account information in Settings", 0, 5 * 60, false); - RARCH_LOG("CHEEVOS username and/or password not informed\n"); + RARCH_ERR("CHEEVOS username and/or password not informed\n"); return -1; } @@ -1337,6 +1353,10 @@ static int cheevos_login(retro_time_t *timeout) request[sizeof(request) - 1] = 0; +#ifdef CHEEVOS_LOG_URLS + RARCH_LOG("CHEEVOS url to login: %s\n", request); +#endif + if (!cheevos_http_get(&json, NULL, request, timeout)) { res = cheevos_get_value(json, JSON_KEY_TOKEN, @@ -1346,7 +1366,6 @@ static int cheevos_login(retro_time_t *timeout) if (!res) { - RARCH_LOG("CHEEVOS user token is '%s'\n", cheevos_locals.token); return 0; } } @@ -1356,7 +1375,7 @@ static int cheevos_login(retro_time_t *timeout) runloop_msg_queue_push( "Please make sure your account information is correct", 0, 5 * 60, false); - RARCH_LOG("CHEEVOS error getting user token.\n"); + RARCH_ERR("CHEEVOS error getting user token.\n"); return -1; } @@ -1376,8 +1395,11 @@ static void cheevos_unlocker(void *payload) ); request[sizeof(request) - 1] = 0; - RARCH_LOG("CHEEVOS awarding achievement %u: %s\n", cheevo_id, request); - + +#ifdef CHEEVOS_LOG_URLS + RARCH_LOG("CHEEVOS url to award a cheevo: %s\n", request); +#endif + if (!cheevos_http_get(&result, NULL, request, NULL)) { RARCH_LOG("CHEEVOS awarded achievement %u: %s\n", cheevo_id, result); @@ -1385,7 +1407,8 @@ static void cheevos_unlocker(void *payload) } else { - RARCH_LOG("CHEEVOS error awarding achievement %u, will retry...\n", cheevo_id); + RARCH_ERR("CHEEVOS error awarding achievement %u, will retry...\n", cheevo_id); + /* re-schedule */ rarch_main_async_job_add(cheevos_unlocker, (void*)(uintptr_t)cheevo_id); } } @@ -1400,8 +1423,7 @@ static void cheevos_test_cheevo_set(const cheevoset_t *set) { if (cheevo->active && cheevos_test_cheevo(cheevo)) { - RARCH_LOG("CHEEVOS %s\n", cheevo->title); - RARCH_LOG("CHEEVOS %s\n", cheevo->description); + RARCH_LOG("CHEEVOS awarding cheevo %s (%s)\n", cheevo->title, cheevo->description); runloop_msg_queue_push(cheevo->title, 0, 3 * 60, false); runloop_msg_queue_push(cheevo->description, 0, 5 * 60, false); @@ -1466,6 +1488,10 @@ static int cheevos_get_by_game_id(const char **json, ); request[sizeof(request) - 1] = 0; + +#ifdef CHEEVOS_LOG_URLS + RARCH_LOG("CHEEVOS url to get the list of cheevos: %s\n", request); +#endif if (!cheevos_http_get(json, NULL, request, timeout)) { @@ -1473,7 +1499,7 @@ static int cheevos_get_by_game_id(const char **json, return 0; } - RARCH_LOG("CHEEVOS error getting achievements for game id %u\n", game_id); + RARCH_ERR("CHEEVOS error getting achievements for game id %u\n", game_id); } return -1; @@ -1504,6 +1530,10 @@ static unsigned cheevos_get_game_id(unsigned char *hash, retro_time_t *timeout) ); request[sizeof(request) - 1] = 0; + +#ifdef CHEEVOS_LOG_URLS + RARCH_LOG("CHEEVOS url to get the game's id: %s\n", request); +#endif if (!cheevos_http_get(&json, NULL, request, timeout)) { @@ -1519,7 +1549,7 @@ static unsigned cheevos_get_game_id(unsigned char *hash, retro_time_t *timeout) } } - RARCH_LOG("CHEEVOS error getting game_id\n"); + RARCH_ERR("CHEEVOS error getting game_id\n"); return 0; } @@ -1539,6 +1569,10 @@ static void cheevos_playing(void *payload) ); request[sizeof(request) - 1] = 0; + +#ifdef CHEEVOS_LOG_URLS + RARCH_LOG("CHEEVOS url to post the 'playing' activity: %s\n", request); +#endif if (!cheevos_http_get(&json, NULL, request, NULL)) { @@ -1548,13 +1582,14 @@ static void cheevos_playing(void *payload) } else { - RARCH_LOG("CHEEVOS error posting playing game %u activity, will retry\n", game_id); + RARCH_ERR("CHEEVOS error posting playing game %u activity, will retry\n", game_id); + /* re-schedule */ rarch_main_async_job_add(cheevos_playing, (void*)(uintptr_t)game_id); } } } - +#ifdef CHEEVOS_DEACTIVATE static int cheevos_deactivate__json_index(void *userdata, unsigned int index) { cheevos_deactivate_t *ud = (cheevos_deactivate_t*)userdata; @@ -1596,22 +1631,28 @@ static int cheevos_deactivate__json_number(void *userdata, for (; cheevo < end; cheevo++) { - if (cheevo->id != id) - continue; - - cheevo->active = 0; - break; + if (cheevo->id == id) + { + cheevo->active = 0; + break; + } } } + if (found) + RARCH_LOG("CHEEVOS deactivated unlocked cheevo %s\n", cheevo->title); + else + RARCH_ERR("CHEEVOS unknown cheevo to deactivate: %u\n", id); } return 0; } +#endif static int cheevos_deactivate_unlocks(unsigned game_id, retro_time_t *timeout) { /* Only call this function after the cheevos have been loaded. */ +#ifdef CHEEVOS_DEACTIVATE static const jsonsax_handlers_t handlers = { NULL, @@ -1643,6 +1684,10 @@ static int cheevos_deactivate_unlocks(unsigned game_id, retro_time_t *timeout) ); request[sizeof(request) - 1] = 0; + +#ifdef CHEEVOS_LOG_URLS + RARCH_LOG("CHEEVOS url to get the list of unlocked cheevos: %s\n", request); +#endif if (!cheevos_http_get(&json, NULL, request, timeout)) { @@ -1658,8 +1703,12 @@ static int cheevos_deactivate_unlocks(unsigned game_id, retro_time_t *timeout) } } - RARCH_LOG("CHEEVOS error deactivating unlocked achievements\n"); + RARCH_ERR("CHEEVOS error deactivating unlocked achievements\n"); return -1; +#else + RARCH_LOG("CHEEVOS cheevo deactivation is disabled\n"); + return 0; +#endif } #define CHEEVOS_SIX_MB (6 * 1024 * 1024) @@ -2014,7 +2063,7 @@ bool cheevos_load(const void *data) if (!memory) { runloop_msg_queue_push("This core doesn't support achievements", 0, 5 * 60, false); - RARCH_LOG("This core doesn't support achievements\n"); + RARCH_ERR("This core doesn't support achievements\n"); return false; } @@ -2079,6 +2128,7 @@ bool cheevos_load(const void *data) runloop_msg_queue_push("This game doesn't feature achievements", 0, 5 * 60, false); + RARCH_LOG("CHEEVOS this game doesn't feature achievements\n"); return false; found: @@ -2099,6 +2149,7 @@ bool cheevos_load(const void *data) } runloop_msg_queue_push("Error loading achievements", 0, 5 * 60, false); + RARCH_ERR("CHEEVOS error loading achievements\n", 0, 5 * 60, false); return false; } From 0e08dbe931ce3ee154038ab4c8520fccd3508c6f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 May 2016 02:32:49 +0200 Subject: [PATCH 352/498] Rename gfx_coord to video_coord --- gfx/common/gl_common.c | 2 +- gfx/common/gl_common.h | 4 ++-- gfx/drivers_font/gl_raster_font.c | 8 ++++---- gfx/drivers_shader/shader_gl_cg.c | 2 +- gfx/drivers_shader/shader_glsl.c | 2 +- gfx/drivers_shader/shader_null.c | 2 +- gfx/video_coord_array.c | 10 +++++----- gfx/video_coord_array.h | 16 ++++++++-------- gfx/video_shader_driver.c | 2 +- gfx/video_shader_driver.h | 2 +- menu/drivers/materialui.c | 6 +++--- menu/drivers/nuklear.c | 2 +- menu/drivers/xmb.c | 14 +++++++------- menu/drivers/zarch.c | 6 +++--- menu/drivers_display/menu_display_d3d.cpp | 4 ++-- menu/drivers_display/menu_display_gl.c | 4 ++-- menu/drivers_display/menu_display_vulkan.c | 4 ++-- menu/menu_display.c | 18 +++++++++--------- menu/menu_display.h | 4 ++-- 19 files changed, 56 insertions(+), 56 deletions(-) diff --git a/gfx/common/gl_common.c b/gfx/common/gl_common.c index 7c78c63d46..3751d1cfa7 100644 --- a/gfx/common/gl_common.c +++ b/gfx/common/gl_common.c @@ -16,7 +16,7 @@ #include "gl_common.h" -void gl_ff_vertex(const struct gfx_coords *coords) +void gl_ff_vertex(const struct video_coords *coords) { #ifndef NO_GL_FF_VERTEX /* Fall back to fixed function-style if needed and possible. */ diff --git a/gfx/common/gl_common.h b/gfx/common/gl_common.h index fba6b5c182..ac0ebc8f04 100644 --- a/gfx/common/gl_common.h +++ b/gfx/common/gl_common.h @@ -231,7 +231,7 @@ typedef struct gl unsigned tex_w, tex_h; math_matrix_4x4 mvp, mvp_no_rot; - struct gfx_coords coords; + struct video_coords coords; const float *vertex_ptr; const float *white_color_ptr; @@ -339,7 +339,7 @@ static INLINE unsigned gl_wrap_type_to_enum(enum gfx_wrap_type type) return 0; } -void gl_ff_vertex(const struct gfx_coords *coords); +void gl_ff_vertex(const struct video_coords *coords); void gl_ff_matrix(const math_matrix_4x4 *mat); #endif diff --git a/gfx/drivers_font/gl_raster_font.c b/gfx/drivers_font/gl_raster_font.c index 911a2541e9..5d47351391 100644 --- a/gfx/drivers_font/gl_raster_font.c +++ b/gfx/drivers_font/gl_raster_font.c @@ -229,7 +229,7 @@ static int gl_get_message_width(void *data, const char *msg, return delta_x * scale; } -static void gl_raster_font_draw_vertices(gl_t *gl, const gfx_coords_t *coords) +static void gl_raster_font_draw_vertices(gl_t *gl, const video_coords_t *coords) { video_shader_ctx_mvp_t mvp; video_shader_ctx_coords_t coords_data; @@ -255,7 +255,7 @@ static void gl_raster_font_render_line( int x, y, delta_x, delta_y; float inv_tex_size_x, inv_tex_size_y, inv_win_width, inv_win_height; unsigned i, msg_len; - struct gfx_coords coords; + struct video_coords coords; GLfloat font_tex_coords[2 * 6 * MAX_MSG_LEN_CHUNK]; GLfloat font_vertex[2 * 6 * MAX_MSG_LEN_CHUNK]; GLfloat font_color[4 * 6 * MAX_MSG_LEN_CHUNK]; @@ -326,7 +326,7 @@ static void gl_raster_font_render_line( coords.lut_tex_coord = font_lut_tex_coord; if (font->block) - gfx_coord_array_append(&font->block->carr, &coords, coords.vertices); + video_coord_array_append(&font->block->carr, &coords, coords.vertices); else gl_raster_font_draw_vertices(gl, &coords); @@ -526,7 +526,7 @@ static void gl_raster_font_flush_block(void *data) return; gl_raster_font_setup_viewport(font, block->fullscreen); - gl_raster_font_draw_vertices(font->gl, (gfx_coords_t*)&block->carr.coords); + gl_raster_font_draw_vertices(font->gl, (video_coords_t*)&block->carr.coords); gl_raster_font_restore_viewport(font->gl); } diff --git a/gfx/drivers_shader/shader_gl_cg.c b/gfx/drivers_shader/shader_gl_cg.c index c54ac7366d..9e42d992a5 100644 --- a/gfx/drivers_shader/shader_gl_cg.c +++ b/gfx/drivers_shader/shader_gl_cg.c @@ -260,7 +260,7 @@ fallback: return false; } -static bool gl_cg_set_coords(void *handle_data, void *shader_data, const struct gfx_coords *coords) +static bool gl_cg_set_coords(void *handle_data, void *shader_data, const struct video_coords *coords) { cg_shader_data_t *cg = (cg_shader_data_t*)shader_data; diff --git a/gfx/drivers_shader/shader_glsl.c b/gfx/drivers_shader/shader_glsl.c index 632806c3ba..a0161b53d0 100644 --- a/gfx/drivers_shader/shader_glsl.c +++ b/gfx/drivers_shader/shader_glsl.c @@ -1407,7 +1407,7 @@ fallback: size += multiplier * coords->vertices; \ } -static bool gl_glsl_set_coords(void *handle_data, void *shader_data, const struct gfx_coords *coords) +static bool gl_glsl_set_coords(void *handle_data, void *shader_data, const struct video_coords *coords) { /* Avoid hitting malloc on every single regular quad draw. */ GLfloat short_buffer[4 * (2 + 2 + 4 + 2)]; diff --git a/gfx/drivers_shader/shader_null.c b/gfx/drivers_shader/shader_null.c index 29bdde3153..0fbe82863d 100644 --- a/gfx/drivers_shader/shader_null.c +++ b/gfx/drivers_shader/shader_null.c @@ -92,7 +92,7 @@ static bool shader_null_set_mvp(void *data, void *shader_data, const math_matrix return false; } -static bool shader_null_set_coords(void *handle_data, void *shader_data, const struct gfx_coords *coords) +static bool shader_null_set_coords(void *handle_data, void *shader_data, const struct video_coords *coords) { #ifdef HAVE_OPENGL #ifndef NO_GL_FF_VERTEX diff --git a/gfx/video_coord_array.c b/gfx/video_coord_array.c index c968edd279..5d73f97df5 100644 --- a/gfx/video_coord_array.c +++ b/gfx/video_coord_array.c @@ -36,7 +36,7 @@ static INLINE bool realloc_checked(void **ptr, size_t size) return *ptr == nptr; } -static bool gfx_coord_array_resize(gfx_coord_array_t *ca, +static bool video_coord_array_resize(video_coord_array_t *ca, unsigned cap) { size_t base_size = sizeof(float) * cap; @@ -59,8 +59,8 @@ static bool gfx_coord_array_resize(gfx_coord_array_t *ca, return true; } -bool gfx_coord_array_append(gfx_coord_array_t *ca, - const gfx_coords_t *coords, unsigned count) +bool video_coord_array_append(video_coord_array_t *ca, + const video_coords_t *coords, unsigned count) { size_t base_size, offset; count = MIN(count, coords->vertices); @@ -68,7 +68,7 @@ bool gfx_coord_array_append(gfx_coord_array_t *ca, if (ca->coords.vertices + count >= ca->allocated) { unsigned cap = next_pow2(ca->coords.vertices + count); - if (!gfx_coord_array_resize(ca, cap)) + if (!video_coord_array_resize(ca, cap)) return false; } @@ -94,7 +94,7 @@ bool gfx_coord_array_append(gfx_coord_array_t *ca, return true; } -void gfx_coord_array_free(gfx_coord_array_t *ca) +void video_coord_array_free(video_coord_array_t *ca) { if (!ca->allocated) return; diff --git a/gfx/video_coord_array.h b/gfx/video_coord_array.h index 7cb2851f5f..5a46843955 100644 --- a/gfx/video_coord_array.h +++ b/gfx/video_coord_array.h @@ -54,7 +54,7 @@ struct gfx_tex_info float coord[8]; }; -typedef struct gfx_coords +typedef struct video_coords { const float *vertex; const float *color; @@ -63,7 +63,7 @@ typedef struct gfx_coords unsigned vertices; const unsigned *index; unsigned indexes; -} gfx_coords_t; +} video_coords_t; typedef struct gfx_mut_coords { @@ -76,22 +76,22 @@ typedef struct gfx_mut_coords unsigned indexes; } gfx_mut_coords_t; -typedef struct gfx_coord_array +typedef struct video_coord_array { gfx_mut_coords_t coords; unsigned allocated; -} gfx_coord_array_t; +} video_coord_array_t; typedef struct gfx_raster_block { bool fullscreen; - gfx_coord_array_t carr; + video_coord_array_t carr; } gfx_font_raster_block_t; -bool gfx_coord_array_append(gfx_coord_array_t *ca, - const gfx_coords_t *coords, unsigned count); +bool video_coord_array_append(video_coord_array_t *ca, + const video_coords_t *coords, unsigned count); -void gfx_coord_array_free(gfx_coord_array_t *ca); +void video_coord_array_free(video_coord_array_t *ca); #ifdef __cplusplus } diff --git a/gfx/video_shader_driver.c b/gfx/video_shader_driver.c index 68beed7855..105365f559 100644 --- a/gfx/video_shader_driver.c +++ b/gfx/video_shader_driver.c @@ -222,7 +222,7 @@ bool video_shader_driver_set_coords(video_shader_ctx_coords_t *coords) if (!current_shader || !current_shader->set_coords) return false; if (!current_shader->set_coords(coords->handle_data, - shader_data, (const struct gfx_coords*)coords->data)) + shader_data, (const struct video_coords*)coords->data)) return false; return true; } diff --git a/gfx/video_shader_driver.h b/gfx/video_shader_driver.h index 426f3ac567..b8d6f4ae18 100644 --- a/gfx/video_shader_driver.h +++ b/gfx/video_shader_driver.h @@ -161,7 +161,7 @@ typedef struct shader_backend void (*shader_scale)(void *data, unsigned index, struct gfx_fbo_scale *scale); bool (*set_coords)(void *handle_data, - void *shader_data, const struct gfx_coords *coords); + void *shader_data, const struct video_coords *coords); bool (*set_mvp)(void *data, void *shader_data, const math_matrix_4x4 *mat); unsigned (*get_prev_textures)(void *data); diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index 23f614cfa6..f30f1a0eae 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -177,7 +177,7 @@ static void mui_draw_icon( { menu_display_ctx_rotate_draw_t rotate_draw; menu_display_ctx_draw_t draw; - struct gfx_coords coords; + struct video_coords coords; math_matrix_4x4 mymat; menu_display_blend_begin(); @@ -275,7 +275,7 @@ static void mui_render_quad(mui_handle_t *mui, float *coord_color) { menu_display_ctx_draw_t draw; - struct gfx_coords coords; + struct video_coords coords; coords.vertices = 4; coords.vertex = NULL; @@ -1101,7 +1101,7 @@ static void mui_free(void *data) if (!mui) return; - gfx_coord_array_free(&mui->list_block.carr); + video_coord_array_free(&mui->list_block.carr); font_driver_bind_block(NULL, NULL); } diff --git a/menu/drivers/nuklear.c b/menu/drivers/nuklear.c index 27bc4f0b55..b2974ac275 100644 --- a/menu/drivers/nuklear.c +++ b/menu/drivers/nuklear.c @@ -313,7 +313,7 @@ static void nk_menu_free(void *data) nk_buffer_free(&device.cmds); nk_common_device_shutdown(&device); - gfx_coord_array_free(&nk->list_block.carr); + video_coord_array_free(&nk->list_block.carr); font_driver_bind_block(NULL, NULL); } diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index a1b2dd0bcc..c85d218b1e 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -493,7 +493,7 @@ static void xmb_draw_icon( float shadow_offset) { menu_display_ctx_draw_t draw; - struct gfx_coords coords; + struct video_coords coords; float shadow[16]; unsigned i; settings_t *settings = config_get_ptr(); @@ -546,7 +546,7 @@ static void xmb_draw_thumbnail(xmb_handle_t *xmb, float *color, unsigned i; menu_display_ctx_rotate_draw_t rotate_draw; menu_display_ctx_draw_t draw; - struct gfx_coords coords; + struct video_coords coords; math_matrix_4x4 mymat; float shadow[16]; float y = xmb->margins.screen.top + xmb->icon.size + xmb->thumbnail_height; @@ -1999,7 +1999,7 @@ static void xmb_draw_dark_layer( unsigned height) { menu_display_ctx_draw_t draw; - struct gfx_coords coords; + struct video_coords coords; float black[16] = { 0, 0, 0, 1, 0, 0, 0, 1, @@ -2495,11 +2495,11 @@ static void xmb_ribbon_set_vertex(float *ribbon_verts, unsigned idx, unsigned ro static void xmb_init_ribbon(xmb_handle_t * xmb) { - gfx_coords_t coords; + video_coords_t coords; float ribbon_verts[2 * XMB_RIBBON_VERTICES]; float dummy[4 * XMB_RIBBON_VERTICES]; unsigned i, r, c, col; - gfx_coord_array_t *ca = NULL; + video_coord_array_t *ca = NULL; memset(&dummy[0], 0, 4 * XMB_RIBBON_VERTICES * sizeof(float)); ca = menu_display_get_coords_array(); @@ -2523,7 +2523,7 @@ static void xmb_init_ribbon(xmb_handle_t * xmb) coords.lut_tex_coord = dummy; coords.vertices = XMB_RIBBON_VERTICES; - gfx_coord_array_append(ca, &coords, XMB_RIBBON_VERTICES); + video_coord_array_append(ca, &coords, XMB_RIBBON_VERTICES); } static void *xmb_init(void **userdata) @@ -2618,7 +2618,7 @@ static void xmb_free(void *data) file_list_free(xmb->horizontal_list); xmb->horizontal_list = NULL; - gfx_coord_array_free(&xmb->raster_block.carr); + video_coord_array_free(&xmb->raster_block.carr); } font_driver_bind_block(NULL, NULL); diff --git a/menu/drivers/zarch.c b/menu/drivers/zarch.c index 24ecf16868..a5e4683016 100644 --- a/menu/drivers/zarch.c +++ b/menu/drivers/zarch.c @@ -871,7 +871,7 @@ static void zarch_frame(void *data) menu_display_ctx_coord_draw_t coord_draw; settings_t *settings = config_get_ptr(); zui_t *zui = (zui_t*)data; - gfx_coord_array_t *ca = NULL; + video_coord_array_t *ca = NULL; ca = menu_display_get_coords_array(); @@ -949,7 +949,7 @@ static void zarch_frame(void *data) draw.y = 0; draw.width = zui->width; draw.height = zui->height; - draw.coords = (struct gfx_coords*)ca; + draw.coords = (struct video_coords*)ca; draw.matrix_data = &zui->mvp; draw.texture = menu_display_white_texture; draw.prim_type = MENU_DISPLAY_PRIM_TRIANGLES; @@ -1048,7 +1048,7 @@ static void zarch_free(void *data) zui_t *zui = (zui_t*)data; if (zui) - gfx_coord_array_free(&zui->tmp_block.carr); + video_coord_array_free(&zui->tmp_block.carr); font_driver_bind_block(NULL, NULL); } diff --git a/menu/drivers_display/menu_display_d3d.cpp b/menu/drivers_display/menu_display_d3d.cpp index dd7336b4f2..816b74e0f1 100644 --- a/menu/drivers_display/menu_display_d3d.cpp +++ b/menu/drivers_display/menu_display_d3d.cpp @@ -184,13 +184,13 @@ static void menu_display_d3d_draw_pipeline(void *data) menu_display_ctx_draw_t *draw = (menu_display_ctx_draw_t*)data; struct uniform_info uniform_param = {0}; static float t = 0; - gfx_coord_array_t *ca = NULL; + video_coord_array_t *ca = NULL; ca = menu_display_get_coords_array(); draw->x = 0; draw->y = 0; - draw->coords = (struct gfx_coords*)(&ca->coords); + draw->coords = (struct video_coords*)(&ca->coords); draw->matrix_data = NULL; switch (draw->pipeline.id) diff --git a/menu/drivers_display/menu_display_gl.c b/menu/drivers_display/menu_display_gl.c index 93f41b37e0..01f6bb54a8 100644 --- a/menu/drivers_display/menu_display_gl.c +++ b/menu/drivers_display/menu_display_gl.c @@ -158,13 +158,13 @@ static void menu_display_gl_draw_pipeline(void *data) menu_display_ctx_draw_t *draw = (menu_display_ctx_draw_t*)data; struct uniform_info uniform_param = {0}; static float t = 0; - gfx_coord_array_t *ca = NULL; + video_coord_array_t *ca = NULL; ca = menu_display_get_coords_array(); draw->x = 0; draw->y = 0; - draw->coords = (struct gfx_coords*)(&ca->coords); + draw->coords = (struct video_coords*)(&ca->coords); draw->matrix_data = NULL; switch (draw->pipeline.id) diff --git a/menu/drivers_display/menu_display_vulkan.c b/menu/drivers_display/menu_display_vulkan.c index 82e5eaca03..ac230d6095 100644 --- a/menu/drivers_display/menu_display_vulkan.c +++ b/menu/drivers_display/menu_display_vulkan.c @@ -97,7 +97,7 @@ static void menu_display_vk_draw_pipeline(void *data) { menu_display_ctx_draw_t *draw = (menu_display_ctx_draw_t*)data; vk_t *vk = (vk_t*)video_driver_get_ptr(false); - gfx_coord_array_t *ca = NULL; + video_coord_array_t *ca = NULL; static float t = 0.0f; if (!vk || !draw) @@ -106,7 +106,7 @@ static void menu_display_vk_draw_pipeline(void *data) ca = menu_display_get_coords_array(); draw->x = 0; draw->y = 0; - draw->coords = (struct gfx_coords*)&ca->coords; + draw->coords = (struct video_coords*)&ca->coords; draw->matrix_data = NULL; draw->pipeline.backend_data = &t; diff --git a/menu/menu_display.c b/menu/menu_display.c index 21074abdac..c5937770d4 100644 --- a/menu/menu_display.c +++ b/menu/menu_display.c @@ -126,7 +126,7 @@ void menu_display_timedate(menu_display_ctx_datetime_t *datetime) } } -static gfx_coord_array_t menu_disp_ca; +static video_coord_array_t menu_disp_ca; static unsigned menu_display_framebuf_width = 0; static unsigned menu_display_framebuf_height = 0; static size_t menu_display_framebuf_pitch = 0; @@ -206,7 +206,7 @@ void menu_display_deinit(void) { if (menu_display_msg_queue) msg_queue_free(menu_display_msg_queue); - gfx_coord_array_free(&menu_disp_ca); + video_coord_array_free(&menu_disp_ca); menu_display_msg_queue = NULL; menu_display_msg_force = false; menu_display_header_height = 0; @@ -228,7 +228,7 @@ void menu_display_coords_array_reset(void) menu_disp_ca.coords.vertices = 0; } -gfx_coord_array_t *menu_display_get_coords_array(void) +video_coord_array_t *menu_display_get_coords_array(void) { return &menu_disp_ca; } @@ -467,7 +467,7 @@ void menu_display_draw_pipeline(menu_display_ctx_draw_t *draw) void menu_display_draw_bg(menu_display_ctx_draw_t *draw) { - static struct gfx_coords coords; + static struct video_coords coords; const float *new_vertex = NULL; const float *new_tex_coord = NULL; if (!menu_disp || !draw) @@ -570,7 +570,7 @@ void menu_display_draw_cursor( float x, float y, unsigned width, unsigned height) { menu_display_ctx_draw_t draw; - struct gfx_coords coords; + struct video_coords coords; settings_t *settings = config_get_ptr(); bool cursor_visible = settings->video.fullscreen || !video_driver_has_windowed(); @@ -618,9 +618,9 @@ void menu_display_push_quad( int x2, int y2) { menu_display_ctx_coord_draw_t coord_draw; - gfx_coords_t coords; float vertex[8]; - gfx_coord_array_t *ca = NULL; + video_coords_t coords; + video_coord_array_t *ca = NULL; ca = menu_display_get_coords_array(); @@ -643,14 +643,14 @@ void menu_display_push_quad( coords.lut_tex_coord = coord_draw.ptr; coords.vertices = 3; - gfx_coord_array_append(ca, &coords, 3); + video_coord_array_append(ca, &coords, 3); coords.color += 4; coords.vertex += 2; coords.tex_coord += 2; coords.lut_tex_coord += 2; - gfx_coord_array_append(ca, &coords, 3); + video_coord_array_append(ca, &coords, 3); } #define PARTICLES_COUNT 100 diff --git a/menu/menu_display.h b/menu/menu_display.h index 2570ca432e..9c3962e1ae 100644 --- a/menu/menu_display.h +++ b/menu/menu_display.h @@ -58,7 +58,7 @@ typedef struct menu_display_ctx_draw float y; unsigned width; unsigned height; - struct gfx_coords *coords; + struct video_coords *coords; void *matrix_data; uintptr_t texture; enum menu_display_prim_type prim_type; @@ -136,7 +136,7 @@ void menu_display_deinit(void); bool menu_display_init(void); void menu_display_coords_array_reset(void); -gfx_coord_array_t *menu_display_get_coords_array(void); +video_coord_array_t *menu_display_get_coords_array(void); void *menu_display_get_font_buffer(void); void menu_display_set_font_buffer(void *buffer); const uint8_t *menu_display_get_font_framebuffer(void); From 2ebb92834c7f2a75c537a28f20e4ae12f46afbfb Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 May 2016 02:34:36 +0200 Subject: [PATCH 353/498] Rename gfx_fbo_rect to video_fbo_rect --- gfx/common/gl_common.h | 2 +- gfx/drivers/gl.c | 14 +++++++------- gfx/video_coord_array.h | 2 +- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/gfx/common/gl_common.h b/gfx/common/gl_common.h index ac0ebc8f04..a9b2485f35 100644 --- a/gfx/common/gl_common.h +++ b/gfx/common/gl_common.h @@ -196,7 +196,7 @@ typedef struct gl /* Render-to-texture, multipass shaders. */ GLuint fbo[GFX_MAX_SHADERS]; GLuint fbo_texture[GFX_MAX_SHADERS]; - struct gfx_fbo_rect fbo_rect[GFX_MAX_SHADERS]; + struct video_fbo_rect fbo_rect[GFX_MAX_SHADERS]; struct gfx_fbo_scale fbo_scale[GFX_MAX_SHADERS]; int fbo_pass; bool fbo_inited; diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 182f12edf8..74ce5b09ed 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -364,8 +364,8 @@ static void gl_compute_fbo_geometry(gl_t *gl, /* Calculate viewports for FBOs. */ for (i = 0; i < gl->fbo_pass; i++) { - struct gfx_fbo_rect *fbo_rect = &gl->fbo_rect[i]; - struct gfx_fbo_scale *fbo_scale = &gl->fbo_scale[i]; + struct video_fbo_rect *fbo_rect = &gl->fbo_rect[i]; + struct gfx_fbo_scale *fbo_scale = &gl->fbo_scale[i]; switch (gl->fbo_scale[i].type_x) { @@ -1025,7 +1025,7 @@ static INLINE void gl_start_frame_fbo(gl_t *gl) } static bool gl_recreate_fbo( - struct gfx_fbo_rect *fbo_rect, + struct video_fbo_rect *fbo_rect, GLuint fbo, GLuint texture ) @@ -1058,7 +1058,7 @@ static void gl_check_fbo_dimension(gl_t *gl, unsigned i, { unsigned img_width, img_height, max, pow2_size; bool check_dimensions = false; - struct gfx_fbo_rect *fbo_rect = &gl->fbo_rect[i]; + struct video_fbo_rect *fbo_rect = &gl->fbo_rect[i]; if (!fbo_rect) return; @@ -1126,7 +1126,7 @@ static void gl_frame_fbo(gl_t *gl, uint64_t frame_count, video_shader_ctx_params_t params; video_shader_ctx_info_t shader_info; unsigned width, height; - const struct gfx_fbo_rect *prev_rect; + const struct video_fbo_rect *prev_rect; struct gfx_tex_info *fbo_info; struct gfx_tex_info fbo_tex_info[GFX_MAX_SHADERS]; int i; @@ -1146,7 +1146,7 @@ static void gl_frame_fbo(gl_t *gl, uint64_t frame_count, video_shader_ctx_mvp_t mvp; video_shader_ctx_coords_t coords; video_shader_ctx_params_t params; - const struct gfx_fbo_rect *rect = &gl->fbo_rect[i]; + const struct video_fbo_rect *rect = &gl->fbo_rect[i]; prev_rect = &gl->fbo_rect[i - 1]; fbo_info = &fbo_tex_info[i - 1]; @@ -1884,7 +1884,7 @@ static bool gl_frame(void *data, const void *frame, #ifdef HAVE_FBO if (gl->fbo_feedback_enable) { - const struct gfx_fbo_rect *rect = &gl->fbo_rect[gl->fbo_feedback_pass]; + 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; diff --git a/gfx/video_coord_array.h b/gfx/video_coord_array.h index 5a46843955..7b1f30e54c 100644 --- a/gfx/video_coord_array.h +++ b/gfx/video_coord_array.h @@ -26,7 +26,7 @@ extern "C" { #endif -struct gfx_fbo_rect +struct video_fbo_rect { unsigned img_width; unsigned img_height; From dde471e0018fe70d058c20c07b20e04398f60e98 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 May 2016 02:39:09 +0200 Subject: [PATCH 354/498] Rename gfx_ structs --- gfx/common/gl_common.h | 4 ++-- gfx/d3d/d3d.cpp | 2 +- gfx/drivers/gl.c | 18 +++++++++--------- gfx/drivers/vulkan.c | 6 +++--- gfx/drivers_shader/shader_gl_cg.c | 10 +++++----- gfx/drivers_shader/shader_glsl.c | 8 ++++---- gfx/drivers_shader/shader_hlsl.c | 7 +++---- gfx/video_coord_array.h | 4 ++-- 8 files changed, 29 insertions(+), 30 deletions(-) diff --git a/gfx/common/gl_common.h b/gfx/common/gl_common.h index a9b2485f35..8c244d13bf 100644 --- a/gfx/common/gl_common.h +++ b/gfx/common/gl_common.h @@ -181,8 +181,8 @@ typedef struct gl GLuint texture[GFX_MAX_TEXTURES]; unsigned tex_index; /* For use with PREV. */ unsigned textures; - struct gfx_tex_info tex_info; - struct gfx_tex_info prev_info[GFX_MAX_TEXTURES]; + struct video_tex_info tex_info; + struct video_tex_info prev_info[GFX_MAX_TEXTURES]; GLuint tex_mag_filter; GLuint tex_min_filter; bool tex_mipmap; diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index 5eb7950be2..f1399993bd 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -1074,7 +1074,7 @@ static bool d3d_construct(d3d_video_t *d3d, static void d3d_set_rotation(void *data, unsigned rot) { d3d_video_t *d3d = (d3d_video_t*)data; - struct gfx_ortho ortho = {0, 1, 0, 1, -1, 1}; + struct video_ortho ortho = {0, 1, 0, 1, -1, 1}; if (!d3d) return; diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 74ce5b09ed..767a2e47b0 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -859,7 +859,7 @@ static bool gl_init_hw_render(gl_t *gl, unsigned width, unsigned height) #endif static void gl_set_projection(gl_t *gl, - struct gfx_ortho *ortho, bool allow_rotate) + struct video_ortho *ortho, bool allow_rotate) { math_matrix_4x4 rot; @@ -885,7 +885,7 @@ static void gl_set_viewport(void *data, unsigned viewport_width, int x = 0; int y = 0; float device_aspect = (float)viewport_width / viewport_height; - struct gfx_ortho ortho = {0, 1, 0, 1, -1, 1}; + struct video_ortho ortho = {0, 1, 0, 1, -1, 1}; settings_t *settings = config_get_ptr(); gl_t *gl = (gl_t*)data; @@ -982,7 +982,7 @@ static void gl_set_viewport(void *data, unsigned viewport_width, static void gl_set_rotation(void *data, unsigned rotation) { gl_t *gl = (gl_t*)data; - struct gfx_ortho ortho = {0, 1, 0, 1, -1, 1}; + struct video_ortho ortho = {0, 1, 0, 1, -1, 1}; if (!gl) return; @@ -1117,8 +1117,8 @@ static void gl_check_fbo_dimensions(gl_t *gl) } static void gl_frame_fbo(gl_t *gl, uint64_t frame_count, - const struct gfx_tex_info *tex_info, - const struct gfx_tex_info *feedback_info) + const struct video_tex_info *tex_info, + const struct video_tex_info *feedback_info) { unsigned mip_level; video_shader_ctx_mvp_t mvp; @@ -1127,8 +1127,8 @@ static void gl_frame_fbo(gl_t *gl, uint64_t frame_count, video_shader_ctx_info_t shader_info; unsigned width, height; const struct video_fbo_rect *prev_rect; - struct gfx_tex_info *fbo_info; - struct gfx_tex_info fbo_tex_info[GFX_MAX_SHADERS]; + struct video_tex_info *fbo_info; + struct video_tex_info fbo_tex_info[GFX_MAX_SHADERS]; int i; GLfloat xamt, yamt; unsigned fbo_tex_info_cnt = 0; @@ -1599,7 +1599,7 @@ static INLINE void gl_copy_frame(gl_t *gl, const void *frame, } static INLINE void gl_set_prev_texture(gl_t *gl, - const struct gfx_tex_info *tex_info) + const struct video_tex_info *tex_info) { memmove(gl->prev_info + 1, gl->prev_info, sizeof(*tex_info) * (gl->textures - 1)); @@ -1757,7 +1757,7 @@ static bool gl_frame(void *data, const void *frame, video_shader_ctx_coords_t coords; video_shader_ctx_params_t params; unsigned width, height; - struct gfx_tex_info feedback_info; + struct video_tex_info feedback_info; video_shader_ctx_info_t shader_info; static struct retro_perf_counter frame_run = {0}; gl_t *gl = (gl_t*)data; diff --git a/gfx/drivers/vulkan.c b/gfx/drivers/vulkan.c index 412529d79b..211828a348 100644 --- a/gfx/drivers/vulkan.c +++ b/gfx/drivers/vulkan.c @@ -1191,7 +1191,7 @@ static bool vulkan_set_shader(void *data, } static void vulkan_set_projection(vk_t *vk, - struct gfx_ortho *ortho, bool allow_rotate) + struct video_ortho *ortho, bool allow_rotate) { math_matrix_4x4 rot; @@ -1212,7 +1212,7 @@ static void vulkan_set_projection(vk_t *vk, static void vulkan_set_rotation(void *data, unsigned rotation) { vk_t *vk = (vk_t*)data; - struct gfx_ortho ortho = {0, 1, 0, 1, -1, 1}; + struct video_ortho ortho = {0, 1, 0, 1, -1, 1}; if (!vk) return; @@ -1243,7 +1243,7 @@ static void vulkan_set_viewport(void *data, unsigned viewport_width, int x = 0; int y = 0; float device_aspect = (float)viewport_width / viewport_height; - struct gfx_ortho ortho = {0, 1, 0, 1, -1, 1}; + struct video_ortho ortho = {0, 1, 0, 1, -1, 1}; settings_t *settings = config_get_ptr(); vk_t *vk = (vk_t*)data; diff --git a/gfx/drivers_shader/shader_gl_cg.c b/gfx/drivers_shader/shader_gl_cg.c index 9e42d992a5..5e34234625 100644 --- a/gfx/drivers_shader/shader_gl_cg.c +++ b/gfx/drivers_shader/shader_gl_cg.c @@ -289,7 +289,7 @@ fallback: static void gl_cg_set_texture_info( cg_shader_data_t *cg, const struct cg_fbo_params *params, - const struct gfx_tex_info *info) + const struct video_tex_info *info) { unsigned i; struct uniform_cg uniform_data[4]; @@ -348,10 +348,10 @@ static void gl_cg_set_params(void *data, void *shader_data, struct uniform_cg uniform_data[10]; struct uniform_info uniform_params[10] = {{0}}; unsigned uniform_count = 0; - const struct gfx_tex_info *info = (const struct gfx_tex_info*)_info; - const struct gfx_tex_info *prev_info = (const struct gfx_tex_info*)_prev_info; - const struct gfx_tex_info *feedback_info = (const struct gfx_tex_info*)_feedback_info; - const struct gfx_tex_info *fbo_info = (const struct gfx_tex_info*)_fbo_info; + const struct video_tex_info *info = (const struct video_tex_info*)_info; + const struct video_tex_info *prev_info = (const struct video_tex_info*)_prev_info; + const struct video_tex_info *feedback_info = (const struct video_tex_info*)_feedback_info; + const struct video_tex_info *fbo_info = (const struct video_tex_info*)_fbo_info; cg_shader_data_t *cg = (cg_shader_data_t*)shader_data; if (!cg || (cg->active_idx == 0)) diff --git a/gfx/drivers_shader/shader_glsl.c b/gfx/drivers_shader/shader_glsl.c index a0161b53d0..38f6b81f1a 100644 --- a/gfx/drivers_shader/shader_glsl.c +++ b/gfx/drivers_shader/shader_glsl.c @@ -1019,10 +1019,10 @@ static void gl_glsl_set_params(void *data, void *shader_data, unsigned texunit = 1; const struct shader_uniforms *uni = NULL; size_t size = 0, attribs_size = 0; - const struct gfx_tex_info *info = (const struct gfx_tex_info*)_info; - const struct gfx_tex_info *prev_info = (const struct gfx_tex_info*)_prev_info; - const struct gfx_tex_info *feedback_info = (const struct gfx_tex_info*)_feedback_info; - const struct gfx_tex_info *fbo_info = (const struct gfx_tex_info*)_fbo_info; + const struct video_tex_info *info = (const struct video_tex_info*)_info; + const struct video_tex_info *prev_info = (const struct video_tex_info*)_prev_info; + const struct video_tex_info *feedback_info = (const struct video_tex_info*)_feedback_info; + const struct video_tex_info *fbo_info = (const struct video_tex_info*)_fbo_info; struct glsl_attrib *attr = (struct glsl_attrib*)attribs; glsl_shader_data_t *glsl = (glsl_shader_data_t*)shader_data; diff --git a/gfx/drivers_shader/shader_hlsl.c b/gfx/drivers_shader/shader_hlsl.c index 26467efafa..2509b2629c 100644 --- a/gfx/drivers_shader/shader_hlsl.c +++ b/gfx/drivers_shader/shader_hlsl.c @@ -124,10 +124,9 @@ static void hlsl_set_params(void *data, void *shader_data, { d3d_video_t *d3d = (d3d_video_t*)data; LPDIRECT3DDEVICE d3d_device_ptr = (LPDIRECT3DDEVICE)d3d->dev; - const struct gfx_tex_info *info = (const struct gfx_tex_info*)_info; - const struct gfx_tex_info *prev_info = (const struct gfx_tex_info*)_prev_info; - (void)_feedback_info; - const struct gfx_tex_info *fbo_info = (const struct gfx_tex_info*)_fbo_info; + const struct video_tex_info *info = (const struct video_tex_info*)_info; + const struct video_tex_info *prev_info = (const struct video_tex_info*)_prev_info; + const struct video_tex_info *fbo_info = (const struct video_tex_info*)_fbo_info; hlsl_shader_data_t *hlsl = (hlsl_shader_data_t*)shader_data; if (!hlsl) diff --git a/gfx/video_coord_array.h b/gfx/video_coord_array.h index 7b1f30e54c..88116a7b15 100644 --- a/gfx/video_coord_array.h +++ b/gfx/video_coord_array.h @@ -36,7 +36,7 @@ struct video_fbo_rect unsigned height; }; -struct gfx_ortho +struct video_ortho { float left; float right; @@ -46,7 +46,7 @@ struct gfx_ortho float zfar; }; -struct gfx_tex_info +struct video_tex_info { unsigned int tex; float input_size[2]; From b2f5e2ac084cad12282350bb207ed33c7b46947b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 May 2016 02:42:02 +0200 Subject: [PATCH 355/498] Rename gfx_font_raster_block --- gfx/drivers_font/gl_raster_font.c | 6 +++--- gfx/video_coord_array.h | 4 ++-- menu/drivers/materialui.c | 2 +- menu/drivers/xmb.c | 2 +- menu/drivers/zarch.c | 2 +- 5 files changed, 8 insertions(+), 8 deletions(-) diff --git a/gfx/drivers_font/gl_raster_font.c b/gfx/drivers_font/gl_raster_font.c index 5d47351391..497521de79 100644 --- a/gfx/drivers_font/gl_raster_font.c +++ b/gfx/drivers_font/gl_raster_font.c @@ -44,7 +44,7 @@ typedef struct const font_renderer_driver_t *font_driver; void *font_data; - gfx_font_raster_block_t *block; + video_font_raster_block_t *block; } gl_raster_t; static void gl_raster_font_free_font(void *data); @@ -520,7 +520,7 @@ static const struct font_glyph *gl_raster_font_get_glyph( static void gl_raster_font_flush_block(void *data) { gl_raster_t *font = (gl_raster_t*)data; - gfx_font_raster_block_t *block = font ? font->block : NULL; + video_font_raster_block_t *block = font ? font->block : NULL; if (!font || !block || !block->carr.coords.vertices) return; @@ -533,7 +533,7 @@ static void gl_raster_font_flush_block(void *data) static void gl_raster_font_bind_block(void *data, void *userdata) { gl_raster_t *font = (gl_raster_t*)data; - gfx_font_raster_block_t *block = (gfx_font_raster_block_t*)userdata; + video_font_raster_block_t *block = (video_font_raster_block_t*)userdata; if (font) font->block = block; diff --git a/gfx/video_coord_array.h b/gfx/video_coord_array.h index 88116a7b15..1fd6588c46 100644 --- a/gfx/video_coord_array.h +++ b/gfx/video_coord_array.h @@ -82,11 +82,11 @@ typedef struct video_coord_array unsigned allocated; } video_coord_array_t; -typedef struct gfx_raster_block +typedef struct video_font_raster_block { bool fullscreen; video_coord_array_t carr; -} gfx_font_raster_block_t; +} video_font_raster_block_t; bool video_coord_array_append(video_coord_array_t *ca, const video_coords_t *coords, unsigned count); diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index f30f1a0eae..49c88ed897 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -109,7 +109,7 @@ typedef struct mui_handle size_t selection_ptr; } categories; - gfx_font_raster_block_t list_block; + video_font_raster_block_t list_block; float scroll_y; } mui_handle_t; diff --git a/menu/drivers/xmb.c b/menu/drivers/xmb.c index c85d218b1e..5391e0184e 100644 --- a/menu/drivers/xmb.c +++ b/menu/drivers/xmb.c @@ -243,7 +243,7 @@ typedef struct xmb_handle xmb_node_t history_tab_node; xmb_node_t add_tab_node; - gfx_font_raster_block_t raster_block; + video_font_raster_block_t raster_block; } xmb_handle_t; float gradient_dark_purple[16] = { diff --git a/menu/drivers/zarch.c b/menu/drivers/zarch.c index a5e4683016..4f60d85183 100644 --- a/menu/drivers/zarch.c +++ b/menu/drivers/zarch.c @@ -107,7 +107,7 @@ typedef struct zarch_handle math_matrix_4x4 mvp; unsigned width; unsigned height; - gfx_font_raster_block_t tmp_block; + video_font_raster_block_t tmp_block; unsigned hash; struct { From 88ae5c0875481220898e6176dde9a2c6f96ecc9e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 May 2016 02:42:52 +0200 Subject: [PATCH 356/498] Rename gfx_mut_coords --- gfx/video_coord_array.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/gfx/video_coord_array.h b/gfx/video_coord_array.h index 1fd6588c46..02305d6f7a 100644 --- a/gfx/video_coord_array.h +++ b/gfx/video_coord_array.h @@ -65,7 +65,7 @@ typedef struct video_coords unsigned indexes; } video_coords_t; -typedef struct gfx_mut_coords +typedef struct video_mut_coords { float *vertex; float *color; @@ -74,11 +74,11 @@ typedef struct gfx_mut_coords unsigned vertices; unsigned *index; unsigned indexes; -} gfx_mut_coords_t; +} video_mut_coords_t; typedef struct video_coord_array { - gfx_mut_coords_t coords; + video_mut_coords_t coords; unsigned allocated; } video_coord_array_t; From 7c20f2b8686cc2cb6a993aa1e5cf5ba1d932329f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 May 2016 03:14:23 +0200 Subject: [PATCH 357/498] Change namespace of thread functions --- audio/audio_driver.c | 2 +- audio/audio_thread_wrapper.c | 4 +- audio/audio_thread_wrapper.h | 4 +- gfx/d3d/d3d.cpp | 2 +- gfx/drivers/gl.c | 2 +- gfx/font_driver.c | 2 +- gfx/video_driver.c | 4 +- gfx/video_thread_wrapper.c | 214 +++++++++++++++++++---------------- gfx/video_thread_wrapper.h | 22 ++-- menu/menu_display.c | 2 +- 10 files changed, 141 insertions(+), 117 deletions(-) diff --git a/audio/audio_driver.c b/audio/audio_driver.c index 0239b80e00..22e3e117f8 100644 --- a/audio/audio_driver.c +++ b/audio/audio_driver.c @@ -347,7 +347,7 @@ static bool audio_driver_init_internal(bool audio_cb_inited) if (audio_cb_inited) { RARCH_LOG("Starting threaded audio driver ...\n"); - if (!rarch_threaded_audio_init( + if (!audio_init_thread( ¤t_audio, &audio_driver_context_audio_data, *settings->audio.device ? settings->audio.device : NULL, diff --git a/audio/audio_thread_wrapper.c b/audio/audio_thread_wrapper.c index 522fbdff85..de7b5280bc 100644 --- a/audio/audio_thread_wrapper.c +++ b/audio/audio_thread_wrapper.c @@ -260,7 +260,7 @@ static const audio_driver_t audio_thread = { }; /** - * rarch_threaded_audio_init: + * audio_thread_init: * @out_driver : output driver * @out_data : output audio data * @device : audio device (optional) @@ -275,7 +275,7 @@ static const audio_driver_t audio_thread = { * * Returns: true (1) if successful, otherwise false (0). **/ -bool rarch_threaded_audio_init(const audio_driver_t **out_driver, +bool audio_init_thread(const audio_driver_t **out_driver, void **out_data, const char *device, unsigned audio_out_rate, unsigned latency, const audio_driver_t *drv) { diff --git a/audio/audio_thread_wrapper.h b/audio/audio_thread_wrapper.h index 4d7836c641..b01a52a458 100644 --- a/audio/audio_thread_wrapper.h +++ b/audio/audio_thread_wrapper.h @@ -22,7 +22,7 @@ #include "audio_driver.h" /** - * rarch_threaded_audio_init: + * audio_thread_init: * @out_driver : output driver * @out_data : output audio data * @device : audio device (optional) @@ -36,7 +36,7 @@ * * Returns: true (1) if successful, otherwise false (0). **/ -bool rarch_threaded_audio_init(const audio_driver_t **out_driver, void **out_data, +bool audio_init_thread(const audio_driver_t **out_driver, void **out_data, const char *device, unsigned out_rate, unsigned latency, const audio_driver_t *driver); diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index f1399993bd..e713505ca8 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -1731,7 +1731,7 @@ static uintptr_t d3d_load_texture(void *video_data, void *data, break; } - return rarch_threaded_video_texture_load(data, func); + return video_thread_texture_load(data, func); } video_texture_load_d3d((d3d_video_t*)video_driver_get_ptr(false), (struct texture_image*)data, filter_type, &id); diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 767a2e47b0..414a2fcdf8 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -3827,7 +3827,7 @@ static uintptr_t gl_load_texture(void *video_data, void *data, default: break; } - return rarch_threaded_video_texture_load(data, func); + return video_thread_texture_load(data, func); } #endif diff --git a/gfx/font_driver.c b/gfx/font_driver.c index b496d60530..cd39ddd3ce 100644 --- a/gfx/font_driver.c +++ b/gfx/font_driver.c @@ -313,7 +313,7 @@ bool font_driver_init_first( if (threading_hint && settings->video.threaded && !video_driver_is_hw_context()) - return rarch_threaded_video_font_init(new_font_driver, new_font_handle, + return video_thread_font_init(new_font_driver, new_font_handle, data, font_path, font_size, api, font_init_first); #endif diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 673b0266c0..5901e8304f 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -288,7 +288,7 @@ void *video_driver_get_ptr(bool force_nonthreaded_data) if (settings->video.threaded && !video_driver_is_hw_context() && !force_nonthreaded_data) - return rarch_threaded_video_get_ptr(NULL); + return video_thread_get_ptr(NULL); #endif return video_driver_data; @@ -700,7 +700,7 @@ static bool init_video(void) /* Can't do hardware rendering with threaded driver currently. */ RARCH_LOG("Starting threaded video driver ...\n"); - if (!rarch_threaded_video_init((const video_driver_t**)¤t_video, + if (!video_init_thread((const video_driver_t**)¤t_video, &video_driver_data, input_get_double_ptr(), input_driver_get_data_ptr(), current_video, &video)) diff --git a/gfx/video_thread_wrapper.c b/gfx/video_thread_wrapper.c index 7450f1b2bc..9cfa2ca0bd 100644 --- a/gfx/video_thread_wrapper.c +++ b/gfx/video_thread_wrapper.c @@ -185,7 +185,7 @@ struct thread_video }; -static void *thread_init_never_call(const video_info_t *video, +static void *video_thread_init_never_call(const video_info_t *video, const input_driver_t **input, void **input_data) { (void)video; @@ -197,7 +197,7 @@ static void *thread_init_never_call(const video_info_t *video, } /* thread -> user */ -static void thread_reply(thread_video_t *thr, const thread_packet_t *pkt) +static void video_thread_reply(thread_video_t *thr, const thread_packet_t *pkt) { slock_lock(thr->lock); @@ -211,7 +211,8 @@ static void thread_reply(thread_video_t *thr, const thread_packet_t *pkt) } /* user -> thread */ -static void thread_send_packet(thread_video_t *thr, const thread_packet_t *pkt) +static void video_thread_send_packet(thread_video_t *thr, + const thread_packet_t *pkt) { slock_lock(thr->lock); @@ -226,7 +227,7 @@ static void thread_send_packet(thread_video_t *thr, const thread_packet_t *pkt) } /* user -> thread */ -static void thread_wait_reply(thread_video_t *thr, thread_packet_t *pkt) +static void video_thread_wait_reply(thread_video_t *thr, thread_packet_t *pkt) { slock_lock(thr->lock); @@ -240,10 +241,10 @@ static void thread_wait_reply(thread_video_t *thr, thread_packet_t *pkt) } /* user -> thread */ -static void thread_send_and_wait(thread_video_t *thr, thread_packet_t *pkt) +static void video_thread_send_and_wait_user_to_thread(thread_video_t *thr, thread_packet_t *pkt) { - thread_send_packet(thr, pkt); - thread_wait_reply(thr, pkt); + video_thread_send_packet(thr, pkt); + video_thread_wait_reply(thr, pkt); } static void thread_update_driver_state(thread_video_t *thr) @@ -287,8 +288,10 @@ static void thread_update_driver_state(thread_video_t *thr) } } -/* returns true when thread_loop should quit */ -static bool thread_handle_packet(thread_video_t *thr, const thread_packet_t *incoming) +/* returns true when video_thread_loop should quit */ +static bool video_thread_handle_packet( + thread_video_t *thr, + const thread_packet_t *incoming) { #ifdef HAVE_OVERLAY unsigned i; @@ -303,7 +306,7 @@ static bool thread_handle_packet(thread_video_t *thr, const thread_packet_t *inc thr->input, thr->input_data); pkt.data.b = thr->driver_data; thr->driver->viewport_info(thr->driver_data, &thr->vp); - thread_reply(thr, &pkt); + video_thread_reply(thr, &pkt); break; case CMD_FREE: @@ -313,13 +316,13 @@ static bool thread_handle_packet(thread_video_t *thr, const thread_packet_t *inc thr->driver->free(thr->driver_data); } thr->driver_data = NULL; - thread_reply(thr, &pkt); + video_thread_reply(thr, &pkt); return true; case CMD_SET_ROTATION: if (thr->driver && thr->driver->set_rotation) thr->driver->set_rotation(thr->driver_data, pkt.data.i); - thread_reply(thr, &pkt); + video_thread_reply(thr, &pkt); break; case CMD_READ_VIEWPORT: @@ -357,7 +360,7 @@ static bool thread_handle_packet(thread_video_t *thr, const thread_packet_t *inc * thread read the async value. Cannot read safely. */ pkt.data.b = false; } - thread_reply(thr, &pkt); + video_thread_reply(thr, &pkt); break; } @@ -368,7 +371,7 @@ static bool thread_handle_packet(thread_video_t *thr, const thread_packet_t *inc pkt.data.set_shader.path); pkt.data.b = ret; - thread_reply(thr, &pkt); + video_thread_reply(thr, &pkt); break; case CMD_ALIVE: @@ -376,14 +379,14 @@ static bool thread_handle_packet(thread_video_t *thr, const thread_packet_t *inc ret = thr->driver->alive(thr->driver_data); pkt.data.b = ret; - thread_reply(thr, &pkt); + video_thread_reply(thr, &pkt); break; #ifdef HAVE_OVERLAY case CMD_OVERLAY_ENABLE: if (thr->overlay && thr->overlay->enable) thr->overlay->enable(thr->driver_data, pkt.data.b); - thread_reply(thr, &pkt); + video_thread_reply(thr, &pkt); break; case CMD_OVERLAY_LOAD: @@ -404,7 +407,7 @@ static bool thread_handle_packet(thread_video_t *thr, const thread_packet_t *inc thr->alpha_mod[i] = 1.0f; } - thread_reply(thr, &pkt); + video_thread_reply(thr, &pkt); break; case CMD_OVERLAY_TEX_GEOM: @@ -415,7 +418,7 @@ static bool thread_handle_packet(thread_video_t *thr, const thread_packet_t *inc pkt.data.rect.y, pkt.data.rect.w, pkt.data.rect.h); - thread_reply(thr, &pkt); + video_thread_reply(thr, &pkt); break; case CMD_OVERLAY_VERTEX_GEOM: @@ -426,14 +429,14 @@ static bool thread_handle_packet(thread_video_t *thr, const thread_packet_t *inc pkt.data.rect.y, pkt.data.rect.w, pkt.data.rect.h); - thread_reply(thr, &pkt); + video_thread_reply(thr, &pkt); break; case CMD_OVERLAY_FULL_SCREEN: if (thr->overlay && thr->overlay->full_screen) thr->overlay->full_screen(thr->driver_data, pkt.data.b); - thread_reply(thr, &pkt); + video_thread_reply(thr, &pkt); break; #endif @@ -443,14 +446,14 @@ static bool thread_handle_packet(thread_video_t *thr, const thread_packet_t *inc pkt.data.new_mode.width, pkt.data.new_mode.height, pkt.data.new_mode.fullscreen); - thread_reply(thr, &pkt); + video_thread_reply(thr, &pkt); break; case CMD_POKE_SET_FILTERING: if (thr->poke && thr->poke->set_filtering) thr->poke->set_filtering(thr->driver_data, pkt.data.filtering.index, pkt.data.filtering.smooth); - thread_reply(thr, &pkt); + video_thread_reply(thr, &pkt); break; case CMD_POKE_GET_VIDEO_OUTPUT_SIZE: @@ -458,25 +461,25 @@ static bool thread_handle_packet(thread_video_t *thr, const thread_packet_t *inc thr->poke->get_video_output_size(thr->driver_data, &pkt.data.output.width, &pkt.data.output.height); - thread_reply(thr, &pkt); + video_thread_reply(thr, &pkt); break; case CMD_POKE_GET_VIDEO_OUTPUT_PREV: if (thr->poke && thr->poke->get_video_output_prev) thr->poke->get_video_output_prev(thr->driver_data); - thread_reply(thr, &pkt); + video_thread_reply(thr, &pkt); break; case CMD_POKE_GET_VIDEO_OUTPUT_NEXT: if (thr->poke && thr->poke->get_video_output_next) thr->poke->get_video_output_next(thr->driver_data); - thread_reply(thr, &pkt); + video_thread_reply(thr, &pkt); break; case CMD_POKE_SET_ASPECT_RATIO: thr->poke->set_aspect_ratio(thr->driver_data, pkt.data.i); - thread_reply(thr, &pkt); + video_thread_reply(thr, &pkt); break; case CMD_POKE_SET_OSD_MSG: @@ -484,7 +487,7 @@ static bool thread_handle_packet(thread_video_t *thr, const thread_packet_t *inc thr->poke->set_osd_msg(thr->driver_data, pkt.data.osd_message.msg, &pkt.data.osd_message.params, NULL); - thread_reply(thr, &pkt); + video_thread_reply(thr, &pkt); break; case CMD_FONT_INIT: @@ -497,7 +500,7 @@ static bool thread_handle_packet(thread_video_t *thr, const thread_packet_t *inc pkt.data.font_init.font_path, pkt.data.font_init.font_size, pkt.data.font_init.api); - thread_reply(thr, &pkt); + video_thread_reply(thr, &pkt); break; case CMD_CUSTOM_COMMAND: @@ -505,7 +508,7 @@ static bool thread_handle_packet(thread_video_t *thr, const thread_packet_t *inc pkt.data.custom_command.return_value = pkt.data.custom_command.method (pkt.data.custom_command.data); - thread_reply(thr, &pkt); + video_thread_reply(thr, &pkt); break; case CMD_NONE: @@ -513,14 +516,14 @@ static bool thread_handle_packet(thread_video_t *thr, const thread_packet_t *inc * thread sends command right after frame update. */ break; default: - thread_reply(thr, &pkt); + video_thread_reply(thr, &pkt); break; } return false; } -static void thread_loop(void *data) +static void video_thread_loop(void *data) { thread_video_t *thr = (thread_video_t*)data; @@ -541,7 +544,7 @@ static void thread_loop(void *data) slock_unlock(thr->lock); - if (thread_handle_packet(thr, &pkt)) + if (video_thread_handle_packet(thr, &pkt)) return; if (updated) @@ -588,7 +591,7 @@ static void thread_loop(void *data) } } -static bool thread_alive(void *data) +static bool video_thread_alive(void *data) { bool ret; thread_video_t *thr = (thread_video_t*)data; @@ -596,7 +599,8 @@ static bool thread_alive(void *data) if (runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL)) { thread_packet_t pkt = { CMD_ALIVE }; - thread_send_and_wait(thr, &pkt); + + video_thread_send_and_wait_user_to_thread(thr, &pkt); return pkt.data.b; } @@ -607,7 +611,7 @@ static bool thread_alive(void *data) return ret; } -static bool thread_focus(void *data) +static bool video_thread_focus(void *data) { bool ret; thread_video_t *thr = (thread_video_t*)data; @@ -619,7 +623,7 @@ static bool thread_focus(void *data) return ret; } -static bool thread_suppress_screensaver(void *data, bool enable) +static bool video_thread_suppress_screensaver(void *data, bool enable) { bool ret; thread_video_t *thr = (thread_video_t*)data; @@ -631,7 +635,7 @@ static bool thread_suppress_screensaver(void *data, bool enable) return ret; } -static bool thread_has_windowed(void *data) +static bool video_thread_has_windowed(void *data) { bool ret; thread_video_t *thr = (thread_video_t*)data; @@ -643,7 +647,7 @@ static bool thread_has_windowed(void *data) return ret; } -static bool thread_frame(void *data, const void *frame_, +static bool video_thread_frame(void *data, const void *frame_, unsigned width, unsigned height, uint64_t frame_count, unsigned pitch, const char *msg) { @@ -742,14 +746,14 @@ static bool thread_frame(void *data, const void *frame_, return true; } -static void thread_set_nonblock_state(void *data, bool state) +static void video_thread_set_nonblock_state(void *data, bool state) { thread_video_t *thr = (thread_video_t*)data; if (thr) thr->nonblock = state; } -static bool thread_init(thread_video_t *thr, const video_info_t *info, +static bool video_thread_init(thread_video_t *thr, const video_info_t *info, const input_driver_t **input, void **input_data) { size_t max_size; @@ -779,18 +783,18 @@ static bool thread_init(thread_video_t *thr, const video_info_t *info, memset(thr->frame.buffer, 0x80, max_size); thr->last_time = retro_get_time_usec(); - thr->thread = sthread_create(thread_loop, thr); + thr->thread = sthread_create(video_thread_loop, thr); if (!thr->thread) return false; - thread_send_and_wait(thr, &pkt); + video_thread_send_and_wait_user_to_thread(thr, &pkt); - thr->send_and_wait = thread_send_and_wait; + thr->send_and_wait = video_thread_send_and_wait_user_to_thread; return pkt.data.b; } -static bool thread_set_shader(void *data, +static bool video_thread_set_shader(void *data, enum rarch_shader_type type, const char *path) { thread_video_t *thr = (thread_video_t*)data; @@ -800,12 +804,13 @@ static bool thread_set_shader(void *data, pkt.data.set_shader.type = type; pkt.data.set_shader.path = path; - thread_send_and_wait(thr, &pkt); + + video_thread_send_and_wait_user_to_thread(thr, &pkt); return pkt.data.b; } -static void thread_set_viewport(void *data, unsigned width, +static void video_thread_set_viewport(void *data, unsigned width, unsigned height, bool force_full, bool allow_rotate) { thread_video_t *thr = (thread_video_t*)data; @@ -821,7 +826,7 @@ static void thread_set_viewport(void *data, unsigned width, slock_unlock(thr->lock); } -static void thread_set_rotation(void *data, unsigned rotation) +static void video_thread_set_rotation(void *data, unsigned rotation) { thread_video_t *thr = (thread_video_t*)data; thread_packet_t pkt = { CMD_SET_ROTATION }; @@ -830,7 +835,8 @@ static void thread_set_rotation(void *data, unsigned rotation) return; pkt.data.i = rotation; - thread_send_and_wait(thr, &pkt); + + video_thread_send_and_wait_user_to_thread(thr, &pkt); } /* This value is set async as stalling on the video driver for @@ -838,7 +844,7 @@ static void thread_set_rotation(void *data, unsigned rotation) * * This means this value might not be correct, so viewport * reads are not supported for now. */ -static void thread_viewport_info(void *data, struct video_viewport *vp) +static void video_thread_viewport_info(void *data, struct video_viewport *vp) { thread_video_t *thr = (thread_video_t*)data; @@ -853,7 +859,7 @@ static void thread_viewport_info(void *data, struct video_viewport *vp) slock_unlock(thr->lock); } -static bool thread_read_viewport(void *data, uint8_t *buffer) +static bool video_thread_read_viewport(void *data, uint8_t *buffer) { thread_video_t *thr = (thread_video_t*)data; thread_packet_t pkt = { CMD_READ_VIEWPORT }; @@ -862,12 +868,13 @@ static bool thread_read_viewport(void *data, uint8_t *buffer) return false; pkt.data.v = buffer; - thread_send_and_wait(thr, &pkt); + + video_thread_send_and_wait_user_to_thread(thr, &pkt); return pkt.data.b; } -static void thread_free(void *data) +static void video_thread_free(void *data) { thread_video_t *thr = (thread_video_t*)data; thread_packet_t pkt = { CMD_FREE }; @@ -875,7 +882,7 @@ static void thread_free(void *data) if (!thr) return; - thread_send_and_wait(thr, &pkt); + video_thread_send_and_wait_user_to_thread(thr, &pkt); sthread_join(thr->thread); @@ -907,7 +914,8 @@ static void thread_overlay_enable(void *data, bool state) return; pkt.data.b = state; - thread_send_and_wait(thr, &pkt); + + video_thread_send_and_wait_user_to_thread(thr, &pkt); } static bool thread_overlay_load(void *data, @@ -922,8 +930,9 @@ static bool thread_overlay_load(void *data, return false; pkt.data.image.data = images; - pkt.data.image.num = num_images; - thread_send_and_wait(thr, &pkt); + pkt.data.image.num = num_images; + + video_thread_send_and_wait_user_to_thread(thr, &pkt); return pkt.data.b; } @@ -942,7 +951,7 @@ static void thread_overlay_tex_geom(void *data, pkt.data.rect.w = w; pkt.data.rect.h = h; - thread_send_and_wait(thr, &pkt); + video_thread_send_and_wait_user_to_thread(thr, &pkt); } static void thread_overlay_vertex_geom(void *data, @@ -960,7 +969,7 @@ static void thread_overlay_vertex_geom(void *data, pkt.data.rect.w = w; pkt.data.rect.h = h; - thread_send_and_wait(thr, &pkt); + video_thread_send_and_wait_user_to_thread(thr, &pkt); } static void thread_overlay_full_screen(void *data, bool enable) @@ -969,7 +978,8 @@ static void thread_overlay_full_screen(void *data, bool enable) thread_packet_t pkt = { CMD_OVERLAY_FULL_SCREEN }; pkt.data.b = enable; - thread_send_and_wait(thr, &pkt); + + video_thread_send_and_wait_user_to_thread(thr, &pkt); } /* We cannot wait for this to complete. Totally blocks the main thread. */ @@ -995,7 +1005,7 @@ static const video_overlay_interface_t thread_overlay = { thread_overlay_set_alpha, }; -static void thread_get_overlay_interface(void *data, +static void video_thread_get_overlay_interface(void *data, const video_overlay_interface_t **iface) { thread_video_t *thr = (thread_video_t*)data; @@ -1018,7 +1028,8 @@ static void thread_set_video_mode(void *data, unsigned width, unsigned height, pkt.data.new_mode.width = width; pkt.data.new_mode.height = height; pkt.data.new_mode.fullscreen = fullscreen; - thread_send_and_wait(thr, &pkt); + + video_thread_send_and_wait_user_to_thread(thr, &pkt); } static void thread_set_filtering(void *data, unsigned idx, bool smooth) @@ -1030,7 +1041,8 @@ static void thread_set_filtering(void *data, unsigned idx, bool smooth) return; pkt.data.filtering.index = idx; pkt.data.filtering.smooth = smooth; - thread_send_and_wait(thr, &pkt); + + video_thread_send_and_wait_user_to_thread(thr, &pkt); } static void thread_get_video_output_size(void *data, @@ -1042,7 +1054,7 @@ static void thread_get_video_output_size(void *data, if (!thr) return; - thread_send_and_wait(thr, &pkt); + video_thread_send_and_wait_user_to_thread(thr, &pkt); *width = pkt.data.output.width; *height = pkt.data.output.height; @@ -1055,7 +1067,8 @@ static void thread_get_video_output_prev(void *data) if (!thr) return; - thread_send_and_wait(thr, &pkt); + + video_thread_send_and_wait_user_to_thread(thr, &pkt); } static void thread_get_video_output_next(void *data) @@ -1065,7 +1078,8 @@ static void thread_get_video_output_next(void *data) if (!thr) return; - thread_send_and_wait(thr, &pkt); + + video_thread_send_and_wait_user_to_thread(thr, &pkt); } static void thread_set_aspect_ratio(void *data, unsigned aspectratio_idx) @@ -1076,7 +1090,8 @@ static void thread_set_aspect_ratio(void *data, unsigned aspectratio_idx) if (!thr) return; pkt.data.i = aspectratio_idx; - thread_send_and_wait(thr, &pkt); + + video_thread_send_and_wait_user_to_thread(thr, &pkt); } #if defined(HAVE_MENU) @@ -1206,7 +1221,8 @@ static const video_poke_interface_t thread_poke = { thread_get_current_shader, }; -static void thread_get_poke_interface(void *data, +static void video_thread_get_poke_interface( + void *data, const video_poke_interface_t **iface) { thread_video_t *thr = (thread_video_t*)data; @@ -1221,28 +1237,29 @@ static void thread_get_poke_interface(void *data, } static const video_driver_t video_thread = { - thread_init_never_call, /* Should never be called directly. */ - thread_frame, - thread_set_nonblock_state, - thread_alive, - thread_focus, - thread_suppress_screensaver, - thread_has_windowed, - thread_set_shader, - thread_free, + video_thread_init_never_call, /* Should never be called directly. */ + video_thread_frame, + video_thread_set_nonblock_state, + video_thread_alive, + video_thread_focus, + video_thread_suppress_screensaver, + video_thread_has_windowed, + video_thread_set_shader, + video_thread_free, "Thread wrapper", - thread_set_viewport, - thread_set_rotation, - thread_viewport_info, - thread_read_viewport, + video_thread_set_viewport, + video_thread_set_rotation, + video_thread_viewport_info, + video_thread_read_viewport, NULL, /* read_frame_raw */ #ifdef HAVE_OVERLAY - thread_get_overlay_interface, /* get_overlay_interface */ + video_thread_get_overlay_interface, /* get_overlay_interface */ #endif - thread_get_poke_interface, + video_thread_get_poke_interface, }; -static void thread_set_callbacks(thread_video_t *thr, +static void video_thread_set_callbacks( + thread_video_t *thr, const video_driver_t *drv) { thr->video_thread = video_thread; @@ -1267,7 +1284,7 @@ static void thread_set_callbacks(thread_video_t *thr, } /** - * rarch_threaded_video_init: + * video_init_thread: * @out_driver : Output video driver * @out_data : Output video data * @input : Input input driver @@ -1280,7 +1297,7 @@ static void thread_set_callbacks(thread_video_t *thr, * * Returns: true (1) if successful, otherwise false (0). **/ -bool rarch_threaded_video_init(const video_driver_t **out_driver, +bool video_init_thread(const video_driver_t **out_driver, void **out_data, const input_driver_t **input, void **input_data, const video_driver_t *drv, const video_info_t *info) { @@ -1288,16 +1305,16 @@ bool rarch_threaded_video_init(const video_driver_t **out_driver, if (!thr) return false; - thread_set_callbacks(thr, drv); + video_thread_set_callbacks(thr, drv); thr->driver = drv; *out_driver = &thr->video_thread; *out_data = thr; - return thread_init(thr, info, input, input_data); + return video_thread_init(thr, info, input, input_data); } /** - * rarch_threaded_video_get_ptr: + * video_thread_get_ptr: * @drv : Found driver. * * Gets the underlying video driver associated with the @@ -1308,9 +1325,10 @@ bool rarch_threaded_video_init(const video_driver_t **out_driver, * with the threaded wrapper (if successful). If not successful, * NULL. **/ -void *rarch_threaded_video_get_ptr(const video_driver_t **drv) +void *video_thread_get_ptr(const video_driver_t **drv) { - const thread_video_t *thr = (const thread_video_t*)video_driver_get_ptr(true); + const thread_video_t *thr = (const thread_video_t*) + video_driver_get_ptr(true); if (drv) *drv = thr->driver; @@ -1320,23 +1338,25 @@ void *rarch_threaded_video_get_ptr(const video_driver_t **drv) return thr->driver_data; } -const char *rarch_threaded_video_get_ident(void) +const char *video_thread_get_ident(void) { - const thread_video_t *thr = (const thread_video_t*)video_driver_get_ptr(true); + const thread_video_t *thr = (const thread_video_t*) + video_driver_get_ptr(true); if (!thr || !thr->driver) return NULL; return thr->driver->ident; } -static void rarch_threaded_video_send_and_wait(thread_video_t *thr, thread_packet_t *pkt) +static void video_thread_send_and_wait(thread_video_t *thr, + thread_packet_t *pkt) { if (!thr || !pkt) return; thr->send_and_wait(thr, pkt); } -bool rarch_threaded_video_font_init(const void **font_driver, void **font_handle, +bool video_thread_font_init(const void **font_driver, void **font_handle, void *data, const char *font_path, float font_size, enum font_driver_render_api api, custom_font_command_method_t func) { @@ -1355,12 +1375,12 @@ bool rarch_threaded_video_font_init(const void **font_driver, void **font_handle pkt.data.font_init.font_size = font_size; pkt.data.font_init.api = api; - rarch_threaded_video_send_and_wait(thr, &pkt); + video_thread_send_and_wait(thr, &pkt); return pkt.data.font_init.return_value; } -unsigned rarch_threaded_video_texture_load(void *data, +unsigned video_thread_texture_load(void *data, custom_command_method_t func) { thread_video_t *thr = (thread_video_t*)video_driver_get_ptr(true); @@ -1372,7 +1392,7 @@ unsigned rarch_threaded_video_texture_load(void *data, pkt.data.custom_command.method = func; pkt.data.custom_command.data = (void*)data; - rarch_threaded_video_send_and_wait(thr, &pkt); + video_thread_send_and_wait(thr, &pkt); return pkt.data.custom_command.return_value; } diff --git a/gfx/video_thread_wrapper.h b/gfx/video_thread_wrapper.h index b31996cf1b..7bfbfc71ec 100644 --- a/gfx/video_thread_wrapper.h +++ b/gfx/video_thread_wrapper.h @@ -74,7 +74,7 @@ typedef struct thread_packet thread_packet_t; typedef struct thread_video thread_video_t; /** - * rarch_threaded_video_init: + * video_init_thread: * @out_driver : Output video driver * @out_data : Output video data * @input : Input input driver @@ -87,13 +87,13 @@ typedef struct thread_video thread_video_t; * * Returns: true (1) if successful, otherwise false (0). **/ -bool rarch_threaded_video_init( +bool video_init_thread( const video_driver_t **out_driver, void **out_data, const input_driver_t **input, void **input_data, const video_driver_t *driver, const video_info_t *info); /** - * rarch_threaded_video_get_ptr: + * video_thread_get_ptr: * @drv : Found driver. * * Gets the underlying video driver associated with the @@ -104,16 +104,20 @@ bool rarch_threaded_video_init( * with the threaded wrapper (if successful). If not successful, * NULL. **/ -void *rarch_threaded_video_get_ptr(const video_driver_t **drv); +void *video_thread_get_ptr(const video_driver_t **drv); -const char *rarch_threaded_video_get_ident(void); +const char *video_thread_get_ident(void); -bool rarch_threaded_video_font_init(const void **font_driver, +bool video_thread_font_init( + const void **font_driver, void **font_handle, - void *data, const char *font_path, float font_size, - enum font_driver_render_api api, custom_font_command_method_t func); + void *data, + const char *font_path, + float font_size, + enum font_driver_render_api api, + custom_font_command_method_t func); -unsigned rarch_threaded_video_texture_load(void *data, +unsigned video_thread_texture_load(void *data, custom_command_method_t func); #ifdef __cplusplus diff --git a/menu/menu_display.c b/menu/menu_display.c index c5937770d4..0a863183be 100644 --- a/menu/menu_display.c +++ b/menu/menu_display.c @@ -60,7 +60,7 @@ static const char *menu_video_get_ident(void) settings_t *settings = config_get_ptr(); if (settings->video.threaded) - return rarch_threaded_video_get_ident(); + return video_thread_get_ident(); #endif return video_driver_get_ident(); From f2631809bbbed275538903e8c6a5e895b9373c1f Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Tue, 10 May 2016 03:15:55 +0200 Subject: [PATCH 358/498] Cleanup --- cheevos.c | 1 - 1 file changed, 1 deletion(-) diff --git a/cheevos.c b/cheevos.c index b111776f62..d3225bfbed 100644 --- a/cheevos.c +++ b/cheevos.c @@ -986,7 +986,6 @@ static const uint8_t *cheevos_get_memory(unsigned offset) { retro_ctx_memory_info_t mem_info; uint8_t *memory = NULL; - unsigned i; mem_info.id = RETRO_MEMORY_SYSTEM_RAM; From 71c5b4972cd74c16b27b125a595b0940dafa4ee8 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 May 2016 03:19:40 +0200 Subject: [PATCH 359/498] CXX_BUILD buildfix --- menu/menu_content.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/menu/menu_content.c b/menu/menu_content.c index 759da171de..d0f43f82b9 100644 --- a/menu/menu_content.c +++ b/menu/menu_content.c @@ -259,7 +259,7 @@ static bool menu_content_find_first_core(void *data) * going to use the current core to load this. */ if (menu_label_hash == MENU_LABEL_LOAD_CONTENT) { - core_info_get_current_core((void*)&info); + core_info_get_current_core((core_info_t**)&info); if (info) { RARCH_LOG("Use the current core (%s) to load this content...\n", From bca9c687a1c4698ef17b326901ebeea352909ba3 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 May 2016 03:23:15 +0200 Subject: [PATCH 360/498] (RJPEG) Remove register storage class --- libretro-common/formats/jpeg/rjpeg.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/libretro-common/formats/jpeg/rjpeg.c b/libretro-common/formats/jpeg/rjpeg.c index d17673bf5d..81ca237750 100644 --- a/libretro-common/formats/jpeg/rjpeg.c +++ b/libretro-common/formats/jpeg/rjpeg.c @@ -204,7 +204,7 @@ static void rjpeg_decode_dht(struct rjpeg_data *ctx) for (i = 0; i < currcnt; ++i) { int j; - register unsigned char code = ctx->pos[i]; + unsigned char code = ctx->pos[i]; for (j = spread; j; --j) { @@ -730,12 +730,12 @@ static void rjpeg_convert(struct rjpeg_data *ctx) { for (x = 0; x < ctx->width; ++x) { - register int y = py[x] << 8; - register int cb = pcb[x] - 128; - register int cr = pcr[x] - 128; - *prgb++ = rjpeg_clip((y + 359 * cr + 128) >> 8); - *prgb++ = rjpeg_clip((y - 88 * cb - 183 * cr + 128) >> 8); - *prgb++ = rjpeg_clip((y + 454 * cb + 128) >> 8); + int y = py[x] << 8; + int cb = pcb[x] - 128; + int cr = pcr[x] - 128; + *prgb++ = rjpeg_clip((y + 359 * cr + 128) >> 8); + *prgb++ = rjpeg_clip((y - 88 * cb - 183 * cr + 128) >> 8); + *prgb++ = rjpeg_clip((y + 454 * cb + 128) >> 8); } py += ctx->comp[0].stride; pcb += ctx->comp[1].stride; @@ -876,12 +876,12 @@ bool rjpeg_image_load(uint8_t *buf, void *data, size_t size, { for (x = 0; x < rjpg->width; ++x) { - register int y = py[x] << 8; - register int cb = pcb[x] - 128; - register int cr = pcr[x] - 128; - *prgb++ = rjpeg_clip((y + 359 * cr + 128) >> 8); - *prgb++ = rjpeg_clip((y - 88 * cb - 183 * cr + 128) >> 8); - *prgb++ = rjpeg_clip((y + 454 * cb + 128) >> 8); + int y = py[x] << 8; + int cb = pcb[x] - 128; + int cr = pcr[x] - 128; + *prgb++ = rjpeg_clip((y + 359 * cr + 128) >> 8); + *prgb++ = rjpeg_clip((y - 88 * cb - 183 * cr + 128) >> 8); + *prgb++ = rjpeg_clip((y + 454 * cb + 128) >> 8); } py += rjpg->comp[0].stride; pcb += rjpg->comp[1].stride; From 91d2af7e3686a44aea04e9e59688ca57f76dffd6 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 May 2016 03:41:49 +0200 Subject: [PATCH 361/498] Update comments --- audio/audio_thread_wrapper.c | 2 +- audio/audio_thread_wrapper.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/audio/audio_thread_wrapper.c b/audio/audio_thread_wrapper.c index de7b5280bc..46a85f4c36 100644 --- a/audio/audio_thread_wrapper.c +++ b/audio/audio_thread_wrapper.c @@ -260,7 +260,7 @@ static const audio_driver_t audio_thread = { }; /** - * audio_thread_init: + * audio_init_thread: * @out_driver : output driver * @out_data : output audio data * @device : audio device (optional) diff --git a/audio/audio_thread_wrapper.h b/audio/audio_thread_wrapper.h index b01a52a458..1e7d43b1ad 100644 --- a/audio/audio_thread_wrapper.h +++ b/audio/audio_thread_wrapper.h @@ -22,7 +22,7 @@ #include "audio_driver.h" /** - * audio_thread_init: + * audio_init_thread: * @out_driver : output driver * @out_data : output audio data * @device : audio device (optional) From b9c9df3a8bc8f6d2bd42fada7d4f1ad5b08f57be Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 May 2016 03:48:05 +0200 Subject: [PATCH 362/498] (GLSM) Buildfix --- libretro-common/glsm/glsm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libretro-common/glsm/glsm.c b/libretro-common/glsm/glsm.c index c8bc9d74b0..dfbb6ef72c 100644 --- a/libretro-common/glsm/glsm.c +++ b/libretro-common/glsm/glsm.c @@ -892,7 +892,7 @@ void rglBindBufferBase( GLenum target, GLuint index, GLuint buffer) { -#if defined(HAVE_OPENG) || defined(HAVE_OPENGLES) && defined(HAVE_OPENGLES3) +#if defined(HAVE_OPENGL) || defined(HAVE_OPENGLES) && defined(HAVE_OPENGLES3) glBindBufferBase(target, index, buffer); #else printf("WARNING! Not implemented.\n"); From 3db9623809a25d73cc5983f27cea2dd879ac4dc4 Mon Sep 17 00:00:00 2001 From: Sebastien Ronsse Date: Tue, 10 May 2016 11:37:54 +1000 Subject: [PATCH 363/498] rbmp encode: Fix saving mechanism resulting in vertically flipped screenshots. --- libretro-common/formats/bmp/rbmp_encode.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/libretro-common/formats/bmp/rbmp_encode.c b/libretro-common/formats/bmp/rbmp_encode.c index 0ce5e47a3f..f4c186054e 100644 --- a/libretro-common/formats/bmp/rbmp_encode.c +++ b/libretro-common/formats/bmp/rbmp_encode.c @@ -151,7 +151,7 @@ static void dump_content(RFILE *file, const void *frame, const uint32_t *u32; } u; - u.u8 = (const uint8_t*)frame + (height-1) * pitch; + u.u8 = (const uint8_t*)frame; line_size = (width * bytes_per_pixel + 3) & ~3; if (type == RBMP_SOURCE_TYPE_BGR24) @@ -159,7 +159,7 @@ static void dump_content(RFILE *file, const void *frame, /* BGR24 byte order input matches output. Can directly copy, but... need to make sure we pad it. */ uint32_t zeros = 0; int pad = line_size-pitch; - for (j = height-1; j >= 0; j--, u.u8 -= pitch) + for (j = 0; j < height; j++, u.u8 += pitch) { filestream_write(file, u.u8, pitch); if(pad != 0) @@ -170,7 +170,7 @@ static void dump_content(RFILE *file, const void *frame, else if(type == RBMP_SOURCE_TYPE_ARGB8888) { /* ARGB8888 byte order input matches output. Can directly copy. */ - for (j = height-1; j >= 0; j--, u.u8 -= pitch) + for (j = 0; j < height; j++, u.u8 += pitch) filestream_write(file, u.u8, line_size); return; } @@ -182,7 +182,7 @@ static void dump_content(RFILE *file, const void *frame, if (type == RBMP_SOURCE_TYPE_XRGB888) { - for (j = height-1; j >= 0; j--, u.u8 -= pitch) + for (j = 0; j < height; j++, u.u8 += pitch) { dump_line_32_to_24(line, u.u32, width); filestream_write(file, line, line_size); @@ -190,7 +190,7 @@ static void dump_content(RFILE *file, const void *frame, } else /* type == RBMP_SOURCE_TYPE_RGB565 */ { - for (j = height-1; j >= 0; j--, u.u8 -= pitch) + for (j = 0; j < height; j++, u.u8 += pitch) { dump_line_565_to_24(line, u.u16, width); filestream_write(file, line, line_size); From bab8935b58905b38af02b4b6011991c4c4b33e38 Mon Sep 17 00:00:00 2001 From: Sebastien Ronsse Date: Tue, 10 May 2016 13:09:05 +1000 Subject: [PATCH 364/498] rbmp encode: Fix memory leak when saving image --- libretro-common/formats/bmp/rbmp_encode.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/libretro-common/formats/bmp/rbmp_encode.c b/libretro-common/formats/bmp/rbmp_encode.c index f4c186054e..8f92c42073 100644 --- a/libretro-common/formats/bmp/rbmp_encode.c +++ b/libretro-common/formats/bmp/rbmp_encode.c @@ -197,6 +197,8 @@ static void dump_content(RFILE *file, const void *frame, } } + /* Free allocated line buffer */ + free(line); } bool rbmp_save_image(const char *filename, const void *frame, From 7462988f33efd664da33355ea98f108e93e682bc Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 May 2016 05:50:24 +0200 Subject: [PATCH 365/498] Use stb_image jpeg code --- libretro-common/formats/jpeg/rjpeg.c | 3077 +++++++++++++++++++------- 1 file changed, 2282 insertions(+), 795 deletions(-) diff --git a/libretro-common/formats/jpeg/rjpeg.c b/libretro-common/formats/jpeg/rjpeg.c index 81ca237750..44be7d75ad 100644 --- a/libretro-common/formats/jpeg/rjpeg.c +++ b/libretro-common/formats/jpeg/rjpeg.c @@ -1,906 +1,2393 @@ -#include #include +#include +#include /* ptrdiff_t on osx */ #include #include -#include +#include #include +#include #include -#define RJPEG_DECODE_SOF 0xC0 -#define RJPEG_DECODE_DHT 0xC4 -#define RJPEG_DECODE_DQT 0xDB -#define RJPEG_DECODE_DRI 0xDD -#define RJPEG_DECODE_SCAN 0xDA -#define RJPEG_DECODE_SKIP_MARKER 0xFE - -#define CF(x) rjpeg_clip(((x) + 64) >> 7) -#define JPEG_DECODER_THROW(ctx, e) do { ctx->error = e; return; } while (0) - -enum rjpeg_decode_result -{ - RJPEG_OK = 0, - RJPEG_NOT_A_FILE, - RJPEG_UNSUPPORTED, - RJPEG_OOM, - RJPEG_INTERNAL_ERROR, - RJPEG_SYNTAX_ERROR, - RJPEG_INTERNAL_FINISHED -}; - enum { - CF4A = (-9), - CF4B = (111), - CF4C = (29), - CF4D = (-3), - CF3A = (28), - CF3B = (109), - CF3C = (-9), - CF3X = (104), - CF3Y = (27), - CF3Z = (-3), - CF2A = (139), - CF2B = (-11) + STBI_default = 0, /* only used for req_comp */ + STBI_grey = 1, + STBI_grey_alpha = 2, + STBI_rgb = 3, + STBI_rgb_alpha = 4 }; -enum +typedef struct { - W1 = 2841, - W2 = 2676, - W3 = 2408, - W5 = 1609, - W6 = 1108, - W7 = 565 -}; + int (*read) (void *user,char *data,int size); /* fill 'data' with 'size' bytes. return number of bytes actually read */ + void (*skip) (void *user,int n); /* skip the next 'n' bytes, or 'unget' the last -n bytes if negative */ + int (*eof) (void *user); /* returns nonzero if we are at end of file/data */ +} stbi_io_callbacks; -struct rjpeg_vlc_code -{ - uint8_t bits; - uint8_t code; -}; +/* should produce compiler error if size is wrong */ +typedef unsigned char validate_uint32[sizeof(uint32_t)==4 ? 1 : -1]; -struct rjpeg_component -{ - int cid; - int ssx, ssy; - int width, height; - int stride; - int qtsel; - int actabsel; - int dctabsel; - int dcpred; - uint8_t *pixels; -}; +#ifdef _MSC_VER +#define STBI_NOTUSED(v) (void)(v) +#else +#define STBI_NOTUSED(v) (void)sizeof(v) +#endif -struct rjpeg_data -{ - enum rjpeg_decode_result error; - const uint8_t *pos; - int size; - int length; - int width, height; - int mbwidth; - int mbheight; - int mbsizex; - int mbsizey; - int ncomp; - struct rjpeg_component comp[3]; - int qtused; - int qtavail; - uint8_t qtab[4][64]; - struct rjpeg_vlc_code vlctab[4][65536]; - int buf, bufbits; - int block[64]; - int rstinterval; - uint8_t *rgb; - char ZZ[64]; -}; +#ifdef _MSC_VER +#define STBI_HAS_LROTL +#endif -static INLINE uint8_t rjpeg_clip(const int x) +#ifdef STBI_HAS_LROTL + #define stbi_lrot(x,y) _lrotl(x,y) +#else + #define stbi_lrot(x,y) (((x) << (y)) | ((x) >> (32 - (y)))) +#endif + +// x86/x64 detection +#if defined(__x86_64__) || defined(_M_X64) +#define STBI__X64_TARGET +#elif defined(__i386) || defined(_M_IX86) +#define STBI__X86_TARGET +#endif + +#if defined(__GNUC__) && (defined(STBI__X86_TARGET) || defined(STBI__X64_TARGET)) && !defined(__SSE2__) && !defined(STBI_NO_SIMD) +/* NOTE: not clear do we actually need this for the 64-bit path? + * gcc doesn't support sse2 intrinsics unless you compile with -msse2, + * (but compiling with -msse2 allows the compiler to use SSE2 everywhere; + * this is just broken and gcc are jerks for not fixing it properly + * http://www.virtualdub.org/blog/pivot/entry.php?id=363 ) + */ +#define STBI_NO_SIMD +#endif + +#if defined(__MINGW32__) && defined(STBI__X86_TARGET) && !defined(STBI_MINGW_ENABLE_SSE2) && !defined(STBI_NO_SIMD) +/* Note that __MINGW32__ doesn't actually mean 32-bit, so we have to avoid STBI__X64_TARGET + * + * 32-bit MinGW wants ESP to be 16-byte aligned, but this is not in the + * Windows ABI and VC++ as well as Windows DLLs don't maintain that invariant. + * As a result, enabling SSE2 on 32-bit MinGW is dangerous when not + * simultaneously enabling "-mstackrealign". + * + * See https://github.com/nothings/stb/issues/81 for more information. + * + * So default to no SSE2 on 32-bit MinGW. If you've read this far and added + * -mstackrealign to your build settings, feel free to #define STBI_MINGW_ENABLE_SSE2. + */ +#define STBI_NO_SIMD +#endif + +#if !defined(STBI_NO_SIMD) && defined(STBI__X86_TARGET) +#define STBI_SSE2 +#include + +#ifdef _MSC_VER + +#if _MSC_VER >= 1400 /* not VC6 */ +#include /* __cpuid */ +static int stbi__cpuid3(void) { - if (x < 0) - return 0; - return ((x > 0xFF) ? 0xFF : (unsigned char) x); + int info[4]; + __cpuid(info,1); + return info[3]; } - -static void rjpeg_skip(struct rjpeg_data *ctx, int count) +#else +static int stbi__cpuid3(void) { - ctx->pos += count; - ctx->size -= count; - ctx->length -= count; - if (ctx->size < 0) - ctx->error = RJPEG_SYNTAX_ERROR; -} - -static INLINE uint16_t rjpeg_decode_16(const uint8_t *pos) -{ - return (pos[0] << 8) | pos[1]; -} - -static INLINE void rjpeg_decode_length(struct rjpeg_data *ctx) -{ - if (ctx->size < 2) - JPEG_DECODER_THROW(ctx, RJPEG_SYNTAX_ERROR); - ctx->length = rjpeg_decode_16(ctx->pos); - if (ctx->length > ctx->size) - JPEG_DECODER_THROW(ctx, RJPEG_SYNTAX_ERROR); - rjpeg_skip(ctx, 2); -} - -static void rjpeg_decode_dqt(struct rjpeg_data *ctx) -{ - unsigned char *t = NULL; - - rjpeg_decode_length(ctx); - - while (ctx->length >= 65) - { - int i = ctx->pos[0]; - if (i & 0xFC) - JPEG_DECODER_THROW(ctx, RJPEG_SYNTAX_ERROR); - ctx->qtavail |= 1 << i; - t = &ctx->qtab[i][0]; - for (i = 0; i < 64; ++i) - t[i] = ctx->pos[i + 1]; - rjpeg_skip(ctx, 65); + int res; + __asm { + mov eax,1 + cpuid + mov res,edx } - - if (ctx->length) - JPEG_DECODER_THROW(ctx, RJPEG_SYNTAX_ERROR); -} - -static void rjpeg_decode_dri(struct rjpeg_data *ctx) -{ - rjpeg_decode_length(ctx); - if (ctx->length < 2) - JPEG_DECODER_THROW(ctx, RJPEG_SYNTAX_ERROR); - ctx->rstinterval = rjpeg_decode_16(ctx->pos); - rjpeg_skip(ctx, ctx->length); -} - -static void rjpeg_decode_dht(struct rjpeg_data *ctx) -{ - unsigned char counts[16]; - struct rjpeg_vlc_code *vlc = NULL; - - rjpeg_decode_length(ctx); - - while (ctx->length >= 17) - { - int codelen; - int spread = 65536; - int remain = 65536; - int i = ctx->pos[0]; - - if (i & 0xEC) - JPEG_DECODER_THROW(ctx, RJPEG_SYNTAX_ERROR); - - if (i & 0x02) - JPEG_DECODER_THROW(ctx, RJPEG_UNSUPPORTED); - - i = (i | (i >> 3)) & 3; /* combined DC/AC + tableid value */ - for (codelen = 1; codelen <= 16; ++codelen) - counts[codelen - 1] = ctx->pos[codelen]; - rjpeg_skip(ctx, 17); - vlc = &ctx->vlctab[i][0]; - - for (codelen = 1; codelen <= 16; ++codelen) - { - int currcnt; - - spread >>= 1; - currcnt = counts[codelen - 1]; - if (!currcnt) - continue; - - if (ctx->length < currcnt) - JPEG_DECODER_THROW(ctx, RJPEG_SYNTAX_ERROR); - remain -= currcnt << (16 - codelen); - - if (remain < 0) - JPEG_DECODER_THROW(ctx, RJPEG_SYNTAX_ERROR); - - for (i = 0; i < currcnt; ++i) - { - int j; - unsigned char code = ctx->pos[i]; - - for (j = spread; j; --j) - { - vlc->bits = (unsigned char) codelen; - vlc->code = code; - ++vlc; - } - } - rjpeg_skip(ctx, currcnt); - } - - while (remain--) - { - vlc->bits = 0; - ++vlc; - } - } - - if (ctx->length) - JPEG_DECODER_THROW(ctx, RJPEG_SYNTAX_ERROR); -} - -static int rjpeg_show_bits(struct rjpeg_data *ctx, int bits) -{ - unsigned char newbyte; - if (!bits) - return 0; - - while (ctx->bufbits < bits) - { - if (ctx->size <= 0) - { - ctx->buf = (ctx->buf << 8) | 0xFF; - ctx->bufbits += 8; - continue; - } - - newbyte = *ctx->pos++; - ctx->size--; - ctx->bufbits += 8; - ctx->buf = (ctx->buf << 8) | newbyte; - - if (newbyte == 0xFF) - { - if (ctx->size) - { - unsigned char marker = *ctx->pos++; - ctx->size--; - switch (marker) - { - case 0: - break; - case 0xD9: - ctx->size = 0; - break; - default: - if ((marker & 0xF8) != 0xD0) - ctx->error = RJPEG_SYNTAX_ERROR; - else - { - ctx->buf = (ctx->buf << 8) | marker; - ctx->bufbits += 8; - } - } - } else - ctx->error = RJPEG_SYNTAX_ERROR; - } - } - return (ctx->buf >> (ctx->bufbits - bits)) & ((1 << bits) - 1); -} - -static void rjpeg_skip_bits(struct rjpeg_data *ctx, int bits) -{ - if (ctx->bufbits < bits) - rjpeg_show_bits(ctx, bits); - ctx->bufbits -= bits; -} - -static int rjpeg_get_bits(struct rjpeg_data *ctx, int bits) -{ - int res = rjpeg_show_bits(ctx, bits); - rjpeg_skip_bits(ctx, bits); return res; } +#endif -static int rjpeg_get_vlc(struct rjpeg_data *ctx, - struct rjpeg_vlc_code *vlc, unsigned char* code) +#define STBI_SIMD_ALIGN(type, name) __declspec(align(16)) type name + +static int stbi__sse2_available() { - int value = rjpeg_show_bits(ctx, 16); - int bits = vlc[value].bits; + int info3 = stbi__cpuid3(); + return ((info3 >> 26) & 1) != 0; +} +#else /* assume GCC-style if not VC++ */ +#define STBI_SIMD_ALIGN(type, name) type name __attribute__((aligned(16))) - if (!bits) - { - ctx->error = RJPEG_SYNTAX_ERROR; - return 0; - } +static int stbi__sse2_available() +{ +#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 408 /* GCC 4.8 or later */ + /* GCC 4.8+ has a nice way to do this */ + return __builtin_cpu_supports("sse2"); +#else + /* portable way to do this, preferably without using GCC inline ASM? + * just bail for now. */ + return 0; +#endif +} +#endif +#endif - rjpeg_skip_bits(ctx, bits); - value = vlc[value].code; - if (code) - *code = (unsigned char) value; - bits = value & 15; - if (!bits) - return 0; - value = rjpeg_get_bits(ctx, bits); - if (value < (1 << (bits - 1))) - value += ((-1) << bits) + 1; - return value; +/* ARM NEON */ +#if defined(STBI_NO_SIMD) && defined(STBI_NEON) +#undef STBI_NEON +#endif + +#ifdef STBI_NEON +#include +/* assume GCC or Clang on ARM targets */ +#define STBI_SIMD_ALIGN(type, name) type name __attribute__((aligned(16))) +#endif + +#ifndef STBI_SIMD_ALIGN +#define STBI_SIMD_ALIGN(type, name) type name +#endif + +/////////////////////////////////////////////// +// +// stbi__context struct and start_xxx functions + +// stbi__context structure is our basic context used by all images, so it +// contains all the IO context, plus some basic image information +typedef struct +{ + uint32_t img_x, img_y; + int img_n, img_out_n; + + stbi_io_callbacks io; + void *io_user_data; + + int read_from_callbacks; + int buflen; + uint8_t buffer_start[128]; + + uint8_t *img_buffer, *img_buffer_end; + uint8_t *img_buffer_original; +} stbi__context; + + +static void stbi__refill_buffer(stbi__context *s); + +// initialize a memory-decode context +static void stbi__start_mem(stbi__context *s, const uint8_t *buffer, int len) +{ + s->io.read = NULL; + s->read_from_callbacks = 0; + s->img_buffer = s->img_buffer_original = (uint8_t *) buffer; + s->img_buffer_end = (uint8_t *) buffer+len; } -static void rjpeg_row_idct(int* blk) +static void stbi__rewind(stbi__context *s) { - int x0, x1, x2, x3, x4, x5, x6, x7, x8; - if (!((x1 = blk[4] << 11) - | (x2 = blk[6]) - | (x3 = blk[2]) - | (x4 = blk[1]) - | (x5 = blk[7]) - | (x6 = blk[5]) - | (x7 = blk[3]))) - { - unsigned i; - int val = blk[0] << 3; - - for (i = 0; i < 8; i++) - blk[i] = val; - return; - } - - x0 = (blk[0] << 11) + 128; - x8 = W7 * (x4 + x5); - x4 = x8 + (W1 - W7) * x4; - x5 = x8 - (W1 + W7) * x5; - x8 = W3 * (x6 + x7); - x6 = x8 - (W3 - W5) * x6; - x7 = x8 - (W3 + W5) * x7; - x8 = x0 + x1; - x0 -= x1; - x1 = W6 * (x3 + x2); - x2 = x1 - (W2 + W6) * x2; - x3 = x1 + (W2 - W6) * x3; - x1 = x4 + x6; - x4 -= x6; - x6 = x5 + x7; - x5 -= x7; - x7 = x8 + x3; - x8 -= x3; - x3 = x0 + x2; - x0 -= x2; - x2 = (181 * (x4 + x5) + 128) >> 8; - x4 = (181 * (x4 - x5) + 128) >> 8; - blk[0] = (x7 + x1) >> 8; - blk[1] = (x3 + x2) >> 8; - blk[2] = (x0 + x4) >> 8; - blk[3] = (x8 + x6) >> 8; - blk[4] = (x8 - x6) >> 8; - blk[5] = (x0 - x4) >> 8; - blk[6] = (x3 - x2) >> 8; - blk[7] = (x7 - x1) >> 8; + /* conceptually rewind SHOULD rewind to the beginning of the stream, + * but we just rewind to the beginning of the initial buffer, because + * we only use it after doing 'test', which only ever looks at at most 92 bytes + */ + s->img_buffer = s->img_buffer_original; } -static void rjpeg_col_idct(const int* blk, unsigned char *out, int stride) +#ifndef STBI_NO_JPEG +static int stbi__jpeg_test(stbi__context *s); +static uint8_t *stbi__jpeg_load(stbi__context *s, int *x, int *y, int *comp, int req_comp); +#endif + +// this is not threadsafe +static const char *stbi__g_failure_reason; + +static int stbi__err(const char *str) { - int x0, x1, x2, x3, x4, x5, x6, x7, x8; - if (!((x1 = blk[8*4] << 8) - | (x2 = blk[8*6]) - | (x3 = blk[8*2]) - | (x4 = blk[8*1]) - | (x5 = blk[8*7]) - | (x6 = blk[8*5]) - | (x7 = blk[8*3]))) - { - x1 = rjpeg_clip(((blk[0] + 32) >> 6) + 128); - for (x0 = 8; x0; --x0) - { - *out = (unsigned char) x1; - out += stride; + stbi__g_failure_reason = str; + return 0; +} + +// stbi__err - error +// stbi__errpf - error returning pointer to float +// stbi__errpuc - error returning pointer to unsigned char + +#ifdef STBI_NO_FAILURE_STRINGS + #define stbi__err(x,y) 0 +#elif defined(STBI_FAILURE_USERMSG) + #define stbi__err(x,y) stbi__err(y) +#else + #define stbi__err(x,y) stbi__err(x) +#endif + +#define stbi__errpf(x,y) ((float *) (stbi__err(x,y)?NULL:NULL)) +#define stbi__errpuc(x,y) ((unsigned char *) (stbi__err(x,y)?NULL:NULL)) + +static int stbi__vertically_flip_on_load = 0; + +static unsigned char *stbi__load_main(stbi__context *s, int *x, int *y, int *comp, int req_comp) +{ + #ifndef STBI_NO_JPEG + if (stbi__jpeg_test(s)) return stbi__jpeg_load(s,x,y,comp,req_comp); + #endif + + return stbi__errpuc("unknown image type", "Image not of any known type, or corrupt"); +} + +static unsigned char *stbi__load_flip(stbi__context *s, int *x, int *y, int *comp, int req_comp) +{ + unsigned char *result = stbi__load_main(s, x, y, comp, req_comp); + + if (stbi__vertically_flip_on_load && result != NULL) { + int w = *x, h = *y; + int depth = req_comp ? req_comp : *comp; + int row,col,z; + uint8_t temp; + + // @OPTIMIZE: use a bigger temp buffer and memcpy multiple pixels at once + for (row = 0; row < (h>>1); row++) { + for (col = 0; col < w; col++) { + for (z = 0; z < depth; z++) { + temp = result[(row * w + col) * depth + z]; + result[(row * w + col) * depth + z] = result[((h - row - 1) * w + col) * depth + z]; + result[((h - row - 1) * w + col) * depth + z] = temp; + } + } } + } + + return result; +} + +static uint8_t *stbi_load_from_memory(const uint8_t *buffer, int len, int *x, int *y, int *comp, int req_comp) +{ + stbi__context s; + stbi__start_mem(&s,buffer,len); + return stbi__load_flip(&s,x,y,comp,req_comp); +} + +////////////////////////////////////////////////////////////////////////////// +// +// Common code used by all image loaders +// + +enum +{ + STBI__SCAN_load=0, + STBI__SCAN_type, + STBI__SCAN_header +}; + +static void stbi__refill_buffer(stbi__context *s) +{ + int n = (s->io.read)(s->io_user_data,(char*)s->buffer_start,s->buflen); + if (n == 0) { + // at end of file, treat same as if from memory, but need to handle case + // where s->img_buffer isn't pointing to safe memory, e.g. 0-byte file + s->read_from_callbacks = 0; + s->img_buffer = s->buffer_start; + s->img_buffer_end = s->buffer_start+1; + *s->img_buffer = 0; + } else { + s->img_buffer = s->buffer_start; + s->img_buffer_end = s->buffer_start + n; + } +} + +static INLINE uint8_t stbi__get8(stbi__context *s) +{ + if (s->img_buffer < s->img_buffer_end) + return *s->img_buffer++; + if (s->read_from_callbacks) { + stbi__refill_buffer(s); + return *s->img_buffer++; + } + return 0; +} + +static INLINE int stbi__at_eof(stbi__context *s) +{ + if (s->io.read) { + if (!(s->io.eof)(s->io_user_data)) return 0; + // if feof() is true, check if buffer = end + // special case: we've only got the special 0 character at the end + if (s->read_from_callbacks == 0) return 1; + } + + return s->img_buffer >= s->img_buffer_end; +} + +static void stbi__skip(stbi__context *s, int n) +{ + if (n < 0) { + s->img_buffer = s->img_buffer_end; return; } - x0 = (blk[0] << 8) + 8192; - x8 = W7 * (x4 + x5) + 4; - x4 = (x8 + (W1 - W7) * x4) >> 3; - x5 = (x8 - (W1 + W7) * x5) >> 3; - x8 = W3 * (x6 + x7) + 4; - x6 = (x8 - (W3 - W5) * x6) >> 3; - x7 = (x8 - (W3 + W5) * x7) >> 3; - x8 = x0 + x1; - x0 -= x1; - x1 = W6 * (x3 + x2) + 4; - x2 = (x1 - (W2 + W6) * x2) >> 3; - x3 = (x1 + (W2 - W6) * x3) >> 3; - x1 = x4 + x6; - x4 -= x6; - x6 = x5 + x7; - x5 -= x7; - x7 = x8 + x3; - x8 -= x3; - x3 = x0 + x2; - x0 -= x2; - x2 = (181 * (x4 + x5) + 128) >> 8; - x4 = (181 * (x4 - x5) + 128) >> 8; - *out = rjpeg_clip(((x7 + x1) >> 14) + 128); - out += stride; - *out = rjpeg_clip(((x3 + x2) >> 14) + 128); - out += stride; - *out = rjpeg_clip(((x0 + x4) >> 14) + 128); - out += stride; - *out = rjpeg_clip(((x8 + x6) >> 14) + 128); - out += stride; - *out = rjpeg_clip(((x8 - x6) >> 14) + 128); - out += stride; - *out = rjpeg_clip(((x0 - x4) >> 14) + 128); - out += stride; - *out = rjpeg_clip(((x3 - x2) >> 14) + 128); - out += stride; - *out = rjpeg_clip(((x7 - x1) >> 14) + 128); + if (s->io.read) { + int blen = (int) (s->img_buffer_end - s->img_buffer); + if (blen < n) { + s->img_buffer = s->img_buffer_end; + (s->io.skip)(s->io_user_data, n - blen); + return; + } + } + s->img_buffer += n; } -static INLINE void rjpeg_decode_block( - struct rjpeg_data *ctx, - struct rjpeg_component *c, - unsigned char* out) +static int stbi__get16be(stbi__context *s) { - unsigned char code = 0; - int coef = 0; + int z = stbi__get8(s); + return (z << 8) + stbi__get8(s); +} - memset(ctx->block, 0, sizeof(ctx->block)); +#define STBI__BYTECAST(x) ((uint8_t) ((x) & 255)) // truncate int to byte without warnings - c->dcpred += rjpeg_get_vlc(ctx, &ctx->vlctab[c->dctabsel][0], NULL); - ctx->block[0] = (c->dcpred) * ctx->qtab[c->qtsel][0]; +////////////////////////////////////////////////////////////////////////////// +// +// "baseline" JPEG/JFIF decoder +// +// simple implementation +// - doesn't support delayed output of y-dimension +// - simple interface (only one output format: 8-bit interleaved RGB) +// - doesn't try to recover corrupt jpegs +// - doesn't allow partial loading, loading multiple at once +// - still fast on x86 (copying globals into locals doesn't help x86) +// - allocates lots of intermediate memory (full size of all components) +// - non-interleaved case requires this anyway +// - allows good upsampling (see next) +// high-quality +// - upsampled channels are bilinearly interpolated, even across blocks +// - quality integer IDCT derived from IJG's 'slow' +// performance +// - fast huffman; reasonable integer IDCT +// - some SIMD kernels for common paths on targets with SSE2/NEON +// - uses a lot of intermediate memory, could cache poorly - do +#ifndef STBI_NO_JPEG + +// huffman decoding acceleration +#define FAST_BITS 9 // larger handles more cases; smaller stomps less cache + +typedef struct +{ + uint8_t fast[1 << FAST_BITS]; + // weirdly, repacking this into AoS is a 10% speed loss, instead of a win + uint16_t code[256]; + uint8_t values[256]; + uint8_t size[257]; + unsigned int maxcode[18]; + int delta[17]; // old 'firstsymbol' - old 'firstcode' +} stbi__huffman; + +typedef struct +{ + stbi__context *s; + stbi__huffman huff_dc[4]; + stbi__huffman huff_ac[4]; + uint8_t dequant[4][64]; + int16_t fast_ac[4][1 << FAST_BITS]; + +// sizes for components, interleaved MCUs + int img_h_max, img_v_max; + int img_mcu_x, img_mcu_y; + int img_mcu_w, img_mcu_h; + +// definition of jpeg image component + struct { - int value = rjpeg_get_vlc(ctx, &ctx->vlctab[c->actabsel][0], &code); + int id; + int h,v; + int tq; + int hd,ha; + int dc_pred; - if (!code) - break; /* EOB */ + int x,y,w2,h2; + uint8_t *data; + void *raw_data, *raw_coeff; + uint8_t *linebuf; + short *coeff; // progressive only + int coeff_w, coeff_h; // number of 8x8 coefficient blocks + } img_comp[4]; - if (!(code & 0x0F) && (code != 0xF0)) - JPEG_DECODER_THROW(ctx, RJPEG_SYNTAX_ERROR); - coef += (code >> 4) + 1; - if (coef > 63) - JPEG_DECODER_THROW(ctx, RJPEG_SYNTAX_ERROR); - ctx->block[(int) ctx->ZZ[coef]] = value * ctx->qtab[c->qtsel][coef]; - } while (coef < 63); + uint32_t code_buffer; // jpeg entropy-coded buffer + int code_bits; // number of valid bits + unsigned char marker; // marker seen while filling entropy buffer + int nomore; // flag if we saw a marker so must stop - for (coef = 0; coef < 64; coef += 8) - rjpeg_row_idct(&ctx->block[coef]); + int progressive; + int spec_start; + int spec_end; + int succ_high; + int succ_low; + int eob_run; - for (coef = 0; coef < 8; ++coef) - rjpeg_col_idct(&ctx->block[coef], &out[coef], c->stride); -} + int scan_n, order[4]; + int restart_interval, todo; +// kernels + void (*idct_block_kernel)(uint8_t *out, int out_stride, short data[64]); + void (*YCbCr_to_RGB_kernel)(uint8_t *out, const uint8_t *y, const uint8_t *pcb, const uint8_t *pcr, int count, int step); + uint8_t *(*resample_row_hv_2_kernel)(uint8_t *out, uint8_t *in_near, uint8_t *in_far, int w, int hs); +} stbi__jpeg; -static INLINE void rjpeg_byte_align(struct rjpeg_data *ctx) +static int stbi__build_huffman(stbi__huffman *h, int *count) { - ctx->bufbits &= 0xF8; + int i,j,k=0,code; + // build size list for each symbol (from JPEG spec) + for (i=0; i < 16; ++i) + for (j=0; j < count[i]; ++j) + h->size[k++] = (uint8_t) (i+1); + h->size[k] = 0; + + // compute actual symbols (from jpeg spec) + code = 0; + k = 0; + for(j=1; j <= 16; ++j) { + // compute delta to add to code to compute symbol id + h->delta[j] = k - code; + if (h->size[k] == j) { + while (h->size[k] == j) + h->code[k++] = (uint16_t) (code++); + if (code-1 >= (1 << j)) return stbi__err("bad code lengths","Corrupt JPEG"); + } + // compute largest code + 1 for this size, preshifted as needed later + h->maxcode[j] = code << (16-j); + code <<= 1; + } + h->maxcode[j] = 0xffffffff; + + // build non-spec acceleration table; 255 is flag for not-accelerated + memset(h->fast, 255, 1 << FAST_BITS); + for (i=0; i < k; ++i) { + int s = h->size[i]; + if (s <= FAST_BITS) { + int c = h->code[i] << (FAST_BITS-s); + int m = 1 << (FAST_BITS-s); + for (j=0; j < m; ++j) { + h->fast[c+j] = (uint8_t) i; + } + } + } + return 1; } -static INLINE void rjpeg_skip_marker(struct rjpeg_data *ctx) -{ - rjpeg_decode_length(ctx); - rjpeg_skip(ctx, ctx->length); -} - -static void rjpeg_decode_sof(struct rjpeg_data *ctx) +// build a table that decodes both magnitude and value of small ACs in +// one go. +static void stbi__build_fast_ac(int16_t *fast_ac, stbi__huffman *h) { int i; - int ssxmax = 0; - int ssymax = 0; - struct rjpeg_component *c = NULL; + for (i=0; i < (1 << FAST_BITS); ++i) { + uint8_t fast = h->fast[i]; + fast_ac[i] = 0; + if (fast < 255) { + int rs = h->values[fast]; + int run = (rs >> 4) & 15; + int magbits = rs & 15; + int len = h->size[fast]; - rjpeg_decode_length(ctx); - - if (ctx->length < 9) - JPEG_DECODER_THROW(ctx, RJPEG_SYNTAX_ERROR); - if (ctx->pos[0] != 8) - JPEG_DECODER_THROW(ctx, RJPEG_UNSUPPORTED); - ctx->height = rjpeg_decode_16(ctx->pos+1); - ctx->width = rjpeg_decode_16(ctx->pos+3); - ctx->ncomp = ctx->pos[5]; - rjpeg_skip(ctx, 6); - - switch (ctx->ncomp) - { - case 1: - case 3: - break; - default: - JPEG_DECODER_THROW(ctx, RJPEG_UNSUPPORTED); + if (magbits && len + magbits <= FAST_BITS) { + // magnitude code followed by receive_extend code + int k = ((i << len) & ((1 << FAST_BITS) - 1)) >> (FAST_BITS - magbits); + int m = 1 << (magbits - 1); + if (k < m) k += (-1 << magbits) + 1; + // if the result is small enough, we can fit it in fast_ac table + if (k >= -128 && k <= 127) + fast_ac[i] = (int16_t) ((k << 8) + (run << 4) + (len + magbits)); + } + } } - - if (ctx->length < (ctx->ncomp * 3)) - JPEG_DECODER_THROW(ctx, RJPEG_SYNTAX_ERROR); - - for (i = 0, c = ctx->comp; i < ctx->ncomp; ++i, ++c) - { - c->cid = ctx->pos[0]; - if (!(c->ssx = ctx->pos[1] >> 4)) - JPEG_DECODER_THROW(ctx, RJPEG_SYNTAX_ERROR); - if (c->ssx & (c->ssx - 1)) - JPEG_DECODER_THROW(ctx, RJPEG_UNSUPPORTED); /* non-power of two */ - if (!(c->ssy = ctx->pos[1] & 15)) - JPEG_DECODER_THROW(ctx, RJPEG_SYNTAX_ERROR); - if (c->ssy & (c->ssy - 1)) - JPEG_DECODER_THROW(ctx, RJPEG_UNSUPPORTED); /* non-power of two */ - if ((c->qtsel = ctx->pos[2]) & 0xFC) - JPEG_DECODER_THROW(ctx, RJPEG_SYNTAX_ERROR); - rjpeg_skip(ctx, 3); - ctx->qtused |= 1 << c->qtsel; - if (c->ssx > ssxmax) ssxmax = c->ssx; - if (c->ssy > ssymax) ssymax = c->ssy; - } - ctx->mbsizex = ssxmax << 3; - ctx->mbsizey = ssymax << 3; - ctx->mbwidth = (ctx->width + ctx->mbsizex - 1) / ctx->mbsizex; - ctx->mbheight = (ctx->height + ctx->mbsizey - 1) / ctx->mbsizey; - - for (i = 0, c = ctx->comp; i < ctx->ncomp; ++i, ++c) - { - c->width = (ctx->width * c->ssx + ssxmax - 1) / ssxmax; - c->stride = (c->width + 7) & 0x7FFFFFF8; - c->height = (ctx->height * c->ssy + ssymax - 1) / ssymax; - c->stride = ctx->mbwidth * ctx->mbsizex * c->ssx / ssxmax; - if (((c->width < 3) && (c->ssx != ssxmax)) || ((c->height < 3) && (c->ssy != ssymax))) - JPEG_DECODER_THROW(ctx, RJPEG_UNSUPPORTED); - if (!(c->pixels = (unsigned char*)malloc(c->stride * (ctx->mbheight * ctx->mbsizey * c->ssy / ssymax)))) - JPEG_DECODER_THROW(ctx, RJPEG_OOM); - } - - if (ctx->ncomp == 3) - { - ctx->rgb = (unsigned char*)malloc(ctx->width * ctx->height * ctx->ncomp); - if (!ctx->rgb) - JPEG_DECODER_THROW(ctx, RJPEG_OOM); - } - rjpeg_skip(ctx, ctx->length); } -static void rjpeg_decode_scan(struct rjpeg_data *ctx) +static void stbi__grow_buffer_unsafe(stbi__jpeg *j) { - int i, mbx, mby, sbx, sby; - int rstcount = ctx->rstinterval; - int nextrst = 0; - struct rjpeg_component *c = NULL; + do { + int b = j->nomore ? 0 : stbi__get8(j->s); + if (b == 0xff) { + int c = stbi__get8(j->s); + if (c != 0) { + j->marker = (unsigned char) c; + j->nomore = 1; + return; + } + } + j->code_buffer |= b << (24 - j->code_bits); + j->code_bits += 8; + } while (j->code_bits <= 24); +} - rjpeg_decode_length(ctx); +// (1 << n) - 1 +static uint32_t stbi__bmask[17]={0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535}; - if (ctx->length < (4 + 2 * ctx->ncomp)) - JPEG_DECODER_THROW(ctx, RJPEG_SYNTAX_ERROR); - if (ctx->pos[0] != ctx->ncomp) - JPEG_DECODER_THROW(ctx, RJPEG_UNSUPPORTED); - rjpeg_skip(ctx, 1); - for (i = 0, c = ctx->comp; i < ctx->ncomp; ++i, ++c) - { - if (ctx->pos[0] != c->cid) - JPEG_DECODER_THROW(ctx, RJPEG_SYNTAX_ERROR); - if (ctx->pos[1] & 0xEE) - JPEG_DECODER_THROW(ctx, RJPEG_SYNTAX_ERROR); - c->dctabsel = ctx->pos[1] >> 4; - c->actabsel = (ctx->pos[1] & 1) | 2; - rjpeg_skip(ctx, 2); +// decode a jpeg huffman value from the bitstream +static INLINE int stbi__jpeg_huff_decode(stbi__jpeg *j, stbi__huffman *h) +{ + unsigned int temp; + int c,k; + + if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); + + // look at the top FAST_BITS and determine what symbol ID it is, + // if the code is <= FAST_BITS + c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1); + k = h->fast[c]; + if (k < 255) { + int s = h->size[k]; + if (s > j->code_bits) + return -1; + j->code_buffer <<= s; + j->code_bits -= s; + return h->values[k]; } - if (ctx->pos[0] || (ctx->pos[1] != 63) || ctx->pos[2]) - JPEG_DECODER_THROW(ctx, RJPEG_UNSUPPORTED); + // naive test is to shift the code_buffer down so k bits are + // valid, then test against maxcode. To speed this up, we've + // preshifted maxcode left so that it has (16-k) 0s at the + // end; in other words, regardless of the number of bits, it + // wants to be compared against something shifted to have 16; + // that way we don't need to shift inside the loop. + temp = j->code_buffer >> 16; + for (k=FAST_BITS+1 ; ; ++k) + if (temp < h->maxcode[k]) + break; + if (k == 17) { + // error! code not found + j->code_bits -= 16; + return -1; + } - rjpeg_skip(ctx, ctx->length); + if (k > j->code_bits) + return -1; - for (mby = 0; mby < ctx->mbheight; ++mby) + // convert the huffman code to the symbol id + c = ((j->code_buffer >> (32 - k)) & stbi__bmask[k]) + h->delta[k]; + assert((((j->code_buffer) >> (32 - h->size[c])) & stbi__bmask[h->size[c]]) == h->code[c]); + + // convert the id to a symbol + j->code_bits -= k; + j->code_buffer <<= k; + return h->values[c]; +} + +// bias[n] = (-1<code_bits < n) stbi__grow_buffer_unsafe(j); + + sgn = (int32_t)j->code_buffer >> 31; // sign bit is always in MSB + k = stbi_lrot(j->code_buffer, n); + assert(n >= 0 && n < (int) (sizeof(stbi__bmask)/sizeof(*stbi__bmask))); + j->code_buffer = k & ~stbi__bmask[n]; + k &= stbi__bmask[n]; + j->code_bits -= n; + return k + (stbi__jbias[n] & ~sgn); +} + +// get some unsigned bits +static INLINE int stbi__jpeg_get_bits(stbi__jpeg *j, int n) +{ + unsigned int k; + if (j->code_bits < n) stbi__grow_buffer_unsafe(j); + k = stbi_lrot(j->code_buffer, n); + j->code_buffer = k & ~stbi__bmask[n]; + k &= stbi__bmask[n]; + j->code_bits -= n; + return k; +} + +static INLINE int stbi__jpeg_get_bit(stbi__jpeg *j) +{ + unsigned int k; + if (j->code_bits < 1) stbi__grow_buffer_unsafe(j); + k = j->code_buffer; + j->code_buffer <<= 1; + --j->code_bits; + return k & 0x80000000; +} + +// given a value that's at position X in the zigzag stream, +// where does it appear in the 8x8 matrix coded as row-major? +static uint8_t stbi__jpeg_dezigzag[64+15] = +{ + 0, 1, 8, 16, 9, 2, 3, 10, + 17, 24, 32, 25, 18, 11, 4, 5, + 12, 19, 26, 33, 40, 48, 41, 34, + 27, 20, 13, 6, 7, 14, 21, 28, + 35, 42, 49, 56, 57, 50, 43, 36, + 29, 22, 15, 23, 30, 37, 44, 51, + 58, 59, 52, 45, 38, 31, 39, 46, + 53, 60, 61, 54, 47, 55, 62, 63, + // let corrupt input sample past end + 63, 63, 63, 63, 63, 63, 63, 63, + 63, 63, 63, 63, 63, 63, 63 +}; + +// decode one 64-entry block-- +static int stbi__jpeg_decode_block(stbi__jpeg *j, short data[64], stbi__huffman *hdc, stbi__huffman *hac, int16_t *fac, int b, uint8_t *dequant) +{ + int diff,dc,k; + int t; + + if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); + t = stbi__jpeg_huff_decode(j, hdc); + if (t < 0) return stbi__err("bad huffman code","Corrupt JPEG"); + + // 0 all the ac values now so we can do it 32-bits at a time + memset(data,0,64*sizeof(data[0])); + + diff = t ? stbi__extend_receive(j, t) : 0; + dc = j->img_comp[b].dc_pred + diff; + j->img_comp[b].dc_pred = dc; + data[0] = (short) (dc * dequant[0]); + + // decode AC components, see JPEG spec + k = 1; + do { + unsigned int zig; + int c,r,s; + if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); + c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1); + r = fac[c]; + if (r) { // fast-AC path + k += (r >> 4) & 15; // run + s = r & 15; // combined length + j->code_buffer <<= s; + j->code_bits -= s; + // decode into unzigzag'd location + zig = stbi__jpeg_dezigzag[k++]; + data[zig] = (short) ((r >> 8) * dequant[zig]); + } else { + int rs = stbi__jpeg_huff_decode(j, hac); + if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG"); + s = rs & 15; + r = rs >> 4; + if (s == 0) { + if (rs != 0xf0) break; // end block + k += 16; + } else { + k += r; + // decode into unzigzag'd location + zig = stbi__jpeg_dezigzag[k++]; + data[zig] = (short) (stbi__extend_receive(j,s) * dequant[zig]); + } + } + } while (k < 64); + return 1; +} + +static int stbi__jpeg_decode_block_prog_dc(stbi__jpeg *j, short data[64], stbi__huffman *hdc, int b) +{ + if (j->spec_end != 0) + return stbi__err("can't merge dc and ac", "Corrupt JPEG"); + + if (j->code_bits < 16) + stbi__grow_buffer_unsafe(j); + + if (j->succ_high == 0) { - for (mbx = 0; mbx < ctx->mbwidth; ++mbx) - { - for (i = 0, c = ctx->comp; i < ctx->ncomp; ++i, ++c) - { - for (sby = 0; sby < c->ssy; ++sby) - { - for (sbx = 0; sbx < c->ssx; ++sbx) - { - rjpeg_decode_block(ctx, c, - &c->pixels[((mby * c->ssy + sby) * c->stride + mbx * c->ssx + sbx) << 3]); - if (ctx->error) - return; + int diff,dc; + int t; + + /* first scan for DC coefficient, must be first */ + memset(data,0,64*sizeof(data[0])); // 0 all the ac values now + t = stbi__jpeg_huff_decode(j, hdc); + diff = t ? stbi__extend_receive(j, t) : 0; + + dc = j->img_comp[b].dc_pred + diff; + j->img_comp[b].dc_pred = dc; + data[0] = (short) (dc << j->succ_low); + } + else + { + /* refinement scan for DC coefficient */ + if (stbi__jpeg_get_bit(j)) + data[0] += (short) (1 << j->succ_low); + } + return 1; +} + +// @OPTIMIZE: store non-zigzagged during the decode passes, +// and only de-zigzag when dequantizing +static int stbi__jpeg_decode_block_prog_ac(stbi__jpeg *j, short data[64], stbi__huffman *hac, int16_t *fac) +{ + int k; + if (j->spec_start == 0) return stbi__err("can't merge dc and ac", "Corrupt JPEG"); + + if (j->succ_high == 0) { + int shift = j->succ_low; + + if (j->eob_run) { + --j->eob_run; + return 1; + } + + k = j->spec_start; + do { + unsigned int zig; + int c,r,s; + if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); + c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1); + r = fac[c]; + if (r) { // fast-AC path + k += (r >> 4) & 15; // run + s = r & 15; // combined length + j->code_buffer <<= s; + j->code_bits -= s; + zig = stbi__jpeg_dezigzag[k++]; + data[zig] = (short) ((r >> 8) << shift); + } else { + int rs = stbi__jpeg_huff_decode(j, hac); + if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG"); + s = rs & 15; + r = rs >> 4; + if (s == 0) { + if (r < 15) { + j->eob_run = (1 << r); + if (r) + j->eob_run += stbi__jpeg_get_bits(j, r); + --j->eob_run; + break; + } + k += 16; + } else { + k += r; + zig = stbi__jpeg_dezigzag[k++]; + data[zig] = (short) (stbi__extend_receive(j,s) << shift); + } + } + } while (k <= j->spec_end); + } else { + // refinement scan for these AC coefficients + + short bit = (short) (1 << j->succ_low); + + if (j->eob_run) { + --j->eob_run; + for (k = j->spec_start; k <= j->spec_end; ++k) { + short *p = &data[stbi__jpeg_dezigzag[k]]; + if (*p != 0) + if (stbi__jpeg_get_bit(j)) + if ((*p & bit)==0) { + if (*p > 0) + *p += bit; + else + *p -= bit; + } + } + } else { + k = j->spec_start; + do { + int r,s; + int rs = stbi__jpeg_huff_decode(j, hac); // @OPTIMIZE see if we can use the fast path here, advance-by-r is so slow, eh + if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG"); + s = rs & 15; + r = rs >> 4; + if (s == 0) { + if (r < 15) { + j->eob_run = (1 << r) - 1; + if (r) + j->eob_run += stbi__jpeg_get_bits(j, r); + r = 64; // force end of block + } else { + // r=15 s=0 should write 16 0s, so we just do + // a run of 15 0s and then write s (which is 0), + // so we don't have to do anything special here + } + } else { + if (s != 1) return stbi__err("bad huffman code", "Corrupt JPEG"); + // sign bit + if (stbi__jpeg_get_bit(j)) + s = bit; + else + s = -bit; + } + + // advance by r + while (k <= j->spec_end) { + short *p = &data[stbi__jpeg_dezigzag[k++]]; + if (*p != 0) { + if (stbi__jpeg_get_bit(j)) + if ((*p & bit)==0) { + if (*p > 0) + *p += bit; + else + *p -= bit; + } + } else { + if (r == 0) { + *p = (short) s; + break; + } + --r; + } + } + } while (k <= j->spec_end); + } + } + return 1; +} + +// take a -128..127 value and stbi__clamp it and convert to 0..255 +static INLINE uint8_t stbi__clamp(int x) +{ + // trick to use a single test to catch both cases + if ((unsigned int) x > 255) { + if (x < 0) return 0; + if (x > 255) return 255; + } + return (uint8_t) x; +} + +#define stbi__f2f(x) ((int) (((x) * 4096 + 0.5))) +#define stbi__fsh(x) ((x) << 12) + +// derived from jidctint -- DCT_ISLOW +#define STBI__IDCT_1D(s0,s1,s2,s3,s4,s5,s6,s7) \ + int t0,t1,t2,t3,p1,p2,p3,p4,p5,x0,x1,x2,x3; \ + p2 = s2; \ + p3 = s6; \ + p1 = (p2+p3) * stbi__f2f(0.5411961f); \ + t2 = p1 + p3*stbi__f2f(-1.847759065f); \ + t3 = p1 + p2*stbi__f2f( 0.765366865f); \ + p2 = s0; \ + p3 = s4; \ + t0 = stbi__fsh(p2+p3); \ + t1 = stbi__fsh(p2-p3); \ + x0 = t0+t3; \ + x3 = t0-t3; \ + x1 = t1+t2; \ + x2 = t1-t2; \ + t0 = s7; \ + t1 = s5; \ + t2 = s3; \ + t3 = s1; \ + p3 = t0+t2; \ + p4 = t1+t3; \ + p1 = t0+t3; \ + p2 = t1+t2; \ + p5 = (p3+p4)*stbi__f2f( 1.175875602f); \ + t0 = t0*stbi__f2f( 0.298631336f); \ + t1 = t1*stbi__f2f( 2.053119869f); \ + t2 = t2*stbi__f2f( 3.072711026f); \ + t3 = t3*stbi__f2f( 1.501321110f); \ + p1 = p5 + p1*stbi__f2f(-0.899976223f); \ + p2 = p5 + p2*stbi__f2f(-2.562915447f); \ + p3 = p3*stbi__f2f(-1.961570560f); \ + p4 = p4*stbi__f2f(-0.390180644f); \ + t3 += p1+p4; \ + t2 += p2+p3; \ + t1 += p2+p4; \ + t0 += p1+p3; + +static void stbi__idct_block(uint8_t *out, int out_stride, short data[64]) +{ + int i,val[64],*v=val; + uint8_t *o; + short *d = data; + + // columns + for (i=0; i < 8; ++i,++d, ++v) { + // if all zeroes, shortcut -- this avoids dequantizing 0s and IDCTing + if (d[ 8]==0 && d[16]==0 && d[24]==0 && d[32]==0 + && d[40]==0 && d[48]==0 && d[56]==0) { + // no shortcut 0 seconds + // (1|2|3|4|5|6|7)==0 0 seconds + // all separate -0.047 seconds + // 1 && 2|3 && 4|5 && 6|7: -0.047 seconds + int dcterm = d[0] << 2; + v[0] = v[8] = v[16] = v[24] = v[32] = v[40] = v[48] = v[56] = dcterm; + } else { + STBI__IDCT_1D(d[ 0],d[ 8],d[16],d[24],d[32],d[40],d[48],d[56]) + // constants scaled things up by 1<<12; let's bring them back + // down, but keep 2 extra bits of precision + x0 += 512; x1 += 512; x2 += 512; x3 += 512; + v[ 0] = (x0+t3) >> 10; + v[56] = (x0-t3) >> 10; + v[ 8] = (x1+t2) >> 10; + v[48] = (x1-t2) >> 10; + v[16] = (x2+t1) >> 10; + v[40] = (x2-t1) >> 10; + v[24] = (x3+t0) >> 10; + v[32] = (x3-t0) >> 10; + } + } + + for (i=0, v=val, o=out; i < 8; ++i,v+=8,o+=out_stride) { + // no fast case since the first 1D IDCT spread components out + STBI__IDCT_1D(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7]) + // constants scaled things up by 1<<12, plus we had 1<<2 from first + // loop, plus horizontal and vertical each scale by sqrt(8) so together + // we've got an extra 1<<3, so 1<<17 total we need to remove. + // so we want to round that, which means adding 0.5 * 1<<17, + // aka 65536. Also, we'll end up with -128 to 127 that we want + // to encode as 0..255 by adding 128, so we'll add that before the shift + x0 += 65536 + (128<<17); + x1 += 65536 + (128<<17); + x2 += 65536 + (128<<17); + x3 += 65536 + (128<<17); + // tried computing the shifts into temps, or'ing the temps to see + // if any were out of range, but that was slower + o[0] = stbi__clamp((x0+t3) >> 17); + o[7] = stbi__clamp((x0-t3) >> 17); + o[1] = stbi__clamp((x1+t2) >> 17); + o[6] = stbi__clamp((x1-t2) >> 17); + o[2] = stbi__clamp((x2+t1) >> 17); + o[5] = stbi__clamp((x2-t1) >> 17); + o[3] = stbi__clamp((x3+t0) >> 17); + o[4] = stbi__clamp((x3-t0) >> 17); + } +} + +#ifdef STBI_SSE2 +/* sse2 integer IDCT. not the fastest possible implementation but it + * produces bit-identical results to the generic C version so it's + * fully "transparent". + */ +static void stbi__idct_simd(uint8_t *out, int out_stride, short data[64]) +{ + /* This is constructed to match our regular (generic) integer IDCT exactly. */ + __m128i row0, row1, row2, row3, row4, row5, row6, row7; + __m128i tmp; + + /* dot product constant: even elems=x, odd elems=y */ + #define dct_const(x,y) _mm_setr_epi16((x),(y),(x),(y),(x),(y),(x),(y)) + + /* out(0) = c0[even]*x + c0[odd]*y (c0, x, y 16-bit, out 32-bit) + * out(1) = c1[even]*x + c1[odd]*y + */ + #define dct_rot(out0,out1, x,y,c0,c1) \ + __m128i c0##lo = _mm_unpacklo_epi16((x),(y)); \ + __m128i c0##hi = _mm_unpackhi_epi16((x),(y)); \ + __m128i out0##_l = _mm_madd_epi16(c0##lo, c0); \ + __m128i out0##_h = _mm_madd_epi16(c0##hi, c0); \ + __m128i out1##_l = _mm_madd_epi16(c0##lo, c1); \ + __m128i out1##_h = _mm_madd_epi16(c0##hi, c1) + + /* out = in << 12 (in 16-bit, out 32-bit) */ + #define dct_widen(out, in) \ + __m128i out##_l = _mm_srai_epi32(_mm_unpacklo_epi16(_mm_setzero_si128(), (in)), 4); \ + __m128i out##_h = _mm_srai_epi32(_mm_unpackhi_epi16(_mm_setzero_si128(), (in)), 4) + + /* wide add */ + #define dct_wadd(out, a, b) \ + __m128i out##_l = _mm_add_epi32(a##_l, b##_l); \ + __m128i out##_h = _mm_add_epi32(a##_h, b##_h) + + /* wide sub */ + #define dct_wsub(out, a, b) \ + __m128i out##_l = _mm_sub_epi32(a##_l, b##_l); \ + __m128i out##_h = _mm_sub_epi32(a##_h, b##_h) + + /* butterfly a/b, add bias, then shift by "s" and pack */ + #define dct_bfly32o(out0, out1, a,b,bias,s) \ + { \ + __m128i abiased_l = _mm_add_epi32(a##_l, bias); \ + __m128i abiased_h = _mm_add_epi32(a##_h, bias); \ + dct_wadd(sum, abiased, b); \ + dct_wsub(dif, abiased, b); \ + out0 = _mm_packs_epi32(_mm_srai_epi32(sum_l, s), _mm_srai_epi32(sum_h, s)); \ + out1 = _mm_packs_epi32(_mm_srai_epi32(dif_l, s), _mm_srai_epi32(dif_h, s)); \ + } + + /* 8-bit interleave step (for transposes) */ + #define dct_interleave8(a, b) \ + tmp = a; \ + a = _mm_unpacklo_epi8(a, b); \ + b = _mm_unpackhi_epi8(tmp, b) + + /* 16-bit interleave step (for transposes) */ + #define dct_interleave16(a, b) \ + tmp = a; \ + a = _mm_unpacklo_epi16(a, b); \ + b = _mm_unpackhi_epi16(tmp, b) + + #define dct_pass(bias,shift) \ + { \ + /* even part */ \ + dct_rot(t2e,t3e, row2,row6, rot0_0,rot0_1); \ + __m128i sum04 = _mm_add_epi16(row0, row4); \ + __m128i dif04 = _mm_sub_epi16(row0, row4); \ + dct_widen(t0e, sum04); \ + dct_widen(t1e, dif04); \ + dct_wadd(x0, t0e, t3e); \ + dct_wsub(x3, t0e, t3e); \ + dct_wadd(x1, t1e, t2e); \ + dct_wsub(x2, t1e, t2e); \ + /* odd part */ \ + dct_rot(y0o,y2o, row7,row3, rot2_0,rot2_1); \ + dct_rot(y1o,y3o, row5,row1, rot3_0,rot3_1); \ + __m128i sum17 = _mm_add_epi16(row1, row7); \ + __m128i sum35 = _mm_add_epi16(row3, row5); \ + dct_rot(y4o,y5o, sum17,sum35, rot1_0,rot1_1); \ + dct_wadd(x4, y0o, y4o); \ + dct_wadd(x5, y1o, y5o); \ + dct_wadd(x6, y2o, y5o); \ + dct_wadd(x7, y3o, y4o); \ + dct_bfly32o(row0,row7, x0,x7,bias,shift); \ + dct_bfly32o(row1,row6, x1,x6,bias,shift); \ + dct_bfly32o(row2,row5, x2,x5,bias,shift); \ + dct_bfly32o(row3,row4, x3,x4,bias,shift); \ + } + + __m128i rot0_0 = dct_const(stbi__f2f(0.5411961f), stbi__f2f(0.5411961f) + stbi__f2f(-1.847759065f)); + __m128i rot0_1 = dct_const(stbi__f2f(0.5411961f) + stbi__f2f( 0.765366865f), stbi__f2f(0.5411961f)); + __m128i rot1_0 = dct_const(stbi__f2f(1.175875602f) + stbi__f2f(-0.899976223f), stbi__f2f(1.175875602f)); + __m128i rot1_1 = dct_const(stbi__f2f(1.175875602f), stbi__f2f(1.175875602f) + stbi__f2f(-2.562915447f)); + __m128i rot2_0 = dct_const(stbi__f2f(-1.961570560f) + stbi__f2f( 0.298631336f), stbi__f2f(-1.961570560f)); + __m128i rot2_1 = dct_const(stbi__f2f(-1.961570560f), stbi__f2f(-1.961570560f) + stbi__f2f( 3.072711026f)); + __m128i rot3_0 = dct_const(stbi__f2f(-0.390180644f) + stbi__f2f( 2.053119869f), stbi__f2f(-0.390180644f)); + __m128i rot3_1 = dct_const(stbi__f2f(-0.390180644f), stbi__f2f(-0.390180644f) + stbi__f2f( 1.501321110f)); + + /* rounding biases in column/row passes, see stbi__idct_block for explanation. */ + __m128i bias_0 = _mm_set1_epi32(512); + __m128i bias_1 = _mm_set1_epi32(65536 + (128<<17)); + + /* load */ + row0 = _mm_load_si128((const __m128i *) (data + 0*8)); + row1 = _mm_load_si128((const __m128i *) (data + 1*8)); + row2 = _mm_load_si128((const __m128i *) (data + 2*8)); + row3 = _mm_load_si128((const __m128i *) (data + 3*8)); + row4 = _mm_load_si128((const __m128i *) (data + 4*8)); + row5 = _mm_load_si128((const __m128i *) (data + 5*8)); + row6 = _mm_load_si128((const __m128i *) (data + 6*8)); + row7 = _mm_load_si128((const __m128i *) (data + 7*8)); + + /* column pass */ + dct_pass(bias_0, 10); + + { + /* 16bit 8x8 transpose pass 1 */ + dct_interleave16(row0, row4); + dct_interleave16(row1, row5); + dct_interleave16(row2, row6); + dct_interleave16(row3, row7); + + /* transpose pass 2 */ + dct_interleave16(row0, row2); + dct_interleave16(row1, row3); + dct_interleave16(row4, row6); + dct_interleave16(row5, row7); + + /* transpose pass 3 */ + dct_interleave16(row0, row1); + dct_interleave16(row2, row3); + dct_interleave16(row4, row5); + dct_interleave16(row6, row7); + } + + /* row pass */ + dct_pass(bias_1, 17); + + { + /* pack */ + __m128i p0 = _mm_packus_epi16(row0, row1); // a0a1a2a3...a7b0b1b2b3...b7 + __m128i p1 = _mm_packus_epi16(row2, row3); + __m128i p2 = _mm_packus_epi16(row4, row5); + __m128i p3 = _mm_packus_epi16(row6, row7); + + // 8bit 8x8 transpose pass 1 + dct_interleave8(p0, p2); // a0e0a1e1... + dct_interleave8(p1, p3); // c0g0c1g1... + + // transpose pass 2 + dct_interleave8(p0, p1); // a0c0e0g0... + dct_interleave8(p2, p3); // b0d0f0h0... + + // transpose pass 3 + dct_interleave8(p0, p2); // a0b0c0d0... + dct_interleave8(p1, p3); // a4b4c4d4... + + // store + _mm_storel_epi64((__m128i *) out, p0); out += out_stride; + _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p0, 0x4e)); out += out_stride; + _mm_storel_epi64((__m128i *) out, p2); out += out_stride; + _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p2, 0x4e)); out += out_stride; + _mm_storel_epi64((__m128i *) out, p1); out += out_stride; + _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p1, 0x4e)); out += out_stride; + _mm_storel_epi64((__m128i *) out, p3); out += out_stride; + _mm_storel_epi64((__m128i *) out, _mm_shuffle_epi32(p3, 0x4e)); + } + +#undef dct_const +#undef dct_rot +#undef dct_widen +#undef dct_wadd +#undef dct_wsub +#undef dct_bfly32o +#undef dct_interleave8 +#undef dct_interleave16 +#undef dct_pass +} + +#endif /* STBI_SSE2 */ + +#ifdef STBI_NEON + +/* NEON integer IDCT. should produce bit-identical + * results to the generic C version. */ +static void stbi__idct_simd(uint8_t *out, int out_stride, short data[64]) +{ + int16x8_t row0, row1, row2, row3, row4, row5, row6, row7; + + int16x4_t rot0_0 = vdup_n_s16(stbi__f2f(0.5411961f)); + int16x4_t rot0_1 = vdup_n_s16(stbi__f2f(-1.847759065f)); + int16x4_t rot0_2 = vdup_n_s16(stbi__f2f( 0.765366865f)); + int16x4_t rot1_0 = vdup_n_s16(stbi__f2f( 1.175875602f)); + int16x4_t rot1_1 = vdup_n_s16(stbi__f2f(-0.899976223f)); + int16x4_t rot1_2 = vdup_n_s16(stbi__f2f(-2.562915447f)); + int16x4_t rot2_0 = vdup_n_s16(stbi__f2f(-1.961570560f)); + int16x4_t rot2_1 = vdup_n_s16(stbi__f2f(-0.390180644f)); + int16x4_t rot3_0 = vdup_n_s16(stbi__f2f( 0.298631336f)); + int16x4_t rot3_1 = vdup_n_s16(stbi__f2f( 2.053119869f)); + int16x4_t rot3_2 = vdup_n_s16(stbi__f2f( 3.072711026f)); + int16x4_t rot3_3 = vdup_n_s16(stbi__f2f( 1.501321110f)); + +#define dct_long_mul(out, inq, coeff) \ + int32x4_t out##_l = vmull_s16(vget_low_s16(inq), coeff); \ + int32x4_t out##_h = vmull_s16(vget_high_s16(inq), coeff) + +#define dct_long_mac(out, acc, inq, coeff) \ + int32x4_t out##_l = vmlal_s16(acc##_l, vget_low_s16(inq), coeff); \ + int32x4_t out##_h = vmlal_s16(acc##_h, vget_high_s16(inq), coeff) + +#define dct_widen(out, inq) \ + int32x4_t out##_l = vshll_n_s16(vget_low_s16(inq), 12); \ + int32x4_t out##_h = vshll_n_s16(vget_high_s16(inq), 12) + +/* wide add */ +#define dct_wadd(out, a, b) \ + int32x4_t out##_l = vaddq_s32(a##_l, b##_l); \ + int32x4_t out##_h = vaddq_s32(a##_h, b##_h) + +/* wide sub */ +#define dct_wsub(out, a, b) \ + int32x4_t out##_l = vsubq_s32(a##_l, b##_l); \ + int32x4_t out##_h = vsubq_s32(a##_h, b##_h) + +// butterfly a/b, then shift using "shiftop" by "s" and pack +#define dct_bfly32o(out0,out1, a,b,shiftop,s) \ + { \ + dct_wadd(sum, a, b); \ + dct_wsub(dif, a, b); \ + out0 = vcombine_s16(shiftop(sum_l, s), shiftop(sum_h, s)); \ + out1 = vcombine_s16(shiftop(dif_l, s), shiftop(dif_h, s)); \ + } + +#define dct_pass(shiftop, shift) \ + { \ + /* even part */ \ + int16x8_t sum26 = vaddq_s16(row2, row6); \ + dct_long_mul(p1e, sum26, rot0_0); \ + dct_long_mac(t2e, p1e, row6, rot0_1); \ + dct_long_mac(t3e, p1e, row2, rot0_2); \ + int16x8_t sum04 = vaddq_s16(row0, row4); \ + int16x8_t dif04 = vsubq_s16(row0, row4); \ + dct_widen(t0e, sum04); \ + dct_widen(t1e, dif04); \ + dct_wadd(x0, t0e, t3e); \ + dct_wsub(x3, t0e, t3e); \ + dct_wadd(x1, t1e, t2e); \ + dct_wsub(x2, t1e, t2e); \ + /* odd part */ \ + int16x8_t sum15 = vaddq_s16(row1, row5); \ + int16x8_t sum17 = vaddq_s16(row1, row7); \ + int16x8_t sum35 = vaddq_s16(row3, row5); \ + int16x8_t sum37 = vaddq_s16(row3, row7); \ + int16x8_t sumodd = vaddq_s16(sum17, sum35); \ + dct_long_mul(p5o, sumodd, rot1_0); \ + dct_long_mac(p1o, p5o, sum17, rot1_1); \ + dct_long_mac(p2o, p5o, sum35, rot1_2); \ + dct_long_mul(p3o, sum37, rot2_0); \ + dct_long_mul(p4o, sum15, rot2_1); \ + dct_wadd(sump13o, p1o, p3o); \ + dct_wadd(sump24o, p2o, p4o); \ + dct_wadd(sump23o, p2o, p3o); \ + dct_wadd(sump14o, p1o, p4o); \ + dct_long_mac(x4, sump13o, row7, rot3_0); \ + dct_long_mac(x5, sump24o, row5, rot3_1); \ + dct_long_mac(x6, sump23o, row3, rot3_2); \ + dct_long_mac(x7, sump14o, row1, rot3_3); \ + dct_bfly32o(row0,row7, x0,x7,shiftop,shift); \ + dct_bfly32o(row1,row6, x1,x6,shiftop,shift); \ + dct_bfly32o(row2,row5, x2,x5,shiftop,shift); \ + dct_bfly32o(row3,row4, x3,x4,shiftop,shift); \ + } + + // load + row0 = vld1q_s16(data + 0*8); + row1 = vld1q_s16(data + 1*8); + row2 = vld1q_s16(data + 2*8); + row3 = vld1q_s16(data + 3*8); + row4 = vld1q_s16(data + 4*8); + row5 = vld1q_s16(data + 5*8); + row6 = vld1q_s16(data + 6*8); + row7 = vld1q_s16(data + 7*8); + + // add DC bias + row0 = vaddq_s16(row0, vsetq_lane_s16(1024, vdupq_n_s16(0), 0)); + + // column pass + dct_pass(vrshrn_n_s32, 10); + + // 16bit 8x8 transpose + { +// these three map to a single VTRN.16, VTRN.32, and VSWP, respectively. +// whether compilers actually get this is another story, sadly. +#define dct_trn16(x, y) { int16x8x2_t t = vtrnq_s16(x, y); x = t.val[0]; y = t.val[1]; } +#define dct_trn32(x, y) { int32x4x2_t t = vtrnq_s32(vreinterpretq_s32_s16(x), vreinterpretq_s32_s16(y)); x = vreinterpretq_s16_s32(t.val[0]); y = vreinterpretq_s16_s32(t.val[1]); } +#define dct_trn64(x, y) { int16x8_t x0 = x; int16x8_t y0 = y; x = vcombine_s16(vget_low_s16(x0), vget_low_s16(y0)); y = vcombine_s16(vget_high_s16(x0), vget_high_s16(y0)); } + + // pass 1 + dct_trn16(row0, row1); // a0b0a2b2a4b4a6b6 + dct_trn16(row2, row3); + dct_trn16(row4, row5); + dct_trn16(row6, row7); + + // pass 2 + dct_trn32(row0, row2); // a0b0c0d0a4b4c4d4 + dct_trn32(row1, row3); + dct_trn32(row4, row6); + dct_trn32(row5, row7); + + // pass 3 + dct_trn64(row0, row4); // a0b0c0d0e0f0g0h0 + dct_trn64(row1, row5); + dct_trn64(row2, row6); + dct_trn64(row3, row7); + +#undef dct_trn16 +#undef dct_trn32 +#undef dct_trn64 + } + + // row pass + // vrshrn_n_s32 only supports shifts up to 16, we need + // 17. so do a non-rounding shift of 16 first then follow + // up with a rounding shift by 1. + dct_pass(vshrn_n_s32, 16); + + { + /* pack and round */ + uint8x8_t p0 = vqrshrun_n_s16(row0, 1); + uint8x8_t p1 = vqrshrun_n_s16(row1, 1); + uint8x8_t p2 = vqrshrun_n_s16(row2, 1); + uint8x8_t p3 = vqrshrun_n_s16(row3, 1); + uint8x8_t p4 = vqrshrun_n_s16(row4, 1); + uint8x8_t p5 = vqrshrun_n_s16(row5, 1); + uint8x8_t p6 = vqrshrun_n_s16(row6, 1); + uint8x8_t p7 = vqrshrun_n_s16(row7, 1); + + /* again, these can translate into one instruction, but often don't. */ +#define dct_trn8_8(x, y) { uint8x8x2_t t = vtrn_u8(x, y); x = t.val[0]; y = t.val[1]; } +#define dct_trn8_16(x, y) { uint16x4x2_t t = vtrn_u16(vreinterpret_u16_u8(x), vreinterpret_u16_u8(y)); x = vreinterpret_u8_u16(t.val[0]); y = vreinterpret_u8_u16(t.val[1]); } +#define dct_trn8_32(x, y) { uint32x2x2_t t = vtrn_u32(vreinterpret_u32_u8(x), vreinterpret_u32_u8(y)); x = vreinterpret_u8_u32(t.val[0]); y = vreinterpret_u8_u32(t.val[1]); } + + /* sadly can't use interleaved stores here since we only write + * 8 bytes to each scan line! */ + + /* 8x8 8-bit transpose pass 1 */ + dct_trn8_8(p0, p1); + dct_trn8_8(p2, p3); + dct_trn8_8(p4, p5); + dct_trn8_8(p6, p7); + + /* pass 2 */ + dct_trn8_16(p0, p2); + dct_trn8_16(p1, p3); + dct_trn8_16(p4, p6); + dct_trn8_16(p5, p7); + + /* pass 3 */ + dct_trn8_32(p0, p4); + dct_trn8_32(p1, p5); + dct_trn8_32(p2, p6); + dct_trn8_32(p3, p7); + + /* store */ + vst1_u8(out, p0); out += out_stride; + vst1_u8(out, p1); out += out_stride; + vst1_u8(out, p2); out += out_stride; + vst1_u8(out, p3); out += out_stride; + vst1_u8(out, p4); out += out_stride; + vst1_u8(out, p5); out += out_stride; + vst1_u8(out, p6); out += out_stride; + vst1_u8(out, p7); + +#undef dct_trn8_8 +#undef dct_trn8_16 +#undef dct_trn8_32 + } + +#undef dct_long_mul +#undef dct_long_mac +#undef dct_widen +#undef dct_wadd +#undef dct_wsub +#undef dct_bfly32o +#undef dct_pass +} + +#endif /* STBI_NEON */ + +#define STBI__MARKER_none 0xff +/* if there's a pending marker from the entropy stream, return that + * otherwise, fetch from the stream and get a marker. if there's no + * marker, return 0xff, which is never a valid marker value + */ +static uint8_t stbi__get_marker(stbi__jpeg *j) +{ + uint8_t x; + if (j->marker != STBI__MARKER_none) { x = j->marker; j->marker = STBI__MARKER_none; return x; } + x = stbi__get8(j->s); + if (x != 0xff) return STBI__MARKER_none; + while (x == 0xff) + x = stbi__get8(j->s); + return x; +} + +/* in each scan, we'll have scan_n components, and the order + * of the components is specified by order[] + */ +#define STBI__RESTART(x) ((x) >= 0xd0 && (x) <= 0xd7) + +/* after a restart interval, stbi__jpeg_reset the entropy decoder and + * the dc prediction + */ +static void stbi__jpeg_reset(stbi__jpeg *j) +{ + j->code_bits = 0; + j->code_buffer = 0; + j->nomore = 0; + j->img_comp[0].dc_pred = j->img_comp[1].dc_pred = j->img_comp[2].dc_pred = 0; + j->marker = STBI__MARKER_none; + j->todo = j->restart_interval ? j->restart_interval : 0x7fffffff; + j->eob_run = 0; + // no more than 1<<31 MCUs if no restart_interal? that's plenty safe, + // since we don't even allow 1<<30 pixels +} + +static int stbi__parse_entropy_coded_data(stbi__jpeg *z) +{ + stbi__jpeg_reset(z); + if (!z->progressive) { + if (z->scan_n == 1) { + int i,j; + STBI_SIMD_ALIGN(short, data[64]); + int n = z->order[0]; + // non-interleaved data, we just need to process one block at a time, + // in trivial scanline order + // number of blocks to do just depends on how many actual "pixels" this + // component has, independent of interleaved MCU blocking and such + int w = (z->img_comp[n].x+7) >> 3; + int h = (z->img_comp[n].y+7) >> 3; + for (j=0; j < h; ++j) { + for (i=0; i < w; ++i) { + int ha = z->img_comp[n].ha; + if (!stbi__jpeg_decode_block(z, data, z->huff_dc+z->img_comp[n].hd, z->huff_ac+ha, z->fast_ac[ha], n, z->dequant[z->img_comp[n].tq])) return 0; + z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*j*8+i*8, z->img_comp[n].w2, data); + // every data block is an MCU, so countdown the restart interval + if (--z->todo <= 0) { + if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); + // if it's NOT a restart, then just bail, so we get corrupt data + // rather than no data + if (!STBI__RESTART(z->marker)) return 1; + stbi__jpeg_reset(z); } } } - - if (ctx->rstinterval && !(--rstcount)) - { - rjpeg_byte_align(ctx); - i = rjpeg_get_bits(ctx, 16); - if (((i & 0xFFF8) != 0xFFD0) || ((i & 7) != nextrst)) - JPEG_DECODER_THROW(ctx, RJPEG_SYNTAX_ERROR); - nextrst = (nextrst + 1) & 7; - rstcount = ctx->rstinterval; - - for (i = 0; i < 3; ++i) - ctx->comp[i].dcpred = 0; + return 1; + } else { // interleaved + int i,j,k,x,y; + STBI_SIMD_ALIGN(short, data[64]); + for (j=0; j < z->img_mcu_y; ++j) { + for (i=0; i < z->img_mcu_x; ++i) { + // scan an interleaved mcu... process scan_n components in order + for (k=0; k < z->scan_n; ++k) { + int n = z->order[k]; + // scan out an mcu's worth of this component; that's just determined + // by the basic H and V specified for the component + for (y=0; y < z->img_comp[n].v; ++y) { + for (x=0; x < z->img_comp[n].h; ++x) { + int x2 = (i*z->img_comp[n].h + x)*8; + int y2 = (j*z->img_comp[n].v + y)*8; + int ha = z->img_comp[n].ha; + if (!stbi__jpeg_decode_block(z, data, z->huff_dc+z->img_comp[n].hd, z->huff_ac+ha, z->fast_ac[ha], n, z->dequant[z->img_comp[n].tq])) return 0; + z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*y2+x2, z->img_comp[n].w2, data); + } + } + } + // after all interleaved components, that's an interleaved MCU, + // so now count down the restart interval + if (--z->todo <= 0) { + if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); + if (!STBI__RESTART(z->marker)) return 1; + stbi__jpeg_reset(z); + } + } } + return 1; + } + } else { + if (z->scan_n == 1) { + int i,j; + int n = z->order[0]; + // non-interleaved data, we just need to process one block at a time, + // in trivial scanline order + // number of blocks to do just depends on how many actual "pixels" this + // component has, independent of interleaved MCU blocking and such + int w = (z->img_comp[n].x+7) >> 3; + int h = (z->img_comp[n].y+7) >> 3; + for (j=0; j < h; ++j) { + for (i=0; i < w; ++i) { + short *data = z->img_comp[n].coeff + 64 * (i + j * z->img_comp[n].coeff_w); + if (z->spec_start == 0) { + if (!stbi__jpeg_decode_block_prog_dc(z, data, &z->huff_dc[z->img_comp[n].hd], n)) + return 0; + } else { + int ha = z->img_comp[n].ha; + if (!stbi__jpeg_decode_block_prog_ac(z, data, &z->huff_ac[ha], z->fast_ac[ha])) + return 0; + } + // every data block is an MCU, so countdown the restart interval + if (--z->todo <= 0) { + if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); + if (!STBI__RESTART(z->marker)) return 1; + stbi__jpeg_reset(z); + } + } + } + return 1; + } else { // interleaved + int i,j,k,x,y; + for (j=0; j < z->img_mcu_y; ++j) { + for (i=0; i < z->img_mcu_x; ++i) { + // scan an interleaved mcu... process scan_n components in order + for (k=0; k < z->scan_n; ++k) { + int n = z->order[k]; + // scan out an mcu's worth of this component; that's just determined + // by the basic H and V specified for the component + for (y=0; y < z->img_comp[n].v; ++y) { + for (x=0; x < z->img_comp[n].h; ++x) { + int x2 = (i*z->img_comp[n].h + x); + int y2 = (j*z->img_comp[n].v + y); + short *data = z->img_comp[n].coeff + 64 * (x2 + y2 * z->img_comp[n].coeff_w); + if (!stbi__jpeg_decode_block_prog_dc(z, data, &z->huff_dc[z->img_comp[n].hd], n)) + return 0; + } + } + } + // after all interleaved components, that's an interleaved MCU, + // so now count down the restart interval + if (--z->todo <= 0) { + if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); + if (!STBI__RESTART(z->marker)) return 1; + stbi__jpeg_reset(z); + } + } + } + return 1; } } - - ctx->error = RJPEG_INTERNAL_FINISHED; } -static void rjpeg_upsample_h(struct rjpeg_data *ctx, struct rjpeg_component *c) -{ - int x, y; - unsigned char *lin = NULL; - unsigned char *lout = NULL; - const int xmax = c->width - 3; - uint8_t *out = (uint8_t*)malloc((c->width * c->height) << 1); - if (!out) - JPEG_DECODER_THROW(ctx, RJPEG_OOM); - lin = c->pixels; - lout = out; - for (y = c->height; y; --y) - { - lout[0] = CF(CF2A * lin[0] + CF2B * lin[1]); - lout[1] = CF(CF3X * lin[0] + CF3Y * lin[1] + CF3Z * lin[2]); - lout[2] = CF(CF3A * lin[0] + CF3B * lin[1] + CF3C * lin[2]); - - for (x = 0; x < xmax; ++x) - { - lout[(x << 1) + 3] = CF(CF4A * lin[x] + CF4B * lin[x + 1] + CF4C * lin[x + 2] + CF4D * lin[x + 3]); - lout[(x << 1) + 4] = CF(CF4D * lin[x] + CF4C * lin[x + 1] + CF4B * lin[x + 2] + CF4A * lin[x + 3]); - } - - lin += c->stride; - lout += c->width << 1; - lout[-3] = CF(CF3A * lin[-1] + CF3B * lin[-2] + CF3C * lin[-3]); - lout[-2] = CF(CF3X * lin[-1] + CF3Y * lin[-2] + CF3Z * lin[-3]); - lout[-1] = CF(CF2A * lin[-1] + CF2B * lin[-2]); - } - c->width <<= 1; - c->stride = c->width; - free(c->pixels); - c->pixels = out; -} - -static void rjpeg_upsample_v(struct rjpeg_data *ctx, struct rjpeg_component *c) -{ - int x; - const int w = c->width, s1 = c->stride, s2 = s1 + s1; - unsigned char *out = (unsigned char*)malloc((c->width * c->height) << 1); - - for (x = 0; x < w; ++x) - { - int y; - unsigned char *cin = &c->pixels[x]; - unsigned char *cout = &out[x]; - - *cout = CF(CF2A * cin[0] + CF2B * cin[s1]); - cout += w; - - *cout = CF(CF3X * cin[0] + CF3Y * cin[s1] + CF3Z * cin[s2]); - cout += w; - - *cout = CF(CF3A * cin[0] + CF3B * cin[s1] + CF3C * cin[s2]); - cout += w; - - cin += s1; - for (y = c->height - 3; y; --y) - { - *cout = CF(CF4A * cin[-s1] + CF4B * cin[0] + CF4C * cin[s1] + CF4D * cin[s2]); - cout += w; - *cout = CF(CF4D * cin[-s1] + CF4C * cin[0] + CF4B * cin[s1] + CF4A * cin[s2]); - cout += w; - cin += s1; - } - cin += s1; - *cout = CF(CF3A * cin[0] + CF3B * cin[-s1] + CF3C * cin[-s2]); - cout += w; - *cout = CF(CF3X * cin[0] + CF3Y * cin[-s1] + CF3Z * cin[-s2]); - cout += w; - *cout = CF(CF2A * cin[0] + CF2B * cin[-s1]); - } - - c->height <<= 1; - c->stride = c->width; - - free(c->pixels); - c->pixels = out; -} - - -static void rjpeg_convert(struct rjpeg_data *ctx) +static void stbi__jpeg_dequantize(short *data, uint8_t *dequant) { int i; - struct rjpeg_component *c = NULL; + for (i=0; i < 64; ++i) + data[i] *= dequant[i]; +} - for (i = 0, c = ctx->comp; i < ctx->ncomp; ++i, ++c) - { - while ((c->width < ctx->width) || (c->height < ctx->height)) - { - if (c->width < ctx->width) - rjpeg_upsample_h(ctx, c); - - if (ctx->error) - return; - - if (c->height < ctx->height) - rjpeg_upsample_v(ctx, c); - - if (ctx->error) - return; - } - if ((c->width < ctx->width) || (c->height < ctx->height)) - JPEG_DECODER_THROW(ctx, RJPEG_INTERNAL_ERROR); - } - - if (ctx->ncomp == 3) - { - /* convert to RGB */ - int x, yy; - unsigned char *prgb = ctx->rgb; - const unsigned char *py = ctx->comp[0].pixels; - const unsigned char *pcb = ctx->comp[1].pixels; - const unsigned char *pcr = ctx->comp[2].pixels; - - for (yy = ctx->height; yy; --yy) - { - for (x = 0; x < ctx->width; ++x) - { - int y = py[x] << 8; - int cb = pcb[x] - 128; - int cr = pcr[x] - 128; - *prgb++ = rjpeg_clip((y + 359 * cr + 128) >> 8); - *prgb++ = rjpeg_clip((y - 88 * cb - 183 * cr + 128) >> 8); - *prgb++ = rjpeg_clip((y + 454 * cb + 128) >> 8); +static void stbi__jpeg_finish(stbi__jpeg *z) +{ + if (z->progressive) { + // dequantize and idct the data + int i,j,n; + for (n=0; n < z->s->img_n; ++n) { + int w = (z->img_comp[n].x+7) >> 3; + int h = (z->img_comp[n].y+7) >> 3; + for (j=0; j < h; ++j) { + for (i=0; i < w; ++i) { + short *data = z->img_comp[n].coeff + 64 * (i + j * z->img_comp[n].coeff_w); + stbi__jpeg_dequantize(data, z->dequant[z->img_comp[n].tq]); + z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*j*8+i*8, z->img_comp[n].w2, data); + } } - py += ctx->comp[0].stride; - pcb += ctx->comp[1].stride; - pcr += ctx->comp[2].stride; } } - else if (ctx->comp[0].width != ctx->comp[0].stride) +} + +static int stbi__process_marker(stbi__jpeg *z, int m) +{ + int L; + switch (m) { + case STBI__MARKER_none: // no marker found + return stbi__err("expected marker","Corrupt JPEG"); + + case 0xDD: // DRI - specify restart interval + if (stbi__get16be(z->s) != 4) return stbi__err("bad DRI len","Corrupt JPEG"); + z->restart_interval = stbi__get16be(z->s); + return 1; + + case 0xDB: // DQT - define quantization table + L = stbi__get16be(z->s)-2; + while (L > 0) { + int q = stbi__get8(z->s); + int p = q >> 4; + int t = q & 15,i; + if (p != 0) return stbi__err("bad DQT type","Corrupt JPEG"); + if (t > 3) return stbi__err("bad DQT table","Corrupt JPEG"); + for (i=0; i < 64; ++i) + z->dequant[t][stbi__jpeg_dezigzag[i]] = stbi__get8(z->s); + L -= 65; + } + return L==0; + + case 0xC4: // DHT - define huffman table + L = stbi__get16be(z->s)-2; + while (L > 0) { + uint8_t *v; + int sizes[16],i,n=0; + int q = stbi__get8(z->s); + int tc = q >> 4; + int th = q & 15; + if (tc > 1 || th > 3) return stbi__err("bad DHT header","Corrupt JPEG"); + for (i=0; i < 16; ++i) { + sizes[i] = stbi__get8(z->s); + n += sizes[i]; + } + L -= 17; + if (tc == 0) { + if (!stbi__build_huffman(z->huff_dc+th, sizes)) return 0; + v = z->huff_dc[th].values; + } else { + if (!stbi__build_huffman(z->huff_ac+th, sizes)) return 0; + v = z->huff_ac[th].values; + } + for (i=0; i < n; ++i) + v[i] = stbi__get8(z->s); + if (tc != 0) + stbi__build_fast_ac(z->fast_ac[th], z->huff_ac + th); + L -= n; + } + return L==0; + } + // check for comment block or APP blocks + if ((m >= 0xE0 && m <= 0xEF) || m == 0xFE) { + stbi__skip(z->s, stbi__get16be(z->s)-2); + return 1; + } + return 0; +} + +// after we see SOS +static int stbi__process_scan_header(stbi__jpeg *z) +{ + int i; + int Ls = stbi__get16be(z->s); + + z->scan_n = stbi__get8(z->s); + + if (z->scan_n < 1 || z->scan_n > 4 || z->scan_n > (int) z->s->img_n) + return stbi__err("bad SOS component count","Corrupt JPEG"); + if (Ls != 6+2*z->scan_n) + return stbi__err("bad SOS len","Corrupt JPEG"); + + for (i=0; i < z->scan_n; ++i) { - /* grayscale -> only remove stride */ - int y; - unsigned char *pin = &ctx->comp[0].pixels[ctx->comp[0].stride]; - unsigned char *pout = &ctx->comp[0].pixels[ctx->comp[0].width]; + int id = stbi__get8(z->s), which; + int q = stbi__get8(z->s); - for (y = ctx->comp[0].height - 1; y; --y) - { - memcpy(pout, pin, ctx->comp[0].width); - pin += ctx->comp[0].stride; - pout += ctx->comp[0].width; - } - ctx->comp[0].stride = ctx->comp[0].width; + for (which = 0; which < z->s->img_n; ++which) + if (z->img_comp[which].id == id) + break; + if (which == z->s->img_n) + return 0; /* no match */ + + z->img_comp[which].hd = q >> 4; if (z->img_comp[which].hd > 3) + return stbi__err("bad DC huff","Corrupt JPEG"); + z->img_comp[which].ha = q & 15; if (z->img_comp[which].ha > 3) + return stbi__err("bad AC huff","Corrupt JPEG"); + z->order[i] = which; } -} - -enum rjpeg_decode_result rjpeg_decode( - struct rjpeg_data *ctx, - const unsigned char* jpeg, - const int size) -{ - ctx->pos = (const unsigned char*) jpeg; - ctx->size = size & 0x7FFFFFFF; - - if (ctx->size < 2) - return RJPEG_NOT_A_FILE; - if ((ctx->pos[0] ^ 0xFF) | (ctx->pos[1] ^ 0xD8)) - return RJPEG_NOT_A_FILE; - - rjpeg_skip(ctx, 2); - - while (!ctx->error) { - if ((ctx->size < 2) || (ctx->pos[0] != 0xFF)) - return RJPEG_SYNTAX_ERROR; - - rjpeg_skip(ctx, 2); - - switch (ctx->pos[-1]) - { - case RJPEG_DECODE_SOF: - rjpeg_decode_sof(ctx); - break; - case RJPEG_DECODE_DHT: - rjpeg_decode_dht(ctx); - break; - case RJPEG_DECODE_DQT: - rjpeg_decode_dqt(ctx); - break; - case RJPEG_DECODE_DRI: - rjpeg_decode_dri(ctx); - break; - case RJPEG_DECODE_SCAN: - rjpeg_decode_scan(ctx); - break; - case RJPEG_DECODE_SKIP_MARKER: - rjpeg_skip_marker(ctx); - break; - default: - if ((ctx->pos[-1] & 0xF0) != 0xE0) - return RJPEG_UNSUPPORTED; - rjpeg_skip_marker(ctx); - break; + int aa; + z->spec_start = stbi__get8(z->s); + z->spec_end = stbi__get8(z->s); /* should be 63, but might be 0 */ + aa = stbi__get8(z->s); + z->succ_high = (aa >> 4); + z->succ_low = (aa & 15); + if (z->progressive) { + if (z->spec_start > 63 || z->spec_end > 63 || z->spec_start > z->spec_end || z->succ_high > 13 || z->succ_low > 13) + return stbi__err("bad SOS", "Corrupt JPEG"); + } else { + if (z->spec_start != 0) return stbi__err("bad SOS","Corrupt JPEG"); + if (z->succ_high != 0 || z->succ_low != 0) return stbi__err("bad SOS","Corrupt JPEG"); + z->spec_end = 63; } } - if (ctx->error != RJPEG_INTERNAL_FINISHED) - return ctx->error; - ctx->error = RJPEG_OK; - rjpeg_convert(ctx); - - return RJPEG_OK; + return 1; } -struct rjpeg_data *rjpeg_new(const uint8_t* data, size_t size) +static int stbi__process_frame_header(stbi__jpeg *z, int scan) { - char temp[64] = { 0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, - 11, 4, 5, 12, 19, 26, 33, 40, 48, 41, 34, 27, 20, 13, 6, 7, 14, 21, 28, 35, - 42, 49, 56, 57, 50, 43, 36, 29, 22, 15, 23, 30, 37, 44, 51, 58, 59, 52, 45, - 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63 }; - struct rjpeg_data *ctx = (struct rjpeg_data*)calloc(1, sizeof(*ctx)); + stbi__context *s = z->s; + int Lf,p,i,q, h_max=1,v_max=1,c; + Lf = stbi__get16be(s); if (Lf < 11) return stbi__err("bad SOF len","Corrupt JPEG"); // JPEG + p = stbi__get8(s); if (p != 8) return stbi__err("only 8-bit","JPEG format not supported: 8-bit only"); // JPEG baseline + s->img_y = stbi__get16be(s); if (s->img_y == 0) return stbi__err("no header height", "JPEG format not supported: delayed height"); // Legal, but we don't handle it--but neither does IJG + s->img_x = stbi__get16be(s); if (s->img_x == 0) return stbi__err("0 width","Corrupt JPEG"); // JPEG requires + c = stbi__get8(s); + if (c != 3 && c != 1) return stbi__err("bad component count","Corrupt JPEG"); // JFIF requires + s->img_n = c; + for (i=0; i < c; ++i) { + z->img_comp[i].data = NULL; + z->img_comp[i].linebuf = NULL; + } - if (!ctx) - return NULL; + if (Lf != 8+3*s->img_n) return stbi__err("bad SOF len","Corrupt JPEG"); - memcpy(ctx->ZZ, temp, sizeof(ctx->ZZ)); - rjpeg_decode(ctx, data, size); + for (i=0; i < s->img_n; ++i) { + z->img_comp[i].id = stbi__get8(s); + if (z->img_comp[i].id != i+1) // JFIF requires + if (z->img_comp[i].id != i) // some version of jpegtran outputs non-JFIF-compliant files! + return stbi__err("bad component ID","Corrupt JPEG"); + q = stbi__get8(s); + z->img_comp[i].h = (q >> 4); if (!z->img_comp[i].h || z->img_comp[i].h > 4) return stbi__err("bad H","Corrupt JPEG"); + z->img_comp[i].v = q & 15; if (!z->img_comp[i].v || z->img_comp[i].v > 4) return stbi__err("bad V","Corrupt JPEG"); + z->img_comp[i].tq = stbi__get8(s); if (z->img_comp[i].tq > 3) return stbi__err("bad TQ","Corrupt JPEG"); + } - return ctx; + if (scan != STBI__SCAN_load) return 1; + + if ((1 << 30) / s->img_x / s->img_n < s->img_y) return stbi__err("too large", "Image too large to decode"); + + for (i=0; i < s->img_n; ++i) { + if (z->img_comp[i].h > h_max) h_max = z->img_comp[i].h; + if (z->img_comp[i].v > v_max) v_max = z->img_comp[i].v; + } + + // compute interleaved mcu info + z->img_h_max = h_max; + z->img_v_max = v_max; + z->img_mcu_w = h_max * 8; + z->img_mcu_h = v_max * 8; + z->img_mcu_x = (s->img_x + z->img_mcu_w-1) / z->img_mcu_w; + z->img_mcu_y = (s->img_y + z->img_mcu_h-1) / z->img_mcu_h; + + for (i=0; i < s->img_n; ++i) { + // number of effective pixels (e.g. for non-interleaved MCU) + z->img_comp[i].x = (s->img_x * z->img_comp[i].h + h_max-1) / h_max; + z->img_comp[i].y = (s->img_y * z->img_comp[i].v + v_max-1) / v_max; + // to simplify generation, we'll allocate enough memory to decode + // the bogus oversized data from using interleaved MCUs and their + // big blocks (e.g. a 16x16 iMCU on an image of width 33); we won't + // discard the extra data until colorspace conversion + z->img_comp[i].w2 = z->img_mcu_x * z->img_comp[i].h * 8; + z->img_comp[i].h2 = z->img_mcu_y * z->img_comp[i].v * 8; + z->img_comp[i].raw_data = malloc(z->img_comp[i].w2 * z->img_comp[i].h2+15); + + if (z->img_comp[i].raw_data == NULL) { + for(--i; i >= 0; --i) { + free(z->img_comp[i].raw_data); + z->img_comp[i].data = NULL; + } + return stbi__err("outofmem", "Out of memory"); + } + // align blocks for idct using mmx/sse + z->img_comp[i].data = (uint8_t*) (((size_t) z->img_comp[i].raw_data + 15) & ~15); + z->img_comp[i].linebuf = NULL; + if (z->progressive) { + z->img_comp[i].coeff_w = (z->img_comp[i].w2 + 7) >> 3; + z->img_comp[i].coeff_h = (z->img_comp[i].h2 + 7) >> 3; + z->img_comp[i].raw_coeff = malloc(z->img_comp[i].coeff_w * z->img_comp[i].coeff_h * 64 * sizeof(short) + 15); + z->img_comp[i].coeff = (short*) (((size_t) z->img_comp[i].raw_coeff + 15) & ~15); + } else { + z->img_comp[i].coeff = 0; + z->img_comp[i].raw_coeff = 0; + } + } + + return 1; } -static void rjpeg_free(struct rjpeg_data *ctx) +// use comparisons since in some cases we handle more than one case (e.g. SOF) +#define stbi__DNL(x) ((x) == 0xdc) +#define stbi__SOI(x) ((x) == 0xd8) +#define stbi__EOI(x) ((x) == 0xd9) +#define stbi__SOF(x) ((x) == 0xc0 || (x) == 0xc1 || (x) == 0xc2) +#define stbi__SOS(x) ((x) == 0xda) + +#define stbi__SOF_progressive(x) ((x) == 0xc2) + +static int stbi__decode_jpeg_header(stbi__jpeg *z, int scan) { - int i; - - for (i = 0; i < 3; ++i) - if (ctx->comp[i].pixels) - free((void*) ctx->comp[i].pixels); - if (ctx->rgb) - free((void*)ctx->rgb); + int m; + z->marker = STBI__MARKER_none; // initialize cached marker to empty + m = stbi__get_marker(z); + if (!stbi__SOI(m)) return stbi__err("no SOI","Corrupt JPEG"); + if (scan == STBI__SCAN_type) return 1; + m = stbi__get_marker(z); + while (!stbi__SOF(m)) { + if (!stbi__process_marker(z,m)) return 0; + m = stbi__get_marker(z); + while (m == STBI__MARKER_none) { + // some files have extra padding after their blocks, so ok, we'll scan + if (stbi__at_eof(z->s)) return stbi__err("no SOF", "Corrupt JPEG"); + m = stbi__get_marker(z); + } + } + z->progressive = stbi__SOF_progressive(m); + if (!stbi__process_frame_header(z, scan)) return 0; + return 1; } -bool rjpeg_image_load(uint8_t *buf, void *data, size_t size, +// decode image to YCbCr format +static int stbi__decode_jpeg_image(stbi__jpeg *j) +{ + int m; + for (m = 0; m < 4; m++) { + j->img_comp[m].raw_data = NULL; + j->img_comp[m].raw_coeff = NULL; + } + j->restart_interval = 0; + if (!stbi__decode_jpeg_header(j, STBI__SCAN_load)) return 0; + m = stbi__get_marker(j); + while (!stbi__EOI(m)) { + if (stbi__SOS(m)) { + if (!stbi__process_scan_header(j)) return 0; + if (!stbi__parse_entropy_coded_data(j)) return 0; + if (j->marker == STBI__MARKER_none ) { + // handle 0s at the end of image data from IP Kamera 9060 + while (!stbi__at_eof(j->s)) { + int x = stbi__get8(j->s); + if (x == 255) { + j->marker = stbi__get8(j->s); + break; + } else if (x != 0) { + return stbi__err("junk before marker", "Corrupt JPEG"); + } + } + // if we reach eof without hitting a marker, stbi__get_marker() below will fail and we'll eventually return 0 + } + } else { + if (!stbi__process_marker(j, m)) return 0; + } + m = stbi__get_marker(j); + } + if (j->progressive) + stbi__jpeg_finish(j); + return 1; +} + +// static jfif-centered resampling (across block boundaries) + +typedef uint8_t *(*resample_row_func)(uint8_t *out, uint8_t *in0, uint8_t *in1, + int w, int hs); + +#define stbi__div4(x) ((uint8_t) ((x) >> 2)) + +static uint8_t *resample_row_1(uint8_t *out, uint8_t *in_near, uint8_t *in_far, int w, int hs) +{ + STBI_NOTUSED(out); + STBI_NOTUSED(in_far); + STBI_NOTUSED(w); + STBI_NOTUSED(hs); + return in_near; +} + +static uint8_t* stbi__resample_row_v_2(uint8_t *out, uint8_t *in_near, uint8_t *in_far, int w, int hs) +{ + // need to generate two samples vertically for every one in input + int i; + STBI_NOTUSED(hs); + for (i=0; i < w; ++i) + out[i] = stbi__div4(3*in_near[i] + in_far[i] + 2); + return out; +} + +static uint8_t* stbi__resample_row_h_2(uint8_t *out, uint8_t *in_near, uint8_t *in_far, int w, int hs) +{ + // need to generate two samples horizontally for every one in input + int i; + uint8_t *input = in_near; + + if (w == 1) { + // if only one sample, can't do any interpolation + out[0] = out[1] = input[0]; + return out; + } + + out[0] = input[0]; + out[1] = stbi__div4(input[0]*3 + input[1] + 2); + for (i=1; i < w-1; ++i) { + int n = 3*input[i]+2; + out[i*2+0] = stbi__div4(n+input[i-1]); + out[i*2+1] = stbi__div4(n+input[i+1]); + } + out[i*2+0] = stbi__div4(input[w-2]*3 + input[w-1] + 2); + out[i*2+1] = input[w-1]; + + STBI_NOTUSED(in_far); + STBI_NOTUSED(hs); + + return out; +} + +#define stbi__div16(x) ((uint8_t) ((x) >> 4)) + +static uint8_t *stbi__resample_row_hv_2(uint8_t *out, uint8_t *in_near, uint8_t *in_far, int w, int hs) +{ + // need to generate 2x2 samples for every one in input + int i,t0,t1; + if (w == 1) { + out[0] = out[1] = stbi__div4(3*in_near[0] + in_far[0] + 2); + return out; + } + + t1 = 3*in_near[0] + in_far[0]; + out[0] = stbi__div4(t1+2); + for (i=1; i < w; ++i) { + t0 = t1; + t1 = 3*in_near[i]+in_far[i]; + out[i*2-1] = stbi__div16(3*t0 + t1 + 8); + out[i*2 ] = stbi__div16(3*t1 + t0 + 8); + } + out[w*2-1] = stbi__div4(t1+2); + + STBI_NOTUSED(hs); + + return out; +} + +#if defined(STBI_SSE2) || defined(STBI_NEON) +static uint8_t *stbi__resample_row_hv_2_simd(uint8_t *out, uint8_t *in_near, uint8_t *in_far, int w, int hs) +{ + /* need to generate 2x2 samples for every one in input */ + int i=0,t0,t1; + + if (w == 1) { + out[0] = out[1] = stbi__div4(3*in_near[0] + in_far[0] + 2); + return out; + } + + t1 = 3*in_near[0] + in_far[0]; + /* process groups of 8 pixels for as long as we can. + * note we can't handle the last pixel in a row in this loop + * because we need to handle the filter boundary conditions. + */ + for (; i < ((w-1) & ~7); i += 8) + { +#if defined(STBI_SSE2) + /* load and perform the vertical filtering pass + * this uses 3*x + y = 4*x + (y - x) */ + __m128i zero = _mm_setzero_si128(); + __m128i farb = _mm_loadl_epi64((__m128i *) (in_far + i)); + __m128i nearb = _mm_loadl_epi64((__m128i *) (in_near + i)); + __m128i farw = _mm_unpacklo_epi8(farb, zero); + __m128i nearw = _mm_unpacklo_epi8(nearb, zero); + __m128i diff = _mm_sub_epi16(farw, nearw); + __m128i nears = _mm_slli_epi16(nearw, 2); + __m128i curr = _mm_add_epi16(nears, diff); /* current row */ + + /* horizontal filter works the same based on shifted vers of current + * row. "prev" is current row shifted right by 1 pixel; we need to + * insert the previous pixel value (from t1). + * "next" is current row shifted left by 1 pixel, with first pixel + * of next block of 8 pixels added in. + */ + __m128i prv0 = _mm_slli_si128(curr, 2); + __m128i nxt0 = _mm_srli_si128(curr, 2); + __m128i prev = _mm_insert_epi16(prv0, t1, 0); + __m128i next = _mm_insert_epi16(nxt0, 3*in_near[i+8] + in_far[i+8], 7); + + /* horizontal filter, polyphase implementation since it's convenient: + * even pixels = 3*cur + prev = cur*4 + (prev - cur) + * odd pixels = 3*cur + next = cur*4 + (next - cur) + * note the shared term. */ + __m128i bias = _mm_set1_epi16(8); + __m128i curs = _mm_slli_epi16(curr, 2); + __m128i prvd = _mm_sub_epi16(prev, curr); + __m128i nxtd = _mm_sub_epi16(next, curr); + __m128i curb = _mm_add_epi16(curs, bias); + __m128i even = _mm_add_epi16(prvd, curb); + __m128i odd = _mm_add_epi16(nxtd, curb); + + /* interleave even and odd pixels, then undo scaling. */ + __m128i int0 = _mm_unpacklo_epi16(even, odd); + __m128i int1 = _mm_unpackhi_epi16(even, odd); + __m128i de0 = _mm_srli_epi16(int0, 4); + __m128i de1 = _mm_srli_epi16(int1, 4); + + /* pack and write output */ + __m128i outv = _mm_packus_epi16(de0, de1); + _mm_storeu_si128((__m128i *) (out + i*2), outv); +#elif defined(STBI_NEON) + // load and perform the vertical filtering pass + // this uses 3*x + y = 4*x + (y - x) + uint8x8_t farb = vld1_u8(in_far + i); + uint8x8_t nearb = vld1_u8(in_near + i); + int16x8_t diff = vreinterpretq_s16_u16(vsubl_u8(farb, nearb)); + int16x8_t nears = vreinterpretq_s16_u16(vshll_n_u8(nearb, 2)); + int16x8_t curr = vaddq_s16(nears, diff); // current row + + // horizontal filter works the same based on shifted vers of current + // row. "prev" is current row shifted right by 1 pixel; we need to + // insert the previous pixel value (from t1). + // "next" is current row shifted left by 1 pixel, with first pixel + // of next block of 8 pixels added in. + int16x8_t prv0 = vextq_s16(curr, curr, 7); + int16x8_t nxt0 = vextq_s16(curr, curr, 1); + int16x8_t prev = vsetq_lane_s16(t1, prv0, 0); + int16x8_t next = vsetq_lane_s16(3*in_near[i+8] + in_far[i+8], nxt0, 7); + + /* horizontal filter, polyphase implementation since it's convenient: + * even pixels = 3*cur + prev = cur*4 + (prev - cur) + * odd pixels = 3*cur + next = cur*4 + (next - cur) + * note the shared term. + */ + int16x8_t curs = vshlq_n_s16(curr, 2); + int16x8_t prvd = vsubq_s16(prev, curr); + int16x8_t nxtd = vsubq_s16(next, curr); + int16x8_t even = vaddq_s16(curs, prvd); + int16x8_t odd = vaddq_s16(curs, nxtd); + + /* undo scaling and round, then store with even/odd phases interleaved */ + uint8x8x2_t o; + o.val[0] = vqrshrun_n_s16(even, 4); + o.val[1] = vqrshrun_n_s16(odd, 4); + vst2_u8(out + i*2, o); +#endif + + /* "previous" value for next iteration */ + t1 = 3*in_near[i+7] + in_far[i+7]; + } + + t0 = t1; + t1 = 3*in_near[i] + in_far[i]; + out[i*2] = stbi__div16(3*t1 + t0 + 8); + + for (++i; i < w; ++i) { + t0 = t1; + t1 = 3*in_near[i]+in_far[i]; + out[i*2-1] = stbi__div16(3*t0 + t1 + 8); + out[i*2 ] = stbi__div16(3*t1 + t0 + 8); + } + out[w*2-1] = stbi__div4(t1+2); + + STBI_NOTUSED(hs); + + return out; +} +#endif + +static uint8_t *stbi__resample_row_generic(uint8_t *out, uint8_t *in_near, uint8_t *in_far, int w, int hs) +{ + /* resample with nearest-neighbor */ + int i,j; + STBI_NOTUSED(in_far); + for (i=0; i < w; ++i) + for (j=0; j < hs; ++j) + out[i*hs+j] = in_near[i]; + return out; +} + +#ifdef STBI_JPEG_OLD +/* this is the same YCbCr-to-RGB calculation that stb_image has used + * historically before the algorithm changes in 1.49 */ +#define float2fixed(x) ((int) ((x) * 65536 + 0.5)) +static void stbi__YCbCr_to_RGB_row(uint8_t *out, const uint8_t *y, const uint8_t *pcb, const uint8_t *pcr, int count, int step) +{ + int i; + for (i=0; i < count; ++i) { + int y_fixed = (y[i] << 16) + 32768; // rounding + int r,g,b; + int cr = pcr[i] - 128; + int cb = pcb[i] - 128; + r = y_fixed + cr*float2fixed(1.40200f); + g = y_fixed - cr*float2fixed(0.71414f) - cb*float2fixed(0.34414f); + b = y_fixed + cb*float2fixed(1.77200f); + r >>= 16; + g >>= 16; + b >>= 16; + if ((unsigned) r > 255) { if (r < 0) r = 0; else r = 255; } + if ((unsigned) g > 255) { if (g < 0) g = 0; else g = 255; } + if ((unsigned) b > 255) { if (b < 0) b = 0; else b = 255; } + out[0] = (uint8_t)r; + out[1] = (uint8_t)g; + out[2] = (uint8_t)b; + out[3] = 255; + out += step; + } +} +#else +/* this is a reduced-precision calculation of YCbCr-to-RGB introduced + * to make sure the code produces the same results in both SIMD and scalar */ +#define float2fixed(x) (((int) ((x) * 4096.0f + 0.5f)) << 8) +static void stbi__YCbCr_to_RGB_row(uint8_t *out, const uint8_t *y, const uint8_t *pcb, const uint8_t *pcr, int count, int step) +{ + int i; + for (i=0; i < count; ++i) { + int y_fixed = (y[i] << 20) + (1<<19); /* rounding */ + int r,g,b; + int cr = pcr[i] - 128; + int cb = pcb[i] - 128; + r = y_fixed + cr* float2fixed(1.40200f); + g = y_fixed + (cr*-float2fixed(0.71414f)) + ((cb*-float2fixed(0.34414f)) & 0xffff0000); + b = y_fixed + cb* float2fixed(1.77200f); + r >>= 20; + g >>= 20; + b >>= 20; + if ((unsigned) r > 255) { if (r < 0) r = 0; else r = 255; } + if ((unsigned) g > 255) { if (g < 0) g = 0; else g = 255; } + if ((unsigned) b > 255) { if (b < 0) b = 0; else b = 255; } + out[0] = (uint8_t)r; + out[1] = (uint8_t)g; + out[2] = (uint8_t)b; + out[3] = 255; + out += step; + } +} +#endif + +#if defined(STBI_SSE2) || defined(STBI_NEON) +static void stbi__YCbCr_to_RGB_simd(uint8_t *out, const uint8_t *y, const uint8_t *pcb, const uint8_t *pcr, int count, int step) +{ + int i = 0; + +#ifdef STBI_SSE2 + /* step == 3 is pretty ugly on the final interleave, and i'm not convinced + * it's useful in practice (you wouldn't use it for textures, for example). + * so just accelerate step == 4 case. + */ + if (step == 4) + { + /* this is a fairly straightforward implementation and not super-optimized. */ + __m128i signflip = _mm_set1_epi8(-0x80); + __m128i cr_const0 = _mm_set1_epi16( (short) ( 1.40200f*4096.0f+0.5f)); + __m128i cr_const1 = _mm_set1_epi16( - (short) ( 0.71414f*4096.0f+0.5f)); + __m128i cb_const0 = _mm_set1_epi16( - (short) ( 0.34414f*4096.0f+0.5f)); + __m128i cb_const1 = _mm_set1_epi16( (short) ( 1.77200f*4096.0f+0.5f)); + __m128i y_bias = _mm_set1_epi8((char) (unsigned char) 128); + __m128i xw = _mm_set1_epi16(255); /* alpha channel */ + + for (; i+7 < count; i += 8) + { + // load + __m128i y_bytes = _mm_loadl_epi64((__m128i *) (y+i)); + __m128i cr_bytes = _mm_loadl_epi64((__m128i *) (pcr+i)); + __m128i cb_bytes = _mm_loadl_epi64((__m128i *) (pcb+i)); + __m128i cr_biased = _mm_xor_si128(cr_bytes, signflip); // -128 + __m128i cb_biased = _mm_xor_si128(cb_bytes, signflip); // -128 + + // unpack to short (and left-shift cr, cb by 8) + __m128i yw = _mm_unpacklo_epi8(y_bias, y_bytes); + __m128i crw = _mm_unpacklo_epi8(_mm_setzero_si128(), cr_biased); + __m128i cbw = _mm_unpacklo_epi8(_mm_setzero_si128(), cb_biased); + + // color transform + __m128i yws = _mm_srli_epi16(yw, 4); + __m128i cr0 = _mm_mulhi_epi16(cr_const0, crw); + __m128i cb0 = _mm_mulhi_epi16(cb_const0, cbw); + __m128i cb1 = _mm_mulhi_epi16(cbw, cb_const1); + __m128i cr1 = _mm_mulhi_epi16(crw, cr_const1); + __m128i rws = _mm_add_epi16(cr0, yws); + __m128i gwt = _mm_add_epi16(cb0, yws); + __m128i bws = _mm_add_epi16(yws, cb1); + __m128i gws = _mm_add_epi16(gwt, cr1); + + // descale + __m128i rw = _mm_srai_epi16(rws, 4); + __m128i bw = _mm_srai_epi16(bws, 4); + __m128i gw = _mm_srai_epi16(gws, 4); + + // back to byte, set up for transpose + __m128i brb = _mm_packus_epi16(rw, bw); + __m128i gxb = _mm_packus_epi16(gw, xw); + + // transpose to interleave channels + __m128i t0 = _mm_unpacklo_epi8(brb, gxb); + __m128i t1 = _mm_unpackhi_epi8(brb, gxb); + __m128i o0 = _mm_unpacklo_epi16(t0, t1); + __m128i o1 = _mm_unpackhi_epi16(t0, t1); + + // store + _mm_storeu_si128((__m128i *) (out + 0), o0); + _mm_storeu_si128((__m128i *) (out + 16), o1); + out += 32; + } + } +#endif + +#ifdef STBI_NEON + // in this version, step=3 support would be easy to add. but is there demand? + if (step == 4) { + // this is a fairly straightforward implementation and not super-optimized. + uint8x8_t signflip = vdup_n_u8(0x80); + int16x8_t cr_const0 = vdupq_n_s16( (short) ( 1.40200f*4096.0f+0.5f)); + int16x8_t cr_const1 = vdupq_n_s16( - (short) ( 0.71414f*4096.0f+0.5f)); + int16x8_t cb_const0 = vdupq_n_s16( - (short) ( 0.34414f*4096.0f+0.5f)); + int16x8_t cb_const1 = vdupq_n_s16( (short) ( 1.77200f*4096.0f+0.5f)); + + for (; i+7 < count; i += 8) { + // load + uint8x8_t y_bytes = vld1_u8(y + i); + uint8x8_t cr_bytes = vld1_u8(pcr + i); + uint8x8_t cb_bytes = vld1_u8(pcb + i); + int8x8_t cr_biased = vreinterpret_s8_u8(vsub_u8(cr_bytes, signflip)); + int8x8_t cb_biased = vreinterpret_s8_u8(vsub_u8(cb_bytes, signflip)); + + // expand to s16 + int16x8_t yws = vreinterpretq_s16_u16(vshll_n_u8(y_bytes, 4)); + int16x8_t crw = vshll_n_s8(cr_biased, 7); + int16x8_t cbw = vshll_n_s8(cb_biased, 7); + + // color transform + int16x8_t cr0 = vqdmulhq_s16(crw, cr_const0); + int16x8_t cb0 = vqdmulhq_s16(cbw, cb_const0); + int16x8_t cr1 = vqdmulhq_s16(crw, cr_const1); + int16x8_t cb1 = vqdmulhq_s16(cbw, cb_const1); + int16x8_t rws = vaddq_s16(yws, cr0); + int16x8_t gws = vaddq_s16(vaddq_s16(yws, cb0), cr1); + int16x8_t bws = vaddq_s16(yws, cb1); + + // undo scaling, round, convert to byte + uint8x8x4_t o; + o.val[0] = vqrshrun_n_s16(rws, 4); + o.val[1] = vqrshrun_n_s16(gws, 4); + o.val[2] = vqrshrun_n_s16(bws, 4); + o.val[3] = vdup_n_u8(255); + + // store, interleaving r/g/b/a + vst4_u8(out, o); + out += 8*4; + } + } +#endif + + for (; i < count; ++i) { + int y_fixed = (y[i] << 20) + (1<<19); // rounding + int r,g,b; + int cr = pcr[i] - 128; + int cb = pcb[i] - 128; + r = y_fixed + cr* float2fixed(1.40200f); + g = y_fixed + cr*-float2fixed(0.71414f) + ((cb*-float2fixed(0.34414f)) & 0xffff0000); + b = y_fixed + cb* float2fixed(1.77200f); + r >>= 20; + g >>= 20; + b >>= 20; + if ((unsigned) r > 255) { if (r < 0) r = 0; else r = 255; } + if ((unsigned) g > 255) { if (g < 0) g = 0; else g = 255; } + if ((unsigned) b > 255) { if (b < 0) b = 0; else b = 255; } + out[0] = (uint8_t)r; + out[1] = (uint8_t)g; + out[2] = (uint8_t)b; + out[3] = 255; + out += step; + } +} +#endif + +/* set up the kernels */ +static void stbi__setup_jpeg(stbi__jpeg *j) +{ + j->idct_block_kernel = stbi__idct_block; + j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_row; + j->resample_row_hv_2_kernel = stbi__resample_row_hv_2; + +#ifdef STBI_SSE2 + if (stbi__sse2_available()) { + j->idct_block_kernel = stbi__idct_simd; + #ifndef STBI_JPEG_OLD + j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_simd; + #endif + j->resample_row_hv_2_kernel = stbi__resample_row_hv_2_simd; + } +#endif + +#ifdef STBI_NEON + j->idct_block_kernel = stbi__idct_simd; + #ifndef STBI_JPEG_OLD + j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_simd; + #endif + j->resample_row_hv_2_kernel = stbi__resample_row_hv_2_simd; +#endif +} + +/* clean up the temporary component buffers */ +static void stbi__cleanup_jpeg(stbi__jpeg *j) +{ + int i; + for (i=0; i < j->s->img_n; ++i) { + if (j->img_comp[i].raw_data) { + free(j->img_comp[i].raw_data); + j->img_comp[i].raw_data = NULL; + j->img_comp[i].data = NULL; + } + if (j->img_comp[i].raw_coeff) { + free(j->img_comp[i].raw_coeff); + j->img_comp[i].raw_coeff = 0; + j->img_comp[i].coeff = 0; + } + if (j->img_comp[i].linebuf) { + free(j->img_comp[i].linebuf); + j->img_comp[i].linebuf = NULL; + } + } +} + +typedef struct +{ + resample_row_func resample; + uint8_t *line0,*line1; + int hs,vs; // expansion factor in each axis + int w_lores; // horizontal pixels pre-expansion + int ystep; // how far through vertical expansion we are + int ypos; // which pre-expansion row we're on +} stbi__resample; + +static uint8_t *load_jpeg_image(stbi__jpeg *z, int *out_x, int *out_y, int *comp, int req_comp) +{ + int n, decode_n; + z->s->img_n = 0; // make stbi__cleanup_jpeg safe + + // validate req_comp + if (req_comp < 0 || req_comp > 4) return stbi__errpuc("bad req_comp", "Internal error"); + + // load a jpeg image from whichever source, but leave in YCbCr format + if (!stbi__decode_jpeg_image(z)) { stbi__cleanup_jpeg(z); return NULL; } + + // determine actual number of components to generate + n = req_comp ? req_comp : z->s->img_n; + + if (z->s->img_n == 3 && n < 3) + decode_n = 1; + else + decode_n = z->s->img_n; + + // resample and color-convert + { + int k; + unsigned int i,j; + uint8_t *output; + uint8_t *coutput[4]; + + stbi__resample res_comp[4]; + + for (k=0; k < decode_n; ++k) { + stbi__resample *r = &res_comp[k]; + + // allocate line buffer big enough for upsampling off the edges + // with upsample factor of 4 + z->img_comp[k].linebuf = (uint8_t *) malloc(z->s->img_x + 3); + if (!z->img_comp[k].linebuf) { stbi__cleanup_jpeg(z); return stbi__errpuc("outofmem", "Out of memory"); } + + r->hs = z->img_h_max / z->img_comp[k].h; + r->vs = z->img_v_max / z->img_comp[k].v; + r->ystep = r->vs >> 1; + r->w_lores = (z->s->img_x + r->hs-1) / r->hs; + r->ypos = 0; + r->line0 = r->line1 = z->img_comp[k].data; + + if (r->hs == 1 && r->vs == 1) r->resample = resample_row_1; + else if (r->hs == 1 && r->vs == 2) r->resample = stbi__resample_row_v_2; + else if (r->hs == 2 && r->vs == 1) r->resample = stbi__resample_row_h_2; + else if (r->hs == 2 && r->vs == 2) r->resample = z->resample_row_hv_2_kernel; + else r->resample = stbi__resample_row_generic; + } + + // can't error after this so, this is safe + output = (uint8_t *) malloc(n * z->s->img_x * z->s->img_y + 1); + if (!output) { stbi__cleanup_jpeg(z); return stbi__errpuc("outofmem", "Out of memory"); } + + // now go ahead and resample + for (j=0; j < z->s->img_y; ++j) { + uint8_t *out = output + n * z->s->img_x * j; + for (k=0; k < decode_n; ++k) { + stbi__resample *r = &res_comp[k]; + int y_bot = r->ystep >= (r->vs >> 1); + coutput[k] = r->resample(z->img_comp[k].linebuf, + y_bot ? r->line1 : r->line0, + y_bot ? r->line0 : r->line1, + r->w_lores, r->hs); + if (++r->ystep >= r->vs) { + r->ystep = 0; + r->line0 = r->line1; + if (++r->ypos < z->img_comp[k].y) + r->line1 += z->img_comp[k].w2; + } + } + if (n >= 3) { + uint8_t *y = coutput[0]; + if (z->s->img_n == 3) { + z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, n); + } else + for (i=0; i < z->s->img_x; ++i) { + out[0] = out[1] = out[2] = y[i]; + out[3] = 255; // not used if n==3 + out += n; + } + } else { + uint8_t *y = coutput[0]; + if (n == 1) + for (i=0; i < z->s->img_x; ++i) out[i] = y[i]; + else + for (i=0; i < z->s->img_x; ++i) *out++ = y[i], *out++ = 255; + } + } + stbi__cleanup_jpeg(z); + *out_x = z->s->img_x; + *out_y = z->s->img_y; + if (comp) *comp = z->s->img_n; // report original components, not output + return output; + } +} + +static unsigned char *stbi__jpeg_load(stbi__context *s, int *x, int *y, int *comp, int req_comp) +{ + stbi__jpeg j; + j.s = s; + stbi__setup_jpeg(&j); + return load_jpeg_image(&j, x,y,comp,req_comp); +} + +static int stbi__jpeg_test(stbi__context *s) +{ + int r; + stbi__jpeg j; + j.s = s; + stbi__setup_jpeg(&j); + r = stbi__decode_jpeg_header(&j, STBI__SCAN_type); + stbi__rewind(s); + return r; +} +#endif + +bool rjpeg_image_load(uint8_t *_buf, void *data, size_t size, unsigned a_shift, unsigned r_shift, unsigned g_shift, unsigned b_shift) { - struct rjpeg_data *rjpg = rjpeg_new(buf, size); + unsigned i; + int x, y, comp; struct texture_image *out_img = (struct texture_image*)data; - if (!rjpg) - goto error; + out_img->pixels = stbi_load_from_memory(_buf, size, &x, &y, &comp, 4); - out_img->width = rjpg->width; - out_img->height = rjpg->height; - out_img->pixels = (uint32_t*)malloc(rjpg->width * rjpg->height * rjpg->ncomp); + out_img->width = x; + out_img->height = y; - if (!out_img->pixels) - goto error; - - if (rjpg->ncomp == 3) +#if 0 + for (i = 0; i < (x * y); i++) { - /* convert to RGB */ - int x, yy; - uint32_t *prgb = (uint32_t*)out_img->pixels; - const unsigned char *py = rjpg->comp[0].pixels; - const unsigned char *pcb = rjpg->comp[1].pixels; - const unsigned char *pcr = rjpg->comp[2].pixels; + uint32_t r = (_buf[i] & 0xff00ff00); + uint32_t g = ((_buf[i] << 16) & 0x00ff0000); + uint32_t b = ((_buf[i] >> 16) & 0xff); - for (yy = rjpg->height; yy; --yy) - { - for (x = 0; x < rjpg->width; ++x) - { - int y = py[x] << 8; - int cb = pcb[x] - 128; - int cr = pcr[x] - 128; - *prgb++ = rjpeg_clip((y + 359 * cr + 128) >> 8); - *prgb++ = rjpeg_clip((y - 88 * cb - 183 * cr + 128) >> 8); - *prgb++ = rjpeg_clip((y + 454 * cb + 128) >> 8); - } - py += rjpg->comp[0].stride; - pcb += rjpg->comp[1].stride; - pcr += rjpg->comp[2].stride; - } + if (r_shift == 0 && b_shift == 16) + out_img->pixels[i] = _buf[i]; + else + out_img->pixels[i] = r | g | b; + //out_img->pixels[i] = (r << r_shift) | (g << g_shift) || (b << b_shift); } - - rjpeg_free(rjpg); +#endif return true; - -error: - if (out_img->pixels) - free(out_img->pixels); - - out_img->pixels = NULL; - out_img->width = out_img->height = 0; - - if (rjpg) - rjpeg_free(rjpg); - return false; } From f931ce76061018a7cc7d43be97a4cbee06a0a9e5 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 May 2016 06:02:00 +0200 Subject: [PATCH 366/498] Adds conversion when color shifts are BGRA --- libretro-common/formats/jpeg/rjpeg.c | 37 +++++++++++++++++----------- 1 file changed, 22 insertions(+), 15 deletions(-) diff --git a/libretro-common/formats/jpeg/rjpeg.c b/libretro-common/formats/jpeg/rjpeg.c index 44be7d75ad..341cdc43f8 100644 --- a/libretro-common/formats/jpeg/rjpeg.c +++ b/libretro-common/formats/jpeg/rjpeg.c @@ -2361,6 +2361,24 @@ static int stbi__jpeg_test(stbi__context *s) } #endif +static INLINE void video_frame_convert_rgba_to_bgra( + const void *src_data, + void *dst_data, + unsigned width) +{ + unsigned x; + uint8_t *dst = (uint8_t*)dst_data; + const uint8_t *src = (const uint8_t*)src_data; + + for (x = 0; x < width; x++, dst += 4, src += 4) + { + dst[3] = src[3]; + dst[0] = src[2]; + dst[1] = src[1]; + dst[2] = src[0]; + } +} + bool rjpeg_image_load(uint8_t *_buf, void *data, size_t size, unsigned a_shift, unsigned r_shift, unsigned g_shift, unsigned b_shift) @@ -2369,25 +2387,14 @@ bool rjpeg_image_load(uint8_t *_buf, void *data, size_t size, int x, y, comp; struct texture_image *out_img = (struct texture_image*)data; - out_img->pixels = stbi_load_from_memory(_buf, size, &x, &y, &comp, 4); + out_img->pixels = (uint32_t*)stbi_load_from_memory(_buf, size, &x, &y, &comp, 4); out_img->width = x; out_img->height = y; -#if 0 - for (i = 0; i < (x * y); i++) - { - uint32_t r = (_buf[i] & 0xff00ff00); - uint32_t g = ((_buf[i] << 16) & 0x00ff0000); - uint32_t b = ((_buf[i] >> 16) & 0xff); - - if (r_shift == 0 && b_shift == 16) - out_img->pixels[i] = _buf[i]; - else - out_img->pixels[i] = r | g | b; - //out_img->pixels[i] = (r << r_shift) | (g << g_shift) || (b << b_shift); - } -#endif + if (r_shift == 0 && b_shift == 16) { } /* RGBA, doesn't need conversion */ + else + video_frame_convert_rgba_to_bgra(_buf, out_img->pixels, x); return true; } From 60b8cf7993b2edebbd22cef3089196c5a594c8fc Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 May 2016 06:16:27 +0200 Subject: [PATCH 367/498] Start adding notes to task_file_transfer.c --- tasks/task_file_transfer.c | 45 ++++++++++++++++++++++++-------------- 1 file changed, 29 insertions(+), 16 deletions(-) diff --git a/tasks/task_file_transfer.c b/tasks/task_file_transfer.c index b8d3ef7ca6..34db03a599 100644 --- a/tasks/task_file_transfer.c +++ b/tasks/task_file_transfer.c @@ -82,8 +82,8 @@ typedef struct nbio_handle #ifdef HAVE_MENU #include "../menu/menu_driver.h" -#ifdef HAVE_RPNG static void rarch_task_file_load_handler(retro_task_t *task); + static int cb_image_menu_upload_generic(void *data, size_t len) { nbio_handle_t *nbio = (nbio_handle_t*)data; @@ -110,7 +110,8 @@ static int cb_image_menu_upload_generic(void *data, size_t len) return 0; } -static int cb_image_menu_generic(nbio_handle_t *nbio) +#ifdef HAVE_RPNG +static int cb_image_menu_generic_rpng(nbio_handle_t *nbio) { unsigned width = 0, height = 0; int retval; @@ -137,11 +138,11 @@ static int cb_image_menu_generic(nbio_handle_t *nbio) return 0; } -static int cb_image_menu_wallpaper(void *data, size_t len) +static int cb_image_menu_wallpaper_rpng(void *data, size_t len) { nbio_handle_t *nbio = (nbio_handle_t*)data; - if (cb_image_menu_generic(nbio) != 0) + if (cb_image_menu_generic_rpng(nbio) != 0) return -1; nbio->image.cb = &cb_image_menu_upload_generic; @@ -153,7 +154,7 @@ static int cb_image_menu_thumbnail(void *data, size_t len) { nbio_handle_t *nbio = (nbio_handle_t*)data; - if (cb_image_menu_generic(nbio) != 0) + if (cb_image_menu_generic_rpng(nbio) != 0) return -1; nbio->image.cb = &cb_image_menu_upload_generic; @@ -173,6 +174,7 @@ static int rarch_main_data_image_iterate_transfer(nbio_handle_t *nbio) for (i = 0; i < nbio->image.pos_increment; i++) { + /* TODO/FIXME - add JPEG equivalents as well */ if (!rpng_nbio_load_image_argb_iterate(nbio->image.handle)) goto error; } @@ -194,6 +196,7 @@ static int rarch_main_data_image_iterate_process_transfer(nbio_handle_t *nbio) for (i = 0; i < nbio->image.processing_pos_increment; i++) { + /* TODO/FIXME -add JPEG equivalents as well */ retval = rpng_nbio_load_image_argb_process(nbio->image.handle, &nbio->image.ti.pixels, &width, &height); @@ -248,7 +251,7 @@ static int cb_nbio_default(void *data, size_t len) return 0; } -static int cb_nbio_generic(nbio_handle_t *nbio, size_t *len) +static int cb_nbio_generic_rpng(nbio_handle_t *nbio, size_t *len) { void *ptr = NULL; @@ -286,7 +289,7 @@ static int cb_nbio_generic(nbio_handle_t *nbio, size_t *len) return 0; } -static int cb_nbio_image_menu_wallpaper(void *data, size_t len) +static int cb_nbio_image_menu_wallpaper_rpng(void *data, size_t len) { nbio_handle_t *nbio = (nbio_handle_t*)data; @@ -294,12 +297,12 @@ static int cb_nbio_image_menu_wallpaper(void *data, size_t len) return -1; nbio->image.handle = rpng_alloc(); - nbio->image.cb = &cb_image_menu_wallpaper; + nbio->image.cb = &cb_image_menu_wallpaper_rpng; - return cb_nbio_generic(nbio, &len); + return cb_nbio_generic_rpng(nbio, &len); } -static int cb_nbio_image_menu_thumbnail(void *data, size_t len) +static int cb_nbio_image_menu_thumbnail_rpng(void *data, size_t len) { nbio_handle_t *nbio = (nbio_handle_t*)data; @@ -309,7 +312,7 @@ static int cb_nbio_image_menu_thumbnail(void *data, size_t len) nbio->image.handle = rpng_alloc(); nbio->image.cb = &cb_image_menu_thumbnail; - return cb_nbio_generic(nbio, &len); + return cb_nbio_generic_rpng(nbio, &len); } #endif #endif @@ -345,10 +348,19 @@ bool rarch_task_push_image_load(const char *fullpath, nbio->status = NBIO_STATUS_TRANSFER; nbio->image.status = NBIO_IMAGE_STATUS_TRANSFER; - if (cb_type_hash == CB_MENU_WALLPAPER) - nbio->cb = &cb_nbio_image_menu_wallpaper; - else if (cb_type_hash == CB_MENU_THUMBNAIL) - nbio->cb = &cb_nbio_image_menu_thumbnail; + if (strstr(fullpath, ".png")) + { +#ifdef HAVE_RPNG + if (cb_type_hash == CB_MENU_WALLPAPER) + nbio->cb = &cb_nbio_image_menu_wallpaper_rpng; + else if (cb_type_hash == CB_MENU_THUMBNAIL) + nbio->cb = &cb_nbio_image_menu_thumbnail_rpng; +#endif + } + else if (strstr(fullpath, ".jpeg") || strstr(fullpath, ".jpg")) + { + /* TODO/FIXME */ + } nbio_begin_read(handle); @@ -370,7 +382,7 @@ bool rarch_task_push_image_load(const char *fullpath, return true; } -/* guarded for rpng/menu use but good for generic use */ +/* Guarded for RPNG/menu use but good for generic reuse */ #if defined(HAVE_RPNG) && defined(HAVE_MENU) static int rarch_main_data_nbio_iterate_transfer(nbio_handle_t *nbio) { @@ -487,6 +499,7 @@ task_finished: if (image->handle) { + /* TODO/FIXME - add JPEG equivalents as well */ rpng_nbio_load_image_free(image->handle); image->handle = NULL; From c321c161a87116d5dd39f14c441dd7ae66042d8b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 May 2016 06:51:58 +0200 Subject: [PATCH 368/498] Update rjpeg --- libretro-common/formats/jpeg/rjpeg.c | 794 ++++++++++++++------------- 1 file changed, 422 insertions(+), 372 deletions(-) diff --git a/libretro-common/formats/jpeg/rjpeg.c b/libretro-common/formats/jpeg/rjpeg.c index 341cdc43f8..29b7f18ee6 100644 --- a/libretro-common/formats/jpeg/rjpeg.c +++ b/libretro-common/formats/jpeg/rjpeg.c @@ -25,15 +25,22 @@ typedef struct int (*eof) (void *user); /* returns nonzero if we are at end of file/data */ } stbi_io_callbacks; +typedef uint8_t *(*resample_row_func)(uint8_t *out, uint8_t *in0, uint8_t *in1, + int w, int hs); + +typedef struct +{ + resample_row_func resample; + uint8_t *line0,*line1; + int hs,vs; /* expansion factor in each axis */ + int w_lores; /* horizontal pixels pre-expansion */ + int ystep; /* how far through vertical expansion we are */ + int ypos; /* which pre-expansion row we're on */ +} stbi__resample; + /* should produce compiler error if size is wrong */ typedef unsigned char validate_uint32[sizeof(uint32_t)==4 ? 1 : -1]; -#ifdef _MSC_VER -#define STBI_NOTUSED(v) (void)(v) -#else -#define STBI_NOTUSED(v) (void)sizeof(v) -#endif - #ifdef _MSC_VER #define STBI_HAS_LROTL #endif @@ -44,7 +51,7 @@ typedef unsigned char validate_uint32[sizeof(uint32_t)==4 ? 1 : -1]; #define stbi_lrot(x,y) (((x) << (y)) | ((x) >> (32 - (y)))) #endif -// x86/x64 detection +/* x86/x64 detection */ #if defined(__x86_64__) || defined(_M_X64) #define STBI__X64_TARGET #elif defined(__i386) || defined(_M_IX86) @@ -77,8 +84,7 @@ typedef unsigned char validate_uint32[sizeof(uint32_t)==4 ? 1 : -1]; #define STBI_NO_SIMD #endif -#if !defined(STBI_NO_SIMD) && defined(STBI__X86_TARGET) -#define STBI_SSE2 +#if defined(__SSE2__) #include #ifdef _MSC_VER @@ -106,7 +112,7 @@ static int stbi__cpuid3(void) #define STBI_SIMD_ALIGN(type, name) __declspec(align(16)) type name -static int stbi__sse2_available() +static int stbi__sse2_available(void) { int info3 = stbi__cpuid3(); return ((info3 >> 26) & 1) != 0; @@ -114,7 +120,7 @@ static int stbi__sse2_available() #else /* assume GCC-style if not VC++ */ #define STBI_SIMD_ALIGN(type, name) type name __attribute__((aligned(16))) -static int stbi__sse2_available() +static int stbi__sse2_available(void) { #if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 408 /* GCC 4.8 or later */ /* GCC 4.8+ has a nice way to do this */ @@ -143,12 +149,6 @@ static int stbi__sse2_available() #define STBI_SIMD_ALIGN(type, name) type name #endif -/////////////////////////////////////////////// -// -// stbi__context struct and start_xxx functions - -// stbi__context structure is our basic context used by all images, so it -// contains all the IO context, plus some basic image information typedef struct { uint32_t img_x, img_y; @@ -165,10 +165,7 @@ typedef struct uint8_t *img_buffer_original; } stbi__context; - -static void stbi__refill_buffer(stbi__context *s); - -// initialize a memory-decode context +/* initialize a memory-decode context */ static void stbi__start_mem(stbi__context *s, const uint8_t *buffer, int len) { s->io.read = NULL; @@ -191,7 +188,7 @@ static int stbi__jpeg_test(stbi__context *s); static uint8_t *stbi__jpeg_load(stbi__context *s, int *x, int *y, int *comp, int req_comp); #endif -// this is not threadsafe +/* this is not threadsafe */ static const char *stbi__g_failure_reason; static int stbi__err(const char *str) @@ -200,10 +197,6 @@ static int stbi__err(const char *str) return 0; } -// stbi__err - error -// stbi__errpf - error returning pointer to float -// stbi__errpuc - error returning pointer to unsigned char - #ifdef STBI_NO_FAILURE_STRINGS #define stbi__err(x,y) 0 #elif defined(STBI_FAILURE_USERMSG) @@ -230,16 +223,19 @@ static unsigned char *stbi__load_flip(stbi__context *s, int *x, int *y, int *com { unsigned char *result = stbi__load_main(s, x, y, comp, req_comp); - if (stbi__vertically_flip_on_load && result != NULL) { + if (stbi__vertically_flip_on_load && result != NULL) + { + uint8_t temp; + int row,col,z; int w = *x, h = *y; int depth = req_comp ? req_comp : *comp; - int row,col,z; - uint8_t temp; - // @OPTIMIZE: use a bigger temp buffer and memcpy multiple pixels at once - for (row = 0; row < (h>>1); row++) { - for (col = 0; col < w; col++) { - for (z = 0; z < depth; z++) { + for (row = 0; row < (h>>1); row++) + { + for (col = 0; col < w; col++) + { + for (z = 0; z < depth; z++) + { temp = result[(row * w + col) * depth + z]; result[(row * w + col) * depth + z] = result[((h - row - 1) * w + col) * depth + z]; result[((h - row - 1) * w + col) * depth + z] = temp; @@ -258,11 +254,6 @@ static uint8_t *stbi_load_from_memory(const uint8_t *buffer, int len, int *x, in return stbi__load_flip(&s,x,y,comp,req_comp); } -////////////////////////////////////////////////////////////////////////////// -// -// Common code used by all image loaders -// - enum { STBI__SCAN_load=0, @@ -273,14 +264,18 @@ enum static void stbi__refill_buffer(stbi__context *s) { int n = (s->io.read)(s->io_user_data,(char*)s->buffer_start,s->buflen); - if (n == 0) { - // at end of file, treat same as if from memory, but need to handle case - // where s->img_buffer isn't pointing to safe memory, e.g. 0-byte file + + if (n == 0) + { + /* at end of file, treat same as if from memory, but need to handle case + * where s->img_buffer isn't pointing to safe memory, e.g. 0-byte file */ s->read_from_callbacks = 0; s->img_buffer = s->buffer_start; s->img_buffer_end = s->buffer_start+1; *s->img_buffer = 0; - } else { + } + else + { s->img_buffer = s->buffer_start; s->img_buffer_end = s->buffer_start + n; } @@ -290,20 +285,29 @@ static INLINE uint8_t stbi__get8(stbi__context *s) { if (s->img_buffer < s->img_buffer_end) return *s->img_buffer++; - if (s->read_from_callbacks) { + + if (s->read_from_callbacks) + { stbi__refill_buffer(s); return *s->img_buffer++; } + return 0; } static INLINE int stbi__at_eof(stbi__context *s) { - if (s->io.read) { - if (!(s->io.eof)(s->io_user_data)) return 0; - // if feof() is true, check if buffer = end - // special case: we've only got the special 0 character at the end - if (s->read_from_callbacks == 0) return 1; + if (s->io.read) + { + if (!(s->io.eof)(s->io_user_data)) + return 0; + + /* if feof() is true, check if buffer = end + * special case: we've only got the special + * 0 character at the end */ + + if (s->read_from_callbacks == 0) + return 1; } return s->img_buffer >= s->img_buffer_end; @@ -332,43 +336,20 @@ static int stbi__get16be(stbi__context *s) return (z << 8) + stbi__get8(s); } -#define STBI__BYTECAST(x) ((uint8_t) ((x) & 255)) // truncate int to byte without warnings +#define STBI__BYTECAST(x) ((uint8_t) ((x) & 255)) /* truncate int to byte without warnings */ -////////////////////////////////////////////////////////////////////////////// -// -// "baseline" JPEG/JFIF decoder -// -// simple implementation -// - doesn't support delayed output of y-dimension -// - simple interface (only one output format: 8-bit interleaved RGB) -// - doesn't try to recover corrupt jpegs -// - doesn't allow partial loading, loading multiple at once -// - still fast on x86 (copying globals into locals doesn't help x86) -// - allocates lots of intermediate memory (full size of all components) -// - non-interleaved case requires this anyway -// - allows good upsampling (see next) -// high-quality -// - upsampled channels are bilinearly interpolated, even across blocks -// - quality integer IDCT derived from IJG's 'slow' -// performance -// - fast huffman; reasonable integer IDCT -// - some SIMD kernels for common paths on targets with SSE2/NEON -// - uses a lot of intermediate memory, could cache poorly - -#ifndef STBI_NO_JPEG - -// huffman decoding acceleration -#define FAST_BITS 9 // larger handles more cases; smaller stomps less cache +/* huffman decoding acceleration */ +#define FAST_BITS 9 /* larger handles more cases; smaller stomps less cache */ typedef struct { uint8_t fast[1 << FAST_BITS]; - // weirdly, repacking this into AoS is a 10% speed loss, instead of a win + /* weirdly, repacking this into AoS is a 10% speed loss, instead of a win */ uint16_t code[256]; uint8_t values[256]; uint8_t size[257]; unsigned int maxcode[18]; - int delta[17]; // old 'firstsymbol' - old 'firstcode' + int delta[17]; /* old 'firstsymbol' - old 'firstcode' */ } stbi__huffman; typedef struct @@ -379,12 +360,12 @@ typedef struct uint8_t dequant[4][64]; int16_t fast_ac[4][1 << FAST_BITS]; -// sizes for components, interleaved MCUs + /* sizes for components, interleaved MCUs */ int img_h_max, img_v_max; int img_mcu_x, img_mcu_y; int img_mcu_w, img_mcu_h; -// definition of jpeg image component + /* definition of jpeg image component */ struct { int id; @@ -397,14 +378,14 @@ typedef struct uint8_t *data; void *raw_data, *raw_coeff; uint8_t *linebuf; - short *coeff; // progressive only - int coeff_w, coeff_h; // number of 8x8 coefficient blocks + short *coeff; /* progressive only */ + int coeff_w, coeff_h; /* number of 8x8 coefficient blocks */ } img_comp[4]; - uint32_t code_buffer; // jpeg entropy-coded buffer - int code_bits; // number of valid bits - unsigned char marker; // marker seen while filling entropy buffer - int nomore; // flag if we saw a marker so must stop + uint32_t code_buffer; /* jpeg entropy-coded buffer */ + int code_bits; /* number of valid bits */ + unsigned char marker; /* marker seen while filling entropy buffer */ + int nomore; /* flag if we saw a marker so must stop */ int progressive; int spec_start; @@ -416,7 +397,7 @@ typedef struct int scan_n, order[4]; int restart_interval, todo; -// kernels + /* kernels */ void (*idct_block_kernel)(uint8_t *out, int out_stride, short data[64]); void (*YCbCr_to_RGB_kernel)(uint8_t *out, const uint8_t *y, const uint8_t *pcb, const uint8_t *pcr, int count, int step); uint8_t *(*resample_row_hv_2_kernel)(uint8_t *out, uint8_t *in_near, uint8_t *in_far, int w, int hs); @@ -425,30 +406,34 @@ typedef struct static int stbi__build_huffman(stbi__huffman *h, int *count) { int i,j,k=0,code; - // build size list for each symbol (from JPEG spec) + /* build size list for each symbol (from JPEG spec) */ for (i=0; i < 16; ++i) for (j=0; j < count[i]; ++j) h->size[k++] = (uint8_t) (i+1); h->size[k] = 0; - // compute actual symbols (from jpeg spec) + /* compute actual symbols (from jpeg spec) */ code = 0; - k = 0; - for(j=1; j <= 16; ++j) { - // compute delta to add to code to compute symbol id + k = 0; + + for(j=1; j <= 16; ++j) + { + /* compute delta to add to code to compute symbol id */ h->delta[j] = k - code; - if (h->size[k] == j) { + if (h->size[k] == j) + { while (h->size[k] == j) h->code[k++] = (uint16_t) (code++); - if (code-1 >= (1 << j)) return stbi__err("bad code lengths","Corrupt JPEG"); + if (code-1 >= (1 << j)) + return stbi__err("bad code lengths","Corrupt JPEG"); } - // compute largest code + 1 for this size, preshifted as needed later + /* compute largest code + 1 for this size, preshifted as needed later */ h->maxcode[j] = code << (16-j); code <<= 1; } h->maxcode[j] = 0xffffffff; - // build non-spec acceleration table; 255 is flag for not-accelerated + /* build non-spec acceleration table; 255 is flag for not-accelerated */ memset(h->fast, 255, 1 << FAST_BITS); for (i=0; i < k; ++i) { int s = h->size[i]; @@ -463,26 +448,31 @@ static int stbi__build_huffman(stbi__huffman *h, int *count) return 1; } -// build a table that decodes both magnitude and value of small ACs in -// one go. +/* build a table that decodes both magnitude and value of small ACs in + * one go. */ static void stbi__build_fast_ac(int16_t *fast_ac, stbi__huffman *h) { int i; - for (i=0; i < (1 << FAST_BITS); ++i) { + + for (i=0; i < (1 << FAST_BITS); ++i) + { uint8_t fast = h->fast[i]; fast_ac[i] = 0; - if (fast < 255) { - int rs = h->values[fast]; - int run = (rs >> 4) & 15; - int magbits = rs & 15; - int len = h->size[fast]; - if (magbits && len + magbits <= FAST_BITS) { - // magnitude code followed by receive_extend code + if (fast < 255) + { + int rs = h->values[fast]; + int run = (rs >> 4) & 15; + int magbits = rs & 15; + int len = h->size[fast]; + + if (magbits && len + magbits <= FAST_BITS) + { + /* magnitude code followed by receive_extend code */ int k = ((i << len) & ((1 << FAST_BITS) - 1)) >> (FAST_BITS - magbits); int m = 1 << (magbits - 1); if (k < m) k += (-1 << magbits) + 1; - // if the result is small enough, we can fit it in fast_ac table + /* if the result is small enough, we can fit it in fast_ac table */ if (k >= -128 && k <= 127) fast_ac[i] = (int16_t) ((k << 8) + (run << 4) + (len + magbits)); } @@ -492,11 +482,15 @@ static void stbi__build_fast_ac(int16_t *fast_ac, stbi__huffman *h) static void stbi__grow_buffer_unsafe(stbi__jpeg *j) { - do { + do + { int b = j->nomore ? 0 : stbi__get8(j->s); - if (b == 0xff) { + if (b == 0xff) + { int c = stbi__get8(j->s); - if (c != 0) { + + if (c != 0) + { j->marker = (unsigned char) c; j->nomore = 1; return; @@ -507,22 +501,24 @@ static void stbi__grow_buffer_unsafe(stbi__jpeg *j) } while (j->code_bits <= 24); } -// (1 << n) - 1 +/* (1 << n) - 1 */ static uint32_t stbi__bmask[17]={0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535}; -// decode a jpeg huffman value from the bitstream +/* decode a JPEG huffman value from the bitstream */ static INLINE int stbi__jpeg_huff_decode(stbi__jpeg *j, stbi__huffman *h) { unsigned int temp; int c,k; - if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); + if (j->code_bits < 16) + stbi__grow_buffer_unsafe(j); - // look at the top FAST_BITS and determine what symbol ID it is, - // if the code is <= FAST_BITS + /* look at the top FAST_BITS and determine what symbol ID it is, + * if the code is <= FAST_BITS */ c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1); k = h->fast[c]; - if (k < 255) { + if (k < 255) + { int s = h->size[k]; if (s > j->code_bits) return -1; @@ -531,18 +527,20 @@ static INLINE int stbi__jpeg_huff_decode(stbi__jpeg *j, stbi__huffman *h) return h->values[k]; } - // naive test is to shift the code_buffer down so k bits are - // valid, then test against maxcode. To speed this up, we've - // preshifted maxcode left so that it has (16-k) 0s at the - // end; in other words, regardless of the number of bits, it - // wants to be compared against something shifted to have 16; - // that way we don't need to shift inside the loop. + /* naive test is to shift the code_buffer down so k bits are + * valid, then test against maxcode. To speed this up, we've + * preshifted maxcode left so that it has (16-k) 0s at the + * end; in other words, regardless of the number of bits, it + * wants to be compared against something shifted to have 16; + * that way we don't need to shift inside the loop. */ temp = j->code_buffer >> 16; for (k=FAST_BITS+1 ; ; ++k) if (temp < h->maxcode[k]) break; - if (k == 17) { - // error! code not found + + if (k == 17) + { + /* error! code not found */ j->code_bits -= 16; return -1; } @@ -550,28 +548,28 @@ static INLINE int stbi__jpeg_huff_decode(stbi__jpeg *j, stbi__huffman *h) if (k > j->code_bits) return -1; - // convert the huffman code to the symbol id + /* convert the huffman code to the symbol id */ c = ((j->code_buffer >> (32 - k)) & stbi__bmask[k]) + h->delta[k]; assert((((j->code_buffer) >> (32 - h->size[c])) & stbi__bmask[h->size[c]]) == h->code[c]); - // convert the id to a symbol + /* convert the id to a symbol */ j->code_bits -= k; j->code_buffer <<= k; return h->values[c]; } -// bias[n] = (-1<code_bits < n) stbi__grow_buffer_unsafe(j); - sgn = (int32_t)j->code_buffer >> 31; // sign bit is always in MSB + sgn = (int32_t)j->code_buffer >> 31; /* sign bit is always in MSB */ k = stbi_lrot(j->code_buffer, n); assert(n >= 0 && n < (int) (sizeof(stbi__bmask)/sizeof(*stbi__bmask))); j->code_buffer = k & ~stbi__bmask[n]; @@ -580,7 +578,7 @@ static INLINE int stbi__extend_receive(stbi__jpeg *j, int n) return k + (stbi__jbias[n] & ~sgn); } -// get some unsigned bits +/* get some unsigned bits */ static INLINE int stbi__jpeg_get_bits(stbi__jpeg *j, int n) { unsigned int k; @@ -602,8 +600,8 @@ static INLINE int stbi__jpeg_get_bit(stbi__jpeg *j) return k & 0x80000000; } -// given a value that's at position X in the zigzag stream, -// where does it appear in the 8x8 matrix coded as row-major? +/* given a value that's at position X in the zigzag stream, + * where does it appear in the 8x8 matrix coded as row-major? */ static uint8_t stbi__jpeg_dezigzag[64+15] = { 0, 1, 8, 16, 9, 2, 3, 10, @@ -614,12 +612,12 @@ static uint8_t stbi__jpeg_dezigzag[64+15] = 29, 22, 15, 23, 30, 37, 44, 51, 58, 59, 52, 45, 38, 31, 39, 46, 53, 60, 61, 54, 47, 55, 62, 63, - // let corrupt input sample past end + /* let corrupt input sample past end */ 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63, 63 }; -// decode one 64-entry block-- +/* decode one 64-entry block-- */ static int stbi__jpeg_decode_block(stbi__jpeg *j, short data[64], stbi__huffman *hdc, stbi__huffman *hac, int16_t *fac, int b, uint8_t *dequant) { int diff,dc,k; @@ -629,7 +627,7 @@ static int stbi__jpeg_decode_block(stbi__jpeg *j, short data[64], stbi__huffman t = stbi__jpeg_huff_decode(j, hdc); if (t < 0) return stbi__err("bad huffman code","Corrupt JPEG"); - // 0 all the ac values now so we can do it 32-bits at a time + /* 0 all the ac values now so we can do it 32-bits at a time */ memset(data,0,64*sizeof(data[0])); diff = t ? stbi__extend_receive(j, t) : 0; @@ -637,33 +635,39 @@ static int stbi__jpeg_decode_block(stbi__jpeg *j, short data[64], stbi__huffman j->img_comp[b].dc_pred = dc; data[0] = (short) (dc * dequant[0]); - // decode AC components, see JPEG spec + /* decode AC components, see JPEG spec */ k = 1; - do { + do + { unsigned int zig; int c,r,s; - if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); + if (j->code_bits < 16) + stbi__grow_buffer_unsafe(j); c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1); r = fac[c]; - if (r) { // fast-AC path - k += (r >> 4) & 15; // run - s = r & 15; // combined length + if (r) + { + /* fast-AC path */ + k += (r >> 4) & 15; /* run */ + s = r & 15; /* combined length */ j->code_buffer <<= s; j->code_bits -= s; - // decode into unzigzag'd location + /* decode into unzigzag'd location */ zig = stbi__jpeg_dezigzag[k++]; data[zig] = (short) ((r >> 8) * dequant[zig]); - } else { + } + else + { int rs = stbi__jpeg_huff_decode(j, hac); if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG"); s = rs & 15; r = rs >> 4; if (s == 0) { - if (rs != 0xf0) break; // end block + if (rs != 0xf0) break; /* end block */ k += 16; } else { k += r; - // decode into unzigzag'd location + /* decode into unzigzag'd location */ zig = stbi__jpeg_dezigzag[k++]; data[zig] = (short) (stbi__extend_receive(j,s) * dequant[zig]); } @@ -686,7 +690,7 @@ static int stbi__jpeg_decode_block_prog_dc(stbi__jpeg *j, short data[64], stbi__ int t; /* first scan for DC coefficient, must be first */ - memset(data,0,64*sizeof(data[0])); // 0 all the ac values now + memset(data,0,64*sizeof(data[0])); /* 0 all the ac values now */ t = stbi__jpeg_huff_decode(j, hdc); diff = t ? stbi__extend_receive(j, t) : 0; @@ -703,8 +707,6 @@ static int stbi__jpeg_decode_block_prog_dc(stbi__jpeg *j, short data[64], stbi__ return 1; } -// @OPTIMIZE: store non-zigzagged during the decode passes, -// and only de-zigzag when dequantizing static int stbi__jpeg_decode_block_prog_ac(stbi__jpeg *j, short data[64], stbi__huffman *hac, int16_t *fac) { int k; @@ -725,7 +727,7 @@ static int stbi__jpeg_decode_block_prog_ac(stbi__jpeg *j, short data[64], stbi__ if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1); r = fac[c]; - if (r) { // fast-AC path + if (r) { /* fast-AC path */ k += (r >> 4) & 15; // run s = r & 15; // combined length j->code_buffer <<= s; @@ -754,7 +756,7 @@ static int stbi__jpeg_decode_block_prog_ac(stbi__jpeg *j, short data[64], stbi__ } } while (k <= j->spec_end); } else { - // refinement scan for these AC coefficients + /* refinement scan for these AC coefficients */ short bit = (short) (1 << j->succ_low); @@ -775,7 +777,7 @@ static int stbi__jpeg_decode_block_prog_ac(stbi__jpeg *j, short data[64], stbi__ k = j->spec_start; do { int r,s; - int rs = stbi__jpeg_huff_decode(j, hac); // @OPTIMIZE see if we can use the fast path here, advance-by-r is so slow, eh + int rs = stbi__jpeg_huff_decode(j, hac); if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG"); s = rs & 15; r = rs >> 4; @@ -824,13 +826,16 @@ static int stbi__jpeg_decode_block_prog_ac(stbi__jpeg *j, short data[64], stbi__ return 1; } -// take a -128..127 value and stbi__clamp it and convert to 0..255 +/* take a -128..127 value and stbi__clamp it and convert to 0..255 */ static INLINE uint8_t stbi__clamp(int x) { - // trick to use a single test to catch both cases - if ((unsigned int) x > 255) { - if (x < 0) return 0; - if (x > 255) return 255; + /* trick to use a single test to catch both cases */ + if ((unsigned int) x > 255) + { + if (x < 0) + return 0; + if (x > 255) + return 255; } return (uint8_t) x; } @@ -838,7 +843,7 @@ static INLINE uint8_t stbi__clamp(int x) #define stbi__f2f(x) ((int) (((x) * 4096 + 0.5))) #define stbi__fsh(x) ((x) << 12) -// derived from jidctint -- DCT_ISLOW +/* derived from jidctint -- DCT_ISLOW */ #define STBI__IDCT_1D(s0,s1,s2,s3,s4,s5,s6,s7) \ int t0,t1,t2,t3,p1,p2,p3,p4,p5,x0,x1,x2,x3; \ p2 = s2; \ @@ -879,24 +884,25 @@ static INLINE uint8_t stbi__clamp(int x) static void stbi__idct_block(uint8_t *out, int out_stride, short data[64]) { int i,val[64],*v=val; - uint8_t *o; - short *d = data; + uint8_t *o = NULL; + int16_t *d = data; - // columns - for (i=0; i < 8; ++i,++d, ++v) { - // if all zeroes, shortcut -- this avoids dequantizing 0s and IDCTing + /* columns */ + for (i=0; i < 8; ++i,++d, ++v) + { + /* if all zeroes, shortcut -- this avoids dequantizing 0s and IDCTing */ if (d[ 8]==0 && d[16]==0 && d[24]==0 && d[32]==0 && d[40]==0 && d[48]==0 && d[56]==0) { - // no shortcut 0 seconds - // (1|2|3|4|5|6|7)==0 0 seconds - // all separate -0.047 seconds - // 1 && 2|3 && 4|5 && 6|7: -0.047 seconds + /* no shortcut 0 seconds + * (1|2|3|4|5|6|7)==0 0 seconds + * all separate -0.047 seconds + * 1 && 2|3 && 4|5 && 6|7: -0.047 seconds */ int dcterm = d[0] << 2; v[0] = v[8] = v[16] = v[24] = v[32] = v[40] = v[48] = v[56] = dcterm; } else { STBI__IDCT_1D(d[ 0],d[ 8],d[16],d[24],d[32],d[40],d[48],d[56]) - // constants scaled things up by 1<<12; let's bring them back - // down, but keep 2 extra bits of precision + /* constants scaled things up by 1<<12; let's bring them back + * down, but keep 2 extra bits of precision */ x0 += 512; x1 += 512; x2 += 512; x3 += 512; v[ 0] = (x0+t3) >> 10; v[56] = (x0-t3) >> 10; @@ -909,16 +915,17 @@ static void stbi__idct_block(uint8_t *out, int out_stride, short data[64]) } } - for (i=0, v=val, o=out; i < 8; ++i,v+=8,o+=out_stride) { - // no fast case since the first 1D IDCT spread components out + for (i=0, v=val, o=out; i < 8; ++i,v+=8,o+=out_stride) + { + /* no fast case since the first 1D IDCT spread components out */ STBI__IDCT_1D(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7]) - // constants scaled things up by 1<<12, plus we had 1<<2 from first - // loop, plus horizontal and vertical each scale by sqrt(8) so together - // we've got an extra 1<<3, so 1<<17 total we need to remove. - // so we want to round that, which means adding 0.5 * 1<<17, - // aka 65536. Also, we'll end up with -128 to 127 that we want - // to encode as 0..255 by adding 128, so we'll add that before the shift - x0 += 65536 + (128<<17); + /* constants scaled things up by 1<<12, plus we had 1<<2 from first + * loop, plus horizontal and vertical each scale by sqrt(8) so together + * we've got an extra 1<<3, so 1<<17 total we need to remove. + * so we want to round that, which means adding 0.5 * 1<<17, + * aka 65536. Also, we'll end up with -128 to 127 that we want + * to encode as 0..255 by adding 128, so we'll add that before the shift */ + x0 += 65536 + (128<<17); x1 += 65536 + (128<<17); x2 += 65536 + (128<<17); x3 += 65536 + (128<<17); @@ -935,7 +942,7 @@ static void stbi__idct_block(uint8_t *out, int out_stride, short data[64]) } } -#ifdef STBI_SSE2 +#if defined(__SSE2__) /* sse2 integer IDCT. not the fastest possible implementation but it * produces bit-identical results to the generic C version so it's * fully "transparent". @@ -1116,7 +1123,7 @@ static void stbi__idct_simd(uint8_t *out, int out_stride, short data[64]) #undef dct_pass } -#endif /* STBI_SSE2 */ +#endif #ifdef STBI_NEON @@ -1257,10 +1264,10 @@ static void stbi__idct_simd(uint8_t *out, int out_stride, short data[64]) #undef dct_trn64 } - // row pass - // vrshrn_n_s32 only supports shifts up to 16, we need - // 17. so do a non-rounding shift of 16 first then follow - // up with a rounding shift by 1. + /* row pass + * vrshrn_n_s32 only supports shifts up to 16, we need + * 17. so do a non-rounding shift of 16 first then follow + * up with a rounding shift by 1. */ dct_pass(vshrn_n_s32, 16); { @@ -1359,8 +1366,8 @@ static void stbi__jpeg_reset(stbi__jpeg *j) j->marker = STBI__MARKER_none; j->todo = j->restart_interval ? j->restart_interval : 0x7fffffff; j->eob_run = 0; - // no more than 1<<31 MCUs if no restart_interal? that's plenty safe, - // since we don't even allow 1<<30 pixels + /* no more than 1<<31 MCUs if no restart_interal? that's plenty safe, + * since we don't even allow 1<<30 pixels */ } static int stbi__parse_entropy_coded_data(stbi__jpeg *z) @@ -1371,10 +1378,10 @@ static int stbi__parse_entropy_coded_data(stbi__jpeg *z) int i,j; STBI_SIMD_ALIGN(short, data[64]); int n = z->order[0]; - // non-interleaved data, we just need to process one block at a time, - // in trivial scanline order - // number of blocks to do just depends on how many actual "pixels" this - // component has, independent of interleaved MCU blocking and such + /* non-interleaved data, we just need to process one block at a time, + * in trivial scanline order + * number of blocks to do just depends on how many actual "pixels" this + * component has, independent of interleaved MCU blocking and such */ int w = (z->img_comp[n].x+7) >> 3; int h = (z->img_comp[n].y+7) >> 3; for (j=0; j < h; ++j) { @@ -1382,8 +1389,9 @@ static int stbi__parse_entropy_coded_data(stbi__jpeg *z) int ha = z->img_comp[n].ha; if (!stbi__jpeg_decode_block(z, data, z->huff_dc+z->img_comp[n].hd, z->huff_ac+ha, z->fast_ac[ha], n, z->dequant[z->img_comp[n].tq])) return 0; z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*j*8+i*8, z->img_comp[n].w2, data); - // every data block is an MCU, so countdown the restart interval - if (--z->todo <= 0) { + /* every data block is an MCU, so countdown the restart interval */ + if (--z->todo <= 0) + { if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); // if it's NOT a restart, then just bail, so we get corrupt data // rather than no data @@ -1496,14 +1504,17 @@ static void stbi__jpeg_dequantize(short *data, uint8_t *dequant) static void stbi__jpeg_finish(stbi__jpeg *z) { - if (z->progressive) { - // dequantize and idct the data + if (z->progressive) + { + /* dequantize and IDCT the data */ int i,j,n; for (n=0; n < z->s->img_n; ++n) { int w = (z->img_comp[n].x+7) >> 3; int h = (z->img_comp[n].y+7) >> 3; - for (j=0; j < h; ++j) { - for (i=0; i < w; ++i) { + for (j=0; j < h; ++j) + { + for (i=0; i < w; ++i) + { short *data = z->img_comp[n].coeff + 64 * (i + j * z->img_comp[n].coeff_w); stbi__jpeg_dequantize(data, z->dequant[z->img_comp[n].tq]); z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*j*8+i*8, z->img_comp[n].w2, data); @@ -1520,44 +1531,57 @@ static int stbi__process_marker(stbi__jpeg *z, int m) case STBI__MARKER_none: // no marker found return stbi__err("expected marker","Corrupt JPEG"); - case 0xDD: // DRI - specify restart interval + case 0xDD: /* DRI - specify restart interval */ if (stbi__get16be(z->s) != 4) return stbi__err("bad DRI len","Corrupt JPEG"); z->restart_interval = stbi__get16be(z->s); return 1; - case 0xDB: // DQT - define quantization table + case 0xDB: /* DQT - define quantization table */ L = stbi__get16be(z->s)-2; - while (L > 0) { + while (L > 0) + { int q = stbi__get8(z->s); int p = q >> 4; int t = q & 15,i; - if (p != 0) return stbi__err("bad DQT type","Corrupt JPEG"); - if (t > 3) return stbi__err("bad DQT table","Corrupt JPEG"); + if (p != 0) + return stbi__err("bad DQT type","Corrupt JPEG"); + if (t > 3) + return stbi__err("bad DQT table","Corrupt JPEG"); for (i=0; i < 64; ++i) z->dequant[t][stbi__jpeg_dezigzag[i]] = stbi__get8(z->s); L -= 65; } return L==0; - case 0xC4: // DHT - define huffman table + case 0xC4: /* DHT - define huffman table */ L = stbi__get16be(z->s)-2; - while (L > 0) { - uint8_t *v; + while (L > 0) + { int sizes[16],i,n=0; - int q = stbi__get8(z->s); - int tc = q >> 4; - int th = q & 15; - if (tc > 1 || th > 3) return stbi__err("bad DHT header","Corrupt JPEG"); - for (i=0; i < 16; ++i) { + uint8_t *v = NULL; + int q = stbi__get8(z->s); + int tc = q >> 4; + int th = q & 15; + if (tc > 1 || th > 3) + return stbi__err("bad DHT header","Corrupt JPEG"); + + for (i=0; i < 16; ++i) + { sizes[i] = stbi__get8(z->s); n += sizes[i]; } L -= 17; - if (tc == 0) { - if (!stbi__build_huffman(z->huff_dc+th, sizes)) return 0; + + if (tc == 0) + { + if (!stbi__build_huffman(z->huff_dc+th, sizes)) + return 0; v = z->huff_dc[th].values; - } else { - if (!stbi__build_huffman(z->huff_ac+th, sizes)) return 0; + } + else + { + if (!stbi__build_huffman(z->huff_ac+th, sizes)) + return 0; v = z->huff_ac[th].values; } for (i=0; i < n; ++i) @@ -1568,15 +1592,17 @@ static int stbi__process_marker(stbi__jpeg *z, int m) } return L==0; } - // check for comment block or APP blocks - if ((m >= 0xE0 && m <= 0xEF) || m == 0xFE) { + + /* check for comment block or APP blocks */ + if ((m >= 0xE0 && m <= 0xEF) || m == 0xFE) + { stbi__skip(z->s, stbi__get16be(z->s)-2); return 1; } return 0; } -// after we see SOS +/* after we see SOS */ static int stbi__process_scan_header(stbi__jpeg *z) { int i; @@ -1631,21 +1657,44 @@ static int stbi__process_frame_header(stbi__jpeg *z, int scan) { stbi__context *s = z->s; int Lf,p,i,q, h_max=1,v_max=1,c; - Lf = stbi__get16be(s); if (Lf < 11) return stbi__err("bad SOF len","Corrupt JPEG"); // JPEG - p = stbi__get8(s); if (p != 8) return stbi__err("only 8-bit","JPEG format not supported: 8-bit only"); // JPEG baseline - s->img_y = stbi__get16be(s); if (s->img_y == 0) return stbi__err("no header height", "JPEG format not supported: delayed height"); // Legal, but we don't handle it--but neither does IJG - s->img_x = stbi__get16be(s); if (s->img_x == 0) return stbi__err("0 width","Corrupt JPEG"); // JPEG requires + Lf = stbi__get16be(s); + + if (Lf < 11) + return stbi__err("bad SOF len","Corrupt JPEG"); /* JPEG */ + + p = stbi__get8(s); + + if (p != 8) + return stbi__err("only 8-bit","JPEG format not supported: 8-bit only"); /* JPEG baseline */ + + s->img_y = stbi__get16be(s); + + if (s->img_y == 0) + return stbi__err("no header height", "JPEG format not supported: delayed height"); /* Legal, but we don't handle it--but neither does IJG */ + + s->img_x = stbi__get16be(s); + + if (s->img_x == 0) + return stbi__err("0 width","Corrupt JPEG"); /* JPEG requires */ + c = stbi__get8(s); - if (c != 3 && c != 1) return stbi__err("bad component count","Corrupt JPEG"); // JFIF requires + + if (c != 3 && c != 1) + return stbi__err("bad component count","Corrupt JPEG"); /* JFIF requires */ + s->img_n = c; - for (i=0; i < c; ++i) { + + for (i=0; i < c; ++i) + { z->img_comp[i].data = NULL; z->img_comp[i].linebuf = NULL; } - if (Lf != 8+3*s->img_n) return stbi__err("bad SOF len","Corrupt JPEG"); + if (Lf != 8+3*s->img_n) + return stbi__err("bad SOF len","Corrupt JPEG"); - for (i=0; i < s->img_n; ++i) { + for (i=0; i < s->img_n; ++i) + { z->img_comp[i].id = stbi__get8(s); if (z->img_comp[i].id != i+1) // JFIF requires if (z->img_comp[i].id != i) // some version of jpegtran outputs non-JFIF-compliant files! @@ -1721,7 +1770,7 @@ static int stbi__process_frame_header(stbi__jpeg *z, int scan) static int stbi__decode_jpeg_header(stbi__jpeg *z, int scan) { int m; - z->marker = STBI__MARKER_none; // initialize cached marker to empty + z->marker = STBI__MARKER_none; /* initialize cached marker to empty */ m = stbi__get_marker(z); if (!stbi__SOI(m)) return stbi__err("no SOI","Corrupt JPEG"); if (scan == STBI__SCAN_type) return 1; @@ -1730,7 +1779,7 @@ static int stbi__decode_jpeg_header(stbi__jpeg *z, int scan) if (!stbi__process_marker(z,m)) return 0; m = stbi__get_marker(z); while (m == STBI__MARKER_none) { - // some files have extra padding after their blocks, so ok, we'll scan + /* some files have extra padding after their blocks, so ok, we'll scan */ if (stbi__at_eof(z->s)) return stbi__err("no SOF", "Corrupt JPEG"); m = stbi__get_marker(z); } @@ -1740,65 +1789,77 @@ static int stbi__decode_jpeg_header(stbi__jpeg *z, int scan) return 1; } -// decode image to YCbCr format +/* decode image to YCbCr format */ static int stbi__decode_jpeg_image(stbi__jpeg *j) { int m; - for (m = 0; m < 4; m++) { + for (m = 0; m < 4; m++) + { j->img_comp[m].raw_data = NULL; j->img_comp[m].raw_coeff = NULL; } j->restart_interval = 0; if (!stbi__decode_jpeg_header(j, STBI__SCAN_load)) return 0; m = stbi__get_marker(j); - while (!stbi__EOI(m)) { - if (stbi__SOS(m)) { - if (!stbi__process_scan_header(j)) return 0; - if (!stbi__parse_entropy_coded_data(j)) return 0; - if (j->marker == STBI__MARKER_none ) { - // handle 0s at the end of image data from IP Kamera 9060 - while (!stbi__at_eof(j->s)) { + + while (!stbi__EOI(m)) + { + if (stbi__SOS(m)) + { + if (!stbi__process_scan_header(j)) + return 0; + if (!stbi__parse_entropy_coded_data(j)) + return 0; + + if (j->marker == STBI__MARKER_none ) + { + /* handle 0s at the end of image data from IP Kamera 9060 */ + while (!stbi__at_eof(j->s)) + { int x = stbi__get8(j->s); - if (x == 255) { + if (x == 255) + { j->marker = stbi__get8(j->s); break; - } else if (x != 0) { - return stbi__err("junk before marker", "Corrupt JPEG"); } + else if (x != 0) + return stbi__err("junk before marker", "Corrupt JPEG"); } - // if we reach eof without hitting a marker, stbi__get_marker() below will fail and we'll eventually return 0 + /* if we reach eof without hitting a marker, stbi__get_marker() below will fail and we'll eventually return 0 */ } - } else { - if (!stbi__process_marker(j, m)) return 0; + } + else + { + if (!stbi__process_marker(j, m)) + return 0; } m = stbi__get_marker(j); } + if (j->progressive) stbi__jpeg_finish(j); return 1; } -// static jfif-centered resampling (across block boundaries) +/* static jfif-centered resampling (across block boundaries) */ -typedef uint8_t *(*resample_row_func)(uint8_t *out, uint8_t *in0, uint8_t *in1, - int w, int hs); #define stbi__div4(x) ((uint8_t) ((x) >> 2)) static uint8_t *resample_row_1(uint8_t *out, uint8_t *in_near, uint8_t *in_far, int w, int hs) { - STBI_NOTUSED(out); - STBI_NOTUSED(in_far); - STBI_NOTUSED(w); - STBI_NOTUSED(hs); + (void)out; + (void)in_far; + (void)w; + (void)hs; return in_near; } static uint8_t* stbi__resample_row_v_2(uint8_t *out, uint8_t *in_near, uint8_t *in_far, int w, int hs) { - // need to generate two samples vertically for every one in input + /* need to generate two samples vertically for every one in input */ int i; - STBI_NOTUSED(hs); + (void)hs; for (i=0; i < w; ++i) out[i] = stbi__div4(3*in_near[i] + in_far[i] + 2); return out; @@ -1806,12 +1867,13 @@ static uint8_t* stbi__resample_row_v_2(uint8_t *out, uint8_t *in_near, uint8_t * static uint8_t* stbi__resample_row_h_2(uint8_t *out, uint8_t *in_near, uint8_t *in_far, int w, int hs) { - // need to generate two samples horizontally for every one in input + /* need to generate two samples horizontally for every one in input */ int i; uint8_t *input = in_near; - if (w == 1) { - // if only one sample, can't do any interpolation + if (w == 1) + { + /* if only one sample, can't do any interpolation */ out[0] = out[1] = input[0]; return out; } @@ -1826,8 +1888,8 @@ static uint8_t* stbi__resample_row_h_2(uint8_t *out, uint8_t *in_near, uint8_t out[i*2+0] = stbi__div4(input[w-2]*3 + input[w-1] + 2); out[i*2+1] = input[w-1]; - STBI_NOTUSED(in_far); - STBI_NOTUSED(hs); + (void)in_far; + (void)hs; return out; } @@ -1836,7 +1898,7 @@ static uint8_t* stbi__resample_row_h_2(uint8_t *out, uint8_t *in_near, uint8_t static uint8_t *stbi__resample_row_hv_2(uint8_t *out, uint8_t *in_near, uint8_t *in_far, int w, int hs) { - // need to generate 2x2 samples for every one in input + /* need to generate 2x2 samples for every one in input */ int i,t0,t1; if (w == 1) { out[0] = out[1] = stbi__div4(3*in_near[0] + in_far[0] + 2); @@ -1853,12 +1915,12 @@ static uint8_t *stbi__resample_row_hv_2(uint8_t *out, uint8_t *in_near, uint8_t } out[w*2-1] = stbi__div4(t1+2); - STBI_NOTUSED(hs); + (void)hs; return out; } -#if defined(STBI_SSE2) || defined(STBI_NEON) +#if defined(__SSE2__) || defined(STBI_NEON) static uint8_t *stbi__resample_row_hv_2_simd(uint8_t *out, uint8_t *in_near, uint8_t *in_far, int w, int hs) { /* need to generate 2x2 samples for every one in input */ @@ -1876,7 +1938,7 @@ static uint8_t *stbi__resample_row_hv_2_simd(uint8_t *out, uint8_t *in_near, uin */ for (; i < ((w-1) & ~7); i += 8) { -#if defined(STBI_SSE2) +#if defined(__SSE2__) /* load and perform the vertical filtering pass * this uses 3*x + y = 4*x + (y - x) */ __m128i zero = _mm_setzero_si128(); @@ -1921,19 +1983,19 @@ static uint8_t *stbi__resample_row_hv_2_simd(uint8_t *out, uint8_t *in_near, uin __m128i outv = _mm_packus_epi16(de0, de1); _mm_storeu_si128((__m128i *) (out + i*2), outv); #elif defined(STBI_NEON) - // load and perform the vertical filtering pass - // this uses 3*x + y = 4*x + (y - x) + /* load and perform the vertical filtering pass + * this uses 3*x + y = 4*x + (y - x) */ uint8x8_t farb = vld1_u8(in_far + i); uint8x8_t nearb = vld1_u8(in_near + i); int16x8_t diff = vreinterpretq_s16_u16(vsubl_u8(farb, nearb)); int16x8_t nears = vreinterpretq_s16_u16(vshll_n_u8(nearb, 2)); - int16x8_t curr = vaddq_s16(nears, diff); // current row + int16x8_t curr = vaddq_s16(nears, diff); /* current row */ - // horizontal filter works the same based on shifted vers of current - // row. "prev" is current row shifted right by 1 pixel; we need to - // insert the previous pixel value (from t1). - // "next" is current row shifted left by 1 pixel, with first pixel - // of next block of 8 pixels added in. + /* horizontal filter works the same based on shifted vers of current + * row. "prev" is current row shifted right by 1 pixel; we need to + * insert the previous pixel value (from t1). + * "next" is current row shifted left by 1 pixel, with first pixel + * of next block of 8 pixels added in. */ int16x8_t prv0 = vextq_s16(curr, curr, 7); int16x8_t nxt0 = vextq_s16(curr, curr, 1); int16x8_t prev = vsetq_lane_s16(t1, prv0, 0); @@ -1973,7 +2035,7 @@ static uint8_t *stbi__resample_row_hv_2_simd(uint8_t *out, uint8_t *in_near, uin } out[w*2-1] = stbi__div4(t1+2); - STBI_NOTUSED(hs); + (void)hs; return out; } @@ -1983,42 +2045,14 @@ static uint8_t *stbi__resample_row_generic(uint8_t *out, uint8_t *in_near, uint8 { /* resample with nearest-neighbor */ int i,j; - STBI_NOTUSED(in_far); + (void)in_far; + for (i=0; i < w; ++i) for (j=0; j < hs; ++j) out[i*hs+j] = in_near[i]; return out; } -#ifdef STBI_JPEG_OLD -/* this is the same YCbCr-to-RGB calculation that stb_image has used - * historically before the algorithm changes in 1.49 */ -#define float2fixed(x) ((int) ((x) * 65536 + 0.5)) -static void stbi__YCbCr_to_RGB_row(uint8_t *out, const uint8_t *y, const uint8_t *pcb, const uint8_t *pcr, int count, int step) -{ - int i; - for (i=0; i < count; ++i) { - int y_fixed = (y[i] << 16) + 32768; // rounding - int r,g,b; - int cr = pcr[i] - 128; - int cb = pcb[i] - 128; - r = y_fixed + cr*float2fixed(1.40200f); - g = y_fixed - cr*float2fixed(0.71414f) - cb*float2fixed(0.34414f); - b = y_fixed + cb*float2fixed(1.77200f); - r >>= 16; - g >>= 16; - b >>= 16; - if ((unsigned) r > 255) { if (r < 0) r = 0; else r = 255; } - if ((unsigned) g > 255) { if (g < 0) g = 0; else g = 255; } - if ((unsigned) b > 255) { if (b < 0) b = 0; else b = 255; } - out[0] = (uint8_t)r; - out[1] = (uint8_t)g; - out[2] = (uint8_t)b; - out[3] = 255; - out += step; - } -} -#else /* this is a reduced-precision calculation of YCbCr-to-RGB introduced * to make sure the code produces the same results in both SIMD and scalar */ #define float2fixed(x) (((int) ((x) * 4096.0f + 0.5f)) << 8) @@ -2046,14 +2080,13 @@ static void stbi__YCbCr_to_RGB_row(uint8_t *out, const uint8_t *y, const uint8_t out += step; } } -#endif -#if defined(STBI_SSE2) || defined(STBI_NEON) +#if defined(__SSE2__) || defined(STBI_NEON) static void stbi__YCbCr_to_RGB_simd(uint8_t *out, const uint8_t *y, const uint8_t *pcb, const uint8_t *pcr, int count, int step) { int i = 0; -#ifdef STBI_SSE2 +#if defined(__SSE2__) /* step == 3 is pretty ugly on the final interleave, and i'm not convinced * it's useful in practice (you wouldn't use it for textures, for example). * so just accelerate step == 4 case. @@ -2071,19 +2104,19 @@ static void stbi__YCbCr_to_RGB_simd(uint8_t *out, const uint8_t *y, const uint8_ for (; i+7 < count; i += 8) { - // load + /* load */ __m128i y_bytes = _mm_loadl_epi64((__m128i *) (y+i)); __m128i cr_bytes = _mm_loadl_epi64((__m128i *) (pcr+i)); __m128i cb_bytes = _mm_loadl_epi64((__m128i *) (pcb+i)); - __m128i cr_biased = _mm_xor_si128(cr_bytes, signflip); // -128 - __m128i cb_biased = _mm_xor_si128(cb_bytes, signflip); // -128 + __m128i cr_biased = _mm_xor_si128(cr_bytes, signflip); /* -128 */ + __m128i cb_biased = _mm_xor_si128(cb_bytes, signflip); /* -128 */ - // unpack to short (and left-shift cr, cb by 8) + /* unpack to short (and left-shift cr, cb by 8) */ __m128i yw = _mm_unpacklo_epi8(y_bias, y_bytes); __m128i crw = _mm_unpacklo_epi8(_mm_setzero_si128(), cr_biased); __m128i cbw = _mm_unpacklo_epi8(_mm_setzero_si128(), cb_biased); - // color transform + /* color transform */ __m128i yws = _mm_srli_epi16(yw, 4); __m128i cr0 = _mm_mulhi_epi16(cr_const0, crw); __m128i cb0 = _mm_mulhi_epi16(cb_const0, cbw); @@ -2094,22 +2127,22 @@ static void stbi__YCbCr_to_RGB_simd(uint8_t *out, const uint8_t *y, const uint8_ __m128i bws = _mm_add_epi16(yws, cb1); __m128i gws = _mm_add_epi16(gwt, cr1); - // descale + /* descale */ __m128i rw = _mm_srai_epi16(rws, 4); __m128i bw = _mm_srai_epi16(bws, 4); __m128i gw = _mm_srai_epi16(gws, 4); - // back to byte, set up for transpose + /* back to byte, set up for transpose */ __m128i brb = _mm_packus_epi16(rw, bw); __m128i gxb = _mm_packus_epi16(gw, xw); - // transpose to interleave channels + /* transpose to interleave channels */ __m128i t0 = _mm_unpacklo_epi8(brb, gxb); __m128i t1 = _mm_unpackhi_epi8(brb, gxb); __m128i o0 = _mm_unpacklo_epi16(t0, t1); __m128i o1 = _mm_unpackhi_epi16(t0, t1); - // store + /* store */ _mm_storeu_si128((__m128i *) (out + 0), o0); _mm_storeu_si128((__m128i *) (out + 16), o1); out += 32; @@ -2118,29 +2151,33 @@ static void stbi__YCbCr_to_RGB_simd(uint8_t *out, const uint8_t *y, const uint8_ #endif #ifdef STBI_NEON - // in this version, step=3 support would be easy to add. but is there demand? - if (step == 4) { - // this is a fairly straightforward implementation and not super-optimized. + /* in this version, step=3 support would be easy to add. but is there demand? */ + if (step == 4) + { + /* this is a fairly straightforward implementation and not super-optimized. */ uint8x8_t signflip = vdup_n_u8(0x80); int16x8_t cr_const0 = vdupq_n_s16( (short) ( 1.40200f*4096.0f+0.5f)); int16x8_t cr_const1 = vdupq_n_s16( - (short) ( 0.71414f*4096.0f+0.5f)); int16x8_t cb_const0 = vdupq_n_s16( - (short) ( 0.34414f*4096.0f+0.5f)); int16x8_t cb_const1 = vdupq_n_s16( (short) ( 1.77200f*4096.0f+0.5f)); - for (; i+7 < count; i += 8) { - // load + for (; i+7 < count; i += 8) + { + uint8x8x4_t o; + + /* load */ uint8x8_t y_bytes = vld1_u8(y + i); uint8x8_t cr_bytes = vld1_u8(pcr + i); uint8x8_t cb_bytes = vld1_u8(pcb + i); int8x8_t cr_biased = vreinterpret_s8_u8(vsub_u8(cr_bytes, signflip)); int8x8_t cb_biased = vreinterpret_s8_u8(vsub_u8(cb_bytes, signflip)); - // expand to s16 + /* expand to s16 */ int16x8_t yws = vreinterpretq_s16_u16(vshll_n_u8(y_bytes, 4)); int16x8_t crw = vshll_n_s8(cr_biased, 7); int16x8_t cbw = vshll_n_s8(cb_biased, 7); - // color transform + /* color transform */ int16x8_t cr0 = vqdmulhq_s16(crw, cr_const0); int16x8_t cb0 = vqdmulhq_s16(cbw, cb_const0); int16x8_t cr1 = vqdmulhq_s16(crw, cr_const1); @@ -2149,28 +2186,27 @@ static void stbi__YCbCr_to_RGB_simd(uint8_t *out, const uint8_t *y, const uint8_ int16x8_t gws = vaddq_s16(vaddq_s16(yws, cb0), cr1); int16x8_t bws = vaddq_s16(yws, cb1); - // undo scaling, round, convert to byte - uint8x8x4_t o; + /* undo scaling, round, convert to byte */ o.val[0] = vqrshrun_n_s16(rws, 4); o.val[1] = vqrshrun_n_s16(gws, 4); o.val[2] = vqrshrun_n_s16(bws, 4); o.val[3] = vdup_n_u8(255); - // store, interleaving r/g/b/a + /* store, interleaving r/g/b/a */ vst4_u8(out, o); out += 8*4; } } #endif - for (; i < count; ++i) { + for (; i < count; ++i) + { int y_fixed = (y[i] << 20) + (1<<19); // rounding - int r,g,b; - int cr = pcr[i] - 128; - int cb = pcb[i] - 128; - r = y_fixed + cr* float2fixed(1.40200f); - g = y_fixed + cr*-float2fixed(0.71414f) + ((cb*-float2fixed(0.34414f)) & 0xffff0000); - b = y_fixed + cb* float2fixed(1.77200f); + int cr = pcr[i] - 128; + int cb = pcb[i] - 128; + int r = y_fixed + cr* float2fixed(1.40200f); + int g = y_fixed + cr*-float2fixed(0.71414f) + ((cb*-float2fixed(0.34414f)) & 0xffff0000); + int b = y_fixed + cb* float2fixed(1.77200f); r >>= 20; g >>= 20; b >>= 20; @@ -2193,21 +2229,19 @@ static void stbi__setup_jpeg(stbi__jpeg *j) j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_row; j->resample_row_hv_2_kernel = stbi__resample_row_hv_2; -#ifdef STBI_SSE2 - if (stbi__sse2_available()) { + +#if defined(__SSE2__) + if (stbi__sse2_available()) + { j->idct_block_kernel = stbi__idct_simd; - #ifndef STBI_JPEG_OLD j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_simd; - #endif j->resample_row_hv_2_kernel = stbi__resample_row_hv_2_simd; } #endif #ifdef STBI_NEON j->idct_block_kernel = stbi__idct_simd; - #ifndef STBI_JPEG_OLD j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_simd; - #endif j->resample_row_hv_2_kernel = stbi__resample_row_hv_2_simd; #endif } @@ -2216,46 +2250,43 @@ static void stbi__setup_jpeg(stbi__jpeg *j) static void stbi__cleanup_jpeg(stbi__jpeg *j) { int i; - for (i=0; i < j->s->img_n; ++i) { - if (j->img_comp[i].raw_data) { + for (i=0; i < j->s->img_n; ++i) + { + if (j->img_comp[i].raw_data) + { free(j->img_comp[i].raw_data); j->img_comp[i].raw_data = NULL; j->img_comp[i].data = NULL; } - if (j->img_comp[i].raw_coeff) { + + if (j->img_comp[i].raw_coeff) + { free(j->img_comp[i].raw_coeff); j->img_comp[i].raw_coeff = 0; j->img_comp[i].coeff = 0; } - if (j->img_comp[i].linebuf) { + + if (j->img_comp[i].linebuf) + { free(j->img_comp[i].linebuf); j->img_comp[i].linebuf = NULL; } } } -typedef struct -{ - resample_row_func resample; - uint8_t *line0,*line1; - int hs,vs; // expansion factor in each axis - int w_lores; // horizontal pixels pre-expansion - int ystep; // how far through vertical expansion we are - int ypos; // which pre-expansion row we're on -} stbi__resample; static uint8_t *load_jpeg_image(stbi__jpeg *z, int *out_x, int *out_y, int *comp, int req_comp) { int n, decode_n; - z->s->img_n = 0; // make stbi__cleanup_jpeg safe + z->s->img_n = 0; /* make stbi__cleanup_jpeg safe */ - // validate req_comp + /* validate req_comp */ if (req_comp < 0 || req_comp > 4) return stbi__errpuc("bad req_comp", "Internal error"); - // load a jpeg image from whichever source, but leave in YCbCr format + /* load a jpeg image from whichever source, but leave in YCbCr format */ if (!stbi__decode_jpeg_image(z)) { stbi__cleanup_jpeg(z); return NULL; } - // determine actual number of components to generate + /* determine actual number of components to generate */ n = req_comp ? req_comp : z->s->img_n; if (z->s->img_n == 3 && n < 3) @@ -2263,7 +2294,7 @@ static uint8_t *load_jpeg_image(stbi__jpeg *z, int *out_x, int *out_y, int *comp else decode_n = z->s->img_n; - // resample and color-convert + /* resample and color-convert */ { int k; unsigned int i,j; @@ -2272,11 +2303,12 @@ static uint8_t *load_jpeg_image(stbi__jpeg *z, int *out_x, int *out_y, int *comp stbi__resample res_comp[4]; - for (k=0; k < decode_n; ++k) { + for (k=0; k < decode_n; ++k) + { stbi__resample *r = &res_comp[k]; - // allocate line buffer big enough for upsampling off the edges - // with upsample factor of 4 + /* allocate line buffer big enough for upsampling off the edges + * with upsample factor of 4 */ z->img_comp[k].linebuf = (uint8_t *) malloc(z->s->img_x + 3); if (!z->img_comp[k].linebuf) { stbi__cleanup_jpeg(z); return stbi__errpuc("outofmem", "Out of memory"); } @@ -2294,49 +2326,68 @@ static uint8_t *load_jpeg_image(stbi__jpeg *z, int *out_x, int *out_y, int *comp else r->resample = stbi__resample_row_generic; } - // can't error after this so, this is safe + /* can't error after this so, this is safe */ output = (uint8_t *) malloc(n * z->s->img_x * z->s->img_y + 1); - if (!output) { stbi__cleanup_jpeg(z); return stbi__errpuc("outofmem", "Out of memory"); } - // now go ahead and resample - for (j=0; j < z->s->img_y; ++j) { + if (!output) + { + stbi__cleanup_jpeg(z); + return stbi__errpuc("outofmem", "Out of memory"); + } + + /* now go ahead and resample */ + for (j=0; j < z->s->img_y; ++j) + { uint8_t *out = output + n * z->s->img_x * j; - for (k=0; k < decode_n; ++k) { + for (k=0; k < decode_n; ++k) + { stbi__resample *r = &res_comp[k]; - int y_bot = r->ystep >= (r->vs >> 1); + int y_bot = r->ystep >= (r->vs >> 1); coutput[k] = r->resample(z->img_comp[k].linebuf, - y_bot ? r->line1 : r->line0, - y_bot ? r->line0 : r->line1, - r->w_lores, r->hs); - if (++r->ystep >= r->vs) { + y_bot ? r->line1 : r->line0, + y_bot ? r->line0 : r->line1, + r->w_lores, r->hs); + + if (++r->ystep >= r->vs) + { r->ystep = 0; r->line0 = r->line1; if (++r->ypos < z->img_comp[k].y) r->line1 += z->img_comp[k].w2; } } - if (n >= 3) { + + if (n >= 3) + { uint8_t *y = coutput[0]; - if (z->s->img_n == 3) { + if (z->s->img_n == 3) z->YCbCr_to_RGB_kernel(out, y, coutput[1], coutput[2], z->s->img_x, n); - } else - for (i=0; i < z->s->img_x; ++i) { + else + for (i=0; i < z->s->img_x; ++i) + { out[0] = out[1] = out[2] = y[i]; - out[3] = 255; // not used if n==3 + out[3] = 255; /* not used if n==3 */ out += n; } - } else { + } + else + { uint8_t *y = coutput[0]; if (n == 1) - for (i=0; i < z->s->img_x; ++i) out[i] = y[i]; + for (i=0; i < z->s->img_x; ++i) + out[i] = y[i]; else - for (i=0; i < z->s->img_x; ++i) *out++ = y[i], *out++ = 255; + for (i=0; i < z->s->img_x; ++i) + *out++ = y[i], *out++ = 255; } } + stbi__cleanup_jpeg(z); *out_x = z->s->img_x; *out_y = z->s->img_y; - if (comp) *comp = z->s->img_n; // report original components, not output + + if (comp) + *comp = z->s->img_n; /* report original components, not output */ return output; } } @@ -2359,7 +2410,6 @@ static int stbi__jpeg_test(stbi__context *s) stbi__rewind(s); return r; } -#endif static INLINE void video_frame_convert_rgba_to_bgra( const void *src_data, From 88f259d3ef7a5635dd0c9f2fd62d85f022be4a00 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Tue, 10 May 2016 07:05:52 +0200 Subject: [PATCH 369/498] (RJPEG) Mass renaming (pt. 1) --- libretro-common/formats/jpeg/rjpeg.c | 205 ++++++++++++++------------- 1 file changed, 109 insertions(+), 96 deletions(-) diff --git a/libretro-common/formats/jpeg/rjpeg.c b/libretro-common/formats/jpeg/rjpeg.c index 29b7f18ee6..55b7d3e33c 100644 --- a/libretro-common/formats/jpeg/rjpeg.c +++ b/libretro-common/formats/jpeg/rjpeg.c @@ -11,11 +11,11 @@ enum { - STBI_default = 0, /* only used for req_comp */ - STBI_grey = 1, - STBI_grey_alpha = 2, - STBI_rgb = 3, - STBI_rgb_alpha = 4 + RJPEG_DEFAULT = 0, /* only used for req_comp */ + RJPEG_GREY, + RJPEG_GREY_ALPHA, + RJPEG_RGB, + RJPEG_RGB_ALPHA }; typedef struct @@ -23,7 +23,7 @@ typedef struct int (*read) (void *user,char *data,int size); /* fill 'data' with 'size' bytes. return number of bytes actually read */ void (*skip) (void *user,int n); /* skip the next 'n' bytes, or 'unget' the last -n bytes if negative */ int (*eof) (void *user); /* returns nonzero if we are at end of file/data */ -} stbi_io_callbacks; +} rjpeg_io_callbacks; typedef uint8_t *(*resample_row_func)(uint8_t *out, uint8_t *in0, uint8_t *in1, int w, int hs); @@ -36,10 +36,7 @@ typedef struct int w_lores; /* horizontal pixels pre-expansion */ int ystep; /* how far through vertical expansion we are */ int ypos; /* which pre-expansion row we're on */ -} stbi__resample; - -/* should produce compiler error if size is wrong */ -typedef unsigned char validate_uint32[sizeof(uint32_t)==4 ? 1 : -1]; +} rjpeg__resample; #ifdef _MSC_VER #define STBI_HAS_LROTL @@ -118,7 +115,7 @@ static int stbi__sse2_available(void) return ((info3 >> 26) & 1) != 0; } #else /* assume GCC-style if not VC++ */ -#define STBI_SIMD_ALIGN(type, name) type name __attribute__((aligned(16))) +#define RJPEG_SIMD_ALIGN(type, name) type name __attribute__((aligned(16))) static int stbi__sse2_available(void) { @@ -163,10 +160,10 @@ typedef struct uint8_t *img_buffer, *img_buffer_end; uint8_t *img_buffer_original; -} stbi__context; +} rjpeg__context; /* initialize a memory-decode context */ -static void stbi__start_mem(stbi__context *s, const uint8_t *buffer, int len) +static void rjpeg__start_mem(stbi__context *s, const uint8_t *buffer, int len) { s->io.read = NULL; s->read_from_callbacks = 0; @@ -174,7 +171,7 @@ static void stbi__start_mem(stbi__context *s, const uint8_t *buffer, int len) s->img_buffer_end = (uint8_t *) buffer+len; } -static void stbi__rewind(stbi__context *s) +static void rjpeg__rewind(stbi__context *s) { /* conceptually rewind SHOULD rewind to the beginning of the stream, * but we just rewind to the beginning of the initial buffer, because @@ -189,11 +186,11 @@ static uint8_t *stbi__jpeg_load(stbi__context *s, int *x, int *y, int *comp, int #endif /* this is not threadsafe */ -static const char *stbi__g_failure_reason; +static const char *rjpeg__g_failure_reason; -static int stbi__err(const char *str) +static INLINE int rjpeg__err(const char *str) { - stbi__g_failure_reason = str; + rjpeg__g_failure_reason = str; return 0; } @@ -208,9 +205,9 @@ static int stbi__err(const char *str) #define stbi__errpf(x,y) ((float *) (stbi__err(x,y)?NULL:NULL)) #define stbi__errpuc(x,y) ((unsigned char *) (stbi__err(x,y)?NULL:NULL)) -static int stbi__vertically_flip_on_load = 0; +static int rjpeg__vertically_flip_on_load = 0; -static unsigned char *stbi__load_main(stbi__context *s, int *x, int *y, int *comp, int req_comp) +static unsigned char *rjpeg__load_main(stbi__context *s, int *x, int *y, int *comp, int req_comp) { #ifndef STBI_NO_JPEG if (stbi__jpeg_test(s)) return stbi__jpeg_load(s,x,y,comp,req_comp); @@ -219,7 +216,7 @@ static unsigned char *stbi__load_main(stbi__context *s, int *x, int *y, int *com return stbi__errpuc("unknown image type", "Image not of any known type, or corrupt"); } -static unsigned char *stbi__load_flip(stbi__context *s, int *x, int *y, int *comp, int req_comp) +static unsigned char *rjpeg__load_flip(stbi__context *s, int *x, int *y, int *comp, int req_comp) { unsigned char *result = stbi__load_main(s, x, y, comp, req_comp); @@ -247,7 +244,7 @@ static unsigned char *stbi__load_flip(stbi__context *s, int *x, int *y, int *com return result; } -static uint8_t *stbi_load_from_memory(const uint8_t *buffer, int len, int *x, int *y, int *comp, int req_comp) +static uint8_t *rjpeg_load_from_memory(const uint8_t *buffer, int len, int *x, int *y, int *comp, int req_comp) { stbi__context s; stbi__start_mem(&s,buffer,len); @@ -256,12 +253,12 @@ static uint8_t *stbi_load_from_memory(const uint8_t *buffer, int len, int *x, in enum { - STBI__SCAN_load=0, - STBI__SCAN_type, - STBI__SCAN_header + RJPEG_SCAN_LOAD = 0, + RJPEG_SCAN_TYPE, + RJPEG_SCAN_HEADER }; -static void stbi__refill_buffer(stbi__context *s) +static void rjpeg__refill_buffer(stbi__context *s) { int n = (s->io.read)(s->io_user_data,(char*)s->buffer_start,s->buflen); @@ -281,7 +278,7 @@ static void stbi__refill_buffer(stbi__context *s) } } -static INLINE uint8_t stbi__get8(stbi__context *s) +static INLINE uint8_t rjpeg__get8(stbi__context *s) { if (s->img_buffer < s->img_buffer_end) return *s->img_buffer++; @@ -295,7 +292,7 @@ static INLINE uint8_t stbi__get8(stbi__context *s) return 0; } -static INLINE int stbi__at_eof(stbi__context *s) +static INLINE int rjpeg__at_eof(stbi__context *s) { if (s->io.read) { @@ -313,7 +310,7 @@ static INLINE int stbi__at_eof(stbi__context *s) return s->img_buffer >= s->img_buffer_end; } -static void stbi__skip(stbi__context *s, int n) +static void rjpeg__skip(stbi__context *s, int n) { if (n < 0) { s->img_buffer = s->img_buffer_end; @@ -330,13 +327,13 @@ static void stbi__skip(stbi__context *s, int n) s->img_buffer += n; } -static int stbi__get16be(stbi__context *s) +static int rjpeg__get16be(stbi__context *s) { int z = stbi__get8(s); return (z << 8) + stbi__get8(s); } -#define STBI__BYTECAST(x) ((uint8_t) ((x) & 255)) /* truncate int to byte without warnings */ +#define RJPEG__BYTECAST(x) ((uint8_t) ((x) & 255)) /* truncate int to byte without warnings */ /* huffman decoding acceleration */ #define FAST_BITS 9 /* larger handles more cases; smaller stomps less cache */ @@ -350,7 +347,7 @@ typedef struct uint8_t size[257]; unsigned int maxcode[18]; int delta[17]; /* old 'firstsymbol' - old 'firstcode' */ -} stbi__huffman; +} rjpeg__huffman; typedef struct { @@ -401,9 +398,9 @@ typedef struct void (*idct_block_kernel)(uint8_t *out, int out_stride, short data[64]); void (*YCbCr_to_RGB_kernel)(uint8_t *out, const uint8_t *y, const uint8_t *pcb, const uint8_t *pcr, int count, int step); uint8_t *(*resample_row_hv_2_kernel)(uint8_t *out, uint8_t *in_near, uint8_t *in_far, int w, int hs); -} stbi__jpeg; +} rjpeg__jpeg; -static int stbi__build_huffman(stbi__huffman *h, int *count) +static int rjpeg__build_huffman(stbi__huffman *h, int *count) { int i,j,k=0,code; /* build size list for each symbol (from JPEG spec) */ @@ -450,7 +447,7 @@ static int stbi__build_huffman(stbi__huffman *h, int *count) /* build a table that decodes both magnitude and value of small ACs in * one go. */ -static void stbi__build_fast_ac(int16_t *fast_ac, stbi__huffman *h) +static void rjpeg__build_fast_ac(int16_t *fast_ac, rjpeg__huffman *h) { int i; @@ -480,14 +477,14 @@ static void stbi__build_fast_ac(int16_t *fast_ac, stbi__huffman *h) } } -static void stbi__grow_buffer_unsafe(stbi__jpeg *j) +static void rjpeg__grow_buffer_unsafe(rjpeg__jpeg *j) { do { - int b = j->nomore ? 0 : stbi__get8(j->s); + int b = j->nomore ? 0 : rjpeg__get8(j->s); if (b == 0xff) { - int c = stbi__get8(j->s); + int c = rjpeg__get8(j->s); if (c != 0) { @@ -502,16 +499,16 @@ static void stbi__grow_buffer_unsafe(stbi__jpeg *j) } /* (1 << n) - 1 */ -static uint32_t stbi__bmask[17]={0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535}; +static uint32_t rjpeg__bmask[17]={0,1,3,7,15,31,63,127,255,511,1023,2047,4095,8191,16383,32767,65535}; /* decode a JPEG huffman value from the bitstream */ -static INLINE int stbi__jpeg_huff_decode(stbi__jpeg *j, stbi__huffman *h) +static INLINE int rjpeg__jpeg_huff_decode(rjpeg__jpeg *j, rjpeg__huffman *h) { unsigned int temp; int c,k; if (j->code_bits < 16) - stbi__grow_buffer_unsafe(j); + rjpeg__grow_buffer_unsafe(j); /* look at the top FAST_BITS and determine what symbol ID it is, * if the code is <= FAST_BITS */ @@ -549,8 +546,8 @@ static INLINE int stbi__jpeg_huff_decode(stbi__jpeg *j, stbi__huffman *h) return -1; /* convert the huffman code to the symbol id */ - c = ((j->code_buffer >> (32 - k)) & stbi__bmask[k]) + h->delta[k]; - assert((((j->code_buffer) >> (32 - h->size[c])) & stbi__bmask[h->size[c]]) == h->code[c]); + c = ((j->code_buffer >> (32 - k)) & rjpeg__bmask[k]) + h->delta[k]; + assert((((j->code_buffer) >> (32 - h->size[c])) & rjpeg__bmask[h->size[c]]) == h->code[c]); /* convert the id to a symbol */ j->code_bits -= k; @@ -559,11 +556,11 @@ static INLINE int stbi__jpeg_huff_decode(stbi__jpeg *j, stbi__huffman *h) } /* bias[n] = (-1<> 2)) +#define rjpeg__div4(x) ((uint8_t) ((x) >> 2)) -static uint8_t *resample_row_1(uint8_t *out, uint8_t *in_near, uint8_t *in_far, int w, int hs) +static uint8_t *rjpeg_resample_row_1(uint8_t *out, uint8_t *in_near, uint8_t *in_far, int w, int hs) { (void)out; (void)in_far; @@ -1855,17 +1852,17 @@ static uint8_t *resample_row_1(uint8_t *out, uint8_t *in_near, uint8_t *in_far, return in_near; } -static uint8_t* stbi__resample_row_v_2(uint8_t *out, uint8_t *in_near, uint8_t *in_far, int w, int hs) +static uint8_t* rjpeg__resample_row_v_2(uint8_t *out, uint8_t *in_near, uint8_t *in_far, int w, int hs) { /* need to generate two samples vertically for every one in input */ int i; (void)hs; for (i=0; i < w; ++i) - out[i] = stbi__div4(3*in_near[i] + in_far[i] + 2); + out[i] = rjpeg__div4(3*in_near[i] + in_far[i] + 2); return out; } -static uint8_t* stbi__resample_row_h_2(uint8_t *out, uint8_t *in_near, uint8_t *in_far, int w, int hs) +static uint8_t* rjpeg__resample_row_h_2(uint8_t *out, uint8_t *in_near, uint8_t *in_far, int w, int hs) { /* need to generate two samples horizontally for every one in input */ int i; @@ -1894,26 +1891,28 @@ static uint8_t* stbi__resample_row_h_2(uint8_t *out, uint8_t *in_near, uint8_t return out; } -#define stbi__div16(x) ((uint8_t) ((x) >> 4)) +#define rjpeg__div16(x) ((uint8_t) ((x) >> 4)) -static uint8_t *stbi__resample_row_hv_2(uint8_t *out, uint8_t *in_near, uint8_t *in_far, int w, int hs) +static uint8_t *rjpeg__resample_row_hv_2(uint8_t *out, uint8_t *in_near, uint8_t *in_far, int w, int hs) { /* need to generate 2x2 samples for every one in input */ int i,t0,t1; - if (w == 1) { - out[0] = out[1] = stbi__div4(3*in_near[0] + in_far[0] + 2); + if (w == 1) + { + out[0] = out[1] = rjpeg__div4(3*in_near[0] + in_far[0] + 2); return out; } - t1 = 3*in_near[0] + in_far[0]; - out[0] = stbi__div4(t1+2); - for (i=1; i < w; ++i) { + t1 = 3*in_near[0] + in_far[0]; + out[0] = rjpeg__div4(t1+2); + for (i=1; i < w; ++i) + { t0 = t1; t1 = 3*in_near[i]+in_far[i]; - out[i*2-1] = stbi__div16(3*t0 + t1 + 8); - out[i*2 ] = stbi__div16(3*t1 + t0 + 8); + out[i*2-1] = rjpeg__div16(3*t0 + t1 + 8); + out[i*2 ] = rjpeg__div16(3*t1 + t0 + 8); } - out[w*2-1] = stbi__div4(t1+2); + out[w*2-1] = rjpeg__div4(t1+2); (void)hs; @@ -1921,13 +1920,14 @@ static uint8_t *stbi__resample_row_hv_2(uint8_t *out, uint8_t *in_near, uint8_t } #if defined(__SSE2__) || defined(STBI_NEON) -static uint8_t *stbi__resample_row_hv_2_simd(uint8_t *out, uint8_t *in_near, uint8_t *in_far, int w, int hs) +static uint8_t *rjpeg__resample_row_hv_2_simd(uint8_t *out, uint8_t *in_near, uint8_t *in_far, int w, int hs) { /* need to generate 2x2 samples for every one in input */ int i=0,t0,t1; - if (w == 1) { - out[0] = out[1] = stbi__div4(3*in_near[0] + in_far[0] + 2); + if (w == 1) + { + out[0] = out[1] = rjpeg__div4(3*in_near[0] + in_far[0] + 2); return out; } @@ -2023,13 +2023,14 @@ static uint8_t *stbi__resample_row_hv_2_simd(uint8_t *out, uint8_t *in_near, uin t1 = 3*in_near[i+7] + in_far[i+7]; } - t0 = t1; - t1 = 3*in_near[i] + in_far[i]; - out[i*2] = stbi__div16(3*t1 + t0 + 8); + t0 = t1; + t1 = 3*in_near[i] + in_far[i]; + out[i*2] = rjpeg__div16(3*t1 + t0 + 8); - for (++i; i < w; ++i) { - t0 = t1; - t1 = 3*in_near[i]+in_far[i]; + for (++i; i < w; ++i) + { + t0 = t1; + t1 = 3*in_near[i]+in_far[i]; out[i*2-1] = stbi__div16(3*t0 + t1 + 8); out[i*2 ] = stbi__div16(3*t1 + t0 + 8); } @@ -2041,7 +2042,7 @@ static uint8_t *stbi__resample_row_hv_2_simd(uint8_t *out, uint8_t *in_near, uin } #endif -static uint8_t *stbi__resample_row_generic(uint8_t *out, uint8_t *in_near, uint8_t *in_far, int w, int hs) +static uint8_t *rjpeg__resample_row_generic(uint8_t *out, uint8_t *in_near, uint8_t *in_far, int w, int hs) { /* resample with nearest-neighbor */ int i,j; @@ -2055,8 +2056,11 @@ static uint8_t *stbi__resample_row_generic(uint8_t *out, uint8_t *in_near, uint8 /* this is a reduced-precision calculation of YCbCr-to-RGB introduced * to make sure the code produces the same results in both SIMD and scalar */ +#ifndef float2fixed #define float2fixed(x) (((int) ((x) * 4096.0f + 0.5f)) << 8) -static void stbi__YCbCr_to_RGB_row(uint8_t *out, const uint8_t *y, const uint8_t *pcb, const uint8_t *pcr, int count, int step) +#endif + +static void rjpeg__YCbCr_to_RGB_row(uint8_t *out, const uint8_t *y, const uint8_t *pcb, const uint8_t *pcr, int count, int step) { int i; for (i=0; i < count; ++i) { @@ -2082,7 +2086,7 @@ static void stbi__YCbCr_to_RGB_row(uint8_t *out, const uint8_t *y, const uint8_t } #if defined(__SSE2__) || defined(STBI_NEON) -static void stbi__YCbCr_to_RGB_simd(uint8_t *out, const uint8_t *y, const uint8_t *pcb, const uint8_t *pcr, int count, int step) +static void rjpeg__YCbCr_to_RGB_simd(uint8_t *out, const uint8_t *y, const uint8_t *pcb, const uint8_t *pcr, int count, int step) { int i = 0; @@ -2223,31 +2227,31 @@ static void stbi__YCbCr_to_RGB_simd(uint8_t *out, const uint8_t *y, const uint8_ #endif /* set up the kernels */ -static void stbi__setup_jpeg(stbi__jpeg *j) +static void rjpeg__setup_jpeg(rjpeg__jpeg *j) { - j->idct_block_kernel = stbi__idct_block; - j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_row; - j->resample_row_hv_2_kernel = stbi__resample_row_hv_2; + j->idct_block_kernel = rjpeg__idct_block; + j->YCbCr_to_RGB_kernel = rjpeg__YCbCr_to_RGB_row; + j->resample_row_hv_2_kernel = rjpeg__resample_row_hv_2; #if defined(__SSE2__) - if (stbi__sse2_available()) + if (rjpeg__sse2_available()) { - j->idct_block_kernel = stbi__idct_simd; - j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_simd; - j->resample_row_hv_2_kernel = stbi__resample_row_hv_2_simd; + j->idct_block_kernel = rjpeg__idct_simd; + j->YCbCr_to_RGB_kernel = rjpeg__YCbCr_to_RGB_simd; + j->resample_row_hv_2_kernel = rjpeg__resample_row_hv_2_simd; } #endif #ifdef STBI_NEON - j->idct_block_kernel = stbi__idct_simd; - j->YCbCr_to_RGB_kernel = stbi__YCbCr_to_RGB_simd; - j->resample_row_hv_2_kernel = stbi__resample_row_hv_2_simd; + j->idct_block_kernel = rjpeg__idct_simd; + j->YCbCr_to_RGB_kernel = rjpeg__YCbCr_to_RGB_simd; + j->resample_row_hv_2_kernel = rjpeg__resample_row_hv_2_simd; #endif } /* clean up the temporary component buffers */ -static void stbi__cleanup_jpeg(stbi__jpeg *j) +static void rjpeg__cleanup_jpeg(rjpeg__jpeg *j) { int i; for (i=0; i < j->s->img_n; ++i) @@ -2275,16 +2279,21 @@ static void stbi__cleanup_jpeg(stbi__jpeg *j) } -static uint8_t *load_jpeg_image(stbi__jpeg *z, int *out_x, int *out_y, int *comp, int req_comp) +static uint8_t *load_jpeg_image(rjpeg__jpeg *z, int *out_x, int *out_y, int *comp, int req_comp) { int n, decode_n; - z->s->img_n = 0; /* make stbi__cleanup_jpeg safe */ + z->s->img_n = 0; /* make rjpeg__cleanup_jpeg safe */ /* validate req_comp */ - if (req_comp < 0 || req_comp > 4) return stbi__errpuc("bad req_comp", "Internal error"); + if (req_comp < 0 || req_comp > 4) + return rjpeg__errpuc("bad req_comp", "Internal error"); /* load a jpeg image from whichever source, but leave in YCbCr format */ - if (!stbi__decode_jpeg_image(z)) { stbi__cleanup_jpeg(z); return NULL; } + if (!stbi__decode_jpeg_image(z)) + { + rjpeg__cleanup_jpeg(z); + return NULL; + } /* determine actual number of components to generate */ n = req_comp ? req_comp : z->s->img_n; @@ -2301,16 +2310,20 @@ static uint8_t *load_jpeg_image(stbi__jpeg *z, int *out_x, int *out_y, int *comp uint8_t *output; uint8_t *coutput[4]; - stbi__resample res_comp[4]; + rjpeg__resample res_comp[4]; for (k=0; k < decode_n; ++k) { - stbi__resample *r = &res_comp[k]; + rjpeg__resample *r = &res_comp[k]; /* allocate line buffer big enough for upsampling off the edges * with upsample factor of 4 */ z->img_comp[k].linebuf = (uint8_t *) malloc(z->s->img_x + 3); - if (!z->img_comp[k].linebuf) { stbi__cleanup_jpeg(z); return stbi__errpuc("outofmem", "Out of memory"); } + if (!z->img_comp[k].linebuf) + { + rjpeg__cleanup_jpeg(z); + return rjpeg__errpuc("outofmem", "Out of memory"); + } r->hs = z->img_h_max / z->img_comp[k].h; r->vs = z->img_v_max / z->img_comp[k].v; @@ -2319,11 +2332,11 @@ static uint8_t *load_jpeg_image(stbi__jpeg *z, int *out_x, int *out_y, int *comp r->ypos = 0; r->line0 = r->line1 = z->img_comp[k].data; - if (r->hs == 1 && r->vs == 1) r->resample = resample_row_1; - else if (r->hs == 1 && r->vs == 2) r->resample = stbi__resample_row_v_2; - else if (r->hs == 2 && r->vs == 1) r->resample = stbi__resample_row_h_2; + if (r->hs == 1 && r->vs == 1) r->resample = rjpeg_resample_row_1; + else if (r->hs == 1 && r->vs == 2) r->resample = rjpeg__resample_row_v_2; + else if (r->hs == 2 && r->vs == 1) r->resample = rjpeg__resample_row_h_2; else if (r->hs == 2 && r->vs == 2) r->resample = z->resample_row_hv_2_kernel; - else r->resample = stbi__resample_row_generic; + else r->resample = rjpeg__resample_row_generic; } /* can't error after this so, this is safe */ @@ -2331,8 +2344,8 @@ static uint8_t *load_jpeg_image(stbi__jpeg *z, int *out_x, int *out_y, int *comp if (!output) { - stbi__cleanup_jpeg(z); - return stbi__errpuc("outofmem", "Out of memory"); + rjpeg__cleanup_jpeg(z); + return rjpeg__errpuc("outofmem", "Out of memory"); } /* now go ahead and resample */ From 3c4329aa1f6e7e1b53a832732f618e79d5c6f0f2 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 May 2016 07:08:45 +0200 Subject: [PATCH 370/498] (RJPEG) uniquely namespace all functions --- libretro-common/formats/jpeg/rjpeg.c | 584 +++++++++++++-------------- 1 file changed, 292 insertions(+), 292 deletions(-) diff --git a/libretro-common/formats/jpeg/rjpeg.c b/libretro-common/formats/jpeg/rjpeg.c index 55b7d3e33c..4be01206c5 100644 --- a/libretro-common/formats/jpeg/rjpeg.c +++ b/libretro-common/formats/jpeg/rjpeg.c @@ -25,12 +25,12 @@ typedef struct int (*eof) (void *user); /* returns nonzero if we are at end of file/data */ } rjpeg_io_callbacks; -typedef uint8_t *(*resample_row_func)(uint8_t *out, uint8_t *in0, uint8_t *in1, +typedef uint8_t *(*rjpeg_resample_row_func)(uint8_t *out, uint8_t *in0, uint8_t *in1, int w, int hs); typedef struct { - resample_row_func resample; + rjpeg_resample_row_func resample; uint8_t *line0,*line1; int hs,vs; /* expansion factor in each axis */ int w_lores; /* horizontal pixels pre-expansion */ @@ -43,19 +43,19 @@ typedef struct #endif #ifdef STBI_HAS_LROTL - #define stbi_lrot(x,y) _lrotl(x,y) + #define rjpeg_lrot(x,y) _lrotl(x,y) #else - #define stbi_lrot(x,y) (((x) << (y)) | ((x) >> (32 - (y)))) + #define rjpeg_lrot(x,y) (((x) << (y)) | ((x) >> (32 - (y)))) #endif /* x86/x64 detection */ #if defined(__x86_64__) || defined(_M_X64) -#define STBI__X64_TARGET +#define RJPEG__X64_TARGET #elif defined(__i386) || defined(_M_IX86) -#define STBI__X86_TARGET +#define RJPEG__X86_TARGET #endif -#if defined(__GNUC__) && (defined(STBI__X86_TARGET) || defined(STBI__X64_TARGET)) && !defined(__SSE2__) && !defined(STBI_NO_SIMD) +#if defined(__GNUC__) && (defined(RJPEG__X86_TARGET) || defined(RJPEG__X64_TARGET)) && !defined(__SSE2__) && !defined(STBI_NO_SIMD) /* NOTE: not clear do we actually need this for the 64-bit path? * gcc doesn't support sse2 intrinsics unless you compile with -msse2, * (but compiling with -msse2 allows the compiler to use SSE2 everywhere; @@ -65,8 +65,8 @@ typedef struct #define STBI_NO_SIMD #endif -#if defined(__MINGW32__) && defined(STBI__X86_TARGET) && !defined(STBI_MINGW_ENABLE_SSE2) && !defined(STBI_NO_SIMD) -/* Note that __MINGW32__ doesn't actually mean 32-bit, so we have to avoid STBI__X64_TARGET +#if defined(__MINGW32__) && defined(RJPEG__X86_TARGET) && !defined(STBI_MINGW_ENABLE_SSE2) && !defined(STBI_NO_SIMD) +/* Note that __MINGW32__ doesn't actually mean 32-bit, so we have to avoid RJPEG__X64_TARGET * * 32-bit MinGW wants ESP to be 16-byte aligned, but this is not in the * Windows ABI and VC++ as well as Windows DLLs don't maintain that invariant. @@ -88,14 +88,14 @@ typedef struct #if _MSC_VER >= 1400 /* not VC6 */ #include /* __cpuid */ -static int stbi__cpuid3(void) +static int rjpeg__cpuid3(void) { int info[4]; __cpuid(info,1); return info[3]; } #else -static int stbi__cpuid3(void) +static int rjpeg__cpuid3(void) { int res; __asm { @@ -109,15 +109,15 @@ static int stbi__cpuid3(void) #define STBI_SIMD_ALIGN(type, name) __declspec(align(16)) type name -static int stbi__sse2_available(void) +static int rjpeg__sse2_available(void) { - int info3 = stbi__cpuid3(); + int info3 = rjpeg__cpuid3(); return ((info3 >> 26) & 1) != 0; } #else /* assume GCC-style if not VC++ */ #define RJPEG_SIMD_ALIGN(type, name) type name __attribute__((aligned(16))) -static int stbi__sse2_available(void) +static int rjpeg__sse2_available(void) { #if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 408 /* GCC 4.8 or later */ /* GCC 4.8+ has a nice way to do this */ @@ -151,7 +151,7 @@ typedef struct uint32_t img_x, img_y; int img_n, img_out_n; - stbi_io_callbacks io; + rjpeg_io_callbacks io; void *io_user_data; int read_from_callbacks; @@ -163,7 +163,7 @@ typedef struct } rjpeg__context; /* initialize a memory-decode context */ -static void rjpeg__start_mem(stbi__context *s, const uint8_t *buffer, int len) +static void rjpeg__start_mem(rjpeg__context *s, const uint8_t *buffer, int len) { s->io.read = NULL; s->read_from_callbacks = 0; @@ -171,7 +171,7 @@ static void rjpeg__start_mem(stbi__context *s, const uint8_t *buffer, int len) s->img_buffer_end = (uint8_t *) buffer+len; } -static void rjpeg__rewind(stbi__context *s) +static void rjpeg__rewind(rjpeg__context *s) { /* conceptually rewind SHOULD rewind to the beginning of the stream, * but we just rewind to the beginning of the initial buffer, because @@ -181,8 +181,8 @@ static void rjpeg__rewind(stbi__context *s) } #ifndef STBI_NO_JPEG -static int stbi__jpeg_test(stbi__context *s); -static uint8_t *stbi__jpeg_load(stbi__context *s, int *x, int *y, int *comp, int req_comp); +static int rjpeg__jpeg_test(rjpeg__context *s); +static uint8_t *rjpeg__jpeg_load(rjpeg__context *s, int *x, int *y, int *comp, int req_comp); #endif /* this is not threadsafe */ @@ -195,32 +195,32 @@ static INLINE int rjpeg__err(const char *str) } #ifdef STBI_NO_FAILURE_STRINGS - #define stbi__err(x,y) 0 + #define rjpeg__err(x,y) 0 #elif defined(STBI_FAILURE_USERMSG) - #define stbi__err(x,y) stbi__err(y) + #define rjpeg__err(x,y) rjpeg__err(y) #else - #define stbi__err(x,y) stbi__err(x) + #define rjpeg__err(x,y) rjpeg__err(x) #endif -#define stbi__errpf(x,y) ((float *) (stbi__err(x,y)?NULL:NULL)) -#define stbi__errpuc(x,y) ((unsigned char *) (stbi__err(x,y)?NULL:NULL)) +#define rjpeg__errpf(x,y) ((float *) (rjpeg__err(x,y)?NULL:NULL)) +#define rjpeg__errpuc(x,y) ((unsigned char *) (rjpeg__err(x,y)?NULL:NULL)) static int rjpeg__vertically_flip_on_load = 0; -static unsigned char *rjpeg__load_main(stbi__context *s, int *x, int *y, int *comp, int req_comp) +static unsigned char *rjpeg__load_main(rjpeg__context *s, int *x, int *y, int *comp, int req_comp) { #ifndef STBI_NO_JPEG - if (stbi__jpeg_test(s)) return stbi__jpeg_load(s,x,y,comp,req_comp); + if (rjpeg__jpeg_test(s)) return rjpeg__jpeg_load(s,x,y,comp,req_comp); #endif - return stbi__errpuc("unknown image type", "Image not of any known type, or corrupt"); + return rjpeg__errpuc("unknown image type", "Image not of any known type, or corrupt"); } -static unsigned char *rjpeg__load_flip(stbi__context *s, int *x, int *y, int *comp, int req_comp) +static unsigned char *rjpeg__load_flip(rjpeg__context *s, int *x, int *y, int *comp, int req_comp) { - unsigned char *result = stbi__load_main(s, x, y, comp, req_comp); + unsigned char *result = rjpeg__load_main(s, x, y, comp, req_comp); - if (stbi__vertically_flip_on_load && result != NULL) + if (rjpeg__vertically_flip_on_load && result != NULL) { uint8_t temp; int row,col,z; @@ -246,9 +246,9 @@ static unsigned char *rjpeg__load_flip(stbi__context *s, int *x, int *y, int *co static uint8_t *rjpeg_load_from_memory(const uint8_t *buffer, int len, int *x, int *y, int *comp, int req_comp) { - stbi__context s; - stbi__start_mem(&s,buffer,len); - return stbi__load_flip(&s,x,y,comp,req_comp); + rjpeg__context s; + rjpeg__start_mem(&s,buffer,len); + return rjpeg__load_flip(&s,x,y,comp,req_comp); } enum @@ -258,7 +258,7 @@ enum RJPEG_SCAN_HEADER }; -static void rjpeg__refill_buffer(stbi__context *s) +static void rjpeg__refill_buffer(rjpeg__context *s) { int n = (s->io.read)(s->io_user_data,(char*)s->buffer_start,s->buflen); @@ -278,21 +278,21 @@ static void rjpeg__refill_buffer(stbi__context *s) } } -static INLINE uint8_t rjpeg__get8(stbi__context *s) +static INLINE uint8_t rjpeg__get8(rjpeg__context *s) { if (s->img_buffer < s->img_buffer_end) return *s->img_buffer++; if (s->read_from_callbacks) { - stbi__refill_buffer(s); + rjpeg__refill_buffer(s); return *s->img_buffer++; } return 0; } -static INLINE int rjpeg__at_eof(stbi__context *s) +static INLINE int rjpeg__at_eof(rjpeg__context *s) { if (s->io.read) { @@ -310,7 +310,7 @@ static INLINE int rjpeg__at_eof(stbi__context *s) return s->img_buffer >= s->img_buffer_end; } -static void rjpeg__skip(stbi__context *s, int n) +static void rjpeg__skip(rjpeg__context *s, int n) { if (n < 0) { s->img_buffer = s->img_buffer_end; @@ -327,10 +327,10 @@ static void rjpeg__skip(stbi__context *s, int n) s->img_buffer += n; } -static int rjpeg__get16be(stbi__context *s) +static int rjpeg__get16be(rjpeg__context *s) { - int z = stbi__get8(s); - return (z << 8) + stbi__get8(s); + int z = rjpeg__get8(s); + return (z << 8) + rjpeg__get8(s); } #define RJPEG__BYTECAST(x) ((uint8_t) ((x) & 255)) /* truncate int to byte without warnings */ @@ -351,9 +351,9 @@ typedef struct typedef struct { - stbi__context *s; - stbi__huffman huff_dc[4]; - stbi__huffman huff_ac[4]; + rjpeg__context *s; + rjpeg__huffman huff_dc[4]; + rjpeg__huffman huff_ac[4]; uint8_t dequant[4][64]; int16_t fast_ac[4][1 << FAST_BITS]; @@ -400,7 +400,7 @@ typedef struct uint8_t *(*resample_row_hv_2_kernel)(uint8_t *out, uint8_t *in_near, uint8_t *in_far, int w, int hs); } rjpeg__jpeg; -static int rjpeg__build_huffman(stbi__huffman *h, int *count) +static int rjpeg__build_huffman(rjpeg__huffman *h, int *count) { int i,j,k=0,code; /* build size list for each symbol (from JPEG spec) */ @@ -422,7 +422,7 @@ static int rjpeg__build_huffman(stbi__huffman *h, int *count) while (h->size[k] == j) h->code[k++] = (uint16_t) (code++); if (code-1 >= (1 << j)) - return stbi__err("bad code lengths","Corrupt JPEG"); + return rjpeg__err("bad code lengths","Corrupt JPEG"); } /* compute largest code + 1 for this size, preshifted as needed later */ h->maxcode[j] = code << (16-j); @@ -560,37 +560,37 @@ static int const rjpeg__jbias[16] = {0,-1,-3,-7,-15,-31,-63,-127,-255,-511,-1023 /* combined JPEG 'receive' and JPEG 'extend', since baseline * always extends everything it receives. */ -static INLINE int rjpeg__extend_receive(stbi__jpeg *j, int n) +static INLINE int rjpeg__extend_receive(rjpeg__jpeg *j, int n) { unsigned int k; int sgn; - if (j->code_bits < n) stbi__grow_buffer_unsafe(j); + if (j->code_bits < n) rjpeg__grow_buffer_unsafe(j); sgn = (int32_t)j->code_buffer >> 31; /* sign bit is always in MSB */ - k = stbi_lrot(j->code_buffer, n); - assert(n >= 0 && n < (int) (sizeof(stbi__bmask)/sizeof(*stbi__bmask))); - j->code_buffer = k & ~stbi__bmask[n]; - k &= stbi__bmask[n]; + k = rjpeg_lrot(j->code_buffer, n); + assert(n >= 0 && n < (int) (sizeof(rjpeg__bmask)/sizeof(*rjpeg__bmask))); + j->code_buffer = k & ~rjpeg__bmask[n]; + k &= rjpeg__bmask[n]; j->code_bits -= n; - return k + (stbi__jbias[n] & ~sgn); + return k + (rjpeg__jbias[n] & ~sgn); } /* get some unsigned bits */ -static INLINE int stbi__jpeg_get_bits(stbi__jpeg *j, int n) +static INLINE int rjpeg__jpeg_get_bits(rjpeg__jpeg *j, int n) { unsigned int k; - if (j->code_bits < n) stbi__grow_buffer_unsafe(j); - k = stbi_lrot(j->code_buffer, n); - j->code_buffer = k & ~stbi__bmask[n]; - k &= stbi__bmask[n]; + if (j->code_bits < n) rjpeg__grow_buffer_unsafe(j); + k = rjpeg_lrot(j->code_buffer, n); + j->code_buffer = k & ~rjpeg__bmask[n]; + k &= rjpeg__bmask[n]; j->code_bits -= n; return k; } -static INLINE int stbi__jpeg_get_bit(stbi__jpeg *j) +static INLINE int rjpeg__jpeg_get_bit(rjpeg__jpeg *j) { unsigned int k; - if (j->code_bits < 1) stbi__grow_buffer_unsafe(j); + if (j->code_bits < 1) rjpeg__grow_buffer_unsafe(j); k = j->code_buffer; j->code_buffer <<= 1; --j->code_bits; @@ -599,7 +599,7 @@ static INLINE int stbi__jpeg_get_bit(stbi__jpeg *j) /* given a value that's at position X in the zigzag stream, * where does it appear in the 8x8 matrix coded as row-major? */ -static uint8_t stbi__jpeg_dezigzag[64+15] = +static uint8_t rjpeg__jpeg_dezigzag[64+15] = { 0, 1, 8, 16, 9, 2, 3, 10, 17, 24, 32, 25, 18, 11, 4, 5, @@ -615,19 +615,19 @@ static uint8_t stbi__jpeg_dezigzag[64+15] = }; /* decode one 64-entry block-- */ -static int stbi__jpeg_decode_block(stbi__jpeg *j, short data[64], stbi__huffman *hdc, stbi__huffman *hac, int16_t *fac, int b, uint8_t *dequant) +static int rjpeg__jpeg_decode_block(rjpeg__jpeg *j, short data[64], rjpeg__huffman *hdc, rjpeg__huffman *hac, int16_t *fac, int b, uint8_t *dequant) { int diff,dc,k; int t; - if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); - t = stbi__jpeg_huff_decode(j, hdc); - if (t < 0) return stbi__err("bad huffman code","Corrupt JPEG"); + if (j->code_bits < 16) rjpeg__grow_buffer_unsafe(j); + t = rjpeg__jpeg_huff_decode(j, hdc); + if (t < 0) return rjpeg__err("bad huffman code","Corrupt JPEG"); /* 0 all the ac values now so we can do it 32-bits at a time */ memset(data,0,64*sizeof(data[0])); - diff = t ? stbi__extend_receive(j, t) : 0; + diff = t ? rjpeg__extend_receive(j, t) : 0; dc = j->img_comp[b].dc_pred + diff; j->img_comp[b].dc_pred = dc; data[0] = (short) (dc * dequant[0]); @@ -639,7 +639,7 @@ static int stbi__jpeg_decode_block(stbi__jpeg *j, short data[64], stbi__huffman unsigned int zig; int c,r,s; if (j->code_bits < 16) - stbi__grow_buffer_unsafe(j); + rjpeg__grow_buffer_unsafe(j); c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1); r = fac[c]; if (r) @@ -650,13 +650,13 @@ static int stbi__jpeg_decode_block(stbi__jpeg *j, short data[64], stbi__huffman j->code_buffer <<= s; j->code_bits -= s; /* decode into unzigzag'd location */ - zig = stbi__jpeg_dezigzag[k++]; + zig = rjpeg__jpeg_dezigzag[k++]; data[zig] = (short) ((r >> 8) * dequant[zig]); } else { - int rs = stbi__jpeg_huff_decode(j, hac); - if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG"); + int rs = rjpeg__jpeg_huff_decode(j, hac); + if (rs < 0) return rjpeg__err("bad huffman code","Corrupt JPEG"); s = rs & 15; r = rs >> 4; if (s == 0) { @@ -665,21 +665,21 @@ static int stbi__jpeg_decode_block(stbi__jpeg *j, short data[64], stbi__huffman } else { k += r; /* decode into unzigzag'd location */ - zig = stbi__jpeg_dezigzag[k++]; - data[zig] = (short) (stbi__extend_receive(j,s) * dequant[zig]); + zig = rjpeg__jpeg_dezigzag[k++]; + data[zig] = (short) (rjpeg__extend_receive(j,s) * dequant[zig]); } } } while (k < 64); return 1; } -static int stbi__jpeg_decode_block_prog_dc(stbi__jpeg *j, short data[64], stbi__huffman *hdc, int b) +static int rjpeg__jpeg_decode_block_prog_dc(rjpeg__jpeg *j, short data[64], rjpeg__huffman *hdc, int b) { if (j->spec_end != 0) - return stbi__err("can't merge dc and ac", "Corrupt JPEG"); + return rjpeg__err("can't merge dc and ac", "Corrupt JPEG"); if (j->code_bits < 16) - stbi__grow_buffer_unsafe(j); + rjpeg__grow_buffer_unsafe(j); if (j->succ_high == 0) { @@ -688,8 +688,8 @@ static int stbi__jpeg_decode_block_prog_dc(stbi__jpeg *j, short data[64], stbi__ /* first scan for DC coefficient, must be first */ memset(data,0,64*sizeof(data[0])); /* 0 all the ac values now */ - t = stbi__jpeg_huff_decode(j, hdc); - diff = t ? stbi__extend_receive(j, t) : 0; + t = rjpeg__jpeg_huff_decode(j, hdc); + diff = t ? rjpeg__extend_receive(j, t) : 0; dc = j->img_comp[b].dc_pred + diff; j->img_comp[b].dc_pred = dc; @@ -698,16 +698,16 @@ static int stbi__jpeg_decode_block_prog_dc(stbi__jpeg *j, short data[64], stbi__ else { /* refinement scan for DC coefficient */ - if (stbi__jpeg_get_bit(j)) + if (rjpeg__jpeg_get_bit(j)) data[0] += (short) (1 << j->succ_low); } return 1; } -static int stbi__jpeg_decode_block_prog_ac(stbi__jpeg *j, short data[64], stbi__huffman *hac, int16_t *fac) +static int rjpeg__jpeg_decode_block_prog_ac(rjpeg__jpeg *j, short data[64], rjpeg__huffman *hac, int16_t *fac) { int k; - if (j->spec_start == 0) return stbi__err("can't merge dc and ac", "Corrupt JPEG"); + if (j->spec_start == 0) return rjpeg__err("can't merge dc and ac", "Corrupt JPEG"); if (j->succ_high == 0) { int shift = j->succ_low; @@ -721,7 +721,7 @@ static int stbi__jpeg_decode_block_prog_ac(stbi__jpeg *j, short data[64], stbi__ do { unsigned int zig; int c,r,s; - if (j->code_bits < 16) stbi__grow_buffer_unsafe(j); + if (j->code_bits < 16) rjpeg__grow_buffer_unsafe(j); c = (j->code_buffer >> (32 - FAST_BITS)) & ((1 << FAST_BITS)-1); r = fac[c]; if (r) { /* fast-AC path */ @@ -729,26 +729,26 @@ static int stbi__jpeg_decode_block_prog_ac(stbi__jpeg *j, short data[64], stbi__ s = r & 15; // combined length j->code_buffer <<= s; j->code_bits -= s; - zig = stbi__jpeg_dezigzag[k++]; + zig = rjpeg__jpeg_dezigzag[k++]; data[zig] = (short) ((r >> 8) << shift); } else { - int rs = stbi__jpeg_huff_decode(j, hac); - if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG"); + int rs = rjpeg__jpeg_huff_decode(j, hac); + if (rs < 0) return rjpeg__err("bad huffman code","Corrupt JPEG"); s = rs & 15; r = rs >> 4; if (s == 0) { if (r < 15) { j->eob_run = (1 << r); if (r) - j->eob_run += stbi__jpeg_get_bits(j, r); + j->eob_run += rjpeg__jpeg_get_bits(j, r); --j->eob_run; break; } k += 16; } else { k += r; - zig = stbi__jpeg_dezigzag[k++]; - data[zig] = (short) (stbi__extend_receive(j,s) << shift); + zig = rjpeg__jpeg_dezigzag[k++]; + data[zig] = (short) (rjpeg__extend_receive(j,s) << shift); } } } while (k <= j->spec_end); @@ -760,9 +760,9 @@ static int stbi__jpeg_decode_block_prog_ac(stbi__jpeg *j, short data[64], stbi__ if (j->eob_run) { --j->eob_run; for (k = j->spec_start; k <= j->spec_end; ++k) { - short *p = &data[stbi__jpeg_dezigzag[k]]; + short *p = &data[rjpeg__jpeg_dezigzag[k]]; if (*p != 0) - if (stbi__jpeg_get_bit(j)) + if (rjpeg__jpeg_get_bit(j)) if ((*p & bit)==0) { if (*p > 0) *p += bit; @@ -774,15 +774,15 @@ static int stbi__jpeg_decode_block_prog_ac(stbi__jpeg *j, short data[64], stbi__ k = j->spec_start; do { int r,s; - int rs = stbi__jpeg_huff_decode(j, hac); - if (rs < 0) return stbi__err("bad huffman code","Corrupt JPEG"); + int rs = rjpeg__jpeg_huff_decode(j, hac); + if (rs < 0) return rjpeg__err("bad huffman code","Corrupt JPEG"); s = rs & 15; r = rs >> 4; if (s == 0) { if (r < 15) { j->eob_run = (1 << r) - 1; if (r) - j->eob_run += stbi__jpeg_get_bits(j, r); + j->eob_run += rjpeg__jpeg_get_bits(j, r); r = 64; // force end of block } else { // r=15 s=0 should write 16 0s, so we just do @@ -790,9 +790,9 @@ static int stbi__jpeg_decode_block_prog_ac(stbi__jpeg *j, short data[64], stbi__ // so we don't have to do anything special here } } else { - if (s != 1) return stbi__err("bad huffman code", "Corrupt JPEG"); + if (s != 1) return rjpeg__err("bad huffman code", "Corrupt JPEG"); // sign bit - if (stbi__jpeg_get_bit(j)) + if (rjpeg__jpeg_get_bit(j)) s = bit; else s = -bit; @@ -800,9 +800,9 @@ static int stbi__jpeg_decode_block_prog_ac(stbi__jpeg *j, short data[64], stbi__ // advance by r while (k <= j->spec_end) { - short *p = &data[stbi__jpeg_dezigzag[k++]]; + short *p = &data[rjpeg__jpeg_dezigzag[k++]]; if (*p != 0) { - if (stbi__jpeg_get_bit(j)) + if (rjpeg__jpeg_get_bit(j)) if ((*p & bit)==0) { if (*p > 0) *p += bit; @@ -823,8 +823,8 @@ static int stbi__jpeg_decode_block_prog_ac(stbi__jpeg *j, short data[64], stbi__ return 1; } -/* take a -128..127 value and stbi__clamp it and convert to 0..255 */ -static INLINE uint8_t stbi__clamp(int x) +/* take a -128..127 value and rjpeg__clamp it and convert to 0..255 */ +static INLINE uint8_t rjpeg__clamp(int x) { /* trick to use a single test to catch both cases */ if ((unsigned int) x > 255) @@ -837,21 +837,21 @@ static INLINE uint8_t stbi__clamp(int x) return (uint8_t) x; } -#define stbi__f2f(x) ((int) (((x) * 4096 + 0.5))) -#define stbi__fsh(x) ((x) << 12) +#define rjpeg__f2f(x) ((int) (((x) * 4096 + 0.5))) +#define rjpeg__fsh(x) ((x) << 12) /* derived from jidctint -- DCT_ISLOW */ -#define STBI__IDCT_1D(s0,s1,s2,s3,s4,s5,s6,s7) \ +#define RJPEG__IDCT_1D(s0,s1,s2,s3,s4,s5,s6,s7) \ int t0,t1,t2,t3,p1,p2,p3,p4,p5,x0,x1,x2,x3; \ p2 = s2; \ p3 = s6; \ - p1 = (p2+p3) * stbi__f2f(0.5411961f); \ - t2 = p1 + p3*stbi__f2f(-1.847759065f); \ - t3 = p1 + p2*stbi__f2f( 0.765366865f); \ + p1 = (p2+p3) * rjpeg__f2f(0.5411961f); \ + t2 = p1 + p3*rjpeg__f2f(-1.847759065f); \ + t3 = p1 + p2*rjpeg__f2f( 0.765366865f); \ p2 = s0; \ p3 = s4; \ - t0 = stbi__fsh(p2+p3); \ - t1 = stbi__fsh(p2-p3); \ + t0 = rjpeg__fsh(p2+p3); \ + t1 = rjpeg__fsh(p2-p3); \ x0 = t0+t3; \ x3 = t0-t3; \ x1 = t1+t2; \ @@ -864,21 +864,21 @@ static INLINE uint8_t stbi__clamp(int x) p4 = t1+t3; \ p1 = t0+t3; \ p2 = t1+t2; \ - p5 = (p3+p4)*stbi__f2f( 1.175875602f); \ - t0 = t0*stbi__f2f( 0.298631336f); \ - t1 = t1*stbi__f2f( 2.053119869f); \ - t2 = t2*stbi__f2f( 3.072711026f); \ - t3 = t3*stbi__f2f( 1.501321110f); \ - p1 = p5 + p1*stbi__f2f(-0.899976223f); \ - p2 = p5 + p2*stbi__f2f(-2.562915447f); \ - p3 = p3*stbi__f2f(-1.961570560f); \ - p4 = p4*stbi__f2f(-0.390180644f); \ + p5 = (p3+p4)*rjpeg__f2f( 1.175875602f); \ + t0 = t0*rjpeg__f2f( 0.298631336f); \ + t1 = t1*rjpeg__f2f( 2.053119869f); \ + t2 = t2*rjpeg__f2f( 3.072711026f); \ + t3 = t3*rjpeg__f2f( 1.501321110f); \ + p1 = p5 + p1*rjpeg__f2f(-0.899976223f); \ + p2 = p5 + p2*rjpeg__f2f(-2.562915447f); \ + p3 = p3*rjpeg__f2f(-1.961570560f); \ + p4 = p4*rjpeg__f2f(-0.390180644f); \ t3 += p1+p4; \ t2 += p2+p3; \ t1 += p2+p4; \ t0 += p1+p3; -static void stbi__idct_block(uint8_t *out, int out_stride, short data[64]) +static void rjpeg__idct_block(uint8_t *out, int out_stride, short data[64]) { int i,val[64],*v=val; uint8_t *o = NULL; @@ -897,7 +897,7 @@ static void stbi__idct_block(uint8_t *out, int out_stride, short data[64]) int dcterm = d[0] << 2; v[0] = v[8] = v[16] = v[24] = v[32] = v[40] = v[48] = v[56] = dcterm; } else { - STBI__IDCT_1D(d[ 0],d[ 8],d[16],d[24],d[32],d[40],d[48],d[56]) + RJPEG__IDCT_1D(d[ 0],d[ 8],d[16],d[24],d[32],d[40],d[48],d[56]) /* constants scaled things up by 1<<12; let's bring them back * down, but keep 2 extra bits of precision */ x0 += 512; x1 += 512; x2 += 512; x3 += 512; @@ -915,7 +915,7 @@ static void stbi__idct_block(uint8_t *out, int out_stride, short data[64]) for (i=0, v=val, o=out; i < 8; ++i,v+=8,o+=out_stride) { /* no fast case since the first 1D IDCT spread components out */ - STBI__IDCT_1D(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7]) + RJPEG__IDCT_1D(v[0],v[1],v[2],v[3],v[4],v[5],v[6],v[7]) /* constants scaled things up by 1<<12, plus we had 1<<2 from first * loop, plus horizontal and vertical each scale by sqrt(8) so together * we've got an extra 1<<3, so 1<<17 total we need to remove. @@ -928,14 +928,14 @@ static void stbi__idct_block(uint8_t *out, int out_stride, short data[64]) x3 += 65536 + (128<<17); // tried computing the shifts into temps, or'ing the temps to see // if any were out of range, but that was slower - o[0] = stbi__clamp((x0+t3) >> 17); - o[7] = stbi__clamp((x0-t3) >> 17); - o[1] = stbi__clamp((x1+t2) >> 17); - o[6] = stbi__clamp((x1-t2) >> 17); - o[2] = stbi__clamp((x2+t1) >> 17); - o[5] = stbi__clamp((x2-t1) >> 17); - o[3] = stbi__clamp((x3+t0) >> 17); - o[4] = stbi__clamp((x3-t0) >> 17); + o[0] = rjpeg__clamp((x0+t3) >> 17); + o[7] = rjpeg__clamp((x0-t3) >> 17); + o[1] = rjpeg__clamp((x1+t2) >> 17); + o[6] = rjpeg__clamp((x1-t2) >> 17); + o[2] = rjpeg__clamp((x2+t1) >> 17); + o[5] = rjpeg__clamp((x2-t1) >> 17); + o[3] = rjpeg__clamp((x3+t0) >> 17); + o[4] = rjpeg__clamp((x3-t0) >> 17); } } @@ -944,7 +944,7 @@ static void stbi__idct_block(uint8_t *out, int out_stride, short data[64]) * produces bit-identical results to the generic C version so it's * fully "transparent". */ -static void stbi__idct_simd(uint8_t *out, int out_stride, short data[64]) +static void rjpeg__idct_simd(uint8_t *out, int out_stride, short data[64]) { /* This is constructed to match our regular (generic) integer IDCT exactly. */ __m128i row0, row1, row2, row3, row4, row5, row6, row7; @@ -1030,16 +1030,16 @@ static void stbi__idct_simd(uint8_t *out, int out_stride, short data[64]) dct_bfly32o(row3,row4, x3,x4,bias,shift); \ } - __m128i rot0_0 = dct_const(stbi__f2f(0.5411961f), stbi__f2f(0.5411961f) + stbi__f2f(-1.847759065f)); - __m128i rot0_1 = dct_const(stbi__f2f(0.5411961f) + stbi__f2f( 0.765366865f), stbi__f2f(0.5411961f)); - __m128i rot1_0 = dct_const(stbi__f2f(1.175875602f) + stbi__f2f(-0.899976223f), stbi__f2f(1.175875602f)); - __m128i rot1_1 = dct_const(stbi__f2f(1.175875602f), stbi__f2f(1.175875602f) + stbi__f2f(-2.562915447f)); - __m128i rot2_0 = dct_const(stbi__f2f(-1.961570560f) + stbi__f2f( 0.298631336f), stbi__f2f(-1.961570560f)); - __m128i rot2_1 = dct_const(stbi__f2f(-1.961570560f), stbi__f2f(-1.961570560f) + stbi__f2f( 3.072711026f)); - __m128i rot3_0 = dct_const(stbi__f2f(-0.390180644f) + stbi__f2f( 2.053119869f), stbi__f2f(-0.390180644f)); - __m128i rot3_1 = dct_const(stbi__f2f(-0.390180644f), stbi__f2f(-0.390180644f) + stbi__f2f( 1.501321110f)); + __m128i rot0_0 = dct_const(rjpeg__f2f(0.5411961f), rjpeg__f2f(0.5411961f) + rjpeg__f2f(-1.847759065f)); + __m128i rot0_1 = dct_const(rjpeg__f2f(0.5411961f) + rjpeg__f2f( 0.765366865f), rjpeg__f2f(0.5411961f)); + __m128i rot1_0 = dct_const(rjpeg__f2f(1.175875602f) + rjpeg__f2f(-0.899976223f), rjpeg__f2f(1.175875602f)); + __m128i rot1_1 = dct_const(rjpeg__f2f(1.175875602f), rjpeg__f2f(1.175875602f) + rjpeg__f2f(-2.562915447f)); + __m128i rot2_0 = dct_const(rjpeg__f2f(-1.961570560f) + rjpeg__f2f( 0.298631336f), rjpeg__f2f(-1.961570560f)); + __m128i rot2_1 = dct_const(rjpeg__f2f(-1.961570560f), rjpeg__f2f(-1.961570560f) + rjpeg__f2f( 3.072711026f)); + __m128i rot3_0 = dct_const(rjpeg__f2f(-0.390180644f) + rjpeg__f2f( 2.053119869f), rjpeg__f2f(-0.390180644f)); + __m128i rot3_1 = dct_const(rjpeg__f2f(-0.390180644f), rjpeg__f2f(-0.390180644f) + rjpeg__f2f( 1.501321110f)); - /* rounding biases in column/row passes, see stbi__idct_block for explanation. */ + /* rounding biases in column/row passes, see rjpeg__idct_block for explanation. */ __m128i bias_0 = _mm_set1_epi32(512); __m128i bias_1 = _mm_set1_epi32(65536 + (128<<17)); @@ -1126,22 +1126,22 @@ static void stbi__idct_simd(uint8_t *out, int out_stride, short data[64]) /* NEON integer IDCT. should produce bit-identical * results to the generic C version. */ -static void stbi__idct_simd(uint8_t *out, int out_stride, short data[64]) +static void rjpeg__idct_simd(uint8_t *out, int out_stride, short data[64]) { int16x8_t row0, row1, row2, row3, row4, row5, row6, row7; - int16x4_t rot0_0 = vdup_n_s16(stbi__f2f(0.5411961f)); - int16x4_t rot0_1 = vdup_n_s16(stbi__f2f(-1.847759065f)); - int16x4_t rot0_2 = vdup_n_s16(stbi__f2f( 0.765366865f)); - int16x4_t rot1_0 = vdup_n_s16(stbi__f2f( 1.175875602f)); - int16x4_t rot1_1 = vdup_n_s16(stbi__f2f(-0.899976223f)); - int16x4_t rot1_2 = vdup_n_s16(stbi__f2f(-2.562915447f)); - int16x4_t rot2_0 = vdup_n_s16(stbi__f2f(-1.961570560f)); - int16x4_t rot2_1 = vdup_n_s16(stbi__f2f(-0.390180644f)); - int16x4_t rot3_0 = vdup_n_s16(stbi__f2f( 0.298631336f)); - int16x4_t rot3_1 = vdup_n_s16(stbi__f2f( 2.053119869f)); - int16x4_t rot3_2 = vdup_n_s16(stbi__f2f( 3.072711026f)); - int16x4_t rot3_3 = vdup_n_s16(stbi__f2f( 1.501321110f)); + int16x4_t rot0_0 = vdup_n_s16(rjpeg__f2f(0.5411961f)); + int16x4_t rot0_1 = vdup_n_s16(rjpeg__f2f(-1.847759065f)); + int16x4_t rot0_2 = vdup_n_s16(rjpeg__f2f( 0.765366865f)); + int16x4_t rot1_0 = vdup_n_s16(rjpeg__f2f( 1.175875602f)); + int16x4_t rot1_1 = vdup_n_s16(rjpeg__f2f(-0.899976223f)); + int16x4_t rot1_2 = vdup_n_s16(rjpeg__f2f(-2.562915447f)); + int16x4_t rot2_0 = vdup_n_s16(rjpeg__f2f(-1.961570560f)); + int16x4_t rot2_1 = vdup_n_s16(rjpeg__f2f(-0.390180644f)); + int16x4_t rot3_0 = vdup_n_s16(rjpeg__f2f( 0.298631336f)); + int16x4_t rot3_1 = vdup_n_s16(rjpeg__f2f( 2.053119869f)); + int16x4_t rot3_2 = vdup_n_s16(rjpeg__f2f( 3.072711026f)); + int16x4_t rot3_3 = vdup_n_s16(rjpeg__f2f( 1.501321110f)); #define dct_long_mul(out, inq, coeff) \ int32x4_t out##_l = vmull_s16(vget_low_s16(inq), coeff); \ @@ -1330,46 +1330,46 @@ static void stbi__idct_simd(uint8_t *out, int out_stride, short data[64]) #endif /* STBI_NEON */ -#define STBI__MARKER_none 0xff +#define RJPEG__MARKER_none 0xff /* if there's a pending marker from the entropy stream, return that * otherwise, fetch from the stream and get a marker. if there's no * marker, return 0xff, which is never a valid marker value */ -static uint8_t stbi__get_marker(stbi__jpeg *j) +static uint8_t rjpeg__get_marker(rjpeg__jpeg *j) { uint8_t x; - if (j->marker != STBI__MARKER_none) { x = j->marker; j->marker = STBI__MARKER_none; return x; } - x = stbi__get8(j->s); - if (x != 0xff) return STBI__MARKER_none; + if (j->marker != RJPEG__MARKER_none) { x = j->marker; j->marker = RJPEG__MARKER_none; return x; } + x = rjpeg__get8(j->s); + if (x != 0xff) return RJPEG__MARKER_none; while (x == 0xff) - x = stbi__get8(j->s); + x = rjpeg__get8(j->s); return x; } /* in each scan, we'll have scan_n components, and the order * of the components is specified by order[] */ -#define STBI__RESTART(x) ((x) >= 0xd0 && (x) <= 0xd7) +#define RJPEG__RESTART(x) ((x) >= 0xd0 && (x) <= 0xd7) -/* after a restart interval, stbi__jpeg_reset the entropy decoder and +/* after a restart interval, rjpeg__jpeg_reset the entropy decoder and * the dc prediction */ -static void stbi__jpeg_reset(stbi__jpeg *j) +static void rjpeg__jpeg_reset(rjpeg__jpeg *j) { j->code_bits = 0; j->code_buffer = 0; j->nomore = 0; j->img_comp[0].dc_pred = j->img_comp[1].dc_pred = j->img_comp[2].dc_pred = 0; - j->marker = STBI__MARKER_none; + j->marker = RJPEG__MARKER_none; j->todo = j->restart_interval ? j->restart_interval : 0x7fffffff; j->eob_run = 0; /* no more than 1<<31 MCUs if no restart_interal? that's plenty safe, * since we don't even allow 1<<30 pixels */ } -static int stbi__parse_entropy_coded_data(stbi__jpeg *z) +static int rjpeg__parse_entropy_coded_data(rjpeg__jpeg *z) { - stbi__jpeg_reset(z); + rjpeg__jpeg_reset(z); if (!z->progressive) { if (z->scan_n == 1) { int i,j; @@ -1384,16 +1384,16 @@ static int stbi__parse_entropy_coded_data(stbi__jpeg *z) for (j=0; j < h; ++j) { for (i=0; i < w; ++i) { int ha = z->img_comp[n].ha; - if (!stbi__jpeg_decode_block(z, data, z->huff_dc+z->img_comp[n].hd, z->huff_ac+ha, z->fast_ac[ha], n, z->dequant[z->img_comp[n].tq])) return 0; + if (!rjpeg__jpeg_decode_block(z, data, z->huff_dc+z->img_comp[n].hd, z->huff_ac+ha, z->fast_ac[ha], n, z->dequant[z->img_comp[n].tq])) return 0; z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*j*8+i*8, z->img_comp[n].w2, data); /* every data block is an MCU, so countdown the restart interval */ if (--z->todo <= 0) { - if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); + if (z->code_bits < 24) rjpeg__grow_buffer_unsafe(z); // if it's NOT a restart, then just bail, so we get corrupt data // rather than no data - if (!STBI__RESTART(z->marker)) return 1; - stbi__jpeg_reset(z); + if (!RJPEG__RESTART(z->marker)) return 1; + rjpeg__jpeg_reset(z); } } } @@ -1413,7 +1413,7 @@ static int stbi__parse_entropy_coded_data(stbi__jpeg *z) int x2 = (i*z->img_comp[n].h + x)*8; int y2 = (j*z->img_comp[n].v + y)*8; int ha = z->img_comp[n].ha; - if (!stbi__jpeg_decode_block(z, data, z->huff_dc+z->img_comp[n].hd, z->huff_ac+ha, z->fast_ac[ha], n, z->dequant[z->img_comp[n].tq])) return 0; + if (!rjpeg__jpeg_decode_block(z, data, z->huff_dc+z->img_comp[n].hd, z->huff_ac+ha, z->fast_ac[ha], n, z->dequant[z->img_comp[n].tq])) return 0; z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*y2+x2, z->img_comp[n].w2, data); } } @@ -1421,9 +1421,9 @@ static int stbi__parse_entropy_coded_data(stbi__jpeg *z) // after all interleaved components, that's an interleaved MCU, // so now count down the restart interval if (--z->todo <= 0) { - if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); - if (!STBI__RESTART(z->marker)) return 1; - stbi__jpeg_reset(z); + if (z->code_bits < 24) rjpeg__grow_buffer_unsafe(z); + if (!RJPEG__RESTART(z->marker)) return 1; + rjpeg__jpeg_reset(z); } } } @@ -1443,18 +1443,18 @@ static int stbi__parse_entropy_coded_data(stbi__jpeg *z) for (i=0; i < w; ++i) { short *data = z->img_comp[n].coeff + 64 * (i + j * z->img_comp[n].coeff_w); if (z->spec_start == 0) { - if (!stbi__jpeg_decode_block_prog_dc(z, data, &z->huff_dc[z->img_comp[n].hd], n)) + if (!rjpeg__jpeg_decode_block_prog_dc(z, data, &z->huff_dc[z->img_comp[n].hd], n)) return 0; } else { int ha = z->img_comp[n].ha; - if (!stbi__jpeg_decode_block_prog_ac(z, data, &z->huff_ac[ha], z->fast_ac[ha])) + if (!rjpeg__jpeg_decode_block_prog_ac(z, data, &z->huff_ac[ha], z->fast_ac[ha])) return 0; } // every data block is an MCU, so countdown the restart interval if (--z->todo <= 0) { - if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); - if (!STBI__RESTART(z->marker)) return 1; - stbi__jpeg_reset(z); + if (z->code_bits < 24) rjpeg__grow_buffer_unsafe(z); + if (!RJPEG__RESTART(z->marker)) return 1; + rjpeg__jpeg_reset(z); } } } @@ -1473,7 +1473,7 @@ static int stbi__parse_entropy_coded_data(stbi__jpeg *z) int x2 = (i*z->img_comp[n].h + x); int y2 = (j*z->img_comp[n].v + y); short *data = z->img_comp[n].coeff + 64 * (x2 + y2 * z->img_comp[n].coeff_w); - if (!stbi__jpeg_decode_block_prog_dc(z, data, &z->huff_dc[z->img_comp[n].hd], n)) + if (!rjpeg__jpeg_decode_block_prog_dc(z, data, &z->huff_dc[z->img_comp[n].hd], n)) return 0; } } @@ -1481,9 +1481,9 @@ static int stbi__parse_entropy_coded_data(stbi__jpeg *z) // after all interleaved components, that's an interleaved MCU, // so now count down the restart interval if (--z->todo <= 0) { - if (z->code_bits < 24) stbi__grow_buffer_unsafe(z); - if (!STBI__RESTART(z->marker)) return 1; - stbi__jpeg_reset(z); + if (z->code_bits < 24) rjpeg__grow_buffer_unsafe(z); + if (!RJPEG__RESTART(z->marker)) return 1; + rjpeg__jpeg_reset(z); } } } @@ -1492,14 +1492,14 @@ static int stbi__parse_entropy_coded_data(stbi__jpeg *z) } } -static void stbi__jpeg_dequantize(short *data, uint8_t *dequant) +static void rjpeg__jpeg_dequantize(short *data, uint8_t *dequant) { int i; for (i=0; i < 64; ++i) data[i] *= dequant[i]; } -static void stbi__jpeg_finish(stbi__jpeg *z) +static void rjpeg__jpeg_finish(rjpeg__jpeg *z) { if (z->progressive) { @@ -1513,7 +1513,7 @@ static void stbi__jpeg_finish(stbi__jpeg *z) for (i=0; i < w; ++i) { short *data = z->img_comp[n].coeff + 64 * (i + j * z->img_comp[n].coeff_w); - stbi__jpeg_dequantize(data, z->dequant[z->img_comp[n].tq]); + rjpeg__jpeg_dequantize(data, z->dequant[z->img_comp[n].tq]); z->idct_block_kernel(z->img_comp[n].data+z->img_comp[n].w2*j*8+i*8, z->img_comp[n].w2, data); } } @@ -1521,70 +1521,70 @@ static void stbi__jpeg_finish(stbi__jpeg *z) } } -static int stbi__process_marker(stbi__jpeg *z, int m) +static int rjpeg__process_marker(rjpeg__jpeg *z, int m) { int L; switch (m) { - case STBI__MARKER_none: // no marker found - return stbi__err("expected marker","Corrupt JPEG"); + case RJPEG__MARKER_none: // no marker found + return rjpeg__err("expected marker","Corrupt JPEG"); case 0xDD: /* DRI - specify restart interval */ - if (stbi__get16be(z->s) != 4) return stbi__err("bad DRI len","Corrupt JPEG"); - z->restart_interval = stbi__get16be(z->s); + if (rjpeg__get16be(z->s) != 4) return rjpeg__err("bad DRI len","Corrupt JPEG"); + z->restart_interval = rjpeg__get16be(z->s); return 1; case 0xDB: /* DQT - define quantization table */ - L = stbi__get16be(z->s)-2; + L = rjpeg__get16be(z->s)-2; while (L > 0) { - int q = stbi__get8(z->s); + int q = rjpeg__get8(z->s); int p = q >> 4; int t = q & 15,i; if (p != 0) - return stbi__err("bad DQT type","Corrupt JPEG"); + return rjpeg__err("bad DQT type","Corrupt JPEG"); if (t > 3) - return stbi__err("bad DQT table","Corrupt JPEG"); + return rjpeg__err("bad DQT table","Corrupt JPEG"); for (i=0; i < 64; ++i) - z->dequant[t][stbi__jpeg_dezigzag[i]] = stbi__get8(z->s); + z->dequant[t][rjpeg__jpeg_dezigzag[i]] = rjpeg__get8(z->s); L -= 65; } return L==0; case 0xC4: /* DHT - define huffman table */ - L = stbi__get16be(z->s)-2; + L = rjpeg__get16be(z->s)-2; while (L > 0) { int sizes[16],i,n=0; uint8_t *v = NULL; - int q = stbi__get8(z->s); + int q = rjpeg__get8(z->s); int tc = q >> 4; int th = q & 15; if (tc > 1 || th > 3) - return stbi__err("bad DHT header","Corrupt JPEG"); + return rjpeg__err("bad DHT header","Corrupt JPEG"); for (i=0; i < 16; ++i) { - sizes[i] = stbi__get8(z->s); + sizes[i] = rjpeg__get8(z->s); n += sizes[i]; } L -= 17; if (tc == 0) { - if (!stbi__build_huffman(z->huff_dc+th, sizes)) + if (!rjpeg__build_huffman(z->huff_dc+th, sizes)) return 0; v = z->huff_dc[th].values; } else { - if (!stbi__build_huffman(z->huff_ac+th, sizes)) + if (!rjpeg__build_huffman(z->huff_ac+th, sizes)) return 0; v = z->huff_ac[th].values; } for (i=0; i < n; ++i) - v[i] = stbi__get8(z->s); + v[i] = rjpeg__get8(z->s); if (tc != 0) - stbi__build_fast_ac(z->fast_ac[th], z->huff_ac + th); + rjpeg__build_fast_ac(z->fast_ac[th], z->huff_ac + th); L -= n; } return L==0; @@ -1593,29 +1593,29 @@ static int stbi__process_marker(stbi__jpeg *z, int m) /* check for comment block or APP blocks */ if ((m >= 0xE0 && m <= 0xEF) || m == 0xFE) { - stbi__skip(z->s, stbi__get16be(z->s)-2); + rjpeg__skip(z->s, rjpeg__get16be(z->s)-2); return 1; } return 0; } /* after we see SOS */ -static int stbi__process_scan_header(stbi__jpeg *z) +static int rjpeg__process_scan_header(rjpeg__jpeg *z) { int i; - int Ls = stbi__get16be(z->s); + int Ls = rjpeg__get16be(z->s); - z->scan_n = stbi__get8(z->s); + z->scan_n = rjpeg__get8(z->s); if (z->scan_n < 1 || z->scan_n > 4 || z->scan_n > (int) z->s->img_n) - return stbi__err("bad SOS component count","Corrupt JPEG"); + return rjpeg__err("bad SOS component count","Corrupt JPEG"); if (Ls != 6+2*z->scan_n) - return stbi__err("bad SOS len","Corrupt JPEG"); + return rjpeg__err("bad SOS len","Corrupt JPEG"); for (i=0; i < z->scan_n; ++i) { - int id = stbi__get8(z->s), which; - int q = stbi__get8(z->s); + int id = rjpeg__get8(z->s), which; + int q = rjpeg__get8(z->s); for (which = 0; which < z->s->img_n; ++which) if (z->img_comp[which].id == id) @@ -1624,25 +1624,25 @@ static int stbi__process_scan_header(stbi__jpeg *z) return 0; /* no match */ z->img_comp[which].hd = q >> 4; if (z->img_comp[which].hd > 3) - return stbi__err("bad DC huff","Corrupt JPEG"); + return rjpeg__err("bad DC huff","Corrupt JPEG"); z->img_comp[which].ha = q & 15; if (z->img_comp[which].ha > 3) - return stbi__err("bad AC huff","Corrupt JPEG"); + return rjpeg__err("bad AC huff","Corrupt JPEG"); z->order[i] = which; } { int aa; - z->spec_start = stbi__get8(z->s); - z->spec_end = stbi__get8(z->s); /* should be 63, but might be 0 */ - aa = stbi__get8(z->s); + z->spec_start = rjpeg__get8(z->s); + z->spec_end = rjpeg__get8(z->s); /* should be 63, but might be 0 */ + aa = rjpeg__get8(z->s); z->succ_high = (aa >> 4); z->succ_low = (aa & 15); if (z->progressive) { if (z->spec_start > 63 || z->spec_end > 63 || z->spec_start > z->spec_end || z->succ_high > 13 || z->succ_low > 13) - return stbi__err("bad SOS", "Corrupt JPEG"); + return rjpeg__err("bad SOS", "Corrupt JPEG"); } else { - if (z->spec_start != 0) return stbi__err("bad SOS","Corrupt JPEG"); - if (z->succ_high != 0 || z->succ_low != 0) return stbi__err("bad SOS","Corrupt JPEG"); + if (z->spec_start != 0) return rjpeg__err("bad SOS","Corrupt JPEG"); + if (z->succ_high != 0 || z->succ_low != 0) return rjpeg__err("bad SOS","Corrupt JPEG"); z->spec_end = 63; } } @@ -1650,34 +1650,34 @@ static int stbi__process_scan_header(stbi__jpeg *z) return 1; } -static int stbi__process_frame_header(stbi__jpeg *z, int scan) +static int rjpeg__process_frame_header(rjpeg__jpeg *z, int scan) { - stbi__context *s = z->s; + rjpeg__context *s = z->s; int Lf,p,i,q, h_max=1,v_max=1,c; - Lf = stbi__get16be(s); + Lf = rjpeg__get16be(s); if (Lf < 11) - return stbi__err("bad SOF len","Corrupt JPEG"); /* JPEG */ + return rjpeg__err("bad SOF len","Corrupt JPEG"); /* JPEG */ - p = stbi__get8(s); + p = rjpeg__get8(s); if (p != 8) - return stbi__err("only 8-bit","JPEG format not supported: 8-bit only"); /* JPEG baseline */ + return rjpeg__err("only 8-bit","JPEG format not supported: 8-bit only"); /* JPEG baseline */ - s->img_y = stbi__get16be(s); + s->img_y = rjpeg__get16be(s); if (s->img_y == 0) - return stbi__err("no header height", "JPEG format not supported: delayed height"); /* Legal, but we don't handle it--but neither does IJG */ + return rjpeg__err("no header height", "JPEG format not supported: delayed height"); /* Legal, but we don't handle it--but neither does IJG */ - s->img_x = stbi__get16be(s); + s->img_x = rjpeg__get16be(s); if (s->img_x == 0) - return stbi__err("0 width","Corrupt JPEG"); /* JPEG requires */ + return rjpeg__err("0 width","Corrupt JPEG"); /* JPEG requires */ - c = stbi__get8(s); + c = rjpeg__get8(s); if (c != 3 && c != 1) - return stbi__err("bad component count","Corrupt JPEG"); /* JFIF requires */ + return rjpeg__err("bad component count","Corrupt JPEG"); /* JFIF requires */ s->img_n = c; @@ -1688,23 +1688,23 @@ static int stbi__process_frame_header(stbi__jpeg *z, int scan) } if (Lf != 8+3*s->img_n) - return stbi__err("bad SOF len","Corrupt JPEG"); + return rjpeg__err("bad SOF len","Corrupt JPEG"); for (i=0; i < s->img_n; ++i) { - z->img_comp[i].id = stbi__get8(s); + z->img_comp[i].id = rjpeg__get8(s); if (z->img_comp[i].id != i+1) // JFIF requires if (z->img_comp[i].id != i) // some version of jpegtran outputs non-JFIF-compliant files! - return stbi__err("bad component ID","Corrupt JPEG"); - q = stbi__get8(s); - z->img_comp[i].h = (q >> 4); if (!z->img_comp[i].h || z->img_comp[i].h > 4) return stbi__err("bad H","Corrupt JPEG"); - z->img_comp[i].v = q & 15; if (!z->img_comp[i].v || z->img_comp[i].v > 4) return stbi__err("bad V","Corrupt JPEG"); - z->img_comp[i].tq = stbi__get8(s); if (z->img_comp[i].tq > 3) return stbi__err("bad TQ","Corrupt JPEG"); + return rjpeg__err("bad component ID","Corrupt JPEG"); + q = rjpeg__get8(s); + z->img_comp[i].h = (q >> 4); if (!z->img_comp[i].h || z->img_comp[i].h > 4) return rjpeg__err("bad H","Corrupt JPEG"); + z->img_comp[i].v = q & 15; if (!z->img_comp[i].v || z->img_comp[i].v > 4) return rjpeg__err("bad V","Corrupt JPEG"); + z->img_comp[i].tq = rjpeg__get8(s); if (z->img_comp[i].tq > 3) return rjpeg__err("bad TQ","Corrupt JPEG"); } - if (scan != STBI__SCAN_load) return 1; + if (scan != RJPEG_SCAN_LOAD) return 1; - if ((1 << 30) / s->img_x / s->img_n < s->img_y) return stbi__err("too large", "Image too large to decode"); + if ((1 << 30) / s->img_x / s->img_n < s->img_y) return rjpeg__err("too large", "Image too large to decode"); for (i=0; i < s->img_n; ++i) { if (z->img_comp[i].h > h_max) h_max = z->img_comp[i].h; @@ -1736,7 +1736,7 @@ static int stbi__process_frame_header(stbi__jpeg *z, int scan) free(z->img_comp[i].raw_data); z->img_comp[i].data = NULL; } - return stbi__err("outofmem", "Out of memory"); + return rjpeg__err("outofmem", "Out of memory"); } // align blocks for idct using mmx/sse z->img_comp[i].data = (uint8_t*) (((size_t) z->img_comp[i].raw_data + 15) & ~15); @@ -1756,38 +1756,38 @@ static int stbi__process_frame_header(stbi__jpeg *z, int scan) } // use comparisons since in some cases we handle more than one case (e.g. SOF) -#define stbi__DNL(x) ((x) == 0xdc) -#define stbi__SOI(x) ((x) == 0xd8) -#define stbi__EOI(x) ((x) == 0xd9) -#define stbi__SOF(x) ((x) == 0xc0 || (x) == 0xc1 || (x) == 0xc2) -#define stbi__SOS(x) ((x) == 0xda) +#define rjpeg__DNL(x) ((x) == 0xdc) +#define rjpeg__SOI(x) ((x) == 0xd8) +#define rjpeg__EOI(x) ((x) == 0xd9) +#define rjpeg__SOF(x) ((x) == 0xc0 || (x) == 0xc1 || (x) == 0xc2) +#define rjpeg__SOS(x) ((x) == 0xda) -#define stbi__SOF_progressive(x) ((x) == 0xc2) +#define rjpeg__SOF_progressive(x) ((x) == 0xc2) -static int stbi__decode_jpeg_header(stbi__jpeg *z, int scan) +static int rjpeg__decode_jpeg_header(rjpeg__jpeg *z, int scan) { int m; - z->marker = STBI__MARKER_none; /* initialize cached marker to empty */ - m = stbi__get_marker(z); - if (!stbi__SOI(m)) return stbi__err("no SOI","Corrupt JPEG"); - if (scan == STBI__SCAN_type) return 1; - m = stbi__get_marker(z); - while (!stbi__SOF(m)) { - if (!stbi__process_marker(z,m)) return 0; - m = stbi__get_marker(z); - while (m == STBI__MARKER_none) { + z->marker = RJPEG__MARKER_none; /* initialize cached marker to empty */ + m = rjpeg__get_marker(z); + if (!rjpeg__SOI(m)) return rjpeg__err("no SOI","Corrupt JPEG"); + if (scan == RJPEG_SCAN_TYPE) return 1; + m = rjpeg__get_marker(z); + while (!rjpeg__SOF(m)) { + if (!rjpeg__process_marker(z,m)) return 0; + m = rjpeg__get_marker(z); + while (m == RJPEG__MARKER_none) { /* some files have extra padding after their blocks, so ok, we'll scan */ - if (stbi__at_eof(z->s)) return stbi__err("no SOF", "Corrupt JPEG"); - m = stbi__get_marker(z); + if (rjpeg__at_eof(z->s)) return rjpeg__err("no SOF", "Corrupt JPEG"); + m = rjpeg__get_marker(z); } } - z->progressive = stbi__SOF_progressive(m); - if (!stbi__process_frame_header(z, scan)) return 0; + z->progressive = rjpeg__SOF_progressive(m); + if (!rjpeg__process_frame_header(z, scan)) return 0; return 1; } /* decode image to YCbCr format */ -static int stbi__decode_jpeg_image(stbi__jpeg *j) +static int rjpeg__decode_jpeg_image(rjpeg__jpeg *j) { int m; for (m = 0; m < 4; m++) @@ -1796,45 +1796,45 @@ static int stbi__decode_jpeg_image(stbi__jpeg *j) j->img_comp[m].raw_coeff = NULL; } j->restart_interval = 0; - if (!stbi__decode_jpeg_header(j, STBI__SCAN_load)) return 0; - m = stbi__get_marker(j); + if (!rjpeg__decode_jpeg_header(j, RJPEG_SCAN_LOAD)) return 0; + m = rjpeg__get_marker(j); - while (!stbi__EOI(m)) + while (!rjpeg__EOI(m)) { - if (stbi__SOS(m)) + if (rjpeg__SOS(m)) { - if (!stbi__process_scan_header(j)) + if (!rjpeg__process_scan_header(j)) return 0; - if (!stbi__parse_entropy_coded_data(j)) + if (!rjpeg__parse_entropy_coded_data(j)) return 0; - if (j->marker == STBI__MARKER_none ) + if (j->marker == RJPEG__MARKER_none ) { /* handle 0s at the end of image data from IP Kamera 9060 */ - while (!stbi__at_eof(j->s)) + while (!rjpeg__at_eof(j->s)) { - int x = stbi__get8(j->s); + int x = rjpeg__get8(j->s); if (x == 255) { - j->marker = stbi__get8(j->s); + j->marker = rjpeg__get8(j->s); break; } else if (x != 0) - return stbi__err("junk before marker", "Corrupt JPEG"); + return rjpeg__err("junk before marker", "Corrupt JPEG"); } - /* if we reach eof without hitting a marker, stbi__get_marker() below will fail and we'll eventually return 0 */ + /* if we reach eof without hitting a marker, rjpeg__get_marker() below will fail and we'll eventually return 0 */ } } else { - if (!stbi__process_marker(j, m)) + if (!rjpeg__process_marker(j, m)) return 0; } - m = stbi__get_marker(j); + m = rjpeg__get_marker(j); } if (j->progressive) - stbi__jpeg_finish(j); + rjpeg__jpeg_finish(j); return 1; } @@ -1876,13 +1876,13 @@ static uint8_t* rjpeg__resample_row_h_2(uint8_t *out, uint8_t *in_near, uint8_t } out[0] = input[0]; - out[1] = stbi__div4(input[0]*3 + input[1] + 2); + out[1] = rjpeg__div4(input[0]*3 + input[1] + 2); for (i=1; i < w-1; ++i) { int n = 3*input[i]+2; - out[i*2+0] = stbi__div4(n+input[i-1]); - out[i*2+1] = stbi__div4(n+input[i+1]); + out[i*2+0] = rjpeg__div4(n+input[i-1]); + out[i*2+1] = rjpeg__div4(n+input[i+1]); } - out[i*2+0] = stbi__div4(input[w-2]*3 + input[w-1] + 2); + out[i*2+0] = rjpeg__div4(input[w-2]*3 + input[w-1] + 2); out[i*2+1] = input[w-1]; (void)in_far; @@ -2031,10 +2031,10 @@ static uint8_t *rjpeg__resample_row_hv_2_simd(uint8_t *out, uint8_t *in_near, ui { t0 = t1; t1 = 3*in_near[i]+in_far[i]; - out[i*2-1] = stbi__div16(3*t0 + t1 + 8); - out[i*2 ] = stbi__div16(3*t1 + t0 + 8); + out[i*2-1] = rjpeg__div16(3*t0 + t1 + 8); + out[i*2 ] = rjpeg__div16(3*t1 + t0 + 8); } - out[w*2-1] = stbi__div4(t1+2); + out[w*2-1] = rjpeg__div4(t1+2); (void)hs; @@ -2289,7 +2289,7 @@ static uint8_t *load_jpeg_image(rjpeg__jpeg *z, int *out_x, int *out_y, int *com return rjpeg__errpuc("bad req_comp", "Internal error"); /* load a jpeg image from whichever source, but leave in YCbCr format */ - if (!stbi__decode_jpeg_image(z)) + if (!rjpeg__decode_jpeg_image(z)) { rjpeg__cleanup_jpeg(z); return NULL; @@ -2354,7 +2354,7 @@ static uint8_t *load_jpeg_image(rjpeg__jpeg *z, int *out_x, int *out_y, int *com uint8_t *out = output + n * z->s->img_x * j; for (k=0; k < decode_n; ++k) { - stbi__resample *r = &res_comp[k]; + rjpeg__resample *r = &res_comp[k]; int y_bot = r->ystep >= (r->vs >> 1); coutput[k] = r->resample(z->img_comp[k].linebuf, y_bot ? r->line1 : r->line0, @@ -2395,7 +2395,7 @@ static uint8_t *load_jpeg_image(rjpeg__jpeg *z, int *out_x, int *out_y, int *com } } - stbi__cleanup_jpeg(z); + rjpeg__cleanup_jpeg(z); *out_x = z->s->img_x; *out_y = z->s->img_y; @@ -2405,22 +2405,22 @@ static uint8_t *load_jpeg_image(rjpeg__jpeg *z, int *out_x, int *out_y, int *com } } -static unsigned char *stbi__jpeg_load(stbi__context *s, int *x, int *y, int *comp, int req_comp) +static unsigned char *rjpeg__jpeg_load(rjpeg__context *s, int *x, int *y, int *comp, int req_comp) { - stbi__jpeg j; + rjpeg__jpeg j; j.s = s; - stbi__setup_jpeg(&j); + rjpeg__setup_jpeg(&j); return load_jpeg_image(&j, x,y,comp,req_comp); } -static int stbi__jpeg_test(stbi__context *s) +static int rjpeg__jpeg_test(rjpeg__context *s) { int r; - stbi__jpeg j; + rjpeg__jpeg j; j.s = s; - stbi__setup_jpeg(&j); - r = stbi__decode_jpeg_header(&j, STBI__SCAN_type); - stbi__rewind(s); + rjpeg__setup_jpeg(&j); + r = rjpeg__decode_jpeg_header(&j, RJPEG_SCAN_TYPE); + rjpeg__rewind(s); return r; } @@ -2450,7 +2450,7 @@ bool rjpeg_image_load(uint8_t *_buf, void *data, size_t size, int x, y, comp; struct texture_image *out_img = (struct texture_image*)data; - out_img->pixels = (uint32_t*)stbi_load_from_memory(_buf, size, &x, &y, &comp, 4); + out_img->pixels = (uint32_t*)rjpeg_load_from_memory(_buf, size, &x, &y, &comp, 4); out_img->width = x; out_img->height = y; From b59b56d2fc70c40631851d08848f0972cd0e3992 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Tue, 10 May 2016 07:09:27 +0200 Subject: [PATCH 371/498] (RJPEG) Last buildfixes --- libretro-common/formats/jpeg/rjpeg.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libretro-common/formats/jpeg/rjpeg.c b/libretro-common/formats/jpeg/rjpeg.c index 4be01206c5..22a7f0565d 100644 --- a/libretro-common/formats/jpeg/rjpeg.c +++ b/libretro-common/formats/jpeg/rjpeg.c @@ -2279,7 +2279,7 @@ static void rjpeg__cleanup_jpeg(rjpeg__jpeg *j) } -static uint8_t *load_jpeg_image(rjpeg__jpeg *z, int *out_x, int *out_y, int *comp, int req_comp) +static uint8_t *rjpeg_load_jpeg_image(rjpeg__jpeg *z, int *out_x, int *out_y, int *comp, int req_comp) { int n, decode_n; z->s->img_n = 0; /* make rjpeg__cleanup_jpeg safe */ @@ -2410,7 +2410,7 @@ static unsigned char *rjpeg__jpeg_load(rjpeg__context *s, int *x, int *y, int *c rjpeg__jpeg j; j.s = s; rjpeg__setup_jpeg(&j); - return load_jpeg_image(&j, x,y,comp,req_comp); + return rjpeg_load_jpeg_image(&j, x,y,comp,req_comp); } static int rjpeg__jpeg_test(rjpeg__context *s) @@ -2446,7 +2446,6 @@ bool rjpeg_image_load(uint8_t *_buf, void *data, size_t size, unsigned a_shift, unsigned r_shift, unsigned g_shift, unsigned b_shift) { - unsigned i; int x, y, comp; struct texture_image *out_img = (struct texture_image*)data; From 8d3f6c39ac7fb92f013c2d7dd89f8c56049f417d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 May 2016 07:10:42 +0200 Subject: [PATCH 372/498] Replace STBI_ with RJPEG_ --- libretro-common/formats/jpeg/rjpeg.c | 54 ++++++++++++++-------------- 1 file changed, 27 insertions(+), 27 deletions(-) diff --git a/libretro-common/formats/jpeg/rjpeg.c b/libretro-common/formats/jpeg/rjpeg.c index 22a7f0565d..48c3542b61 100644 --- a/libretro-common/formats/jpeg/rjpeg.c +++ b/libretro-common/formats/jpeg/rjpeg.c @@ -39,10 +39,10 @@ typedef struct } rjpeg__resample; #ifdef _MSC_VER -#define STBI_HAS_LROTL +#define RJPEG_HAS_LROTL #endif -#ifdef STBI_HAS_LROTL +#ifdef RJPEG_HAS_LROTL #define rjpeg_lrot(x,y) _lrotl(x,y) #else #define rjpeg_lrot(x,y) (((x) << (y)) | ((x) >> (32 - (y)))) @@ -55,17 +55,17 @@ typedef struct #define RJPEG__X86_TARGET #endif -#if defined(__GNUC__) && (defined(RJPEG__X86_TARGET) || defined(RJPEG__X64_TARGET)) && !defined(__SSE2__) && !defined(STBI_NO_SIMD) +#if defined(__GNUC__) && (defined(RJPEG__X86_TARGET) || defined(RJPEG__X64_TARGET)) && !defined(__SSE2__) && !defined(RJPEG_NO_SIMD) /* NOTE: not clear do we actually need this for the 64-bit path? * gcc doesn't support sse2 intrinsics unless you compile with -msse2, * (but compiling with -msse2 allows the compiler to use SSE2 everywhere; * this is just broken and gcc are jerks for not fixing it properly * http://www.virtualdub.org/blog/pivot/entry.php?id=363 ) */ -#define STBI_NO_SIMD +#define RJPEG_NO_SIMD #endif -#if defined(__MINGW32__) && defined(RJPEG__X86_TARGET) && !defined(STBI_MINGW_ENABLE_SSE2) && !defined(STBI_NO_SIMD) +#if defined(__MINGW32__) && defined(RJPEG__X86_TARGET) && !defined(RJPEG_MINGW_ENABLE_SSE2) && !defined(RJPEG_NO_SIMD) /* Note that __MINGW32__ doesn't actually mean 32-bit, so we have to avoid RJPEG__X64_TARGET * * 32-bit MinGW wants ESP to be 16-byte aligned, but this is not in the @@ -76,9 +76,9 @@ typedef struct * See https://github.com/nothings/stb/issues/81 for more information. * * So default to no SSE2 on 32-bit MinGW. If you've read this far and added - * -mstackrealign to your build settings, feel free to #define STBI_MINGW_ENABLE_SSE2. + * -mstackrealign to your build settings, feel free to #define RJPEG_MINGW_ENABLE_SSE2. */ -#define STBI_NO_SIMD +#define RJPEG_NO_SIMD #endif #if defined(__SSE2__) @@ -107,7 +107,7 @@ static int rjpeg__cpuid3(void) } #endif -#define STBI_SIMD_ALIGN(type, name) __declspec(align(16)) type name +#define RJPEG_SIMD_ALIGN(type, name) __declspec(align(16)) type name static int rjpeg__sse2_available(void) { @@ -132,18 +132,18 @@ static int rjpeg__sse2_available(void) #endif /* ARM NEON */ -#if defined(STBI_NO_SIMD) && defined(STBI_NEON) -#undef STBI_NEON +#if defined(RJPEG_NO_SIMD) && defined(RJPEG_NEON) +#undef RJPEG_NEON #endif -#ifdef STBI_NEON +#ifdef RJPEG_NEON #include /* assume GCC or Clang on ARM targets */ -#define STBI_SIMD_ALIGN(type, name) type name __attribute__((aligned(16))) +#define RJPEG_SIMD_ALIGN(type, name) type name __attribute__((aligned(16))) #endif -#ifndef STBI_SIMD_ALIGN -#define STBI_SIMD_ALIGN(type, name) type name +#ifndef RJPEG_SIMD_ALIGN +#define RJPEG_SIMD_ALIGN(type, name) type name #endif typedef struct @@ -180,7 +180,7 @@ static void rjpeg__rewind(rjpeg__context *s) s->img_buffer = s->img_buffer_original; } -#ifndef STBI_NO_JPEG +#ifndef RJPEG_NO_JPEG static int rjpeg__jpeg_test(rjpeg__context *s); static uint8_t *rjpeg__jpeg_load(rjpeg__context *s, int *x, int *y, int *comp, int req_comp); #endif @@ -194,9 +194,9 @@ static INLINE int rjpeg__err(const char *str) return 0; } -#ifdef STBI_NO_FAILURE_STRINGS +#ifdef RJPEG_NO_FAILURE_STRINGS #define rjpeg__err(x,y) 0 -#elif defined(STBI_FAILURE_USERMSG) +#elif defined(RJPEG_FAILURE_USERMSG) #define rjpeg__err(x,y) rjpeg__err(y) #else #define rjpeg__err(x,y) rjpeg__err(x) @@ -209,7 +209,7 @@ static int rjpeg__vertically_flip_on_load = 0; static unsigned char *rjpeg__load_main(rjpeg__context *s, int *x, int *y, int *comp, int req_comp) { - #ifndef STBI_NO_JPEG + #ifndef RJPEG_NO_JPEG if (rjpeg__jpeg_test(s)) return rjpeg__jpeg_load(s,x,y,comp,req_comp); #endif @@ -1122,7 +1122,7 @@ static void rjpeg__idct_simd(uint8_t *out, int out_stride, short data[64]) #endif -#ifdef STBI_NEON +#ifdef RJPEG_NEON /* NEON integer IDCT. should produce bit-identical * results to the generic C version. */ @@ -1328,7 +1328,7 @@ static void rjpeg__idct_simd(uint8_t *out, int out_stride, short data[64]) #undef dct_pass } -#endif /* STBI_NEON */ +#endif /* RJPEG_NEON */ #define RJPEG__MARKER_none 0xff /* if there's a pending marker from the entropy stream, return that @@ -1373,7 +1373,7 @@ static int rjpeg__parse_entropy_coded_data(rjpeg__jpeg *z) if (!z->progressive) { if (z->scan_n == 1) { int i,j; - STBI_SIMD_ALIGN(short, data[64]); + RJPEG_SIMD_ALIGN(short, data[64]); int n = z->order[0]; /* non-interleaved data, we just need to process one block at a time, * in trivial scanline order @@ -1400,7 +1400,7 @@ static int rjpeg__parse_entropy_coded_data(rjpeg__jpeg *z) return 1; } else { // interleaved int i,j,k,x,y; - STBI_SIMD_ALIGN(short, data[64]); + RJPEG_SIMD_ALIGN(short, data[64]); for (j=0; j < z->img_mcu_y; ++j) { for (i=0; i < z->img_mcu_x; ++i) { // scan an interleaved mcu... process scan_n components in order @@ -1919,7 +1919,7 @@ static uint8_t *rjpeg__resample_row_hv_2(uint8_t *out, uint8_t *in_near, uint8_t return out; } -#if defined(__SSE2__) || defined(STBI_NEON) +#if defined(__SSE2__) || defined(RJPEG_NEON) static uint8_t *rjpeg__resample_row_hv_2_simd(uint8_t *out, uint8_t *in_near, uint8_t *in_far, int w, int hs) { /* need to generate 2x2 samples for every one in input */ @@ -1982,7 +1982,7 @@ static uint8_t *rjpeg__resample_row_hv_2_simd(uint8_t *out, uint8_t *in_near, ui /* pack and write output */ __m128i outv = _mm_packus_epi16(de0, de1); _mm_storeu_si128((__m128i *) (out + i*2), outv); -#elif defined(STBI_NEON) +#elif defined(RJPEG_NEON) /* load and perform the vertical filtering pass * this uses 3*x + y = 4*x + (y - x) */ uint8x8_t farb = vld1_u8(in_far + i); @@ -2085,7 +2085,7 @@ static void rjpeg__YCbCr_to_RGB_row(uint8_t *out, const uint8_t *y, const uint8_ } } -#if defined(__SSE2__) || defined(STBI_NEON) +#if defined(__SSE2__) || defined(RJPEG_NEON) static void rjpeg__YCbCr_to_RGB_simd(uint8_t *out, const uint8_t *y, const uint8_t *pcb, const uint8_t *pcr, int count, int step) { int i = 0; @@ -2154,7 +2154,7 @@ static void rjpeg__YCbCr_to_RGB_simd(uint8_t *out, const uint8_t *y, const uint8 } #endif -#ifdef STBI_NEON +#ifdef RJPEG_NEON /* in this version, step=3 support would be easy to add. but is there demand? */ if (step == 4) { @@ -2243,7 +2243,7 @@ static void rjpeg__setup_jpeg(rjpeg__jpeg *j) } #endif -#ifdef STBI_NEON +#ifdef RJPEG_NEON j->idct_block_kernel = rjpeg__idct_simd; j->YCbCr_to_RGB_kernel = rjpeg__YCbCr_to_RGB_simd; j->resample_row_hv_2_kernel = rjpeg__resample_row_hv_2_simd; From bb063fb6924e300ac89a29793c0fb7f8210e5989 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 May 2016 07:13:52 +0200 Subject: [PATCH 373/498] Cleanups --- libretro-common/formats/jpeg/rjpeg.c | 76 ++++++++++++++++------------ 1 file changed, 43 insertions(+), 33 deletions(-) diff --git a/libretro-common/formats/jpeg/rjpeg.c b/libretro-common/formats/jpeg/rjpeg.c index 48c3542b61..6f33b5a42a 100644 --- a/libretro-common/formats/jpeg/rjpeg.c +++ b/libretro-common/formats/jpeg/rjpeg.c @@ -1,3 +1,6 @@ +/* Modified version of stb_image's JPEG sources. + */ + #include #include #include /* ptrdiff_t on osx */ @@ -400,6 +403,31 @@ typedef struct uint8_t *(*resample_row_hv_2_kernel)(uint8_t *out, uint8_t *in_near, uint8_t *in_far, int w, int hs); } rjpeg__jpeg; +#define rjpeg__f2f(x) ((int) (((x) * 4096 + 0.5))) +#define rjpeg__fsh(x) ((x) << 12) + +#define RJPEG__MARKER_none 0xff +/* if there's a pending marker from the entropy stream, return that + * otherwise, fetch from the stream and get a marker. if there's no + * marker, return 0xff, which is never a valid marker value + */ + +/* in each scan, we'll have scan_n components, and the order + * of the components is specified by order[] + */ +#define RJPEG__RESTART(x) ((x) >= 0xd0 && (x) <= 0xd7) + +// use comparisons since in some cases we handle more than one case (e.g. SOF) +#define rjpeg__DNL(x) ((x) == 0xdc) +#define rjpeg__SOI(x) ((x) == 0xd8) +#define rjpeg__EOI(x) ((x) == 0xd9) +#define rjpeg__SOF(x) ((x) == 0xc0 || (x) == 0xc1 || (x) == 0xc2) +#define rjpeg__SOS(x) ((x) == 0xda) + +#define rjpeg__SOF_progressive(x) ((x) == 0xc2) +#define rjpeg__div4(x) ((uint8_t) ((x) >> 2)) +#define rjpeg__div16(x) ((uint8_t) ((x) >> 4)) + static int rjpeg__build_huffman(rjpeg__huffman *h, int *count) { int i,j,k=0,code; @@ -837,8 +865,6 @@ static INLINE uint8_t rjpeg__clamp(int x) return (uint8_t) x; } -#define rjpeg__f2f(x) ((int) (((x) * 4096 + 0.5))) -#define rjpeg__fsh(x) ((x) << 12) /* derived from jidctint -- DCT_ISLOW */ #define RJPEG__IDCT_1D(s0,s1,s2,s3,s4,s5,s6,s7) \ @@ -1330,11 +1356,6 @@ static void rjpeg__idct_simd(uint8_t *out, int out_stride, short data[64]) #endif /* RJPEG_NEON */ -#define RJPEG__MARKER_none 0xff -/* if there's a pending marker from the entropy stream, return that - * otherwise, fetch from the stream and get a marker. if there's no - * marker, return 0xff, which is never a valid marker value - */ static uint8_t rjpeg__get_marker(rjpeg__jpeg *j) { uint8_t x; @@ -1346,10 +1367,6 @@ static uint8_t rjpeg__get_marker(rjpeg__jpeg *j) return x; } -/* in each scan, we'll have scan_n components, and the order - * of the components is specified by order[] - */ -#define RJPEG__RESTART(x) ((x) >= 0xd0 && (x) <= 0xd7) /* after a restart interval, rjpeg__jpeg_reset the entropy decoder and * the dc prediction @@ -1755,14 +1772,6 @@ static int rjpeg__process_frame_header(rjpeg__jpeg *z, int scan) return 1; } -// use comparisons since in some cases we handle more than one case (e.g. SOF) -#define rjpeg__DNL(x) ((x) == 0xdc) -#define rjpeg__SOI(x) ((x) == 0xd8) -#define rjpeg__EOI(x) ((x) == 0xd9) -#define rjpeg__SOF(x) ((x) == 0xc0 || (x) == 0xc1 || (x) == 0xc2) -#define rjpeg__SOS(x) ((x) == 0xda) - -#define rjpeg__SOF_progressive(x) ((x) == 0xc2) static int rjpeg__decode_jpeg_header(rjpeg__jpeg *z, int scan) { @@ -1841,7 +1850,6 @@ static int rjpeg__decode_jpeg_image(rjpeg__jpeg *j) /* static jfif-centered resampling (across block boundaries) */ -#define rjpeg__div4(x) ((uint8_t) ((x) >> 2)) static uint8_t *rjpeg_resample_row_1(uint8_t *out, uint8_t *in_near, uint8_t *in_far, int w, int hs) { @@ -1891,7 +1899,6 @@ static uint8_t* rjpeg__resample_row_h_2(uint8_t *out, uint8_t *in_near, uint8_t return out; } -#define rjpeg__div16(x) ((uint8_t) ((x) >> 4)) static uint8_t *rjpeg__resample_row_hv_2(uint8_t *out, uint8_t *in_near, uint8_t *in_far, int w, int hs) { @@ -2278,7 +2285,6 @@ static void rjpeg__cleanup_jpeg(rjpeg__jpeg *j) } } - static uint8_t *rjpeg_load_jpeg_image(rjpeg__jpeg *z, int *out_x, int *out_y, int *comp, int req_comp) { int n, decode_n; @@ -2325,18 +2331,22 @@ static uint8_t *rjpeg_load_jpeg_image(rjpeg__jpeg *z, int *out_x, int *out_y, in return rjpeg__errpuc("outofmem", "Out of memory"); } - r->hs = z->img_h_max / z->img_comp[k].h; - r->vs = z->img_v_max / z->img_comp[k].v; - r->ystep = r->vs >> 1; - r->w_lores = (z->s->img_x + r->hs-1) / r->hs; - r->ypos = 0; - r->line0 = r->line1 = z->img_comp[k].data; + r->hs = z->img_h_max / z->img_comp[k].h; + r->vs = z->img_v_max / z->img_comp[k].v; + r->ystep = r->vs >> 1; + r->w_lores = (z->s->img_x + r->hs-1) / r->hs; + r->ypos = 0; + r->line0 = r->line1 = z->img_comp[k].data; + r->resample = rjpeg__resample_row_generic; - if (r->hs == 1 && r->vs == 1) r->resample = rjpeg_resample_row_1; - else if (r->hs == 1 && r->vs == 2) r->resample = rjpeg__resample_row_v_2; - else if (r->hs == 2 && r->vs == 1) r->resample = rjpeg__resample_row_h_2; - else if (r->hs == 2 && r->vs == 2) r->resample = z->resample_row_hv_2_kernel; - else r->resample = rjpeg__resample_row_generic; + if (r->hs == 1 && r->vs == 1) + r->resample = rjpeg_resample_row_1; + else if (r->hs == 1 && r->vs == 2) + r->resample = rjpeg__resample_row_v_2; + else if (r->hs == 2 && r->vs == 1) + r->resample = rjpeg__resample_row_h_2; + else if (r->hs == 2 && r->vs == 2) + r->resample = z->resample_row_hv_2_kernel; } /* can't error after this so, this is safe */ From f3af0263ed579757d07b366a84471275aea22cd9 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 May 2016 07:15:23 +0200 Subject: [PATCH 374/498] Remove RJPEG_NO_JPEG --- libretro-common/formats/jpeg/rjpeg.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libretro-common/formats/jpeg/rjpeg.c b/libretro-common/formats/jpeg/rjpeg.c index 6f33b5a42a..8a96a3a651 100644 --- a/libretro-common/formats/jpeg/rjpeg.c +++ b/libretro-common/formats/jpeg/rjpeg.c @@ -212,9 +212,8 @@ static int rjpeg__vertically_flip_on_load = 0; static unsigned char *rjpeg__load_main(rjpeg__context *s, int *x, int *y, int *comp, int req_comp) { - #ifndef RJPEG_NO_JPEG - if (rjpeg__jpeg_test(s)) return rjpeg__jpeg_load(s,x,y,comp,req_comp); - #endif + if (rjpeg__jpeg_test(s)) + return rjpeg__jpeg_load(s,x,y,comp,req_comp); return rjpeg__errpuc("unknown image type", "Image not of any known type, or corrupt"); } From ea8715ca9291193a867143de1e0ed85c61f7bc45 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 May 2016 07:16:27 +0200 Subject: [PATCH 375/498] (RJPEG) Cleanup --- libretro-common/formats/jpeg/rjpeg.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libretro-common/formats/jpeg/rjpeg.c b/libretro-common/formats/jpeg/rjpeg.c index 8a96a3a651..4d43a66c76 100644 --- a/libretro-common/formats/jpeg/rjpeg.c +++ b/libretro-common/formats/jpeg/rjpeg.c @@ -183,10 +183,8 @@ static void rjpeg__rewind(rjpeg__context *s) s->img_buffer = s->img_buffer_original; } -#ifndef RJPEG_NO_JPEG static int rjpeg__jpeg_test(rjpeg__context *s); static uint8_t *rjpeg__jpeg_load(rjpeg__context *s, int *x, int *y, int *comp, int req_comp); -#endif /* this is not threadsafe */ static const char *rjpeg__g_failure_reason; From 8b07f39d6f706931689cef4a0aaa126a346cf336 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 May 2016 07:54:47 +0200 Subject: [PATCH 376/498] Create tasks/task_image.c --- Makefile.common | 1 + griffin/griffin.c | 1 + tasks/task_file_transfer.c | 409 +------------------------------------ tasks/task_image.c | 403 ++++++++++++++++++++++++++++++++++++ tasks/tasks_internal.h | 45 ++++ 5 files changed, 454 insertions(+), 405 deletions(-) create mode 100644 tasks/task_image.c diff --git a/Makefile.common b/Makefile.common index 9d184e89f8..ab4df5e620 100644 --- a/Makefile.common +++ b/Makefile.common @@ -127,6 +127,7 @@ OBJ += frontend/frontend.o \ tasks/tasks_internal.o \ tasks/task_content.o \ tasks/task_file_transfer.o \ + tasks/task_image.o \ content.o \ libretro-common/encodings/encoding_utf.o \ libretro-common/lists/file_list.o \ diff --git a/griffin/griffin.c b/griffin/griffin.c index 8c0d1ab72f..4bd73571bf 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -802,6 +802,7 @@ NETPLAY DATA RUNLOOP ============================================================ */ #include "../tasks/task_content.c" +#include "../tasks/image.c" #include "../tasks/task_file_transfer.c" #ifdef HAVE_ZLIB #include "../tasks/task_decompress.c" diff --git a/tasks/task_file_transfer.c b/tasks/task_file_transfer.c index 34db03a599..5b7c4ce5c5 100644 --- a/tasks/task_file_transfer.c +++ b/tasks/task_file_transfer.c @@ -17,373 +17,15 @@ #include #include #include -#include #include #include #include -#include #include #include #include "tasks_internal.h" #include "../verbosity.h" -#define CB_MENU_WALLPAPER 0xb476e505U -#define CB_MENU_THUMBNAIL 0x82f93a21U - -enum nbio_image_status_enum -{ - NBIO_IMAGE_STATUS_POLL = 0, - NBIO_IMAGE_STATUS_TRANSFER, - NBIO_IMAGE_STATUS_TRANSFER_PARSE, - NBIO_IMAGE_STATUS_PROCESS_TRANSFER, - NBIO_IMAGE_STATUS_PROCESS_TRANSFER_PARSE, - NBIO_IMAGE_STATUS_TRANSFER_PARSE_FREE -}; - -enum nbio_status_enum -{ - NBIO_STATUS_POLL = 0, - NBIO_STATUS_TRANSFER, - NBIO_STATUS_TRANSFER_PARSE, - NBIO_STATUS_TRANSFER_PARSE_FREE -}; - -typedef struct nbio_image_handle -{ - struct texture_image ti; - bool is_blocking; - bool is_blocking_on_processing; - bool is_finished; - transfer_cb_t cb; -#ifdef HAVE_RPNG - rpng_t *handle; -#endif - unsigned processing_pos_increment; - unsigned pos_increment; - uint64_t frame_count; - int processing_final_state; - unsigned status; -} nbio_image_handle_t; - -typedef struct nbio_handle -{ - nbio_image_handle_t image; - bool is_finished; - transfer_cb_t cb; - struct nbio_t *handle; - unsigned pos_increment; - uint64_t frame_count; - msg_queue_t *msg_queue; - unsigned status; -} nbio_handle_t; - - -#ifdef HAVE_MENU -#include "../menu/menu_driver.h" - -static void rarch_task_file_load_handler(retro_task_t *task); - -static int cb_image_menu_upload_generic(void *data, size_t len) -{ - nbio_handle_t *nbio = (nbio_handle_t*)data; - unsigned r_shift, g_shift, b_shift, a_shift; - - if (!nbio) - return -1; - - if (nbio->image.processing_final_state == IMAGE_PROCESS_ERROR || - nbio->image.processing_final_state == IMAGE_PROCESS_ERROR_END) - return -1; - - video_texture_image_set_color_shifts(&r_shift, &g_shift, &b_shift, - &a_shift); - - video_texture_image_color_convert(r_shift, g_shift, b_shift, - a_shift, &nbio->image.ti); - - nbio->image.is_blocking_on_processing = false; - nbio->image.is_blocking = true; - nbio->image.is_finished = true; - nbio->is_finished = true; - - return 0; -} - -#ifdef HAVE_RPNG -static int cb_image_menu_generic_rpng(nbio_handle_t *nbio) -{ - unsigned width = 0, height = 0; - int retval; - if (!nbio) - return -1; - - if (!rpng_is_valid(nbio->image.handle)) - return -1; - - retval = rpng_nbio_load_image_argb_process(nbio->image.handle, - &nbio->image.ti.pixels, &width, &height); - - nbio->image.ti.width = width; - nbio->image.ti.height = height; - - if (retval == IMAGE_PROCESS_ERROR) - return -1; - if (retval == IMAGE_PROCESS_ERROR_END) - return -1; - - nbio->image.is_blocking_on_processing = true; - nbio->image.is_finished = false; - - return 0; -} - -static int cb_image_menu_wallpaper_rpng(void *data, size_t len) -{ - nbio_handle_t *nbio = (nbio_handle_t*)data; - - if (cb_image_menu_generic_rpng(nbio) != 0) - return -1; - - nbio->image.cb = &cb_image_menu_upload_generic; - - return 0; -} - -static int cb_image_menu_thumbnail(void *data, size_t len) -{ - nbio_handle_t *nbio = (nbio_handle_t*)data; - - if (cb_image_menu_generic_rpng(nbio) != 0) - return -1; - - nbio->image.cb = &cb_image_menu_upload_generic; - - return 0; -} - -static int rarch_main_data_image_iterate_transfer(nbio_handle_t *nbio) -{ - unsigned i; - - if (!nbio) - return -1; - - if (nbio->image.is_finished) - return 0; - - for (i = 0; i < nbio->image.pos_increment; i++) - { - /* TODO/FIXME - add JPEG equivalents as well */ - if (!rpng_nbio_load_image_argb_iterate(nbio->image.handle)) - goto error; - } - - nbio->image.frame_count++; - return 0; - -error: - return -1; -} - -static int rarch_main_data_image_iterate_process_transfer(nbio_handle_t *nbio) -{ - unsigned i, width = 0, height = 0; - int retval = 0; - - if (!nbio) - return -1; - - for (i = 0; i < nbio->image.processing_pos_increment; i++) - { - /* TODO/FIXME -add JPEG equivalents as well */ - retval = rpng_nbio_load_image_argb_process(nbio->image.handle, - &nbio->image.ti.pixels, &width, &height); - - nbio->image.ti.width = width; - nbio->image.ti.height = height; - - if (retval != IMAGE_PROCESS_NEXT) - break; - } - - if (retval == IMAGE_PROCESS_NEXT) - return 0; - - nbio->image.processing_final_state = retval; - return -1; -} - -static int rarch_main_data_image_iterate_process_transfer_parse( - nbio_handle_t *nbio) -{ - if (nbio->image.handle && nbio->image.cb) - { - size_t len = 0; - nbio->image.cb(nbio, len); - } - - return 0; -} - -static int rarch_main_data_image_iterate_transfer_parse(nbio_handle_t *nbio) -{ - if (nbio->image.handle && nbio->image.cb) - { - size_t len = 0; - nbio->image.cb(nbio, len); - } - - return 0; -} - -static int cb_nbio_default(void *data, size_t len) -{ - nbio_handle_t *nbio = (nbio_handle_t*)data; - - if (!data) - return -1; - - (void)len; - - nbio->is_finished = true; - - return 0; -} - -static int cb_nbio_generic_rpng(nbio_handle_t *nbio, size_t *len) -{ - void *ptr = NULL; - - if (!nbio->image.handle) - { - nbio->image.cb = NULL; - return -1; - } - - ptr = nbio_get_ptr(nbio->handle, len); - - if (!ptr) - { - rpng_nbio_load_image_free(nbio->image.handle); - nbio->image.handle = NULL; - nbio->image.cb = NULL; - - return -1; - } - - rpng_set_buf_ptr(nbio->image.handle, (uint8_t*)ptr); - nbio->image.pos_increment = (*len / 2) ? (*len / 2) : 1; - nbio->image.processing_pos_increment = (*len / 4) ? (*len / 4) : 1; - - if (!rpng_nbio_load_image_argb_start(nbio->image.handle)) - { - rpng_nbio_load_image_free(nbio->image.handle); - return -1; - } - - nbio->image.is_blocking = false; - nbio->image.is_finished = false; - nbio->is_finished = true; - - return 0; -} - -static int cb_nbio_image_menu_wallpaper_rpng(void *data, size_t len) -{ - nbio_handle_t *nbio = (nbio_handle_t*)data; - - if (!nbio || !data) - return -1; - - nbio->image.handle = rpng_alloc(); - nbio->image.cb = &cb_image_menu_wallpaper_rpng; - - return cb_nbio_generic_rpng(nbio, &len); -} - -static int cb_nbio_image_menu_thumbnail_rpng(void *data, size_t len) -{ - nbio_handle_t *nbio = (nbio_handle_t*)data; - - if (!nbio || !data) - return -1; - - nbio->image.handle = rpng_alloc(); - nbio->image.cb = &cb_image_menu_thumbnail; - - return cb_nbio_generic_rpng(nbio, &len); -} -#endif -#endif - -bool rarch_task_push_image_load(const char *fullpath, - const char *type, retro_task_callback_t cb, void *user_data) -{ -#if defined(HAVE_RPNG) && defined(HAVE_MENU) - nbio_handle_t *nbio = NULL; - retro_task_t *t = NULL; - uint32_t cb_type_hash = 0; - struct nbio_t* handle = NULL; - - cb_type_hash = djb2_calculate(type); - - handle = nbio_open(fullpath, NBIO_READ); - - if (!handle) - { - RARCH_ERR("[image load] Failed to open '%s': %s.\n", - fullpath, strerror(errno)); - return false; - } - - nbio = (nbio_handle_t*)calloc(1, sizeof(*nbio)); - - if (!nbio) - return false; - - nbio->handle = handle; - nbio->is_finished = false; - nbio->cb = &cb_nbio_default; - nbio->status = NBIO_STATUS_TRANSFER; - nbio->image.status = NBIO_IMAGE_STATUS_TRANSFER; - - if (strstr(fullpath, ".png")) - { -#ifdef HAVE_RPNG - if (cb_type_hash == CB_MENU_WALLPAPER) - nbio->cb = &cb_nbio_image_menu_wallpaper_rpng; - else if (cb_type_hash == CB_MENU_THUMBNAIL) - nbio->cb = &cb_nbio_image_menu_thumbnail_rpng; -#endif - } - else if (strstr(fullpath, ".jpeg") || strstr(fullpath, ".jpg")) - { - /* TODO/FIXME */ - } - - nbio_begin_read(handle); - - t = (retro_task_t*)calloc(1, sizeof(*t)); - - if (!t) - { - free(nbio); - return false; - } - - t->state = nbio; - t->handler = rarch_task_file_load_handler; - t->callback = cb; - t->user_data = user_data; - - task_queue_ctl(TASK_QUEUE_CTL_PUSH, t); -#endif - return true; -} - -/* Guarded for RPNG/menu use but good for generic reuse */ -#if defined(HAVE_RPNG) && defined(HAVE_MENU) static int rarch_main_data_nbio_iterate_transfer(nbio_handle_t *nbio) { size_t i; @@ -420,10 +62,9 @@ static int rarch_main_data_nbio_iterate_parse(nbio_handle_t *nbio) return 0; } -static void rarch_task_file_load_handler(retro_task_t *task) +void rarch_task_file_load_handler(retro_task_t *task) { nbio_handle_t *nbio = (nbio_handle_t*)task->state; - nbio_image_handle_t *image = nbio ? &nbio->image : NULL; switch (nbio->status) { @@ -443,43 +84,8 @@ static void rarch_task_file_load_handler(retro_task_t *task) if (nbio->image.handle) { - switch (image->status) - { - case NBIO_IMAGE_STATUS_PROCESS_TRANSFER: - if (rarch_main_data_image_iterate_process_transfer(nbio) == -1) - image->status = NBIO_IMAGE_STATUS_PROCESS_TRANSFER_PARSE; - break; - case NBIO_IMAGE_STATUS_TRANSFER_PARSE: - rarch_main_data_image_iterate_transfer_parse(nbio); - if (image->is_blocking_on_processing) - image->status = NBIO_IMAGE_STATUS_PROCESS_TRANSFER; - break; - case NBIO_IMAGE_STATUS_TRANSFER: - if (!image->is_blocking) - if (rarch_main_data_image_iterate_transfer(nbio) == -1) - image->status = NBIO_IMAGE_STATUS_TRANSFER_PARSE; - break; - case NBIO_IMAGE_STATUS_PROCESS_TRANSFER_PARSE: - rarch_main_data_image_iterate_process_transfer_parse(nbio); - if (!image->is_finished) - break; - case NBIO_IMAGE_STATUS_TRANSFER_PARSE_FREE: - case NBIO_IMAGE_STATUS_POLL: - default: - break; - } - - if ( nbio->is_finished - && nbio->image.is_finished - && !task->cancelled) - { - task->task_data = malloc(sizeof(nbio->image.ti)); - - if (task->task_data) - memcpy(task->task_data, &nbio->image.ti, sizeof(nbio->image.ti)); - + if (!rarch_task_image_load_handler(task)) goto task_finished; - } } else if (nbio->is_finished) @@ -497,14 +103,8 @@ static void rarch_task_file_load_handler(retro_task_t *task) task_finished: task->finished = true; - if (image->handle) - { - /* TODO/FIXME - add JPEG equivalents as well */ - rpng_nbio_load_image_free(image->handle); - - image->handle = NULL; - image->frame_count = 0; - } + if (nbio->image.handle != NULL) + rarch_task_image_load_free(task); nbio_free(nbio->handle); nbio->handle = NULL; @@ -512,4 +112,3 @@ task_finished: nbio->frame_count = 0; free(nbio); } -#endif diff --git a/tasks/task_image.c b/tasks/task_image.c new file mode 100644 index 0000000000..3b2eb8ce98 --- /dev/null +++ b/tasks/task_image.c @@ -0,0 +1,403 @@ +/* RetroArch - A frontend for libretro. + * 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. + * + * 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 +#include + +#include +#include +#include +#include +#include +#include +#include +#ifdef HAVE_RPNG +#include +#endif + +#ifdef HAVE_MENU +#include "../menu/menu_driver.h" +#endif + +#include "tasks_internal.h" +#include "../verbosity.h" + +enum nbio_image_status_enum +{ + NBIO_IMAGE_STATUS_POLL = 0, + NBIO_IMAGE_STATUS_TRANSFER, + NBIO_IMAGE_STATUS_TRANSFER_PARSE, + NBIO_IMAGE_STATUS_PROCESS_TRANSFER, + NBIO_IMAGE_STATUS_PROCESS_TRANSFER_PARSE, + NBIO_IMAGE_STATUS_TRANSFER_PARSE_FREE +}; + +static int cb_image_menu_upload_generic(void *data, size_t len) +{ + nbio_handle_t *nbio = (nbio_handle_t*)data; + unsigned r_shift, g_shift, b_shift, a_shift; + + if (!nbio) + return -1; + + if (nbio->image.processing_final_state == IMAGE_PROCESS_ERROR || + nbio->image.processing_final_state == IMAGE_PROCESS_ERROR_END) + return -1; + + video_texture_image_set_color_shifts(&r_shift, &g_shift, &b_shift, + &a_shift); + + video_texture_image_color_convert(r_shift, g_shift, b_shift, + a_shift, &nbio->image.ti); + + nbio->image.is_blocking_on_processing = false; + nbio->image.is_blocking = true; + nbio->image.is_finished = true; + nbio->is_finished = true; + + return 0; +} + +static int rarch_main_data_image_iterate_process_transfer_parse( + nbio_handle_t *nbio) +{ + if (nbio->image.handle && nbio->image.cb) + { + size_t len = 0; + nbio->image.cb(nbio, len); + } + + return 0; +} + +static int rarch_main_data_image_iterate_transfer_parse(nbio_handle_t *nbio) +{ + if (nbio->image.handle && nbio->image.cb) + { + size_t len = 0; + nbio->image.cb(nbio, len); + } + + return 0; +} + +static int cb_nbio_default(void *data, size_t len) +{ + nbio_handle_t *nbio = (nbio_handle_t*)data; + + if (!data) + return -1; + + (void)len; + + nbio->is_finished = true; + + return 0; +} + +#ifdef HAVE_RPNG +static int cb_image_menu_generic_rpng(nbio_handle_t *nbio) +{ + unsigned width = 0, height = 0; + int retval; + if (!nbio) + return -1; + + if (!rpng_is_valid(nbio->image.handle)) + return -1; + + retval = rpng_nbio_load_image_argb_process(nbio->image.handle, + &nbio->image.ti.pixels, &width, &height); + + nbio->image.ti.width = width; + nbio->image.ti.height = height; + + if (retval == IMAGE_PROCESS_ERROR) + return -1; + if (retval == IMAGE_PROCESS_ERROR_END) + return -1; + + nbio->image.is_blocking_on_processing = true; + nbio->image.is_finished = false; + + return 0; +} + +static int cb_image_menu_wallpaper_rpng(void *data, size_t len) +{ + nbio_handle_t *nbio = (nbio_handle_t*)data; + + if (cb_image_menu_generic_rpng(nbio) != 0) + return -1; + + nbio->image.cb = &cb_image_menu_upload_generic; + + return 0; +} + +static int cb_image_menu_thumbnail(void *data, size_t len) +{ + nbio_handle_t *nbio = (nbio_handle_t*)data; + + if (cb_image_menu_generic_rpng(nbio) != 0) + return -1; + + nbio->image.cb = &cb_image_menu_upload_generic; + + return 0; +} + +static int rarch_main_data_image_iterate_transfer(nbio_handle_t *nbio) +{ + unsigned i; + + if (!nbio) + return -1; + + if (nbio->image.is_finished) + return 0; + + for (i = 0; i < nbio->image.pos_increment; i++) + { + /* TODO/FIXME - add JPEG equivalents as well */ + if (!rpng_nbio_load_image_argb_iterate(nbio->image.handle)) + goto error; + } + + nbio->image.frame_count++; + return 0; + +error: + return -1; +} + +static int rarch_main_data_image_iterate_process_transfer(nbio_handle_t *nbio) +{ + unsigned i, width = 0, height = 0; + int retval = 0; + + if (!nbio) + return -1; + + for (i = 0; i < nbio->image.processing_pos_increment; i++) + { + /* TODO/FIXME -add JPEG equivalents as well */ + retval = rpng_nbio_load_image_argb_process(nbio->image.handle, + &nbio->image.ti.pixels, &width, &height); + + nbio->image.ti.width = width; + nbio->image.ti.height = height; + + if (retval != IMAGE_PROCESS_NEXT) + break; + } + + if (retval == IMAGE_PROCESS_NEXT) + return 0; + + nbio->image.processing_final_state = retval; + return -1; +} + +static int cb_nbio_generic_rpng(nbio_handle_t *nbio, size_t *len) +{ + void *ptr = NULL; + + if (!nbio->image.handle) + { + nbio->image.cb = NULL; + return -1; + } + + ptr = nbio_get_ptr(nbio->handle, len); + + if (!ptr) + { + rpng_nbio_load_image_free(nbio->image.handle); + nbio->image.handle = NULL; + nbio->image.cb = NULL; + + return -1; + } + + rpng_set_buf_ptr(nbio->image.handle, (uint8_t*)ptr); + nbio->image.pos_increment = (*len / 2) ? (*len / 2) : 1; + nbio->image.processing_pos_increment = (*len / 4) ? (*len / 4) : 1; + + if (!rpng_nbio_load_image_argb_start(nbio->image.handle)) + { + rpng_nbio_load_image_free(nbio->image.handle); + return -1; + } + + nbio->image.is_blocking = false; + nbio->image.is_finished = false; + nbio->is_finished = true; + + return 0; +} + +static int cb_nbio_image_menu_wallpaper_rpng(void *data, size_t len) +{ + nbio_handle_t *nbio = (nbio_handle_t*)data; + + if (!nbio || !data) + return -1; + + nbio->image.handle = rpng_alloc(); + nbio->image.cb = &cb_image_menu_wallpaper_rpng; + + return cb_nbio_generic_rpng(nbio, &len); +} + +static int cb_nbio_image_menu_thumbnail_rpng(void *data, size_t len) +{ + nbio_handle_t *nbio = (nbio_handle_t*)data; + + if (!nbio || !data) + return -1; + + nbio->image.handle = rpng_alloc(); + nbio->image.cb = &cb_image_menu_thumbnail; + + return cb_nbio_generic_rpng(nbio, &len); +} +#endif + +bool rarch_task_image_load_handler(retro_task_t *task) +{ + nbio_handle_t *nbio = (nbio_handle_t*)task->state; + nbio_image_handle_t *image = nbio ? &nbio->image : NULL; + + switch (image->status) + { + case NBIO_IMAGE_STATUS_PROCESS_TRANSFER: + if (rarch_main_data_image_iterate_process_transfer(nbio) == -1) + image->status = NBIO_IMAGE_STATUS_PROCESS_TRANSFER_PARSE; + break; + case NBIO_IMAGE_STATUS_TRANSFER_PARSE: + rarch_main_data_image_iterate_transfer_parse(nbio); + if (image->is_blocking_on_processing) + image->status = NBIO_IMAGE_STATUS_PROCESS_TRANSFER; + break; + case NBIO_IMAGE_STATUS_TRANSFER: + if (!image->is_blocking) + if (rarch_main_data_image_iterate_transfer(nbio) == -1) + image->status = NBIO_IMAGE_STATUS_TRANSFER_PARSE; + break; + case NBIO_IMAGE_STATUS_PROCESS_TRANSFER_PARSE: + rarch_main_data_image_iterate_process_transfer_parse(nbio); + if (!image->is_finished) + break; + case NBIO_IMAGE_STATUS_TRANSFER_PARSE_FREE: + case NBIO_IMAGE_STATUS_POLL: + default: + break; + } + + if ( nbio->is_finished + && nbio->image.is_finished + && !task->cancelled) + { + task->task_data = malloc(sizeof(nbio->image.ti)); + + if (task->task_data) + memcpy(task->task_data, &nbio->image.ti, sizeof(nbio->image.ti)); + + return false; + } + + return true; +} + +bool rarch_task_push_image_load(const char *fullpath, + const char *type, retro_task_callback_t cb, void *user_data) +{ +#if defined(HAVE_RPNG) && defined(HAVE_MENU) + nbio_handle_t *nbio = NULL; + retro_task_t *t = NULL; + uint32_t cb_type_hash = 0; + struct nbio_t* handle = NULL; + + cb_type_hash = djb2_calculate(type); + + handle = nbio_open(fullpath, NBIO_READ); + + if (!handle) + { + RARCH_ERR("[image load] Failed to open '%s': %s.\n", + fullpath, strerror(errno)); + return false; + } + + nbio = (nbio_handle_t*)calloc(1, sizeof(*nbio)); + + if (!nbio) + return false; + + nbio->handle = handle; + nbio->is_finished = false; + nbio->cb = &cb_nbio_default; + nbio->status = NBIO_STATUS_TRANSFER; + nbio->image.status = NBIO_IMAGE_STATUS_TRANSFER; + + if (strstr(fullpath, ".png")) + { +#ifdef HAVE_RPNG + if (cb_type_hash == CB_MENU_WALLPAPER) + nbio->cb = &cb_nbio_image_menu_wallpaper_rpng; + else if (cb_type_hash == CB_MENU_THUMBNAIL) + nbio->cb = &cb_nbio_image_menu_thumbnail_rpng; +#endif + } + else if (strstr(fullpath, ".jpeg") || strstr(fullpath, ".jpg")) + { + /* TODO/FIXME */ + } + + nbio_begin_read(handle); + + t = (retro_task_t*)calloc(1, sizeof(*t)); + + if (!t) + { + free(nbio); + return false; + } + + t->state = nbio; + t->handler = rarch_task_file_load_handler; + t->callback = cb; + t->user_data = user_data; + + task_queue_ctl(TASK_QUEUE_CTL_PUSH, t); +#endif + return true; +} + +void rarch_task_image_load_free(retro_task_t *task) +{ + nbio_handle_t *nbio = (nbio_handle_t*)task->state; + nbio_image_handle_t *image = nbio ? &nbio->image : NULL; + +#ifdef HAVE_RPNG + /* TODO/FIXME - add JPEG equivalents as well */ + rpng_nbio_load_image_free(image->handle); +#endif + + image->handle = NULL; + image->frame_count = 0; +} diff --git a/tasks/tasks_internal.h b/tasks/tasks_internal.h index 44562f2bad..897ce2fc2f 100644 --- a/tasks/tasks_internal.h +++ b/tasks/tasks_internal.h @@ -19,6 +19,7 @@ #include #include +#include #include #include "../core_type.h" @@ -28,6 +29,17 @@ extern "C" { #endif +#define CB_MENU_WALLPAPER 0xb476e505U +#define CB_MENU_THUMBNAIL 0x82f93a21U + +enum nbio_status_enum +{ + NBIO_STATUS_POLL = 0, + NBIO_STATUS_TRANSFER, + NBIO_STATUS_TRANSFER_PARSE, + NBIO_STATUS_TRANSFER_PARSE_FREE +}; + #ifdef HAVE_NETWORKING typedef struct { char *data; @@ -40,6 +52,33 @@ typedef struct http_transfer_info int progress; } http_transfer_info_t; +typedef struct nbio_image_handle +{ + struct texture_image ti; + bool is_blocking; + bool is_blocking_on_processing; + bool is_finished; + transfer_cb_t cb; + void *handle; + unsigned processing_pos_increment; + unsigned pos_increment; + uint64_t frame_count; + int processing_final_state; + unsigned status; +} nbio_image_handle_t; + +typedef struct nbio_handle +{ + nbio_image_handle_t image; + bool is_finished; + transfer_cb_t cb; + struct nbio_t *handle; + unsigned pos_increment; + uint64_t frame_count; + msg_queue_t *msg_queue; + unsigned status; +} nbio_handle_t; + void *rarch_task_push_http_transfer(const char *url, const char *type, retro_task_callback_t cb, void *userdata); @@ -71,6 +110,8 @@ int detect_psp_game(const char *track_path, char *game_id); bool rarch_task_check_decompress(const char *source_file); +bool rarch_task_image_load_handler(retro_task_t *task); + bool rarch_task_push_decompress( const char *source_file, const char *target_dir, @@ -88,6 +129,10 @@ bool rarch_task_push_content_load_default( retro_task_callback_t cb, void *user_data); +void rarch_task_image_load_free(retro_task_t *task); + +void rarch_task_file_load_handler(retro_task_t *task);; + #ifdef __cplusplus } #endif From 55c505225398a6d9176a7f51b6dc5c4f3ef2bfa5 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 May 2016 07:55:31 +0200 Subject: [PATCH 377/498] Cleanups --- tasks/task_image.c | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/tasks/task_image.c b/tasks/task_image.c index 3b2eb8ce98..cbd88e2bc4 100644 --- a/tasks/task_image.c +++ b/tasks/task_image.c @@ -35,14 +35,14 @@ #include "tasks_internal.h" #include "../verbosity.h" -enum nbio_image_status_enum +enum image_status_enum { - NBIO_IMAGE_STATUS_POLL = 0, - NBIO_IMAGE_STATUS_TRANSFER, - NBIO_IMAGE_STATUS_TRANSFER_PARSE, - NBIO_IMAGE_STATUS_PROCESS_TRANSFER, - NBIO_IMAGE_STATUS_PROCESS_TRANSFER_PARSE, - NBIO_IMAGE_STATUS_TRANSFER_PARSE_FREE + IMAGE_STATUS_POLL = 0, + IMAGE_STATUS_TRANSFER, + IMAGE_STATUS_TRANSFER_PARSE, + IMAGE_STATUS_PROCESS_TRANSFER, + IMAGE_STATUS_PROCESS_TRANSFER_PARSE, + IMAGE_STATUS_TRANSFER_PARSE_FREE }; static int cb_image_menu_upload_generic(void *data, size_t len) @@ -284,26 +284,26 @@ bool rarch_task_image_load_handler(retro_task_t *task) switch (image->status) { - case NBIO_IMAGE_STATUS_PROCESS_TRANSFER: + case IMAGE_STATUS_PROCESS_TRANSFER: if (rarch_main_data_image_iterate_process_transfer(nbio) == -1) - image->status = NBIO_IMAGE_STATUS_PROCESS_TRANSFER_PARSE; + image->status = IMAGE_STATUS_PROCESS_TRANSFER_PARSE; break; - case NBIO_IMAGE_STATUS_TRANSFER_PARSE: + case IMAGE_STATUS_TRANSFER_PARSE: rarch_main_data_image_iterate_transfer_parse(nbio); if (image->is_blocking_on_processing) - image->status = NBIO_IMAGE_STATUS_PROCESS_TRANSFER; + image->status = IMAGE_STATUS_PROCESS_TRANSFER; break; - case NBIO_IMAGE_STATUS_TRANSFER: + case IMAGE_STATUS_TRANSFER: if (!image->is_blocking) if (rarch_main_data_image_iterate_transfer(nbio) == -1) - image->status = NBIO_IMAGE_STATUS_TRANSFER_PARSE; + image->status = IMAGE_STATUS_TRANSFER_PARSE; break; - case NBIO_IMAGE_STATUS_PROCESS_TRANSFER_PARSE: + case IMAGE_STATUS_PROCESS_TRANSFER_PARSE: rarch_main_data_image_iterate_process_transfer_parse(nbio); if (!image->is_finished) break; - case NBIO_IMAGE_STATUS_TRANSFER_PARSE_FREE: - case NBIO_IMAGE_STATUS_POLL: + case IMAGE_STATUS_TRANSFER_PARSE_FREE: + case IMAGE_STATUS_POLL: default: break; } @@ -352,7 +352,7 @@ bool rarch_task_push_image_load(const char *fullpath, nbio->is_finished = false; nbio->cb = &cb_nbio_default; nbio->status = NBIO_STATUS_TRANSFER; - nbio->image.status = NBIO_IMAGE_STATUS_TRANSFER; + nbio->image.status = IMAGE_STATUS_TRANSFER; if (strstr(fullpath, ".png")) { From dc0616d6780c282884c33a691c5abb3e879eeecb Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 May 2016 08:02:42 +0200 Subject: [PATCH 378/498] CXX_BUILD fixes --- tasks/task_image.c | 35 +++++++++++++++++++++-------------- 1 file changed, 21 insertions(+), 14 deletions(-) diff --git a/tasks/task_image.c b/tasks/task_image.c index cbd88e2bc4..ec9583f15a 100644 --- a/tasks/task_image.c +++ b/tasks/task_image.c @@ -116,19 +116,24 @@ static int cb_image_menu_generic_rpng(nbio_handle_t *nbio) if (!nbio) return -1; - if (!rpng_is_valid(nbio->image.handle)) + if (!rpng_is_valid((rpng_t*)nbio->image.handle)) return -1; - retval = rpng_nbio_load_image_argb_process(nbio->image.handle, + retval = rpng_nbio_load_image_argb_process( + (rpng_t*)nbio->image.handle, &nbio->image.ti.pixels, &width, &height); nbio->image.ti.width = width; nbio->image.ti.height = height; - if (retval == IMAGE_PROCESS_ERROR) - return -1; - if (retval == IMAGE_PROCESS_ERROR_END) - return -1; + switch (retval) + { + case IMAGE_PROCESS_ERROR: + case IMAGE_PROCESS_ERROR_END: + return -1; + default: + break; + } nbio->image.is_blocking_on_processing = true; nbio->image.is_finished = false; @@ -173,7 +178,7 @@ static int rarch_main_data_image_iterate_transfer(nbio_handle_t *nbio) for (i = 0; i < nbio->image.pos_increment; i++) { /* TODO/FIXME - add JPEG equivalents as well */ - if (!rpng_nbio_load_image_argb_iterate(nbio->image.handle)) + if (!rpng_nbio_load_image_argb_iterate((rpng_t*)nbio->image.handle)) goto error; } @@ -195,8 +200,10 @@ static int rarch_main_data_image_iterate_process_transfer(nbio_handle_t *nbio) for (i = 0; i < nbio->image.processing_pos_increment; i++) { /* TODO/FIXME -add JPEG equivalents as well */ - retval = rpng_nbio_load_image_argb_process(nbio->image.handle, - &nbio->image.ti.pixels, &width, &height); + retval = rpng_nbio_load_image_argb_process( + (rpng_t*)nbio->image.handle, + &nbio->image.ti.pixels, + &width, &height); nbio->image.ti.width = width; nbio->image.ti.height = height; @@ -226,20 +233,20 @@ static int cb_nbio_generic_rpng(nbio_handle_t *nbio, size_t *len) if (!ptr) { - rpng_nbio_load_image_free(nbio->image.handle); + rpng_nbio_load_image_free((rpng_t*)nbio->image.handle); nbio->image.handle = NULL; nbio->image.cb = NULL; return -1; } - rpng_set_buf_ptr(nbio->image.handle, (uint8_t*)ptr); + rpng_set_buf_ptr((rpng_t*)nbio->image.handle, (uint8_t*)ptr); nbio->image.pos_increment = (*len / 2) ? (*len / 2) : 1; nbio->image.processing_pos_increment = (*len / 4) ? (*len / 4) : 1; - if (!rpng_nbio_load_image_argb_start(nbio->image.handle)) + if (!rpng_nbio_load_image_argb_start((rpng_t*)nbio->image.handle)) { - rpng_nbio_load_image_free(nbio->image.handle); + rpng_nbio_load_image_free((rpng_t*)nbio->image.handle); return -1; } @@ -395,7 +402,7 @@ void rarch_task_image_load_free(retro_task_t *task) #ifdef HAVE_RPNG /* TODO/FIXME - add JPEG equivalents as well */ - rpng_nbio_load_image_free(image->handle); + rpng_nbio_load_image_free((rpng_t*)image->handle); #endif image->handle = NULL; From d160ed322efc422dc329fa8ec43d4db32a52f532 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 May 2016 08:09:12 +0200 Subject: [PATCH 379/498] (task_image.c) Cleanup --- tasks/task_image.c | 48 +++++++++++++++++++++++----------------------- 1 file changed, 24 insertions(+), 24 deletions(-) diff --git a/tasks/task_image.c b/tasks/task_image.c index ec9583f15a..c13ccda678 100644 --- a/tasks/task_image.c +++ b/tasks/task_image.c @@ -219,42 +219,48 @@ static int rarch_main_data_image_iterate_process_transfer(nbio_handle_t *nbio) return -1; } +static void rarch_task_image_load_free_internal(nbio_handle_t *nbio) +{ + nbio_image_handle_t *image = nbio ? &nbio->image : NULL; + +#ifdef HAVE_RPNG + /* TODO/FIXME - add JPEG equivalents as well */ + rpng_nbio_load_image_free((rpng_t*)image->handle); +#endif + + image->handle = NULL; + image->cb = NULL; + image->frame_count = 0; +} + static int cb_nbio_generic_rpng(nbio_handle_t *nbio, size_t *len) { void *ptr = NULL; if (!nbio->image.handle) - { - nbio->image.cb = NULL; - return -1; - } + goto error; ptr = nbio_get_ptr(nbio->handle, len); if (!ptr) - { - rpng_nbio_load_image_free((rpng_t*)nbio->image.handle); - nbio->image.handle = NULL; - nbio->image.cb = NULL; - - return -1; - } + goto error; rpng_set_buf_ptr((rpng_t*)nbio->image.handle, (uint8_t*)ptr); nbio->image.pos_increment = (*len / 2) ? (*len / 2) : 1; nbio->image.processing_pos_increment = (*len / 4) ? (*len / 4) : 1; if (!rpng_nbio_load_image_argb_start((rpng_t*)nbio->image.handle)) - { - rpng_nbio_load_image_free((rpng_t*)nbio->image.handle); - return -1; - } + goto error; nbio->image.is_blocking = false; nbio->image.is_finished = false; nbio->is_finished = true; return 0; + +error: + rarch_task_image_load_free_internal(nbio); + return -1; } static int cb_nbio_image_menu_wallpaper_rpng(void *data, size_t len) @@ -395,16 +401,10 @@ bool rarch_task_push_image_load(const char *fullpath, return true; } + void rarch_task_image_load_free(retro_task_t *task) { nbio_handle_t *nbio = (nbio_handle_t*)task->state; - nbio_image_handle_t *image = nbio ? &nbio->image : NULL; - -#ifdef HAVE_RPNG - /* TODO/FIXME - add JPEG equivalents as well */ - rpng_nbio_load_image_free((rpng_t*)image->handle); -#endif - - image->handle = NULL; - image->frame_count = 0; + rarch_task_image_load_free_internal(nbio); } + From 4e04588d2dcf311c6184c81f4f7072eb4ec7e3e3 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 May 2016 08:23:49 +0200 Subject: [PATCH 380/498] Create rarch_main_data_image_iterate --- tasks/task_image.c | 44 +++++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 19 deletions(-) diff --git a/tasks/task_image.c b/tasks/task_image.c index c13ccda678..9ca18a88ff 100644 --- a/tasks/task_image.c +++ b/tasks/task_image.c @@ -108,25 +108,38 @@ static int cb_nbio_default(void *data, size_t len) return 0; } +static int rarch_main_data_image_iterate( + nbio_handle_t *nbio, + unsigned *width, + unsigned *height, + int *retval) +{ +#ifdef HAVE_RPNG + *retval = rpng_nbio_load_image_argb_process( + (rpng_t*)nbio->image.handle, + &nbio->image.ti.pixels, + width, height); +#endif + + nbio->image.ti.width = *width; + nbio->image.ti.height = *height; + + return *retval; +} + #ifdef HAVE_RPNG static int cb_image_menu_generic_rpng(nbio_handle_t *nbio) { + int retval = 0; unsigned width = 0, height = 0; - int retval; if (!nbio) return -1; if (!rpng_is_valid((rpng_t*)nbio->image.handle)) return -1; - retval = rpng_nbio_load_image_argb_process( - (rpng_t*)nbio->image.handle, - &nbio->image.ti.pixels, &width, &height); - - nbio->image.ti.width = width; - nbio->image.ti.height = height; - - switch (retval) + switch (rarch_main_data_image_iterate(nbio, + &width, &height, &retval)) { case IMAGE_PROCESS_ERROR: case IMAGE_PROCESS_ERROR_END: @@ -189,6 +202,7 @@ error: return -1; } + static int rarch_main_data_image_iterate_process_transfer(nbio_handle_t *nbio) { unsigned i, width = 0, height = 0; @@ -199,16 +213,8 @@ static int rarch_main_data_image_iterate_process_transfer(nbio_handle_t *nbio) for (i = 0; i < nbio->image.processing_pos_increment; i++) { - /* TODO/FIXME -add JPEG equivalents as well */ - retval = rpng_nbio_load_image_argb_process( - (rpng_t*)nbio->image.handle, - &nbio->image.ti.pixels, - &width, &height); - - nbio->image.ti.width = width; - nbio->image.ti.height = height; - - if (retval != IMAGE_PROCESS_NEXT) + if (rarch_main_data_image_iterate(nbio, + &width, &height, &retval) != IMAGE_PROCESS_NEXT) break; } From 58ae02207fb3dd6b80f651827e8e306e7229c996 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 May 2016 08:25:18 +0200 Subject: [PATCH 381/498] Move rpng_is_valid to function --- tasks/task_image.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tasks/task_image.c b/tasks/task_image.c index 9ca18a88ff..d179a98cde 100644 --- a/tasks/task_image.c +++ b/tasks/task_image.c @@ -115,6 +115,9 @@ static int rarch_main_data_image_iterate( int *retval) { #ifdef HAVE_RPNG + if (!rpng_is_valid((rpng_t*)nbio->image.handle)) + return IMAGE_PROCESS_ERROR; + *retval = rpng_nbio_load_image_argb_process( (rpng_t*)nbio->image.handle, &nbio->image.ti.pixels, @@ -135,9 +138,6 @@ static int cb_image_menu_generic_rpng(nbio_handle_t *nbio) if (!nbio) return -1; - if (!rpng_is_valid((rpng_t*)nbio->image.handle)) - return -1; - switch (rarch_main_data_image_iterate(nbio, &width, &height, &retval)) { From a4ccfc4d9627d292c93ef10b93b8ec16fe778296 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 May 2016 08:28:48 +0200 Subject: [PATCH 382/498] Cleanups --- tasks/task_image.c | 37 +++++++++++++++++-------------------- 1 file changed, 17 insertions(+), 20 deletions(-) diff --git a/tasks/task_image.c b/tasks/task_image.c index d179a98cde..8ee986b655 100644 --- a/tasks/task_image.c +++ b/tasks/task_image.c @@ -345,27 +345,18 @@ bool rarch_task_image_load_handler(retro_task_t *task) bool rarch_task_push_image_load(const char *fullpath, const char *type, retro_task_callback_t cb, void *user_data) { -#if defined(HAVE_RPNG) && defined(HAVE_MENU) - nbio_handle_t *nbio = NULL; - retro_task_t *t = NULL; - uint32_t cb_type_hash = 0; - struct nbio_t* handle = NULL; - - cb_type_hash = djb2_calculate(type); - - handle = nbio_open(fullpath, NBIO_READ); + nbio_handle_t *nbio = NULL; + retro_task_t *t = NULL; + uint32_t cb_type_hash = djb2_calculate(type); + struct nbio_t *handle = nbio_open(fullpath, NBIO_READ); if (!handle) - { - RARCH_ERR("[image load] Failed to open '%s': %s.\n", - fullpath, strerror(errno)); - return false; - } + goto error; nbio = (nbio_handle_t*)calloc(1, sizeof(*nbio)); if (!nbio) - return false; + goto error; nbio->handle = handle; nbio->is_finished = false; @@ -392,10 +383,7 @@ bool rarch_task_push_image_load(const char *fullpath, t = (retro_task_t*)calloc(1, sizeof(*t)); if (!t) - { - free(nbio); - return false; - } + goto error; t->state = nbio; t->handler = rarch_task_file_load_handler; @@ -403,8 +391,17 @@ bool rarch_task_push_image_load(const char *fullpath, t->user_data = user_data; task_queue_ctl(TASK_QUEUE_CTL_PUSH, t); -#endif + return true; + +error: + if (t) + free(t); + if (nbio) + free(nbio); + RARCH_ERR("[image load] Failed to open '%s': %s.\n", + fullpath, strerror(errno)); + return false; } From 4a49c197c9fb414e640c8f2d6c14768727d42656 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 May 2016 08:31:07 +0200 Subject: [PATCH 383/498] (task_image.c) Rename function --- tasks/task_image.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tasks/task_image.c b/tasks/task_image.c index 8ee986b655..7ae06bfa25 100644 --- a/tasks/task_image.c +++ b/tasks/task_image.c @@ -108,7 +108,7 @@ static int cb_nbio_default(void *data, size_t len) return 0; } -static int rarch_main_data_image_iterate( +static int rarch_main_data_image_process( nbio_handle_t *nbio, unsigned *width, unsigned *height, @@ -138,7 +138,7 @@ static int cb_image_menu_generic_rpng(nbio_handle_t *nbio) if (!nbio) return -1; - switch (rarch_main_data_image_iterate(nbio, + switch (rarch_main_data_image_process(nbio, &width, &height, &retval)) { case IMAGE_PROCESS_ERROR: @@ -213,7 +213,7 @@ static int rarch_main_data_image_iterate_process_transfer(nbio_handle_t *nbio) for (i = 0; i < nbio->image.processing_pos_increment; i++) { - if (rarch_main_data_image_iterate(nbio, + if (rarch_main_data_image_process(nbio, &width, &height, &retval) != IMAGE_PROCESS_NEXT) break; } @@ -404,7 +404,6 @@ error: return false; } - void rarch_task_image_load_free(retro_task_t *task) { nbio_handle_t *nbio = (nbio_handle_t*)task->state; From b79b2dca1310fbd5ce6edef8e298e64e55dd7f2b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 May 2016 08:53:14 +0200 Subject: [PATCH 384/498] Create performance_counters --- Makefile.common | 1 + audio/audio_driver.c | 2 +- audio/audio_dsp_filter.c | 1 + audio/audio_resampler_driver.c | 1 + audio/audio_thread_wrapper.c | 2 +- audio/audio_utils.c | 1 + audio/drivers/ctr_csnd_audio.c | 2 +- audio/drivers/ctr_dsp_audio.c | 2 +- camera/drivers/video4linux2.c | 2 +- cheevos.c | 2 +- command.c | 2 +- dynamic.c | 1 + gfx/common/vulkan_common.h | 1 - gfx/d3d/d3d.cpp | 2 +- gfx/d3d/render_chain_cg.cpp | 2 +- gfx/drivers/ctr_gfx.c | 2 +- gfx/drivers/gl.c | 2 +- gfx/drivers/sdl2_gfx.c | 2 +- gfx/drivers/sdl_gfx.c | 2 +- gfx/drivers/vg.c | 2 +- gfx/drivers/vulkan.c | 2 +- gfx/video_driver.c | 1 + gfx/video_filter.c | 1 + gfx/video_thread_wrapper.c | 1 + griffin/griffin.c | 1 + input/drivers/android_input.c | 2 +- managers/state_manager.c | 2 +- menu/cbs/menu_cbs_get_value.c | 2 +- menu/cbs/menu_cbs_start.c | 2 +- menu/drivers/menu_generic.c | 1 + menu/menu_animation.c | 1 + menu/menu_displaylist.c | 2 +- menu/menu_input.c | 1 + menu/menu_setting.c | 2 +- network/net_http_special.c | 1 + performance.c | 111 ------------------------- performance.h | 50 ------------ performance_counters.c | 145 +++++++++++++++++++++++++++++++++ performance_counters.h | 83 +++++++++++++++++++ 39 files changed, 262 insertions(+), 183 deletions(-) create mode 100644 performance_counters.c create mode 100644 performance_counters.h diff --git a/Makefile.common b/Makefile.common index ab4df5e620..9a55a67774 100644 --- a/Makefile.common +++ b/Makefile.common @@ -205,6 +205,7 @@ OBJ += frontend/frontend.o \ record/record_driver.o \ record/drivers/record_null.o \ performance.o \ + performance_counters.o \ verbosity.o ifneq ($(HAVE_GETOPT_LONG), 1) diff --git a/audio/audio_driver.c b/audio/audio_driver.c index 22e3e117f8..b9cd3fed4c 100644 --- a/audio/audio_driver.c +++ b/audio/audio_driver.c @@ -30,7 +30,7 @@ #include "../configuration.h" #include "../retroarch.h" #include "../runloop.h" -#include "../performance.h" +#include "../performance_counters.h" #include "../verbosity.h" #include "../list_special.h" diff --git a/audio/audio_dsp_filter.c b/audio/audio_dsp_filter.c index 6c68911dad..09a7759ae5 100644 --- a/audio/audio_dsp_filter.c +++ b/audio/audio_dsp_filter.c @@ -30,6 +30,7 @@ #include "../config_file_userdata.h" #include "../frontend/frontend_driver.h" #include "../performance.h" +#include "../performance_counters.h" #include "../dynamic.h" struct rarch_dsp_plug diff --git a/audio/audio_resampler_driver.c b/audio/audio_resampler_driver.c index 44855d962d..b4b770db5c 100644 --- a/audio/audio_resampler_driver.c +++ b/audio/audio_resampler_driver.c @@ -22,6 +22,7 @@ #include "../config_file_userdata.h" #ifdef RARCH_INTERNAL #include "../performance.h" +#include "../performance_counters.h" #endif #ifndef DONT_HAVE_STRING_LIST #include "../list_special.h" diff --git a/audio/audio_thread_wrapper.c b/audio/audio_thread_wrapper.c index 46a85f4c36..55bb2886f9 100644 --- a/audio/audio_thread_wrapper.c +++ b/audio/audio_thread_wrapper.c @@ -21,7 +21,7 @@ #include #include "audio_thread_wrapper.h" -#include "../performance.h" +#include "../performance_counters.h" #include "../verbosity.h" typedef struct audio_thread diff --git a/audio/audio_utils.c b/audio/audio_utils.c index b67a734e48..0946d57651 100644 --- a/audio/audio_utils.c +++ b/audio/audio_utils.c @@ -25,6 +25,7 @@ #ifdef RARCH_INTERNAL #include "../performance.h" +#include "../performance_counters.h" #endif /** diff --git a/audio/drivers/ctr_csnd_audio.c b/audio/drivers/ctr_csnd_audio.c index 32741dd2ed..3245876afa 100644 --- a/audio/drivers/ctr_csnd_audio.c +++ b/audio/drivers/ctr_csnd_audio.c @@ -18,7 +18,7 @@ #include "../audio_driver.h" #include "../../configuration.h" -#include "../../performance.h" +#include "../../performance_counters.h" #include "../../runloop.h" typedef struct diff --git a/audio/drivers/ctr_dsp_audio.c b/audio/drivers/ctr_dsp_audio.c index ff1ccc75b5..36ffbfc777 100644 --- a/audio/drivers/ctr_dsp_audio.c +++ b/audio/drivers/ctr_dsp_audio.c @@ -18,7 +18,7 @@ #include "../audio_driver.h" #include "../../configuration.h" -#include "../../performance.h" +#include "../../performance_counters.h" #include "../../runloop.h" #include "../../ctr/ctr_debug.h" diff --git a/camera/drivers/video4linux2.c b/camera/drivers/video4linux2.c index 684504ca4c..c5eba58f9b 100644 --- a/camera/drivers/video4linux2.c +++ b/camera/drivers/video4linux2.c @@ -41,7 +41,7 @@ #include #include "../camera_driver.h" -#include "../../performance.h" +#include "../../performance_counters.h" #include "../../verbosity.h" struct buffer diff --git a/cheevos.c b/cheevos.c index d3225bfbed..9eba3219d2 100644 --- a/cheevos.c +++ b/cheevos.c @@ -26,7 +26,7 @@ #include "libretro.h" #include "network/net_http_special.h" #include "configuration.h" -#include "performance.h" +#include "performance_counters.h" #include "msg_hash.h" #include "runloop.h" #include "core.h" diff --git a/command.c b/command.c index 36eae2360a..4259459032 100644 --- a/command.c +++ b/command.c @@ -44,7 +44,7 @@ #include "autosave.h" #include "core_info.h" #include "core_type.h" -#include "performance.h" +#include "performance_counters.h" #include "dynamic.h" #include "content.h" #include "movie.h" diff --git a/dynamic.c b/dynamic.c index cf8afb23b4..ddd52747e9 100644 --- a/dynamic.c +++ b/dynamic.c @@ -37,6 +37,7 @@ #include "location/location_driver.h" #include "record/record_driver.h" #include "core.h" +#include "performance_counters.h" #include "performance.h" #include "system.h" #include "gfx/video_context_driver.h" diff --git a/gfx/common/vulkan_common.h b/gfx/common/vulkan_common.h index 02961f8e83..6afaa53178 100644 --- a/gfx/common/vulkan_common.h +++ b/gfx/common/vulkan_common.h @@ -39,7 +39,6 @@ #include #include "../../driver.h" -#include "../../performance.h" #include "../../libretro.h" #include "../../general.h" #include "../../retroarch.h" diff --git a/gfx/d3d/d3d.cpp b/gfx/d3d/d3d.cpp index e713505ca8..0083a39401 100644 --- a/gfx/d3d/d3d.cpp +++ b/gfx/d3d/d3d.cpp @@ -47,7 +47,7 @@ #endif #include "../../core.h" -#include "../../performance.h" +#include "../../performance_counters.h" #include "../../defines/d3d_defines.h" #include "../../verbosity.h" diff --git a/gfx/d3d/render_chain_cg.cpp b/gfx/d3d/render_chain_cg.cpp index ccfdfafc1e..5d9999234c 100644 --- a/gfx/d3d/render_chain_cg.cpp +++ b/gfx/d3d/render_chain_cg.cpp @@ -30,7 +30,7 @@ #include "render_chain_driver.h" #include "../video_driver.h" #include "../../general.h" -#include "../../performance.h" +#include "../../performance_counters.h" #include "../../verbosity.h" #include "d3d.h" diff --git a/gfx/drivers/ctr_gfx.c b/gfx/drivers/ctr_gfx.c index e254216539..ead9fcbd99 100644 --- a/gfx/drivers/ctr_gfx.c +++ b/gfx/drivers/ctr_gfx.c @@ -28,7 +28,7 @@ #include "../../driver.h" #include "../../retroarch.h" -#include "../../performance.h" +#include "../../performance_counters.h" #define CTR_TOP_FRAMEBUFFER_WIDTH 400 #define CTR_TOP_FRAMEBUFFER_HEIGHT 240 diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 414a2fcdf8..f3d240fa52 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -34,7 +34,7 @@ #include "../../driver.h" #include "../../record/record_driver.h" -#include "../../performance.h" +#include "../../performance_counters.h" #include "../../libretro.h" #include "../../general.h" diff --git a/gfx/drivers/sdl2_gfx.c b/gfx/drivers/sdl2_gfx.c index 5b8dfa7dee..9c8401b8fb 100644 --- a/gfx/drivers/sdl2_gfx.c +++ b/gfx/drivers/sdl2_gfx.c @@ -25,7 +25,7 @@ #include "../../driver.h" #include "../../general.h" #include "../../retroarch.h" -#include "../../performance.h" +#include "../../performance_counters.h" #include "../../verbosity.h" #include "../video_context_driver.h" #include "../font_driver.h" diff --git a/gfx/drivers/sdl_gfx.c b/gfx/drivers/sdl_gfx.c index 50ae2b98ce..bbc58dc24f 100644 --- a/gfx/drivers/sdl_gfx.c +++ b/gfx/drivers/sdl_gfx.c @@ -25,7 +25,7 @@ #include "../../driver.h" #include "../../general.h" -#include "../../performance.h" +#include "../../performance_counters.h" #include "../video_frame.h" #include "../video_context_driver.h" diff --git a/gfx/drivers/vg.c b/gfx/drivers/vg.c index 59bc5831c1..73527ff83c 100644 --- a/gfx/drivers/vg.c +++ b/gfx/drivers/vg.c @@ -30,7 +30,7 @@ #include "../../general.h" #include "../../retroarch.h" #include "../../driver.h" -#include "../../performance.h" +#include "../../performance_counters.h" #include "../font_driver.h" #include "../../content.h" #include "../../runloop.h" diff --git a/gfx/drivers/vulkan.c b/gfx/drivers/vulkan.c index 211828a348..1147badfa2 100644 --- a/gfx/drivers/vulkan.c +++ b/gfx/drivers/vulkan.c @@ -36,7 +36,7 @@ #include "../../driver.h" #include "../../record/record_driver.h" -#include "../../performance.h" +#include "../../performance_counters.h" #include "../../libretro.h" #include "../../general.h" diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 5901e8304f..6f1bcd39dd 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -34,6 +34,7 @@ #include "../retroarch.h" #include "../runloop.h" #include "../performance.h" +#include "../performance_counters.h" #include "../list_special.h" #include "../core.h" #include "../system.h" diff --git a/gfx/video_filter.c b/gfx/video_filter.c index aa263d7a48..0f72d35560 100644 --- a/gfx/video_filter.c +++ b/gfx/video_filter.c @@ -25,6 +25,7 @@ #include "../dynamic.h" #include "../general.h" #include "../performance.h" +#include "../performance_counters.h" #include "../verbosity.h" #include "video_filter.h" #include "video_filters/softfilter.h" diff --git a/gfx/video_thread_wrapper.c b/gfx/video_thread_wrapper.c index 9cfa2ca0bd..aa03dccb43 100644 --- a/gfx/video_thread_wrapper.c +++ b/gfx/video_thread_wrapper.c @@ -24,6 +24,7 @@ #include "font_driver.h" #include "video_shader_driver.h" #include "../performance.h" +#include "../performance_counters.h" #include "../runloop.h" #include "../verbosity.h" diff --git a/griffin/griffin.c b/griffin/griffin.c index 4bd73571bf..e483a0c10c 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -63,6 +63,7 @@ ENCODINGS PERFORMANCE ============================================================ */ #include "../performance.c" +#include "../performance_counters.c" /*============================================================ COMPATIBILITY diff --git a/input/drivers/android_input.c b/input/drivers/android_input.c index d27b7b3206..6b9125923f 100644 --- a/input/drivers/android_input.c +++ b/input/drivers/android_input.c @@ -30,7 +30,7 @@ #include "../input_config.h" #include "../input_joypad_driver.h" #include "../drivers_keyboard/keyboard_event_android.h" -#include "../../performance.h" +#include "../../performance_counters.h" #include "../../general.h" #include "../../driver.h" diff --git a/managers/state_manager.c b/managers/state_manager.c index e47e8ca500..ffe31d4f19 100644 --- a/managers/state_manager.c +++ b/managers/state_manager.c @@ -31,7 +31,7 @@ #include "../movie.h" #include "../core.h" #include "../runloop.h" -#include "../performance.h" +#include "../performance_counters.h" #include "../verbosity.h" #include "../audio/audio_driver.h" diff --git a/menu/cbs/menu_cbs_get_value.c b/menu/cbs/menu_cbs_get_value.c index 6c49bcfeec..6ab52e6106 100644 --- a/menu/cbs/menu_cbs_get_value.c +++ b/menu/cbs/menu_cbs_get_value.c @@ -30,7 +30,7 @@ #include "../../managers/core_option_manager.h" #include "../../managers/cheat_manager.h" #include "../../general.h" -#include "../../performance.h" +#include "../../performance_counters.h" #include "../../system.h" #include "../../intl/intl.h" diff --git a/menu/cbs/menu_cbs_start.c b/menu/cbs/menu_cbs_start.c index ed07712099..ef0b7b4a31 100644 --- a/menu/cbs/menu_cbs_start.c +++ b/menu/cbs/menu_cbs_start.c @@ -30,7 +30,7 @@ #include "../../general.h" #include "../../retroarch.h" #include "../../system.h" -#include "../../performance.h" +#include "../../performance_counters.h" #include "../../gfx/video_shader_driver.h" diff --git a/menu/drivers/menu_generic.c b/menu/drivers/menu_generic.c index 293fba9f12..fa0e875a99 100644 --- a/menu/drivers/menu_generic.c +++ b/menu/drivers/menu_generic.c @@ -29,6 +29,7 @@ #include "../../configuration.h" #include "../../performance.h" +#include "../../performance_counters.h" #include "../../input/input_autodetect.h" #include "../../input/input_config.h" #include "../../cheevos.h" diff --git a/menu/menu_animation.c b/menu/menu_animation.c index b72d7e9c37..be5365859d 100644 --- a/menu/menu_animation.c +++ b/menu/menu_animation.c @@ -23,6 +23,7 @@ #include "menu_animation.h" #include "../configuration.h" #include "../performance.h" +#include "../performance_counters.h" #define IDEAL_DELTA_TIME (1.0 / 60.0 * 1000000.0) diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index babe720ea0..eb902a4c99 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -44,7 +44,7 @@ #include "../git_version.h" #include "../input/input_config.h" #include "../list_special.h" -#include "../performance.h" +#include "../performance_counters.h" #include "../core_info.h" #ifdef HAVE_CHEEVOS diff --git a/menu/menu_input.c b/menu/menu_input.c index a8d76940be..cfc431e7ca 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -40,6 +40,7 @@ #include "../general.h" #include "../managers/cheat_manager.h" #include "../performance.h" +#include "../performance_counters.h" #include "../core.h" #include "../input/input_joypad_driver.h" #include "../input/input_remapping.h" diff --git a/menu/menu_setting.c b/menu/menu_setting.c index ea9d339edc..d6e20db97a 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -59,7 +59,7 @@ #include "../input/input_config.h" #include "../input/input_autodetect.h" #include "../config.def.h" -#include "../performance.h" +#include "../performance_counters.h" #include "../lakka.h" #include "../tasks/tasks_internal.h" diff --git a/network/net_http_special.c b/network/net_http_special.c index 3eec1fb230..62fb7c2dc7 100644 --- a/network/net_http_special.c +++ b/network/net_http_special.c @@ -19,6 +19,7 @@ #include #include "../performance.h" +#include "../performance_counters.h" #include "net_http_special.h" int net_http_get(const char **result, size_t *size, const char *url, retro_time_t *timeout) diff --git a/performance.c b/performance.c index a48377b026..5cfe6327f0 100644 --- a/performance.c +++ b/performance.c @@ -109,90 +109,6 @@ static int clock_gettime(int clk_ik, struct timespec *t) #include "frontend/drivers/platform_linux.h" #endif -static struct retro_perf_counter *perf_counters_rarch[MAX_COUNTERS]; -static struct retro_perf_counter *perf_counters_libretro[MAX_COUNTERS]; -static unsigned perf_ptr_rarch; -static unsigned perf_ptr_libretro; - -struct retro_perf_counter **retro_get_perf_counter_rarch(void) -{ - return perf_counters_rarch; -} - -struct retro_perf_counter **retro_get_perf_counter_libretro(void) -{ - return perf_counters_libretro; -} - -unsigned retro_get_perf_count_rarch(void) -{ - return perf_ptr_rarch; -} - -unsigned retro_get_perf_count_libretro(void) -{ - return perf_ptr_libretro; -} - -void rarch_perf_register(struct retro_perf_counter *perf) -{ - if ( - !runloop_ctl(RUNLOOP_CTL_IS_PERFCNT_ENABLE, NULL) - || perf->registered - || perf_ptr_rarch >= MAX_COUNTERS - ) - return; - - perf_counters_rarch[perf_ptr_rarch++] = perf; - perf->registered = true; -} - -void retro_perf_register(struct retro_perf_counter *perf) -{ - if (perf->registered || perf_ptr_libretro >= MAX_COUNTERS) - return; - - perf_counters_libretro[perf_ptr_libretro++] = perf; - perf->registered = true; -} - -void retro_perf_clear(void) -{ - perf_ptr_libretro = 0; - memset(perf_counters_libretro, 0, sizeof(perf_counters_libretro)); -} - -static void log_counters(struct retro_perf_counter **counters, unsigned num) -{ - unsigned i; - for (i = 0; i < num; i++) - { - if (counters[i]->call_cnt) - { - RARCH_LOG(PERF_LOG_FMT, - counters[i]->ident, - (unsigned long long)counters[i]->total / - (unsigned long long)counters[i]->call_cnt, - (unsigned long long)counters[i]->call_cnt); - } - } -} - -void rarch_perf_log(void) -{ - if (!runloop_ctl(RUNLOOP_CTL_IS_PERFCNT_ENABLE, NULL)) - return; - - RARCH_LOG("[PERF]: Performance counters (RetroArch):\n"); - log_counters(perf_counters_rarch, perf_ptr_rarch); -} - -void retro_perf_log(void) -{ - RARCH_LOG("[PERF]: Performance counters (libretro):\n"); - log_counters(perf_counters_libretro, perf_ptr_libretro); -} - /** * retro_get_perf_counter: * @@ -652,30 +568,3 @@ uint64_t retro_get_cpu_features(void) return cpu; } - -int rarch_perf_init(struct retro_perf_counter *perf, const char *name) -{ - perf->ident = name; - - if (!perf->registered) - rarch_perf_register(perf); - - return 0; -} - -void retro_perf_start(struct retro_perf_counter *perf) -{ - if (!runloop_ctl(RUNLOOP_CTL_IS_PERFCNT_ENABLE, NULL) || !perf) - return; - - perf->call_cnt++; - perf->start = retro_get_perf_counter(); -} - -void retro_perf_stop(struct retro_perf_counter *perf) -{ - if (!runloop_ctl(RUNLOOP_CTL_IS_PERFCNT_ENABLE, NULL) || !perf) - return; - - perf->total += retro_get_perf_counter() - perf->start; -} diff --git a/performance.h b/performance.h index 3f941d8957..71b56a00f1 100644 --- a/performance.h +++ b/performance.h @@ -25,27 +25,6 @@ extern "C" { #endif -#ifndef MAX_COUNTERS -#define MAX_COUNTERS 64 -#endif - -struct retro_perf_counter **retro_get_perf_counter_rarch(void); - -struct retro_perf_counter **retro_get_perf_counter_libretro(void); - -unsigned retro_get_perf_count_rarch(void); - -unsigned retro_get_perf_count_libretro(void); - -/* - * retro_get_perf_counter: - * - * Gets performance counter. - * - * Returns: performance counter. - **/ -retro_perf_tick_t retro_get_perf_counter(void); - /** * retro_get_time_usec: * @@ -54,35 +33,6 @@ retro_perf_tick_t retro_get_perf_counter(void); **/ retro_time_t retro_get_time_usec(void); -void retro_perf_register(struct retro_perf_counter *perf); - -/* Same as retro_perf_register, just for libretro cores. */ -void retro_perf_register(struct retro_perf_counter *perf); - -void retro_perf_clear(void); - -void retro_perf_log(void); - -void rarch_perf_log(void); - -int rarch_perf_init(struct retro_perf_counter *perf, const char *name); - -/** - * retro_perf_start: - * @perf : pointer to performance counter - * - * Start performance counter. - **/ -void retro_perf_start(struct retro_perf_counter *perf); - -/** - * retro_perf_stop: - * @perf : pointer to performance counter - * - * Stop performance counter. - **/ -void retro_perf_stop(struct retro_perf_counter *perf); - /** * retro_get_cpu_features: * diff --git a/performance_counters.c b/performance_counters.c new file mode 100644 index 0000000000..ce8e4d248a --- /dev/null +++ b/performance_counters.c @@ -0,0 +1,145 @@ +/* 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. + * + * 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 + +#include "performance_counters.h" + +#include "general.h" +#include "compat/strl.h" +#include "verbosity.h" + +#ifdef _WIN32 +#define PERF_LOG_FMT "[PERF]: Avg (%s): %I64u ticks, %I64u runs.\n" +#else +#define PERF_LOG_FMT "[PERF]: Avg (%s): %llu ticks, %llu runs.\n" +#endif + +#if !defined(_WIN32) && !defined(RARCH_CONSOLE) +#include +#endif + +static struct retro_perf_counter *perf_counters_rarch[MAX_COUNTERS]; +static struct retro_perf_counter *perf_counters_libretro[MAX_COUNTERS]; +static unsigned perf_ptr_rarch; +static unsigned perf_ptr_libretro; + +struct retro_perf_counter **retro_get_perf_counter_rarch(void) +{ + return perf_counters_rarch; +} + +struct retro_perf_counter **retro_get_perf_counter_libretro(void) +{ + return perf_counters_libretro; +} + +unsigned retro_get_perf_count_rarch(void) +{ + return perf_ptr_rarch; +} + +unsigned retro_get_perf_count_libretro(void) +{ + return perf_ptr_libretro; +} + +void rarch_perf_register(struct retro_perf_counter *perf) +{ + if ( + !runloop_ctl(RUNLOOP_CTL_IS_PERFCNT_ENABLE, NULL) + || perf->registered + || perf_ptr_rarch >= MAX_COUNTERS + ) + return; + + perf_counters_rarch[perf_ptr_rarch++] = perf; + perf->registered = true; +} + +void retro_perf_register(struct retro_perf_counter *perf) +{ + if (perf->registered || perf_ptr_libretro >= MAX_COUNTERS) + return; + + perf_counters_libretro[perf_ptr_libretro++] = perf; + perf->registered = true; +} + +void retro_perf_clear(void) +{ + perf_ptr_libretro = 0; + memset(perf_counters_libretro, 0, sizeof(perf_counters_libretro)); +} + +static void log_counters(struct retro_perf_counter **counters, unsigned num) +{ + unsigned i; + for (i = 0; i < num; i++) + { + if (counters[i]->call_cnt) + { + RARCH_LOG(PERF_LOG_FMT, + counters[i]->ident, + (unsigned long long)counters[i]->total / + (unsigned long long)counters[i]->call_cnt, + (unsigned long long)counters[i]->call_cnt); + } + } +} + +void rarch_perf_log(void) +{ + if (!runloop_ctl(RUNLOOP_CTL_IS_PERFCNT_ENABLE, NULL)) + return; + + RARCH_LOG("[PERF]: Performance counters (RetroArch):\n"); + log_counters(perf_counters_rarch, perf_ptr_rarch); +} + +void retro_perf_log(void) +{ + RARCH_LOG("[PERF]: Performance counters (libretro):\n"); + log_counters(perf_counters_libretro, perf_ptr_libretro); +} + +int rarch_perf_init(struct retro_perf_counter *perf, const char *name) +{ + perf->ident = name; + + if (!perf->registered) + rarch_perf_register(perf); + + return 0; +} + +void retro_perf_start(struct retro_perf_counter *perf) +{ + if (!runloop_ctl(RUNLOOP_CTL_IS_PERFCNT_ENABLE, NULL) || !perf) + return; + + perf->call_cnt++; + perf->start = retro_get_perf_counter(); +} + +void retro_perf_stop(struct retro_perf_counter *perf) +{ + if (!runloop_ctl(RUNLOOP_CTL_IS_PERFCNT_ENABLE, NULL) || !perf) + return; + + perf->total += retro_get_perf_counter() - perf->start; +} diff --git a/performance_counters.h b/performance_counters.h new file mode 100644 index 0000000000..c15cc7881a --- /dev/null +++ b/performance_counters.h @@ -0,0 +1,83 @@ +/* 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. + * + * 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 _PERFORMANCE_COUNTERS_H +#define _PERFORMANCE_COUNTERS_H + +#include + +#include "libretro.h" + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef MAX_COUNTERS +#define MAX_COUNTERS 64 +#endif + +struct retro_perf_counter **retro_get_perf_counter_rarch(void); + +struct retro_perf_counter **retro_get_perf_counter_libretro(void); + +unsigned retro_get_perf_count_rarch(void); + +unsigned retro_get_perf_count_libretro(void); + +/* + * retro_get_perf_counter: + * + * Gets performance counter. + * + * Returns: performance counter. + **/ +retro_perf_tick_t retro_get_perf_counter(void); + +void retro_perf_register(struct retro_perf_counter *perf); + +/* Same as retro_perf_register, just for libretro cores. */ +void retro_perf_register(struct retro_perf_counter *perf); + +void retro_perf_clear(void); + +void retro_perf_log(void); + +void rarch_perf_log(void); + +int rarch_perf_init(struct retro_perf_counter *perf, const char *name); + +/** + * retro_perf_start: + * @perf : pointer to performance counter + * + * Start performance counter. + **/ +void retro_perf_start(struct retro_perf_counter *perf); + +/** + * retro_perf_stop: + * @perf : pointer to performance counter + * + * Stop performance counter. + **/ +void retro_perf_stop(struct retro_perf_counter *perf); + +#ifdef __cplusplus +} +#endif + +#endif + From 288dbe2bd0229964f3394044fd7ccf7101c683ba Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 May 2016 08:55:28 +0200 Subject: [PATCH 385/498] retro_get_cpu_features - don't spam log --- performance.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/performance.c b/performance.c index 5cfe6327f0..fcbc516359 100644 --- a/performance.c +++ b/performance.c @@ -564,7 +564,5 @@ uint64_t retro_get_cpu_features(void) if (cpu & RETRO_SIMD_VFPU) strlcat(buf, " VFPU", sizeof(buf)); if (cpu & RETRO_SIMD_PS) strlcat(buf, " PS", sizeof(buf)); - RARCH_LOG("[CPUID]: Features:%s\n", buf); - return cpu; } From 0d371def5c72b2e68f8f335f2c33cffd64c6906d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 May 2016 09:17:04 +0200 Subject: [PATCH 386/498] Refactor performance.c code --- audio/audio_dsp_filter.c | 4 +- audio/audio_resampler_driver.c | 2 +- audio/audio_utils.c | 2 +- dynamic.c | 6 +- gfx/video_driver.c | 2 +- gfx/video_filter.c | 8 +- gfx/video_thread_wrapper.c | 6 +- menu/drivers/menu_generic.c | 4 +- menu/menu_animation.c | 2 +- menu/menu_input.c | 10 +-- network/net_http_special.c | 14 ++-- performance.c | 142 ++++++++++++++++----------------- performance.h | 52 ++++++++++-- performance_counters.c | 5 +- retroarch.c | 4 +- runloop.c | 8 +- 16 files changed, 153 insertions(+), 118 deletions(-) diff --git a/audio/audio_dsp_filter.c b/audio/audio_dsp_filter.c index 09a7759ae5..e781683918 100644 --- a/audio/audio_dsp_filter.c +++ b/audio/audio_dsp_filter.c @@ -147,7 +147,7 @@ static const dspfilter_get_implementation_t dsp_plugs_builtin[] = { static bool append_plugs(rarch_dsp_filter_t *dsp, struct string_list *list) { unsigned i; - dspfilter_simd_mask_t mask = retro_get_cpu_features(); + dspfilter_simd_mask_t mask = cpu_features_get(); (void)list; @@ -171,7 +171,7 @@ static bool append_plugs(rarch_dsp_filter_t *dsp, struct string_list *list) static bool append_plugs(rarch_dsp_filter_t *dsp, struct string_list *list) { unsigned i; - dspfilter_simd_mask_t mask = retro_get_cpu_features(); + dspfilter_simd_mask_t mask = cpu_features_get(); for (i = 0; i < list->size; i++) { diff --git a/audio/audio_resampler_driver.c b/audio/audio_resampler_driver.c index b4b770db5c..a50d70fece 100644 --- a/audio/audio_resampler_driver.c +++ b/audio/audio_resampler_driver.c @@ -143,7 +143,7 @@ retro_get_cpu_features_t perf_get_cpu_features_cb; static resampler_simd_mask_t resampler_get_cpu_features(void) { #ifdef RARCH_INTERNAL - return retro_get_cpu_features(); + return cpu_features_get(); #else return perf_get_cpu_features_cb(); #endif diff --git a/audio/audio_utils.c b/audio/audio_utils.c index 0946d57651..51b5f9b9a1 100644 --- a/audio/audio_utils.c +++ b/audio/audio_utils.c @@ -410,7 +410,7 @@ retro_get_cpu_features_t perf_get_cpu_features_cb; static unsigned audio_convert_get_cpu_features(void) { #ifdef RARCH_INTERNAL - return retro_get_cpu_features(); + return cpu_features_get(); #else return perf_get_cpu_features_cb(); #endif diff --git a/dynamic.c b/dynamic.c index ddd52747e9..e89bdfa18d 100644 --- a/dynamic.c +++ b/dynamic.c @@ -1122,9 +1122,9 @@ bool rarch_environment_cb(unsigned cmd, void *data) struct retro_perf_callback *cb = (struct retro_perf_callback*)data; RARCH_LOG("Environ GET_PERF_INTERFACE.\n"); - cb->get_time_usec = retro_get_time_usec; - cb->get_cpu_features = retro_get_cpu_features; - cb->get_perf_counter = retro_get_perf_counter; + cb->get_time_usec = cpu_features_get_time_usec; + cb->get_cpu_features = cpu_features_get; + cb->get_perf_counter = cpu_features_get_perf_counter; cb->perf_register = retro_perf_register; cb->perf_start = retro_perf_start; diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 6f1bcd39dd..8b380a7dc4 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -983,7 +983,7 @@ bool video_monitor_get_fps(char *buf, size_t size, { static retro_time_t curr_time; static retro_time_t fps_time; - retro_time_t new_time = retro_get_time_usec(); + retro_time_t new_time = cpu_features_get_time_usec(); *buf = '\0'; diff --git a/gfx/video_filter.c b/gfx/video_filter.c index 0f72d35560..fe46697bce 100644 --- a/gfx/video_filter.c +++ b/gfx/video_filter.c @@ -204,7 +204,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 : - retro_get_cpu_cores(), cpu_features, + cpu_features_get_core_amount(), cpu_features, &userdata); if (!filt->impl_data) { @@ -262,7 +262,7 @@ static bool append_softfilter_plugs(rarch_softfilter_t *filt, struct string_list *list) { unsigned i; - softfilter_simd_mask_t mask = retro_get_cpu_features(); + softfilter_simd_mask_t mask = cpu_features_get(); for (i = 0; i < list->size; i++) { @@ -345,7 +345,7 @@ static bool append_softfilter_plugs(rarch_softfilter_t *filt, struct string_list *list) { unsigned i; - softfilter_simd_mask_t mask = retro_get_cpu_features(); + softfilter_simd_mask_t mask = cpu_features_get(); (void)list; @@ -382,7 +382,7 @@ rarch_softfilter_t *rarch_softfilter_new(const char *filter_config, enum retro_pixel_format in_pixel_format, unsigned max_width, unsigned max_height) { - softfilter_simd_mask_t cpu_features = retro_get_cpu_features(); + softfilter_simd_mask_t cpu_features = cpu_features_get(); char basedir[PATH_MAX_LENGTH]; #ifdef HAVE_DYLIB char ext_name[PATH_MAX_LENGTH]; diff --git a/gfx/video_thread_wrapper.c b/gfx/video_thread_wrapper.c index aa03dccb43..b4b8ca1155 100644 --- a/gfx/video_thread_wrapper.c +++ b/gfx/video_thread_wrapper.c @@ -692,7 +692,7 @@ static bool video_thread_frame(void *data, const void *frame_, /* Ideally, use absolute time, but that is only a good idea on POSIX. */ while (thr->frame.updated) { - retro_time_t current = retro_get_time_usec(); + retro_time_t current = cpu_features_get_time_usec(); retro_time_t delta = target - current; if (delta <= 0) @@ -743,7 +743,7 @@ static bool video_thread_frame(void *data, const void *frame_, retro_perf_stop(&thr_frame); - thr->last_time = retro_get_time_usec(); + thr->last_time = cpu_features_get_time_usec(); return true; } @@ -783,7 +783,7 @@ static bool video_thread_init(thread_video_t *thr, const video_info_t *info, memset(thr->frame.buffer, 0x80, max_size); - thr->last_time = retro_get_time_usec(); + thr->last_time = cpu_features_get_time_usec(); thr->thread = sthread_create(video_thread_loop, thr); if (!thr->thread) diff --git a/menu/drivers/menu_generic.c b/menu/drivers/menu_generic.c index fa0e875a99..c1bd67114d 100644 --- a/menu/drivers/menu_generic.c +++ b/menu/drivers/menu_generic.c @@ -53,11 +53,11 @@ static int action_iterate_help(menu_handle_t *menu, int64_t timeout; static bool timer_begin = false; static bool timer_end = false; - int64_t current = retro_get_time_usec(); + int64_t current = cpu_features_get_time_usec(); if (!timer_begin) { - timeout_end = retro_get_time_usec() + + timeout_end = cpu_features_get_time_usec() + 3 /* seconds */ * 1000000; timer_begin = true; timer_end = false; diff --git a/menu/menu_animation.c b/menu/menu_animation.c index be5365859d..db267ec8fb 100644 --- a/menu/menu_animation.c +++ b/menu/menu_animation.c @@ -560,7 +560,7 @@ bool menu_animation_ctl(enum menu_animation_ctl_state state, void *data) static retro_time_t last_clock_update = 0; settings_t *settings = config_get_ptr(); - cur_time = retro_get_time_usec(); + cur_time = cpu_features_get_time_usec(); delta_time = cur_time - old_time; if (delta_time >= IDEAL_DELTA_TIME* 4) diff --git a/menu/menu_input.c b/menu/menu_input.c index cfc431e7ca..0025dd668d 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -267,7 +267,7 @@ static bool menu_input_key_bind_custom_bind_keyboard_cb( menu_input->binds.target->key = (enum retro_key)code; menu_input->binds.begin++; menu_input->binds.target++; - menu_input->binds.timeout_end = retro_get_time_usec() + + menu_input->binds.timeout_end = cpu_features_get_time_usec() + MENU_KEYBOARD_BIND_TIMEOUT_SECONDS * 1000000; return (menu_input->binds.begin <= menu_input->binds.last); @@ -455,7 +455,7 @@ static bool menu_input_key_bind_set_mode( menu_input_key_bind_poll_bind_state( &menu_input->binds, bind_port, false); - menu_input->binds.timeout_end = retro_get_time_usec() + + menu_input->binds.timeout_end = cpu_features_get_time_usec() + MENU_KEYBOARD_BIND_TIMEOUT_SECONDS * 1000000; keys.userdata = menu; @@ -574,7 +574,7 @@ static bool menu_input_key_bind_iterate(char *s, size_t len) struct menu_bind_state binds; bool timed_out = false; menu_input_t *menu_input = menu_input_get_ptr(); - int64_t current = retro_get_time_usec(); + int64_t current = cpu_features_get_time_usec(); int timeout = (menu_input->binds.timeout_end - current) / 1000000; @@ -584,7 +584,7 @@ static bool menu_input_key_bind_iterate(char *s, size_t len) menu_input->binds.begin++; menu_input->binds.target++; - menu_input->binds.timeout_end = retro_get_time_usec() + + menu_input->binds.timeout_end = cpu_features_get_time_usec() + MENU_KEYBOARD_BIND_TIMEOUT_SECONDS * 1000000; timed_out = true; } @@ -631,7 +631,7 @@ static bool menu_input_key_bind_iterate(char *s, size_t len) } binds.target++; - binds.timeout_end = retro_get_time_usec() + + binds.timeout_end = cpu_features_get_time_usec() + MENU_KEYBOARD_BIND_TIMEOUT_SECONDS * 1000000; } menu_input->binds = binds; diff --git a/network/net_http_special.c b/network/net_http_special.c index 62fb7c2dc7..2c488c614c 100644 --- a/network/net_http_special.c +++ b/network/net_http_special.c @@ -24,12 +24,12 @@ int net_http_get(const char **result, size_t *size, const char *url, retro_time_t *timeout) { - uint8_t* data; size_t length; - char* res; - int ret = NET_HTTP_GET_OK; - struct http_t* http = NULL; - retro_time_t t0 = retro_get_time_usec(); + uint8_t* data = NULL; + char* res = NULL; + int ret = NET_HTTP_GET_OK; + struct http_t* http = NULL; + retro_time_t t0 = cpu_features_get_time_usec(); struct http_connection_t *conn = net_http_connection_new(url); *result = NULL; @@ -60,7 +60,7 @@ int net_http_get(const char **result, size_t *size, const char *url, retro_time_ while (!net_http_update(http, NULL, NULL)) { /* Timeout error. */ - if (timeout && (retro_get_time_usec() - t0) > *timeout) + if (timeout && (cpu_features_get_time_usec() - t0) > *timeout) { ret = NET_HTTP_GET_TIMEOUT; goto error; @@ -99,7 +99,7 @@ error: if (timeout) { - t0 = retro_get_time_usec() - t0; + t0 = cpu_features_get_time_usec() - t0; if (t0 < *timeout) *timeout -= t0; diff --git a/performance.c b/performance.c index fcbc516359..b165192103 100644 --- a/performance.c +++ b/performance.c @@ -27,7 +27,9 @@ #define PERF_LOG_FMT "[PERF]: Avg (%s): %llu ticks, %llu runs.\n" #endif -#if !defined(_WIN32) && !defined(RARCH_CONSOLE) +#if defined(_WIN32) +#include +#else #include #endif @@ -110,13 +112,13 @@ static int clock_gettime(int clk_ik, struct timespec *t) #endif /** - * retro_get_perf_counter: + * cpu_features_get_perf_counter: * * Gets performance counter. * * Returns: performance counter. **/ -retro_perf_tick_t retro_get_perf_counter(void) +retro_perf_tick_t cpu_features_get_perf_counter(void) { retro_perf_tick_t time_ticks = 0; #if defined(__linux__) || defined(__QNX__) || defined(__MACH__) @@ -125,16 +127,12 @@ retro_perf_tick_t retro_get_perf_counter(void) time_ticks = (retro_perf_tick_t)tv.tv_sec * 1000000000 + (retro_perf_tick_t)tv.tv_nsec; -#elif defined(__GNUC__) && !defined(RARCH_CONSOLE) - -#if defined(__i386__) || defined(__i486__) || defined(__i686__) +#elif defined(__GNUC__) && defined(__i386__) || defined(__i486__) || defined(__i686__) __asm__ volatile ("rdtsc" : "=A" (time_ticks)); -#elif defined(__x86_64__) +#elif defined(__GNUC__) && defined(__x86_64__) unsigned a, d; __asm__ volatile ("rdtsc" : "=a" (a), "=d" (d)); time_ticks = (retro_perf_tick_t)a | ((retro_perf_tick_t)d << 32); -#endif - #elif defined(__ARM_ARCH_6__) __asm__ volatile( "mrc p15, 0, %0, c9, c13, 0" : "=r"(time_ticks) ); #elif defined(__CELLOS_LV2__) || defined(_XBOX360) || defined(__powerpc__) || defined(__ppc__) || defined(__POWERPC__) @@ -171,13 +169,13 @@ retro_perf_tick_t retro_get_perf_counter(void) } /** - * retro_get_time_usec: + * cpu_features_get_time_usec: * * Gets time in microseconds. * * Returns: time in microseconds. **/ -retro_time_t retro_get_time_usec(void) +retro_time_t cpu_features_get_time_usec(void) { #if defined(_WIN32) static LARGE_INTEGER freq; @@ -210,7 +208,7 @@ retro_time_t retro_get_time_usec(void) #elif defined(VITA) return sceKernelGetProcessTimeWide(); #else -#error "Your platform does not have a timer function implemented in retro_get_time_usec(). Cannot continue." +#error "Your platform does not have a timer function implemented in cpu_features_get_time_usec(). Cannot continue." #endif } @@ -245,7 +243,7 @@ void x86_cpuid(int func, int flags[4]) #elif defined(_MSC_VER) __cpuid(flags, func); #else - RARCH_WARN("Unknown compiler. Cannot check CPUID with inline assembly.\n"); + printf("Unknown compiler. Cannot check CPUID with inline assembly.\n"); memset(flags, 0, 4 * sizeof(int)); #endif } @@ -267,7 +265,7 @@ static uint64_t xgetbv_x86(uint32_t idx) /* Intrinsic only works on 2010 SP1 and above. */ return _xgetbv(idx); #else - RARCH_WARN("Unknown compiler. Cannot check xgetbv bits.\n"); + printf("Unknown compiler. Cannot check xgetbv bits.\n"); return 0; #endif } @@ -293,13 +291,13 @@ static void arm_enable_runfast_mode(void) #endif /** - * retro_get_cpu_cores: + * cpu_features_get_core_amount: * * Gets the amount of available CPU cores. * * Returns: amount of CPU cores available. **/ -unsigned retro_get_cpu_cores(void) +unsigned cpu_features_get_core_amount(void) { #if defined(_WIN32) && !defined(_XBOX) /* Win32 */ @@ -354,13 +352,13 @@ unsigned retro_get_cpu_cores(void) #define VENDOR_INTEL_d 0x49656e69 /** - * retro_get_cpu_features: + * cpu_features_get: * * Gets CPU features.. * * Returns: bitmask of all CPU features available. **/ -uint64_t retro_get_cpu_features(void) +uint64_t cpu_features_get(void) { int flags[4]; int vendor_shuffle[3]; @@ -389,53 +387,53 @@ uint64_t retro_get_cpu_features(void) len = sizeof(size_t); if (sysctlbyname("hw.optional.mmx", NULL, &len, NULL, 0) == 0) { - cpu |= RETRO_SIMD_MMX; - cpu |= RETRO_SIMD_MMXEXT; + cpu |= CPU_FEATURE_MMX; + cpu |= CPU_FEATURE_MMXEXT; } len = sizeof(size_t); if (sysctlbyname("hw.optional.sse", NULL, &len, NULL, 0) == 0) - cpu |= RETRO_SIMD_SSE; + cpu |= CPU_FEATURE_SSE; len = sizeof(size_t); if (sysctlbyname("hw.optional.sse2", NULL, &len, NULL, 0) == 0) - cpu |= RETRO_SIMD_SSE2; + cpu |= CPU_FEATURE_SSE2; len = sizeof(size_t); if (sysctlbyname("hw.optional.sse3", NULL, &len, NULL, 0) == 0) - cpu |= RETRO_SIMD_SSE3; + cpu |= CPU_FEATURE_SSE3; len = sizeof(size_t); if (sysctlbyname("hw.optional.supplementalsse3", NULL, &len, NULL, 0) == 0) - cpu |= RETRO_SIMD_SSSE3; + cpu |= CPU_FEATURE_SSSE3; len = sizeof(size_t); if (sysctlbyname("hw.optional.sse4_1", NULL, &len, NULL, 0) == 0) - cpu |= RETRO_SIMD_SSE4; + cpu |= CPU_FEATURE_SSE4; len = sizeof(size_t); if (sysctlbyname("hw.optional.sse4_2", NULL, &len, NULL, 0) == 0) - cpu |= RETRO_SIMD_SSE42; + cpu |= CPU_FEATURE_SSE42; len = sizeof(size_t); if (sysctlbyname("hw.optional.aes", NULL, &len, NULL, 0) == 0) - cpu |= RETRO_SIMD_AES; + cpu |= CPU_FEATURE_AES; len = sizeof(size_t); if (sysctlbyname("hw.optional.avx1_0", NULL, &len, NULL, 0) == 0) - cpu |= RETRO_SIMD_AVX; + cpu |= CPU_FEATURE_AVX; len = sizeof(size_t); if (sysctlbyname("hw.optional.avx2_0", NULL, &len, NULL, 0) == 0) - cpu |= RETRO_SIMD_AVX2; + cpu |= CPU_FEATURE_AVX2; len = sizeof(size_t); if (sysctlbyname("hw.optional.altivec", NULL, &len, NULL, 0) == 0) - cpu |= RETRO_SIMD_VMX; + cpu |= CPU_FEATURE_VMX; len = sizeof(size_t); if (sysctlbyname("hw.optional.neon", NULL, &len, NULL, 0) == 0) - cpu |= RETRO_SIMD_NEON; + cpu |= CPU_FEATURE_NEON; #elif defined(CPU_X86) (void)avx_flags; @@ -446,7 +444,7 @@ uint64_t retro_get_cpu_features(void) vendor_shuffle[2] = flags[2]; memcpy(vendor, vendor_shuffle, sizeof(vendor_shuffle)); - RARCH_LOG("[CPUID]: Vendor: %s\n", vendor); + printf("[CPUID]: Vendor: %s\n", vendor); vendor_is_intel = ( flags[1] == VENDOR_INTEL_b && @@ -460,52 +458,52 @@ uint64_t retro_get_cpu_features(void) x86_cpuid(1, flags); if (flags[3] & (1 << 23)) - cpu |= RETRO_SIMD_MMX; + cpu |= CPU_FEATURE_MMX; if (flags[3] & (1 << 25)) { /* SSE also implies MMXEXT (according to FFmpeg source). */ - cpu |= RETRO_SIMD_SSE; - cpu |= RETRO_SIMD_MMXEXT; + cpu |= CPU_FEATURE_SSE; + cpu |= CPU_FEATURE_MMXEXT; } if (flags[3] & (1 << 26)) - cpu |= RETRO_SIMD_SSE2; + cpu |= CPU_FEATURE_SSE2; if (flags[2] & (1 << 0)) - cpu |= RETRO_SIMD_SSE3; + cpu |= CPU_FEATURE_SSE3; if (flags[2] & (1 << 9)) - cpu |= RETRO_SIMD_SSSE3; + cpu |= CPU_FEATURE_SSSE3; if (flags[2] & (1 << 19)) - cpu |= RETRO_SIMD_SSE4; + cpu |= CPU_FEATURE_SSE4; if (flags[2] & (1 << 20)) - cpu |= RETRO_SIMD_SSE42; + cpu |= CPU_FEATURE_SSE42; if ((flags[2] & (1 << 23))) - cpu |= RETRO_SIMD_POPCNT; + cpu |= CPU_FEATURE_POPCNT; if (vendor_is_intel && (flags[2] & (1 << 22))) - cpu |= RETRO_SIMD_MOVBE; + cpu |= CPU_FEATURE_MOVBE; if (flags[2] & (1 << 25)) - cpu |= RETRO_SIMD_AES; + cpu |= CPU_FEATURE_AES; /* Must only perform xgetbv check if we have * AVX CPU support (guaranteed to have at least i686). */ if (((flags[2] & avx_flags) == avx_flags) && ((xgetbv_x86(0) & 0x6) == 0x6)) - cpu |= RETRO_SIMD_AVX; + cpu |= CPU_FEATURE_AVX; if (max_flag >= 7) { x86_cpuid(7, flags); if (flags[1] & (1 << 5)) - cpu |= RETRO_SIMD_AVX2; + cpu |= CPU_FEATURE_AVX2; } x86_cpuid(0x80000000, flags); @@ -514,55 +512,55 @@ uint64_t retro_get_cpu_features(void) { x86_cpuid(0x80000001, flags); if (flags[3] & (1 << 23)) - cpu |= RETRO_SIMD_MMX; + cpu |= CPU_FEATURE_MMX; if (flags[3] & (1 << 22)) - cpu |= RETRO_SIMD_MMXEXT; + cpu |= CPU_FEATURE_MMXEXT; } #elif defined(__linux__) cpu_flags = linux_get_cpu_features(); if (cpu_flags & CPU_ARM_FEATURE_NEON) { - cpu |= RETRO_SIMD_NEON; + cpu |= CPU_FEATURE_NEON; #ifdef __ARM_NEON__ arm_enable_runfast_mode(); #endif } if (cpu_flags & CPU_ARM_FEATURE_VFPv3) - cpu |= RETRO_SIMD_VFPV3; + cpu |= CPU_FEATURE_VFPV3; #elif defined(__ARM_NEON__) - cpu |= RETRO_SIMD_NEON; + cpu |= CPU_FEATURE_NEON; arm_enable_runfast_mode(); #elif defined(__ALTIVEC__) - cpu |= RETRO_SIMD_VMX; + cpu |= CPU_FEATURE_VMX; #elif defined(XBOX360) - cpu |= RETRO_SIMD_VMX128; + cpu |= CPU_FEATURE_VMX128; #elif defined(PSP) - cpu |= RETRO_SIMD_VFPU; + cpu |= CPU_FEATURE_VFPU; #elif defined(GEKKO) - cpu |= RETRO_SIMD_PS; + cpu |= CPU_FEATURE_PS; #endif - if (cpu & RETRO_SIMD_MMX) strlcat(buf, " MMX", sizeof(buf)); - if (cpu & RETRO_SIMD_MMXEXT) strlcat(buf, " MMXEXT", sizeof(buf)); - if (cpu & RETRO_SIMD_SSE) strlcat(buf, " SSE", sizeof(buf)); - if (cpu & RETRO_SIMD_SSE2) strlcat(buf, " SSE2", sizeof(buf)); - if (cpu & RETRO_SIMD_SSE3) strlcat(buf, " SSE3", sizeof(buf)); - if (cpu & RETRO_SIMD_SSSE3) strlcat(buf, " SSSE3", sizeof(buf)); - if (cpu & RETRO_SIMD_SSE4) strlcat(buf, " SSE4", sizeof(buf)); - if (cpu & RETRO_SIMD_SSE42) strlcat(buf, " SSE4.2", sizeof(buf)); - if (cpu & RETRO_SIMD_AES) strlcat(buf, " AES", sizeof(buf)); - if (cpu & RETRO_SIMD_AVX) strlcat(buf, " AVX", sizeof(buf)); - if (cpu & RETRO_SIMD_AVX2) strlcat(buf, " AVX2", sizeof(buf)); - if (cpu & RETRO_SIMD_NEON) strlcat(buf, " NEON", sizeof(buf)); - if (cpu & RETRO_SIMD_VFPV3) strlcat(buf, " VFPv3", sizeof(buf)); - if (cpu & RETRO_SIMD_VFPV4) strlcat(buf, " VFPv4", sizeof(buf)); - if (cpu & RETRO_SIMD_VMX) strlcat(buf, " VMX", sizeof(buf)); - if (cpu & RETRO_SIMD_VMX128) strlcat(buf, " VMX128", sizeof(buf)); - if (cpu & RETRO_SIMD_VFPU) strlcat(buf, " VFPU", sizeof(buf)); - if (cpu & RETRO_SIMD_PS) strlcat(buf, " PS", sizeof(buf)); + if (cpu & CPU_FEATURE_MMX) strlcat(buf, " MMX", sizeof(buf)); + if (cpu & CPU_FEATURE_MMXEXT) strlcat(buf, " MMXEXT", sizeof(buf)); + if (cpu & CPU_FEATURE_SSE) strlcat(buf, " SSE", sizeof(buf)); + if (cpu & CPU_FEATURE_SSE2) strlcat(buf, " SSE2", sizeof(buf)); + if (cpu & CPU_FEATURE_SSE3) strlcat(buf, " SSE3", sizeof(buf)); + if (cpu & CPU_FEATURE_SSSE3) strlcat(buf, " SSSE3", sizeof(buf)); + if (cpu & CPU_FEATURE_SSE4) strlcat(buf, " SSE4", sizeof(buf)); + if (cpu & CPU_FEATURE_SSE42) strlcat(buf, " SSE4.2", sizeof(buf)); + if (cpu & CPU_FEATURE_AES) strlcat(buf, " AES", sizeof(buf)); + if (cpu & CPU_FEATURE_AVX) strlcat(buf, " AVX", sizeof(buf)); + if (cpu & CPU_FEATURE_AVX2) strlcat(buf, " AVX2", sizeof(buf)); + if (cpu & CPU_FEATURE_NEON) strlcat(buf, " NEON", sizeof(buf)); + if (cpu & CPU_FEATURE_VFPV3) strlcat(buf, " VFPv3", sizeof(buf)); + if (cpu & CPU_FEATURE_VFPV4) strlcat(buf, " VFPv4", sizeof(buf)); + if (cpu & CPU_FEATURE_VMX) strlcat(buf, " VMX", sizeof(buf)); + if (cpu & CPU_FEATURE_VMX128) strlcat(buf, " VMX128", sizeof(buf)); + if (cpu & CPU_FEATURE_VFPU) strlcat(buf, " VFPU", sizeof(buf)); + if (cpu & CPU_FEATURE_PS) strlcat(buf, " PS", sizeof(buf)); return cpu; } diff --git a/performance.h b/performance.h index 71b56a00f1..dac242511d 100644 --- a/performance.h +++ b/performance.h @@ -14,42 +14,78 @@ * If not, see . */ -#ifndef _RARCH_PERF_H -#define _RARCH_PERF_H +#ifndef _LIBRETRO_SDK_CPU_INFO_H +#define _LIBRETRO_SDK_CPU_INFO_H #include +#ifdef RARCH_INTERNAL #include "libretro.h" +#else +typedef uint64_t retro_perf_tick_t; +typedef uint64_t retro_time_t; +#endif + +/* ID values for CPU features */ +#define CPU_FEATURE_SSE (1 << 0) +#define CPU_FEATURE_SSE2 (1 << 1) +#define CPU_FEATURE_VMX (1 << 2) +#define CPU_FEATURE_VMX128 (1 << 3) +#define CPU_FEATURE_AVX (1 << 4) +#define CPU_FEATURE_NEON (1 << 5) +#define CPU_FEATURE_SSE3 (1 << 6) +#define CPU_FEATURE_SSSE3 (1 << 7) +#define CPU_FEATURE_MMX (1 << 8) +#define CPU_FEATURE_MMXEXT (1 << 9) +#define CPU_FEATURE_SSE4 (1 << 10) +#define CPU_FEATURE_SSE42 (1 << 11) +#define CPU_FEATURE_AVX2 (1 << 12) +#define CPU_FEATURE_VFPU (1 << 13) +#define CPU_FEATURE_PS (1 << 14) +#define CPU_FEATURE_AES (1 << 15) +#define CPU_FEATURE_VFPV3 (1 << 16) +#define CPU_FEATURE_VFPV4 (1 << 17) +#define CPU_FEATURE_POPCNT (1 << 18) +#define CPU_FEATURE_MOVBE (1 << 19) #ifdef __cplusplus extern "C" { #endif /** - * retro_get_time_usec: + * cpu_features_get_perf_counter: + * + * Gets performance counter. + * + * Returns: performance counter. + **/ +retro_perf_tick_t cpu_features_get_perf_counter(void); + +/** + * cpu_features_get_time_usec: * * Gets time in microseconds. * * Returns: time in microseconds. **/ -retro_time_t retro_get_time_usec(void); +retro_time_t cpu_features_get_time_usec(void); /** - * retro_get_cpu_features: + * cpu_features_get: * * Gets CPU features.. * * Returns: bitmask of all CPU features available. **/ -uint64_t retro_get_cpu_features(void); +uint64_t cpu_features_get(void); /** - * retro_get_cpu_cores: + * cpu_features_get_core_amount: * * Gets the amount of available CPU cores. * * Returns: amount of CPU cores available. **/ -unsigned retro_get_cpu_cores(void); +unsigned cpu_features_get_core_amount(void); #ifdef __cplusplus diff --git a/performance_counters.c b/performance_counters.c index ce8e4d248a..209e6fb824 100644 --- a/performance_counters.c +++ b/performance_counters.c @@ -17,6 +17,7 @@ #include #include +#include "performance.h" #include "performance_counters.h" #include "general.h" @@ -133,7 +134,7 @@ void retro_perf_start(struct retro_perf_counter *perf) return; perf->call_cnt++; - perf->start = retro_get_perf_counter(); + perf->start = cpu_features_get_perf_counter(); } void retro_perf_stop(struct retro_perf_counter *perf) @@ -141,5 +142,5 @@ void retro_perf_stop(struct retro_perf_counter *perf) if (!runloop_ctl(RUNLOOP_CTL_IS_PERFCNT_ENABLE, NULL) || !perf) return; - perf->total += retro_get_perf_counter() - perf->start; + perf->total += cpu_features_get_perf_counter() - perf->start; } diff --git a/retroarch.c b/retroarch.c index a19faf4fbb..e0f1cff51f 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1545,7 +1545,7 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data) break; case RARCH_CTL_VALIDATE_CPU_FEATURES: { - uint64_t cpu = retro_get_cpu_features(); + uint64_t cpu = cpu_features_get(); (void)cpu; #ifdef __SSE__ @@ -1594,7 +1594,7 @@ int retroarch_get_capabilities(enum rarch_capabilities type, { case RARCH_CAPABILITIES_CPU: { - uint64_t cpu = retro_get_cpu_features(); + uint64_t cpu = cpu_features_get(); if (cpu & RETRO_SIMD_MMX) strlcat(s, "MMX ", len); diff --git a/runloop.c b/runloop.c index 647e15544a..63e4e2d889 100644 --- a/runloop.c +++ b/runloop.c @@ -1316,7 +1316,7 @@ int runloop_iterate(unsigned *sleep_ms) (settings->fastforward_ratio == 0.0f) ? 1.0f : settings->fastforward_ratio; - frame_limit_last_time = retro_get_time_usec(); + frame_limit_last_time = cpu_features_get_time_usec(); frame_limit_minimum_time = (retro_time_t)roundf(1000000.0f / (av_info->timing.fps * fastforward_ratio)); @@ -1343,7 +1343,7 @@ int runloop_iterate(unsigned *sleep_ms) /* Updates frame timing if frame timing callback is in use by the core. * Limits frame time if fast forward ratio throttle is enabled. */ - retro_time_t current = retro_get_time_usec(); + retro_time_t current = cpu_features_get_time_usec(); retro_time_t delta = current - runloop_frame_time_last; bool is_locked_fps = (runloop_ctl(RUNLOOP_CTL_IS_PAUSED, NULL) || input_driver_is_nonblock_state()) | @@ -1513,7 +1513,7 @@ int runloop_iterate(unsigned *sleep_ms) end: #endif - current = retro_get_time_usec(); + current = cpu_features_get_time_usec(); target = frame_limit_last_time + frame_limit_minimum_time; to_sleep_ms = (target - current) / 1000; @@ -1526,7 +1526,7 @@ end: return 1; } - frame_limit_last_time = retro_get_time_usec(); + frame_limit_last_time = cpu_features_get_time_usec(); return 0; } From 2b8ff3bf3844e20ba8021f1f40c3e59f64b69772 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 May 2016 09:27:29 +0200 Subject: [PATCH 387/498] Move cpu_features to libretro-common --- Makefile.common | 2 +- audio/audio_dsp_filter.c | 2 +- audio/audio_resampler_driver.c | 2 +- audio/audio_utils.c | 3 +- dynamic.c | 2 +- gfx/video_driver.c | 2 +- gfx/video_filter.c | 2 +- gfx/video_thread_wrapper.c | 2 +- griffin/griffin.c | 2 +- .../features/cpu_features.c | 40 +++++++++---------- libretro-common/formats/jpeg/rjpeg.c | 22 ++++++++++ .../include/features/cpu_features.h | 30 ++++++++------ libretro-common/include/formats/image.h | 30 ++++++++------ libretro-common/include/formats/jsonsax.h | 2 +- libretro-common/include/formats/rjpeg.h | 2 +- libretro-common/include/formats/rpng.h | 2 +- libretro-common/include/formats/rxml.h | 2 +- menu/drivers/menu_generic.c | 3 +- menu/menu_animation.c | 3 +- menu/menu_input.c | 3 +- network/net_http_special.c | 2 +- performance_counters.c | 3 +- retroarch.c | 2 +- runloop.c | 2 +- 24 files changed, 102 insertions(+), 65 deletions(-) rename performance.c => libretro-common/features/cpu_features.c (91%) rename performance.h => libretro-common/include/features/cpu_features.h (56%) diff --git a/Makefile.common b/Makefile.common index 9a55a67774..98e9683fc0 100644 --- a/Makefile.common +++ b/Makefile.common @@ -204,7 +204,7 @@ OBJ += frontend/frontend.o \ movie.o \ record/record_driver.o \ record/drivers/record_null.o \ - performance.o \ + libretro-common/features/cpu_features.o \ performance_counters.o \ verbosity.o diff --git a/audio/audio_dsp_filter.c b/audio/audio_dsp_filter.c index e781683918..1d206e2a5f 100644 --- a/audio/audio_dsp_filter.c +++ b/audio/audio_dsp_filter.c @@ -23,13 +23,13 @@ #include #include +#include #include "audio_dsp_filter.h" #include "audio_filters/dspfilter.h" #include "../config_file_userdata.h" #include "../frontend/frontend_driver.h" -#include "../performance.h" #include "../performance_counters.h" #include "../dynamic.h" diff --git a/audio/audio_resampler_driver.c b/audio/audio_resampler_driver.c index a50d70fece..9487afed5b 100644 --- a/audio/audio_resampler_driver.c +++ b/audio/audio_resampler_driver.c @@ -17,11 +17,11 @@ #include #include +#include #include "audio_resampler_driver.h" #include "../config_file_userdata.h" #ifdef RARCH_INTERNAL -#include "../performance.h" #include "../performance_counters.h" #endif #ifndef DONT_HAVE_STRING_LIST diff --git a/audio/audio_utils.c b/audio/audio_utils.c index 51b5f9b9a1..64b7df19ec 100644 --- a/audio/audio_utils.c +++ b/audio/audio_utils.c @@ -23,8 +23,9 @@ #include #endif +#include + #ifdef RARCH_INTERNAL -#include "../performance.h" #include "../performance_counters.h" #endif diff --git a/dynamic.c b/dynamic.c index e89bdfa18d..e8cf340371 100644 --- a/dynamic.c +++ b/dynamic.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #ifdef HAVE_CONFIG_H @@ -38,7 +39,6 @@ #include "record/record_driver.h" #include "core.h" #include "performance_counters.h" -#include "performance.h" #include "system.h" #include "gfx/video_context_driver.h" diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 8b380a7dc4..dc66557d6b 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -25,6 +25,7 @@ #endif #include +#include #include "video_thread_wrapper.h" #include "../frontend/frontend_driver.h" @@ -33,7 +34,6 @@ #include "../config.def.h" #include "../retroarch.h" #include "../runloop.h" -#include "../performance.h" #include "../performance_counters.h" #include "../list_special.h" #include "../core.h" diff --git a/gfx/video_filter.c b/gfx/video_filter.c index fe46697bce..6cc8a2be7a 100644 --- a/gfx/video_filter.c +++ b/gfx/video_filter.c @@ -19,12 +19,12 @@ #include #include #include +#include #include "../frontend/frontend_driver.h" #include "../config_file_userdata.h" #include "../dynamic.h" #include "../general.h" -#include "../performance.h" #include "../performance_counters.h" #include "../verbosity.h" #include "video_filter.h" diff --git a/gfx/video_thread_wrapper.c b/gfx/video_thread_wrapper.c index b4b8ca1155..bbfc87d8fd 100644 --- a/gfx/video_thread_wrapper.c +++ b/gfx/video_thread_wrapper.c @@ -19,11 +19,11 @@ #include #include +#include #include "video_thread_wrapper.h" #include "font_driver.h" #include "video_shader_driver.h" -#include "../performance.h" #include "../performance_counters.h" #include "../runloop.h" #include "../verbosity.h" diff --git a/griffin/griffin.c b/griffin/griffin.c index e483a0c10c..735ea2f1fe 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -62,7 +62,7 @@ ENCODINGS /*============================================================ PERFORMANCE ============================================================ */ -#include "../performance.c" +#include "../libretro-common/features/cpu_features.c" #include "../performance_counters.c" /*============================================================ diff --git a/performance.c b/libretro-common/features/cpu_features.c similarity index 91% rename from performance.c rename to libretro-common/features/cpu_features.c index b165192103..94f5b73e79 100644 --- a/performance.c +++ b/libretro-common/features/cpu_features.c @@ -1,31 +1,29 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2010-2014 - Hans-Kristian Arntzen - * Copyright (C) 2011-2016 - Daniel De Matteis +/* Copyright (C) 2010-2016 The RetroArch team * - * 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. + * --------------------------------------------------------------------------------------- + * The following license statement only applies to this file (cpu_features.c). + * --------------------------------------------------------------------------------------- * - * 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. + * 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: * - * You should have received a copy of the GNU General Public License along with RetroArch. - * If not, see . + * 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 "libretro.h" -#include "performance.h" -#include "general.h" -#include "compat/strl.h" -#include "verbosity.h" -#ifdef _WIN32 -#define PERF_LOG_FMT "[PERF]: Avg (%s): %I64u ticks, %I64u runs.\n" -#else -#define PERF_LOG_FMT "[PERF]: Avg (%s): %llu ticks, %llu runs.\n" -#endif +#include +#include #if defined(_WIN32) #include diff --git a/libretro-common/formats/jpeg/rjpeg.c b/libretro-common/formats/jpeg/rjpeg.c index 4d43a66c76..e8e6f2701d 100644 --- a/libretro-common/formats/jpeg/rjpeg.c +++ b/libretro-common/formats/jpeg/rjpeg.c @@ -1,3 +1,25 @@ +/* Copyright (C) 2010-2016 The RetroArch team + * + * --------------------------------------------------------------------------------------- + * The following license statement only applies to this file (rjpeg.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. + */ + /* Modified version of stb_image's JPEG sources. */ diff --git a/performance.h b/libretro-common/include/features/cpu_features.h similarity index 56% rename from performance.h rename to libretro-common/include/features/cpu_features.h index dac242511d..dc8d091188 100644 --- a/performance.h +++ b/libretro-common/include/features/cpu_features.h @@ -1,17 +1,23 @@ -/* 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. +/* Copyright (C) 2010-2016 The RetroArch team * - * 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. + * --------------------------------------------------------------------------------------- + * The following license statement only applies to this file (cpu_features.h). + * --------------------------------------------------------------------------------------- * - * You should have received a copy of the GNU General Public License along with RetroArch. - * If not, see . + * 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_CPU_INFO_H diff --git a/libretro-common/include/formats/image.h b/libretro-common/include/formats/image.h index 1f96b81efd..00457cf2a5 100644 --- a/libretro-common/include/formats/image.h +++ b/libretro-common/include/formats/image.h @@ -1,17 +1,23 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2010-2014 - Hans-Kristian Arntzen - * Copyright (C) 2011-2015 - 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. +/* Copyright (C) 2010-2016 The RetroArch team * - * 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. + * --------------------------------------------------------------------------------------- + * The following license statement only applies to this file (image.h). + * --------------------------------------------------------------------------------------- * - * You should have received a copy of the GNU General Public License along with RetroArch. - * If not, see . + * 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 __RARCH_IMAGE_CONTEXT_H diff --git a/libretro-common/include/formats/jsonsax.h b/libretro-common/include/formats/jsonsax.h index 76860fe5f5..86d6d6b207 100644 --- a/libretro-common/include/formats/jsonsax.h +++ b/libretro-common/include/formats/jsonsax.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2015 The RetroArch team +/* Copyright (C) 2010-2016 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (jsonsax.h). diff --git a/libretro-common/include/formats/rjpeg.h b/libretro-common/include/formats/rjpeg.h index 539fd058df..81f61b92af 100644 --- a/libretro-common/include/formats/rjpeg.h +++ b/libretro-common/include/formats/rjpeg.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2015 The RetroArch team +/* Copyright (C) 2010-2016 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (rjpeg.h). diff --git a/libretro-common/include/formats/rpng.h b/libretro-common/include/formats/rpng.h index 94db62932f..fa3f5d5bca 100644 --- a/libretro-common/include/formats/rpng.h +++ b/libretro-common/include/formats/rpng.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2015 The RetroArch team +/* Copyright (C) 2010-2016 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (rpng.h). diff --git a/libretro-common/include/formats/rxml.h b/libretro-common/include/formats/rxml.h index 3ee1109601..c3f3335c19 100644 --- a/libretro-common/include/formats/rxml.h +++ b/libretro-common/include/formats/rxml.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2015 The RetroArch team +/* Copyright (C) 2010-2016 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (rxml.h). diff --git a/menu/drivers/menu_generic.c b/menu/drivers/menu_generic.c index c1bd67114d..989d3b5727 100644 --- a/menu/drivers/menu_generic.c +++ b/menu/drivers/menu_generic.c @@ -18,6 +18,8 @@ #include #include +#include + #include "menu_generic.h" #include "../menu_driver.h" @@ -28,7 +30,6 @@ #include "../menu_entries.h" #include "../../configuration.h" -#include "../../performance.h" #include "../../performance_counters.h" #include "../../input/input_autodetect.h" #include "../../input/input_config.h" diff --git a/menu/menu_animation.c b/menu/menu_animation.c index db267ec8fb..a4c1efb0ce 100644 --- a/menu/menu_animation.c +++ b/menu/menu_animation.c @@ -16,13 +16,14 @@ #include #include + #include #include #include +#include #include "menu_animation.h" #include "../configuration.h" -#include "../performance.h" #include "../performance_counters.h" #define IDEAL_DELTA_TIME (1.0 / 60.0 * 1000000.0) diff --git a/menu/menu_input.c b/menu/menu_input.c index 0025dd668d..f1a5b66415 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -27,6 +27,8 @@ #include #include +#include + #include "menu_driver.h" #include "menu_input.h" #include "menu_animation.h" @@ -39,7 +41,6 @@ #include "../general.h" #include "../managers/cheat_manager.h" -#include "../performance.h" #include "../performance_counters.h" #include "../core.h" #include "../input/input_joypad_driver.h" diff --git a/network/net_http_special.c b/network/net_http_special.c index 2c488c614c..10ad9c15fe 100644 --- a/network/net_http_special.c +++ b/network/net_http_special.c @@ -17,8 +17,8 @@ #include #include +#include -#include "../performance.h" #include "../performance_counters.h" #include "net_http_special.h" diff --git a/performance_counters.c b/performance_counters.c index 209e6fb824..2ac7ee2a72 100644 --- a/performance_counters.c +++ b/performance_counters.c @@ -17,7 +17,8 @@ #include #include -#include "performance.h" +#include + #include "performance_counters.h" #include "general.h" diff --git a/retroarch.c b/retroarch.c index e0f1cff51f..70032242ec 100644 --- a/retroarch.c +++ b/retroarch.c @@ -42,6 +42,7 @@ #include #include #include +#include #include "content.h" #include "core_type.h" @@ -58,7 +59,6 @@ #include "configuration.h" #include "general.h" #include "runloop.h" -#include "performance.h" #include "managers/cheat_manager.h" #include "system.h" diff --git a/runloop.c b/runloop.c index 63e4e2d889..03780d734b 100644 --- a/runloop.c +++ b/runloop.c @@ -23,6 +23,7 @@ #include #include #include +#include #include #ifdef HAVE_THREADS #include @@ -38,7 +39,6 @@ #include "autosave.h" #include "core_info.h" #include "configuration.h" -#include "performance.h" #include "movie.h" #include "retroarch.h" #include "runloop.h" From 35ea37b37f9ba135d6ee03ca07c0cf5537df47f5 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 May 2016 09:32:24 +0200 Subject: [PATCH 388/498] Revert "Move cpu_features to libretro-common" This reverts commit 2b8ff3bf3844e20ba8021f1f40c3e59f64b69772. --- Makefile.common | 2 +- audio/audio_dsp_filter.c | 2 +- audio/audio_resampler_driver.c | 2 +- audio/audio_utils.c | 3 +- dynamic.c | 2 +- gfx/video_driver.c | 2 +- gfx/video_filter.c | 2 +- gfx/video_thread_wrapper.c | 2 +- griffin/griffin.c | 2 +- libretro-common/formats/jpeg/rjpeg.c | 22 ---------- libretro-common/include/formats/image.h | 30 ++++++-------- libretro-common/include/formats/jsonsax.h | 2 +- libretro-common/include/formats/rjpeg.h | 2 +- libretro-common/include/formats/rpng.h | 2 +- libretro-common/include/formats/rxml.h | 2 +- menu/drivers/menu_generic.c | 3 +- menu/menu_animation.c | 3 +- menu/menu_input.c | 3 +- network/net_http_special.c | 2 +- .../features/cpu_features.c => performance.c | 40 ++++++++++--------- .../features/cpu_features.h => performance.h | 30 ++++++-------- performance_counters.c | 3 +- retroarch.c | 2 +- runloop.c | 2 +- 24 files changed, 65 insertions(+), 102 deletions(-) rename libretro-common/features/cpu_features.c => performance.c (91%) rename libretro-common/include/features/cpu_features.h => performance.h (56%) diff --git a/Makefile.common b/Makefile.common index 98e9683fc0..9a55a67774 100644 --- a/Makefile.common +++ b/Makefile.common @@ -204,7 +204,7 @@ OBJ += frontend/frontend.o \ movie.o \ record/record_driver.o \ record/drivers/record_null.o \ - libretro-common/features/cpu_features.o \ + performance.o \ performance_counters.o \ verbosity.o diff --git a/audio/audio_dsp_filter.c b/audio/audio_dsp_filter.c index 1d206e2a5f..e781683918 100644 --- a/audio/audio_dsp_filter.c +++ b/audio/audio_dsp_filter.c @@ -23,13 +23,13 @@ #include #include -#include #include "audio_dsp_filter.h" #include "audio_filters/dspfilter.h" #include "../config_file_userdata.h" #include "../frontend/frontend_driver.h" +#include "../performance.h" #include "../performance_counters.h" #include "../dynamic.h" diff --git a/audio/audio_resampler_driver.c b/audio/audio_resampler_driver.c index 9487afed5b..a50d70fece 100644 --- a/audio/audio_resampler_driver.c +++ b/audio/audio_resampler_driver.c @@ -17,11 +17,11 @@ #include #include -#include #include "audio_resampler_driver.h" #include "../config_file_userdata.h" #ifdef RARCH_INTERNAL +#include "../performance.h" #include "../performance_counters.h" #endif #ifndef DONT_HAVE_STRING_LIST diff --git a/audio/audio_utils.c b/audio/audio_utils.c index 64b7df19ec..51b5f9b9a1 100644 --- a/audio/audio_utils.c +++ b/audio/audio_utils.c @@ -23,9 +23,8 @@ #include #endif -#include - #ifdef RARCH_INTERNAL +#include "../performance.h" #include "../performance_counters.h" #endif diff --git a/dynamic.c b/dynamic.c index e8cf340371..e89bdfa18d 100644 --- a/dynamic.c +++ b/dynamic.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #ifdef HAVE_CONFIG_H @@ -39,6 +38,7 @@ #include "record/record_driver.h" #include "core.h" #include "performance_counters.h" +#include "performance.h" #include "system.h" #include "gfx/video_context_driver.h" diff --git a/gfx/video_driver.c b/gfx/video_driver.c index dc66557d6b..8b380a7dc4 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -25,7 +25,6 @@ #endif #include -#include #include "video_thread_wrapper.h" #include "../frontend/frontend_driver.h" @@ -34,6 +33,7 @@ #include "../config.def.h" #include "../retroarch.h" #include "../runloop.h" +#include "../performance.h" #include "../performance_counters.h" #include "../list_special.h" #include "../core.h" diff --git a/gfx/video_filter.c b/gfx/video_filter.c index 6cc8a2be7a..fe46697bce 100644 --- a/gfx/video_filter.c +++ b/gfx/video_filter.c @@ -19,12 +19,12 @@ #include #include #include -#include #include "../frontend/frontend_driver.h" #include "../config_file_userdata.h" #include "../dynamic.h" #include "../general.h" +#include "../performance.h" #include "../performance_counters.h" #include "../verbosity.h" #include "video_filter.h" diff --git a/gfx/video_thread_wrapper.c b/gfx/video_thread_wrapper.c index bbfc87d8fd..b4b8ca1155 100644 --- a/gfx/video_thread_wrapper.c +++ b/gfx/video_thread_wrapper.c @@ -19,11 +19,11 @@ #include #include -#include #include "video_thread_wrapper.h" #include "font_driver.h" #include "video_shader_driver.h" +#include "../performance.h" #include "../performance_counters.h" #include "../runloop.h" #include "../verbosity.h" diff --git a/griffin/griffin.c b/griffin/griffin.c index 735ea2f1fe..e483a0c10c 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -62,7 +62,7 @@ ENCODINGS /*============================================================ PERFORMANCE ============================================================ */ -#include "../libretro-common/features/cpu_features.c" +#include "../performance.c" #include "../performance_counters.c" /*============================================================ diff --git a/libretro-common/formats/jpeg/rjpeg.c b/libretro-common/formats/jpeg/rjpeg.c index e8e6f2701d..4d43a66c76 100644 --- a/libretro-common/formats/jpeg/rjpeg.c +++ b/libretro-common/formats/jpeg/rjpeg.c @@ -1,25 +1,3 @@ -/* Copyright (C) 2010-2016 The RetroArch team - * - * --------------------------------------------------------------------------------------- - * The following license statement only applies to this file (rjpeg.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. - */ - /* Modified version of stb_image's JPEG sources. */ diff --git a/libretro-common/include/formats/image.h b/libretro-common/include/formats/image.h index 00457cf2a5..1f96b81efd 100644 --- a/libretro-common/include/formats/image.h +++ b/libretro-common/include/formats/image.h @@ -1,23 +1,17 @@ -/* Copyright (C) 2010-2016 The RetroArch team +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2014 - Hans-Kristian Arntzen + * Copyright (C) 2011-2015 - 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. * - * --------------------------------------------------------------------------------------- - * The following license statement only applies to this file (image.h). - * --------------------------------------------------------------------------------------- + * 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. * - * 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. + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . */ #ifndef __RARCH_IMAGE_CONTEXT_H diff --git a/libretro-common/include/formats/jsonsax.h b/libretro-common/include/formats/jsonsax.h index 86d6d6b207..76860fe5f5 100644 --- a/libretro-common/include/formats/jsonsax.h +++ b/libretro-common/include/formats/jsonsax.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2016 The RetroArch team +/* Copyright (C) 2010-2015 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (jsonsax.h). diff --git a/libretro-common/include/formats/rjpeg.h b/libretro-common/include/formats/rjpeg.h index 81f61b92af..539fd058df 100644 --- a/libretro-common/include/formats/rjpeg.h +++ b/libretro-common/include/formats/rjpeg.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2016 The RetroArch team +/* Copyright (C) 2010-2015 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (rjpeg.h). diff --git a/libretro-common/include/formats/rpng.h b/libretro-common/include/formats/rpng.h index fa3f5d5bca..94db62932f 100644 --- a/libretro-common/include/formats/rpng.h +++ b/libretro-common/include/formats/rpng.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2016 The RetroArch team +/* Copyright (C) 2010-2015 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (rpng.h). diff --git a/libretro-common/include/formats/rxml.h b/libretro-common/include/formats/rxml.h index c3f3335c19..3ee1109601 100644 --- a/libretro-common/include/formats/rxml.h +++ b/libretro-common/include/formats/rxml.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2016 The RetroArch team +/* Copyright (C) 2010-2015 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (rxml.h). diff --git a/menu/drivers/menu_generic.c b/menu/drivers/menu_generic.c index 989d3b5727..c1bd67114d 100644 --- a/menu/drivers/menu_generic.c +++ b/menu/drivers/menu_generic.c @@ -18,8 +18,6 @@ #include #include -#include - #include "menu_generic.h" #include "../menu_driver.h" @@ -30,6 +28,7 @@ #include "../menu_entries.h" #include "../../configuration.h" +#include "../../performance.h" #include "../../performance_counters.h" #include "../../input/input_autodetect.h" #include "../../input/input_config.h" diff --git a/menu/menu_animation.c b/menu/menu_animation.c index a4c1efb0ce..db267ec8fb 100644 --- a/menu/menu_animation.c +++ b/menu/menu_animation.c @@ -16,14 +16,13 @@ #include #include - #include #include #include -#include #include "menu_animation.h" #include "../configuration.h" +#include "../performance.h" #include "../performance_counters.h" #define IDEAL_DELTA_TIME (1.0 / 60.0 * 1000000.0) diff --git a/menu/menu_input.c b/menu/menu_input.c index f1a5b66415..0025dd668d 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -27,8 +27,6 @@ #include #include -#include - #include "menu_driver.h" #include "menu_input.h" #include "menu_animation.h" @@ -41,6 +39,7 @@ #include "../general.h" #include "../managers/cheat_manager.h" +#include "../performance.h" #include "../performance_counters.h" #include "../core.h" #include "../input/input_joypad_driver.h" diff --git a/network/net_http_special.c b/network/net_http_special.c index 10ad9c15fe..2c488c614c 100644 --- a/network/net_http_special.c +++ b/network/net_http_special.c @@ -17,8 +17,8 @@ #include #include -#include +#include "../performance.h" #include "../performance_counters.h" #include "net_http_special.h" diff --git a/libretro-common/features/cpu_features.c b/performance.c similarity index 91% rename from libretro-common/features/cpu_features.c rename to performance.c index 94f5b73e79..b165192103 100644 --- a/libretro-common/features/cpu_features.c +++ b/performance.c @@ -1,29 +1,31 @@ -/* Copyright (C) 2010-2016 The RetroArch team +/* RetroArch - A frontend for libretro. + * Copyright (C) 2010-2014 - Hans-Kristian Arntzen + * Copyright (C) 2011-2016 - Daniel De Matteis * - * --------------------------------------------------------------------------------------- - * The following license statement only applies to this file (cpu_features.c). - * --------------------------------------------------------------------------------------- + * 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. * - * 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: + * 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. * - * 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. + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . */ #include +#include "libretro.h" +#include "performance.h" +#include "general.h" +#include "compat/strl.h" +#include "verbosity.h" -#include -#include +#ifdef _WIN32 +#define PERF_LOG_FMT "[PERF]: Avg (%s): %I64u ticks, %I64u runs.\n" +#else +#define PERF_LOG_FMT "[PERF]: Avg (%s): %llu ticks, %llu runs.\n" +#endif #if defined(_WIN32) #include diff --git a/libretro-common/include/features/cpu_features.h b/performance.h similarity index 56% rename from libretro-common/include/features/cpu_features.h rename to performance.h index dc8d091188..dac242511d 100644 --- a/libretro-common/include/features/cpu_features.h +++ b/performance.h @@ -1,23 +1,17 @@ -/* Copyright (C) 2010-2016 The RetroArch team +/* 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. * - * --------------------------------------------------------------------------------------- - * The following license statement only applies to this file (cpu_features.h). - * --------------------------------------------------------------------------------------- + * 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. * - * 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. + * You should have received a copy of the GNU General Public License along with RetroArch. + * If not, see . */ #ifndef _LIBRETRO_SDK_CPU_INFO_H diff --git a/performance_counters.c b/performance_counters.c index 2ac7ee2a72..209e6fb824 100644 --- a/performance_counters.c +++ b/performance_counters.c @@ -17,8 +17,7 @@ #include #include -#include - +#include "performance.h" #include "performance_counters.h" #include "general.h" diff --git a/retroarch.c b/retroarch.c index 70032242ec..e0f1cff51f 100644 --- a/retroarch.c +++ b/retroarch.c @@ -42,7 +42,6 @@ #include #include #include -#include #include "content.h" #include "core_type.h" @@ -59,6 +58,7 @@ #include "configuration.h" #include "general.h" #include "runloop.h" +#include "performance.h" #include "managers/cheat_manager.h" #include "system.h" diff --git a/runloop.c b/runloop.c index 03780d734b..63e4e2d889 100644 --- a/runloop.c +++ b/runloop.c @@ -23,7 +23,6 @@ #include #include #include -#include #include #ifdef HAVE_THREADS #include @@ -39,6 +38,7 @@ #include "autosave.h" #include "core_info.h" #include "configuration.h" +#include "performance.h" #include "movie.h" #include "retroarch.h" #include "runloop.h" From 16894e5a5aac869355077cbd8316c93b95ec6493 Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Tue, 10 May 2016 09:33:11 +0200 Subject: [PATCH 389/498] (Griffin) Buildfix --- griffin/griffin.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/griffin/griffin.c b/griffin/griffin.c index e483a0c10c..6fe88a87b8 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -803,7 +803,7 @@ NETPLAY DATA RUNLOOP ============================================================ */ #include "../tasks/task_content.c" -#include "../tasks/image.c" +#include "../tasks/task_image.c" #include "../tasks/task_file_transfer.c" #ifdef HAVE_ZLIB #include "../tasks/task_decompress.c" From 723463149eee2c8cf50afd188bcabd7704510c74 Mon Sep 17 00:00:00 2001 From: Andre Leiradella Date: Tue, 10 May 2016 08:04:41 -0300 Subject: [PATCH 390/498] implemented the RETRO_ENVIRONMENT_SET_MEMORY_MAPS callback --- dynamic.c | 36 ++++++++++++++++++++++++++++++++++++ runloop.c | 17 ++++++++++++----- system.h | 2 ++ 3 files changed, 50 insertions(+), 5 deletions(-) diff --git a/dynamic.c b/dynamic.c index e89bdfa18d..320bba474a 100644 --- a/dynamic.c +++ b/dynamic.c @@ -1213,6 +1213,42 @@ bool rarch_environment_cb(unsigned cmd, void *data) system->ports.size = i; break; } + + case RETRO_ENVIRONMENT_SET_MEMORY_MAPS: + { + unsigned i; + const struct retro_memory_map *mmaps = + (const struct retro_memory_map*)data; + + RARCH_LOG("Environ SET_MEMORY_MAPS.\n"); + RARCH_LOG(" flags ptr offset start select disconn len addrspace\n"); + + for (i = 0; i < mmaps->num_descriptors; i++) + { + const struct retro_memory_descriptor *desc = + &mmaps->descriptors[i]; + + RARCH_LOG("Memory map: %u\n", i + 1); + RARCH_LOG(" %08X %p %08X %08X %08X %08X %08X %s\n", + desc->flags, desc->ptr, desc->offset, desc->start, + desc->select, desc->disconnect, desc->len, + desc->addrspace ? desc->addrspace : ""); + } + + free((void*)system->mmaps.descriptors); + system->mmaps.num_descriptors = 0; + + system->mmaps.descriptors = (struct retro_memory_descriptor*) + calloc(mmaps->num_descriptors, sizeof(*system->mmaps.descriptors)); + + if (!system->mmaps.descriptors) + return false; + + memcpy((void*)system->mmaps.descriptors, mmaps->descriptors, + mmaps->num_descriptors * sizeof(*system->mmaps.descriptors)); + system->mmaps.num_descriptors = mmaps->num_descriptors; + break; + } case RETRO_ENVIRONMENT_SET_GEOMETRY: { diff --git a/runloop.c b/runloop.c index 63e4e2d889..7e42d10147 100644 --- a/runloop.c +++ b/runloop.c @@ -717,13 +717,20 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) if (runloop_system.subsystem.data) free(runloop_system.subsystem.data); runloop_system.subsystem.data = NULL; + runloop_system.subsystem.size = 0; + if (runloop_system.ports.data) free(runloop_system.ports.data); - runloop_system.subsystem.size = 0; - runloop_system.ports.data = NULL; - runloop_system.ports.size = 0; - runloop_key_event = NULL; - runloop_frontend_key_event = NULL; + runloop_system.ports.data = NULL; + runloop_system.ports.size = 0; + + if (runloop_system.mmaps.descriptors) + free((void *)runloop_system.mmaps.descriptors); + runloop_system.mmaps.descriptors = NULL; + runloop_system.mmaps.num_descriptors = 0; + + runloop_key_event = NULL; + runloop_frontend_key_event = NULL; audio_driver_unset_callback(); memset(&runloop_system, 0, sizeof(rarch_system_info_t)); diff --git a/system.h b/system.h index a878b1d624..ad7f656789 100644 --- a/system.h +++ b/system.h @@ -54,6 +54,8 @@ typedef struct rarch_system_info struct retro_controller_info *data; unsigned size; } ports; + + struct retro_memory_map mmaps; } rarch_system_info_t; #ifdef __cplusplus From 9f4a308c1a4be7e5b25a3d3c78953a89ff95435a Mon Sep 17 00:00:00 2001 From: Andre Leiradella Date: Tue, 10 May 2016 08:55:10 -0300 Subject: [PATCH 391/498] better mmap flag visualization --- dynamic.c | 35 ++++++++++++++++++++++++++++++++--- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/dynamic.c b/dynamic.c index 320bba474a..3110320469 100644 --- a/dynamic.c +++ b/dynamic.c @@ -1221,16 +1221,45 @@ bool rarch_environment_cb(unsigned cmd, void *data) (const struct retro_memory_map*)data; RARCH_LOG("Environ SET_MEMORY_MAPS.\n"); - RARCH_LOG(" flags ptr offset start select disconn len addrspace\n"); + + if (sizeof(void *) == 8) + RARCH_LOG(" flags ptr offset start select disconn len addrspace\n"); + else + RARCH_LOG(" flags ptr offset start select disconn len addrspace\n"); for (i = 0; i < mmaps->num_descriptors; i++) { const struct retro_memory_descriptor *desc = &mmaps->descriptors[i]; + char flags[7]; + + flags[0] = 'M'; + if ((desc->flags & RETRO_MEMDESC_MINSIZE_8) == RETRO_MEMDESC_MINSIZE_8) + flags[1] = '8'; + else if ((desc->flags & RETRO_MEMDESC_MINSIZE_4) == RETRO_MEMDESC_MINSIZE_4) + flags[1] = '4'; + else if ((desc->flags & RETRO_MEMDESC_MINSIZE_2) == RETRO_MEMDESC_MINSIZE_2) + flags[1] = '2'; + else + flags[1] = '1'; + + flags[2] = 'A'; + if ((desc->flags & RETRO_MEMDESC_ALIGN_8) == RETRO_MEMDESC_ALIGN_8) + flags[3] = '8'; + else if ((desc->flags & RETRO_MEMDESC_ALIGN_4) == RETRO_MEMDESC_ALIGN_4) + flags[3] = '4'; + else if ((desc->flags & RETRO_MEMDESC_ALIGN_2) == RETRO_MEMDESC_ALIGN_2) + flags[3] = '2'; + else + flags[3] = '1'; + + flags[4] = (desc->flags & RETRO_MEMDESC_BIGENDIAN) ? 'B' : 'b'; + flags[5] = (desc->flags & RETRO_MEMDESC_CONST) ? 'C' : 'c'; + flags[6] = 0; RARCH_LOG("Memory map: %u\n", i + 1); - RARCH_LOG(" %08X %p %08X %08X %08X %08X %08X %s\n", - desc->flags, desc->ptr, desc->offset, desc->start, + RARCH_LOG(" %s %p %08X %08X %08X %08X %08X %s\n", + flags, desc->ptr, desc->offset, desc->start, desc->select, desc->disconnect, desc->len, desc->addrspace ? desc->addrspace : ""); } From 7a0ff5911dab7796580f669ca92030e338eaf35c Mon Sep 17 00:00:00 2001 From: Alcaro Date: Tue, 10 May 2016 18:34:46 +0200 Subject: [PATCH 392/498] Fix #2897 --- deps/spir2cross | 1 - 1 file changed, 1 deletion(-) delete mode 160000 deps/spir2cross diff --git a/deps/spir2cross b/deps/spir2cross deleted file mode 160000 index 0ae2bcc3d0..0000000000 --- a/deps/spir2cross +++ /dev/null @@ -1 +0,0 @@ -Subproject commit 0ae2bcc3d0edc60e03180f6080a168f78edc82ca From f49dcd07391c1ec6227964f00ea9e654d96500d8 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 May 2016 18:43:23 +0200 Subject: [PATCH 393/498] (performance.c ) Cleanups --- performance.c | 118 +++++++++++++++++++++++--------------------------- performance.h | 22 ---------- 2 files changed, 55 insertions(+), 85 deletions(-) diff --git a/performance.c b/performance.c index b165192103..15eac5fdfb 100644 --- a/performance.c +++ b/performance.c @@ -16,16 +16,6 @@ #include #include "libretro.h" -#include "performance.h" -#include "general.h" -#include "compat/strl.h" -#include "verbosity.h" - -#ifdef _WIN32 -#define PERF_LOG_FMT "[PERF]: Avg (%s): %I64u ticks, %I64u runs.\n" -#else -#define PERF_LOG_FMT "[PERF]: Avg (%s): %llu ticks, %llu runs.\n" -#endif #if defined(_WIN32) #include @@ -33,6 +23,8 @@ #include #endif +#include + #if defined(_WIN32) && !defined(_XBOX) #include #include @@ -387,53 +379,53 @@ uint64_t cpu_features_get(void) len = sizeof(size_t); if (sysctlbyname("hw.optional.mmx", NULL, &len, NULL, 0) == 0) { - cpu |= CPU_FEATURE_MMX; - cpu |= CPU_FEATURE_MMXEXT; + cpu |= RETRO_SIMD_MMX; + cpu |= RETRO_SIMD_MMXEXT; } len = sizeof(size_t); if (sysctlbyname("hw.optional.sse", NULL, &len, NULL, 0) == 0) - cpu |= CPU_FEATURE_SSE; + cpu |= RETRO_SIMD_SSE; len = sizeof(size_t); if (sysctlbyname("hw.optional.sse2", NULL, &len, NULL, 0) == 0) - cpu |= CPU_FEATURE_SSE2; + cpu |= RETRO_SIMD_SSE2; len = sizeof(size_t); if (sysctlbyname("hw.optional.sse3", NULL, &len, NULL, 0) == 0) - cpu |= CPU_FEATURE_SSE3; + cpu |= RETRO_SIMD_SSE3; len = sizeof(size_t); if (sysctlbyname("hw.optional.supplementalsse3", NULL, &len, NULL, 0) == 0) - cpu |= CPU_FEATURE_SSSE3; + cpu |= RETRO_SIMD_SSSE3; len = sizeof(size_t); if (sysctlbyname("hw.optional.sse4_1", NULL, &len, NULL, 0) == 0) - cpu |= CPU_FEATURE_SSE4; + cpu |= RETRO_SIMD_SSE4; len = sizeof(size_t); if (sysctlbyname("hw.optional.sse4_2", NULL, &len, NULL, 0) == 0) - cpu |= CPU_FEATURE_SSE42; + cpu |= RETRO_SIMD_SSE42; len = sizeof(size_t); if (sysctlbyname("hw.optional.aes", NULL, &len, NULL, 0) == 0) - cpu |= CPU_FEATURE_AES; + cpu |= RETRO_SIMD_AES; len = sizeof(size_t); if (sysctlbyname("hw.optional.avx1_0", NULL, &len, NULL, 0) == 0) - cpu |= CPU_FEATURE_AVX; + cpu |= RETRO_SIMD_AVX; len = sizeof(size_t); if (sysctlbyname("hw.optional.avx2_0", NULL, &len, NULL, 0) == 0) - cpu |= CPU_FEATURE_AVX2; + cpu |= RETRO_SIMD_AVX2; len = sizeof(size_t); if (sysctlbyname("hw.optional.altivec", NULL, &len, NULL, 0) == 0) - cpu |= CPU_FEATURE_VMX; + cpu |= RETRO_SIMD_VMX; len = sizeof(size_t); if (sysctlbyname("hw.optional.neon", NULL, &len, NULL, 0) == 0) - cpu |= CPU_FEATURE_NEON; + cpu |= RETRO_SIMD_NEON; #elif defined(CPU_X86) (void)avx_flags; @@ -458,52 +450,52 @@ uint64_t cpu_features_get(void) x86_cpuid(1, flags); if (flags[3] & (1 << 23)) - cpu |= CPU_FEATURE_MMX; + cpu |= RETRO_SIMD_MMX; if (flags[3] & (1 << 25)) { /* SSE also implies MMXEXT (according to FFmpeg source). */ - cpu |= CPU_FEATURE_SSE; - cpu |= CPU_FEATURE_MMXEXT; + cpu |= RETRO_SIMD_SSE; + cpu |= RETRO_SIMD_MMXEXT; } if (flags[3] & (1 << 26)) - cpu |= CPU_FEATURE_SSE2; + cpu |= RETRO_SIMD_SSE2; if (flags[2] & (1 << 0)) - cpu |= CPU_FEATURE_SSE3; + cpu |= RETRO_SIMD_SSE3; if (flags[2] & (1 << 9)) - cpu |= CPU_FEATURE_SSSE3; + cpu |= RETRO_SIMD_SSSE3; if (flags[2] & (1 << 19)) - cpu |= CPU_FEATURE_SSE4; + cpu |= RETRO_SIMD_SSE4; if (flags[2] & (1 << 20)) - cpu |= CPU_FEATURE_SSE42; + cpu |= RETRO_SIMD_SSE42; if ((flags[2] & (1 << 23))) - cpu |= CPU_FEATURE_POPCNT; + cpu |= RETRO_SIMD_POPCNT; if (vendor_is_intel && (flags[2] & (1 << 22))) - cpu |= CPU_FEATURE_MOVBE; + cpu |= RETRO_SIMD_MOVBE; if (flags[2] & (1 << 25)) - cpu |= CPU_FEATURE_AES; + cpu |= RETRO_SIMD_AES; /* Must only perform xgetbv check if we have * AVX CPU support (guaranteed to have at least i686). */ if (((flags[2] & avx_flags) == avx_flags) && ((xgetbv_x86(0) & 0x6) == 0x6)) - cpu |= CPU_FEATURE_AVX; + cpu |= RETRO_SIMD_AVX; if (max_flag >= 7) { x86_cpuid(7, flags); if (flags[1] & (1 << 5)) - cpu |= CPU_FEATURE_AVX2; + cpu |= RETRO_SIMD_AVX2; } x86_cpuid(0x80000000, flags); @@ -512,55 +504,55 @@ uint64_t cpu_features_get(void) { x86_cpuid(0x80000001, flags); if (flags[3] & (1 << 23)) - cpu |= CPU_FEATURE_MMX; + cpu |= RETRO_SIMD_MMX; if (flags[3] & (1 << 22)) - cpu |= CPU_FEATURE_MMXEXT; + cpu |= RETRO_SIMD_MMXEXT; } #elif defined(__linux__) cpu_flags = linux_get_cpu_features(); if (cpu_flags & CPU_ARM_FEATURE_NEON) { - cpu |= CPU_FEATURE_NEON; + cpu |= RETRO_SIMD_NEON; #ifdef __ARM_NEON__ arm_enable_runfast_mode(); #endif } if (cpu_flags & CPU_ARM_FEATURE_VFPv3) - cpu |= CPU_FEATURE_VFPV3; + cpu |= RETRO_SIMD_VFPV3; #elif defined(__ARM_NEON__) - cpu |= CPU_FEATURE_NEON; + cpu |= RETRO_SIMD_NEON; arm_enable_runfast_mode(); #elif defined(__ALTIVEC__) - cpu |= CPU_FEATURE_VMX; + cpu |= RETRO_SIMD_VMX; #elif defined(XBOX360) - cpu |= CPU_FEATURE_VMX128; + cpu |= RETRO_SIMD_VMX128; #elif defined(PSP) - cpu |= CPU_FEATURE_VFPU; + cpu |= RETRO_SIMD_VFPU; #elif defined(GEKKO) - cpu |= CPU_FEATURE_PS; + cpu |= RETRO_SIMD_PS; #endif - if (cpu & CPU_FEATURE_MMX) strlcat(buf, " MMX", sizeof(buf)); - if (cpu & CPU_FEATURE_MMXEXT) strlcat(buf, " MMXEXT", sizeof(buf)); - if (cpu & CPU_FEATURE_SSE) strlcat(buf, " SSE", sizeof(buf)); - if (cpu & CPU_FEATURE_SSE2) strlcat(buf, " SSE2", sizeof(buf)); - if (cpu & CPU_FEATURE_SSE3) strlcat(buf, " SSE3", sizeof(buf)); - if (cpu & CPU_FEATURE_SSSE3) strlcat(buf, " SSSE3", sizeof(buf)); - if (cpu & CPU_FEATURE_SSE4) strlcat(buf, " SSE4", sizeof(buf)); - if (cpu & CPU_FEATURE_SSE42) strlcat(buf, " SSE4.2", sizeof(buf)); - if (cpu & CPU_FEATURE_AES) strlcat(buf, " AES", sizeof(buf)); - if (cpu & CPU_FEATURE_AVX) strlcat(buf, " AVX", sizeof(buf)); - if (cpu & CPU_FEATURE_AVX2) strlcat(buf, " AVX2", sizeof(buf)); - if (cpu & CPU_FEATURE_NEON) strlcat(buf, " NEON", sizeof(buf)); - if (cpu & CPU_FEATURE_VFPV3) strlcat(buf, " VFPv3", sizeof(buf)); - if (cpu & CPU_FEATURE_VFPV4) strlcat(buf, " VFPv4", sizeof(buf)); - if (cpu & CPU_FEATURE_VMX) strlcat(buf, " VMX", sizeof(buf)); - if (cpu & CPU_FEATURE_VMX128) strlcat(buf, " VMX128", sizeof(buf)); - if (cpu & CPU_FEATURE_VFPU) strlcat(buf, " VFPU", sizeof(buf)); - if (cpu & CPU_FEATURE_PS) strlcat(buf, " PS", sizeof(buf)); + if (cpu & RETRO_SIMD_MMX) strlcat(buf, " MMX", sizeof(buf)); + if (cpu & RETRO_SIMD_MMXEXT) strlcat(buf, " MMXEXT", sizeof(buf)); + if (cpu & RETRO_SIMD_SSE) strlcat(buf, " SSE", sizeof(buf)); + if (cpu & RETRO_SIMD_SSE2) strlcat(buf, " SSE2", sizeof(buf)); + if (cpu & RETRO_SIMD_SSE3) strlcat(buf, " SSE3", sizeof(buf)); + if (cpu & RETRO_SIMD_SSSE3) strlcat(buf, " SSSE3", sizeof(buf)); + if (cpu & RETRO_SIMD_SSE4) strlcat(buf, " SSE4", sizeof(buf)); + if (cpu & RETRO_SIMD_SSE42) strlcat(buf, " SSE4.2", sizeof(buf)); + if (cpu & RETRO_SIMD_AES) strlcat(buf, " AES", sizeof(buf)); + if (cpu & RETRO_SIMD_AVX) strlcat(buf, " AVX", sizeof(buf)); + if (cpu & RETRO_SIMD_AVX2) strlcat(buf, " AVX2", sizeof(buf)); + if (cpu & RETRO_SIMD_NEON) strlcat(buf, " NEON", sizeof(buf)); + if (cpu & RETRO_SIMD_VFPV3) strlcat(buf, " VFPv3", sizeof(buf)); + if (cpu & RETRO_SIMD_VFPV4) strlcat(buf, " VFPv4", sizeof(buf)); + if (cpu & RETRO_SIMD_VMX) strlcat(buf, " VMX", sizeof(buf)); + if (cpu & RETRO_SIMD_VMX128) strlcat(buf, " VMX128", sizeof(buf)); + if (cpu & RETRO_SIMD_VFPU) strlcat(buf, " VFPU", sizeof(buf)); + if (cpu & RETRO_SIMD_PS) strlcat(buf, " PS", sizeof(buf)); return cpu; } diff --git a/performance.h b/performance.h index dac242511d..c3ea91d859 100644 --- a/performance.h +++ b/performance.h @@ -26,28 +26,6 @@ typedef uint64_t retro_perf_tick_t; typedef uint64_t retro_time_t; #endif -/* ID values for CPU features */ -#define CPU_FEATURE_SSE (1 << 0) -#define CPU_FEATURE_SSE2 (1 << 1) -#define CPU_FEATURE_VMX (1 << 2) -#define CPU_FEATURE_VMX128 (1 << 3) -#define CPU_FEATURE_AVX (1 << 4) -#define CPU_FEATURE_NEON (1 << 5) -#define CPU_FEATURE_SSE3 (1 << 6) -#define CPU_FEATURE_SSSE3 (1 << 7) -#define CPU_FEATURE_MMX (1 << 8) -#define CPU_FEATURE_MMXEXT (1 << 9) -#define CPU_FEATURE_SSE4 (1 << 10) -#define CPU_FEATURE_SSE42 (1 << 11) -#define CPU_FEATURE_AVX2 (1 << 12) -#define CPU_FEATURE_VFPU (1 << 13) -#define CPU_FEATURE_PS (1 << 14) -#define CPU_FEATURE_AES (1 << 15) -#define CPU_FEATURE_VFPV3 (1 << 16) -#define CPU_FEATURE_VFPV4 (1 << 17) -#define CPU_FEATURE_POPCNT (1 << 18) -#define CPU_FEATURE_MOVBE (1 << 19) - #ifdef __cplusplus extern "C" { #endif From 4a7ab8366b631ff5e167f8037469806df66050bb Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 May 2016 19:03:53 +0200 Subject: [PATCH 394/498] Move libretro.h headers to libretro-common/include --- audio/audio_resampler_driver.h | 9 +++---- camera/camera_driver.h | 3 ++- cheevos.c | 2 +- core.h | 2 +- core_impl.c | 2 +- cores/dynamic_dummy.c | 3 ++- cores/internal_cores.h | 2 +- cores/libretro-ffmpeg/ffmpeg_core.c | 2 +- cores/libretro-ffmpeg/libretro.h | 1 - cores/libretro-imageviewer/image_core.c | 4 +-- .../libretro-test-gl-ff/libretro_gl_ff_test.c | 2 +- cores/libretro-test-gl/libretro_gl_test.c | 2 +- cores/libretro-test/libretro-test.c | 2 +- cores/retropad/retropad.c | 2 +- dynamic.h | 2 +- gfx/common/vulkan_common.h | 5 ++-- gfx/d3d/render_chain_driver.h | 3 ++- gfx/drivers/gl.c | 2 +- gfx/drivers/vg.c | 2 +- gfx/drivers/vulkan.c | 27 ++++++++++--------- gfx/video_driver.h | 2 +- gfx/video_filter.h | 3 ++- gfx/video_state_python.c | 6 +++-- input/common/input_x11_common.c | 3 ++- input/connect/joypad_connection.h | 2 +- input/drivers/ctr_input.c | 3 ++- input/drivers/gx_input.c | 3 ++- input/drivers/ps3_input.c | 6 ++--- input/drivers/psp_input.c | 6 ++--- input/drivers/sdl_input.c | 2 +- input/drivers/xdk_xinput_input.c | 6 ++--- input/drivers/xenon360_input.c | 7 ++--- input/input_hid_driver.h | 2 +- input/input_joypad_driver.h | 3 +-- input/input_keyboard.h | 3 +-- input/input_keymaps.h | 2 +- .../include/libretro.h | 0 .../include/libretro_vulkan.h | 2 +- managers/core_option_manager.c | 2 +- network/net_http_special.h | 2 +- network/netplay.h | 2 +- performance.c | 3 ++- performance.h | 7 +---- performance_counters.h | 2 +- system.h | 2 +- 45 files changed, 81 insertions(+), 79 deletions(-) delete mode 100644 cores/libretro-ffmpeg/libretro.h rename libretro.h => libretro-common/include/libretro.h (100%) rename libretro_vulkan.h => libretro-common/include/libretro_vulkan.h (99%) diff --git a/audio/audio_resampler_driver.h b/audio/audio_resampler_driver.h index 0b1224a795..ca89c42fec 100644 --- a/audio/audio_resampler_driver.h +++ b/audio/audio_resampler_driver.h @@ -22,12 +22,13 @@ extern "C" { #endif -#include #include +#include #include -#include #include +#include +#include #define RESAMPLER_SIMD_SSE (1 << 0) #define RESAMPLER_SIMD_SSE2 (1 << 1) @@ -200,10 +201,6 @@ bool rarch_resampler_realloc(void **re, const rarch_resampler_t **backend, (backend)->process(handle, data); \ } while(0) -#ifndef RARCH_INTERNAL -#include "libretro.h" -extern retro_get_cpu_features_t perf_get_cpu_features_cb; -#endif #ifdef __cplusplus } diff --git a/camera/camera_driver.h b/camera/camera_driver.h index 5a767df5a6..bfd6f6bf18 100644 --- a/camera/camera_driver.h +++ b/camera/camera_driver.h @@ -18,8 +18,9 @@ #define __CAMERA_DRIVER__H #include + #include -#include "../libretro.h" +#include #ifdef __cplusplus extern "C" { diff --git a/cheevos.c b/cheevos.c index 9eba3219d2..ff3f473944 100644 --- a/cheevos.c +++ b/cheevos.c @@ -20,10 +20,10 @@ #include #include #include +#include #include "cheevos.h" #include "dynamic.h" -#include "libretro.h" #include "network/net_http_special.h" #include "configuration.h" #include "performance_counters.h" diff --git a/core.h b/core.h index 2866e3abcc..d969e82138 100644 --- a/core.h +++ b/core.h @@ -23,9 +23,9 @@ extern "C" { #endif #include +#include #include "core_type.h" -#include "libretro.h" enum { diff --git a/core_impl.c b/core_impl.c index 163ed55396..2c3d365418 100644 --- a/core_impl.c +++ b/core_impl.c @@ -24,9 +24,9 @@ #include #include #include +#include #include "dynamic.h" -#include "libretro.h" #include "core.h" #include "general.h" #include "msg_hash.h" diff --git a/cores/dynamic_dummy.c b/cores/dynamic_dummy.c index ffcdf493a0..53efa0b90a 100644 --- a/cores/dynamic_dummy.c +++ b/cores/dynamic_dummy.c @@ -19,8 +19,9 @@ #include #include +#include + #include "internal_cores.h" -#include "../libretro.h" static uint16_t *frame_buf; diff --git a/cores/internal_cores.h b/cores/internal_cores.h index 60fbb49417..22d25e18aa 100644 --- a/cores/internal_cores.h +++ b/cores/internal_cores.h @@ -19,7 +19,7 @@ #define INTERNAL_CORES_H__ #include -#include "../libretro.h" +#include void libretro_dummy_retro_init(void); diff --git a/cores/libretro-ffmpeg/ffmpeg_core.c b/cores/libretro-ffmpeg/ffmpeg_core.c index 799f54c016..9e56232ae9 100644 --- a/cores/libretro-ffmpeg/ffmpeg_core.c +++ b/cores/libretro-ffmpeg/ffmpeg_core.c @@ -42,7 +42,7 @@ extern "C" { #include #include -#include "libretro.h" +#include #ifdef RARCH_INTERNAL #include "internal_cores.h" #define CORE_PREFIX(s) libretro_ffmpeg_##s diff --git a/cores/libretro-ffmpeg/libretro.h b/cores/libretro-ffmpeg/libretro.h deleted file mode 100644 index 5ed9e5c181..0000000000 --- a/cores/libretro-ffmpeg/libretro.h +++ /dev/null @@ -1 +0,0 @@ -#include "../../libretro.h" diff --git a/cores/libretro-imageviewer/image_core.c b/cores/libretro-imageviewer/image_core.c index 771776e0f5..2a4d168fe0 100644 --- a/cores/libretro-imageviewer/image_core.c +++ b/cores/libretro-imageviewer/image_core.c @@ -22,12 +22,12 @@ #include "../../deps/stb/stb_image.h" +#include + #ifdef RARCH_INTERNAL #include "internal_cores.h" -#include "../../libretro.h" #define IMAGE_CORE_PREFIX(s) libretro_imageviewer_##s #else -#include "libretro.h" #define IMAGE_CORE_PREFIX(s) s #endif diff --git a/cores/libretro-test-gl-ff/libretro_gl_ff_test.c b/cores/libretro-test-gl-ff/libretro_gl_ff_test.c index f9e6d4ce6d..a0f1ee215f 100644 --- a/cores/libretro-test-gl-ff/libretro_gl_ff_test.c +++ b/cores/libretro-test-gl-ff/libretro_gl_ff_test.c @@ -6,7 +6,7 @@ #include -#include "../../libretro.h" +#include #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) static struct retro_hw_render_callback hw_render; diff --git a/cores/libretro-test-gl/libretro_gl_test.c b/cores/libretro-test-gl/libretro_gl_test.c index 139d87ae14..b995d691d9 100644 --- a/cores/libretro-test-gl/libretro_gl_test.c +++ b/cores/libretro-test-gl/libretro_gl_test.c @@ -6,7 +6,7 @@ #include -#include "../../libretro.h" +#include #define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) static struct retro_hw_render_callback hw_render; diff --git a/cores/libretro-test/libretro-test.c b/cores/libretro-test/libretro-test.c index bc7e592399..3eccfc83c6 100644 --- a/cores/libretro-test/libretro-test.c +++ b/cores/libretro-test/libretro-test.c @@ -7,7 +7,7 @@ #include -#include "../../libretro.h" +#include static uint32_t *frame_buf; static struct retro_log_callback logging; diff --git a/cores/retropad/retropad.c b/cores/retropad/retropad.c index 608866b57d..6edc342820 100644 --- a/cores/retropad/retropad.c +++ b/cores/retropad/retropad.c @@ -40,7 +40,7 @@ #include -#include "../../libretro.h" +#include #ifndef SOCKET_ERROR #define SOCKET_ERROR -1 diff --git a/dynamic.h b/dynamic.h index f072f78a7a..4fe1152614 100644 --- a/dynamic.h +++ b/dynamic.h @@ -18,9 +18,9 @@ #define __DYNAMIC_H #include +#include #include "core_type.h" -#include "libretro.h" #ifdef HAVE_CONFIG_H #include "config.h" diff --git a/gfx/common/vulkan_common.h b/gfx/common/vulkan_common.h index 6afaa53178..13d0f0b6d9 100644 --- a/gfx/common/vulkan_common.h +++ b/gfx/common/vulkan_common.h @@ -38,13 +38,14 @@ #include #include +#include +#include + #include "../../driver.h" -#include "../../libretro.h" #include "../../general.h" #include "../../retroarch.h" #include "../font_driver.h" #include "../video_context_driver.h" -#include "../../libretro_vulkan.h" #include "../drivers_shader/shader_vulkan.h" typedef struct vulkan_filter_chain vulkan_filter_chain_t; diff --git a/gfx/d3d/render_chain_driver.h b/gfx/d3d/render_chain_driver.h index 498f0000b4..7ccb55be87 100644 --- a/gfx/d3d/render_chain_driver.h +++ b/gfx/d3d/render_chain_driver.h @@ -17,10 +17,11 @@ #ifndef __D3D_RENDER_CHAIN_H #define __D3D_RENDER_CHAIN_H +#include + #include "../video_driver.h" #include "../video_shader_parse.h" #include "../video_state_tracker.h" -#include "../../libretro.h" #include "../../defines/d3d_defines.h" #ifdef __cplusplus diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index f3d240fa52..7f0fe2f7c2 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -31,12 +31,12 @@ #include #include #include +#include #include "../../driver.h" #include "../../record/record_driver.h" #include "../../performance_counters.h" -#include "../../libretro.h" #include "../../general.h" #include "../../retroarch.h" #include "../../verbosity.h" diff --git a/gfx/drivers/vg.c b/gfx/drivers/vg.c index 73527ff83c..f7413a50ac 100644 --- a/gfx/drivers/vg.c +++ b/gfx/drivers/vg.c @@ -24,9 +24,9 @@ #include #include #include +#include #include "../video_context_driver.h" -#include "../../libretro.h" #include "../../general.h" #include "../../retroarch.h" #include "../../driver.h" diff --git a/gfx/drivers/vulkan.c b/gfx/drivers/vulkan.c index 1147badfa2..7975eddfcb 100644 --- a/gfx/drivers/vulkan.c +++ b/gfx/drivers/vulkan.c @@ -13,6 +13,20 @@ * If not, see . */ +#include +#include +#include +#include + + +#include +#include +#include +#include +#include +#include +#include + #include "../common/vulkan_common.h" #include "vulkan_shaders/alpha_blend.vert.inc" #include "vulkan_shaders/alpha_blend.frag.inc" @@ -22,23 +36,10 @@ #include "vulkan_shaders/ribbon_simple.vert.inc" #include "vulkan_shaders/ribbon_simple.frag.inc" -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include - #include "../../driver.h" #include "../../record/record_driver.h" #include "../../performance_counters.h" -#include "../../libretro.h" #include "../../general.h" #include "../../retroarch.h" diff --git a/gfx/video_driver.h b/gfx/video_driver.h index 450f3b2782..93b5a13c68 100644 --- a/gfx/video_driver.h +++ b/gfx/video_driver.h @@ -22,12 +22,12 @@ #include #include +#include #include "font_driver.h" #include "video_filter.h" #include "video_shader_parse.h" -#include "../libretro.h" #include "../input/input_driver.h" diff --git a/gfx/video_filter.h b/gfx/video_filter.h index 7f12f92b55..d8af27ad47 100644 --- a/gfx/video_filter.h +++ b/gfx/video_filter.h @@ -17,9 +17,10 @@ #ifndef RARCH_FILTER_H__ #define RARCH_FILTER_H__ -#include "../libretro.h" #include +#include + #define RARCH_SOFTFILTER_THREADS_AUTO 0 typedef struct rarch_softfilter rarch_softfilter_t; diff --git a/gfx/video_state_python.c b/gfx/video_state_python.c index 2ad9fd1dd7..08c2d0dc67 100644 --- a/gfx/video_state_python.c +++ b/gfx/video_state_python.c @@ -14,18 +14,20 @@ * If not, see . */ -#include #include #include #include +#include + #include #include #include +#include + #include "video_state_python.h" #include "../dynamic.h" -#include "../libretro.h" #include "../core.h" #include "../general.h" #include "../verbosity.h" diff --git a/input/common/input_x11_common.c b/input/common/input_x11_common.c index 087bc3a8aa..1e028ad8bb 100644 --- a/input/common/input_x11_common.c +++ b/input/common/input_x11_common.c @@ -14,8 +14,9 @@ * If not, see . */ +#include + #include "input_x11_common.h" -#include "../../libretro.h" static bool x11_mouse_wu; static bool x11_mouse_wd; diff --git a/input/connect/joypad_connection.h b/input/connect/joypad_connection.h index 1e0e270505..1b5c70d768 100644 --- a/input/connect/joypad_connection.h +++ b/input/connect/joypad_connection.h @@ -20,7 +20,7 @@ #include #include -#include "../../libretro.h" +#include typedef void (*send_control_t)(void *data, uint8_t *buf, size_t size); diff --git a/input/drivers/ctr_input.c b/input/drivers/ctr_input.c index b44b1906a2..cc37474e85 100644 --- a/input/drivers/ctr_input.c +++ b/input/drivers/ctr_input.c @@ -15,10 +15,11 @@ #include #include + #include +#include #include "../../driver.h" -#include "../../libretro.h" #include "../../general.h" #include "../input_config.h" #include "../input_joypad_driver.h" diff --git a/input/drivers/gx_input.c b/input/drivers/gx_input.c index c280873b33..6962795464 100644 --- a/input/drivers/gx_input.c +++ b/input/drivers/gx_input.c @@ -23,8 +23,9 @@ #include #include +#include + #include "../../driver.h" -#include "../../libretro.h" #ifndef MAX_PADS #define MAX_PADS 4 diff --git a/input/drivers/ps3_input.c b/input/drivers/ps3_input.c index 58a0325b93..2cfba27289 100644 --- a/input/drivers/ps3_input.c +++ b/input/drivers/ps3_input.c @@ -17,14 +17,14 @@ #include #include -#include - #include +#include +#include + #include "../../defines/ps3_defines.h" #include "../../driver.h" -#include "../../libretro.h" #include "../../general.h" #ifdef HAVE_MOUSE diff --git a/input/drivers/psp_input.c b/input/drivers/psp_input.c index a832cb80e7..d9fcccfc55 100644 --- a/input/drivers/psp_input.c +++ b/input/drivers/psp_input.c @@ -17,8 +17,6 @@ #include #include -#include - #if defined(SN_TARGET_PSP2) #include #include @@ -29,10 +27,12 @@ #include #endif +#include +#include + #include "../../defines/psp_defines.h" #include "../../driver.h" -#include "../../libretro.h" #include "../../general.h" #include "../input_config.h" #ifdef HAVE_KERNEL_PRX diff --git a/input/drivers/sdl_input.c b/input/drivers/sdl_input.c index c07ac18470..3ad5bfa4c8 100644 --- a/input/drivers/sdl_input.c +++ b/input/drivers/sdl_input.c @@ -19,6 +19,7 @@ #include #include +#include #include "../../driver.h" @@ -26,7 +27,6 @@ #include "../../gfx/video_context_driver.h" #include "../../general.h" #include "../../verbosity.h" -#include "../../libretro.h" #include "../input_autodetect.h" #include "../input_config.h" #include "../input_joypad_driver.h" diff --git a/input/drivers/xdk_xinput_input.c b/input/drivers/xdk_xinput_input.c index 7ae411debb..aa7f7d1ae4 100644 --- a/input/drivers/xdk_xinput_input.c +++ b/input/drivers/xdk_xinput_input.c @@ -17,15 +17,15 @@ #include #include -#include - #ifdef _XBOX #include #endif +#include +#include + #include "../../driver.h" #include "../../general.h" -#include "../../libretro.h" #define MAX_PADS 4 diff --git a/input/drivers/xenon360_input.c b/input/drivers/xenon360_input.c index 438d6e1e48..cce53c6c68 100644 --- a/input/drivers/xenon360_input.c +++ b/input/drivers/xenon360_input.c @@ -18,12 +18,13 @@ #include #include -#include "../../driver.h" -#include "../../libretro.h" - #include #include +#include + +#include "../../driver.h" + #define MAX_PADS 4 static uint64_t state[MAX_PADS]; diff --git a/input/input_hid_driver.h b/input/input_hid_driver.h index cc77346afd..2a48c67816 100644 --- a/input/input_hid_driver.h +++ b/input/input_hid_driver.h @@ -24,7 +24,7 @@ extern "C" { #include #include -#include "../libretro.h" +#include typedef struct hid_driver hid_driver_t; diff --git a/input/input_joypad_driver.h b/input/input_joypad_driver.h index 1e1a5edca6..ef6d949dbf 100644 --- a/input/input_joypad_driver.h +++ b/input/input_joypad_driver.h @@ -23,8 +23,7 @@ extern "C" { #include #include - -#include "../libretro.h" +#include typedef struct rarch_joypad_driver input_device_driver_t; diff --git a/input/input_keyboard.h b/input/input_keyboard.h index 50bf53f602..d662ef3042 100644 --- a/input/input_keyboard.h +++ b/input/input_keyboard.h @@ -24,8 +24,7 @@ extern "C" { #include #include - -#include "../libretro.h" +#include enum rarch_input_keyboard_ctl_state { diff --git a/input/input_keymaps.h b/input/input_keymaps.h index 967f444bde..6a99c17ed1 100644 --- a/input/input_keymaps.h +++ b/input/input_keymaps.h @@ -19,7 +19,7 @@ #include -#include "../libretro.h" +#include #ifdef __cplusplus extern "C" { diff --git a/libretro.h b/libretro-common/include/libretro.h similarity index 100% rename from libretro.h rename to libretro-common/include/libretro.h diff --git a/libretro_vulkan.h b/libretro-common/include/libretro_vulkan.h similarity index 99% rename from libretro_vulkan.h rename to libretro-common/include/libretro_vulkan.h index 01e310bc7b..55375e1399 100644 --- a/libretro_vulkan.h +++ b/libretro-common/include/libretro_vulkan.h @@ -23,7 +23,7 @@ #ifndef LIBRETRO_VULKAN_H__ #define LIBRETRO_VULKAN_H__ -#include "libretro.h" +#include #include #define RETRO_HW_RENDER_INTERFACE_VULKAN_VERSION 2 diff --git a/managers/core_option_manager.c b/managers/core_option_manager.c index 466f10352d..f5075a9365 100644 --- a/managers/core_option_manager.c +++ b/managers/core_option_manager.c @@ -24,7 +24,7 @@ #include #include -#include "../libretro.h" +#include #include "core_option_manager.h" diff --git a/network/net_http_special.h b/network/net_http_special.h index de8c305153..6fa1af0fa8 100644 --- a/network/net_http_special.h +++ b/network/net_http_special.h @@ -17,7 +17,7 @@ #ifndef __NET_HTTP_SPECIAL_H #define __NET_HTTP_SPECIAL_H -#include "../libretro.h" +#include enum { diff --git a/network/netplay.h b/network/netplay.h index 8015c4c428..8f22abc60a 100644 --- a/network/netplay.h +++ b/network/netplay.h @@ -22,8 +22,8 @@ #include #include +#include -#include "../libretro.h" #include "../core.h" typedef struct netplay netplay_t; diff --git a/performance.c b/performance.c index 15eac5fdfb..923ca11d85 100644 --- a/performance.c +++ b/performance.c @@ -15,7 +15,7 @@ */ #include -#include "libretro.h" + #if defined(_WIN32) #include @@ -24,6 +24,7 @@ #endif #include +#include #if defined(_WIN32) && !defined(_XBOX) #include diff --git a/performance.h b/performance.h index c3ea91d859..ce04550938 100644 --- a/performance.h +++ b/performance.h @@ -19,12 +19,7 @@ #include -#ifdef RARCH_INTERNAL -#include "libretro.h" -#else -typedef uint64_t retro_perf_tick_t; -typedef uint64_t retro_time_t; -#endif +#include #ifdef __cplusplus extern "C" { diff --git a/performance_counters.h b/performance_counters.h index c15cc7881a..a992a4baa4 100644 --- a/performance_counters.h +++ b/performance_counters.h @@ -19,7 +19,7 @@ #include -#include "libretro.h" +#include #ifdef __cplusplus extern "C" { diff --git a/system.h b/system.h index a878b1d624..774b079724 100644 --- a/system.h +++ b/system.h @@ -17,9 +17,9 @@ #define __RARCH_SYSTEM_H #include +#include #include "driver.h" -#include "libretro.h" #ifndef MAX_USERS #define MAX_USERS 16 From fe4ef69aafaa031744177a47d5cd59600730fd4b Mon Sep 17 00:00:00 2001 From: Alcaro Date: Tue, 10 May 2016 18:51:39 +0200 Subject: [PATCH 395/498] Better check this one too. (Vulkan is the only user of that, right?) --- qb/config.libs.sh | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/qb/config.libs.sh b/qb/config.libs.sh index 04cdff7566..a58f88f77b 100644 --- a/qb/config.libs.sh +++ b/qb/config.libs.sh @@ -403,6 +403,12 @@ if [ "$HAVE_VULKAN" != 'no' ] && [ ! -e deps/glslang/glslang/README.md ]; then HAVE_VULKAN=no fi +if [ "$HAVE_VULKAN" != 'no' ] && [ ! -e deps/SPIRV-Cross/README.md ]; then + echo "Warning: SPIRV-Cross submodule not loaded, can't use Vulkan." + echo "To fix, use: git submodule init && git submodule update" + HAVE_VULKAN=no +fi + check_pkgconf PYTHON python3 if [ "$HAVE_MATERIALUI" != 'no' ] || [ "$HAVE_XMB" != 'no' ] || [ "$HAVE_ZARCH" != 'no' ]; then From 2235aad7310971b0b5be6b70ead7b7ecf9b9c5fe Mon Sep 17 00:00:00 2001 From: Alcaro Date: Tue, 10 May 2016 19:43:15 +0200 Subject: [PATCH 396/498] Need these even without networking --- tasks/tasks_internal.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tasks/tasks_internal.h b/tasks/tasks_internal.h index 897ce2fc2f..1427740abb 100644 --- a/tasks/tasks_internal.h +++ b/tasks/tasks_internal.h @@ -51,6 +51,7 @@ typedef struct http_transfer_info char url[PATH_MAX_LENGTH]; int progress; } http_transfer_info_t; +#endif typedef struct nbio_image_handle { @@ -79,6 +80,7 @@ typedef struct nbio_handle unsigned status; } nbio_handle_t; +#ifdef HAVE_NETWORKING void *rarch_task_push_http_transfer(const char *url, const char *type, retro_task_callback_t cb, void *userdata); From 1bef3665e2080384092e32c2a94915b1e884616a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 May 2016 20:06:38 +0200 Subject: [PATCH 397/498] Cleanups --- frontend/drivers/platform_linux.c | 214 +++++++++++++----------------- 1 file changed, 95 insertions(+), 119 deletions(-) diff --git a/frontend/drivers/platform_linux.c b/frontend/drivers/platform_linux.c index 634f60c05a..8e6de08f55 100644 --- a/frontend/drivers/platform_linux.c +++ b/frontend/drivers/platform_linux.c @@ -65,9 +65,7 @@ typedef struct } CpuList; static bool cpu_inited_once; -static enum cpu_family g_cpuFamily; static uint64_t g_cpuFeatures; -static int g_cpuCount; #ifndef HAVE_DYNAMIC static enum frontend_fork linux_fork_mode = FRONTEND_FORK_NONE; @@ -207,126 +205,22 @@ static const char *parse_decimal(const char* input, return p; } - -/* Parse a textual list of cpus and store the result inside a CpuList object. - * Input format is the following: - * - comma-separated list of items (no spaces) - * - each item is either a single decimal number (cpu index), or a range made - * of two numbers separated by a single dash (-). Ranges are inclusive. - * - * Examples: 0 - * 2,4-127,128-143 - * 0-1 - */ -static void cpulist_parse(CpuList* list, char **buf, ssize_t length) -{ - const char* p = (const char*)buf; - const char* end = p + length; - - /* NOTE: the input line coming from sysfs typically contains a - * trailing newline, so take care of it in the code below - */ - while (p < end && *p != '\n') - { - int val, start_value, end_value; - /* Find the end of current item, and put it into 'q' */ - const char *q = (const char*)memchr(p, ',', end-p); - - if (!q) - q = end; - - /* Get first value */ - p = parse_decimal(p, q, &start_value); - if (p == NULL) - return; - - end_value = start_value; - - /* If we're not at the end of the item, expect a dash and - * and integer; extract end value. - */ - if (p < q && *p == '-') - { - p = parse_decimal(p+1, q, &end_value); - if (p == NULL) - return; - } - - /* Set bits CPU list bits */ - for (val = start_value; val <= end_value; val++) - { - if ((unsigned)val < 32) - list->mask |= (uint32_t)(1U << val); - } - - /* Jump to next item */ - p = q; - if (p < end) - p++; - } -} - -/* Read a CPU list from one sysfs file */ -static void cpulist_read_from(CpuList* list, const char* filename) -{ - ssize_t length; - char *buf = NULL; - - list->mask = 0; - - if (filestream_read_file(filename, (void**)&buf, &length) != 1) - { - RARCH_ERR("Could not read %s: %s\n", filename, strerror(errno)); - return; - } - - cpulist_parse(list, &buf, length); - if (buf) - free(buf); - buf = NULL; -} - -/* Return the number of cpus present on a given device. +/* Return the number of cores present on a given CPU. * * To handle all weird kernel configurations, we need to compute the * intersection of the 'present' and 'possible' CPU lists and count * the result. */ -static int get_cpu_count(void) -{ - CpuList cpus_present[1]; - CpuList cpus_possible[1]; - - cpulist_read_from(cpus_present, "/sys/devices/system/cpu/present"); - cpulist_read_from(cpus_possible, "/sys/devices/system/cpu/possible"); - - /* Compute the intersection of both sets to get the actual number of - * CPU cores that can be used on this device by the kernel. - */ - cpus_present->mask &= cpus_possible->mask; - - return __builtin_popcount(cpus_present->mask); -} - static void linux_cpu_init(void) { ssize_t length; void *buf = NULL; - g_cpuFamily = DEFAULT_CPU_FAMILY; g_cpuFeatures = 0; - g_cpuCount = 1; if (filestream_read_file("/proc/cpuinfo", &buf, &length) != 1) return; - /* Count the CPU cores, the value may be 0 for single-core CPUs */ - g_cpuCount = get_cpu_count(); - if (g_cpuCount == 0) - g_cpuCount = 1; - - RARCH_LOG("found cpuCount = %d\n", g_cpuCount); - #ifdef __ARM_ARCH__ /* Extract architecture from the "CPU Architecture" field. * The list is well-known, unlike the the output of @@ -415,30 +309,112 @@ static void linux_cpu_init(void) } #endif /* __ARM_ARCH__ */ -#ifdef __i386__ - g_cpuFamily = CPU_FAMILY_X86; -#elif defined(_MIPS_ARCH) - g_cpuFamily = CPU_FAMILY_MIPS; -#endif - if (buf) free(buf); buf = NULL; } -enum cpu_family linux_get_cpu_platform(void) -{ - return g_cpuFamily; -} - uint64_t linux_get_cpu_features(void) { return g_cpuFeatures; } +/* Parse a textual list of cpus and store the result inside a CpuList object. + * Input format is the following: + * - comma-separated list of items (no spaces) + * - each item is either a single decimal number (cpu index), or a range made + * of two numbers separated by a single dash (-). Ranges are inclusive. + * + * Examples: 0 + * 2,4-127,128-143 + * 0-1 + */ +static void cpulist_parse(CpuList* list, char **buf, ssize_t length) +{ + const char* p = (const char*)buf; + const char* end = p + length; + + /* NOTE: the input line coming from sysfs typically contains a + * trailing newline, so take care of it in the code below + */ + while (p < end && *p != '\n') + { + int val, start_value, end_value; + /* Find the end of current item, and put it into 'q' */ + const char *q = (const char*)memchr(p, ',', end-p); + + if (!q) + q = end; + + /* Get first value */ + p = parse_decimal(p, q, &start_value); + if (p == NULL) + return; + + end_value = start_value; + + /* If we're not at the end of the item, expect a dash and + * and integer; extract end value. + */ + if (p < q && *p == '-') + { + p = parse_decimal(p+1, q, &end_value); + if (p == NULL) + return; + } + + /* Set bits CPU list bits */ + for (val = start_value; val <= end_value; val++) + { + if ((unsigned)val < 32) + list->mask |= (uint32_t)(1U << val); + } + + /* Jump to next item */ + p = q; + if (p < end) + p++; + } +} + +/* Read a CPU list from one sysfs file */ +static void cpulist_read_from(CpuList* list, const char* filename) +{ + ssize_t length; + char *buf = NULL; + + list->mask = 0; + + if (filestream_read_file(filename, (void**)&buf, &length) != 1) + { + RARCH_ERR("Could not read %s: %s\n", filename, strerror(errno)); + return; + } + + cpulist_parse(list, &buf, length); + if (buf) + free(buf); + buf = NULL; +} + int linux_get_cpu_count(void) { - return g_cpuCount; + int amount = 0; + CpuList cpus_present[1]; + CpuList cpus_possible[1]; + + cpulist_read_from(cpus_present, "/sys/devices/system/cpu/present"); + cpulist_read_from(cpus_possible, "/sys/devices/system/cpu/possible"); + + /* Compute the intersection of both sets to get the actual number of + * CPU cores that can be used on this device by the kernel. + */ + cpus_present->mask &= cpus_possible->mask; + amount = __builtin_popcount(cpus_present->mask); + + if (amount == 0) + return 1; + return amount; } int system_property_get(const char *command, From 1fdc547a97351262cec0c0300aaf7c229f11f393 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 May 2016 20:20:44 +0200 Subject: [PATCH 398/498] Refactor performance.c - merge Android performance code --- frontend/drivers/platform_linux.c | 368 ------------------------------ frontend/drivers/platform_linux.h | 31 --- performance.c | 350 +++++++++++++++++++++++++++- 3 files changed, 343 insertions(+), 406 deletions(-) diff --git a/frontend/drivers/platform_linux.c b/frontend/drivers/platform_linux.c index 8e6de08f55..7b65e20b94 100644 --- a/frontend/drivers/platform_linux.c +++ b/frontend/drivers/platform_linux.c @@ -41,7 +41,6 @@ #include #include #include -#include #include #include "../frontend.h" @@ -51,372 +50,10 @@ #include "../../verbosity.h" #include "platform_linux.h" -/* This small data type is used to represent a CPU list / mask, - * as read from sysfs on Linux. - * - * See http://www.kernel.org/doc/Documentation/cputopology.txt - * - * For now, we don't expect more than 32 cores on mobile devices, - * so keep everything simple. - */ -typedef struct -{ - uint32_t mask; -} CpuList; - -static bool cpu_inited_once; -static uint64_t g_cpuFeatures; - #ifndef HAVE_DYNAMIC static enum frontend_fork linux_fork_mode = FRONTEND_FORK_NONE; #endif -#ifdef __arm__ -# define DEFAULT_CPU_FAMILY CPU_FAMILY_ARM -#elif defined __i386__ -# define DEFAULT_CPU_FAMILY CPU_FAMILY_X86 -#else -# define DEFAULT_CPU_FAMILY CPU_FAMILY_UNKNOWN -#endif - -#ifdef __i386__ -void x86_cpuid(int func, int flags[4]); -#endif - -#ifdef __ARM_ARCH__ -/* Extract the content of a the first occurrence of a given field in - * the content of /proc/cpuinfo and return it as a heap-allocated - * string that must be freed by the caller. - * - * Return NULL if not found - */ -static char *extract_cpuinfo_field(char* buffer, - ssize_t length, const char* field) -{ - int len; - const char *q; - int fieldlen = strlen(field); - char* bufend = buffer + length; - char* result = NULL; - /* Look for first field occurrence, - * and ensures it starts the line. */ - const char *p = buffer; - - for (;;) - { - p = memmem(p, bufend-p, field, fieldlen); - if (p == NULL) - return result; - - if (p == buffer || p[-1] == '\n') - break; - - p += fieldlen; - } - - /* Skip to the first column followed by a space */ - p += fieldlen; - p = memchr(p, ':', bufend-p); - if (p == NULL || p[1] != ' ') - return result; - - /* Find the end of the line */ - p += 2; - q = memchr(p, '\n', bufend-p); - if (q == NULL) - q = bufend; - - /* Copy the line into a heap-allocated buffer */ - len = q-p; - result = malloc(len+1); - if (result == NULL) - return result; - - memcpy(result, p, len); - result[len] = '\0'; - - return result; -} - -/* Checks that a space-separated list of items - * contains one given 'item'. - * Returns 1 if found, 0 otherwise. - */ -static int has_list_item(const char* list, const char* item) -{ - const char* p = list; - int itemlen = strlen(item); - - if (list == NULL) - return 0; - - while (*p) - { - const char* q; - - /* skip spaces */ - while (*p == ' ' || *p == '\t') - p++; - - /* find end of current list item */ - q = p; - while (*q && *q != ' ' && *q != '\t') - q++; - - if (itemlen == q-p && !memcmp(p, item, itemlen)) - return 1; - - /* skip to next item */ - p = q; - } - return 0; -} -#endif - - -/* Parse an decimal integer starting from 'input', but not going further - * than 'limit'. Return the value into '*result'. - * - * NOTE: Does not skip over leading spaces, or deal with sign characters. - * NOTE: Ignores overflows. - * - * The function returns NULL in case of error (bad format), or the new - * position after the decimal number in case of success (which will always - * be <= 'limit'). - */ -static const char *parse_decimal(const char* input, - const char* limit, int* result) -{ - const char* p = input; - int val = 0; - - while (p < limit) - { - int d = (*p - '0'); - if ((unsigned)d >= 10U) - break; - val = val*10 + d; - p++; - } - if (p == input) - return NULL; - - *result = val; - return p; -} - -/* Return the number of cores present on a given CPU. - * - * To handle all weird kernel configurations, we need to compute the - * intersection of the 'present' and 'possible' CPU lists and count - * the result. - */ -static void linux_cpu_init(void) -{ - ssize_t length; - void *buf = NULL; - - g_cpuFeatures = 0; - - if (filestream_read_file("/proc/cpuinfo", &buf, &length) != 1) - return; - -#ifdef __ARM_ARCH__ - /* Extract architecture from the "CPU Architecture" field. - * The list is well-known, unlike the the output of - * the 'Processor' field which can vary greatly. - * - * See the definition of the 'proc_arch' array in - * $KERNEL/arch/arm/kernel/setup.c and the 'c_show' function in - * same file. - */ - char* cpu_arch = extract_cpuinfo_field(buf, length, "CPU architecture"); - - if (cpu_arch) - { - char* end; - int has_armv7 = 0; - /* read the initial decimal number, ignore the rest */ - long arch_number = strtol(cpu_arch, &end, 10); - - RARCH_LOG("Found CPU architecture = '%s'\n", cpu_arch); - - /* Here we assume that ARMv8 will be upwards compatible with v7 - * in the future. Unfortunately, there is no 'Features' field to - * indicate that Thumb-2 is supported. - */ - if (end > cpu_arch && arch_number >= 7) - has_armv7 = 1; - - /* Unfortunately, it seems that certain ARMv6-based CPUs - * report an incorrect architecture number of 7! - * - * See http://code.google.com/p/android/issues/detail?id=10812 - * - * We try to correct this by looking at the 'elf_format' - * field reported by the 'Processor' field, which is of the - * form of "(v7l)" for an ARMv7-based CPU, and "(v6l)" for - * an ARMv6-one. - */ - if (has_armv7) - { - char *cpu_proc = extract_cpuinfo_field(buf, length, - "Processor"); - - if (cpu_proc != NULL) - { - RARCH_LOG("found cpu_proc = '%s'\n", cpu_proc); - if (has_list_item(cpu_proc, "(v6l)")) - { - RARCH_ERR("CPU processor and architecture mismatch!!\n"); - has_armv7 = 0; - } - free(cpu_proc); - } - } - - if (has_armv7) - g_cpuFeatures |= CPU_ARM_FEATURE_ARMv7; - - /* The LDREX / STREX instructions are available from ARMv6 */ - if (arch_number >= 6) - g_cpuFeatures |= CPU_ARM_FEATURE_LDREX_STREX; - - free(cpu_arch); - } - - /* Extract the list of CPU features from 'Features' field */ - char* cpu_features = extract_cpuinfo_field(buf, length, "Features"); - - if (cpu_features) - { - RARCH_LOG("found cpu_features = '%s'\n", cpu_features); - - if (has_list_item(cpu_features, "vfpv3")) - g_cpuFeatures |= CPU_ARM_FEATURE_VFPv3; - - else if (has_list_item(cpu_features, "vfpv3d16")) - g_cpuFeatures |= CPU_ARM_FEATURE_VFPv3; - - /* Note: Certain kernels only report NEON but not VFPv3 - * in their features list. However, ARM mandates - * that if NEON is implemented, so must be VFPv3 - * so always set the flag. - */ - if (has_list_item(cpu_features, "neon")) - g_cpuFeatures |= CPU_ARM_FEATURE_NEON | CPU_ARM_FEATURE_VFPv3; - free(cpu_features); - } -#endif /* __ARM_ARCH__ */ - - if (buf) - free(buf); - buf = NULL; -} - -uint64_t linux_get_cpu_features(void) -{ - return g_cpuFeatures; -} - -/* Parse a textual list of cpus and store the result inside a CpuList object. - * Input format is the following: - * - comma-separated list of items (no spaces) - * - each item is either a single decimal number (cpu index), or a range made - * of two numbers separated by a single dash (-). Ranges are inclusive. - * - * Examples: 0 - * 2,4-127,128-143 - * 0-1 - */ -static void cpulist_parse(CpuList* list, char **buf, ssize_t length) -{ - const char* p = (const char*)buf; - const char* end = p + length; - - /* NOTE: the input line coming from sysfs typically contains a - * trailing newline, so take care of it in the code below - */ - while (p < end && *p != '\n') - { - int val, start_value, end_value; - /* Find the end of current item, and put it into 'q' */ - const char *q = (const char*)memchr(p, ',', end-p); - - if (!q) - q = end; - - /* Get first value */ - p = parse_decimal(p, q, &start_value); - if (p == NULL) - return; - - end_value = start_value; - - /* If we're not at the end of the item, expect a dash and - * and integer; extract end value. - */ - if (p < q && *p == '-') - { - p = parse_decimal(p+1, q, &end_value); - if (p == NULL) - return; - } - - /* Set bits CPU list bits */ - for (val = start_value; val <= end_value; val++) - { - if ((unsigned)val < 32) - list->mask |= (uint32_t)(1U << val); - } - - /* Jump to next item */ - p = q; - if (p < end) - p++; - } -} - -/* Read a CPU list from one sysfs file */ -static void cpulist_read_from(CpuList* list, const char* filename) -{ - ssize_t length; - char *buf = NULL; - - list->mask = 0; - - if (filestream_read_file(filename, (void**)&buf, &length) != 1) - { - RARCH_ERR("Could not read %s: %s\n", filename, strerror(errno)); - return; - } - - cpulist_parse(list, &buf, length); - if (buf) - free(buf); - buf = NULL; -} - -int linux_get_cpu_count(void) -{ - int amount = 0; - CpuList cpus_present[1]; - CpuList cpus_possible[1]; - - cpulist_read_from(cpus_present, "/sys/devices/system/cpu/present"); - cpulist_read_from(cpus_possible, "/sys/devices/system/cpu/possible"); - - /* Compute the intersection of both sets to get the actual number of - * CPU cores that can be used on this device by the kernel. - */ - cpus_present->mask &= cpus_possible->mask; - amount = __builtin_popcount(cpus_present->mask); - - if (amount == 0) - return 1; - return amount; -} - int system_property_get(const char *command, const char *args, char *value) { @@ -2141,11 +1778,6 @@ static void frontend_linux_init(void *data) "getStringExtra", "(Ljava/lang/String;)Ljava/lang/String;"); #endif - if (!cpu_inited_once) - { - linux_cpu_init(); - cpu_inited_once = true; - } } #ifdef ANDROID diff --git a/frontend/drivers/platform_linux.h b/frontend/drivers/platform_linux.h index 9ccdf069b5..345bae2907 100644 --- a/frontend/drivers/platform_linux.h +++ b/frontend/drivers/platform_linux.h @@ -23,31 +23,6 @@ #include -enum cpu_family -{ - CPU_FAMILY_UNKNOWN = 0, - CPU_FAMILY_ARM, - CPU_FAMILY_X86, - CPU_FAMILY_MIPS, - - CPU_FAMILY_MAX /* do not remove */ -}; - -enum -{ - CPU_ARM_FEATURE_ARMv7 = (1 << 0), - CPU_ARM_FEATURE_VFPv3 = (1 << 1), - CPU_ARM_FEATURE_NEON = (1 << 2), - CPU_ARM_FEATURE_LDREX_STREX = (1 << 3) -}; - -enum -{ - CPU_X86_FEATURE_SSSE3 = (1 << 0), - CPU_X86_FEATURE_POPCNT = (1 << 1), - CPU_X86_FEATURE_MOVBE = (1 << 2) -}; - #ifndef MAX_PADS #define MAX_PADS 8 #endif @@ -56,12 +31,6 @@ enum #define MAX_AXIS 10 #endif -enum cpu_family linux_get_cpu_family(void); - -uint64_t linux_get_cpu_features(void); - -int linux_get_cpu_count(void); - #ifdef ANDROID #include #include diff --git a/performance.c b/performance.c index 923ca11d85..7f7da8f31f 100644 --- a/performance.c +++ b/performance.c @@ -15,7 +15,7 @@ */ #include - +#include #if defined(_WIN32) #include @@ -24,6 +24,7 @@ #endif #include +#include #include #if defined(_WIN32) && !defined(_XBOX) @@ -100,10 +101,6 @@ static int clock_gettime(int clk_ik, struct timespec *t) #include -#if defined(__linux__) -#include "frontend/drivers/platform_linux.h" -#endif - /** * cpu_features_get_perf_counter: * @@ -283,6 +280,214 @@ static void arm_enable_runfast_mode(void) } #endif +#if defined(__linux__) + +#ifdef __ARM_ARCH__ +/* Extract the content of a the first occurrence of a given field in + * the content of /proc/cpuinfo and return it as a heap-allocated + * string that must be freed by the caller. + * + * Return NULL if not found + */ +static char *extract_cpuinfo_field(char* buffer, + ssize_t length, const char* field) +{ + int len; + const char *q; + int fieldlen = strlen(field); + char* bufend = buffer + length; + char* result = NULL; + /* Look for first field occurrence, + * and ensures it starts the line. */ + const char *p = buffer; + + for (;;) + { + p = memmem(p, bufend-p, field, fieldlen); + if (p == NULL) + return result; + + if (p == buffer || p[-1] == '\n') + break; + + p += fieldlen; + } + + /* Skip to the first column followed by a space */ + p += fieldlen; + p = memchr(p, ':', bufend-p); + if (p == NULL || p[1] != ' ') + return result; + + /* Find the end of the line */ + p += 2; + q = memchr(p, '\n', bufend-p); + if (q == NULL) + q = bufend; + + /* Copy the line into a heap-allocated buffer */ + len = q-p; + result = malloc(len+1); + if (result == NULL) + return result; + + memcpy(result, p, len); + result[len] = '\0'; + + return result; +} + +/* Checks that a space-separated list of items + * contains one given 'item'. + * Returns 1 if found, 0 otherwise. + */ +static int has_list_item(const char* list, const char* item) +{ + const char* p = list; + int itemlen = strlen(item); + + if (list == NULL) + return 0; + + while (*p) + { + const char* q; + + /* skip spaces */ + while (*p == ' ' || *p == '\t') + p++; + + /* find end of current list item */ + q = p; + while (*q && *q != ' ' && *q != '\t') + q++; + + if (itemlen == q-p && !memcmp(p, item, itemlen)) + return 1; + + /* skip to next item */ + p = q; + } + return 0; +} +#endif + +typedef struct +{ + uint32_t mask; +} CpuList; + + +#if !defined(_SC_NPROCESSORS_ONLN) +/* Parse an decimal integer starting from 'input', but not going further + * than 'limit'. Return the value into '*result'. + * + * NOTE: Does not skip over leading spaces, or deal with sign characters. + * NOTE: Ignores overflows. + * + * The function returns NULL in case of error (bad format), or the new + * position after the decimal number in case of success (which will always + * be <= 'limit'). + */ +static const char *parse_decimal(const char* input, + const char* limit, int* result) +{ + const char* p = input; + int val = 0; + + while (p < limit) + { + int d = (*p - '0'); + if ((unsigned)d >= 10U) + break; + val = val*10 + d; + p++; + } + if (p == input) + return NULL; + + *result = val; + return p; +} + +/* Parse a textual list of cpus and store the result inside a CpuList object. + * Input format is the following: + * - comma-separated list of items (no spaces) + * - each item is either a single decimal number (cpu index), or a range made + * of two numbers separated by a single dash (-). Ranges are inclusive. + * + * Examples: 0 + * 2,4-127,128-143 + * 0-1 + */ +static void cpulist_parse(CpuList* list, char **buf, ssize_t length) +{ + const char* p = (const char*)buf; + const char* end = p + length; + + /* NOTE: the input line coming from sysfs typically contains a + * trailing newline, so take care of it in the code below + */ + while (p < end && *p != '\n') + { + int val, start_value, end_value; + /* Find the end of current item, and put it into 'q' */ + const char *q = (const char*)memchr(p, ',', end-p); + + if (!q) + q = end; + + /* Get first value */ + p = parse_decimal(p, q, &start_value); + if (p == NULL) + return; + + end_value = start_value; + + /* If we're not at the end of the item, expect a dash and + * and integer; extract end value. + */ + if (p < q && *p == '-') + { + p = parse_decimal(p+1, q, &end_value); + if (p == NULL) + return; + } + + /* Set bits CPU list bits */ + for (val = start_value; val <= end_value; val++) + { + if ((unsigned)val < 32) + list->mask |= (uint32_t)(1U << val); + } + + /* Jump to next item */ + p = q; + if (p < end) + p++; + } +} + +/* Read a CPU list from one sysfs file */ +static void cpulist_read_from(CpuList* list, const char* filename) +{ + ssize_t length; + char *buf = NULL; + + list->mask = 0; + + if (filestream_read_file(filename, (void**)&buf, &length) != 1) + return; + + cpulist_parse(list, &buf, length); + if (buf) + free(buf); + buf = NULL; +} +#endif + +#endif + /** * cpu_features_get_core_amount: * @@ -330,7 +535,22 @@ unsigned cpu_features_get_core_amount(void) } return num_cpu; #elif defined(__linux__) - return linux_get_cpu_count(); + CpuList cpus_present[1]; + CpuList cpus_possible[1]; + int amount = 0; + + cpulist_read_from(cpus_present, "/sys/devices/system/cpu/present"); + cpulist_read_from(cpus_possible, "/sys/devices/system/cpu/possible"); + + /* Compute the intersection of both sets to get the actual number of + * CPU cores that can be used on this device by the kernel. + */ + cpus_present->mask &= cpus_possible->mask; + amount = __builtin_popcount(cpus_present->mask); + + if (amount == 0) + return 1; + return amount; #elif defined(_XBOX360) return 3; #else @@ -510,7 +730,123 @@ uint64_t cpu_features_get(void) cpu |= RETRO_SIMD_MMXEXT; } #elif defined(__linux__) - cpu_flags = linux_get_cpu_features(); + + static bool cpu_inited_once = false; + static uint64_t g_cpuFeatures; + + enum + { + CPU_ARM_FEATURE_ARMv7 = (1 << 0), + CPU_ARM_FEATURE_VFPv3 = (1 << 1), + CPU_ARM_FEATURE_NEON = (1 << 2), + CPU_ARM_FEATURE_LDREX_STREX = (1 << 3) + }; + + if (!cpu_inited_once) + { + ssize_t length; + void *buf = NULL; + + g_cpuFeatures = 0; + + if (filestream_read_file("/proc/cpuinfo", &buf, &length) == 1) + { +#ifdef __ARM_ARCH__ + /* Extract architecture from the "CPU Architecture" field. + * The list is well-known, unlike the the output of + * the 'Processor' field which can vary greatly. + * + * See the definition of the 'proc_arch' array in + * $KERNEL/arch/arm/kernel/setup.c and the 'c_show' function in + * same file. + */ + char* cpu_arch = extract_cpuinfo_field(buf, length, "CPU architecture"); + + if (cpu_arch) + { + char* end; + int has_armv7 = 0; + /* read the initial decimal number, ignore the rest */ + long arch_number = strtol(cpu_arch, &end, 10); + + RARCH_LOG("Found CPU architecture = '%s'\n", cpu_arch); + + /* Here we assume that ARMv8 will be upwards compatible with v7 + * in the future. Unfortunately, there is no 'Features' field to + * indicate that Thumb-2 is supported. + */ + if (end > cpu_arch && arch_number >= 7) + has_armv7 = 1; + + /* Unfortunately, it seems that certain ARMv6-based CPUs + * report an incorrect architecture number of 7! + * + * See http://code.google.com/p/android/issues/detail?id=10812 + * + * We try to correct this by looking at the 'elf_format' + * field reported by the 'Processor' field, which is of the + * form of "(v7l)" for an ARMv7-based CPU, and "(v6l)" for + * an ARMv6-one. + */ + if (has_armv7) + { + char *cpu_proc = extract_cpuinfo_field(buf, length, + "Processor"); + + if (cpu_proc != NULL) + { + RARCH_LOG("found cpu_proc = '%s'\n", cpu_proc); + if (has_list_item(cpu_proc, "(v6l)")) + { + /* CPU processor and architecture mismatch. */ + has_armv7 = 0; + } + free(cpu_proc); + } + } + + if (has_armv7) + g_cpuFeatures |= CPU_ARM_FEATURE_ARMv7; + + /* The LDREX / STREX instructions are available from ARMv6 */ + if (arch_number >= 6) + g_cpuFeatures |= CPU_ARM_FEATURE_LDREX_STREX; + + free(cpu_arch); + } + + /* Extract the list of CPU features from 'Features' field */ + char* cpu_features = extract_cpuinfo_field(buf, length, "Features"); + + if (cpu_features) + { + RARCH_LOG("found cpu_features = '%s'\n", cpu_features); + + if (has_list_item(cpu_features, "vfpv3")) + g_cpuFeatures |= CPU_ARM_FEATURE_VFPv3; + + else if (has_list_item(cpu_features, "vfpv3d16")) + g_cpuFeatures |= CPU_ARM_FEATURE_VFPv3; + + /* Note: Certain kernels only report NEON but not VFPv3 + * in their features list. However, ARM mandates + * that if NEON is implemented, so must be VFPv3 + * so always set the flag. + */ + if (has_list_item(cpu_features, "neon")) + g_cpuFeatures |= CPU_ARM_FEATURE_NEON | CPU_ARM_FEATURE_VFPv3; + free(cpu_features); + } +#endif /* __ARM_ARCH__ */ + + if (buf) + free(buf); + buf = NULL; + } + cpu_inited_once = true; + } + + cpu_flags = g_cpuFeatures; if (cpu_flags & CPU_ARM_FEATURE_NEON) { From 9aed52ac650de08c9e20764fd8d3d7b5d8373d64 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 May 2016 20:31:27 +0200 Subject: [PATCH 399/498] Move performance.c to libretro-common/features/features_cpu.c --- Makefile.common | 2 +- audio/audio_dsp_filter.c | 2 +- audio/audio_resampler_driver.c | 6 +- audio/audio_utils.c | 10 +-- dynamic.c | 3 +- frontend/drivers/platform_linux.c | 1 + gfx/video_driver.c | 2 +- gfx/video_filter.c | 2 +- gfx/video_thread_wrapper.c | 2 +- griffin/griffin.c | 2 +- .../features/features_cpu.c | 33 ++++---- .../include/features/features_cpu.h | 75 +++++++++++++++++++ menu/drivers/menu_generic.c | 2 +- menu/menu_animation.c | 3 +- menu/menu_input.c | 3 +- network/net_http_special.c | 2 +- performance.h | 69 ----------------- performance_counters.c | 3 +- retroarch.c | 3 +- runloop.c | 2 +- 20 files changed, 118 insertions(+), 109 deletions(-) rename performance.c => libretro-common/features/features_cpu.c (94%) create mode 100644 libretro-common/include/features/features_cpu.h delete mode 100644 performance.h diff --git a/Makefile.common b/Makefile.common index 9a55a67774..b36ec42be9 100644 --- a/Makefile.common +++ b/Makefile.common @@ -204,7 +204,7 @@ OBJ += frontend/frontend.o \ movie.o \ record/record_driver.o \ record/drivers/record_null.o \ - performance.o \ + libretro-common/features/features_cpu.o \ performance_counters.o \ verbosity.o diff --git a/audio/audio_dsp_filter.c b/audio/audio_dsp_filter.c index e781683918..6f49734f2e 100644 --- a/audio/audio_dsp_filter.c +++ b/audio/audio_dsp_filter.c @@ -23,13 +23,13 @@ #include #include +#include #include "audio_dsp_filter.h" #include "audio_filters/dspfilter.h" #include "../config_file_userdata.h" #include "../frontend/frontend_driver.h" -#include "../performance.h" #include "../performance_counters.h" #include "../dynamic.h" diff --git a/audio/audio_resampler_driver.c b/audio/audio_resampler_driver.c index a50d70fece..6e1f5cebb0 100644 --- a/audio/audio_resampler_driver.c +++ b/audio/audio_resampler_driver.c @@ -17,11 +17,11 @@ #include #include +#include #include "audio_resampler_driver.h" #include "../config_file_userdata.h" #ifdef RARCH_INTERNAL -#include "../performance.h" #include "../performance_counters.h" #endif #ifndef DONT_HAVE_STRING_LIST @@ -142,11 +142,7 @@ retro_get_cpu_features_t perf_get_cpu_features_cb; static resampler_simd_mask_t resampler_get_cpu_features(void) { -#ifdef RARCH_INTERNAL return cpu_features_get(); -#else - return perf_get_cpu_features_cb(); -#endif } /** diff --git a/audio/audio_utils.c b/audio/audio_utils.c index 51b5f9b9a1..b7cab9463a 100644 --- a/audio/audio_utils.c +++ b/audio/audio_utils.c @@ -13,18 +13,18 @@ * You should have received a copy of the GNU General Public License along with RetroArch. * If not, see . */ - -#include -#include "audio_utils.h" - #if defined(__SSE2__) #include #elif defined(__ALTIVEC__) #include #endif +#include +#include + +#include "audio_utils.h" + #ifdef RARCH_INTERNAL -#include "../performance.h" #include "../performance_counters.h" #endif diff --git a/dynamic.c b/dynamic.c index e89bdfa18d..e02798fb8f 100644 --- a/dynamic.c +++ b/dynamic.c @@ -25,6 +25,8 @@ #include #include +#include + #ifdef HAVE_CONFIG_H #include "config.h" #endif @@ -38,7 +40,6 @@ #include "record/record_driver.h" #include "core.h" #include "performance_counters.h" -#include "performance.h" #include "system.h" #include "gfx/video_context_driver.h" diff --git a/frontend/drivers/platform_linux.c b/frontend/drivers/platform_linux.c index 7b65e20b94..592ed1e242 100644 --- a/frontend/drivers/platform_linux.c +++ b/frontend/drivers/platform_linux.c @@ -41,6 +41,7 @@ #include #include #include +#include #include #include "../frontend.h" diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 8b380a7dc4..7af875e3e4 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -25,6 +25,7 @@ #endif #include +#include #include "video_thread_wrapper.h" #include "../frontend/frontend_driver.h" @@ -33,7 +34,6 @@ #include "../config.def.h" #include "../retroarch.h" #include "../runloop.h" -#include "../performance.h" #include "../performance_counters.h" #include "../list_special.h" #include "../core.h" diff --git a/gfx/video_filter.c b/gfx/video_filter.c index fe46697bce..1f59be39ad 100644 --- a/gfx/video_filter.c +++ b/gfx/video_filter.c @@ -19,12 +19,12 @@ #include #include #include +#include #include "../frontend/frontend_driver.h" #include "../config_file_userdata.h" #include "../dynamic.h" #include "../general.h" -#include "../performance.h" #include "../performance_counters.h" #include "../verbosity.h" #include "video_filter.h" diff --git a/gfx/video_thread_wrapper.c b/gfx/video_thread_wrapper.c index b4b8ca1155..3f7b058e53 100644 --- a/gfx/video_thread_wrapper.c +++ b/gfx/video_thread_wrapper.c @@ -18,12 +18,12 @@ #include #include +#include #include #include "video_thread_wrapper.h" #include "font_driver.h" #include "video_shader_driver.h" -#include "../performance.h" #include "../performance_counters.h" #include "../runloop.h" #include "../verbosity.h" diff --git a/griffin/griffin.c b/griffin/griffin.c index 6fe88a87b8..edf45c5fad 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -62,7 +62,7 @@ ENCODINGS /*============================================================ PERFORMANCE ============================================================ */ -#include "../performance.c" +#include "../libretro-common/features/features_cpu.c" #include "../performance_counters.c" /*============================================================ diff --git a/performance.c b/libretro-common/features/features_cpu.c similarity index 94% rename from performance.c rename to libretro-common/features/features_cpu.c index 7f7da8f31f..185de2932c 100644 --- a/performance.c +++ b/libretro-common/features/features_cpu.c @@ -1,17 +1,23 @@ -/* RetroArch - A frontend for libretro. - * Copyright (C) 2010-2014 - Hans-Kristian Arntzen - * Copyright (C) 2011-2016 - Daniel De Matteis +/* Copyright (C) 2010-2016 The RetroArch team * - * 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. + * --------------------------------------------------------------------------------------- + * The following license statement only applies to this file (features_cpu.c). + * --------------------------------------------------------------------------------------- * - * 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. + * 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: * - * You should have received a copy of the GNU General Public License along with RetroArch. - * If not, see . + * 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 @@ -769,8 +775,6 @@ uint64_t cpu_features_get(void) /* read the initial decimal number, ignore the rest */ long arch_number = strtol(cpu_arch, &end, 10); - RARCH_LOG("Found CPU architecture = '%s'\n", cpu_arch); - /* Here we assume that ARMv8 will be upwards compatible with v7 * in the future. Unfortunately, there is no 'Features' field to * indicate that Thumb-2 is supported. @@ -795,7 +799,6 @@ uint64_t cpu_features_get(void) if (cpu_proc != NULL) { - RARCH_LOG("found cpu_proc = '%s'\n", cpu_proc); if (has_list_item(cpu_proc, "(v6l)")) { /* CPU processor and architecture mismatch. */ @@ -820,8 +823,6 @@ uint64_t cpu_features_get(void) if (cpu_features) { - RARCH_LOG("found cpu_features = '%s'\n", cpu_features); - if (has_list_item(cpu_features, "vfpv3")) g_cpuFeatures |= CPU_ARM_FEATURE_VFPv3; diff --git a/libretro-common/include/features/features_cpu.h b/libretro-common/include/features/features_cpu.h new file mode 100644 index 0000000000..f5da7c1424 --- /dev/null +++ b/libretro-common/include/features/features_cpu.h @@ -0,0 +1,75 @@ +/* Copyright (C) 2010-2016 The RetroArch team + * + * --------------------------------------------------------------------------------------- + * The following license statement only applies to this file (features_cpu.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_CPU_INFO_H +#define _LIBRETRO_SDK_CPU_INFO_H + +#include + +#include + +#ifdef __cplusplus +extern "C" { +#endif + +/** + * cpu_features_get_perf_counter: + * + * Gets performance counter. + * + * Returns: performance counter. + **/ +retro_perf_tick_t cpu_features_get_perf_counter(void); + +/** + * cpu_features_get_time_usec: + * + * Gets time in microseconds. * + * Returns: time in microseconds. + **/ +retro_time_t cpu_features_get_time_usec(void); + +/** + * cpu_features_get: + * + * Gets CPU features.. + * + * Returns: bitmask of all CPU features available. + **/ +uint64_t cpu_features_get(void); + +/** + * cpu_features_get_core_amount: + * + * Gets the amount of available CPU cores. + * + * Returns: amount of CPU cores available. + **/ +unsigned cpu_features_get_core_amount(void); + + +#ifdef __cplusplus +} +#endif + +#endif + diff --git a/menu/drivers/menu_generic.c b/menu/drivers/menu_generic.c index c1bd67114d..95140707b9 100644 --- a/menu/drivers/menu_generic.c +++ b/menu/drivers/menu_generic.c @@ -17,6 +17,7 @@ #include #include +#include #include "menu_generic.h" @@ -28,7 +29,6 @@ #include "../menu_entries.h" #include "../../configuration.h" -#include "../../performance.h" #include "../../performance_counters.h" #include "../../input/input_autodetect.h" #include "../../input/input_config.h" diff --git a/menu/menu_animation.c b/menu/menu_animation.c index db267ec8fb..1f58a26ede 100644 --- a/menu/menu_animation.c +++ b/menu/menu_animation.c @@ -16,13 +16,14 @@ #include #include + #include #include #include +#include #include "menu_animation.h" #include "../configuration.h" -#include "../performance.h" #include "../performance_counters.h" #define IDEAL_DELTA_TIME (1.0 / 60.0 * 1000000.0) diff --git a/menu/menu_input.c b/menu/menu_input.c index 0025dd668d..64a5c65eea 100644 --- a/menu/menu_input.c +++ b/menu/menu_input.c @@ -27,6 +27,8 @@ #include #include +#include + #include "menu_driver.h" #include "menu_input.h" #include "menu_animation.h" @@ -39,7 +41,6 @@ #include "../general.h" #include "../managers/cheat_manager.h" -#include "../performance.h" #include "../performance_counters.h" #include "../core.h" #include "../input/input_joypad_driver.h" diff --git a/network/net_http_special.c b/network/net_http_special.c index 2c488c614c..f074510ca4 100644 --- a/network/net_http_special.c +++ b/network/net_http_special.c @@ -17,8 +17,8 @@ #include #include +#include -#include "../performance.h" #include "../performance_counters.h" #include "net_http_special.h" diff --git a/performance.h b/performance.h deleted file mode 100644 index ce04550938..0000000000 --- a/performance.h +++ /dev/null @@ -1,69 +0,0 @@ -/* 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. - * - * 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 _LIBRETRO_SDK_CPU_INFO_H -#define _LIBRETRO_SDK_CPU_INFO_H - -#include - -#include - -#ifdef __cplusplus -extern "C" { -#endif - -/** - * cpu_features_get_perf_counter: - * - * Gets performance counter. - * - * Returns: performance counter. - **/ -retro_perf_tick_t cpu_features_get_perf_counter(void); - -/** - * cpu_features_get_time_usec: - * - * Gets time in microseconds. * - * Returns: time in microseconds. - **/ -retro_time_t cpu_features_get_time_usec(void); - -/** - * cpu_features_get: - * - * Gets CPU features.. - * - * Returns: bitmask of all CPU features available. - **/ -uint64_t cpu_features_get(void); - -/** - * cpu_features_get_core_amount: - * - * Gets the amount of available CPU cores. - * - * Returns: amount of CPU cores available. - **/ -unsigned cpu_features_get_core_amount(void); - - -#ifdef __cplusplus -} -#endif - -#endif - diff --git a/performance_counters.c b/performance_counters.c index 209e6fb824..97e9ec9366 100644 --- a/performance_counters.c +++ b/performance_counters.c @@ -17,7 +17,8 @@ #include #include -#include "performance.h" +#include + #include "performance_counters.h" #include "general.h" diff --git a/retroarch.c b/retroarch.c index e0f1cff51f..dd6801fc3d 100644 --- a/retroarch.c +++ b/retroarch.c @@ -43,6 +43,8 @@ #include #include +#include + #include "content.h" #include "core_type.h" #include "core_info.h" @@ -58,7 +60,6 @@ #include "configuration.h" #include "general.h" #include "runloop.h" -#include "performance.h" #include "managers/cheat_manager.h" #include "system.h" diff --git a/runloop.c b/runloop.c index 63e4e2d889..fcd1e6bfab 100644 --- a/runloop.c +++ b/runloop.c @@ -29,6 +29,7 @@ #endif #include #include +#include #include @@ -38,7 +39,6 @@ #include "autosave.h" #include "core_info.h" #include "configuration.h" -#include "performance.h" #include "movie.h" #include "retroarch.h" #include "runloop.h" From eec4218ebbc98d66ed021f32b7da9f1bef53db63 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Tue, 10 May 2016 20:36:05 +0200 Subject: [PATCH 400/498] (RJPEG) Use features_cpu --- libretro-common/formats/jpeg/rjpeg.c | 49 +++++----------------------- 1 file changed, 9 insertions(+), 40 deletions(-) diff --git a/libretro-common/formats/jpeg/rjpeg.c b/libretro-common/formats/jpeg/rjpeg.c index 4d43a66c76..7e384ad7fa 100644 --- a/libretro-common/formats/jpeg/rjpeg.c +++ b/libretro-common/formats/jpeg/rjpeg.c @@ -11,6 +11,7 @@ #include #include #include +#include enum { @@ -88,51 +89,19 @@ typedef struct #include #ifdef _MSC_VER - -#if _MSC_VER >= 1400 /* not VC6 */ -#include /* __cpuid */ -static int rjpeg__cpuid3(void) -{ - int info[4]; - __cpuid(info,1); - return info[3]; -} -#else -static int rjpeg__cpuid3(void) -{ - int res; - __asm { - mov eax,1 - cpuid - mov res,edx - } - return res; -} -#endif - #define RJPEG_SIMD_ALIGN(type, name) __declspec(align(16)) type name - -static int rjpeg__sse2_available(void) -{ - int info3 = rjpeg__cpuid3(); - return ((info3 >> 26) & 1) != 0; -} -#else /* assume GCC-style if not VC++ */ -#define RJPEG_SIMD_ALIGN(type, name) type name __attribute__((aligned(16))) - -static int rjpeg__sse2_available(void) -{ -#if defined(__GNUC__) && (__GNUC__ * 100 + __GNUC_MINOR__) >= 408 /* GCC 4.8 or later */ - /* GCC 4.8+ has a nice way to do this */ - return __builtin_cpu_supports("sse2"); #else - /* portable way to do this, preferably without using GCC inline ASM? - * just bail for now. */ +#define RJPEG_SIMD_ALIGN(type, name) type name __attribute__((aligned(16))) +#endif + +static int rjpeg__sse2_available(void) +{ + uint64_t mask = cpu_features_get(); + if (mask & RETRO_SIMD_SSE2) + return 1; return 0; -#endif } #endif -#endif /* ARM NEON */ #if defined(RJPEG_NO_SIMD) && defined(RJPEG_NEON) From 44ab560dd696b0cea86d3561c11b084570f1ff71 Mon Sep 17 00:00:00 2001 From: Andre Leiradella Date: Tue, 10 May 2016 16:42:13 -0300 Subject: [PATCH 401/498] pre-processed mmaps according to instructions at https://github.com/Alcaro/minir/blob/master/minircheats-model.cpp#L21 --- dynamic.c | 141 ++++++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 122 insertions(+), 19 deletions(-) diff --git a/dynamic.c b/dynamic.c index 3110320469..70e1d7cbba 100644 --- a/dynamic.c +++ b/dynamic.c @@ -622,6 +622,106 @@ static void rarch_log_libretro(enum retro_log_level level, va_end(vp); } +static size_t add_bits_down(size_t n) +{ + n |= n >> 1; + n |= n >> 2; + 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; +} + +static size_t inflate(size_t addr, size_t mask) +{ + while (mask) + { + size_t tmp = (mask - 1) & ~mask; + /* to put in an 1 bit instead, OR in tmp+1 */ + addr = ((addr & ~tmp) << 1) | (addr & tmp); + mask = mask & (mask - 1); + } + + return addr; +} + +static size_t reduce(size_t addr, size_t mask) +{ + while (mask) + { + size_t tmp = (mask - 1) & ~mask; + addr = (addr & tmp) | ((addr >> 1) & ~tmp); + mask = (mask & (mask - 1)) >> 1; + } + + return addr; +} + +static size_t highest_bit(size_t n) +{ + n = add_bits_down(n); + return n ^ (n >> 1); +} + +static bool preprocess_descriptors(struct retro_memory_descriptor *first, unsigned count) +{ + struct retro_memory_descriptor *desc; + const struct retro_memory_descriptor *end; + size_t top_addr, disconnect_mask; + + end = first + count; + top_addr = 1; + + for (desc = first; desc < end; desc++) + { + if (desc->select != 0) + top_addr |= desc->select; + else + top_addr |= desc->start + desc->len - 1; + } + + top_addr = add_bits_down(top_addr); + + for (desc = first; desc < end; desc++) + { + if (desc->select == 0) + { + if (desc->len == 0) + return false; + + if ((desc->len & (desc->len - 1)) != 0) + return false; + + desc->select = top_addr & ~inflate(add_bits_down(desc->len - 1), desc->disconnect); + } + + if (desc->len == 0) + desc->len = add_bits_down(reduce(top_addr & ~desc->select, desc->disconnect)) + 1; + + if (desc->start & ~desc->select) + return false; + + while (reduce(top_addr & ~desc->select, desc->disconnect) >> 1 > desc->len - 1) + desc->disconnect |= highest_bit(top_addr & ~desc->select & ~desc->disconnect); + + disconnect_mask = add_bits_down(desc->len - 1); + desc->disconnect &= disconnect_mask; + + while ((~disconnect_mask) >> 1 & desc->disconnect) + { + disconnect_mask >>= 1; + desc->disconnect &= disconnect_mask; + } + } + + return true; +} + /** * rarch_environment_cb: * @cmd : Identifier of command. @@ -1217,20 +1317,36 @@ bool rarch_environment_cb(unsigned cmd, void *data) case RETRO_ENVIRONMENT_SET_MEMORY_MAPS: { unsigned i; + struct retro_memory_descriptor *descriptors; const struct retro_memory_map *mmaps = (const struct retro_memory_map*)data; + free((void*)system->mmaps.descriptors); + system->mmaps.num_descriptors = 0; + + descriptors = (struct retro_memory_descriptor*) + calloc(mmaps->num_descriptors, sizeof(*system->mmaps.descriptors)); + + if (!descriptors) + return false; + + system->mmaps.descriptors = descriptors; + memcpy((void*)system->mmaps.descriptors, mmaps->descriptors, + mmaps->num_descriptors * sizeof(*system->mmaps.descriptors)); + system->mmaps.num_descriptors = mmaps->num_descriptors; + preprocess_descriptors(descriptors, mmaps->num_descriptors); + RARCH_LOG("Environ SET_MEMORY_MAPS.\n"); if (sizeof(void *) == 8) - RARCH_LOG(" flags ptr offset start select disconn len addrspace\n"); + RARCH_LOG(" ndx flags ptr offset start select disconn len addrspace\n"); else - RARCH_LOG(" flags ptr offset start select disconn len addrspace\n"); + RARCH_LOG(" ndx flags ptr offset start select disconn len addrspace\n"); - for (i = 0; i < mmaps->num_descriptors; i++) + for (i = 0; i < system->mmaps.num_descriptors; i++) { const struct retro_memory_descriptor *desc = - &mmaps->descriptors[i]; + &system->mmaps.descriptors[i]; char flags[7]; flags[0] = 'M'; @@ -1257,25 +1373,12 @@ bool rarch_environment_cb(unsigned cmd, void *data) flags[5] = (desc->flags & RETRO_MEMDESC_CONST) ? 'C' : 'c'; flags[6] = 0; - RARCH_LOG("Memory map: %u\n", i + 1); - RARCH_LOG(" %s %p %08X %08X %08X %08X %08X %s\n", - flags, desc->ptr, desc->offset, desc->start, + RARCH_LOG(" %03u %s %p %08X %08X %08X %08X %08X %s\n", + i + 1, flags, desc->ptr, desc->offset, desc->start, desc->select, desc->disconnect, desc->len, desc->addrspace ? desc->addrspace : ""); } - free((void*)system->mmaps.descriptors); - system->mmaps.num_descriptors = 0; - - system->mmaps.descriptors = (struct retro_memory_descriptor*) - calloc(mmaps->num_descriptors, sizeof(*system->mmaps.descriptors)); - - if (!system->mmaps.descriptors) - return false; - - memcpy((void*)system->mmaps.descriptors, mmaps->descriptors, - mmaps->num_descriptors * sizeof(*system->mmaps.descriptors)); - system->mmaps.num_descriptors = mmaps->num_descriptors; break; } From c62723ebe288599e3d625a98d66d7dfe80b0f85f Mon Sep 17 00:00:00 2001 From: Andre Leiradella Date: Tue, 10 May 2016 16:47:14 -0300 Subject: [PATCH 402/498] replaced tab by spaces --- dynamic.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/dynamic.c b/dynamic.c index 70e1d7cbba..bda1e0ad09 100644 --- a/dynamic.c +++ b/dynamic.c @@ -624,22 +624,22 @@ static void rarch_log_libretro(enum retro_log_level level, static size_t add_bits_down(size_t n) { - n |= n >> 1; - n |= n >> 2; - n |= n >> 4; - n |= n >> 8; - n |= n >> 16; + n |= n >> 1; + n |= n >> 2; + 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) + if (sizeof(size_t) > 4) n |= n >> 16 >> 16; - return n; + return n; } static size_t inflate(size_t addr, size_t mask) { - while (mask) + while (mask) { size_t tmp = (mask - 1) & ~mask; /* to put in an 1 bit instead, OR in tmp+1 */ From 3d7be6136311775306ea32f9037588612fc7cb72 Mon Sep 17 00:00:00 2001 From: Andre Leiradella Date: Tue, 10 May 2016 17:39:20 -0300 Subject: [PATCH 403/498] renamed some functions because of griffin --- dynamic.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/dynamic.c b/dynamic.c index bda1e0ad09..fc800b9d06 100644 --- a/dynamic.c +++ b/dynamic.c @@ -622,7 +622,7 @@ static void rarch_log_libretro(enum retro_log_level level, va_end(vp); } -static size_t add_bits_down(size_t n) +static size_t mmap_add_bits_down(size_t n) { n |= n >> 1; n |= n >> 2; @@ -637,7 +637,7 @@ static size_t add_bits_down(size_t n) return n; } -static size_t inflate(size_t addr, size_t mask) +static size_t mmap_inflate(size_t addr, size_t mask) { while (mask) { @@ -650,7 +650,7 @@ static size_t inflate(size_t addr, size_t mask) return addr; } -static size_t reduce(size_t addr, size_t mask) +static size_t mmap_reduce(size_t addr, size_t mask) { while (mask) { @@ -662,13 +662,13 @@ static size_t reduce(size_t addr, size_t mask) return addr; } -static size_t highest_bit(size_t n) +static size_t mmap_highest_bit(size_t n) { - n = add_bits_down(n); + n = mmap_add_bits_down(n); return n ^ (n >> 1); } -static bool preprocess_descriptors(struct retro_memory_descriptor *first, unsigned count) +static bool mmap_preprocess_descriptors(struct retro_memory_descriptor *first, unsigned count) { struct retro_memory_descriptor *desc; const struct retro_memory_descriptor *end; @@ -685,7 +685,7 @@ static bool preprocess_descriptors(struct retro_memory_descriptor *first, unsign top_addr |= desc->start + desc->len - 1; } - top_addr = add_bits_down(top_addr); + top_addr = mmap_add_bits_down(top_addr); for (desc = first; desc < end; desc++) { @@ -697,19 +697,19 @@ static bool preprocess_descriptors(struct retro_memory_descriptor *first, unsign if ((desc->len & (desc->len - 1)) != 0) return false; - desc->select = top_addr & ~inflate(add_bits_down(desc->len - 1), desc->disconnect); + desc->select = top_addr & ~mmap_inflate(mmap_add_bits_down(desc->len - 1), desc->disconnect); } if (desc->len == 0) - desc->len = add_bits_down(reduce(top_addr & ~desc->select, desc->disconnect)) + 1; + desc->len = mmap_add_bits_down(mmap_reduce(top_addr & ~desc->select, desc->disconnect)) + 1; if (desc->start & ~desc->select) return false; - while (reduce(top_addr & ~desc->select, desc->disconnect) >> 1 > desc->len - 1) - desc->disconnect |= highest_bit(top_addr & ~desc->select & ~desc->disconnect); + while (mmap_reduce(top_addr & ~desc->select, desc->disconnect) >> 1 > desc->len - 1) + desc->disconnect |= mmap_highest_bit(top_addr & ~desc->select & ~desc->disconnect); - disconnect_mask = add_bits_down(desc->len - 1); + disconnect_mask = mmap_add_bits_down(desc->len - 1); desc->disconnect &= disconnect_mask; while ((~disconnect_mask) >> 1 & desc->disconnect) @@ -1334,7 +1334,7 @@ bool rarch_environment_cb(unsigned cmd, void *data) memcpy((void*)system->mmaps.descriptors, mmaps->descriptors, mmaps->num_descriptors * sizeof(*system->mmaps.descriptors)); system->mmaps.num_descriptors = mmaps->num_descriptors; - preprocess_descriptors(descriptors, mmaps->num_descriptors); + mmap_preprocess_descriptors(descriptors, mmaps->num_descriptors); RARCH_LOG("Environ SET_MEMORY_MAPS.\n"); From 19afc807efa242ef503f184de71469b50e662b6c Mon Sep 17 00:00:00 2001 From: Twinaphex Date: Tue, 10 May 2016 23:33:51 +0200 Subject: [PATCH 404/498] (iOS) Not sure why we are calling rarch_main() twice for iOS --- menu/menu_driver.c | 2 +- ui/drivers/ui_cocoatouch.m | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/menu/menu_driver.c b/menu/menu_driver.c index a7ebcfac2a..006820a9c6 100644 --- a/menu/menu_driver.c +++ b/menu/menu_driver.c @@ -761,7 +761,7 @@ bool menu_driver_ctl(enum rarch_menu_ctl_state state, void *data) if (!latch) return false; - if (menu_driver_ctx->toggle) + if (menu_driver_ctx && menu_driver_ctx->toggle) menu_driver_ctx->toggle(menu_userdata, *latch); } break; diff --git a/ui/drivers/ui_cocoatouch.m b/ui/drivers/ui_cocoatouch.m index 586dada58a..aae07ab0e0 100644 --- a/ui/drivers/ui_cocoatouch.m +++ b/ui/drivers/ui_cocoatouch.m @@ -337,9 +337,6 @@ enum apple_platform = self; [self setDelegate:self]; - - if (rarch_main(argc, argv, NULL)) - apple_rarch_exited(); #ifdef HAVE_AVFOUNDATION /* Other background audio check */ From 2c6cf33dec6477ccd9270040b5e07dd912ef1c11 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 00:26:31 +0200 Subject: [PATCH 405/498] Take out RARCH_CONSOLE ifdef --- performance_counters.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/performance_counters.c b/performance_counters.c index 97e9ec9366..002222ef5c 100644 --- a/performance_counters.c +++ b/performance_counters.c @@ -17,6 +17,12 @@ #include #include +#ifdef _WIN32 +#include +#else +#include +#endif + #include #include "performance_counters.h" @@ -31,10 +37,6 @@ #define PERF_LOG_FMT "[PERF]: Avg (%s): %llu ticks, %llu runs.\n" #endif -#if !defined(_WIN32) && !defined(RARCH_CONSOLE) -#include -#endif - static struct retro_perf_counter *perf_counters_rarch[MAX_COUNTERS]; static struct retro_perf_counter *perf_counters_libretro[MAX_COUNTERS]; static unsigned perf_ptr_rarch; From 4ad23c927ae4d2db3663b48574c8566f87faa3d7 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 00:40:34 +0200 Subject: [PATCH 406/498] Take out RARCH_CONSOLE ifdefs --- menu/menu_setting.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/menu/menu_setting.c b/menu/menu_setting.c index d6e20db97a..427aca79d9 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -4594,7 +4594,7 @@ static bool setting_append_list( &subgroup_info, parent_group); -#if defined(HAVE_THREADS) && !defined(RARCH_CONSOLE) +#if defined(HAVE_THREADS) CONFIG_BOOL( list, list_info, &settings->video.threaded, @@ -5454,7 +5454,6 @@ static bool setting_append_list( &subgroup_info, parent_group); -#ifndef RARCH_CONSOLE CONFIG_BOOL( list, list_info, &settings->video.font_enable, @@ -5468,7 +5467,6 @@ static bool setting_append_list( parent_group, general_write_handler, general_read_handler); -#endif CONFIG_PATH( list, list_info, From 1ac30884c438b9b70a645589bb04620c46e4e719 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 03:40:25 +0200 Subject: [PATCH 407/498] (RJPEG) Prevent warnings --- libretro-common/formats/jpeg/rjpeg.c | 26 ++++++++++++++++++++++- libretro-common/include/formats/image.h | 2 +- libretro-common/include/formats/jsonsax.h | 2 +- libretro-common/include/formats/rjpeg.h | 2 +- libretro-common/include/formats/rxml.h | 2 +- 5 files changed, 29 insertions(+), 5 deletions(-) diff --git a/libretro-common/formats/jpeg/rjpeg.c b/libretro-common/formats/jpeg/rjpeg.c index 7e384ad7fa..a9ca0b753f 100644 --- a/libretro-common/formats/jpeg/rjpeg.c +++ b/libretro-common/formats/jpeg/rjpeg.c @@ -1,3 +1,25 @@ +/* Copyright (C) 2010-2016 The RetroArch team + * + * --------------------------------------------------------------------------------------- + * The following license statement only applies to this file (rjpeg.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. + */ + /* Modified version of stb_image's JPEG sources. */ @@ -2422,7 +2444,9 @@ bool rjpeg_image_load(uint8_t *_buf, void *data, size_t size, unsigned a_shift, unsigned r_shift, unsigned g_shift, unsigned b_shift) { - int x, y, comp; + int comp; + int x = 0; + int y = 0; struct texture_image *out_img = (struct texture_image*)data; out_img->pixels = (uint32_t*)rjpeg_load_from_memory(_buf, size, &x, &y, &comp, 4); diff --git a/libretro-common/include/formats/image.h b/libretro-common/include/formats/image.h index 1f96b81efd..3c98761b3e 100644 --- a/libretro-common/include/formats/image.h +++ b/libretro-common/include/formats/image.h @@ -1,6 +1,6 @@ /* RetroArch - A frontend for libretro. * Copyright (C) 2010-2014 - Hans-Kristian Arntzen - * Copyright (C) 2011-2015 - Daniel De Matteis + * 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- diff --git a/libretro-common/include/formats/jsonsax.h b/libretro-common/include/formats/jsonsax.h index 76860fe5f5..86d6d6b207 100644 --- a/libretro-common/include/formats/jsonsax.h +++ b/libretro-common/include/formats/jsonsax.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2015 The RetroArch team +/* Copyright (C) 2010-2016 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (jsonsax.h). diff --git a/libretro-common/include/formats/rjpeg.h b/libretro-common/include/formats/rjpeg.h index 539fd058df..81f61b92af 100644 --- a/libretro-common/include/formats/rjpeg.h +++ b/libretro-common/include/formats/rjpeg.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2015 The RetroArch team +/* Copyright (C) 2010-2016 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (rjpeg.h). diff --git a/libretro-common/include/formats/rxml.h b/libretro-common/include/formats/rxml.h index 3ee1109601..c3f3335c19 100644 --- a/libretro-common/include/formats/rxml.h +++ b/libretro-common/include/formats/rxml.h @@ -1,4 +1,4 @@ -/* Copyright (C) 2010-2015 The RetroArch team +/* Copyright (C) 2010-2016 The RetroArch team * * --------------------------------------------------------------------------------------- * The following license statement only applies to this file (rxml.h). From 1b4d744dcdf476758ffbef1d5f21d76f29e5db4e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 03:51:26 +0200 Subject: [PATCH 408/498] (task_image.c) Cleanups --- tasks/task_image.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/tasks/task_image.c b/tasks/task_image.c index 7ae06bfa25..0944079394 100644 --- a/tasks/task_image.c +++ b/tasks/task_image.c @@ -154,18 +154,6 @@ static int cb_image_menu_generic_rpng(nbio_handle_t *nbio) return 0; } -static int cb_image_menu_wallpaper_rpng(void *data, size_t len) -{ - nbio_handle_t *nbio = (nbio_handle_t*)data; - - if (cb_image_menu_generic_rpng(nbio) != 0) - return -1; - - nbio->image.cb = &cb_image_menu_upload_generic; - - return 0; -} - static int cb_image_menu_thumbnail(void *data, size_t len) { nbio_handle_t *nbio = (nbio_handle_t*)data; @@ -190,9 +178,11 @@ static int rarch_main_data_image_iterate_transfer(nbio_handle_t *nbio) for (i = 0; i < nbio->image.pos_increment; i++) { +#ifdef HAVE_RPNG /* TODO/FIXME - add JPEG equivalents as well */ if (!rpng_nbio_load_image_argb_iterate((rpng_t*)nbio->image.handle)) goto error; +#endif } nbio->image.frame_count++; @@ -251,12 +241,17 @@ static int cb_nbio_generic_rpng(nbio_handle_t *nbio, size_t *len) if (!ptr) goto error; +#ifdef HAVE_RPNG rpng_set_buf_ptr((rpng_t*)nbio->image.handle, (uint8_t*)ptr); +#endif + nbio->image.pos_increment = (*len / 2) ? (*len / 2) : 1; nbio->image.processing_pos_increment = (*len / 4) ? (*len / 4) : 1; +#ifdef HAVE_RPNG if (!rpng_nbio_load_image_argb_start((rpng_t*)nbio->image.handle)) goto error; +#endif nbio->image.is_blocking = false; nbio->image.is_finished = false; @@ -276,8 +271,11 @@ static int cb_nbio_image_menu_wallpaper_rpng(void *data, size_t len) if (!nbio || !data) return -1; +#ifdef HAVE_RPNG nbio->image.handle = rpng_alloc(); - nbio->image.cb = &cb_image_menu_wallpaper_rpng; +#endif + + nbio->image.cb = &cb_image_menu_thumbnail; return cb_nbio_generic_rpng(nbio, &len); } @@ -289,7 +287,10 @@ static int cb_nbio_image_menu_thumbnail_rpng(void *data, size_t len) if (!nbio || !data) return -1; +#ifdef HAVE_RPNG nbio->image.handle = rpng_alloc(); +#endif + nbio->image.cb = &cb_image_menu_thumbnail; return cb_nbio_generic_rpng(nbio, &len); From e6f55814a9eae3da0c59245337ae1bd43a000cab Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 03:55:09 +0200 Subject: [PATCH 409/498] (task_image.c) Cleanups --- tasks/task_image.c | 49 ++++++++++++---------------------------------- 1 file changed, 13 insertions(+), 36 deletions(-) diff --git a/tasks/task_image.c b/tasks/task_image.c index 0944079394..55aaf49f61 100644 --- a/tasks/task_image.c +++ b/tasks/task_image.c @@ -71,18 +71,6 @@ static int cb_image_menu_upload_generic(void *data, size_t len) return 0; } -static int rarch_main_data_image_iterate_process_transfer_parse( - nbio_handle_t *nbio) -{ - if (nbio->image.handle && nbio->image.cb) - { - size_t len = 0; - nbio->image.cb(nbio, len); - } - - return 0; -} - static int rarch_main_data_image_iterate_transfer_parse(nbio_handle_t *nbio) { if (nbio->image.handle && nbio->image.cb) @@ -130,8 +118,7 @@ static int rarch_main_data_image_process( return *retval; } -#ifdef HAVE_RPNG -static int cb_image_menu_generic_rpng(nbio_handle_t *nbio) +static int cb_image_menu_generic(nbio_handle_t *nbio) { int retval = 0; unsigned width = 0, height = 0; @@ -158,7 +145,7 @@ static int cb_image_menu_thumbnail(void *data, size_t len) { nbio_handle_t *nbio = (nbio_handle_t*)data; - if (cb_image_menu_generic_rpng(nbio) != 0) + if (cb_image_menu_generic(nbio) != 0) return -1; nbio->image.cb = &cb_image_menu_upload_generic; @@ -166,6 +153,7 @@ static int cb_image_menu_thumbnail(void *data, size_t len) return 0; } +#ifdef HAVE_RPNG static int rarch_main_data_image_iterate_transfer(nbio_handle_t *nbio) { unsigned i; @@ -264,22 +252,6 @@ error: return -1; } -static int cb_nbio_image_menu_wallpaper_rpng(void *data, size_t len) -{ - nbio_handle_t *nbio = (nbio_handle_t*)data; - - if (!nbio || !data) - return -1; - -#ifdef HAVE_RPNG - nbio->image.handle = rpng_alloc(); -#endif - - nbio->image.cb = &cb_image_menu_thumbnail; - - return cb_nbio_generic_rpng(nbio, &len); -} - static int cb_nbio_image_menu_thumbnail_rpng(void *data, size_t len) { nbio_handle_t *nbio = (nbio_handle_t*)data; @@ -319,7 +291,7 @@ bool rarch_task_image_load_handler(retro_task_t *task) image->status = IMAGE_STATUS_TRANSFER_PARSE; break; case IMAGE_STATUS_PROCESS_TRANSFER_PARSE: - rarch_main_data_image_iterate_process_transfer_parse(nbio); + rarch_main_data_image_iterate_transfer_parse(nbio); if (!image->is_finished) break; case IMAGE_STATUS_TRANSFER_PARSE_FREE: @@ -368,10 +340,15 @@ bool rarch_task_push_image_load(const char *fullpath, if (strstr(fullpath, ".png")) { #ifdef HAVE_RPNG - if (cb_type_hash == CB_MENU_WALLPAPER) - nbio->cb = &cb_nbio_image_menu_wallpaper_rpng; - else if (cb_type_hash == CB_MENU_THUMBNAIL) - nbio->cb = &cb_nbio_image_menu_thumbnail_rpng; + switch (cb_type_hash) + { + case CB_MENU_WALLPAPER: + case CB_MENU_THUMBNAIL: + nbio->cb = &cb_nbio_image_menu_thumbnail_rpng; + break; + default: + break; + } #endif } else if (strstr(fullpath, ".jpeg") || strstr(fullpath, ".jpg")) From 556017f23d043cc07714c581b2e381a96ed00fb3 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 03:56:31 +0200 Subject: [PATCH 410/498] Cleanup --- tasks/task_image.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasks/task_image.c b/tasks/task_image.c index 55aaf49f61..07da9dcd62 100644 --- a/tasks/task_image.c +++ b/tasks/task_image.c @@ -252,7 +252,7 @@ error: return -1; } -static int cb_nbio_image_menu_thumbnail_rpng(void *data, size_t len) +static int cb_nbio_image_menu_thumbnail(void *data, size_t len) { nbio_handle_t *nbio = (nbio_handle_t*)data; @@ -344,7 +344,7 @@ bool rarch_task_push_image_load(const char *fullpath, { case CB_MENU_WALLPAPER: case CB_MENU_THUMBNAIL: - nbio->cb = &cb_nbio_image_menu_thumbnail_rpng; + nbio->cb = &cb_nbio_image_menu_thumbnail; break; default: break; From e6969f7ceda3784bffda1652aa3e984c165ff892 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 04:03:21 +0200 Subject: [PATCH 411/498] Cleanups --- tasks/task_image.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tasks/task_image.c b/tasks/task_image.c index 07da9dcd62..be15b3e1e2 100644 --- a/tasks/task_image.c +++ b/tasks/task_image.c @@ -217,7 +217,7 @@ static void rarch_task_image_load_free_internal(nbio_handle_t *nbio) image->frame_count = 0; } -static int cb_nbio_generic_rpng(nbio_handle_t *nbio, size_t *len) +static int cb_nbio_generic(nbio_handle_t *nbio, size_t *len) { void *ptr = NULL; @@ -265,7 +265,7 @@ static int cb_nbio_image_menu_thumbnail(void *data, size_t len) nbio->image.cb = &cb_image_menu_thumbnail; - return cb_nbio_generic_rpng(nbio, &len); + return cb_nbio_generic(nbio, &len); } #endif From 5ad45ea17f49c4735d3f0d71d1849e4209651bf5 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 04:10:42 +0200 Subject: [PATCH 412/498] task_image.c - Refactors to prepare it for JPEG support --- tasks/task_image.c | 94 +++++++++++++++++++++++++++++------------- tasks/tasks_internal.h | 10 ++++- 2 files changed, 74 insertions(+), 30 deletions(-) diff --git a/tasks/task_image.c b/tasks/task_image.c index be15b3e1e2..bcc25af17e 100644 --- a/tasks/task_image.c +++ b/tasks/task_image.c @@ -102,15 +102,22 @@ static int rarch_main_data_image_process( unsigned *height, int *retval) { + switch (nbio->image_type) + { + case IMAGE_TYPE_PNG: #ifdef HAVE_RPNG - if (!rpng_is_valid((rpng_t*)nbio->image.handle)) - return IMAGE_PROCESS_ERROR; + if (!rpng_is_valid((rpng_t*)nbio->image.handle)) + return IMAGE_PROCESS_ERROR; - *retval = rpng_nbio_load_image_argb_process( - (rpng_t*)nbio->image.handle, - &nbio->image.ti.pixels, - width, height); + *retval = rpng_nbio_load_image_argb_process( + (rpng_t*)nbio->image.handle, + &nbio->image.ti.pixels, + width, height); #endif + break; + case IMAGE_TYPE_JPEG: + break; + } nbio->image.ti.width = *width; nbio->image.ti.height = *height; @@ -166,11 +173,17 @@ static int rarch_main_data_image_iterate_transfer(nbio_handle_t *nbio) for (i = 0; i < nbio->image.pos_increment; i++) { + switch (nbio->image_type) + { + case IMAGE_TYPE_PNG: #ifdef HAVE_RPNG - /* TODO/FIXME - add JPEG equivalents as well */ - if (!rpng_nbio_load_image_argb_iterate((rpng_t*)nbio->image.handle)) - goto error; + if (!rpng_nbio_load_image_argb_iterate((rpng_t*)nbio->image.handle)) + goto error; #endif + break; + case IMAGE_TYPE_JPEG: + break; + } } nbio->image.frame_count++; @@ -207,10 +220,16 @@ static void rarch_task_image_load_free_internal(nbio_handle_t *nbio) { nbio_image_handle_t *image = nbio ? &nbio->image : NULL; + switch (nbio->image_type) + { + case IMAGE_TYPE_PNG: #ifdef HAVE_RPNG - /* TODO/FIXME - add JPEG equivalents as well */ - rpng_nbio_load_image_free((rpng_t*)image->handle); + rpng_nbio_load_image_free((rpng_t*)image->handle); #endif + break; + case IMAGE_TYPE_JPEG: + break; + } image->handle = NULL; image->cb = NULL; @@ -229,17 +248,31 @@ static int cb_nbio_generic(nbio_handle_t *nbio, size_t *len) if (!ptr) goto error; + switch (nbio->image_type) + { + case IMAGE_TYPE_PNG: #ifdef HAVE_RPNG - rpng_set_buf_ptr((rpng_t*)nbio->image.handle, (uint8_t*)ptr); + rpng_set_buf_ptr((rpng_t*)nbio->image.handle, (uint8_t*)ptr); #endif + break; + case IMAGE_TYPE_JPEG: + break; + } nbio->image.pos_increment = (*len / 2) ? (*len / 2) : 1; nbio->image.processing_pos_increment = (*len / 4) ? (*len / 4) : 1; + switch (nbio->image_type) + { + case IMAGE_TYPE_PNG: #ifdef HAVE_RPNG - if (!rpng_nbio_load_image_argb_start((rpng_t*)nbio->image.handle)) - goto error; + if (!rpng_nbio_load_image_argb_start((rpng_t*)nbio->image.handle)) + goto error; #endif + break; + case IMAGE_TYPE_JPEG: + break; + } nbio->image.is_blocking = false; nbio->image.is_finished = false; @@ -259,9 +292,16 @@ static int cb_nbio_image_menu_thumbnail(void *data, size_t len) if (!nbio || !data) return -1; + switch (nbio->image_type) + { + case IMAGE_TYPE_PNG: #ifdef HAVE_RPNG - nbio->image.handle = rpng_alloc(); + nbio->image.handle = rpng_alloc(); #endif + break; + case IMAGE_TYPE_JPEG: + break; + } nbio->image.cb = &cb_image_menu_thumbnail; @@ -338,22 +378,18 @@ bool rarch_task_push_image_load(const char *fullpath, nbio->image.status = IMAGE_STATUS_TRANSFER; if (strstr(fullpath, ".png")) - { -#ifdef HAVE_RPNG - switch (cb_type_hash) - { - case CB_MENU_WALLPAPER: - case CB_MENU_THUMBNAIL: - nbio->cb = &cb_nbio_image_menu_thumbnail; - break; - default: - break; - } -#endif - } + nbio->image_type = IMAGE_TYPE_PNG; else if (strstr(fullpath, ".jpeg") || strstr(fullpath, ".jpg")) + nbio->image_type = IMAGE_TYPE_JPEG; + + switch (cb_type_hash) { - /* TODO/FIXME */ + case CB_MENU_WALLPAPER: + case CB_MENU_THUMBNAIL: + nbio->cb = &cb_nbio_image_menu_thumbnail; + break; + default: + break; } nbio_begin_read(handle); diff --git a/tasks/tasks_internal.h b/tasks/tasks_internal.h index 1427740abb..737261fe74 100644 --- a/tasks/tasks_internal.h +++ b/tasks/tasks_internal.h @@ -40,8 +40,15 @@ enum nbio_status_enum NBIO_STATUS_TRANSFER_PARSE_FREE }; +enum image_type_enum +{ + IMAGE_TYPE_PNG = 0, + IMAGE_TYPE_JPEG +}; + #ifdef HAVE_NETWORKING -typedef struct { +typedef struct +{ char *data; size_t len; } http_transfer_data_t; @@ -70,6 +77,7 @@ typedef struct nbio_image_handle typedef struct nbio_handle { + enum image_type_enum image_type; nbio_image_handle_t image; bool is_finished; transfer_cb_t cb; From b9df6f52f53343d1c0be0aa6865ce21fbefee4cc Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 04:22:22 +0200 Subject: [PATCH 413/498] Kill off a bunch of RARCH_CTL_LOAD_CONTENT enums --- command.c | 23 +++++++++++++++-------- retroarch.c | 12 ------------ retroarch.h | 6 ------ runloop.c | 9 ++++++++- 4 files changed, 23 insertions(+), 27 deletions(-) diff --git a/command.c b/command.c index 4259459032..beabb1c5d5 100644 --- a/command.c +++ b/command.c @@ -70,6 +70,7 @@ #ifdef HAVE_MENU #include "menu/menu_driver.h" +#include "menu/menu_content.h" #include "menu/menu_display.h" #include "menu/menu_shader.h" #endif @@ -1559,8 +1560,13 @@ static bool command_event_cmd_exec(void *data) } #if defined(HAVE_DYNAMIC) - if (!rarch_ctl(RARCH_CTL_LOAD_CONTENT, NULL)) +#ifdef HAVE_MENU + if (!menu_content_ctl(MENU_CONTENT_CTL_LOAD, NULL)) + { + rarch_ctl(RARCH_CTL_MENU_RUNNING, NULL); return false; + } +#endif #else frontend_driver_set_fork(FRONTEND_FORK_CORE_WITH_ARGS); #endif @@ -1620,15 +1626,16 @@ bool command_event(enum event_command cmd, void *data) #ifdef HAVE_DYNAMIC command_event(CMD_EVENT_LOAD_CORE, NULL); #endif - rarch_ctl(RARCH_CTL_LOAD_CONTENT, NULL); - break; -#ifdef HAVE_FFMPEG + /* fall-through */ case CMD_EVENT_LOAD_CONTENT_FFMPEG: - rarch_ctl(RARCH_CTL_LOAD_CONTENT_FFMPEG, NULL); - break; -#endif case CMD_EVENT_LOAD_CONTENT_IMAGEVIEWER: - rarch_ctl(RARCH_CTL_LOAD_CONTENT_IMAGEVIEWER, NULL); +#ifdef HAVE_MENU + if (!menu_content_ctl(MENU_CONTENT_CTL_LOAD, NULL)) + { + rarch_ctl(RARCH_CTL_MENU_RUNNING, NULL); + return false; + } +#endif break; case CMD_EVENT_LOAD_CONTENT: { diff --git a/retroarch.c b/retroarch.c index dd6801fc3d..85f46f4072 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1513,18 +1513,6 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data) #ifdef HAVE_OVERLAY if (settings->input.overlay_hide_in_menu) command_event(CMD_EVENT_OVERLAY_DEINIT, NULL); -#endif - break; - case RARCH_CTL_LOAD_CONTENT: - case RARCH_CTL_LOAD_CONTENT_FFMPEG: - case RARCH_CTL_LOAD_CONTENT_IMAGEVIEWER: -#ifdef HAVE_MENU - /* If content loading fails, we go back to menu. */ - if (!menu_content_ctl(MENU_CONTENT_CTL_LOAD, NULL)) - { - rarch_ctl(RARCH_CTL_MENU_RUNNING, NULL); - return false; - } #endif break; case RARCH_CTL_MENU_RUNNING_FINISHED: diff --git a/retroarch.h b/retroarch.h index 253c659105..7b5e9bb023 100644 --- a/retroarch.h +++ b/retroarch.h @@ -80,12 +80,6 @@ enum rarch_ctl_state RARCH_CTL_DESTROY, - RARCH_CTL_LOAD_CONTENT, - - RARCH_CTL_LOAD_CONTENT_FFMPEG, - - RARCH_CTL_LOAD_CONTENT_IMAGEVIEWER, - RARCH_CTL_MENU_RUNNING, RARCH_CTL_MENU_RUNNING_FINISHED, diff --git a/runloop.c b/runloop.c index 2bd9e449eb..dd257f8460 100644 --- a/runloop.c +++ b/runloop.c @@ -60,6 +60,7 @@ #ifdef HAVE_MENU #include "menu/menu_driver.h" +#include "menu/menu_content.h" #endif #ifdef HAVE_NETPLAY @@ -1052,7 +1053,13 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) runloop_ctl(RUNLOOP_CTL_TASK_INIT, NULL); runloop_ctl(RUNLOOP_CTL_CLEAR_CONTENT_PATH, NULL); - rarch_ctl(RARCH_CTL_LOAD_CONTENT, NULL); +#ifdef HAVE_MENU + if (!menu_content_ctl(MENU_CONTENT_CTL_LOAD, NULL)) + { + rarch_ctl(RARCH_CTL_MENU_RUNNING, NULL); + return false; + } +#endif break; case RUNLOOP_CTL_SET_CORE_SHUTDOWN: runloop_core_shutdown_initiated = true; From 95a6428915b182251cb74acaaac48f0dc936b684 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 04:24:27 +0200 Subject: [PATCH 414/498] RARCH_CTL_FORCE_QUIT is the same as RARCH_CTL_QUIT --- command.c | 6 +++--- frontend/drivers/platform_gx.c | 2 +- frontend/drivers/platform_linux.c | 2 +- retroarch.c | 3 --- retroarch.h | 2 -- 5 files changed, 5 insertions(+), 10 deletions(-) diff --git a/command.c b/command.c index beabb1c5d5..40d4dc1075 100644 --- a/command.c +++ b/command.c @@ -2032,19 +2032,19 @@ bool command_event(enum event_command cmd, void *data) } break; case CMD_EVENT_QUIT_RETROARCH: - rarch_ctl(RARCH_CTL_FORCE_QUIT, NULL); + rarch_ctl(RARCH_CTL_QUIT, NULL); break; case CMD_EVENT_SHUTDOWN: #if defined(__linux__) && !defined(ANDROID) runloop_msg_queue_push("Shutting down...", 1, 180, true); - rarch_ctl(RARCH_CTL_FORCE_QUIT, NULL); + rarch_ctl(RARCH_CTL_QUIT, NULL); system("shutdown -P now"); #endif break; case CMD_EVENT_REBOOT: #if defined(__linux__) && !defined(ANDROID) runloop_msg_queue_push("Rebooting...", 1, 180, true); - rarch_ctl(RARCH_CTL_FORCE_QUIT, NULL); + rarch_ctl(RARCH_CTL_QUIT, NULL); system("shutdown -r now"); #endif break; diff --git a/frontend/drivers/platform_gx.c b/frontend/drivers/platform_gx.c index 6e5d43edee..a4e070e30b 100644 --- a/frontend/drivers/platform_gx.c +++ b/frontend/drivers/platform_gx.c @@ -426,7 +426,7 @@ static bool frontend_gx_set_fork(enum frontend_fork fork_mode) case FRONTEND_FORK_RESTART: RARCH_LOG("FRONTEND_FORK_RESTART\n"); gx_fork_mode = fork_mode; - rarch_ctl(RARCH_CTL_FORCE_QUIT, NULL); + command_event(CMD_EVENT_QUIT_RETROARCH, NULL); break; case FRONTEND_FORK_NONE: default: diff --git a/frontend/drivers/platform_linux.c b/frontend/drivers/platform_linux.c index 592ed1e242..9f0ea43639 100644 --- a/frontend/drivers/platform_linux.c +++ b/frontend/drivers/platform_linux.c @@ -1827,7 +1827,7 @@ static bool frontend_linux_set_fork(enum frontend_fork fork_mode) fill_pathname_application_path(executable_path, sizeof(executable_path)); strlcpy(settings->path.libretro, executable_path, sizeof(settings->path.libretro)); } - rarch_ctl(RARCH_CTL_FORCE_QUIT, NULL); + command_event(CMD_EVENT_QUIT_RETROARCH, NULL); break; case FRONTEND_FORK_NONE: default: diff --git a/retroarch.c b/retroarch.c index 85f46f4072..dbf803e32b 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1529,9 +1529,6 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data) runloop_ctl(RUNLOOP_CTL_SET_SHUTDOWN, NULL); rarch_ctl(RARCH_CTL_MENU_RUNNING_FINISHED, NULL); break; - case RARCH_CTL_FORCE_QUIT: - rarch_ctl(RARCH_CTL_QUIT, NULL); - break; case RARCH_CTL_VALIDATE_CPU_FEATURES: { uint64_t cpu = cpu_features_get(); diff --git a/retroarch.h b/retroarch.h index 7b5e9bb023..f7f4196350 100644 --- a/retroarch.h +++ b/retroarch.h @@ -91,8 +91,6 @@ enum rarch_ctl_state RARCH_CTL_QUIT, - RARCH_CTL_FORCE_QUIT, - /* Validates CPU features for given processor architecture. * Make sure we haven't compiled for something we cannot run. * Ideally, code would get swapped out depending on CPU support, From 030513bceea594e906e95695fb2db73f47a47240 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 04:29:01 +0200 Subject: [PATCH 415/498] Create retroarch_fill_pathnames --- command.c | 4 ++-- retroarch.c | 38 +++++++++++++++++++++----------------- retroarch.h | 4 ++-- 3 files changed, 25 insertions(+), 21 deletions(-) diff --git a/command.c b/command.c index 40d4dc1075..91e9ff2217 100644 --- a/command.c +++ b/command.c @@ -871,7 +871,7 @@ static bool command_event_disk_control_append_image(const char *path) * started out in a single disk case, and that this way * of doing it makes the most sense. */ rarch_ctl(RARCH_CTL_SET_PATHS, (void*)path); - rarch_ctl(RARCH_CTL_FILL_PATHNAMES, NULL); + retroarch_fill_pathnames(); } command_event(CMD_EVENT_AUTOSAVE_INIT, NULL); @@ -1205,7 +1205,7 @@ static bool event_init_content(void) return true; if (!content_does_not_need_content()) - rarch_ctl(RARCH_CTL_FILL_PATHNAMES, NULL); + retroarch_fill_pathnames(); if (!content_init()) return false; diff --git a/retroarch.c b/retroarch.c index dbf803e32b..b2b6b4ace9 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1548,23 +1548,6 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data) #endif } break; - case RARCH_CTL_FILL_PATHNAMES: - retroarch_init_savefile_paths(); - bsv_movie_set_path(global->name.savefile); - - if (!*global->name.base) - return false; - - if (!*global->name.ups) - fill_pathname_noext(global->name.ups, global->name.base, ".ups", - sizeof(global->name.ups)); - if (!*global->name.bps) - fill_pathname_noext(global->name.bps, global->name.base, ".bps", - sizeof(global->name.bps)); - if (!*global->name.ips) - fill_pathname_noext(global->name.ips, global->name.base, ".ips", - sizeof(global->name.ips)); - break; case RARCH_CTL_NONE: default: return false; @@ -1573,6 +1556,27 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data) return true; } +void retroarch_fill_pathnames(void) +{ + global_t *global = global_get_ptr(); + + retroarch_init_savefile_paths(); + bsv_movie_set_path(global->name.savefile); + + if (!*global->name.base) + return; + + if (!*global->name.ups) + fill_pathname_noext(global->name.ups, global->name.base, ".ups", + sizeof(global->name.ups)); + if (!*global->name.bps) + fill_pathname_noext(global->name.bps, global->name.base, ".bps", + sizeof(global->name.bps)); + if (!*global->name.ips) + fill_pathname_noext(global->name.ips, global->name.base, ".ips", + sizeof(global->name.ips)); +} + int retroarch_get_capabilities(enum rarch_capabilities type, char *s, size_t len) { diff --git a/retroarch.h b/retroarch.h index f7f4196350..36dd53cc03 100644 --- a/retroarch.h +++ b/retroarch.h @@ -97,8 +97,6 @@ enum rarch_ctl_state * but this will do for now. */ RARCH_CTL_VALIDATE_CPU_FEATURES, - RARCH_CTL_FILL_PATHNAMES, - RARCH_CTL_SET_PATHS_REDIRECT, RARCH_CTL_SET_SRAM_ENABLE, @@ -171,6 +169,8 @@ const char *retroarch_get_current_savefile_dir(void); bool retroarch_validate_game_options(char *s, size_t len, bool mkdir); +void retroarch_fill_pathnames(void); + /** * retroarch_fail: * @error_code : Error code. From 7ebfe1b66d3b217ecd701b2ea371c742e9071817 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 04:32:29 +0200 Subject: [PATCH 416/498] Create retroarch_set_pathnames --- command.c | 2 +- retroarch.c | 34 +++++++++++++++++++--------------- retroarch.h | 4 ++-- 3 files changed, 22 insertions(+), 18 deletions(-) diff --git a/command.c b/command.c index 91e9ff2217..f3b4ba0378 100644 --- a/command.c +++ b/command.c @@ -870,7 +870,7 @@ static bool command_event_disk_control_append_image(const char *path) * If we actually use append_image, we assume that we * started out in a single disk case, and that this way * of doing it makes the most sense. */ - rarch_ctl(RARCH_CTL_SET_PATHS, (void*)path); + retroarch_set_pathnames(path); retroarch_fill_pathnames(); } diff --git a/retroarch.c b/retroarch.c index b2b6b4ace9..aedcb24b83 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1040,7 +1040,7 @@ static void retroarch_parse_input(int argc, char *argv[]) { /* We requested explicit ROM, so use PLAIN core type. */ current_core_type = CORE_TYPE_PLAIN; - rarch_ctl(RARCH_CTL_SET_PATHS, (void*)argv[optind]); + retroarch_set_pathnames((const char*)argv[optind]); } else if (*global->subsystem && optind < argc) { @@ -1340,20 +1340,6 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data) switch(state) { - case RARCH_CTL_SET_PATHS: - retroarch_set_basename((const char*)data); - - if (!global->has_set.save_path) - fill_pathname_noext(global->name.savefile, global->name.base, - ".srm", sizeof(global->name.savefile)); - if (!global->has_set.state_path) - fill_pathname_noext(global->name.savestate, global->name.base, - ".state", sizeof(global->name.savestate)); - fill_pathname_noext(global->name.cheatfile, global->name.base, - ".cht", sizeof(global->name.cheatfile)); - - retroarch_set_paths_redirect((const char*)data); - break; case RARCH_CTL_IS_PLAIN_CORE: return (current_core_type == CORE_TYPE_PLAIN); case RARCH_CTL_IS_DUMMY_CORE: @@ -1556,6 +1542,24 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data) return true; } +void retroarch_set_pathnames(const char *path) +{ + global_t *global = global_get_ptr(); + + retroarch_set_basename(path); + + if (!global->has_set.save_path) + fill_pathname_noext(global->name.savefile, global->name.base, + ".srm", sizeof(global->name.savefile)); + if (!global->has_set.state_path) + fill_pathname_noext(global->name.savestate, global->name.base, + ".state", sizeof(global->name.savestate)); + fill_pathname_noext(global->name.cheatfile, global->name.base, + ".cht", sizeof(global->name.cheatfile)); + + retroarch_set_paths_redirect(path); +} + void retroarch_fill_pathnames(void) { global_t *global = global_get_ptr(); diff --git a/retroarch.h b/retroarch.h index 36dd53cc03..d4e13ab3c4 100644 --- a/retroarch.h +++ b/retroarch.h @@ -101,8 +101,6 @@ enum rarch_ctl_state RARCH_CTL_SET_SRAM_ENABLE, - RARCH_CTL_SET_PATHS, - RARCH_CTL_SET_FORCE_FULLSCREEN, RARCH_CTL_UNSET_FORCE_FULLSCREEN, @@ -169,6 +167,8 @@ const char *retroarch_get_current_savefile_dir(void); bool retroarch_validate_game_options(char *s, size_t len, bool mkdir); +void retroarch_set_pathnames(const char *path); + void retroarch_fill_pathnames(void); /** From b0342ebe44f43eeaf8b32d543553bd91b3d610fb Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 09:52:06 +0200 Subject: [PATCH 417/498] Buildfix for compiling without ffmpeg --- command.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/command.h b/command.h index 92dd882916..b10279a548 100644 --- a/command.h +++ b/command.h @@ -44,9 +44,7 @@ enum event_command /* Loads content file. */ CMD_EVENT_LOAD_CONTENT, CMD_EVENT_LOAD_CONTENT_PERSIST, -#ifdef HAVE_FFMPEG CMD_EVENT_LOAD_CONTENT_FFMPEG, -#endif CMD_EVENT_LOAD_CONTENT_IMAGEVIEWER, CMD_EVENT_SET_PER_GAME_RESOLUTION, CMD_EVENT_SET_FRAME_LIMIT, From 78783cc2aa55ad1809b44f4c0b7f09400369b716 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 10:06:15 +0200 Subject: [PATCH 418/498] Buildfixes for compiling without HAVE_MENU --- cheevos.c | 1 + driver.c | 1 + gfx/drivers/vulkan.c | 2 ++ 3 files changed, 4 insertions(+) diff --git a/cheevos.c b/cheevos.c index ff3f473944..67c8600804 100644 --- a/cheevos.c +++ b/cheevos.c @@ -23,6 +23,7 @@ #include #include "cheevos.h" +#include "command.h" #include "dynamic.h" #include "network/net_http_special.h" #include "configuration.h" diff --git a/driver.c b/driver.c index 5e6c076363..9bebc2a2a8 100644 --- a/driver.c +++ b/driver.c @@ -17,6 +17,7 @@ #include #include +#include "command.h" #include "general.h" #include "msg_hash.h" #include "system.h" diff --git a/gfx/drivers/vulkan.c b/gfx/drivers/vulkan.c index 7975eddfcb..aab91ebcc3 100644 --- a/gfx/drivers/vulkan.c +++ b/gfx/drivers/vulkan.c @@ -2008,7 +2008,9 @@ static const video_poke_interface_t vulkan_poke_interface = { NULL, NULL, #endif +#ifdef HAVE_MENU vulkan_set_osd_msg, +#endif vulkan_show_mouse, NULL, vulkan_get_current_shader, From fc56f6ebdb0a9a5e1b296de6ce3c3602c9f70426 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 10:10:30 +0200 Subject: [PATCH 419/498] Add some HAVE_THREADS ifdefs --- gfx/common/vulkan_common.c | 10 ++++++++++ gfx/drivers/gl.c | 2 ++ gfx/drivers/vulkan.c | 12 ++++++++++++ 3 files changed, 24 insertions(+) diff --git a/gfx/common/vulkan_common.c b/gfx/common/vulkan_common.c index 7f232211b1..6a205c6638 100644 --- a/gfx/common/vulkan_common.c +++ b/gfx/common/vulkan_common.c @@ -481,7 +481,9 @@ struct vk_texture vulkan_create_texture(vk_t *vk, submit_info.commandBufferCount = 1; submit_info.pCommandBuffers = &staging; +#ifdef HAVE_THREADS slock_lock(vk->context->queue_lock); +#endif VKFUNC(vkQueueSubmit)(vk->context->queue, 1, &submit_info, VK_NULL_HANDLE); @@ -489,7 +491,9 @@ struct vk_texture vulkan_create_texture(vk_t *vk, * during init, so waiting for GPU to complete transfer * and blocking isn't a big deal. */ VKFUNC(vkQueueWaitIdle)(vk->context->queue); +#ifdef HAVE_THREADS slock_unlock(vk->context->queue_lock); +#endif VKFUNC(vkFreeCommandBuffers)(vk->context->device, vk->staging_pool, 1, &staging); vulkan_destroy_texture( @@ -1423,9 +1427,11 @@ bool vulkan_context_init(gfx_ctx_vulkan_data_t *vk, break; } +#ifdef HAVE_THREADS vk->context.queue_lock = slock_new(); if (!vk->context.queue_lock) return false; +#endif return true; } @@ -1577,7 +1583,9 @@ void vulkan_present(gfx_ctx_vulkan_data_t *vk, unsigned index) present.pWaitSemaphores = &vk->context.swapchain_semaphores[index]; /* Better hope QueuePresent doesn't block D: */ +#ifdef HAVE_THREADS slock_lock(vk->context.queue_lock); +#endif err = VKFUNC(vkQueuePresentKHR)(vk->context.queue, &present); if (err != VK_SUCCESS || result != VK_SUCCESS) @@ -1586,7 +1594,9 @@ void vulkan_present(gfx_ctx_vulkan_data_t *vk, unsigned index) vk->context.invalid_swapchain = true; } +#ifdef HAVE_THREADS slock_unlock(vk->context.queue_lock); +#endif } void vulkan_context_destroy(gfx_ctx_vulkan_data_t *vk, diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 7f0fe2f7c2..cfaff3e26f 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -3786,6 +3786,7 @@ static void video_texture_load_gl( ); } +#ifdef HAVE_THREADS static int video_texture_load_wrap_gl_mipmap(void *data) { uintptr_t id = 0; @@ -3807,6 +3808,7 @@ static int video_texture_load_wrap_gl(void *data) TEXTURE_FILTER_LINEAR, &id); return id; } +#endif static uintptr_t gl_load_texture(void *video_data, void *data, bool threaded, enum texture_filter_type filter_type) diff --git a/gfx/drivers/vulkan.c b/gfx/drivers/vulkan.c index aab91ebcc3..c46ea440e5 100644 --- a/gfx/drivers/vulkan.c +++ b/gfx/drivers/vulkan.c @@ -885,13 +885,17 @@ static void vulkan_set_command_buffers(void *handle, uint32_t num_cmd, static void vulkan_lock_queue(void *handle) { vk_t *vk = (vk_t*)handle; +#ifdef HAVE_THREADS slock_lock(vk->context->queue_lock); +#endif } static void vulkan_unlock_queue(void *handle) { vk_t *vk = (vk_t*)handle; +#ifdef HAVE_THREADS slock_unlock(vk->context->queue_lock); +#endif } static void vulkan_init_hw_render(vk_t *vk) @@ -1741,10 +1745,14 @@ static bool vulkan_frame(void *data, const void *frame, retro_perf_start(&queue_submit); +#ifdef HAVE_THREADS slock_lock(vk->context->queue_lock); +#endif VKFUNC(vkQueueSubmit)(vk->context->queue, 1, &submit_info, vk->context->swapchain_fences[frame_index]); +#ifdef HAVE_THREADS slock_unlock(vk->context->queue_lock); +#endif retro_perf_stop(&queue_submit); retro_perf_start(&swapbuffers); @@ -2263,9 +2271,13 @@ static bool vulkan_overlay_load(void *data, if (!vk) return false; +#ifdef HAVE_THREADS slock_lock(vk->context->queue_lock); +#endif VKFUNC(vkQueueWaitIdle)(vk->context->queue); +#ifdef HAVE_THREADS slock_unlock(vk->context->queue_lock); +#endif vulkan_overlay_free(vk); vk->overlay.images = (struct vk_texture*) From 377f09f12a51a6a50e31decf68f54bd0cf9eab39 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 18:54:22 +0200 Subject: [PATCH 420/498] Change back retro_dirent_is_dir to hopefully avoid sshfs issues - more rigorous testing should be applied before changing these functions --- libretro-common/file/retro_dirent.c | 5 +---- libretro-common/include/retro_dirent.h | 2 +- libretro-common/lists/dir_list.c | 2 +- 3 files changed, 3 insertions(+), 6 deletions(-) diff --git a/libretro-common/file/retro_dirent.c b/libretro-common/file/retro_dirent.c index bdb50094a9..15046be14c 100644 --- a/libretro-common/file/retro_dirent.c +++ b/libretro-common/file/retro_dirent.c @@ -158,7 +158,7 @@ const char *retro_dirent_get_name(struct RDIR *rdir) * Returns: true if directory listing entry is * a directory, false if not. */ -bool retro_dirent_is_dir(struct RDIR *rdir) +bool retro_dirent_is_dir(struct RDIR *rdir, const char *path) { #if defined(_WIN32) const WIN32_FIND_DATA *entry = (const WIN32_FIND_DATA*)&rdir->entry; @@ -174,18 +174,15 @@ bool retro_dirent_is_dir(struct RDIR *rdir) CellFsDirent *entry = (CellFsDirent*)&rdir->entry; return (entry->d_type == CELL_FS_TYPE_DIRECTORY); #elif defined(DT_DIR) - const char *path = NULL; const struct dirent *entry = (const struct dirent*)rdir->entry; if (entry->d_type == DT_DIR) return true; /* This can happen on certain file systems. */ - path = retro_dirent_get_name(rdir); if (entry->d_type == DT_UNKNOWN || entry->d_type == DT_LNK) return path_is_directory(path); return false; #else /* dirent struct doesn't have d_type, do it the slow way ... */ - const char *path = retro_dirent_get_name(rdir); return path_is_directory(path); #endif } diff --git a/libretro-common/include/retro_dirent.h b/libretro-common/include/retro_dirent.h index 65af28d11d..9b4f53b1d2 100644 --- a/libretro-common/include/retro_dirent.h +++ b/libretro-common/include/retro_dirent.h @@ -49,7 +49,7 @@ const char *retro_dirent_get_name(struct RDIR *rdir); * Returns: true if directory listing entry is * a directory, false if not. */ -bool retro_dirent_is_dir(struct RDIR *rdir); +bool retro_dirent_is_dir(struct RDIR *rdir, const char *path); void retro_closedir(struct RDIR *rdir); diff --git a/libretro-common/lists/dir_list.c b/libretro-common/lists/dir_list.c index 5fb2b373e3..8bcb3f3fbe 100644 --- a/libretro-common/lists/dir_list.c +++ b/libretro-common/lists/dir_list.c @@ -188,7 +188,7 @@ struct string_list *dir_list_new(const char *dir, const char *file_ext = path_get_extension(name); fill_pathname_join(file_path, dir, name, sizeof(file_path)); - is_dir = retro_dirent_is_dir(entry); + is_dir = retro_dirent_is_dir(entry, file_path); ret = parse_dir_entry(name, file_path, is_dir, include_dirs, include_compressed, list, ext_list, file_ext); From 5845a9944d2c2e7c4532c5d739793dee4ac3ae77 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 19:02:43 +0200 Subject: [PATCH 421/498] Add more HAVE_THREADS ifdefs --- Makefile.common | 9 +++++++-- audio/audio_driver.c | 2 +- audio/drivers/jack.c | 14 ++++++++++++++ audio/drivers/sdl_audio.c | 10 ++++++++++ gfx/drivers_context/wayland_ctx.c | 2 +- gfx/drivers_context/x_ctx.c | 2 +- griffin/griffin.c | 2 +- input/input_hid_driver.c | 2 +- 8 files changed, 36 insertions(+), 7 deletions(-) diff --git a/Makefile.common b/Makefile.common index b36ec42be9..4d909c217a 100644 --- a/Makefile.common +++ b/Makefile.common @@ -291,8 +291,11 @@ ifeq ($(HAVE_OSS_BSD), 1) endif ifeq ($(HAVE_ALSA), 1) - OBJ += audio/drivers/alsa.o \ - audio/drivers/alsathread.o + OBJ += audio/drivers/alsa.o + +ifeq ($(HAVE_THREADS), 1) + OBJ += audio/drivers/alsathread.o +endif LIBS += $(ALSA_LIBS) DEFINES += $(ALSA_CFLAGS) endif @@ -575,11 +578,13 @@ ifeq ($(HAVE_UDEV), 1) endif ifeq ($(HAVE_LIBUSB), 1) +ifeq ($(HAVE_THREADS), 1) DEFINES += -DHAVE_LIBUSB OBJ += input/drivers_hid/libusb_hid.o LIBS += -lusb-1.0 HAVE_HID = 1 endif +endif ifeq ($(HAVE_IOHIDMANAGER), 1) DEFINES += -DHAVE_IOHIDMANAGER diff --git a/audio/audio_driver.c b/audio/audio_driver.c index b9cd3fed4c..c875df40f1 100644 --- a/audio/audio_driver.c +++ b/audio/audio_driver.c @@ -93,7 +93,7 @@ typedef struct audio_driver_input_data static const audio_driver_t *audio_drivers[] = { #ifdef HAVE_ALSA &audio_alsa, -#ifndef __QNX__ +#if !defined(__QNX__) && defined(HAVE_THREADS) &audio_alsathread, #endif #endif diff --git a/audio/drivers/jack.c b/audio/drivers/jack.c index f9f3abfaf6..80b2ee34e3 100644 --- a/audio/drivers/jack.c +++ b/audio/drivers/jack.c @@ -41,8 +41,10 @@ typedef struct jack bool nonblock; bool is_paused; +#ifdef HAVE_THREADS scond_t *cond; slock_t *cond_lock; +#endif size_t buffer_size; } jack_t; @@ -54,7 +56,9 @@ static int process_cb(jack_nframes_t nframes, void *data) if (nframes <= 0) { +#ifdef HAVE_THREADS scond_signal(jd->cond); +#endif return 0; } @@ -74,7 +78,9 @@ static int process_cb(jack_nframes_t nframes, void *data) for (f = min_avail; f < nframes; f++) out[f] = 0.0f; } +#ifdef HAVE_THREADS scond_signal(jd->cond); +#endif return 0; } @@ -86,7 +92,9 @@ static void shutdown_cb(void *data) return; jd->shutdown = true; +#ifdef HAVE_THREADS scond_signal(jd->cond); +#endif } static int parse_ports(char **dest_ports, const char **jports) @@ -149,8 +157,10 @@ static void *ja_init(const char *device, unsigned rate, unsigned latency) if (!jd) return NULL; +#ifdef HAVE_THREADS jd->cond = scond_new(); jd->cond_lock = slock_new(); +#endif jd->client = jack_client_open("RetroArch", JackNullOption, NULL); if (jd->client == NULL) @@ -258,12 +268,14 @@ static size_t write_buffer(jack_t *jd, const float *buf, size_t size) } written += write_frames; } +#ifdef HAVE_THREADS else { slock_lock(jd->cond_lock); scond_wait(jd->cond, jd->cond_lock); slock_unlock(jd->cond_lock); } +#endif if (jd->nonblock) break; @@ -327,10 +339,12 @@ static void ja_free(void *data) if (jd->buffer[i] != NULL) jack_ringbuffer_free(jd->buffer[i]); +#ifdef HAVE_THREADS if (jd->cond_lock) slock_free(jd->cond_lock); if (jd->cond) scond_free(jd->cond); +#endif free(jd); } diff --git a/audio/drivers/sdl_audio.c b/audio/drivers/sdl_audio.c index dc6f16eb34..181d60f105 100644 --- a/audio/drivers/sdl_audio.c +++ b/audio/drivers/sdl_audio.c @@ -35,8 +35,10 @@ typedef struct sdl_audio bool nonblock; bool is_paused; +#ifdef HAVE_THREADS slock_t *lock; scond_t *cond; +#endif fifo_buffer_t *buffer; } sdl_audio_t; @@ -47,7 +49,9 @@ static void sdl_audio_cb(void *data, Uint8 *stream, int len) size_t write_size = len > (int)avail ? avail : len; fifo_read(sdl->buffer, stream, write_size); +#ifdef HAVE_THREADS scond_signal(sdl->cond); +#endif /* If underrun, fill rest with silence. */ memset(stream + write_size, 0, len - write_size); @@ -109,8 +113,10 @@ static void *sdl_audio_init(const char *device, settings->audio.out_rate = out.freq; +#ifdef HAVE_THREADS sdl->lock = slock_new(); sdl->cond = scond_new(); +#endif RARCH_LOG("SDL audio: Requested %u ms latency, got %d ms\n", latency, (int)(out.samples * 4 * 1000 / settings->audio.out_rate)); @@ -160,9 +166,11 @@ static ssize_t sdl_audio_write(void *data, const void *buf, size_t size) if (avail == 0) { SDL_UnlockAudio(); +#ifdef HAVE_THREADS slock_lock(sdl->lock); scond_wait(sdl->cond, sdl->lock); slock_unlock(sdl->lock); +#endif } else { @@ -220,8 +228,10 @@ static void sdl_audio_free(void *data) if (sdl) { fifo_free(sdl->buffer); +#ifdef HAVE_THREADS slock_free(sdl->lock); scond_free(sdl->cond); +#endif } free(sdl); } diff --git a/gfx/drivers_context/wayland_ctx.c b/gfx/drivers_context/wayland_ctx.c index 7098916b39..66b7dbbdc9 100644 --- a/gfx/drivers_context/wayland_ctx.c +++ b/gfx/drivers_context/wayland_ctx.c @@ -706,7 +706,7 @@ static void gfx_ctx_wl_destroy(void *data) switch (wl_api) { case GFX_CTX_VULKAN_API: -#ifdef HAVE_VULKAN +#if defined(HAVE_VULKAN) && defined(HAVE_THREADS) if (wl->vk.context.queue_lock) slock_free(wl->vk.context.queue_lock); #endif diff --git a/gfx/drivers_context/x_ctx.c b/gfx/drivers_context/x_ctx.c index 1e6c41101b..1f7aec4f85 100644 --- a/gfx/drivers_context/x_ctx.c +++ b/gfx/drivers_context/x_ctx.c @@ -167,7 +167,7 @@ static void gfx_ctx_x_destroy(void *data) switch (x_api) { case GFX_CTX_VULKAN_API: -#ifdef HAVE_VULKAN +#if defined(HAVE_VULKAN) && defined(HAVE_THREADS) if (x->vk.context.queue_lock) slock_free(x->vk.context.queue_lock); #endif diff --git a/griffin/griffin.c b/griffin/griffin.c index edf45c5fad..da142c7151 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -430,7 +430,7 @@ INPUT (HID) #include "../input/drivers_hid/null_hid.c" -#if defined(HAVE_LIBUSB) +#if defined(HAVE_LIBUSB) && defined(HAVE_THREADS) #include "../input/drivers_hid/libusb_hid.c" #endif diff --git a/input/input_hid_driver.c b/input/input_hid_driver.c index ce37c24f22..a7b9bdc732 100644 --- a/input/input_hid_driver.c +++ b/input/input_hid_driver.c @@ -29,7 +29,7 @@ static hid_driver_t *hid_drivers[] = { #if defined(__APPLE__) && defined(HAVE_IOHIDMANAGER) &iohidmanager_hid, #endif -#ifdef HAVE_LIBUSB +#if defined(HAVE_LIBUSB) && defined(HAVE_THREADS) &libusb_hid, #endif #ifdef HW_RVL From 123025665d324bbf5345c5942ae3ca175ecb540b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 19:11:09 +0200 Subject: [PATCH 422/498] (Qb) When threads are disabled, disable cheevos and/or libusb too --- qb/config.libs.sh | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/qb/config.libs.sh b/qb/config.libs.sh index a58f88f77b..1bf9ec0816 100644 --- a/qb/config.libs.sh +++ b/qb/config.libs.sh @@ -416,12 +416,12 @@ if [ "$HAVE_MATERIALUI" != 'no' ] || [ "$HAVE_XMB" != 'no' ] || [ "$HAVE_ZARCH" HAVE_MATERIALUI=no HAVE_XMB=no HAVE_ZARCH=no - echo "Notice: RGUI not available, MaterialUI, XMB and ZARCH will be disabled." + echo "Notice: RGUI not available, MaterialUI, XMB and ZARCH will also be disabled." elif [ "$HAVE_OPENGL" = 'no' ] && [ "$HAVE_GLES" = 'no' ] && [ "$HAVE_VULKAN" = 'no' ]; then HAVE_MATERIALUI=no HAVE_XMB=no HAVE_ZARCH=no - echo "Notice: Hardware rendering context not available, XMB, MaterialUI and ZARCH will be disabled." + echo "Notice: Hardware rendering context not available, XMB, MaterialUI and ZARCH will also be disabled." fi fi @@ -429,6 +429,16 @@ check_macro NEON __ARM_NEON__ add_define_make OS "$OS" +if [ "$HAVE_THREADS" = 'no' ] && [ "HAVE_CHEEVOS" != 'no' ]; then + HAVE_CHEEVOS=no + echo "Notice: Threads are not available, Cheevos will also be disabled." +fi + +if [ "$HAVE_THREADS" = 'no' ] && [ "HAVE_LIBUSB" != 'no' ]; then + HAVE_LIBUSB=no + echo "Notice: Threads are not available, libusb will also be disabled." +fi + # Creates config.mk and config.h. add_define_make GLOBAL_CONFIG_DIR "$GLOBAL_CONFIG_DIR" VARS=$(eval set | grep ^HAVE_ | sed s/=.*// | sed s/^HAVE_//) From daf031173f5990a11374215daaae26d21488e526 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 19:25:15 +0200 Subject: [PATCH 423/498] Remove unused variable --- runloop.c | 6 ++++++ runloop.h | 7 +------ 2 files changed, 7 insertions(+), 6 deletions(-) diff --git a/runloop.c b/runloop.c index dd257f8460..1daa414811 100644 --- a/runloop.c +++ b/runloop.c @@ -93,6 +93,12 @@ cmd->state[1], cmd->state[2])) #endif +struct rarch_dir_list +{ + struct string_list *list; + size_t ptr; +}; + typedef struct event_cmd_state { retro_input_t state[3]; diff --git a/runloop.h b/runloop.h index 46a74d6e9f..5315099600 100644 --- a/runloop.h +++ b/runloop.h @@ -112,11 +112,7 @@ enum runloop_ctl_state typedef int (*transfer_cb_t)(void *data, size_t len); -typedef struct rarch_dir_list -{ - struct string_list *list; - size_t ptr; -} rarch_dir_list_t; +typedef struct rarch_dir_list rarch_dir_list_t; typedef struct rarch_dir { @@ -127,7 +123,6 @@ typedef struct rarch_dir #ifdef HAVE_OVERLAY char osk_overlay[PATH_MAX_LENGTH]; #endif - rarch_dir_list_t filter_dir; } rarch_dir_t; typedef struct rarch_path From 22bea3a50b62651492b55e118135f4a97723b186 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 19:28:22 +0200 Subject: [PATCH 424/498] Remove some RUNLOOP_CTL_ enums --- runloop.c | 104 +++++++++++++++++++++++++++++------------------------- runloop.h | 4 --- 2 files changed, 55 insertions(+), 53 deletions(-) diff --git a/runloop.c b/runloop.c index 1daa414811..92a85b4d81 100644 --- a/runloop.c +++ b/runloop.c @@ -233,6 +233,60 @@ static bool runloop_check_movie_record(void) return true; } +static bool runloop_check_movie_init(void) +{ + char msg[128], path[PATH_MAX_LENGTH]; + settings_t *settings = config_get_ptr(); + if (bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL)) + return false; + + settings->rewind_granularity = 1; + + if (settings->state_slot > 0) + snprintf(path, sizeof(path), "%s%d", + bsv_movie_get_path(), settings->state_slot); + else + strlcpy(path, bsv_movie_get_path(), sizeof(path)); + + strlcat(path, ".bsv", sizeof(path)); + + snprintf(msg, sizeof(msg), "%s \"%s\".", + msg_hash_to_str(MSG_STARTING_MOVIE_RECORD_TO), + path); + + bsv_movie_init_handle(path, RARCH_MOVIE_RECORD); + + if (!bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL)) + return false; + + if (bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL)) + { + runloop_msg_queue_push(msg, 1, 180, true); + RARCH_LOG("%s \"%s\".\n", + msg_hash_to_str(MSG_STARTING_MOVIE_RECORD_TO), + path); + } + else + { + runloop_msg_queue_push( + msg_hash_to_str(MSG_FAILED_TO_START_MOVIE_RECORD), + 1, 180, true); + RARCH_ERR("%s\n", + msg_hash_to_str(MSG_FAILED_TO_START_MOVIE_RECORD)); + } + + return true; +} + +static bool runloop_check_movie(void) +{ + if (bsv_movie_ctl(BSV_MOVIE_CTL_PLAYBACK_ON, NULL)) + return runloop_check_movie_playback(); + if (!bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL)) + return runloop_check_movie_init(); + return runloop_check_movie_record(); +} + /* Checks if slowmotion toggle/hold was being pressed and/or held. */ static bool runloop_check_slowmotion(bool *ptr) { @@ -595,7 +649,7 @@ static bool runloop_check_state(event_cmd_state_t *cmd, rarch_dir_list_t *shader runloop_check_slowmotion(&tmp); if (runloop_cmd_triggered(cmd, RARCH_MOVIE_RECORD_TOGGLE)) - runloop_ctl(RUNLOOP_CTL_CHECK_MOVIE, NULL); + runloop_check_movie(); runloop_check_shader_dir(shader_dir, runloop_cmd_triggered(cmd, RARCH_SHADER_NEXT), @@ -875,54 +929,6 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) return false; } break; - case RUNLOOP_CTL_CHECK_MOVIE: - if (bsv_movie_ctl(BSV_MOVIE_CTL_PLAYBACK_ON, NULL)) - return runloop_check_movie_playback(); - if (!bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL)) - return runloop_ctl(RUNLOOP_CTL_CHECK_MOVIE_INIT, NULL); - return runloop_check_movie_record(); - case RUNLOOP_CTL_CHECK_MOVIE_INIT: - if (bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL)) - return false; - { - char msg[128]; - char path[PATH_MAX_LENGTH]; - - settings->rewind_granularity = 1; - - if (settings->state_slot > 0) - snprintf(path, sizeof(path), "%s%d", - bsv_movie_get_path(), settings->state_slot); - else - strlcpy(path, bsv_movie_get_path(), sizeof(path)); - - strlcat(path, ".bsv", sizeof(path)); - - snprintf(msg, sizeof(msg), "%s \"%s\".", - msg_hash_to_str(MSG_STARTING_MOVIE_RECORD_TO), - path); - - bsv_movie_init_handle(path, RARCH_MOVIE_RECORD); - - if (!bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL)) - return false; - else if (bsv_movie_ctl(BSV_MOVIE_CTL_IS_INITED, NULL)) - { - runloop_msg_queue_push(msg, 1, 180, true); - RARCH_LOG("%s \"%s\".\n", - msg_hash_to_str(MSG_STARTING_MOVIE_RECORD_TO), - path); - } - else - { - runloop_msg_queue_push( - msg_hash_to_str(MSG_FAILED_TO_START_MOVIE_RECORD), - 1, 180, true); - RARCH_ERR("%s\n", - msg_hash_to_str(MSG_FAILED_TO_START_MOVIE_RECORD)); - } - } - break; case RUNLOOP_CTL_FRAME_TIME_FREE: memset(&runloop_frame_time, 0, sizeof(struct retro_frame_time_callback)); runloop_frame_time_last = 0; diff --git a/runloop.h b/runloop.h index 5315099600..ce7cc6f03d 100644 --- a/runloop.h +++ b/runloop.h @@ -79,10 +79,6 @@ enum runloop_ctl_state RUNLOOP_CTL_KEY_EVENT_GET, RUNLOOP_CTL_DATA_DEINIT, - RUNLOOP_CTL_CHECK_MOVIE, - - RUNLOOP_CTL_CHECK_MOVIE_INIT, - /* Initializes message queue. */ RUNLOOP_CTL_MSG_QUEUE_INIT, From 322d11e3879074b09325402ff0618ee22b9dee55 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 19:37:56 +0200 Subject: [PATCH 425/498] Avoid some warnings when compiling with --disable-netplay --- command.c | 136 +++++++++++++++++++++++++++--------------------------- 1 file changed, 69 insertions(+), 67 deletions(-) diff --git a/command.c b/command.c index f3b4ba0378..98ae2e3fec 100644 --- a/command.c +++ b/command.c @@ -201,40 +201,6 @@ static const struct cmd_map map[] = { { "MENU_B", RETRO_DEVICE_ID_JOYPAD_B }, }; -#if defined(HAVE_NETWORK_CMD) && defined(HAVE_NETPLAY) -static bool command_network_init(command_t *handle, uint16_t port) -{ - int fd; - struct addrinfo *res = NULL; - - RARCH_LOG("Bringing up command interface on port %hu.\n", - (unsigned short)port); - - fd = socket_init((void**)&res, port, NULL, SOCKET_TYPE_DATAGRAM); - - if (fd < 0) - goto error; - - handle->net_fd = fd; - - if (!socket_nonblock(handle->net_fd)) - goto error; - - if (!socket_bind(handle->net_fd, (void*)res)) - { - RARCH_ERR("Failed to bind socket.\n"); - goto error; - } - - freeaddrinfo_retro(res); - return true; - -error: - if (res) - freeaddrinfo_retro(res); - return false; -} - static bool command_get_arg(const char *tok, const char **arg, unsigned *index) { @@ -276,6 +242,75 @@ static bool command_get_arg(const char *tok, return false; } +static void command_parse_sub_msg(command_t *handle, const char *tok) +{ + const char *arg = NULL; + unsigned index = 0; + + if (command_get_arg(tok, &arg, &index)) + { + if (arg) + { + if (!action_map[index].action(arg)) + RARCH_ERR("Command \"%s\" failed.\n", arg); + } + else + handle->state[map[index].id] = true; + } + else + RARCH_WARN("%s \"%s\" %s.\n", + msg_hash_to_str(MSG_UNRECOGNIZED_COMMAND), + tok, + msg_hash_to_str(MSG_RECEIVED)); +} + +static void command_parse_msg(command_t *handle, char *buf) +{ + char *save = NULL; + const char *tok = strtok_r(buf, "\n", &save); + + while (tok) + { + command_parse_sub_msg(handle, tok); + tok = strtok_r(NULL, "\n", &save); + } +} + +#if defined(HAVE_NETWORK_CMD) && defined(HAVE_NETPLAY) +static bool command_network_init(command_t *handle, uint16_t port) +{ + int fd; + struct addrinfo *res = NULL; + + RARCH_LOG("Bringing up command interface on port %hu.\n", + (unsigned short)port); + + fd = socket_init((void**)&res, port, NULL, SOCKET_TYPE_DATAGRAM); + + if (fd < 0) + goto error; + + handle->net_fd = fd; + + if (!socket_nonblock(handle->net_fd)) + goto error; + + if (!socket_bind(handle->net_fd, (void*)res)) + { + RARCH_ERR("Failed to bind socket.\n"); + goto error; + } + + freeaddrinfo_retro(res); + return true; + +error: + if (res) + freeaddrinfo_retro(res); + return false; +} + + static bool send_udp_packet(const char *host, uint16_t port, const char *msg) @@ -390,39 +425,6 @@ bool command_network_send(const char *cmd_) return ret; } -static void command_parse_sub_msg(command_t *handle, const char *tok) -{ - const char *arg = NULL; - unsigned index = 0; - - if (command_get_arg(tok, &arg, &index)) - { - if (arg) - { - if (!action_map[index].action(arg)) - RARCH_ERR("Command \"%s\" failed.\n", arg); - } - else - handle->state[map[index].id] = true; - } - else - RARCH_WARN("%s \"%s\" %s.\n", - msg_hash_to_str(MSG_UNRECOGNIZED_COMMAND), - tok, - msg_hash_to_str(MSG_RECEIVED)); -} - -static void command_parse_msg(command_t *handle, char *buf) -{ - char *save = NULL; - const char *tok = strtok_r(buf, "\n", &save); - - while (tok) - { - command_parse_sub_msg(handle, tok); - tok = strtok_r(NULL, "\n", &save); - } -} static void command_network_poll(command_t *handle) { From dc46c0d0124ac76ab4c7f4380b28b616dc62c0ee Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 19:38:46 +0200 Subject: [PATCH 426/498] C89 build-fix --- tasks/tasks_internal.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasks/tasks_internal.h b/tasks/tasks_internal.h index 737261fe74..f880dbe156 100644 --- a/tasks/tasks_internal.h +++ b/tasks/tasks_internal.h @@ -141,7 +141,7 @@ bool rarch_task_push_content_load_default( void rarch_task_image_load_free(retro_task_t *task); -void rarch_task_file_load_handler(retro_task_t *task);; +void rarch_task_file_load_handler(retro_task_t *task); #ifdef __cplusplus } From 5cc86384b813d397d003c9f25562cb4278a18229 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 20:38:09 +0200 Subject: [PATCH 427/498] (task_image.c) Cleanups --- tasks/task_image.c | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/tasks/task_image.c b/tasks/task_image.c index bcc25af17e..446a3f4dca 100644 --- a/tasks/task_image.c +++ b/tasks/task_image.c @@ -99,9 +99,10 @@ static int cb_nbio_default(void *data, size_t len) static int rarch_main_data_image_process( nbio_handle_t *nbio, unsigned *width, - unsigned *height, - int *retval) + unsigned *height) { + int retval = 0; + switch (nbio->image_type) { case IMAGE_TYPE_PNG: @@ -109,7 +110,7 @@ static int rarch_main_data_image_process( if (!rpng_is_valid((rpng_t*)nbio->image.handle)) return IMAGE_PROCESS_ERROR; - *retval = rpng_nbio_load_image_argb_process( + retval = rpng_nbio_load_image_argb_process( (rpng_t*)nbio->image.handle, &nbio->image.ti.pixels, width, height); @@ -122,7 +123,7 @@ static int rarch_main_data_image_process( nbio->image.ti.width = *width; nbio->image.ti.height = *height; - return *retval; + return retval; } static int cb_image_menu_generic(nbio_handle_t *nbio) @@ -132,8 +133,10 @@ static int cb_image_menu_generic(nbio_handle_t *nbio) if (!nbio) return -1; - switch (rarch_main_data_image_process(nbio, - &width, &height, &retval)) + retval = rarch_main_data_image_process(nbio, + &width, &height); + + switch (retval) { case IMAGE_PROCESS_ERROR: case IMAGE_PROCESS_ERROR_END: @@ -204,8 +207,9 @@ static int rarch_main_data_image_iterate_process_transfer(nbio_handle_t *nbio) for (i = 0; i < nbio->image.processing_pos_increment; i++) { - if (rarch_main_data_image_process(nbio, - &width, &height, &retval) != IMAGE_PROCESS_NEXT) + retval = rarch_main_data_image_process(nbio, + &width, &height); + if (retval != IMAGE_PROCESS_NEXT) break; } From 0e972b98047fb2ae61dbdb841df16688c887ae0a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 20:44:24 +0200 Subject: [PATCH 428/498] Rename rarch_git_version to retroarch_git_version --- git_version.c | 2 +- git_version.h | 2 +- menu/menu_displaylist.c | 2 +- retroarch.c | 4 ++-- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/git_version.c b/git_version.c index 12835695e4..3d7a62109e 100644 --- a/git_version.c +++ b/git_version.c @@ -17,5 +17,5 @@ #include "git_version.h" #define STR_(x) #x #define STR(x) STR_(x) -const char rarch_git_version[] = STR(GIT_VERSION); +const char retroarch_git_version[] = STR(GIT_VERSION); diff --git a/git_version.h b/git_version.h index 843d5d1f1c..2217898ee7 100644 --- a/git_version.h +++ b/git_version.h @@ -23,7 +23,7 @@ extern "C" { /* Put this in a separate file so we don't have to rebuilt * retroarch.c every single build. */ -extern const char rarch_git_version[]; +extern const char retroarch_git_version[]; #ifdef __cplusplus } diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index eb902a4c99..66fdcd1c7f 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -619,7 +619,7 @@ static int menu_displaylist_parse_system_info(menu_displaylist_info_t *info) strlcpy(tmp, menu_hash_to_str(MENU_LABEL_VALUE_SYSTEM_INFO_GIT_VERSION), sizeof(tmp)); strlcat(tmp, ": ", sizeof(tmp)); - strlcat(tmp, rarch_git_version, sizeof(tmp)); + strlcat(tmp, retroarch_git_version, sizeof(tmp)); menu_entries_add(info->list, tmp, "", MENU_SETTINGS_CORE_INFO_NONE, 0, 0); #endif diff --git a/retroarch.c b/retroarch.c index aedcb24b83..b62edb6f54 100644 --- a/retroarch.c +++ b/retroarch.c @@ -176,7 +176,7 @@ static void retroarch_print_version(void) fprintf(stderr, "%s: Frontend for libretro -- v%s", msg_hash_to_str(MSG_PROGRAM), PACKAGE_VERSION); #ifdef HAVE_GIT_VERSION - printf(" -- %s --\n", rarch_git_version); + printf(" -- %s --\n", retroarch_git_version); #endif retroarch_get_capabilities(RARCH_CAPABILITIES_COMPILER, str, sizeof(str)); fprintf(stdout, "%s", str); @@ -1249,7 +1249,7 @@ static int retroarch_main_init(int argc, char *argv[]) fprintf(stderr, "Built: %s\n", __DATE__); RARCH_LOG_OUTPUT("Version: %s\n", PACKAGE_VERSION); #ifdef HAVE_GIT_VERSION - RARCH_LOG_OUTPUT("Git: %s\n", rarch_git_version); + RARCH_LOG_OUTPUT("Git: %s\n", retroarch_git_version); #endif RARCH_LOG_OUTPUT("=================================================\n"); } From a082198d4b506076c66dbe90a7f6718ef0cd5a6f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 20:50:34 +0200 Subject: [PATCH 429/498] Change retroarch_main_init --- content.c | 2 +- retroarch.c | 16 +++++----------- retroarch.h | 14 +++++++++++--- 3 files changed, 17 insertions(+), 15 deletions(-) diff --git a/content.c b/content.c index 73c0f6ba94..2873230cef 100644 --- a/content.c +++ b/content.c @@ -892,7 +892,7 @@ bool content_load(content_ctx_info_t *info) wrap_args->argc = *rarch_argc_ptr; wrap_args->argv = rarch_argv_ptr; - if (!rarch_ctl(RARCH_CTL_MAIN_INIT, wrap_args)) + if (!retroarch_main_init(wrap_args->argc, wrap_args->argv)) { retval = false; goto error; diff --git a/retroarch.c b/retroarch.c index b62edb6f54..9fe07f1327 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1220,7 +1220,7 @@ bool retroarch_validate_game_options(char *s, size_t len, bool mkdir) * * Returns: 0 on success, otherwise 1 if there was an error. **/ -static int retroarch_main_init(int argc, char *argv[]) +bool retroarch_main_init(int argc, char *argv[]) { int sjlj_ret; bool *verbosity = NULL; @@ -1230,7 +1230,7 @@ static int retroarch_main_init(int argc, char *argv[]) if ((sjlj_ret = setjmp(error_sjlj_context)) > 0) { RARCH_ERR("Fatal error received in: \"%s\"\n", error_string); - return sjlj_ret; + return false; } rarch_ctl(RARCH_CTL_SET_ERROR_ON_INIT, NULL); @@ -1315,12 +1315,13 @@ static int retroarch_main_init(int argc, char *argv[]) rarch_ctl(RARCH_CTL_UNSET_ERROR_ON_INIT, NULL); rarch_ctl(RARCH_CTL_SET_INITED, NULL); - return 0; + + return true; error: command_event(CMD_EVENT_CORE_DEINIT, NULL); rarch_ctl(RARCH_CTL_UNSET_INITED, NULL); - return 1; + return false; } #define FAIL_CPU(simd_type) do { \ @@ -1416,13 +1417,6 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data) rarch_ctl(RARCH_CTL_UNSET_INITED, NULL); break; - case RARCH_CTL_MAIN_INIT: - { - struct rarch_main_wrap *wrap = (struct rarch_main_wrap*)data; - if (retroarch_main_init(wrap->argc, wrap->argv)) - return false; - } - break; case RARCH_CTL_INIT: rarch_ctl(RARCH_CTL_DEINIT, NULL); retroarch_init_state(); diff --git a/retroarch.h b/retroarch.h index d4e13ab3c4..77759ad38f 100644 --- a/retroarch.h +++ b/retroarch.h @@ -60,9 +60,6 @@ enum rarch_ctl_state /* Initialize all drivers. */ RARCH_CTL_INIT, - /* Initializes RetroArch. */ - RARCH_CTL_MAIN_INIT, - /* Deinitializes RetroArch. */ RARCH_CTL_MAIN_DEINIT, @@ -180,6 +177,17 @@ void retroarch_fill_pathnames(void); **/ void retroarch_fail(int error_code, const char *error); +/** + * retroarch_main_init: + * @argc : Count of (commandline) arguments. + * @argv : (Commandline) arguments. + * + * Initializes the program. + * + * Returns: 1 (true) on success, otherwise false (0) if there was an error. + **/ +bool retroarch_main_init(int argc, char *argv[]); + #ifdef __cplusplus } #endif From cf3f8d587cd5333f900044c7693cc7f84fbcc85a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 20:53:28 +0200 Subject: [PATCH 430/498] Cleanup --- command.c | 8 ++++---- retroarch.c | 10 ++++++---- retroarch.h | 4 ++-- 3 files changed, 12 insertions(+), 10 deletions(-) diff --git a/command.c b/command.c index 98ae2e3fec..55728c2845 100644 --- a/command.c +++ b/command.c @@ -1779,7 +1779,7 @@ bool command_event(enum event_command cmd, void *data) command_event(CMD_EVENT_LOAD_CORE_DEINIT, NULL); break; case CMD_EVENT_QUIT: - rarch_ctl(RARCH_CTL_QUIT, NULL); + retroarch_main_quit(); break; case CMD_EVENT_CHEEVOS_HARDCORE_MODE_TOGGLE: #ifdef HAVE_CHEEVOS @@ -2034,19 +2034,19 @@ bool command_event(enum event_command cmd, void *data) } break; case CMD_EVENT_QUIT_RETROARCH: - rarch_ctl(RARCH_CTL_QUIT, NULL); + command_event(CMD_EVENT_QUIT, NULL); break; case CMD_EVENT_SHUTDOWN: #if defined(__linux__) && !defined(ANDROID) runloop_msg_queue_push("Shutting down...", 1, 180, true); - rarch_ctl(RARCH_CTL_QUIT, NULL); + command_event(CMD_EVENT_QUIT, NULL); system("shutdown -P now"); #endif break; case CMD_EVENT_REBOOT: #if defined(__linux__) && !defined(ANDROID) runloop_msg_queue_push("Rebooting...", 1, 180, true); - rarch_ctl(RARCH_CTL_QUIT, NULL); + command_event(CMD_EVENT_QUIT, NULL); system("shutdown -r now"); #endif break; diff --git a/retroarch.c b/retroarch.c index 9fe07f1327..73d24c472c 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1505,10 +1505,6 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data) command_event(CMD_EVENT_OVERLAY_INIT, NULL); #endif break; - case RARCH_CTL_QUIT: - runloop_ctl(RUNLOOP_CTL_SET_SHUTDOWN, NULL); - rarch_ctl(RARCH_CTL_MENU_RUNNING_FINISHED, NULL); - break; case RARCH_CTL_VALIDATE_CPU_FEATURES: { uint64_t cpu = cpu_features_get(); @@ -1666,3 +1662,9 @@ void retroarch_fail(int error_code, const char *error) strlcpy(error_string, error, sizeof(error_string)); longjmp(error_sjlj_context, error_code); } + +void retroarch_main_quit(void) +{ + runloop_ctl(RUNLOOP_CTL_SET_SHUTDOWN, NULL); + rarch_ctl(RARCH_CTL_MENU_RUNNING_FINISHED, NULL); +} diff --git a/retroarch.h b/retroarch.h index 77759ad38f..24b3c78a1f 100644 --- a/retroarch.h +++ b/retroarch.h @@ -86,8 +86,6 @@ enum rarch_ctl_state * properly. */ RARCH_CTL_REPLACE_CONFIG, - RARCH_CTL_QUIT, - /* Validates CPU features for given processor architecture. * Make sure we haven't compiled for something we cannot run. * Ideally, code would get swapped out depending on CPU support, @@ -188,6 +186,8 @@ void retroarch_fail(int error_code, const char *error); **/ bool retroarch_main_init(int argc, char *argv[]); +void retroarch_main_quit(void); + #ifdef __cplusplus } #endif From 90d7722125b22dff32acebaf3e635057c95f0ff3 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 20:56:02 +0200 Subject: [PATCH 431/498] Remove CMD_EVENT_QUIT_RETROARCH --- command.c | 3 --- command.h | 2 -- frontend/drivers/platform_gx.c | 2 +- frontend/drivers/platform_linux.c | 2 +- menu/menu_setting.c | 2 +- 5 files changed, 3 insertions(+), 8 deletions(-) diff --git a/command.c b/command.c index 55728c2845..d7c99c8eb9 100644 --- a/command.c +++ b/command.c @@ -2033,9 +2033,6 @@ bool command_event(enum event_command cmd, void *data) driver_ctl(RARCH_DRIVER_CTL_INIT, &flags); } break; - case CMD_EVENT_QUIT_RETROARCH: - command_event(CMD_EVENT_QUIT, NULL); - break; case CMD_EVENT_SHUTDOWN: #if defined(__linux__) && !defined(ANDROID) runloop_msg_queue_push("Shutting down...", 1, 180, true); diff --git a/command.h b/command.h index b10279a548..c1db7db1a9 100644 --- a/command.h +++ b/command.h @@ -129,8 +129,6 @@ enum event_command CMD_EVENT_RESET_CONTEXT, /* Restarts RetroArch. */ CMD_EVENT_RESTART_RETROARCH, - /* Force-quit RetroArch. */ - CMD_EVENT_QUIT_RETROARCH, /* Shutdown the OS */ CMD_EVENT_SHUTDOWN, /* Reboot the OS */ diff --git a/frontend/drivers/platform_gx.c b/frontend/drivers/platform_gx.c index a4e070e30b..7478b21148 100644 --- a/frontend/drivers/platform_gx.c +++ b/frontend/drivers/platform_gx.c @@ -426,7 +426,7 @@ static bool frontend_gx_set_fork(enum frontend_fork fork_mode) case FRONTEND_FORK_RESTART: RARCH_LOG("FRONTEND_FORK_RESTART\n"); gx_fork_mode = fork_mode; - command_event(CMD_EVENT_QUIT_RETROARCH, NULL); + command_event(CMD_EVENT_QUIT, NULL); break; case FRONTEND_FORK_NONE: default: diff --git a/frontend/drivers/platform_linux.c b/frontend/drivers/platform_linux.c index 9f0ea43639..3f48e38a7d 100644 --- a/frontend/drivers/platform_linux.c +++ b/frontend/drivers/platform_linux.c @@ -1827,7 +1827,7 @@ static bool frontend_linux_set_fork(enum frontend_fork fork_mode) fill_pathname_application_path(executable_path, sizeof(executable_path)); strlcpy(settings->path.libretro, executable_path, sizeof(settings->path.libretro)); } - command_event(CMD_EVENT_QUIT_RETROARCH, NULL); + command_event(CMD_EVENT_QUIT, NULL); break; case FRONTEND_FORK_NONE: default: diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 427aca79d9..0959b2ccc7 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -3638,7 +3638,7 @@ static bool setting_append_list( &group_info, &subgroup_info, parent_group); - menu_settings_list_current_add_cmd(list, list_info, CMD_EVENT_QUIT_RETROARCH); + menu_settings_list_current_add_cmd(list, list_info, CMD_EVENT_QUIT); #endif #if defined(HAVE_LAKKA) From 4100bf95b425bb12c61926a4e5a56feb39fdd028 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 21:22:45 +0200 Subject: [PATCH 432/498] Able to compile without RPNG support --- Makefile.common | 6 +---- menu/cbs/menu_cbs_ok.c | 2 ++ qb/config.libs.sh | 6 +++++ qb/config.params.sh | 1 + tasks/task_image.c | 51 +++++++++++++++++++++--------------------- 5 files changed, 35 insertions(+), 31 deletions(-) diff --git a/Makefile.common b/Makefile.common index 4d909c217a..dfe3772c1e 100644 --- a/Makefile.common +++ b/Makefile.common @@ -890,7 +890,6 @@ ifeq ($(HAVE_ZLIB), 1) tasks/task_decompress.o OBJ += $(ZLIB_OBJS) DEFINES += -DHAVE_ZLIB - HAVE_RPNG = 1 HAVE_COMPRESSION = 1 ifeq ($(WANT_ZLIB), 1) DEFINES += -DWANT_ZLIB @@ -900,11 +899,8 @@ ifeq ($(HAVE_ZLIB), 1) endif endif -ifdef HAVE_RPNG - DEFINES += -DHAVE_RPNG -endif - ifeq ($(HAVE_RPNG), 1) + DEFINES += -DHAVE_RPNG OBJ += libretro-common/formats/png/rpng.o \ libretro-common/formats/png/rpng_encode.o endif diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index c129b1d76c..818266fe99 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -1259,6 +1259,7 @@ static int action_ok_save_state(const char *path, } #ifdef HAVE_NETWORKING +#ifdef HAVE_ZLIB static void cb_decompressed(void *task_data, void *user_data, const char *err) { decompress_task_data_t *dec = (decompress_task_data_t*)task_data; @@ -1289,6 +1290,7 @@ static void cb_decompressed(void *task_data, void *user_data, const char *err) free(dec); } } +#endif /* expects http_transfer_t*, menu_file_transfer_t* */ static void cb_generic_download(void *task_data, diff --git a/qb/config.libs.sh b/qb/config.libs.sh index 1bf9ec0816..01859e8ede 100644 --- a/qb/config.libs.sh +++ b/qb/config.libs.sh @@ -425,10 +425,16 @@ if [ "$HAVE_MATERIALUI" != 'no' ] || [ "$HAVE_XMB" != 'no' ] || [ "$HAVE_ZARCH" fi fi + check_macro NEON __ARM_NEON__ add_define_make OS "$OS" +if [ "$HAVE_ZLIB" = 'no' ] && [ "HAVE_RPNG" != 'no' ]; then + HAVE_RPNG=no + echo "Notice: zlib is not available, RPNG will also be disabled." +fi + if [ "$HAVE_THREADS" = 'no' ] && [ "HAVE_CHEEVOS" != 'no' ]; then HAVE_CHEEVOS=no echo "Notice: Threads are not available, Cheevos will also be disabled." diff --git a/qb/config.params.sh b/qb/config.params.sh index 16c576a2a6..e69da313e8 100644 --- a/qb/config.params.sh +++ b/qb/config.params.sh @@ -77,3 +77,4 @@ HAVE_XSHM=no # XShm video driver support (disabled because it's ju HAVE_CHEEVOS=yes # Retro Achievements HAVE_VULKAN=auto # Vulkan support C89_VULKAN=no +HAVE_RPNG=yes # RPNG support diff --git a/tasks/task_image.c b/tasks/task_image.c index 446a3f4dca..ea6e504279 100644 --- a/tasks/task_image.c +++ b/tasks/task_image.c @@ -163,7 +163,29 @@ static int cb_image_menu_thumbnail(void *data, size_t len) return 0; } -#ifdef HAVE_RPNG +static int rarch_main_data_image_iterate_process_transfer(nbio_handle_t *nbio) +{ + unsigned i, width = 0, height = 0; + int retval = 0; + + if (!nbio) + return -1; + + for (i = 0; i < nbio->image.processing_pos_increment; i++) + { + retval = rarch_main_data_image_process(nbio, + &width, &height); + if (retval != IMAGE_PROCESS_NEXT) + break; + } + + if (retval == IMAGE_PROCESS_NEXT) + return 0; + + nbio->image.processing_final_state = retval; + return -1; +} + static int rarch_main_data_image_iterate_transfer(nbio_handle_t *nbio) { unsigned i; @@ -192,32 +214,10 @@ static int rarch_main_data_image_iterate_transfer(nbio_handle_t *nbio) nbio->image.frame_count++; return 0; +#ifdef HAVE_RPNG error: return -1; -} - - -static int rarch_main_data_image_iterate_process_transfer(nbio_handle_t *nbio) -{ - unsigned i, width = 0, height = 0; - int retval = 0; - - if (!nbio) - return -1; - - for (i = 0; i < nbio->image.processing_pos_increment; i++) - { - retval = rarch_main_data_image_process(nbio, - &width, &height); - if (retval != IMAGE_PROCESS_NEXT) - break; - } - - if (retval == IMAGE_PROCESS_NEXT) - return 0; - - nbio->image.processing_final_state = retval; - return -1; +#endif } static void rarch_task_image_load_free_internal(nbio_handle_t *nbio) @@ -311,7 +311,6 @@ static int cb_nbio_image_menu_thumbnail(void *data, size_t len) return cb_nbio_generic(nbio, &len); } -#endif bool rarch_task_image_load_handler(retro_task_t *task) { From 28dd2c2545d1ccb4110fe1cf62909cc29a85b0b7 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 21:27:17 +0200 Subject: [PATCH 433/498] Add HAVE_RJPEG ifdefs --- Makefile.common | 9 +++++++-- griffin/griffin.c | 2 ++ qb/config.params.sh | 1 + tasks/task_image.c | 12 ++++++++++++ 4 files changed, 22 insertions(+), 2 deletions(-) diff --git a/Makefile.common b/Makefile.common index dfe3772c1e..b869261baa 100644 --- a/Makefile.common +++ b/Makefile.common @@ -904,8 +904,13 @@ ifeq ($(HAVE_RPNG), 1) OBJ += libretro-common/formats/png/rpng.o \ libretro-common/formats/png/rpng_encode.o endif -OBJ += libretro-common/formats/jpeg/rjpeg.o \ - libretro-common/formats/bmp/rbmp_encode.o \ + +ifeq ($(HAVE_RJPEG), 1) + DEFINES += -DHAVE_RJPEG + OBJ += libretro-common/formats/jpeg/rjpeg.o +endif + +OBJ += libretro-common/formats/bmp/rbmp_encode.o \ libretro-common/formats/tga/rtga.o \ libretro-common/formats/json/jsonsax.o diff --git a/griffin/griffin.c b/griffin/griffin.c index da142c7151..13c99f3c2c 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -232,7 +232,9 @@ VIDEO IMAGE #include "../libretro-common/formats/png/rpng.c" #include "../libretro-common/formats/png/rpng_encode.c" #endif +#ifdef HAVE_RJPEG #include "../libretro-common/formats/jpeg/rjpeg.c" +#endif #include "../libretro-common/formats/bmp/rbmp_encode.c" /*============================================================ diff --git a/qb/config.params.sh b/qb/config.params.sh index e69da313e8..6c4ca9414a 100644 --- a/qb/config.params.sh +++ b/qb/config.params.sh @@ -78,3 +78,4 @@ HAVE_CHEEVOS=yes # Retro Achievements HAVE_VULKAN=auto # Vulkan support C89_VULKAN=no HAVE_RPNG=yes # RPNG support +HAVE_RJPEG=yes # RJPEG support diff --git a/tasks/task_image.c b/tasks/task_image.c index ea6e504279..f3c442219f 100644 --- a/tasks/task_image.c +++ b/tasks/task_image.c @@ -117,6 +117,8 @@ static int rarch_main_data_image_process( #endif break; case IMAGE_TYPE_JPEG: +#ifdef HAVE_RJPEG +#endif break; } @@ -207,6 +209,8 @@ static int rarch_main_data_image_iterate_transfer(nbio_handle_t *nbio) #endif break; case IMAGE_TYPE_JPEG: +#ifdef HAVE_RJPEG +#endif break; } } @@ -232,6 +236,8 @@ static void rarch_task_image_load_free_internal(nbio_handle_t *nbio) #endif break; case IMAGE_TYPE_JPEG: +#ifdef HAVE_RJPEG +#endif break; } @@ -260,6 +266,8 @@ static int cb_nbio_generic(nbio_handle_t *nbio, size_t *len) #endif break; case IMAGE_TYPE_JPEG: +#ifdef HAVE_RJPEG +#endif break; } @@ -275,6 +283,8 @@ static int cb_nbio_generic(nbio_handle_t *nbio, size_t *len) #endif break; case IMAGE_TYPE_JPEG: +#ifdef HAVE_RJPEG +#endif break; } @@ -304,6 +314,8 @@ static int cb_nbio_image_menu_thumbnail(void *data, size_t len) #endif break; case IMAGE_TYPE_JPEG: +#ifdef HAVE_RJPEG +#endif break; } From e3802c499f06481dddf9b42560cb7b3b7886020b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 21:38:33 +0200 Subject: [PATCH 434/498] Add RJPEG header include --- tasks/task_image.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/tasks/task_image.c b/tasks/task_image.c index f3c442219f..63fdaf6461 100644 --- a/tasks/task_image.c +++ b/tasks/task_image.c @@ -27,6 +27,9 @@ #ifdef HAVE_RPNG #include #endif +#ifdef HAVE_RJPEG +#include +#endif #ifdef HAVE_MENU #include "../menu/menu_driver.h" From 07101f48d32f6b3286af4e00ceebaa5b40512f90 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 21:41:19 +0200 Subject: [PATCH 435/498] Move struct to content.c --- content.c | 8 ++++++++ content.h | 8 -------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/content.c b/content.c index 2873230cef..7804333047 100644 --- a/content.c +++ b/content.c @@ -90,6 +90,14 @@ struct sram_block size_t size; }; +typedef struct content_stream +{ + uint32_t a; + const uint8_t *b; + size_t c; + uint32_t crc; +} content_stream_t; + static const struct file_archive_file_backend *stream_backend = NULL; static struct string_list *temporary_content = NULL; static bool _content_is_inited = false; diff --git a/content.h b/content.h index e02ee8f692..13118f67f9 100644 --- a/content.h +++ b/content.h @@ -36,14 +36,6 @@ typedef struct ram_type int type; } ram_type_t; -typedef struct content_stream -{ - uint32_t a; - const uint8_t *b; - size_t c; - uint32_t crc; -} content_stream_t; - typedef struct content_ctx_info { int argc; /* Argument count. */ From 1abe81b2224e332ef0f95b4afdf1ec991eaa1de2 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 21:44:52 +0200 Subject: [PATCH 436/498] Create retroarch_replace_config --- menu/cbs/menu_cbs_ok.c | 2 +- retroarch.c | 53 ++++++++++++++++++++++++------------------ retroarch.h | 9 +++---- 3 files changed, 36 insertions(+), 28 deletions(-) diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 818266fe99..c9d9a25328 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -772,7 +772,7 @@ static int generic_action_ok(const char *path, flush_type = MENU_SETTINGS; menu_display_set_msg_force(true); - if (rarch_ctl(RARCH_CTL_REPLACE_CONFIG, action_path)) + if (retroarch_replace_config(action_path)) { bool pending_push = false; menu_navigation_ctl(MENU_NAVIGATION_CTL_CLEAR, &pending_push); diff --git a/retroarch.c b/retroarch.c index 73d24c472c..725582914a 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1463,29 +1463,6 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data) break; case RARCH_CTL_IS_BLOCK_CONFIG_READ: return rarch_block_config_read; - case RARCH_CTL_REPLACE_CONFIG: - { - char *path = (char*)data; - - if (!path) - return false; - - /* If config file to be replaced is the same as the - * current config file, exit. */ - if (string_is_equal(path, global->path.config)) - return false; - - if (settings->config_save_on_exit && *global->path.config) - config_save_file(global->path.config); - - strlcpy(global->path.config, path, sizeof(global->path.config)); - - rarch_ctl(RARCH_CTL_UNSET_BLOCK_CONFIG_READ, NULL); - - *settings->path.libretro = '\0'; /* Load core in new config. */ - } - runloop_ctl(RUNLOOP_CTL_PREPARE_DUMMY, NULL); - break; case RARCH_CTL_MENU_RUNNING: #ifdef HAVE_MENU menu_driver_ctl(RARCH_MENU_CTL_SET_TOGGLE, NULL); @@ -1532,6 +1509,36 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data) return true; } +/* Replaces currently loaded configuration file with + * another one. Will load a dummy core to flush state + * properly. */ +bool retroarch_replace_config(char *path) +{ + settings_t *settings = config_get_ptr(); + global_t *global = global_get_ptr(); + + if (!path) + return false; + + /* If config file to be replaced is the same as the + * current config file, exit. */ + if (string_is_equal(path, global->path.config)) + return false; + + if (settings->config_save_on_exit && *global->path.config) + config_save_file(global->path.config); + + strlcpy(global->path.config, path, sizeof(global->path.config)); + + rarch_ctl(RARCH_CTL_UNSET_BLOCK_CONFIG_READ, NULL); + + *settings->path.libretro = '\0'; /* Load core in new config. */ + + runloop_ctl(RUNLOOP_CTL_PREPARE_DUMMY, NULL); + + return true; +} + void retroarch_set_pathnames(const char *path) { global_t *global = global_get_ptr(); diff --git a/retroarch.h b/retroarch.h index 24b3c78a1f..f1678210f7 100644 --- a/retroarch.h +++ b/retroarch.h @@ -81,10 +81,6 @@ enum rarch_ctl_state RARCH_CTL_MENU_RUNNING_FINISHED, - /* Replaces currently loaded configuration file with - * another one. Will load a dummy core to flush state - * properly. */ - RARCH_CTL_REPLACE_CONFIG, /* Validates CPU features for given processor architecture. * Make sure we haven't compiled for something we cannot run. @@ -166,6 +162,11 @@ void retroarch_set_pathnames(const char *path); void retroarch_fill_pathnames(void); +/* Replaces currently loaded configuration file with + * another one. Will load a dummy core to flush state + * properly. */ +bool retroarch_replace_config(char *path); + /** * retroarch_fail: * @error_code : Error code. From 367150b487b4675c900023f09ec0dd081dc84400 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 21:48:30 +0200 Subject: [PATCH 437/498] Cleanups --- gfx/video_texture_image.c | 4 +++ retroarch.c | 53 +++++++++++++++++++++------------------ retroarch.h | 7 ------ 3 files changed, 33 insertions(+), 31 deletions(-) diff --git a/gfx/video_texture_image.c b/gfx/video_texture_image.c index 349a4332f7..19bcdd00aa 100644 --- a/gfx/video_texture_image.c +++ b/gfx/video_texture_image.c @@ -29,7 +29,9 @@ #ifdef HAVE_RPNG #include #endif +#ifdef HAVE_RJPEG #include +#endif #include #include "../general.h" @@ -276,9 +278,11 @@ bool video_texture_image_load(struct texture_image *out_img, #endif break; case IMAGE_FORMAT_JPEG: +#ifdef HAVE_RJPEG if (rjpeg_image_load((uint8_t*)ptr, out_img, file_len, a_shift, r_shift, g_shift, b_shift)) goto success; +#endif break; default: case IMAGE_FORMAT_NONE: diff --git a/retroarch.c b/retroarch.c index 725582914a..59e862602c 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1211,6 +1211,34 @@ bool retroarch_validate_game_options(char *s, size_t len, bool mkdir) return true; } +#define FAIL_CPU(simd_type) do { \ + RARCH_ERR(simd_type " code is compiled in, but CPU does not support this feature. Cannot continue.\n"); \ + retroarch_fail(1, "validate_cpu_features()"); \ +} while(0) + +/* Validates CPU features for given processor architecture. + * Make sure we haven't compiled for something we cannot run. + * Ideally, code would get swapped out depending on CPU support, + * but this will do for now. */ +static void retroarch_validate_cpu_features(void) +{ + uint64_t cpu = cpu_features_get(); + (void)cpu; + +#ifdef __SSE__ + if (!(cpu & RETRO_SIMD_SSE)) + FAIL_CPU("SSE"); +#endif +#ifdef __SSE2__ + if (!(cpu & RETRO_SIMD_SSE2)) + FAIL_CPU("SSE2"); +#endif +#ifdef __AVX__ + if (!(cpu & RETRO_SIMD_AVX)) + FAIL_CPU("AVX"); +#endif +} + /** * retroarch_main_init: * @argc : Count of (commandline) arguments. @@ -1254,7 +1282,7 @@ bool retroarch_main_init(int argc, char *argv[]) RARCH_LOG_OUTPUT("=================================================\n"); } - rarch_ctl(RARCH_CTL_VALIDATE_CPU_FEATURES, NULL); + retroarch_validate_cpu_features(); config_load(); runloop_ctl(RUNLOOP_CTL_TASK_INIT, NULL); @@ -1324,10 +1352,6 @@ error: return false; } -#define FAIL_CPU(simd_type) do { \ - RARCH_ERR(simd_type " code is compiled in, but CPU does not support this feature. Cannot continue.\n"); \ - retroarch_fail(1, "validate_cpu_features()"); \ -} while(0) bool rarch_ctl(enum rarch_ctl_state state, void *data) { @@ -1482,25 +1506,6 @@ bool rarch_ctl(enum rarch_ctl_state state, void *data) command_event(CMD_EVENT_OVERLAY_INIT, NULL); #endif break; - case RARCH_CTL_VALIDATE_CPU_FEATURES: - { - uint64_t cpu = cpu_features_get(); - (void)cpu; - -#ifdef __SSE__ - if (!(cpu & RETRO_SIMD_SSE)) - FAIL_CPU("SSE"); -#endif -#ifdef __SSE2__ - if (!(cpu & RETRO_SIMD_SSE2)) - FAIL_CPU("SSE2"); -#endif -#ifdef __AVX__ - if (!(cpu & RETRO_SIMD_AVX)) - FAIL_CPU("AVX"); -#endif - } - break; case RARCH_CTL_NONE: default: return false; diff --git a/retroarch.h b/retroarch.h index f1678210f7..0ce529bd78 100644 --- a/retroarch.h +++ b/retroarch.h @@ -81,13 +81,6 @@ enum rarch_ctl_state RARCH_CTL_MENU_RUNNING_FINISHED, - - /* Validates CPU features for given processor architecture. - * Make sure we haven't compiled for something we cannot run. - * Ideally, code would get swapped out depending on CPU support, - * but this will do for now. */ - RARCH_CTL_VALIDATE_CPU_FEATURES, - RARCH_CTL_SET_PATHS_REDIRECT, RARCH_CTL_SET_SRAM_ENABLE, From 670b564f135ef00f88df79b73f1f8e829a4ae0ec Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 21:57:41 +0200 Subject: [PATCH 438/498] Add HAVE_RTGA switch --- Makefile.common | 5 ++++- gfx/video_texture_image.c | 4 ++++ griffin/griffin.c | 2 ++ qb/config.params.sh | 1 + 4 files changed, 11 insertions(+), 1 deletion(-) diff --git a/Makefile.common b/Makefile.common index b869261baa..b5e54fbec6 100644 --- a/Makefile.common +++ b/Makefile.common @@ -911,9 +911,12 @@ ifeq ($(HAVE_RJPEG), 1) endif OBJ += libretro-common/formats/bmp/rbmp_encode.o \ - libretro-common/formats/tga/rtga.o \ libretro-common/formats/json/jsonsax.o +ifeq ($(HAVE_RTGA), 1) +OBJ += libretro-common/formats/tga/rtga.o +endif + ifdef HAVE_COMPRESSION DEFINES += -DHAVE_COMPRESSION endif diff --git a/gfx/video_texture_image.c b/gfx/video_texture_image.c index 19bcdd00aa..8949781813 100644 --- a/gfx/video_texture_image.c +++ b/gfx/video_texture_image.c @@ -32,7 +32,9 @@ #ifdef HAVE_RJPEG #include #endif +#ifdef HAVE_RTGA #include +#endif #include "../general.h" @@ -266,9 +268,11 @@ bool video_texture_image_load(struct texture_image *out_img, switch (fmt) { case IMAGE_FORMAT_TGA: +#ifdef HAVE_RTGA if (rtga_image_load_shift((uint8_t*)ptr, out_img, a_shift, r_shift, g_shift, b_shift)) goto success; +#endif break; case IMAGE_FORMAT_PNG: #ifdef HAVE_RPNG diff --git a/griffin/griffin.c b/griffin/griffin.c index 13c99f3c2c..ba626ee9fe 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -222,7 +222,9 @@ VIDEO IMAGE #include "../gfx/video_texture_image.c" +#ifdef HAVE_RTGA #include "../libretro-common/formats/tga/rtga.c" +#endif #ifdef HAVE_IMAGEVIEWER #include "../cores/libretro-imageviewer/image_core.c" diff --git a/qb/config.params.sh b/qb/config.params.sh index 6c4ca9414a..7f89043a61 100644 --- a/qb/config.params.sh +++ b/qb/config.params.sh @@ -79,3 +79,4 @@ HAVE_VULKAN=auto # Vulkan support C89_VULKAN=no HAVE_RPNG=yes # RPNG support HAVE_RJPEG=yes # RJPEG support +HAVE_RTGA=yes # RTGA support From c9d3936ee53cc123bafd72b05e8ec70e12efbb10 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 22:49:41 +0200 Subject: [PATCH 439/498] Check for GL_EXT_framebuffer_object too --- gfx/drivers/gl.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index cfaff3e26f..93b9a46972 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -190,7 +190,8 @@ static bool gl_check_mipmap(void) if (!extension_queried) { gl_t *gl = (gl_t*)video_driver_get_ptr(false); - extension = gl_query_extension(gl, "ARB_framebuffer_object"); + extension = gl_query_extension(gl, "ARB_framebuffer_object") || + gl_query_extension(gl, "EXT_framebuffer_object"); extension_queried = true; } @@ -230,7 +231,8 @@ static bool gl_init_vao(gl_t *gl) #elif !defined(HAVE_OPENGLES2) static bool gl_check_fbo_proc(gl_t *gl) { - if (!gl->core_context && !gl_query_extension(gl, "ARB_framebuffer_object")) + if (!gl->core_context && !gl_query_extension(gl, "ARB_framebuffer_object") + && !gl_query_extension(gl, "EXT_framebuffer_object")) return false; return glGenFramebuffers From 67e64f4ca6e33453daf6f6250e48c08edab0a425 Mon Sep 17 00:00:00 2001 From: neville Date: Wed, 11 May 2016 23:04:48 +0200 Subject: [PATCH 440/498] gl_check_mipmap - don't look for GL_EXT_framebuffer_object here - breaks OSX PPC --- gfx/drivers/gl.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 93b9a46972..6426a0b0b3 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -190,8 +190,7 @@ static bool gl_check_mipmap(void) if (!extension_queried) { gl_t *gl = (gl_t*)video_driver_get_ptr(false); - extension = gl_query_extension(gl, "ARB_framebuffer_object") || - gl_query_extension(gl, "EXT_framebuffer_object"); + extension = gl_query_extension(gl, "ARB_framebuffer_object"); extension_queried = true; } From 2321ee829ff978c5361ad391250d6415335cedf5 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Wed, 11 May 2016 23:17:42 +0200 Subject: [PATCH 441/498] Add glsym_es3 --- libretro-common/glsym/glsym_es3.c | 10 +++++++ libretro-common/include/glsym/glsym_es3.h | 35 +++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 libretro-common/glsym/glsym_es3.c create mode 100644 libretro-common/include/glsym/glsym_es3.h diff --git a/libretro-common/glsym/glsym_es3.c b/libretro-common/glsym/glsym_es3.c new file mode 100644 index 0000000000..a8c0657824 --- /dev/null +++ b/libretro-common/glsym/glsym_es3.c @@ -0,0 +1,10 @@ +#include "glsym.h" +#include +#define SYM(x) { "gl" #x, &(gl##x) } +const struct rglgen_sym_map rglgen_symbol_map[] = { + + + { NULL, NULL }, +}; + + diff --git a/libretro-common/include/glsym/glsym_es3.h b/libretro-common/include/glsym/glsym_es3.h new file mode 100644 index 0000000000..996b9d2760 --- /dev/null +++ b/libretro-common/include/glsym/glsym_es3.h @@ -0,0 +1,35 @@ +#ifndef RGLGEN_DECL_H__ +#define RGLGEN_DECL_H__ +#ifdef __cplusplus +extern "C" { +#endif +#ifdef GL_APIENTRY +typedef void (GL_APIENTRY *RGLGENGLDEBUGPROC)(GLenum, GLenum, GLuint, GLenum, GLsizei, const GLchar*, GLvoid*); +#else +#ifndef APIENTRY +#define APIENTRY +#endif +#ifndef APIENTRYP +#define APIENTRYP APIENTRY * +#endif +typedef void (APIENTRY *RGLGENGLDEBUGPROCARB)(GLenum, GLenum, GLuint, GLenum, GLsizei, const GLchar*, GLvoid*); +typedef void (APIENTRY *RGLGENGLDEBUGPROC)(GLenum, GLenum, GLuint, GLenum, GLsizei, const GLchar*, GLvoid*); +#endif +#ifndef GL_OES_EGL_image +typedef void *GLeglImageOES; +#endif +#if !defined(GL_OES_fixed_point) && !defined(HAVE_OPENGLES2) +typedef GLint GLfixed; +#endif + + + + + + +struct rglgen_sym_map { const char *sym; void *ptr; }; +extern const struct rglgen_sym_map rglgen_symbol_map[]; +#ifdef __cplusplus +} +#endif +#endif From 21438fc0af11fa87ac7e7b38b69ef54fa8599241 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 May 2016 02:58:09 +0200 Subject: [PATCH 442/498] Some buildfixes for GL_DEBUG --- gfx/drivers/gl.c | 2 +- gfx/drivers_context/xegl_ctx.c | 9 +++------ 2 files changed, 4 insertions(+), 7 deletions(-) diff --git a/gfx/drivers/gl.c b/gfx/drivers/gl.c index 6426a0b0b3..ae9ea181fc 100644 --- a/gfx/drivers/gl.c +++ b/gfx/drivers/gl.c @@ -2494,7 +2494,7 @@ static void DEBUG_CALLBACK_TYPE gl_debug_cb(GLenum source, GLenum type, const GLchar *message, void *userParam) { const char *src = NULL; - const char **typestr = NULL; + const char *typestr = NULL; gl_t *gl = (gl_t*)userParam; /* Useful for debugger. */ (void)gl; diff --git a/gfx/drivers_context/xegl_ctx.c b/gfx/drivers_context/xegl_ctx.c index 6fa1a2f33b..5d21b9c250 100644 --- a/gfx/drivers_context/xegl_ctx.c +++ b/gfx/drivers_context/xegl_ctx.c @@ -189,16 +189,13 @@ static EGLint *xegl_fill_attribs(xegl_ctx_data_t *xegl, EGLint *attr) #ifdef EGL_KHR_create_context case GFX_CTX_OPENGL_API: { - bool debug = false; unsigned version = xegl->egl.major * 1000 + xegl->egl.minor; bool core = version >= 3001; - struct retro_hw_render_callback *hwr = NULL; - - hwr = video_driver_get_hw_context(); #ifdef GL_DEBUG - debug = true; + bool debug = true; #else - debug = hwr->debug_context; + struct retro_hw_render_callback *hwr = video_driver_get_hw_context(); + bool debug = hwr->debug_context; #endif if (core) From f0b99edafcfc05a58012f649570a29aaebbfb3f0 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 May 2016 04:29:36 +0200 Subject: [PATCH 443/498] Prevent some warnings/errors from occurring with MESA_DEBUG --- gfx/drivers_shader/shader_glsl.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/gfx/drivers_shader/shader_glsl.c b/gfx/drivers_shader/shader_glsl.c index 38f6b81f1a..e7b3ac687e 100644 --- a/gfx/drivers_shader/shader_glsl.c +++ b/gfx/drivers_shader/shader_glsl.c @@ -1153,7 +1153,10 @@ static void gl_glsl_set_params(void *data, void *shader_data, orig_uniforms[1].enabled = true; for (j = 0; j < 2; j++) - gl_glsl_set_uniform_parameter(glsl, &orig_uniforms[j], NULL); + { + if (orig_uniforms[j].enabled) + gl_glsl_set_uniform_parameter(glsl, &orig_uniforms[j], NULL); + } /* Pass texture coordinates. */ if (uni->orig.tex_coord >= 0) @@ -1204,7 +1207,10 @@ static void gl_glsl_set_params(void *data, void *shader_data, feedback_uniforms[1].enabled = true; for (j = 0; j < 2; j++) - gl_glsl_set_uniform_parameter(glsl, &feedback_uniforms[j], NULL); + { + if (feedback_uniforms[j].enabled) + gl_glsl_set_uniform_parameter(glsl, &feedback_uniforms[j], NULL); + } /* Pass texture coordinates. */ if (uni->feedback.tex_coord >= 0) @@ -1255,7 +1261,10 @@ static void gl_glsl_set_params(void *data, void *shader_data, fbo_tex_params[2].enabled = true; for (j = 0; j < 3; j++) - gl_glsl_set_uniform_parameter(glsl, &fbo_tex_params[j], NULL); + { + if (fbo_tex_params[j].enabled) + gl_glsl_set_uniform_parameter(glsl, &fbo_tex_params[j], NULL); + } if (uni->pass[i].tex_coord >= 0) { @@ -1307,7 +1316,10 @@ static void gl_glsl_set_params(void *data, void *shader_data, prev_tex_params[2].enabled = true; for (j = 0; j < 3; j++) - gl_glsl_set_uniform_parameter(glsl, &prev_tex_params[j], NULL); + { + if (prev_tex_params[j].enabled) + gl_glsl_set_uniform_parameter(glsl, &prev_tex_params[j], NULL); + } /* Pass texture coordinates. */ if (uni->prev[i].tex_coord >= 0) From e1d9e3418328bb9becc518d2d5cadaf35314176c Mon Sep 17 00:00:00 2001 From: Ezio-PS Date: Thu, 12 May 2016 08:14:10 +0200 Subject: [PATCH 444/498] Updated Italian Translation --- menu/intl/menu_hash_it.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/menu/intl/menu_hash_it.c b/menu/intl/menu_hash_it.c index 88e58073a3..b19195cba1 100644 --- a/menu/intl/menu_hash_it.c +++ b/menu/intl/menu_hash_it.c @@ -352,7 +352,9 @@ const char *menu_hash_to_str_it(uint32_t hash) case MENU_LABEL_VALUE_PAUSE_NONACTIVE: return "Non caricare in background"; case MENU_LABEL_VALUE_UI_COMPANION_START_ON_BOOT: - return "Avvia UI Companion all'avvio"; + return "Abilita UI Companion all'avvio"; + case MENU_LABEL_VALUE_UI_COMPANION_ENABLE: + return "Abilita UI Companion"; case MENU_LABEL_VALUE_UI_MENUBAR_ENABLE: return "Barra dei menù"; case MENU_LABEL_VALUE_ARCHIVE_MODE: @@ -587,8 +589,10 @@ const char *menu_hash_to_str_it(uint32_t hash) return "Settaggi"; case MENU_LABEL_VALUE_QUIT_RETROARCH: return "Esci da RetroArch"; - case MENU_LABEL_VALUE_SHUTDOWN: + case MENU_LABEL_VALUE_SHUTDOWN: return "Spegni"; + case MENU_LABEL_VALUE_REBOOT: + return "Riavvia"; case MENU_LABEL_VALUE_HELP: return "Aiuto"; case MENU_LABEL_VALUE_SAVE_NEW_CONFIG: @@ -924,7 +928,7 @@ const char *menu_hash_to_str_it(uint32_t hash) case MENU_LABEL_VALUE_DIRECTORY_SETTINGS: return "Directory"; case MENU_LABEL_VALUE_RECORDING_SETTINGS: - return "Registrando"; + return "Registrazione"; case MENU_LABEL_VALUE_NO_INFORMATION_AVAILABLE: return "Nessuna informazione disponibile."; case MENU_LABEL_VALUE_INPUT_USER_BINDS: @@ -967,6 +971,12 @@ const char *menu_hash_to_str_it(uint32_t hash) return "Cerca:"; case MENU_LABEL_VALUE_USE_BUILTIN_IMAGE_VIEWER: return "Usa visualizzatore di immagini interno"; + case MENU_LABEL_VALUE_ENABLE: + return "Attivare"; + case MENU_LABEL_VALUE_START_CORE: + return "Avvia Core"; + case MENU_LABEL_VALUE_INPUT_POLL_TYPE_BEHAVIOR: + return "Tipo di ritardo"; default: break; } From c1bfe795f8dee8453f77b5ec0b71821676f13ef0 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 May 2016 09:04:31 +0200 Subject: [PATCH 445/498] Create runloop_prepare_dummy --- command.c | 2 +- retroarch.c | 2 +- runloop.c | 39 +++++++++++++++++++++------------------ runloop.h | 5 +++-- 4 files changed, 26 insertions(+), 22 deletions(-) diff --git a/command.c b/command.c index d7c99c8eb9..57762309db 100644 --- a/command.c +++ b/command.c @@ -1775,7 +1775,7 @@ bool command_event(enum event_command cmd, void *data) return false; break; case CMD_EVENT_UNLOAD_CORE: - runloop_ctl(RUNLOOP_CTL_PREPARE_DUMMY, NULL); + runloop_prepare_dummy(); command_event(CMD_EVENT_LOAD_CORE_DEINIT, NULL); break; case CMD_EVENT_QUIT: diff --git a/retroarch.c b/retroarch.c index 59e862602c..f4c5fb3ba5 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1539,7 +1539,7 @@ bool retroarch_replace_config(char *path) *settings->path.libretro = '\0'; /* Load core in new config. */ - runloop_ctl(RUNLOOP_CTL_PREPARE_DUMMY, NULL); + runloop_prepare_dummy(); return true; } diff --git a/runloop.c b/runloop.c index 92a85b4d81..ce0f8f18a4 100644 --- a/runloop.c +++ b/runloop.c @@ -720,6 +720,26 @@ static bool runloop_is_frame_count_end(void) } +bool runloop_prepare_dummy(void) +{ + memset(&runloop_frame_time, 0, sizeof(struct retro_frame_time_callback)); +#ifdef HAVE_MENU + menu_driver_ctl(RARCH_MENU_CTL_UNSET_LOAD_NO_CONTENT, NULL); +#endif + runloop_ctl(RUNLOOP_CTL_DATA_DEINIT, NULL); + runloop_ctl(RUNLOOP_CTL_TASK_INIT, NULL); + runloop_ctl(RUNLOOP_CTL_CLEAR_CONTENT_PATH, NULL); + +#ifdef HAVE_MENU + if (!menu_content_ctl(MENU_CONTENT_CTL_LOAD, NULL)) + { + rarch_ctl(RARCH_CTL_MENU_RUNNING, NULL); + return false; + } +#endif + return true; +} + bool runloop_ctl(enum runloop_ctl_state state, void *data) { settings_t *settings = config_get_ptr(); @@ -1056,23 +1076,6 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) task_queue_ctl(TASK_QUEUE_CTL_INIT, &threaded_enable); } break; - case RUNLOOP_CTL_PREPARE_DUMMY: - memset(&runloop_frame_time, 0, sizeof(struct retro_frame_time_callback)); -#ifdef HAVE_MENU - menu_driver_ctl(RARCH_MENU_CTL_UNSET_LOAD_NO_CONTENT, NULL); -#endif - runloop_ctl(RUNLOOP_CTL_DATA_DEINIT, NULL); - runloop_ctl(RUNLOOP_CTL_TASK_INIT, NULL); - runloop_ctl(RUNLOOP_CTL_CLEAR_CONTENT_PATH, NULL); - -#ifdef HAVE_MENU - if (!menu_content_ctl(MENU_CONTENT_CTL_LOAD, NULL)) - { - rarch_ctl(RARCH_CTL_MENU_RUNNING, NULL); - return false; - } -#endif - break; case RUNLOOP_CTL_SET_CORE_SHUTDOWN: runloop_core_shutdown_initiated = true; break; @@ -1262,7 +1265,7 @@ static void runloop_iterate_linefeed_overlay(settings_t *settings) * Aborts core shutdown if invoked. */ static int runloop_iterate_time_to_exit_load_dummy(void) { - if (!runloop_ctl(RUNLOOP_CTL_PREPARE_DUMMY, NULL)) + if (!runloop_prepare_dummy()) return -1; runloop_ctl(RUNLOOP_CTL_UNSET_SHUTDOWN, NULL); diff --git a/runloop.h b/runloop.h index ce7cc6f03d..3c7f5ad9b6 100644 --- a/runloop.h +++ b/runloop.h @@ -102,8 +102,7 @@ enum runloop_ctl_state RUNLOOP_CTL_SHADER_DIR_INIT, RUNLOOP_CTL_SYSTEM_INFO_GET, RUNLOOP_CTL_SYSTEM_INFO_INIT, - RUNLOOP_CTL_SYSTEM_INFO_FREE, - RUNLOOP_CTL_PREPARE_DUMMY + RUNLOOP_CTL_SYSTEM_INFO_FREE }; typedef int (*transfer_cb_t)(void *data, size_t len); @@ -295,6 +294,8 @@ void runloop_msg_queue_push(const char *msg, unsigned prio, char* runloop_msg_queue_pull(void); +bool runloop_prepare_dummy(void); + bool runloop_ctl(enum runloop_ctl_state state, void *data); From 35bf38e05cfbaa3ed4efbfdfd2afdcedc2c57b8a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 May 2016 09:25:52 +0200 Subject: [PATCH 446/498] Create runloop_get_system_info/runloop_free_system_info/runloop_init_system_info --- command.c | 12 ++-- configuration.c | 4 +- content.c | 4 +- dynamic.c | 6 +- frontend/frontend.c | 2 +- gfx/video_driver.c | 2 +- location/location_driver.c | 4 +- menu/cbs/menu_cbs_deferred_push.c | 3 +- menu/cbs/menu_cbs_get_value.c | 6 +- menu/cbs/menu_cbs_ok.c | 2 +- menu/drivers/materialui.c | 2 +- menu/menu_displaylist.c | 6 +- menu/menu_entries.c | 2 +- menu/menu_setting.c | 12 ++-- network/netplay_common.c | 2 +- retroarch.c | 28 +++++---- runloop.c | 98 ++++++++++++++++--------------- runloop.h | 12 ++-- 18 files changed, 110 insertions(+), 97 deletions(-) diff --git a/command.c b/command.c index 57762309db..d19de50906 100644 --- a/command.c +++ b/command.c @@ -733,7 +733,7 @@ static void command_event_disk_control_set_eject(bool new_state, bool print_log) rarch_system_info_t *info = NULL; const struct retro_disk_control_callback *control = NULL; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); + runloop_get_system_info((void**)&info); if (info) control = (const struct retro_disk_control_callback*)&info->disk_control_cb; @@ -781,7 +781,7 @@ static void command_event_disk_control_set_index(unsigned idx) rarch_system_info_t *info = NULL; const struct retro_disk_control_callback *control = NULL; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); + runloop_get_system_info((void**)&info); if (info) control = (const struct retro_disk_control_callback*)&info->disk_control_cb; @@ -838,7 +838,7 @@ static bool command_event_disk_control_append_image(const char *path) const struct retro_disk_control_callback *control = NULL; rarch_system_info_t *sysinfo = NULL; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &sysinfo); + runloop_get_system_info((void**)&info); if (sysinfo) control = (const struct retro_disk_control_callback*) @@ -983,7 +983,7 @@ static void command_event_init_controllers(void) settings_t *settings = config_get_ptr(); rarch_system_info_t *info = NULL; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); + runloop_get_system_info((void**)&info); for (i = 0; i < MAX_USERS; i++) { @@ -1236,7 +1236,7 @@ static bool command_event_init_core(enum rarch_core_type *data) if (!core_init_symbols(data)) return false; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_INIT, NULL); + runloop_get_system_info((void**)&info); /* auto overrides: apply overrides */ if(settings->auto_overrides_enable) @@ -1591,7 +1591,7 @@ bool command_event(enum event_command cmd, void *data) settings_t *settings = config_get_ptr(); rarch_system_info_t *info = NULL; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); + runloop_get_system_info((void**)&info); (void)i; diff --git a/configuration.c b/configuration.c index 2adf63d908..3767670826 100644 --- a/configuration.c +++ b/configuration.c @@ -1965,7 +1965,7 @@ bool config_load_override(void) settings_t *settings = config_get_ptr(); rarch_system_info_t *system = NULL; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + runloop_get_system_info((void**)&system); if (system) core_name = system->info.library_name; @@ -2143,7 +2143,7 @@ bool config_load_remap(void) settings_t *settings = config_get_ptr(); rarch_system_info_t *system = NULL; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + runloop_get_system_info((void**)&system); if (system) core_name = system->info.library_name; diff --git a/content.c b/content.c index 7804333047..026d25415c 100644 --- a/content.c +++ b/content.c @@ -1329,7 +1329,7 @@ static bool load_content_from_compressed_archive( settings_t *settings = config_get_ptr(); rarch_system_info_t *sys_info= NULL; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &sys_info); + runloop_get_system_info((void**)sys_info); if (sys_info && sys_info->info.block_extract) return true; @@ -1648,7 +1648,7 @@ static bool content_file_init(struct string_list *temporary_content) rarch_system_info_t *system = NULL; global_t *global = global_get_ptr(); - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + runloop_get_system_info((void**)system); if (*global->subsystem) { diff --git a/dynamic.c b/dynamic.c index edefb1fd1c..e2297bcd4b 100644 --- a/dynamic.c +++ b/dynamic.c @@ -578,7 +578,9 @@ void uninit_libretro_sym(struct retro_core_t *current_core) memset(current_core, 0, sizeof(struct retro_core_t)); runloop_ctl(RUNLOOP_CTL_CORE_OPTIONS_DEINIT, NULL); - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_FREE, NULL); + + runloop_free_system_info(); + runloop_ctl(RUNLOOP_CTL_FRAME_TIME_FREE, NULL); camera_driver_ctl(RARCH_CAMERA_CTL_UNSET_ACTIVE, NULL); location_driver_ctl(RARCH_LOCATION_CTL_UNSET_ACTIVE, NULL); @@ -740,7 +742,7 @@ bool rarch_environment_cb(unsigned cmd, void *data) global_t *global = global_get_ptr(); rarch_system_info_t *system = NULL; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + runloop_get_system_info((void**)&system); if (ignore_environment_cb) return false; diff --git a/frontend/frontend.c b/frontend/frontend.c index 3708bb64d9..24f5ae7c3c 100644 --- a/frontend/frontend.c +++ b/frontend/frontend.c @@ -130,7 +130,7 @@ int rarch_main(int argc, char *argv[], void *data) return 0; } - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + runloop_get_system_info((void**)&system); runloop_ctl(RUNLOOP_CTL_GET_CONTENT_PATH, &fullpath); if (content_is_inited() || content_does_not_need_content()) diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 7af875e3e4..3c380cd5e4 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -598,7 +598,7 @@ static bool init_video(void) struct retro_system_av_info *av_info = video_viewport_get_system_av_info(); - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + runloop_get_system_info((void**)&system); init_video_filter(video_driver_state.pix_fmt); command_event(CMD_EVENT_SHADER_DIR_INIT, NULL); diff --git a/location/location_driver.c b/location/location_driver.c index 4921fb1a92..e8cec5b048 100644 --- a/location/location_driver.c +++ b/location/location_driver.c @@ -203,7 +203,7 @@ void init_location(void) { rarch_system_info_t *system = NULL; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + runloop_get_system_info((void**)&system); /* Resource leaks will follow if location interface is initialized twice. */ if (location_data) @@ -227,7 +227,7 @@ static void uninit_location(void) { rarch_system_info_t *system = NULL; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + runloop_get_system_info((void**)&system); if (location_data && location_driver) { diff --git a/menu/cbs/menu_cbs_deferred_push.c b/menu/cbs/menu_cbs_deferred_push.c index afa343df23..8c7dd23034 100644 --- a/menu/cbs/menu_cbs_deferred_push.c +++ b/menu/cbs/menu_cbs_deferred_push.c @@ -345,7 +345,8 @@ static int general_push(menu_displaylist_info_t *info, core_info_get_list(&list); menu_driver_ctl(RARCH_MENU_CTL_SYSTEM_INFO_GET, &system_menu); - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + + runloop_get_system_info((void**)&system); switch (id) { diff --git a/menu/cbs/menu_cbs_get_value.c b/menu/cbs/menu_cbs_get_value.c index 6ab52e6106..8e6a569801 100644 --- a/menu/cbs/menu_cbs_get_value.c +++ b/menu/cbs/menu_cbs_get_value.c @@ -778,7 +778,8 @@ static void menu_action_setting_disp_set_label_menu_disk_index( rarch_system_info_t *system = NULL; struct retro_disk_control_callback *control = NULL; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + runloop_get_system_info((void**)&system); + if (!system) return; @@ -1164,7 +1165,8 @@ static void menu_action_setting_disp_set_label_core_option_create( rarch_system_info_t *system = NULL; global_t *global = global_get_ptr(); - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + runloop_get_system_info((void**)&system); + if (!system) return; diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index c9d9a25328..5f61e41dc8 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -1013,7 +1013,7 @@ static int generic_action_ok_remap_file_save(const char *path, const char *game_name = NULL; const char *core_name = NULL; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); + runloop_get_system_info((void**)&info); if (info) core_name = info->info.library_name; diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index 49c88ed897..0290b56631 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -685,7 +685,7 @@ static int mui_get_core_title(char *s, size_t len) core_name = system->library_name; core_version = system->library_version; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); + runloop_get_system_info((void**)&info); if (!settings->menu.core_enable) return -1; diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 66fdcd1c7f..5b8aa3bc3d 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -2157,7 +2157,7 @@ static int menu_displaylist_parse_load_content_settings( { rarch_system_info_t *system = NULL; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + runloop_get_system_info((void**)&system); menu_entries_add(info->list, menu_hash_to_str(MENU_LABEL_VALUE_RESUME_CONTENT), @@ -2518,7 +2518,7 @@ static int menu_displaylist_parse_options_remappings( if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu)) return -1; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + runloop_get_system_info((void**)&system); for (p = 0; p < settings->input.max_users; p++) { @@ -3326,7 +3326,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) case DISPLAYLIST_MAIN_MENU: { rarch_system_info_t *system = NULL; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + runloop_get_system_info((void**)&system); if (!rarch_ctl(RARCH_CTL_IS_DUMMY_CORE, NULL)) menu_displaylist_parse_settings(menu, info, diff --git a/menu/menu_entries.c b/menu/menu_entries.c index 9b430e2c26..f79da5fb0e 100644 --- a/menu/menu_entries.c +++ b/menu/menu_entries.c @@ -448,7 +448,7 @@ int menu_entries_get_core_title(char *s, size_t len) core_name = system->library_name; core_version = system->library_version; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); + runloop_get_system_info((void**)&info); if (!settings->menu.core_enable) return -1; diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 0959b2ccc7..d6b69d3307 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -1068,7 +1068,7 @@ static void setting_get_string_representation_uint_libretro_device(void *data, settings_t *settings = config_get_ptr(); rarch_system_info_t *system = NULL; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + runloop_get_system_info((void**)&system); if (!setting) return; @@ -2290,7 +2290,7 @@ static int setting_action_start_libretro_device_type(void *data) settings_t *settings = config_get_ptr(); rarch_system_info_t *system = NULL; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + runloop_get_system_info((void**)&system); if (setting_generic_action_start_default(setting) != 0) return -1; @@ -2440,7 +2440,7 @@ static int setting_action_left_libretro_device_type( settings_t *settings = config_get_ptr(); rarch_system_info_t *system = NULL; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + runloop_get_system_info((void**)&system); if (!setting) return -1; @@ -2505,7 +2505,7 @@ static int setting_action_right_libretro_device_type( settings_t *settings = config_get_ptr(); rarch_system_info_t *system = NULL; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + runloop_get_system_info((void**)&system); if (!setting) return -1; @@ -2888,7 +2888,7 @@ void general_write_handler(void *data) uint32_t hash = setting ? menu_hash_calculate(setting->name) : 0; uint64_t flags = menu_setting_get_flags(setting); - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + runloop_get_system_info((void**)&system); if (!setting) return; @@ -3238,7 +3238,7 @@ static bool setting_append_list_input_player_options( (user == 0) ? retro_keybinds_1 : retro_keybinds_rest; rarch_system_info_t *system = NULL; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + runloop_get_system_info((void**)&system); snprintf(buffer[user], sizeof(buffer[user]), "%s %u", menu_hash_to_str(MENU_VALUE_USER), user + 1); diff --git a/network/netplay_common.c b/network/netplay_common.c index f6bc3deb0b..40b2e3b853 100644 --- a/network/netplay_common.c +++ b/network/netplay_common.c @@ -169,7 +169,7 @@ uint32_t np_impl_magic(void) api = api_info.version; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); + runloop_get_system_info((void**)&info); if (info) lib = info->info.library_name; diff --git a/retroarch.c b/retroarch.c index f4c5fb3ba5..4fcdae0caf 100644 --- a/retroarch.c +++ b/retroarch.c @@ -412,7 +412,8 @@ static void retroarch_set_paths_redirect(const char *path) settings_t *settings = config_get_ptr(); rarch_system_info_t *info = NULL; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); + runloop_get_system_info((void**)&info); + if (!global) { RARCH_WARN("retroarch_set_paths_redirect was sent a NULL \"global\" pointer."); @@ -1066,9 +1067,9 @@ static void retroarch_parse_input(int argc, char *argv[]) static void retroarch_init_savefile_paths(void) { global_t *global = global_get_ptr(); - rarch_system_info_t *system = NULL; + rarch_system_info_t *info = NULL; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + runloop_get_system_info((void**)&info); command_event(CMD_EVENT_SAVEFILES_DEINIT, NULL); @@ -1080,14 +1081,15 @@ static void retroarch_init_savefile_paths(void) /* For subsystems, we know exactly which RAM types are supported. */ unsigned i, j; - const struct retro_subsystem_info *info = + const struct retro_subsystem_info *subsystem_info = libretro_find_subsystem_info( - system->subsystem.data, - system->subsystem.size, + info->subsystem.data, + info->subsystem.size, global->subsystem); /* We'll handle this error gracefully later. */ - unsigned num_content = MIN(info ? info->num_roms : 0, + unsigned num_content = MIN(info + ? subsystem_info->num_roms : 0, global->subsystem_fullpaths ? global->subsystem_fullpaths->size : 0); @@ -1095,14 +1097,14 @@ static void retroarch_init_savefile_paths(void) for (i = 0; i < num_content; i++) { - for (j = 0; j < info->roms[i].num_memory; j++) + for (j = 0; j < subsystem_info->roms[i].num_memory; j++) { union string_list_elem_attr attr; char path[PATH_MAX_LENGTH] = {0}; char ext[32] = {0}; const struct retro_subsystem_memory_info *mem = (const struct retro_subsystem_memory_info*) - &info->roms[i].memory[j]; + &subsystem_info->roms[i].memory[j]; snprintf(ext, sizeof(ext), ".%s", mem->extension); @@ -1172,12 +1174,12 @@ bool retroarch_validate_game_options(char *s, size_t len, bool mkdir) const char *game_name = NULL; global_t *global = global_get_ptr(); settings_t *settings = config_get_ptr(); - rarch_system_info_t *system = NULL; + rarch_system_info_t *info = NULL; - runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + runloop_get_system_info((void**)&info); - if (system) - core_name = system->info.library_name; + if (info) + core_name = info->info.library_name; if (global) game_name = path_basename(global->name.base); diff --git a/runloop.c b/runloop.c index ce0f8f18a4..4d75054087 100644 --- a/runloop.c +++ b/runloop.c @@ -740,6 +740,57 @@ bool runloop_prepare_dummy(void) return true; } +bool runloop_get_system_info(void **data) +{ + rarch_system_info_t **system = (rarch_system_info_t**)data; + if (!system) + return false; + *system = &runloop_system; + return true; +} + +void runloop_init_system_info(void) +{ + core_get_system_info(&runloop_system.info); + + if (!runloop_system.info.library_name) + runloop_system.info.library_name = msg_hash_to_str(MSG_UNKNOWN); + if (!runloop_system.info.library_version) + runloop_system.info.library_version = "v0"; + + video_driver_set_title_buf(); + + strlcpy(runloop_system.valid_extensions, + runloop_system.info.valid_extensions ? + runloop_system.info.valid_extensions : DEFAULT_EXT, + sizeof(runloop_system.valid_extensions)); +} + +void runloop_free_system_info(void) +{ + /* No longer valid. */ + if (runloop_system.subsystem.data) + free(runloop_system.subsystem.data); + runloop_system.subsystem.data = NULL; + runloop_system.subsystem.size = 0; + + if (runloop_system.ports.data) + free(runloop_system.ports.data); + runloop_system.ports.data = NULL; + runloop_system.ports.size = 0; + + if (runloop_system.mmaps.descriptors) + free((void *)runloop_system.mmaps.descriptors); + runloop_system.mmaps.descriptors = NULL; + runloop_system.mmaps.num_descriptors = 0; + + runloop_key_event = NULL; + runloop_frontend_key_event = NULL; + + audio_driver_unset_callback(); + memset(&runloop_system, 0, sizeof(rarch_system_info_t)); +} + bool runloop_ctl(enum runloop_ctl_state state, void *data) { settings_t *settings = config_get_ptr(); @@ -751,21 +802,6 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) break; case RUNLOOP_CTL_SHADER_DIR_INIT: return shader_dir_init(&runloop_shader_dir); - case RUNLOOP_CTL_SYSTEM_INFO_INIT: - core_get_system_info(&runloop_system.info); - - if (!runloop_system.info.library_name) - runloop_system.info.library_name = msg_hash_to_str(MSG_UNKNOWN); - if (!runloop_system.info.library_version) - runloop_system.info.library_version = "v0"; - - video_driver_set_title_buf(); - - strlcpy(runloop_system.valid_extensions, - runloop_system.info.valid_extensions ? - runloop_system.info.valid_extensions : DEFAULT_EXT, - sizeof(runloop_system.valid_extensions)); - break; case RUNLOOP_CTL_GET_CORE_OPTION_SIZE: { unsigned *idx = (unsigned*)data; @@ -784,38 +820,6 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) *coreopts = runloop_core_options; } break; - case RUNLOOP_CTL_SYSTEM_INFO_GET: - { - rarch_system_info_t **system = (rarch_system_info_t**)data; - if (!system) - return false; - *system = &runloop_system; - } - break; - case RUNLOOP_CTL_SYSTEM_INFO_FREE: - - /* No longer valid. */ - if (runloop_system.subsystem.data) - free(runloop_system.subsystem.data); - runloop_system.subsystem.data = NULL; - runloop_system.subsystem.size = 0; - - if (runloop_system.ports.data) - free(runloop_system.ports.data); - runloop_system.ports.data = NULL; - runloop_system.ports.size = 0; - - if (runloop_system.mmaps.descriptors) - free((void *)runloop_system.mmaps.descriptors); - runloop_system.mmaps.descriptors = NULL; - runloop_system.mmaps.num_descriptors = 0; - - runloop_key_event = NULL; - runloop_frontend_key_event = NULL; - - audio_driver_unset_callback(); - memset(&runloop_system, 0, sizeof(rarch_system_info_t)); - break; case RUNLOOP_CTL_SET_FRAME_TIME_LAST: runloop_frame_time_last_enable = true; break; diff --git a/runloop.h b/runloop.h index 3c7f5ad9b6..d92643b929 100644 --- a/runloop.h +++ b/runloop.h @@ -99,10 +99,7 @@ enum runloop_ctl_state RUNLOOP_CTL_CORE_OPTIONS_DEINIT, RUNLOOP_CTL_CORE_OPTIONS_FREE, RUNLOOP_CTL_SHADER_DIR_DEINIT, - RUNLOOP_CTL_SHADER_DIR_INIT, - RUNLOOP_CTL_SYSTEM_INFO_GET, - RUNLOOP_CTL_SYSTEM_INFO_INIT, - RUNLOOP_CTL_SYSTEM_INFO_FREE + RUNLOOP_CTL_SHADER_DIR_INIT }; typedef int (*transfer_cb_t)(void *data, size_t len); @@ -296,8 +293,13 @@ char* runloop_msg_queue_pull(void); bool runloop_prepare_dummy(void); -bool runloop_ctl(enum runloop_ctl_state state, void *data); +void runloop_init_system_info(void); +void runloop_free_system_info(void); + +bool runloop_get_system_info(void **data); + +bool runloop_ctl(enum runloop_ctl_state state, void *data); #ifdef __cplusplus } From 6b33c19802cc2804ad4802ececd0de9b82197e41 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 May 2016 09:31:25 +0200 Subject: [PATCH 447/498] Fix CXX_BUILD --- libretro-common/include/features/features_cpu.h | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/libretro-common/include/features/features_cpu.h b/libretro-common/include/features/features_cpu.h index f5da7c1424..019c7f76a4 100644 --- a/libretro-common/include/features/features_cpu.h +++ b/libretro-common/include/features/features_cpu.h @@ -23,13 +23,13 @@ #ifndef _LIBRETRO_SDK_CPU_INFO_H #define _LIBRETRO_SDK_CPU_INFO_H +#include + #include #include -#ifdef __cplusplus -extern "C" { -#endif +RETRO_BEGIN_DECLS /** * cpu_features_get_perf_counter: @@ -66,10 +66,7 @@ uint64_t cpu_features_get(void); **/ unsigned cpu_features_get_core_amount(void); - -#ifdef __cplusplus -} -#endif +RETRO_END_DECLS #endif From df3b090d7a6e7a546d2e3d59f80890c60e631567 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 May 2016 09:37:21 +0200 Subject: [PATCH 448/498] Revert "Create runloop_get_system_info/runloop_free_system_info/runloop_init_system_info" This reverts commit 35bf38e05cfbaa3ed4efbfdfd2afdcedc2c57b8a. --- command.c | 12 ++-- configuration.c | 4 +- content.c | 4 +- dynamic.c | 6 +- frontend/frontend.c | 2 +- gfx/video_driver.c | 2 +- location/location_driver.c | 4 +- menu/cbs/menu_cbs_deferred_push.c | 3 +- menu/cbs/menu_cbs_get_value.c | 6 +- menu/cbs/menu_cbs_ok.c | 2 +- menu/drivers/materialui.c | 2 +- menu/menu_displaylist.c | 6 +- menu/menu_entries.c | 2 +- menu/menu_setting.c | 12 ++-- network/netplay_common.c | 2 +- retroarch.c | 28 ++++----- runloop.c | 98 +++++++++++++++---------------- runloop.h | 12 ++-- 18 files changed, 97 insertions(+), 110 deletions(-) diff --git a/command.c b/command.c index d19de50906..57762309db 100644 --- a/command.c +++ b/command.c @@ -733,7 +733,7 @@ static void command_event_disk_control_set_eject(bool new_state, bool print_log) rarch_system_info_t *info = NULL; const struct retro_disk_control_callback *control = NULL; - runloop_get_system_info((void**)&info); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); if (info) control = (const struct retro_disk_control_callback*)&info->disk_control_cb; @@ -781,7 +781,7 @@ static void command_event_disk_control_set_index(unsigned idx) rarch_system_info_t *info = NULL; const struct retro_disk_control_callback *control = NULL; - runloop_get_system_info((void**)&info); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); if (info) control = (const struct retro_disk_control_callback*)&info->disk_control_cb; @@ -838,7 +838,7 @@ static bool command_event_disk_control_append_image(const char *path) const struct retro_disk_control_callback *control = NULL; rarch_system_info_t *sysinfo = NULL; - runloop_get_system_info((void**)&info); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &sysinfo); if (sysinfo) control = (const struct retro_disk_control_callback*) @@ -983,7 +983,7 @@ static void command_event_init_controllers(void) settings_t *settings = config_get_ptr(); rarch_system_info_t *info = NULL; - runloop_get_system_info((void**)&info); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); for (i = 0; i < MAX_USERS; i++) { @@ -1236,7 +1236,7 @@ static bool command_event_init_core(enum rarch_core_type *data) if (!core_init_symbols(data)) return false; - runloop_get_system_info((void**)&info); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_INIT, NULL); /* auto overrides: apply overrides */ if(settings->auto_overrides_enable) @@ -1591,7 +1591,7 @@ bool command_event(enum event_command cmd, void *data) settings_t *settings = config_get_ptr(); rarch_system_info_t *info = NULL; - runloop_get_system_info((void**)&info); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); (void)i; diff --git a/configuration.c b/configuration.c index 3767670826..2adf63d908 100644 --- a/configuration.c +++ b/configuration.c @@ -1965,7 +1965,7 @@ bool config_load_override(void) settings_t *settings = config_get_ptr(); rarch_system_info_t *system = NULL; - runloop_get_system_info((void**)&system); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (system) core_name = system->info.library_name; @@ -2143,7 +2143,7 @@ bool config_load_remap(void) settings_t *settings = config_get_ptr(); rarch_system_info_t *system = NULL; - runloop_get_system_info((void**)&system); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (system) core_name = system->info.library_name; diff --git a/content.c b/content.c index 026d25415c..7804333047 100644 --- a/content.c +++ b/content.c @@ -1329,7 +1329,7 @@ static bool load_content_from_compressed_archive( settings_t *settings = config_get_ptr(); rarch_system_info_t *sys_info= NULL; - runloop_get_system_info((void**)sys_info); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &sys_info); if (sys_info && sys_info->info.block_extract) return true; @@ -1648,7 +1648,7 @@ static bool content_file_init(struct string_list *temporary_content) rarch_system_info_t *system = NULL; global_t *global = global_get_ptr(); - runloop_get_system_info((void**)system); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (*global->subsystem) { diff --git a/dynamic.c b/dynamic.c index e2297bcd4b..edefb1fd1c 100644 --- a/dynamic.c +++ b/dynamic.c @@ -578,9 +578,7 @@ void uninit_libretro_sym(struct retro_core_t *current_core) memset(current_core, 0, sizeof(struct retro_core_t)); runloop_ctl(RUNLOOP_CTL_CORE_OPTIONS_DEINIT, NULL); - - runloop_free_system_info(); - + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_FREE, NULL); runloop_ctl(RUNLOOP_CTL_FRAME_TIME_FREE, NULL); camera_driver_ctl(RARCH_CAMERA_CTL_UNSET_ACTIVE, NULL); location_driver_ctl(RARCH_LOCATION_CTL_UNSET_ACTIVE, NULL); @@ -742,7 +740,7 @@ bool rarch_environment_cb(unsigned cmd, void *data) global_t *global = global_get_ptr(); rarch_system_info_t *system = NULL; - runloop_get_system_info((void**)&system); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (ignore_environment_cb) return false; diff --git a/frontend/frontend.c b/frontend/frontend.c index 24f5ae7c3c..3708bb64d9 100644 --- a/frontend/frontend.c +++ b/frontend/frontend.c @@ -130,7 +130,7 @@ int rarch_main(int argc, char *argv[], void *data) return 0; } - runloop_get_system_info((void**)&system); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); runloop_ctl(RUNLOOP_CTL_GET_CONTENT_PATH, &fullpath); if (content_is_inited() || content_does_not_need_content()) diff --git a/gfx/video_driver.c b/gfx/video_driver.c index 3c380cd5e4..7af875e3e4 100644 --- a/gfx/video_driver.c +++ b/gfx/video_driver.c @@ -598,7 +598,7 @@ static bool init_video(void) struct retro_system_av_info *av_info = video_viewport_get_system_av_info(); - runloop_get_system_info((void**)&system); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); init_video_filter(video_driver_state.pix_fmt); command_event(CMD_EVENT_SHADER_DIR_INIT, NULL); diff --git a/location/location_driver.c b/location/location_driver.c index e8cec5b048..4921fb1a92 100644 --- a/location/location_driver.c +++ b/location/location_driver.c @@ -203,7 +203,7 @@ void init_location(void) { rarch_system_info_t *system = NULL; - runloop_get_system_info((void**)&system); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); /* Resource leaks will follow if location interface is initialized twice. */ if (location_data) @@ -227,7 +227,7 @@ static void uninit_location(void) { rarch_system_info_t *system = NULL; - runloop_get_system_info((void**)&system); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (location_data && location_driver) { diff --git a/menu/cbs/menu_cbs_deferred_push.c b/menu/cbs/menu_cbs_deferred_push.c index 8c7dd23034..afa343df23 100644 --- a/menu/cbs/menu_cbs_deferred_push.c +++ b/menu/cbs/menu_cbs_deferred_push.c @@ -345,8 +345,7 @@ static int general_push(menu_displaylist_info_t *info, core_info_get_list(&list); menu_driver_ctl(RARCH_MENU_CTL_SYSTEM_INFO_GET, &system_menu); - - runloop_get_system_info((void**)&system); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); switch (id) { diff --git a/menu/cbs/menu_cbs_get_value.c b/menu/cbs/menu_cbs_get_value.c index 8e6a569801..6ab52e6106 100644 --- a/menu/cbs/menu_cbs_get_value.c +++ b/menu/cbs/menu_cbs_get_value.c @@ -778,8 +778,7 @@ static void menu_action_setting_disp_set_label_menu_disk_index( rarch_system_info_t *system = NULL; struct retro_disk_control_callback *control = NULL; - runloop_get_system_info((void**)&system); - + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (!system) return; @@ -1165,8 +1164,7 @@ static void menu_action_setting_disp_set_label_core_option_create( rarch_system_info_t *system = NULL; global_t *global = global_get_ptr(); - runloop_get_system_info((void**)&system); - + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (!system) return; diff --git a/menu/cbs/menu_cbs_ok.c b/menu/cbs/menu_cbs_ok.c index 5f61e41dc8..c9d9a25328 100644 --- a/menu/cbs/menu_cbs_ok.c +++ b/menu/cbs/menu_cbs_ok.c @@ -1013,7 +1013,7 @@ static int generic_action_ok_remap_file_save(const char *path, const char *game_name = NULL; const char *core_name = NULL; - runloop_get_system_info((void**)&info); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); if (info) core_name = info->info.library_name; diff --git a/menu/drivers/materialui.c b/menu/drivers/materialui.c index 0290b56631..49c88ed897 100644 --- a/menu/drivers/materialui.c +++ b/menu/drivers/materialui.c @@ -685,7 +685,7 @@ static int mui_get_core_title(char *s, size_t len) core_name = system->library_name; core_version = system->library_version; - runloop_get_system_info((void**)&info); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); if (!settings->menu.core_enable) return -1; diff --git a/menu/menu_displaylist.c b/menu/menu_displaylist.c index 5b8aa3bc3d..66fdcd1c7f 100644 --- a/menu/menu_displaylist.c +++ b/menu/menu_displaylist.c @@ -2157,7 +2157,7 @@ static int menu_displaylist_parse_load_content_settings( { rarch_system_info_t *system = NULL; - runloop_get_system_info((void**)&system); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); menu_entries_add(info->list, menu_hash_to_str(MENU_LABEL_VALUE_RESUME_CONTENT), @@ -2518,7 +2518,7 @@ static int menu_displaylist_parse_options_remappings( if (!menu_driver_ctl(RARCH_MENU_CTL_DRIVER_DATA_GET, &menu)) return -1; - runloop_get_system_info((void**)&system); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); for (p = 0; p < settings->input.max_users; p++) { @@ -3326,7 +3326,7 @@ bool menu_displaylist_ctl(enum menu_displaylist_ctl_state type, void *data) case DISPLAYLIST_MAIN_MENU: { rarch_system_info_t *system = NULL; - runloop_get_system_info((void**)&system); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (!rarch_ctl(RARCH_CTL_IS_DUMMY_CORE, NULL)) menu_displaylist_parse_settings(menu, info, diff --git a/menu/menu_entries.c b/menu/menu_entries.c index f79da5fb0e..9b430e2c26 100644 --- a/menu/menu_entries.c +++ b/menu/menu_entries.c @@ -448,7 +448,7 @@ int menu_entries_get_core_title(char *s, size_t len) core_name = system->library_name; core_version = system->library_version; - runloop_get_system_info((void**)&info); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); if (!settings->menu.core_enable) return -1; diff --git a/menu/menu_setting.c b/menu/menu_setting.c index d6b69d3307..0959b2ccc7 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -1068,7 +1068,7 @@ static void setting_get_string_representation_uint_libretro_device(void *data, settings_t *settings = config_get_ptr(); rarch_system_info_t *system = NULL; - runloop_get_system_info((void**)&system); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (!setting) return; @@ -2290,7 +2290,7 @@ static int setting_action_start_libretro_device_type(void *data) settings_t *settings = config_get_ptr(); rarch_system_info_t *system = NULL; - runloop_get_system_info((void**)&system); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (setting_generic_action_start_default(setting) != 0) return -1; @@ -2440,7 +2440,7 @@ static int setting_action_left_libretro_device_type( settings_t *settings = config_get_ptr(); rarch_system_info_t *system = NULL; - runloop_get_system_info((void**)&system); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (!setting) return -1; @@ -2505,7 +2505,7 @@ static int setting_action_right_libretro_device_type( settings_t *settings = config_get_ptr(); rarch_system_info_t *system = NULL; - runloop_get_system_info((void**)&system); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (!setting) return -1; @@ -2888,7 +2888,7 @@ void general_write_handler(void *data) uint32_t hash = setting ? menu_hash_calculate(setting->name) : 0; uint64_t flags = menu_setting_get_flags(setting); - runloop_get_system_info((void**)&system); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); if (!setting) return; @@ -3238,7 +3238,7 @@ static bool setting_append_list_input_player_options( (user == 0) ? retro_keybinds_1 : retro_keybinds_rest; rarch_system_info_t *system = NULL; - runloop_get_system_info((void**)&system); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); snprintf(buffer[user], sizeof(buffer[user]), "%s %u", menu_hash_to_str(MENU_VALUE_USER), user + 1); diff --git a/network/netplay_common.c b/network/netplay_common.c index 40b2e3b853..f6bc3deb0b 100644 --- a/network/netplay_common.c +++ b/network/netplay_common.c @@ -169,7 +169,7 @@ uint32_t np_impl_magic(void) api = api_info.version; - runloop_get_system_info((void**)&info); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); if (info) lib = info->info.library_name; diff --git a/retroarch.c b/retroarch.c index 4fcdae0caf..f4c5fb3ba5 100644 --- a/retroarch.c +++ b/retroarch.c @@ -412,8 +412,7 @@ static void retroarch_set_paths_redirect(const char *path) settings_t *settings = config_get_ptr(); rarch_system_info_t *info = NULL; - runloop_get_system_info((void**)&info); - + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &info); if (!global) { RARCH_WARN("retroarch_set_paths_redirect was sent a NULL \"global\" pointer."); @@ -1067,9 +1066,9 @@ static void retroarch_parse_input(int argc, char *argv[]) static void retroarch_init_savefile_paths(void) { global_t *global = global_get_ptr(); - rarch_system_info_t *info = NULL; + rarch_system_info_t *system = NULL; - runloop_get_system_info((void**)&info); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); command_event(CMD_EVENT_SAVEFILES_DEINIT, NULL); @@ -1081,15 +1080,14 @@ static void retroarch_init_savefile_paths(void) /* For subsystems, we know exactly which RAM types are supported. */ unsigned i, j; - const struct retro_subsystem_info *subsystem_info = + const struct retro_subsystem_info *info = libretro_find_subsystem_info( - info->subsystem.data, - info->subsystem.size, + system->subsystem.data, + system->subsystem.size, global->subsystem); /* We'll handle this error gracefully later. */ - unsigned num_content = MIN(info - ? subsystem_info->num_roms : 0, + unsigned num_content = MIN(info ? info->num_roms : 0, global->subsystem_fullpaths ? global->subsystem_fullpaths->size : 0); @@ -1097,14 +1095,14 @@ static void retroarch_init_savefile_paths(void) for (i = 0; i < num_content; i++) { - for (j = 0; j < subsystem_info->roms[i].num_memory; j++) + for (j = 0; j < info->roms[i].num_memory; j++) { union string_list_elem_attr attr; char path[PATH_MAX_LENGTH] = {0}; char ext[32] = {0}; const struct retro_subsystem_memory_info *mem = (const struct retro_subsystem_memory_info*) - &subsystem_info->roms[i].memory[j]; + &info->roms[i].memory[j]; snprintf(ext, sizeof(ext), ".%s", mem->extension); @@ -1174,12 +1172,12 @@ bool retroarch_validate_game_options(char *s, size_t len, bool mkdir) const char *game_name = NULL; global_t *global = global_get_ptr(); settings_t *settings = config_get_ptr(); - rarch_system_info_t *info = NULL; + rarch_system_info_t *system = NULL; - runloop_get_system_info((void**)&info); + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); - if (info) - core_name = info->info.library_name; + if (system) + core_name = system->info.library_name; if (global) game_name = path_basename(global->name.base); diff --git a/runloop.c b/runloop.c index 4d75054087..ce0f8f18a4 100644 --- a/runloop.c +++ b/runloop.c @@ -740,57 +740,6 @@ bool runloop_prepare_dummy(void) return true; } -bool runloop_get_system_info(void **data) -{ - rarch_system_info_t **system = (rarch_system_info_t**)data; - if (!system) - return false; - *system = &runloop_system; - return true; -} - -void runloop_init_system_info(void) -{ - core_get_system_info(&runloop_system.info); - - if (!runloop_system.info.library_name) - runloop_system.info.library_name = msg_hash_to_str(MSG_UNKNOWN); - if (!runloop_system.info.library_version) - runloop_system.info.library_version = "v0"; - - video_driver_set_title_buf(); - - strlcpy(runloop_system.valid_extensions, - runloop_system.info.valid_extensions ? - runloop_system.info.valid_extensions : DEFAULT_EXT, - sizeof(runloop_system.valid_extensions)); -} - -void runloop_free_system_info(void) -{ - /* No longer valid. */ - if (runloop_system.subsystem.data) - free(runloop_system.subsystem.data); - runloop_system.subsystem.data = NULL; - runloop_system.subsystem.size = 0; - - if (runloop_system.ports.data) - free(runloop_system.ports.data); - runloop_system.ports.data = NULL; - runloop_system.ports.size = 0; - - if (runloop_system.mmaps.descriptors) - free((void *)runloop_system.mmaps.descriptors); - runloop_system.mmaps.descriptors = NULL; - runloop_system.mmaps.num_descriptors = 0; - - runloop_key_event = NULL; - runloop_frontend_key_event = NULL; - - audio_driver_unset_callback(); - memset(&runloop_system, 0, sizeof(rarch_system_info_t)); -} - bool runloop_ctl(enum runloop_ctl_state state, void *data) { settings_t *settings = config_get_ptr(); @@ -802,6 +751,21 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) break; case RUNLOOP_CTL_SHADER_DIR_INIT: return shader_dir_init(&runloop_shader_dir); + case RUNLOOP_CTL_SYSTEM_INFO_INIT: + core_get_system_info(&runloop_system.info); + + if (!runloop_system.info.library_name) + runloop_system.info.library_name = msg_hash_to_str(MSG_UNKNOWN); + if (!runloop_system.info.library_version) + runloop_system.info.library_version = "v0"; + + video_driver_set_title_buf(); + + strlcpy(runloop_system.valid_extensions, + runloop_system.info.valid_extensions ? + runloop_system.info.valid_extensions : DEFAULT_EXT, + sizeof(runloop_system.valid_extensions)); + break; case RUNLOOP_CTL_GET_CORE_OPTION_SIZE: { unsigned *idx = (unsigned*)data; @@ -820,6 +784,38 @@ bool runloop_ctl(enum runloop_ctl_state state, void *data) *coreopts = runloop_core_options; } break; + case RUNLOOP_CTL_SYSTEM_INFO_GET: + { + rarch_system_info_t **system = (rarch_system_info_t**)data; + if (!system) + return false; + *system = &runloop_system; + } + break; + case RUNLOOP_CTL_SYSTEM_INFO_FREE: + + /* No longer valid. */ + if (runloop_system.subsystem.data) + free(runloop_system.subsystem.data); + runloop_system.subsystem.data = NULL; + runloop_system.subsystem.size = 0; + + if (runloop_system.ports.data) + free(runloop_system.ports.data); + runloop_system.ports.data = NULL; + runloop_system.ports.size = 0; + + if (runloop_system.mmaps.descriptors) + free((void *)runloop_system.mmaps.descriptors); + runloop_system.mmaps.descriptors = NULL; + runloop_system.mmaps.num_descriptors = 0; + + runloop_key_event = NULL; + runloop_frontend_key_event = NULL; + + audio_driver_unset_callback(); + memset(&runloop_system, 0, sizeof(rarch_system_info_t)); + break; case RUNLOOP_CTL_SET_FRAME_TIME_LAST: runloop_frame_time_last_enable = true; break; diff --git a/runloop.h b/runloop.h index d92643b929..3c7f5ad9b6 100644 --- a/runloop.h +++ b/runloop.h @@ -99,7 +99,10 @@ enum runloop_ctl_state RUNLOOP_CTL_CORE_OPTIONS_DEINIT, RUNLOOP_CTL_CORE_OPTIONS_FREE, RUNLOOP_CTL_SHADER_DIR_DEINIT, - RUNLOOP_CTL_SHADER_DIR_INIT + RUNLOOP_CTL_SHADER_DIR_INIT, + RUNLOOP_CTL_SYSTEM_INFO_GET, + RUNLOOP_CTL_SYSTEM_INFO_INIT, + RUNLOOP_CTL_SYSTEM_INFO_FREE }; typedef int (*transfer_cb_t)(void *data, size_t len); @@ -293,14 +296,9 @@ char* runloop_msg_queue_pull(void); bool runloop_prepare_dummy(void); -void runloop_init_system_info(void); - -void runloop_free_system_info(void); - -bool runloop_get_system_info(void **data); - bool runloop_ctl(enum runloop_ctl_state state, void *data); + #ifdef __cplusplus } #endif From a7d4379011b068442dcdf4a01042fd1670dd95b4 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 May 2016 10:20:14 +0200 Subject: [PATCH 449/498] Rename np_is_server to netplay_is_server --- network/netplay_common.c | 2 +- network/netplay_net.c | 2 +- network/netplay_private.h | 4 +++- network/netplay_spectate.c | 6 +++--- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/network/netplay_common.c b/network/netplay_common.c index f6bc3deb0b..764846b7af 100644 --- a/network/netplay_common.c +++ b/network/netplay_common.c @@ -311,7 +311,7 @@ bool np_get_info(netplay_t *netplay) return true; } -bool np_is_server(netplay_t* netplay) +bool netplay_is_server(netplay_t* netplay) { if (!netplay) return false; diff --git a/network/netplay_net.c b/network/netplay_net.c index 42a224f77a..5a2fd1c911 100644 --- a/network/netplay_net.c +++ b/network/netplay_net.c @@ -137,7 +137,7 @@ static bool netplay_net_init_buffers(netplay_t *netplay) static bool netplay_net_info_cb(netplay_t* netplay, unsigned frames) { - if (np_is_server(netplay)) + if (netplay_is_server(netplay)) { if (!np_send_info(netplay)) return false; diff --git a/network/netplay_private.h b/network/netplay_private.h index d1d7e8b489..49158ca859 100644 --- a/network/netplay_private.h +++ b/network/netplay_private.h @@ -16,6 +16,7 @@ #ifndef __RARCH_NETPLAY_PRIVATE_H #define __RARCH_NETPLAY_PRIVATE_H + #include "netplay.h" #include @@ -149,6 +150,7 @@ bool np_bsv_parse_header(const uint32_t *header, uint32_t magic); uint32_t np_impl_magic(void); bool np_send_info(netplay_t *netplay); bool np_get_info(netplay_t *netplay); -bool np_is_server(netplay_t* netplay); +bool netplay_is_server(netplay_t* netplay); bool np_is_spectate(netplay_t* netplay); + #endif diff --git a/network/netplay_spectate.c b/network/netplay_spectate.c index d257c61212..fea0576625 100644 --- a/network/netplay_spectate.c +++ b/network/netplay_spectate.c @@ -41,7 +41,7 @@ static void netplay_spectate_pre_frame(netplay_t *netplay) fd_set fds; struct timeval tmp_tv = {0}; - if (!np_is_server(netplay)) + if (!netplay_is_server(netplay)) return; FD_ZERO(&fds); @@ -133,7 +133,7 @@ static void netplay_spectate_post_frame(netplay_t *netplay) { unsigned i; - if (!np_is_server(netplay)) + if (!netplay_is_server(netplay)) return; for (i = 0; i < MAX_SPECTATORS; i++) @@ -165,7 +165,7 @@ static void netplay_spectate_post_frame(netplay_t *netplay) static bool netplay_spectate_info_cb(netplay_t *netplay, unsigned frames) { unsigned i; - if(np_is_server(netplay)) + if(netplay_is_server(netplay)) { if(!np_get_info(netplay)) return false; From 193eb623541e8cb2628ff2d9f83431fba7358946 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 May 2016 10:29:19 +0200 Subject: [PATCH 450/498] (Android) Add include dirs --- pkg/android/phoenix/jni/Android.mk | 3 ++- pkg/android/phoenix/jni/Android2.mk | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/pkg/android/phoenix/jni/Android.mk b/pkg/android/phoenix/jni/Android.mk index fac9cf6e7e..702b06f30b 100644 --- a/pkg/android/phoenix/jni/Android.mk +++ b/pkg/android/phoenix/jni/Android.mk @@ -79,7 +79,8 @@ LOCAL_CPPFLAGS += -I$(LOCAL_PATH)/$(RARCH_DIR)/deps/glslang \ -I$(LOCAL_PATH)/$(RARCH_DIR)/deps/glslang/glslang/glslang/Public \ -I$(LOCAL_PATH)/$(RARCH_DIR)/deps/glslang/glslang/glslang/MachineIndependent \ -I$(LOCAL_PATH)/$(RARCH_DIR)/deps/glslang/glslang/SPIRV \ - -I$(LOCAL_PATH)/$(RARCH_DIR)/deps/spir2cross + -I$(LOCAL_PATH)/$(RARCH_DIR)/deps/spir2cross \ + -I$(LOCAL_PATH)/$(RARCH_DIR)/deps/SPIRV-Cross LOCAL_SRC_FILES += $(RARCH_DIR)/deps/glslang/glslang.cpp \ $(RARCH_DIR)/deps/glslang/glslang/SPIRV/SpvBuilder.cpp \ diff --git a/pkg/android/phoenix/jni/Android2.mk b/pkg/android/phoenix/jni/Android2.mk index 06ec713d76..265d051fd1 100644 --- a/pkg/android/phoenix/jni/Android2.mk +++ b/pkg/android/phoenix/jni/Android2.mk @@ -83,7 +83,10 @@ LOCAL_C_INCLUDES += $(INCFLAGS) LOCAL_CPPFLAGS += -I$(LOCAL_PATH)/$(RARCH_DIR)/deps/glslang \ -I$(LOCAL_PATH)/$(RARCH_DIR)/deps/glslang/glslang/glslang/Public \ -I$(LOCAL_PATH)/$(RARCH_DIR)/deps/glslang/glslang/glslang/MachineIndependent \ - -I$(LOCAL_PATH)/$(RARCH_DIR)/deps/glslang/glslang/SPIRV + -I$(LOCAL_PATH)/$(RARCH_DIR)/deps/glslang/glslang/SPIRV \ + -I$(LOCAL_PATH)/$(RARCH_DIR)/deps/spir2cross \ + -I$(LOCAL_PATH)/$(RARCH_DIR)/deps/SPIRV-Cross + LOCAL_SRC_FILES += $(RARCH_DIR)/deps/glslang/glslang.cpp \ $(RARCH_DIR)/deps/glslang/glslang/SPIRV/SpvBuilder.cpp \ $(RARCH_DIR)/deps/glslang/glslang/SPIRV/SPVRemapper.cpp \ From 315c6b968736de578861328d2129b3060fe941e4 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 May 2016 10:44:15 +0200 Subject: [PATCH 451/498] Cleanups --- pkg/android/phoenix/jni/Android.mk | 2 +- pkg/android/phoenix/jni/Android2.mk | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/pkg/android/phoenix/jni/Android.mk b/pkg/android/phoenix/jni/Android.mk index 702b06f30b..5125d92e9c 100644 --- a/pkg/android/phoenix/jni/Android.mk +++ b/pkg/android/phoenix/jni/Android.mk @@ -63,7 +63,7 @@ DEFINES += -DHAVE_CHEEVOS DEFINES += -DHAVE_SL LOCAL_CFLAGS += -Wall -std=gnu99 -pthread -Wno-unused-function -fno-stack-protector -funroll-loops $(DEFINES) -LOCAL_CPPFLAGS := -fno-exceptions -std=gnu++11 -fno-rtti -Wno-reorder $(DEFINES) +LOCAL_CPPFLAGS := -fexceptions -std=gnu++11 -fno-rtti -Wno-reorder $(DEFINES) # Let ndk-build set the optimization flags but remove -O3 like in cf3c3 LOCAL_CFLAGS := $(subst -O3,-O2,$(LOCAL_CFLAGS)) diff --git a/pkg/android/phoenix/jni/Android2.mk b/pkg/android/phoenix/jni/Android2.mk index 265d051fd1..f1177b051e 100644 --- a/pkg/android/phoenix/jni/Android2.mk +++ b/pkg/android/phoenix/jni/Android2.mk @@ -65,7 +65,7 @@ DEFINES += -DDEBUG_ANDROID DEFINES += -DHAVE_SL LOCAL_CFLAGS += -Wall -std=gnu99 -pthread -Wno-unused-function -fno-stack-protector -funroll-loops $(DEFINES) -LOCAL_CPPFLAGS := -std=gnu++11 $(DEFINES) +LOCAL_CPPFLAGS := -fexceptions -std=gnu++11 -fno-rtti -Wno-reorder $(DEFINES) ifeq ($(NDK_DEBUG),1) LOCAL_CFLAGS += -O0 -g From cba281052a6e7ae616674ece18f328db972a2ad1 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 May 2016 12:03:43 +0200 Subject: [PATCH 452/498] Rename np_ functions --- network/netplay.c | 2 +- network/netplay_common.c | 32 ++++++++++++++++---------------- network/netplay_net.c | 4 ++-- network/netplay_private.h | 20 ++++++++++---------- network/netplay_spectate.c | 12 ++++++------ 5 files changed, 35 insertions(+), 35 deletions(-) diff --git a/network/netplay.c b/network/netplay.c index 2a26c5b523..2491f569a8 100644 --- a/network/netplay.c +++ b/network/netplay.c @@ -589,7 +589,7 @@ int16_t input_state_net(unsigned port, unsigned device, #ifndef HAVE_SOCKET_LEGACY /* Custom inet_ntop. Win32 doesn't seem to support this ... */ -void np_log_connection(const struct sockaddr_storage *their_addr, +void netplay_log_connection(const struct sockaddr_storage *their_addr, unsigned slot, const char *nick) { union diff --git a/network/netplay_common.c b/network/netplay_common.c index 764846b7af..7d438e3525 100644 --- a/network/netplay_common.c +++ b/network/netplay_common.c @@ -18,7 +18,7 @@ #include #include "../content.h" -bool np_get_nickname(netplay_t *netplay, int fd) +bool netplay_get_nickname(netplay_t *netplay, int fd) { uint8_t nick_size; @@ -42,7 +42,7 @@ bool np_get_nickname(netplay_t *netplay, int fd) return true; } -bool np_send_nickname(netplay_t *netplay, int fd) +bool netplay_send_nickname(netplay_t *netplay, int fd) { uint8_t nick_size = strlen(netplay->nick); @@ -61,7 +61,7 @@ bool np_send_nickname(netplay_t *netplay, int fd) return true; } -uint32_t *np_bsv_header_generate(size_t *size, uint32_t magic) +uint32_t *netplay_bsv_header_generate(size_t *size, uint32_t magic) { retro_ctx_serialize_info_t serial_info; retro_ctx_size_info_t info; @@ -100,7 +100,7 @@ error: return NULL; } -bool np_bsv_parse_header(const uint32_t *header, uint32_t magic) +bool netplay_bsv_parse_header(const uint32_t *header, uint32_t magic) { retro_ctx_size_info_t info; uint32_t *content_crc_ptr; @@ -146,7 +146,7 @@ bool np_bsv_parse_header(const uint32_t *header, uint32_t magic) } /** - * np_impl_magic: + * netplay_impl_magic: * * Not really a hash, but should be enough to differentiate * implementations from each other. @@ -155,7 +155,7 @@ bool np_bsv_parse_header(const uint32_t *header, uint32_t magic) * The alternative would have been checking serialization sizes, but it * was troublesome for cross platform compat. **/ -uint32_t np_impl_magic(void) +uint32_t netplay_impl_magic(void) { size_t i, len; retro_ctx_api_info_t api_info; @@ -193,7 +193,7 @@ uint32_t np_impl_magic(void) return res; } -bool np_send_info(netplay_t *netplay) +bool netplay_send_info(netplay_t *netplay) { unsigned sram_size; retro_ctx_memory_info_t mem_info; @@ -208,13 +208,13 @@ bool np_send_info(netplay_t *netplay) content_get_crc(&content_crc_ptr); header[0] = htonl(*content_crc_ptr); - header[1] = htonl(np_impl_magic()); + header[1] = htonl(netplay_impl_magic()); header[2] = htonl(mem_info.size); if (!socket_send_all_blocking(netplay->fd, header, sizeof(header), false)) return false; - if (!np_send_nickname(netplay, netplay->fd)) + if (!netplay_send_nickname(netplay, netplay->fd)) { RARCH_ERR("Failed to send nick to host.\n"); return false; @@ -230,7 +230,7 @@ bool np_send_info(netplay_t *netplay) return false; } - if (!np_get_nickname(netplay, netplay->fd)) + if (!netplay_get_nickname(netplay, netplay->fd)) { RARCH_ERR("Failed to receive nick from host.\n"); return false; @@ -243,7 +243,7 @@ bool np_send_info(netplay_t *netplay) return true; } -bool np_get_info(netplay_t *netplay) +bool netplay_get_info(netplay_t *netplay) { unsigned sram_size; uint32_t header[3]; @@ -265,7 +265,7 @@ bool np_get_info(netplay_t *netplay) return false; } - if (np_impl_magic() != ntohl(header[1])) + if (netplay_impl_magic() != ntohl(header[1])) { RARCH_ERR("Implementations differ, make sure you're using exact same " "libretro implementations and RetroArch version.\n"); @@ -282,7 +282,7 @@ bool np_get_info(netplay_t *netplay) return false; } - if (!np_get_nickname(netplay, netplay->fd)) + if (!netplay_get_nickname(netplay, netplay->fd)) { RARCH_ERR("Failed to get nickname from client.\n"); return false; @@ -298,14 +298,14 @@ bool np_get_info(netplay_t *netplay) return false; } - if (!np_send_nickname(netplay, netplay->fd)) + if (!netplay_send_nickname(netplay, netplay->fd)) { RARCH_ERR("Failed to send nickname to client.\n"); return false; } #ifndef HAVE_SOCKET_LEGACY - np_log_connection(&netplay->other_addr, 0, netplay->other_nick); + netplay_log_connection(&netplay->other_addr, 0, netplay->other_nick); #endif return true; @@ -318,7 +318,7 @@ bool netplay_is_server(netplay_t* netplay) return netplay->is_server; } -bool np_is_spectate(netplay_t* netplay) +bool netplay_is_spectate(netplay_t* netplay) { if (!netplay) return false; diff --git a/network/netplay_net.c b/network/netplay_net.c index 5a2fd1c911..d119c73c53 100644 --- a/network/netplay_net.c +++ b/network/netplay_net.c @@ -139,12 +139,12 @@ static bool netplay_net_info_cb(netplay_t* netplay, unsigned frames) { if (netplay_is_server(netplay)) { - if (!np_send_info(netplay)) + if (!netplay_send_info(netplay)) return false; } else { - if (!np_get_info(netplay)) + if (!netplay_get_info(netplay)) return false; } diff --git a/network/netplay_private.h b/network/netplay_private.h index 49158ca859..e52ceae46a 100644 --- a/network/netplay_private.h +++ b/network/netplay_private.h @@ -139,18 +139,18 @@ extern void *netplay_data; struct netplay_callbacks* netplay_get_cbs_net(void); struct netplay_callbacks* netplay_get_cbs_spectate(void); -void np_log_connection(const struct sockaddr_storage *their_addr, +void netplay_log_connection(const struct sockaddr_storage *their_addr, unsigned slot, const char *nick); -bool np_get_nickname(netplay_t *netplay, int fd); -bool np_send_nickname(netplay_t *netplay, int fd); -bool np_send_info(netplay_t *netplay); -uint32_t *np_bsv_header_generate(size_t *size, uint32_t magic); -bool np_bsv_parse_header(const uint32_t *header, uint32_t magic); -uint32_t np_impl_magic(void); -bool np_send_info(netplay_t *netplay); -bool np_get_info(netplay_t *netplay); +bool netplay_get_nickname(netplay_t *netplay, int fd); +bool netplay_send_nickname(netplay_t *netplay, int fd); +bool netplay_send_info(netplay_t *netplay); +uint32_t *netplay_bsv_header_generate(size_t *size, uint32_t magic); +bool netplay_bsv_parse_header(const uint32_t *header, uint32_t magic); +uint32_t netplay_impl_magic(void); +bool netplay_send_info(netplay_t *netplay); +bool netplay_get_info(netplay_t *netplay); bool netplay_is_server(netplay_t* netplay); -bool np_is_spectate(netplay_t* netplay); +bool netplay_is_spectate(netplay_t* netplay); #endif diff --git a/network/netplay_spectate.c b/network/netplay_spectate.c index fea0576625..455b4de174 100644 --- a/network/netplay_spectate.c +++ b/network/netplay_spectate.c @@ -78,22 +78,22 @@ static void netplay_spectate_pre_frame(netplay_t *netplay) return; } - if (!np_get_nickname(netplay, new_fd)) + if (!netplay_get_nickname(netplay, new_fd)) { RARCH_ERR("Failed to get nickname from client.\n"); socket_close(new_fd); return; } - if (!np_send_nickname(netplay, new_fd)) + if (!netplay_send_nickname(netplay, new_fd)) { RARCH_ERR("Failed to send nickname to client.\n"); socket_close(new_fd); return; } - header = np_bsv_header_generate(&header_size, - np_impl_magic()); + header = netplay_bsv_header_generate(&header_size, + netplay_impl_magic()); if (!header) { @@ -118,7 +118,7 @@ static void netplay_spectate_pre_frame(netplay_t *netplay) netplay->spectate.fds[idx] = new_fd; #ifndef HAVE_SOCKET_LEGACY - np_log_connection(&their_addr, idx, netplay->other_nick); + netplay_log_connection(&their_addr, idx, netplay->other_nick); #endif } @@ -167,7 +167,7 @@ static bool netplay_spectate_info_cb(netplay_t *netplay, unsigned frames) unsigned i; if(netplay_is_server(netplay)) { - if(!np_get_info(netplay)) + if(!netplay_get_info(netplay)) return false; } From 597102e863a07aa19713ecc1a9a7b049549171a7 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 May 2016 12:15:53 +0200 Subject: [PATCH 453/498] Remove __ARM_ARCH__ ifdefs --- libretro-common/features/features_cpu.c | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/libretro-common/features/features_cpu.c b/libretro-common/features/features_cpu.c index 185de2932c..c85271f5e0 100644 --- a/libretro-common/features/features_cpu.c +++ b/libretro-common/features/features_cpu.c @@ -288,7 +288,6 @@ static void arm_enable_runfast_mode(void) #if defined(__linux__) -#ifdef __ARM_ARCH__ /* Extract the content of a the first occurrence of a given field in * the content of /proc/cpuinfo and return it as a heap-allocated * string that must be freed by the caller. @@ -376,7 +375,6 @@ static int has_list_item(const char* list, const char* item) } return 0; } -#endif typedef struct { @@ -737,8 +735,8 @@ uint64_t cpu_features_get(void) } #elif defined(__linux__) - static bool cpu_inited_once = false; - static uint64_t g_cpuFeatures; + static bool cpu_inited_once = false; + static uint64_t g_cpuFeatures = 0; enum { @@ -753,11 +751,8 @@ uint64_t cpu_features_get(void) ssize_t length; void *buf = NULL; - g_cpuFeatures = 0; - if (filestream_read_file("/proc/cpuinfo", &buf, &length) == 1) { -#ifdef __ARM_ARCH__ /* Extract architecture from the "CPU Architecture" field. * The list is well-known, unlike the the output of * the 'Processor' field which can vary greatly. @@ -838,7 +833,6 @@ uint64_t cpu_features_get(void) g_cpuFeatures |= CPU_ARM_FEATURE_NEON | CPU_ARM_FEATURE_VFPv3; free(cpu_features); } -#endif /* __ARM_ARCH__ */ if (buf) free(buf); From 3bdfbb63180a793ac309c362634b753d7d4f0efe Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 May 2016 12:22:32 +0200 Subject: [PATCH 454/498] features_cpu.c - cleanups --- libretro-common/features/features_cpu.c | 28 +++++++++++++------------ 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/libretro-common/features/features_cpu.c b/libretro-common/features/features_cpu.c index c85271f5e0..3977bbf5b4 100644 --- a/libretro-common/features/features_cpu.c +++ b/libretro-common/features/features_cpu.c @@ -286,7 +286,7 @@ static void arm_enable_runfast_mode(void) } #endif -#if defined(__linux__) +#if defined(__linux__) && !defined(CPU_X86) /* Extract the content of a the first occurrence of a given field in * the content of /proc/cpuinfo and return it as a heap-allocated @@ -753,6 +753,7 @@ uint64_t cpu_features_get(void) if (filestream_read_file("/proc/cpuinfo", &buf, &length) == 1) { + char* cpu_features = NULL; /* Extract architecture from the "CPU Architecture" field. * The list is well-known, unlike the the output of * the 'Processor' field which can vary greatly. @@ -765,9 +766,9 @@ uint64_t cpu_features_get(void) if (cpu_arch) { - char* end; - int has_armv7 = 0; - /* read the initial decimal number, ignore the rest */ + char* end = NULL; + int has_armv7 = 0; + /* Read the initial decimal number, ignore the rest */ long arch_number = strtol(cpu_arch, &end, 10); /* Here we assume that ARMv8 will be upwards compatible with v7 @@ -792,13 +793,11 @@ uint64_t cpu_features_get(void) char *cpu_proc = extract_cpuinfo_field(buf, length, "Processor"); - if (cpu_proc != NULL) + if (cpu_proc) { + /* CPU processor and architecture mismatch. */ if (has_list_item(cpu_proc, "(v6l)")) - { - /* CPU processor and architecture mismatch. */ has_armv7 = 0; - } free(cpu_proc); } } @@ -810,17 +809,15 @@ uint64_t cpu_features_get(void) if (arch_number >= 6) g_cpuFeatures |= CPU_ARM_FEATURE_LDREX_STREX; - free(cpu_arch); } /* Extract the list of CPU features from 'Features' field */ - char* cpu_features = extract_cpuinfo_field(buf, length, "Features"); + cpu_features = extract_cpuinfo_field(buf, length, "Features"); if (cpu_features) { if (has_list_item(cpu_features, "vfpv3")) g_cpuFeatures |= CPU_ARM_FEATURE_VFPv3; - else if (has_list_item(cpu_features, "vfpv3d16")) g_cpuFeatures |= CPU_ARM_FEATURE_VFPv3; @@ -831,12 +828,17 @@ uint64_t cpu_features_get(void) */ if (has_list_item(cpu_features, "neon")) g_cpuFeatures |= CPU_ARM_FEATURE_NEON | CPU_ARM_FEATURE_VFPv3; - free(cpu_features); } + if (cpu_features) + free(cpu_features); + if (cpu_arch) + free(cpu_arch); if (buf) free(buf); - buf = NULL; + cpu_features = NULL; + cpu_arch = NULL; + buf = NULL; } cpu_inited_once = true; } From be506c6d64d6cadc2c945a9057346e339502353d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Thu, 12 May 2016 13:13:14 +0200 Subject: [PATCH 455/498] (task_image.c) Cleanups --- tasks/task_image.c | 76 ++++++++++++++++++++++++++++++---------------- 1 file changed, 49 insertions(+), 27 deletions(-) diff --git a/tasks/task_image.c b/tasks/task_image.c index 63fdaf6461..d5fe2c0bea 100644 --- a/tasks/task_image.c +++ b/tasks/task_image.c @@ -99,23 +99,22 @@ static int cb_nbio_default(void *data, size_t len) return 0; } -static int rarch_main_data_image_process( - nbio_handle_t *nbio, - unsigned *width, - unsigned *height) +static int image_transfer_process( + void *data, + enum image_type_enum type, + uint32_t **buf, + unsigned *width, unsigned *height) { - int retval = 0; - - switch (nbio->image_type) + switch (type) { case IMAGE_TYPE_PNG: #ifdef HAVE_RPNG - if (!rpng_is_valid((rpng_t*)nbio->image.handle)) + if (!rpng_is_valid((rpng_t*)data)) return IMAGE_PROCESS_ERROR; - retval = rpng_nbio_load_image_argb_process( - (rpng_t*)nbio->image.handle, - &nbio->image.ti.pixels, + return rpng_nbio_load_image_argb_process( + (rpng_t*)data, + buf, width, height); #endif break; @@ -125,6 +124,41 @@ static int rarch_main_data_image_process( break; } + return 0; +} + +static bool image_transfer_iterate(void *data, enum image_type_enum type) +{ + switch (type) + { + case IMAGE_TYPE_PNG: +#ifdef HAVE_RPNG + if (!rpng_nbio_load_image_argb_iterate((rpng_t*)data)) + return false; +#endif + break; + case IMAGE_TYPE_JPEG: +#ifdef HAVE_RJPEG +#endif + break; + } + + return true; +} + +static int rarch_main_data_image_process( + nbio_handle_t *nbio, + unsigned *width, + unsigned *height) +{ + int retval = image_transfer_process( + (rpng_t*)nbio->image.handle, + nbio->image_type, + &nbio->image.ti.pixels, width, height); + + if (retval == IMAGE_PROCESS_ERROR) + return IMAGE_PROCESS_ERROR; + nbio->image.ti.width = *width; nbio->image.ti.height = *height; @@ -191,40 +225,28 @@ static int rarch_main_data_image_iterate_process_transfer(nbio_handle_t *nbio) return -1; } + static int rarch_main_data_image_iterate_transfer(nbio_handle_t *nbio) { unsigned i; if (!nbio) - return -1; + goto error; if (nbio->image.is_finished) return 0; for (i = 0; i < nbio->image.pos_increment; i++) { - switch (nbio->image_type) - { - case IMAGE_TYPE_PNG: -#ifdef HAVE_RPNG - if (!rpng_nbio_load_image_argb_iterate((rpng_t*)nbio->image.handle)) - goto error; -#endif - break; - case IMAGE_TYPE_JPEG: -#ifdef HAVE_RJPEG -#endif - break; - } + if (!image_transfer_iterate(nbio->image.handle, nbio->image_type)) + goto error; } nbio->image.frame_count++; return 0; -#ifdef HAVE_RPNG error: return -1; -#endif } static void rarch_task_image_load_free_internal(nbio_handle_t *nbio) From 031686f27a6cefb16f7df8c9eec7b54b0e45787f Mon Sep 17 00:00:00 2001 From: Andre Leiradella Date: Thu, 12 May 2016 22:03:18 -0300 Subject: [PATCH 456/498] added RETRO_ENVIRONMENT_SET_SUPPORT_ACHIEVEMENTS; cheevos now work with mmaps --- cheevos.c | 225 +++++++++++++++++++++++++++-------------------------- cheevos.h | 2 + dynamic.c | 9 +++ libretro.h | 9 +++ 4 files changed, 135 insertions(+), 110 deletions(-) diff --git a/cheevos.c b/cheevos.c index 9eba3219d2..0335de628a 100644 --- a/cheevos.c +++ b/cheevos.c @@ -24,6 +24,7 @@ #include "cheevos.h" #include "dynamic.h" #include "libretro.h" +#include "system.h" #include "network/net_http_special.h" #include "configuration.h" #include "performance_counters.h" @@ -44,6 +45,9 @@ /* Define this macro to log URLs (will log the user token). */ #undef CHEEVOS_LOG_URLS +/* Define this macro to dump all cheevos' addresses. */ +#undef CHEEVOS_DUMP_ADDRS + #define JSON_KEY_GAMEID 0xb4960eecU #define JSON_KEY_ACHIEVEMENTS 0x69749ae1U #define JSON_KEY_ID 0x005973f2U @@ -62,6 +66,7 @@ enum { CHEEVOS_CONSOLE_GAMEBOY = 4, + CHEEVOS_CONSOLE_GAMEBOY_ADVANCED = 5, CHEEVOS_CONSOLE_GAMEBOY_COLOR = 6, }; @@ -142,7 +147,7 @@ typedef struct { unsigned size; unsigned type; - unsigned bank_id; + int bank_id; unsigned value; unsigned previous; } cheevos_var_t; @@ -218,7 +223,7 @@ typedef struct typedef struct { int in_cheevos; - int console_id; + int is_console_id; unsigned core_count; unsigned unofficial_count; @@ -236,19 +241,23 @@ typedef struct typedef struct { - int loaded; - int console_id; + int loaded; + int console_id; + bool core_supports; cheevoset_t core; cheevoset_t unofficial; char token[32]; + + retro_ctx_memory_info_t meminfo[4]; } cheevos_locals_t; static cheevos_locals_t cheevos_locals = { 0, 0, + true, {NULL, 0}, {NULL, 0}, {0}, @@ -620,6 +629,69 @@ static void cheevos_parse_var(cheevos_var_t *var, const char **memaddr) var->value = strtol(str, &end, base); *memaddr = end; + + if ( var->type == CHEEVOS_VAR_TYPE_ADDRESS + || var->type == CHEEVOS_VAR_TYPE_DELTA_MEM) + { + rarch_system_info_t *system; + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + + var->bank_id = -1; + + if (system->mmaps.num_descriptors != 0) + { + const struct retro_memory_descriptor *desc; + const struct retro_memory_descriptor *end; + +#if 0 + if (cheevos_locals.console_id == CHEEVOS_CONSOLE_GAMEBOY_ADVANCED) + { + /* Patch the address to correctly map it to the mmaps */ + if (var->value < 0x8000) + { + /* Internal RAM */ + var->value += 0x3000000; + } + else + { + /* Work RAM */ + var->value += 0x2000000 - 0x8000; + } + } +#endif + + desc = system->mmaps.descriptors; + end = desc + system->mmaps.num_descriptors; + + for (; desc < end; desc++) + { + if (var->value >= desc->start && var->value < (desc->start + desc->len)) + { + var->bank_id = desc - system->mmaps.descriptors; + var->value = var->value - desc->start + desc->offset; + break; + } + } + } + else + { + unsigned i; + + for (i = 0; i < sizeof(cheevos_locals.meminfo) / sizeof(cheevos_locals.meminfo[0]); i++) + { + if (var->value < cheevos_locals.meminfo[i].size) + { + var->bank_id = i; + break; + } + + var->value -= cheevos_locals.meminfo[i].size; + } + } +#ifdef CHEEVOS_DUMP_ADDRS + RARCH_LOG("CHEEVOS var %03d:%08X\n", var->bank_id + 1, var->value); +#endif + } } static void cheevos_parse_cond(cheevos_cond_t *cond, const char **memaddr) @@ -818,7 +890,7 @@ static int cheevos_read__json_key( void *userdata, if (hash == JSON_KEY_ACHIEVEMENTS) ud->in_cheevos = 1; else if (hash == JSON_KEY_CONSOLE_ID) - ud->console_id = 0; + ud->is_console_id = 1; else if (ud->in_cheevos) { switch ( hash ) @@ -883,8 +955,11 @@ static int cheevos_read__json_number(void *userdata, ud->field->string = number; ud->field->length = length; } - else if (ud->console_id == 0) - ud->console_id = strtol(number, NULL, 10); + else if (ud->is_console_id) + { + cheevos_locals.console_id = strtol(number, NULL, 10); + ud->is_console_id = 0; + } return 0; } @@ -963,7 +1038,7 @@ static int cheevos_parse(const char *json) /* Load the achievements. */ ud.in_cheevos = 0; - ud.console_id = -1; + ud.is_console_id = 0; ud.field = NULL; ud.core_count = 0; ud.unofficial_count = 0; @@ -974,7 +1049,6 @@ static int cheevos_parse(const char *json) return -1; } - cheevos_locals.console_id = ud.console_id; return 0; } @@ -982,63 +1056,23 @@ static int cheevos_parse(const char *json) Test all the achievements (call once per frame). *****************************************************************************/ -static const uint8_t *cheevos_get_memory(unsigned offset) +static const uint8_t *cheevos_get_memory(const cheevos_var_t *var) { - retro_ctx_memory_info_t mem_info; - uint8_t *memory = NULL; + if (var->bank_id >= 0) + { + rarch_system_info_t *system; + runloop_ctl(RUNLOOP_CTL_SYSTEM_INFO_GET, &system); + + if (system->mmaps.num_descriptors != 0) + { + return (uint8_t *)system->mmaps.descriptors[var->bank_id].ptr + var->value; + } + else + { + return (uint8_t *)cheevos_locals.meminfo[var->bank_id].data + var->value; + } + } - mem_info.id = RETRO_MEMORY_SYSTEM_RAM; - - core_get_memory(&mem_info); - - if (offset < mem_info.size) - { - memory = (uint8_t*)mem_info.data; - return memory + offset; - } - - offset -= mem_info.size; - - mem_info.data = NULL; - mem_info.size = 0; - mem_info.id = RETRO_MEMORY_SAVE_RAM; - - core_get_memory(&mem_info); - - if (offset < mem_info.size) - { - memory = (uint8_t*)mem_info.data; - return memory + offset; - } - - offset -= mem_info.size; - - mem_info.data = NULL; - mem_info.size = 0; - mem_info.id = RETRO_MEMORY_VIDEO_RAM; - - core_get_memory(&mem_info); - - if (offset < mem_info.size) - { - memory = (uint8_t*)mem_info.data; - return memory + offset; - } - - offset -= mem_info.size; - - mem_info.data = NULL; - mem_info.size = 0; - mem_info.id = RETRO_MEMORY_RTC; - - core_get_memory(&mem_info); - - if (offset < mem_info.size) - { - memory = (uint8_t*)mem_info.data; - return memory + offset; - } - return NULL; } @@ -1055,7 +1089,7 @@ static unsigned cheevos_get_var_value(cheevos_var_t *var) || var->type == CHEEVOS_VAR_TYPE_DELTA_MEM) { /* TODO Check with Scott if the bank id is needed */ - memory = cheevos_get_memory(var->value); + memory = cheevos_get_memory(var); if (memory) { @@ -1396,7 +1430,7 @@ static void cheevos_unlocker(void *payload) request[sizeof(request) - 1] = 0; #ifdef CHEEVOS_LOG_URLS - RARCH_LOG("CHEEVOS url to award a cheevo: %s\n", request); + RARCH_LOG("CHEEVOS url to award the cheevo: %s\n", request); #endif if (!cheevos_http_get(&result, NULL, request, NULL)) @@ -1970,8 +2004,6 @@ static unsigned cheevos_find_game_id_nes( bool cheevos_load(const void *data) { - retro_ctx_memory_info_t mem_info; - static const uint32_t genesis_exts[] = { 0x0b888feeU, /* mdx */ @@ -2008,7 +2040,6 @@ bool cheevos_load(const void *data) {cheevos_find_game_id_generic, "Generic (plain content)", NULL}, }; - size_t memory; struct retro_system_info sysinfo; unsigned i; const char *json = NULL; @@ -2019,52 +2050,21 @@ bool cheevos_load(const void *data) cheevos_locals.loaded = 0; - /* Just return OK if cheevos are disabled. */ - if (!settings->cheevos.enable) + /* Just return OK if cheevos are disabled, the core doesn't support cheevos, or info is NULL. */ + if (!settings->cheevos.enable || !cheevos_locals.core_supports || !info) return true; - /* Also return OK if there's no content. */ - if (!info) - return true; + cheevos_locals.meminfo[0].id = RETRO_MEMORY_SYSTEM_RAM; + core_get_memory(&cheevos_locals.meminfo[0]); - mem_info.data = NULL; - mem_info.size = 0; - mem_info.id = RETRO_MEMORY_SYSTEM_RAM; + cheevos_locals.meminfo[1].id = RETRO_MEMORY_SAVE_RAM; + core_get_memory(&cheevos_locals.meminfo[1]); - core_get_memory(&mem_info); - - memory = mem_info.size; + cheevos_locals.meminfo[2].id = RETRO_MEMORY_VIDEO_RAM; + core_get_memory(&cheevos_locals.meminfo[2]); - mem_info.data = NULL; - mem_info.size = 0; - mem_info.id = RETRO_MEMORY_VIDEO_RAM; - - core_get_memory(&mem_info); - - memory += mem_info.size; - - mem_info.data = NULL; - mem_info.size = 0; - mem_info.id = RETRO_MEMORY_RTC; - - core_get_memory(&mem_info); - - memory += mem_info.size; - - mem_info.data = NULL; - mem_info.size = 0; - mem_info.id = RETRO_MEMORY_SAVE_RAM; - - core_get_memory(&mem_info); - - memory += mem_info.size; - - if (!memory) - { - runloop_msg_queue_push("This core doesn't support achievements", 0, 5 * 60, false); - RARCH_ERR("This core doesn't support achievements\n"); - return false; - } + cheevos_locals.meminfo[3].id = RETRO_MEMORY_RTC; + core_get_memory(&cheevos_locals.meminfo[3]); /* The the supported extensions as a hint to what method we should use. */ @@ -2306,3 +2306,8 @@ bool cheevos_set_cheats(void) return true; } + +void cheevos_set_support_cheevos(bool state) +{ + cheevos_locals.core_supports = state; +} diff --git a/cheevos.h b/cheevos.h index 8e75ed8520..02f2df55ac 100644 --- a/cheevos.h +++ b/cheevos.h @@ -42,4 +42,6 @@ bool cheevos_test(void); bool cheevos_set_cheats(void); +void cheevos_set_support_cheevos(bool state); + #endif /* __RARCH_CHEEVOS_H */ diff --git a/dynamic.c b/dynamic.c index fc800b9d06..a435df35c0 100644 --- a/dynamic.c +++ b/dynamic.c @@ -45,6 +45,7 @@ #include "cores/internal_cores.h" #include "frontend/frontend_driver.h" #include "content.h" +#include "cheevos.h" #include "retroarch.h" #include "configuration.h" #include "general.h" @@ -1428,6 +1429,14 @@ 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: + { + bool state = *(const bool*)data; + RARCH_LOG("Environ SET_SUPPORT_ACHIEVEMENTS: %s.\n", state ? "yes" : "no"); + cheevos_set_support_cheevos(state); + break; + } /* Private extensions for internal use, not part of libretro API. */ /* None yet. */ diff --git a/libretro.h b/libretro.h index 3d2b2581e8..2959e14501 100644 --- a/libretro.h +++ b/libretro.h @@ -946,6 +946,15 @@ struct retro_hw_render_interface * the contents of the HW_RENDER_INTERFACE are invalidated. */ +#define RETRO_ENVIRONMENT_SET_SUPPORT_ACHIEVEMENTS (42 | RETRO_ENVIRONMENT_EXPERIMENTAL) + /* const bool * -- + * If true, the libretro implementation supports achievements + * either via memory descriptors set with RETRO_ENVIRONMENT_SET_MEMORY_MAPS + * or via retro_get_memory_data/retro_get_memory_size. + * + * This must be called before the first call to retro_run. + */ + #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. */ From f20b96916581a1435961349118baf8b0c0803217 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 May 2016 04:02:08 +0200 Subject: [PATCH 457/498] (libretro-common) features_cpu - reimplement ARM cpu features code --- libretro-common/features/features_cpu.c | 259 +++++++----------------- 1 file changed, 70 insertions(+), 189 deletions(-) diff --git a/libretro-common/features/features_cpu.c b/libretro-common/features/features_cpu.c index 3977bbf5b4..f3671e92d8 100644 --- a/libretro-common/features/features_cpu.c +++ b/libretro-common/features/features_cpu.c @@ -287,100 +287,76 @@ static void arm_enable_runfast_mode(void) #endif #if defined(__linux__) && !defined(CPU_X86) - -/* Extract the content of a the first occurrence of a given field in - * the content of /proc/cpuinfo and return it as a heap-allocated - * string that must be freed by the caller. - * - * Return NULL if not found - */ -static char *extract_cpuinfo_field(char* buffer, - ssize_t length, const char* field) +static unsigned char check_arm_cpu_feature(const char* feature) { - int len; - const char *q; - int fieldlen = strlen(field); - char* bufend = buffer + length; - char* result = NULL; - /* Look for first field occurrence, - * and ensures it starts the line. */ - const char *p = buffer; + unsigned char status = 0; + FILE *fp = fopen("/proc/cpuinfo", "r"); - for (;;) + if (fp) { - p = memmem(p, bufend-p, field, fieldlen); - if (p == NULL) - return result; + char line[1024]; + + while (fgets(line , sizeof(line) , fp) != NULL) + { + if (strncmp(line, "Features\t: ", 11)) + continue; + + if (strstr(line + 11, feature) != NULL) + status = 1; - if (p == buffer || p[-1] == '\n') break; + } - p += fieldlen; + fclose(fp); } - - /* Skip to the first column followed by a space */ - p += fieldlen; - p = memchr(p, ':', bufend-p); - if (p == NULL || p[1] != ' ') - return result; - - /* Find the end of the line */ - p += 2; - q = memchr(p, '\n', bufend-p); - if (q == NULL) - q = bufend; - - /* Copy the line into a heap-allocated buffer */ - len = q-p; - result = malloc(len+1); - if (result == NULL) - return result; - - memcpy(result, p, len); - result[len] = '\0'; - - return result; + return status; } -/* Checks that a space-separated list of items - * contains one given 'item'. - * Returns 1 if found, 0 otherwise. - */ -static int has_list_item(const char* list, const char* item) +static unsigned char get_arm_cpu_implementer(void) { - const char* p = list; - int itemlen = strlen(item); + unsigned char implementer = 0; + FILE *fp = fopen("/proc/cpuinfo", "r"); - if (list == NULL) - return 0; + if (fp) + { + char line[1024]; - while (*p) - { - const char* q; + while (fgets(line , sizeof(line) , fp) != NULL) + { + if (strncmp(line, "CPU implementer\t: ", 18)) + continue; - /* skip spaces */ - while (*p == ' ' || *p == '\t') - p++; + sscanf(line+18, "0x%02hhx", &implementer); - /* find end of current list item */ - q = p; - while (*q && *q != ' ' && *q != '\t') - q++; - - if (itemlen == q-p && !memcmp(p, item, itemlen)) - return 1; - - /* skip to next item */ - p = q; - } - return 0; + break; + } + fclose(fp); + } + return implementer; } -typedef struct +static unsigned short get_arm_cpu_part(void) { - uint32_t mask; -} CpuList; + unsigned short part = 0; + FILE *fp = fopen("/proc/cpuinfo", "r"); + if (fp) + { + char line[1024]; + + while (fgets(line , sizeof(line) , fp) != NULL) + { + if (strncmp(line, "CPU part\t: ", 11)) + continue; + + sscanf(line+11, "0x%03hx", &part); + + break; + } + fclose(fp); + } + return part; +} #if !defined(_SC_NPROCESSORS_ONLN) /* Parse an decimal integer starting from 'input', but not going further @@ -734,118 +710,7 @@ uint64_t cpu_features_get(void) cpu |= RETRO_SIMD_MMXEXT; } #elif defined(__linux__) - - static bool cpu_inited_once = false; - static uint64_t g_cpuFeatures = 0; - - enum - { - CPU_ARM_FEATURE_ARMv7 = (1 << 0), - CPU_ARM_FEATURE_VFPv3 = (1 << 1), - CPU_ARM_FEATURE_NEON = (1 << 2), - CPU_ARM_FEATURE_LDREX_STREX = (1 << 3) - }; - - if (!cpu_inited_once) - { - ssize_t length; - void *buf = NULL; - - if (filestream_read_file("/proc/cpuinfo", &buf, &length) == 1) - { - char* cpu_features = NULL; - /* Extract architecture from the "CPU Architecture" field. - * The list is well-known, unlike the the output of - * the 'Processor' field which can vary greatly. - * - * See the definition of the 'proc_arch' array in - * $KERNEL/arch/arm/kernel/setup.c and the 'c_show' function in - * same file. - */ - char* cpu_arch = extract_cpuinfo_field(buf, length, "CPU architecture"); - - if (cpu_arch) - { - char* end = NULL; - int has_armv7 = 0; - /* Read the initial decimal number, ignore the rest */ - long arch_number = strtol(cpu_arch, &end, 10); - - /* Here we assume that ARMv8 will be upwards compatible with v7 - * in the future. Unfortunately, there is no 'Features' field to - * indicate that Thumb-2 is supported. - */ - if (end > cpu_arch && arch_number >= 7) - has_armv7 = 1; - - /* Unfortunately, it seems that certain ARMv6-based CPUs - * report an incorrect architecture number of 7! - * - * See http://code.google.com/p/android/issues/detail?id=10812 - * - * We try to correct this by looking at the 'elf_format' - * field reported by the 'Processor' field, which is of the - * form of "(v7l)" for an ARMv7-based CPU, and "(v6l)" for - * an ARMv6-one. - */ - if (has_armv7) - { - char *cpu_proc = extract_cpuinfo_field(buf, length, - "Processor"); - - if (cpu_proc) - { - /* CPU processor and architecture mismatch. */ - if (has_list_item(cpu_proc, "(v6l)")) - has_armv7 = 0; - free(cpu_proc); - } - } - - if (has_armv7) - g_cpuFeatures |= CPU_ARM_FEATURE_ARMv7; - - /* The LDREX / STREX instructions are available from ARMv6 */ - if (arch_number >= 6) - g_cpuFeatures |= CPU_ARM_FEATURE_LDREX_STREX; - - } - - /* Extract the list of CPU features from 'Features' field */ - cpu_features = extract_cpuinfo_field(buf, length, "Features"); - - if (cpu_features) - { - if (has_list_item(cpu_features, "vfpv3")) - g_cpuFeatures |= CPU_ARM_FEATURE_VFPv3; - else if (has_list_item(cpu_features, "vfpv3d16")) - g_cpuFeatures |= CPU_ARM_FEATURE_VFPv3; - - /* Note: Certain kernels only report NEON but not VFPv3 - * in their features list. However, ARM mandates - * that if NEON is implemented, so must be VFPv3 - * so always set the flag. - */ - if (has_list_item(cpu_features, "neon")) - g_cpuFeatures |= CPU_ARM_FEATURE_NEON | CPU_ARM_FEATURE_VFPv3; - } - - if (cpu_features) - free(cpu_features); - if (cpu_arch) - free(cpu_arch); - if (buf) - free(buf); - cpu_features = NULL; - cpu_arch = NULL; - buf = NULL; - } - cpu_inited_once = true; - } - - cpu_flags = g_cpuFeatures; - - if (cpu_flags & CPU_ARM_FEATURE_NEON) + if (check_arm_cpu_feature("neon")) { cpu |= RETRO_SIMD_NEON; #ifdef __ARM_NEON__ @@ -853,9 +718,25 @@ uint64_t cpu_features_get(void) #endif } - if (cpu_flags & CPU_ARM_FEATURE_VFPv3) + if (check_arm_cpu_feature("vfpv3")) cpu |= RETRO_SIMD_VFPV3; + if (check_arm_cpu_feature("vfpv4")) + cpu |= RETRO_SIMD_VFPV4; + +#if 0 + check_arm_cpu_feature("swp"); + check_arm_cpu_feature("half"); + check_arm_cpu_feature("thumb"); + check_arm_cpu_feature("fastmult"); + check_arm_cpu_feature("vfp"); + check_arm_cpu_feature("edsp"); + check_arm_cpu_feature("thumbee"); + check_arm_cpu_feature("tls"); + check_arm_cpu_feature("idiva"); + check_arm_cpu_feature("idivt"); +#endif + #elif defined(__ARM_NEON__) cpu |= RETRO_SIMD_NEON; arm_enable_runfast_mode(); From d040263a833645aa8f856185c8c5f2c2a4af6a42 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 May 2016 04:28:16 +0200 Subject: [PATCH 458/498] image_transfer_new/image_transfer_free --- tasks/task_image.c | 71 ++++++++++++++++++++++++++++++---------------- 1 file changed, 46 insertions(+), 25 deletions(-) diff --git a/tasks/task_image.c b/tasks/task_image.c index d5fe2c0bea..220848e3f9 100644 --- a/tasks/task_image.c +++ b/tasks/task_image.c @@ -99,6 +99,40 @@ static int cb_nbio_default(void *data, size_t len) return 0; } +void image_transfer_free(void *data, enum image_type_enum type) +{ + switch (type) + { + case IMAGE_TYPE_PNG: +#ifdef HAVE_RPNG + rpng_nbio_load_image_free((rpng_t*)data); +#endif + break; + case IMAGE_TYPE_JPEG: +#ifdef HAVE_RJPEG +#endif + break; + } +} + +void *image_transfer_new(enum image_type_enum type) +{ + switch (type) + { + case IMAGE_TYPE_PNG: +#ifdef HAVE_RPNG + return rpng_alloc(); +#endif + break; + case IMAGE_TYPE_JPEG: +#ifdef HAVE_RJPEG +#endif + break; + } + + return NULL; +} + static int image_transfer_process( void *data, enum image_type_enum type, @@ -249,22 +283,12 @@ error: return -1; } + static void rarch_task_image_load_free_internal(nbio_handle_t *nbio) { nbio_image_handle_t *image = nbio ? &nbio->image : NULL; - switch (nbio->image_type) - { - case IMAGE_TYPE_PNG: -#ifdef HAVE_RPNG - rpng_nbio_load_image_free((rpng_t*)image->handle); -#endif - break; - case IMAGE_TYPE_JPEG: -#ifdef HAVE_RJPEG -#endif - break; - } + image_transfer_free(image->handle, nbio->image_type); image->handle = NULL; image->cb = NULL; @@ -324,29 +348,26 @@ error: return -1; } + static int cb_nbio_image_menu_thumbnail(void *data, size_t len) { nbio_handle_t *nbio = (nbio_handle_t*)data; if (!nbio || !data) return -1; - - switch (nbio->image_type) - { - case IMAGE_TYPE_PNG: -#ifdef HAVE_RPNG - nbio->image.handle = rpng_alloc(); -#endif - break; - case IMAGE_TYPE_JPEG: -#ifdef HAVE_RJPEG -#endif - break; - } + + nbio->image.handle = image_transfer_new(nbio->image_type); + + if (!nbio->image.handle) + goto error; nbio->image.cb = &cb_image_menu_thumbnail; return cb_nbio_generic(nbio, &len); + +error: + nbio->image.handle = 0; + return -1; } bool rarch_task_image_load_handler(retro_task_t *task) From 6daf6e227092d204885fa9d21ba4d2a4e216f5c2 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 May 2016 04:33:11 +0200 Subject: [PATCH 459/498] Cleanups --- tasks/task_image.c | 69 +++++++++++++++++++++++++++------------------- 1 file changed, 41 insertions(+), 28 deletions(-) diff --git a/tasks/task_image.c b/tasks/task_image.c index 220848e3f9..5c7144fc9a 100644 --- a/tasks/task_image.c +++ b/tasks/task_image.c @@ -133,6 +133,44 @@ void *image_transfer_new(enum image_type_enum type) return NULL; } +bool image_transfer_start(void *data, enum image_type_enum type) +{ + switch (type) + { + case IMAGE_TYPE_PNG: +#ifdef HAVE_RPNG + if (!rpng_nbio_load_image_argb_start((rpng_t*)data)) + return false; +#endif + break; + case IMAGE_TYPE_JPEG: +#ifdef HAVE_RJPEG +#endif + break; + } + + return true; +} + +void image_transfer_set_buffer_ptr( + void *data, + enum image_type_enum type, + void *ptr) +{ + switch (type) + { + case IMAGE_TYPE_PNG: +#ifdef HAVE_RPNG + rpng_set_buf_ptr((rpng_t*)data, (uint8_t*)ptr); +#endif + break; + case IMAGE_TYPE_JPEG: +#ifdef HAVE_RJPEG +#endif + break; + } +} + static int image_transfer_process( void *data, enum image_type_enum type, @@ -259,7 +297,6 @@ static int rarch_main_data_image_iterate_process_transfer(nbio_handle_t *nbio) return -1; } - static int rarch_main_data_image_iterate_transfer(nbio_handle_t *nbio) { unsigned i; @@ -283,7 +320,6 @@ error: return -1; } - static void rarch_task_image_load_free_internal(nbio_handle_t *nbio) { nbio_image_handle_t *image = nbio ? &nbio->image : NULL; @@ -307,35 +343,13 @@ static int cb_nbio_generic(nbio_handle_t *nbio, size_t *len) if (!ptr) goto error; - switch (nbio->image_type) - { - case IMAGE_TYPE_PNG: -#ifdef HAVE_RPNG - rpng_set_buf_ptr((rpng_t*)nbio->image.handle, (uint8_t*)ptr); -#endif - break; - case IMAGE_TYPE_JPEG: -#ifdef HAVE_RJPEG -#endif - break; - } + image_transfer_set_buffer_ptr(nbio->image.handle, nbio->image_type, ptr); nbio->image.pos_increment = (*len / 2) ? (*len / 2) : 1; nbio->image.processing_pos_increment = (*len / 4) ? (*len / 4) : 1; - switch (nbio->image_type) - { - case IMAGE_TYPE_PNG: -#ifdef HAVE_RPNG - if (!rpng_nbio_load_image_argb_start((rpng_t*)nbio->image.handle)) - goto error; -#endif - break; - case IMAGE_TYPE_JPEG: -#ifdef HAVE_RJPEG -#endif - break; - } + if (!image_transfer_start(nbio->image.handle, nbio->image_type)) + goto error; nbio->image.is_blocking = false; nbio->image.is_finished = false; @@ -348,7 +362,6 @@ error: return -1; } - static int cb_nbio_image_menu_thumbnail(void *data, size_t len) { nbio_handle_t *nbio = (nbio_handle_t*)data; From 13f49e1d9aab852fd2858aec5fc15870e4eb1c8f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 May 2016 04:38:21 +0200 Subject: [PATCH 460/498] Split up image transfer code to separate file --- Makefile.common | 3 +- griffin/griffin.c | 1 + libretro-common/formats/image_transfer.c | 131 +++++++++++++++++++++++ libretro-common/include/formats/image.h | 27 +++++ tasks/task_image.c | 127 +--------------------- tasks/tasks_internal.h | 6 -- 6 files changed, 162 insertions(+), 133 deletions(-) create mode 100644 libretro-common/formats/image_transfer.c diff --git a/Makefile.common b/Makefile.common index b5e54fbec6..9050d0f349 100644 --- a/Makefile.common +++ b/Makefile.common @@ -911,7 +911,8 @@ ifeq ($(HAVE_RJPEG), 1) endif OBJ += libretro-common/formats/bmp/rbmp_encode.o \ - libretro-common/formats/json/jsonsax.o + libretro-common/formats/json/jsonsax.o \ + libretro-common/formats/image_transfer.o ifeq ($(HAVE_RTGA), 1) OBJ += libretro-common/formats/tga/rtga.o diff --git a/griffin/griffin.c b/griffin/griffin.c index ba626ee9fe..1f189425d3 100644 --- a/griffin/griffin.c +++ b/griffin/griffin.c @@ -230,6 +230,7 @@ VIDEO IMAGE #include "../cores/libretro-imageviewer/image_core.c" #endif +#include "../libretro-common/formats/image_transfer.c" #ifdef HAVE_RPNG #include "../libretro-common/formats/png/rpng.c" #include "../libretro-common/formats/png/rpng_encode.c" diff --git a/libretro-common/formats/image_transfer.c b/libretro-common/formats/image_transfer.c new file mode 100644 index 0000000000..5bc554f0a7 --- /dev/null +++ b/libretro-common/formats/image_transfer.c @@ -0,0 +1,131 @@ +#include +#include +#include + +#ifdef HAVE_RPNG +#include +#endif +#ifdef HAVE_RJPEG +#include +#endif + +#include + +void image_transfer_free(void *data, enum image_type_enum type) +{ + switch (type) + { + case IMAGE_TYPE_PNG: +#ifdef HAVE_RPNG + rpng_nbio_load_image_free((rpng_t*)data); +#endif + break; + case IMAGE_TYPE_JPEG: +#ifdef HAVE_RJPEG +#endif + break; + } +} + +void *image_transfer_new(enum image_type_enum type) +{ + switch (type) + { + case IMAGE_TYPE_PNG: +#ifdef HAVE_RPNG + return rpng_alloc(); +#endif + break; + case IMAGE_TYPE_JPEG: +#ifdef HAVE_RJPEG +#endif + break; + } + + return NULL; +} + +bool image_transfer_start(void *data, enum image_type_enum type) +{ + switch (type) + { + case IMAGE_TYPE_PNG: +#ifdef HAVE_RPNG + if (!rpng_nbio_load_image_argb_start((rpng_t*)data)) + return false; +#endif + break; + case IMAGE_TYPE_JPEG: +#ifdef HAVE_RJPEG +#endif + break; + } + + return true; +} + +void image_transfer_set_buffer_ptr( + void *data, + enum image_type_enum type, + void *ptr) +{ + switch (type) + { + case IMAGE_TYPE_PNG: +#ifdef HAVE_RPNG + rpng_set_buf_ptr((rpng_t*)data, (uint8_t*)ptr); +#endif + break; + case IMAGE_TYPE_JPEG: +#ifdef HAVE_RJPEG +#endif + break; + } +} + +int image_transfer_process( + void *data, + enum image_type_enum type, + uint32_t **buf, + unsigned *width, unsigned *height) +{ + switch (type) + { + case IMAGE_TYPE_PNG: +#ifdef HAVE_RPNG + if (!rpng_is_valid((rpng_t*)data)) + return IMAGE_PROCESS_ERROR; + + return rpng_nbio_load_image_argb_process( + (rpng_t*)data, + buf, + width, height); +#endif + break; + case IMAGE_TYPE_JPEG: +#ifdef HAVE_RJPEG +#endif + break; + } + + return 0; +} + +bool image_transfer_iterate(void *data, enum image_type_enum type) +{ + switch (type) + { + case IMAGE_TYPE_PNG: +#ifdef HAVE_RPNG + if (!rpng_nbio_load_image_argb_iterate((rpng_t*)data)) + return false; +#endif + break; + case IMAGE_TYPE_JPEG: +#ifdef HAVE_RJPEG +#endif + break; + } + + return true; +} diff --git a/libretro-common/include/formats/image.h b/libretro-common/include/formats/image.h index 3c98761b3e..9e9794ac94 100644 --- a/libretro-common/include/formats/image.h +++ b/libretro-common/include/formats/image.h @@ -40,6 +40,12 @@ struct texture_image uint32_t *pixels; }; +enum image_type_enum +{ + IMAGE_TYPE_PNG = 0, + IMAGE_TYPE_JPEG +}; + bool video_texture_image_set_color_shifts(unsigned *r_shift, unsigned *g_shift, unsigned *b_shift, unsigned *a_shift); @@ -50,6 +56,27 @@ bool video_texture_image_color_convert(unsigned r_shift, bool video_texture_image_load(struct texture_image *img, const char *path); void video_texture_image_free(struct texture_image *img); +/* Image transfer */ + +void image_transfer_free(void *data, enum image_type_enum type); + +void *image_transfer_new(enum image_type_enum type); + +bool image_transfer_start(void *data, enum image_type_enum type); + +void image_transfer_set_buffer_ptr( + void *data, + enum image_type_enum type, + void *ptr); + +int image_transfer_process( + void *data, + enum image_type_enum type, + uint32_t **buf, + unsigned *width, unsigned *height); + +bool image_transfer_iterate(void *data, enum image_type_enum type); + RETRO_END_DECLS #endif diff --git a/tasks/task_image.c b/tasks/task_image.c index 5c7144fc9a..124d0f712f 100644 --- a/tasks/task_image.c +++ b/tasks/task_image.c @@ -24,12 +24,6 @@ #include #include #include -#ifdef HAVE_RPNG -#include -#endif -#ifdef HAVE_RJPEG -#include -#endif #ifdef HAVE_MENU #include "../menu/menu_driver.h" @@ -99,132 +93,13 @@ static int cb_nbio_default(void *data, size_t len) return 0; } -void image_transfer_free(void *data, enum image_type_enum type) -{ - switch (type) - { - case IMAGE_TYPE_PNG: -#ifdef HAVE_RPNG - rpng_nbio_load_image_free((rpng_t*)data); -#endif - break; - case IMAGE_TYPE_JPEG: -#ifdef HAVE_RJPEG -#endif - break; - } -} - -void *image_transfer_new(enum image_type_enum type) -{ - switch (type) - { - case IMAGE_TYPE_PNG: -#ifdef HAVE_RPNG - return rpng_alloc(); -#endif - break; - case IMAGE_TYPE_JPEG: -#ifdef HAVE_RJPEG -#endif - break; - } - - return NULL; -} - -bool image_transfer_start(void *data, enum image_type_enum type) -{ - switch (type) - { - case IMAGE_TYPE_PNG: -#ifdef HAVE_RPNG - if (!rpng_nbio_load_image_argb_start((rpng_t*)data)) - return false; -#endif - break; - case IMAGE_TYPE_JPEG: -#ifdef HAVE_RJPEG -#endif - break; - } - - return true; -} - -void image_transfer_set_buffer_ptr( - void *data, - enum image_type_enum type, - void *ptr) -{ - switch (type) - { - case IMAGE_TYPE_PNG: -#ifdef HAVE_RPNG - rpng_set_buf_ptr((rpng_t*)data, (uint8_t*)ptr); -#endif - break; - case IMAGE_TYPE_JPEG: -#ifdef HAVE_RJPEG -#endif - break; - } -} - -static int image_transfer_process( - void *data, - enum image_type_enum type, - uint32_t **buf, - unsigned *width, unsigned *height) -{ - switch (type) - { - case IMAGE_TYPE_PNG: -#ifdef HAVE_RPNG - if (!rpng_is_valid((rpng_t*)data)) - return IMAGE_PROCESS_ERROR; - - return rpng_nbio_load_image_argb_process( - (rpng_t*)data, - buf, - width, height); -#endif - break; - case IMAGE_TYPE_JPEG: -#ifdef HAVE_RJPEG -#endif - break; - } - - return 0; -} - -static bool image_transfer_iterate(void *data, enum image_type_enum type) -{ - switch (type) - { - case IMAGE_TYPE_PNG: -#ifdef HAVE_RPNG - if (!rpng_nbio_load_image_argb_iterate((rpng_t*)data)) - return false; -#endif - break; - case IMAGE_TYPE_JPEG: -#ifdef HAVE_RJPEG -#endif - break; - } - - return true; -} - static int rarch_main_data_image_process( nbio_handle_t *nbio, unsigned *width, unsigned *height) { int retval = image_transfer_process( - (rpng_t*)nbio->image.handle, + nbio->image.handle, nbio->image_type, &nbio->image.ti.pixels, width, height); diff --git a/tasks/tasks_internal.h b/tasks/tasks_internal.h index f880dbe156..7ab3291530 100644 --- a/tasks/tasks_internal.h +++ b/tasks/tasks_internal.h @@ -40,12 +40,6 @@ enum nbio_status_enum NBIO_STATUS_TRANSFER_PARSE_FREE }; -enum image_type_enum -{ - IMAGE_TYPE_PNG = 0, - IMAGE_TYPE_JPEG -}; - #ifdef HAVE_NETWORKING typedef struct { From 4ba5ae42a6116d0fc8901c2d9bf65874751fd114 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 May 2016 04:41:46 +0200 Subject: [PATCH 461/498] Add HAVE_CHEEVOS ifdefs --- dynamic.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/dynamic.c b/dynamic.c index 260e0a9819..b9fd204516 100644 --- a/dynamic.c +++ b/dynamic.c @@ -46,7 +46,9 @@ #include "cores/internal_cores.h" #include "frontend/frontend_driver.h" #include "content.h" +#ifdef HAVE_CHEEVOS #include "cheevos.h" +#endif #include "retroarch.h" #include "configuration.h" #include "general.h" @@ -1432,12 +1434,14 @@ bool rarch_environment_cb(unsigned cmd, void *data) (const struct retro_hw_render_interface**)data); case RETRO_ENVIRONMENT_SET_SUPPORT_ACHIEVEMENTS: +#ifdef HAVE_CHEEVOS { bool state = *(const bool*)data; RARCH_LOG("Environ SET_SUPPORT_ACHIEVEMENTS: %s.\n", state ? "yes" : "no"); cheevos_set_support_cheevos(state); break; } +#endif /* Private extensions for internal use, not part of libretro API. */ /* None yet. */ From 98a403defd86aad60a9220a5fd40295b8425e1cd Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 May 2016 04:53:35 +0200 Subject: [PATCH 462/498] Don't let it fall through when trying to use certain env callbacks --- dynamic.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/dynamic.c b/dynamic.c index b9fd204516..1b53e3a1da 100644 --- a/dynamic.c +++ b/dynamic.c @@ -1127,17 +1127,14 @@ bool rarch_environment_cb(unsigned cmd, void *data) break; } - /* FIXME - PS3 audio driver needs to be fixed so that threaded - * audio works correctly (audio is already on a thread for PS3 - * audio driver so that's probably the problem) */ -#if defined(HAVE_THREADS) && !defined(__CELLOS_LV2__) case RETRO_ENVIRONMENT_SET_AUDIO_CALLBACK: +#if defined(HAVE_THREADS) && !defined(__CELLOS_LV2__) { RARCH_LOG("Environ SET_AUDIO_CALLBACK.\n"); audio_driver_set_callback(data); - break; } #endif + break; case RETRO_ENVIRONMENT_SET_FRAME_TIME_CALLBACK: { @@ -1435,17 +1432,14 @@ bool rarch_environment_cb(unsigned cmd, void *data) case RETRO_ENVIRONMENT_SET_SUPPORT_ACHIEVEMENTS: #ifdef HAVE_CHEEVOS - { - bool state = *(const bool*)data; - RARCH_LOG("Environ SET_SUPPORT_ACHIEVEMENTS: %s.\n", state ? "yes" : "no"); - cheevos_set_support_cheevos(state); - break; - } + { + bool state = *(const bool*)data; + RARCH_LOG("Environ SET_SUPPORT_ACHIEVEMENTS: %s.\n", state ? "yes" : "no"); + cheevos_set_support_cheevos(state); + } #endif + break; - /* Private extensions for internal use, not part of libretro API. */ - /* None yet. */ - /* Default */ default: RARCH_LOG("Environ UNSUPPORTED (#%u).\n", cmd); From d3df0160057c782ae38d51fc95ae3365d9e69c7a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 May 2016 08:13:21 +0200 Subject: [PATCH 463/498] (RJPEG) Add rjpeg_alloc --- libretro-common/formats/image_transfer.c | 1 + libretro-common/formats/jpeg/rjpeg.c | 14 ++++++++++++++ libretro-common/include/formats/rjpeg.h | 4 ++++ 3 files changed, 19 insertions(+) diff --git a/libretro-common/formats/image_transfer.c b/libretro-common/formats/image_transfer.c index 5bc554f0a7..d01c44b5bb 100644 --- a/libretro-common/formats/image_transfer.c +++ b/libretro-common/formats/image_transfer.c @@ -38,6 +38,7 @@ void *image_transfer_new(enum image_type_enum type) break; case IMAGE_TYPE_JPEG: #ifdef HAVE_RJPEG + return rjpeg_alloc(); #endif break; } diff --git a/libretro-common/formats/jpeg/rjpeg.c b/libretro-common/formats/jpeg/rjpeg.c index a9ca0b753f..6ae2afd3c4 100644 --- a/libretro-common/formats/jpeg/rjpeg.c +++ b/libretro-common/formats/jpeg/rjpeg.c @@ -33,6 +33,7 @@ #include #include #include +#include #include enum @@ -64,6 +65,11 @@ typedef struct int ypos; /* which pre-expansion row we're on */ } rjpeg__resample; +struct rjpeg +{ + void *empty; +}; + #ifdef _MSC_VER #define RJPEG_HAS_LROTL #endif @@ -2460,3 +2466,11 @@ bool rjpeg_image_load(uint8_t *_buf, void *data, size_t size, return true; } + +void *rjpeg_alloc(void) +{ + rjpeg_t *rjpeg = (rjpeg_t*)calloc(1, sizeof(*rjpeg)); + if (!rjpeg) + return NULL; + return rjpeg; +} diff --git a/libretro-common/include/formats/rjpeg.h b/libretro-common/include/formats/rjpeg.h index 81f61b92af..62fafb4123 100644 --- a/libretro-common/include/formats/rjpeg.h +++ b/libretro-common/include/formats/rjpeg.h @@ -32,9 +32,13 @@ RETRO_BEGIN_DECLS +typedef struct rjpeg rjpeg_t; + bool rjpeg_image_load(uint8_t *buf, void *data, size_t size, unsigned a_shift, unsigned r_shift, unsigned g_shift, unsigned b_shift); +void *rjpeg_alloc(void); + RETRO_END_DECLS #endif From 17d39fd54fd441f66bf611abc53a49ae182a71a3 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 May 2016 08:16:13 +0200 Subject: [PATCH 464/498] Add rjpeg_free --- libretro-common/formats/image_transfer.c | 7 ++++++- libretro-common/formats/jpeg/rjpeg.c | 10 +++++++++- libretro-common/include/formats/rjpeg.h | 4 +++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/libretro-common/formats/image_transfer.c b/libretro-common/formats/image_transfer.c index d01c44b5bb..ae29f8756d 100644 --- a/libretro-common/formats/image_transfer.c +++ b/libretro-common/formats/image_transfer.c @@ -22,6 +22,7 @@ void image_transfer_free(void *data, enum image_type_enum type) break; case IMAGE_TYPE_JPEG: #ifdef HAVE_RJPEG + rjpeg_free((rjpeg_t*)data); #endif break; } @@ -34,12 +35,16 @@ void *image_transfer_new(enum image_type_enum type) case IMAGE_TYPE_PNG: #ifdef HAVE_RPNG return rpng_alloc(); -#endif +#else break; +#endif case IMAGE_TYPE_JPEG: #ifdef HAVE_RJPEG return rjpeg_alloc(); +#else + break; #endif + default: break; } diff --git a/libretro-common/formats/jpeg/rjpeg.c b/libretro-common/formats/jpeg/rjpeg.c index 6ae2afd3c4..8419e5bb12 100644 --- a/libretro-common/formats/jpeg/rjpeg.c +++ b/libretro-common/formats/jpeg/rjpeg.c @@ -2467,7 +2467,15 @@ bool rjpeg_image_load(uint8_t *_buf, void *data, size_t size, return true; } -void *rjpeg_alloc(void) +void rjpeg_free(rjpeg_t *rjpeg) +{ + if (!rjpeg) + return; + + free(rjpeg); +} + +rjpeg_t *rjpeg_alloc(void) { rjpeg_t *rjpeg = (rjpeg_t*)calloc(1, sizeof(*rjpeg)); if (!rjpeg) diff --git a/libretro-common/include/formats/rjpeg.h b/libretro-common/include/formats/rjpeg.h index 62fafb4123..f0ddece720 100644 --- a/libretro-common/include/formats/rjpeg.h +++ b/libretro-common/include/formats/rjpeg.h @@ -37,7 +37,9 @@ typedef struct rjpeg rjpeg_t; bool rjpeg_image_load(uint8_t *buf, void *data, size_t size, unsigned a_shift, unsigned r_shift, unsigned g_shift, unsigned b_shift); -void *rjpeg_alloc(void); +void rjpeg_free(rjpeg_t *rjpeg); + +rjpeg_t *rjpeg_alloc(void); RETRO_END_DECLS From 5068accc4e5e0f9e89d16f04e6d97328370cdfe7 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 May 2016 08:50:50 +0200 Subject: [PATCH 465/498] Start preparing image transfer for RJPEG --- libretro-common/formats/image_transfer.c | 13 ++++--- libretro-common/formats/jpeg/rjpeg.c | 44 ++++++++++++++---------- libretro-common/formats/png/rpng.c | 4 +-- libretro-common/include/formats/image.h | 2 +- libretro-common/include/formats/rjpeg.h | 3 ++ libretro-common/include/formats/rpng.h | 2 +- tasks/task_image.c | 4 ++- tasks/tasks_internal.h | 1 + 8 files changed, 44 insertions(+), 29 deletions(-) diff --git a/libretro-common/formats/image_transfer.c b/libretro-common/formats/image_transfer.c index ae29f8756d..b0a756163e 100644 --- a/libretro-common/formats/image_transfer.c +++ b/libretro-common/formats/image_transfer.c @@ -92,7 +92,7 @@ void image_transfer_set_buffer_ptr( int image_transfer_process( void *data, enum image_type_enum type, - uint32_t **buf, + uint32_t **buf, size_t len, unsigned *width, unsigned *height) { switch (type) @@ -104,14 +104,17 @@ int image_transfer_process( return rpng_nbio_load_image_argb_process( (rpng_t*)data, - buf, - width, height); -#endif + buf, width, height); +#else break; +#endif case IMAGE_TYPE_JPEG: #ifdef HAVE_RJPEG -#endif + return rjpeg_process_image((rjpeg_t*)data, + buf, len, width, height); +#else break; +#endif } return 0; diff --git a/libretro-common/formats/jpeg/rjpeg.c b/libretro-common/formats/jpeg/rjpeg.c index 8419e5bb12..4ac0defbff 100644 --- a/libretro-common/formats/jpeg/rjpeg.c +++ b/libretro-common/formats/jpeg/rjpeg.c @@ -181,7 +181,7 @@ static void rjpeg__rewind(rjpeg__context *s) } static int rjpeg__jpeg_test(rjpeg__context *s); -static uint8_t *rjpeg__jpeg_load(rjpeg__context *s, int *x, int *y, int *comp, int req_comp); +static uint8_t *rjpeg__jpeg_load(rjpeg__context *s, unsigned *x, unsigned *y, int *comp, int req_comp); /* this is not threadsafe */ static const char *rjpeg__g_failure_reason; @@ -205,7 +205,7 @@ static INLINE int rjpeg__err(const char *str) static int rjpeg__vertically_flip_on_load = 0; -static unsigned char *rjpeg__load_main(rjpeg__context *s, int *x, int *y, int *comp, int req_comp) +static unsigned char *rjpeg__load_main(rjpeg__context *s, unsigned *x, unsigned *y, int *comp, int req_comp) { if (rjpeg__jpeg_test(s)) return rjpeg__jpeg_load(s,x,y,comp,req_comp); @@ -213,7 +213,7 @@ static unsigned char *rjpeg__load_main(rjpeg__context *s, int *x, int *y, int *c return rjpeg__errpuc("unknown image type", "Image not of any known type, or corrupt"); } -static unsigned char *rjpeg__load_flip(rjpeg__context *s, int *x, int *y, int *comp, int req_comp) +static unsigned char *rjpeg__load_flip(rjpeg__context *s, unsigned *x, unsigned *y, int *comp, int req_comp) { unsigned char *result = rjpeg__load_main(s, x, y, comp, req_comp); @@ -241,7 +241,7 @@ static unsigned char *rjpeg__load_flip(rjpeg__context *s, int *x, int *y, int *c return result; } -static uint8_t *rjpeg_load_from_memory(const uint8_t *buffer, int len, int *x, int *y, int *comp, int req_comp) +static uint8_t *rjpeg_load_from_memory(const uint8_t *buffer, int len, unsigned *x, unsigned *y, int *comp, int req_comp) { rjpeg__context s; rjpeg__start_mem(&s,buffer,len); @@ -2279,7 +2279,7 @@ static void rjpeg__cleanup_jpeg(rjpeg__jpeg *j) } } -static uint8_t *rjpeg_load_jpeg_image(rjpeg__jpeg *z, int *out_x, int *out_y, int *comp, int req_comp) +static uint8_t *rjpeg_load_jpeg_image(rjpeg__jpeg *z, unsigned *out_x, unsigned *out_y, int *comp, int req_comp) { int n, decode_n; z->s->img_n = 0; /* make rjpeg__cleanup_jpeg safe */ @@ -2409,7 +2409,7 @@ static uint8_t *rjpeg_load_jpeg_image(rjpeg__jpeg *z, int *out_x, int *out_y, in } } -static unsigned char *rjpeg__jpeg_load(rjpeg__context *s, int *x, int *y, int *comp, int req_comp) +static unsigned char *rjpeg__jpeg_load(rjpeg__context *s, unsigned *x, unsigned *y, int *comp, int req_comp) { rjpeg__jpeg j; j.s = s; @@ -2446,25 +2446,31 @@ static INLINE void video_frame_convert_rgba_to_bgra( } } -bool rjpeg_image_load(uint8_t *_buf, void *data, size_t size, +int rjpeg_process_image(void *data, uint8_t *buf, + size_t size, unsigned *width, unsigned *height) +{ + int comp; + struct texture_image *out_img = (struct texture_image*)data; + + out_img->pixels = (uint32_t*)rjpeg_load_from_memory(buf, size, width, height, &comp, 4); + out_img->width = *width; + out_img->height = *height; + + return 1; +} + +bool rjpeg_image_load(uint8_t *buf, void *data, size_t size, unsigned a_shift, unsigned r_shift, unsigned g_shift, unsigned b_shift) { - int comp; - int x = 0; - int y = 0; + unsigned width = 0; + unsigned height = 0; struct texture_image *out_img = (struct texture_image*)data; - out_img->pixels = (uint32_t*)rjpeg_load_from_memory(_buf, size, &x, &y, &comp, 4); + if (rjpeg_process_image(out_img, buf, size, &width, &height)) + return true; - out_img->width = x; - out_img->height = y; - - if (r_shift == 0 && b_shift == 16) { } /* RGBA, doesn't need conversion */ - else - video_frame_convert_rgba_to_bgra(_buf, out_img->pixels, x); - - return true; + return false; } void rjpeg_free(rjpeg_t *rjpeg) diff --git a/libretro-common/formats/png/rpng.c b/libretro-common/formats/png/rpng.c index ab92674082..3a52e2d2fc 100644 --- a/libretro-common/formats/png/rpng.c +++ b/libretro-common/formats/png/rpng.c @@ -1019,12 +1019,12 @@ bool rpng_is_valid(rpng_t *rpng) return false; } -bool rpng_set_buf_ptr(rpng_t *rpng, uint8_t *data) +bool rpng_set_buf_ptr(rpng_t *rpng, void *data) { if (!rpng) return false; - rpng->buff_data = data; + rpng->buff_data = (uint8_t*)data; return true; } diff --git a/libretro-common/include/formats/image.h b/libretro-common/include/formats/image.h index 9e9794ac94..0cb7fd3c14 100644 --- a/libretro-common/include/formats/image.h +++ b/libretro-common/include/formats/image.h @@ -72,7 +72,7 @@ void image_transfer_set_buffer_ptr( int image_transfer_process( void *data, enum image_type_enum type, - uint32_t **buf, + uint32_t **buf, size_t size, unsigned *width, unsigned *height); bool image_transfer_iterate(void *data, enum image_type_enum type); diff --git a/libretro-common/include/formats/rjpeg.h b/libretro-common/include/formats/rjpeg.h index f0ddece720..afb51c942e 100644 --- a/libretro-common/include/formats/rjpeg.h +++ b/libretro-common/include/formats/rjpeg.h @@ -34,6 +34,9 @@ RETRO_BEGIN_DECLS typedef struct rjpeg rjpeg_t; +int rjpeg_process_image(void *data, uint8_t *buf, + size_t size, unsigned *width, unsigned *height); + bool rjpeg_image_load(uint8_t *buf, void *data, size_t size, unsigned a_shift, unsigned r_shift, unsigned g_shift, unsigned b_shift); diff --git a/libretro-common/include/formats/rpng.h b/libretro-common/include/formats/rpng.h index 94db62932f..b9fa108b62 100644 --- a/libretro-common/include/formats/rpng.h +++ b/libretro-common/include/formats/rpng.h @@ -39,7 +39,7 @@ rpng_t *rpng_nbio_load_image_argb_init(const char *path); bool rpng_is_valid(rpng_t *rpng); -bool rpng_set_buf_ptr(rpng_t *rpng, uint8_t *data); +bool rpng_set_buf_ptr(rpng_t *rpng, void *data); rpng_t *rpng_alloc(void); diff --git a/tasks/task_image.c b/tasks/task_image.c index 124d0f712f..ed74d11719 100644 --- a/tasks/task_image.c +++ b/tasks/task_image.c @@ -101,7 +101,7 @@ static int rarch_main_data_image_process( int retval = image_transfer_process( nbio->image.handle, nbio->image_type, - &nbio->image.ti.pixels, width, height); + &nbio->image.ti.pixels, nbio->image.size, width, height); if (retval == IMAGE_PROCESS_ERROR) return IMAGE_PROCESS_ERROR; @@ -220,6 +220,7 @@ static int cb_nbio_generic(nbio_handle_t *nbio, size_t *len) image_transfer_set_buffer_ptr(nbio->image.handle, nbio->image_type, ptr); + nbio->image.size = *len; nbio->image.pos_increment = (*len / 2) ? (*len / 2) : 1; nbio->image.processing_pos_increment = (*len / 4) ? (*len / 4) : 1; @@ -245,6 +246,7 @@ static int cb_nbio_image_menu_thumbnail(void *data, size_t len) return -1; nbio->image.handle = image_transfer_new(nbio->image_type); + nbio->image.size = len; if (!nbio->image.handle) goto error; diff --git a/tasks/tasks_internal.h b/tasks/tasks_internal.h index 7ab3291530..c393fb1609 100644 --- a/tasks/tasks_internal.h +++ b/tasks/tasks_internal.h @@ -62,6 +62,7 @@ typedef struct nbio_image_handle bool is_finished; transfer_cb_t cb; void *handle; + size_t size; unsigned processing_pos_increment; unsigned pos_increment; uint64_t frame_count; From 8efe2de0ecec95a7c76493f563bed72e5b87dfc8 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 May 2016 09:08:32 +0200 Subject: [PATCH 466/498] (RJPEG/RPNG) Add debug logs and change function signatures --- gfx/video_texture_image.c | 3 +- libretro-common/formats/image_transfer.c | 35 ++++++++++++++++++++++-- libretro-common/formats/jpeg/rjpeg.c | 9 +++--- libretro-common/formats/png/rpng.c | 4 ++- libretro-common/include/formats/rjpeg.h | 2 +- libretro-common/include/formats/rpng.h | 2 +- 6 files changed, 44 insertions(+), 11 deletions(-) diff --git a/gfx/video_texture_image.c b/gfx/video_texture_image.c index 8949781813..d133e11930 100644 --- a/gfx/video_texture_image.c +++ b/gfx/video_texture_image.c @@ -184,7 +184,8 @@ static bool video_texture_image_load_png( do { - ret = rpng_nbio_load_image_argb_process(rpng, &out_img->pixels, &out_img->width, + ret = rpng_nbio_load_image_argb_process(rpng, + (void**)&out_img->pixels, &out_img->width, &out_img->height); }while(ret == IMAGE_PROCESS_NEXT); diff --git a/libretro-common/formats/image_transfer.c b/libretro-common/formats/image_transfer.c index b0a756163e..16e1943421 100644 --- a/libretro-common/formats/image_transfer.c +++ b/libretro-common/formats/image_transfer.c @@ -11,8 +11,16 @@ #include +#if 0 +#define DEBUG +#endif + void image_transfer_free(void *data, enum image_type_enum type) { +#ifdef DEBUG + printf("image_transfer_free\n"); +#endif + switch (type) { case IMAGE_TYPE_PNG: @@ -30,6 +38,10 @@ void image_transfer_free(void *data, enum image_type_enum type) void *image_transfer_new(enum image_type_enum type) { +#ifdef DEBUG + printf("image_transfer_new\n"); +#endif + switch (type) { case IMAGE_TYPE_PNG: @@ -53,6 +65,10 @@ void *image_transfer_new(enum image_type_enum type) bool image_transfer_start(void *data, enum image_type_enum type) { +#ifdef DEBUG + printf("image_transfer_start\n"); +#endif + switch (type) { case IMAGE_TYPE_PNG: @@ -95,6 +111,10 @@ int image_transfer_process( uint32_t **buf, size_t len, unsigned *width, unsigned *height) { +#ifdef DEBUG + printf("image_transfer_process\n"); +#endif + switch (type) { case IMAGE_TYPE_PNG: @@ -104,14 +124,17 @@ int image_transfer_process( return rpng_nbio_load_image_argb_process( (rpng_t*)data, - buf, width, height); + (void**)buf, width, height); #else break; #endif case IMAGE_TYPE_JPEG: #ifdef HAVE_RJPEG +#ifdef DEBUG + printf("len is: %d\n", len); +#endif return rjpeg_process_image((rjpeg_t*)data, - buf, len, width, height); + (void**)buf, len, width, height); #else break; #endif @@ -122,6 +145,10 @@ int image_transfer_process( bool image_transfer_iterate(void *data, enum image_type_enum type) { +#ifdef DEBUG + printf("image_transfer_iterate\n"); +#endif + switch (type) { case IMAGE_TYPE_PNG: @@ -132,8 +159,10 @@ bool image_transfer_iterate(void *data, enum image_type_enum type) break; case IMAGE_TYPE_JPEG: #ifdef HAVE_RJPEG -#endif + return false; +#else break; +#endif } return true; diff --git a/libretro-common/formats/jpeg/rjpeg.c b/libretro-common/formats/jpeg/rjpeg.c index 4ac0defbff..887c6e3667 100644 --- a/libretro-common/formats/jpeg/rjpeg.c +++ b/libretro-common/formats/jpeg/rjpeg.c @@ -2446,17 +2446,18 @@ static INLINE void video_frame_convert_rgba_to_bgra( } } -int rjpeg_process_image(void *data, uint8_t *buf, +int rjpeg_process_image(void *data, void **buf_data, size_t size, unsigned *width, unsigned *height) { int comp; struct texture_image *out_img = (struct texture_image*)data; + uint8_t **buf = (uint8_t**)buf_data; - out_img->pixels = (uint32_t*)rjpeg_load_from_memory(buf, size, width, height, &comp, 4); + out_img->pixels = (uint32_t*)rjpeg_load_from_memory(*buf, size, width, height, &comp, 4); out_img->width = *width; out_img->height = *height; - return 1; + return IMAGE_PROCESS_END; } bool rjpeg_image_load(uint8_t *buf, void *data, size_t size, @@ -2467,7 +2468,7 @@ bool rjpeg_image_load(uint8_t *buf, void *data, size_t size, unsigned height = 0; struct texture_image *out_img = (struct texture_image*)data; - if (rjpeg_process_image(out_img, buf, size, &width, &height)) + if (rjpeg_process_image(out_img, (void**)&buf, size, &width, &height) == IMAGE_PROCESS_END) return true; return false; diff --git a/libretro-common/formats/png/rpng.c b/libretro-common/formats/png/rpng.c index 3a52e2d2fc..81f85258d1 100644 --- a/libretro-common/formats/png/rpng.c +++ b/libretro-common/formats/png/rpng.c @@ -943,8 +943,10 @@ error: } int rpng_nbio_load_image_argb_process(rpng_t *rpng, - uint32_t **data, unsigned *width, unsigned *height) + void **_data, unsigned *width, unsigned *height) { + uint32_t **data = (uint32_t**)_data; + if (!rpng->process.initialized) { if (!rpng->process.stream_backend) diff --git a/libretro-common/include/formats/rjpeg.h b/libretro-common/include/formats/rjpeg.h index afb51c942e..a73de52340 100644 --- a/libretro-common/include/formats/rjpeg.h +++ b/libretro-common/include/formats/rjpeg.h @@ -34,7 +34,7 @@ RETRO_BEGIN_DECLS typedef struct rjpeg rjpeg_t; -int rjpeg_process_image(void *data, uint8_t *buf, +int rjpeg_process_image(void *data, void **buf, size_t size, unsigned *width, unsigned *height); bool rjpeg_image_load(uint8_t *buf, void *data, size_t size, diff --git a/libretro-common/include/formats/rpng.h b/libretro-common/include/formats/rpng.h index b9fa108b62..47a30630bf 100644 --- a/libretro-common/include/formats/rpng.h +++ b/libretro-common/include/formats/rpng.h @@ -48,7 +48,7 @@ void rpng_nbio_load_image_free(rpng_t *rpng); bool rpng_nbio_load_image_argb_iterate(rpng_t *rpng); int rpng_nbio_load_image_argb_process(rpng_t *rpng, - uint32_t **data, unsigned *width, unsigned *height); + void **data, unsigned *width, unsigned *height); bool rpng_nbio_load_image_argb_start(rpng_t *rpng); From f2912eb4c3b594c7e83cac6859a671c43fbf29a8 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 May 2016 09:22:29 +0200 Subject: [PATCH 467/498] Cleanup --- tasks/task_image.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/tasks/task_image.c b/tasks/task_image.c index ed74d11719..3a5277cafd 100644 --- a/tasks/task_image.c +++ b/tasks/task_image.c @@ -114,15 +114,12 @@ static int rarch_main_data_image_process( static int cb_image_menu_generic(nbio_handle_t *nbio) { - int retval = 0; unsigned width = 0, height = 0; if (!nbio) return -1; - retval = rarch_main_data_image_process(nbio, - &width, &height); - - switch (retval) + switch (rarch_main_data_image_process(nbio, + &width, &height)) { case IMAGE_PROCESS_ERROR: case IMAGE_PROCESS_ERROR_END: From 1e872108b772fda68c3318e3c5e77b8b12d2fc0f Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 May 2016 09:27:58 +0200 Subject: [PATCH 468/498] (RJPEG) Add back rgba to bgra routines --- libretro-common/formats/jpeg/rjpeg.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libretro-common/formats/jpeg/rjpeg.c b/libretro-common/formats/jpeg/rjpeg.c index 887c6e3667..072f0a3a74 100644 --- a/libretro-common/formats/jpeg/rjpeg.c +++ b/libretro-common/formats/jpeg/rjpeg.c @@ -2468,10 +2468,14 @@ bool rjpeg_image_load(uint8_t *buf, void *data, size_t size, unsigned height = 0; struct texture_image *out_img = (struct texture_image*)data; - if (rjpeg_process_image(out_img, (void**)&buf, size, &width, &height) == IMAGE_PROCESS_END) - return true; + if (rjpeg_process_image(out_img, (void**)&buf, size, &width, &height) != IMAGE_PROCESS_END) + return false; - return false; + if (r_shift == 0 && b_shift == 16) { } /* RGBA, doesn't need conversion */ + else + video_frame_convert_rgba_to_bgra(buf, out_img->pixels, width); + + return true; } void rjpeg_free(rjpeg_t *rjpeg) From 1512d36220c454afc3684fbfdcd1ff68d082d361 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 May 2016 09:34:42 +0200 Subject: [PATCH 469/498] rjpeg_process_image should not set the texture image's width/height - that is done later --- libretro-common/formats/jpeg/rjpeg.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/libretro-common/formats/jpeg/rjpeg.c b/libretro-common/formats/jpeg/rjpeg.c index 072f0a3a74..2a4a3de1ed 100644 --- a/libretro-common/formats/jpeg/rjpeg.c +++ b/libretro-common/formats/jpeg/rjpeg.c @@ -2454,8 +2454,6 @@ int rjpeg_process_image(void *data, void **buf_data, uint8_t **buf = (uint8_t**)buf_data; out_img->pixels = (uint32_t*)rjpeg_load_from_memory(*buf, size, width, height, &comp, 4); - out_img->width = *width; - out_img->height = *height; return IMAGE_PROCESS_END; } @@ -2471,6 +2469,9 @@ bool rjpeg_image_load(uint8_t *buf, void *data, size_t size, if (rjpeg_process_image(out_img, (void**)&buf, size, &width, &height) != IMAGE_PROCESS_END) return false; + out_img->width = width; + out_img->height = height; + if (r_shift == 0 && b_shift == 16) { } /* RGBA, doesn't need conversion */ else video_frame_convert_rgba_to_bgra(buf, out_img->pixels, width); From 1623d538d58a6043d7f4fa7f401ea29c9e598b4a Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 May 2016 09:42:02 +0200 Subject: [PATCH 470/498] Add rjpeg_set_buf_ptr --- libretro-common/formats/image_transfer.c | 1 + libretro-common/formats/jpeg/rjpeg.c | 11 +++++++++++ libretro-common/include/formats/rjpeg.h | 2 ++ 3 files changed, 14 insertions(+) diff --git a/libretro-common/formats/image_transfer.c b/libretro-common/formats/image_transfer.c index 16e1943421..faa4fbf2fc 100644 --- a/libretro-common/formats/image_transfer.c +++ b/libretro-common/formats/image_transfer.c @@ -100,6 +100,7 @@ void image_transfer_set_buffer_ptr( break; case IMAGE_TYPE_JPEG: #ifdef HAVE_RJPEG + rjpeg_set_buf_ptr((rjpeg_t*)data, (uint8_t*)ptr); #endif break; } diff --git a/libretro-common/formats/jpeg/rjpeg.c b/libretro-common/formats/jpeg/rjpeg.c index 2a4a3de1ed..fc80f77a91 100644 --- a/libretro-common/formats/jpeg/rjpeg.c +++ b/libretro-common/formats/jpeg/rjpeg.c @@ -67,6 +67,7 @@ typedef struct struct rjpeg { + uint8_t *buff_data; void *empty; }; @@ -2479,6 +2480,16 @@ bool rjpeg_image_load(uint8_t *buf, void *data, size_t size, return true; } +bool rjpeg_set_buf_ptr(rjpeg_t *rjpeg, void *data) +{ + if (!rjpeg) + return false; + + rjpeg->buff_data = (uint8_t*)data; + + return true; +} + void rjpeg_free(rjpeg_t *rjpeg) { if (!rjpeg) diff --git a/libretro-common/include/formats/rjpeg.h b/libretro-common/include/formats/rjpeg.h index a73de52340..3fa89e63aa 100644 --- a/libretro-common/include/formats/rjpeg.h +++ b/libretro-common/include/formats/rjpeg.h @@ -40,6 +40,8 @@ int rjpeg_process_image(void *data, void **buf, bool rjpeg_image_load(uint8_t *buf, void *data, size_t size, unsigned a_shift, unsigned r_shift, unsigned g_shift, unsigned b_shift); +bool rjpeg_set_buf_ptr(rjpeg_t *rpng, void *data); + void rjpeg_free(rjpeg_t *rjpeg); rjpeg_t *rjpeg_alloc(void); From fa27a8447e149a73045c49a64f2b8f7d555f3759 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 May 2016 09:49:38 +0200 Subject: [PATCH 471/498] Rename RPNG functions --- gfx/video_texture_image.c | 10 +++++----- libretro-common/formats/image_transfer.c | 10 +++++----- libretro-common/formats/png/rpng.c | 12 +++++++----- libretro-common/include/formats/rpng.h | 12 ++++++------ 4 files changed, 23 insertions(+), 21 deletions(-) diff --git a/gfx/video_texture_image.c b/gfx/video_texture_image.c index d133e11930..703ee2187e 100644 --- a/gfx/video_texture_image.c +++ b/gfx/video_texture_image.c @@ -174,18 +174,18 @@ static bool video_texture_image_load_png( if (!rpng_set_buf_ptr(rpng, (uint8_t*)ptr)) goto end; - if (!rpng_nbio_load_image_argb_start(rpng)) + if (!rpng_start(rpng)) goto end; - while (rpng_nbio_load_image_argb_iterate(rpng)); + while (rpng_iterate_image(rpng)); if (!rpng_is_valid(rpng)) goto end; do { - ret = rpng_nbio_load_image_argb_process(rpng, - (void**)&out_img->pixels, &out_img->width, + ret = rpng_process_image(rpng, + (void**)&out_img->pixels, 0, &out_img->width, &out_img->height); }while(ret == IMAGE_PROCESS_NEXT); @@ -207,7 +207,7 @@ static bool video_texture_image_load_png( end: if (rpng) - rpng_nbio_load_image_free(rpng); + rpng_free(rpng); return success; } diff --git a/libretro-common/formats/image_transfer.c b/libretro-common/formats/image_transfer.c index faa4fbf2fc..55839c0f17 100644 --- a/libretro-common/formats/image_transfer.c +++ b/libretro-common/formats/image_transfer.c @@ -25,7 +25,7 @@ void image_transfer_free(void *data, enum image_type_enum type) { case IMAGE_TYPE_PNG: #ifdef HAVE_RPNG - rpng_nbio_load_image_free((rpng_t*)data); + rpng_free((rpng_t*)data); #endif break; case IMAGE_TYPE_JPEG: @@ -73,7 +73,7 @@ bool image_transfer_start(void *data, enum image_type_enum type) { case IMAGE_TYPE_PNG: #ifdef HAVE_RPNG - if (!rpng_nbio_load_image_argb_start((rpng_t*)data)) + if (!rpng_start((rpng_t*)data)) return false; #endif break; @@ -123,9 +123,9 @@ int image_transfer_process( if (!rpng_is_valid((rpng_t*)data)) return IMAGE_PROCESS_ERROR; - return rpng_nbio_load_image_argb_process( + return rpng_process_image( (rpng_t*)data, - (void**)buf, width, height); + (void**)buf, len, width, height); #else break; #endif @@ -154,7 +154,7 @@ bool image_transfer_iterate(void *data, enum image_type_enum type) { case IMAGE_TYPE_PNG: #ifdef HAVE_RPNG - if (!rpng_nbio_load_image_argb_iterate((rpng_t*)data)) + if (!rpng_iterate_image((rpng_t*)data)) return false; #endif break; diff --git a/libretro-common/formats/png/rpng.c b/libretro-common/formats/png/rpng.c index 81f85258d1..b15b06d439 100644 --- a/libretro-common/formats/png/rpng.c +++ b/libretro-common/formats/png/rpng.c @@ -844,7 +844,7 @@ static bool png_parse_ihdr(uint8_t *buf, return true; } -bool rpng_nbio_load_image_argb_iterate(rpng_t *rpng) +bool rpng_iterate_image(rpng_t *rpng) { unsigned i; struct png_chunk chunk = {0}; @@ -942,11 +942,13 @@ error: return false; } -int rpng_nbio_load_image_argb_process(rpng_t *rpng, - void **_data, unsigned *width, unsigned *height) +int rpng_process_image(rpng_t *rpng, + void **_data, size_t size, unsigned *width, unsigned *height) { uint32_t **data = (uint32_t**)_data; + (void)size; + if (!rpng->process.initialized) { if (!rpng->process.stream_backend) @@ -970,7 +972,7 @@ int rpng_nbio_load_image_argb_process(rpng_t *rpng, return png_reverse_filter_iterate(rpng, data); } -void rpng_nbio_load_image_free(rpng_t *rpng) +void rpng_free(rpng_t *rpng) { if (!rpng) return; @@ -988,7 +990,7 @@ void rpng_nbio_load_image_free(rpng_t *rpng) free(rpng); } -bool rpng_nbio_load_image_argb_start(rpng_t *rpng) +bool rpng_start(rpng_t *rpng) { unsigned i; char header[8] = {0}; diff --git a/libretro-common/include/formats/rpng.h b/libretro-common/include/formats/rpng.h index 47a30630bf..57cce2f199 100644 --- a/libretro-common/include/formats/rpng.h +++ b/libretro-common/include/formats/rpng.h @@ -35,7 +35,7 @@ RETRO_BEGIN_DECLS typedef struct rpng rpng_t; -rpng_t *rpng_nbio_load_image_argb_init(const char *path); +rpng_t *rpng_init(const char *path); bool rpng_is_valid(rpng_t *rpng); @@ -43,14 +43,14 @@ bool rpng_set_buf_ptr(rpng_t *rpng, void *data); rpng_t *rpng_alloc(void); -void rpng_nbio_load_image_free(rpng_t *rpng); +void rpng_free(rpng_t *rpng); -bool rpng_nbio_load_image_argb_iterate(rpng_t *rpng); +bool rpng_iterate_image(rpng_t *rpng); -int rpng_nbio_load_image_argb_process(rpng_t *rpng, - void **data, unsigned *width, unsigned *height); +int rpng_process_image(rpng_t *rpng, + void **data, size_t size, unsigned *width, unsigned *height); -bool rpng_nbio_load_image_argb_start(rpng_t *rpng); +bool rpng_start(rpng_t *rpng); #ifdef HAVE_ZLIB_DEFLATE bool rpng_save_image_argb(const char *path, const uint32_t *data, From ee95af8ae3b1806ba002776c12169665800b57b4 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 May 2016 09:51:08 +0200 Subject: [PATCH 472/498] (RPNG) Cleanup --- libretro-common/formats/png/rpng.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/libretro-common/formats/png/rpng.c b/libretro-common/formats/png/rpng.c index b15b06d439..e813fe8319 100644 --- a/libretro-common/formats/png/rpng.c +++ b/libretro-common/formats/png/rpng.c @@ -962,9 +962,8 @@ int rpng_process_image(rpng_t *rpng, if (!rpng->process.inflate_initialized) { - int ret = rpng_load_image_argb_process_inflate_init(rpng, data, - width, height); - if (ret == -1) + if (rpng_load_image_argb_process_inflate_init(rpng, data, + width, height) == -1) return PNG_PROCESS_ERROR; return 0; } From 101539b489691be4f2f2eaa33aad760e14d31962 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 May 2016 09:58:42 +0200 Subject: [PATCH 473/498] (RJPEG) more internal changes --- libretro-common/formats/jpeg/rjpeg.c | 26 ++++++++++++++++++++----- libretro-common/include/formats/rjpeg.h | 4 ++-- 2 files changed, 23 insertions(+), 7 deletions(-) diff --git a/libretro-common/formats/jpeg/rjpeg.c b/libretro-common/formats/jpeg/rjpeg.c index fc80f77a91..5c643efdb6 100644 --- a/libretro-common/formats/jpeg/rjpeg.c +++ b/libretro-common/formats/jpeg/rjpeg.c @@ -68,6 +68,7 @@ typedef struct struct rjpeg { uint8_t *buff_data; + struct texture_image *out_img; void *empty; }; @@ -2447,12 +2448,12 @@ static INLINE void video_frame_convert_rgba_to_bgra( } } -int rjpeg_process_image(void *data, void **buf_data, +int rjpeg_process_image(rjpeg_t *rjpeg, void **buf_data, size_t size, unsigned *width, unsigned *height) { int comp; - struct texture_image *out_img = (struct texture_image*)data; - uint8_t **buf = (uint8_t**)buf_data; + struct texture_image *out_img = (struct texture_image*)rjpeg->out_img; + uint8_t **buf = (uint8_t**)rjpeg->buff_data; out_img->pixels = (uint32_t*)rjpeg_load_from_memory(*buf, size, width, height, &comp, 4); @@ -2466,9 +2467,18 @@ bool rjpeg_image_load(uint8_t *buf, void *data, size_t size, unsigned width = 0; unsigned height = 0; struct texture_image *out_img = (struct texture_image*)data; + rjpeg_t *rjpeg = rjpeg_alloc(); - if (rjpeg_process_image(out_img, (void**)&buf, size, &width, &height) != IMAGE_PROCESS_END) - return false; + if (!rjpeg) + goto error; + + if (!rjpeg_set_buf_ptr(rjpeg, &buf)) + goto error; + + rjpeg->out_img = out_img; + + if (rjpeg_process_image(rjpeg, (void**)&buf, size, &width, &height) != IMAGE_PROCESS_END) + goto error; out_img->width = width; out_img->height = height; @@ -2478,6 +2488,11 @@ bool rjpeg_image_load(uint8_t *buf, void *data, size_t size, video_frame_convert_rgba_to_bgra(buf, out_img->pixels, width); return true; + +error: + if (rjpeg) + free(rjpeg); + return false; } bool rjpeg_set_buf_ptr(rjpeg_t *rjpeg, void *data) @@ -2503,5 +2518,6 @@ rjpeg_t *rjpeg_alloc(void) rjpeg_t *rjpeg = (rjpeg_t*)calloc(1, sizeof(*rjpeg)); if (!rjpeg) return NULL; + rjpeg->out_img = (struct texture_image*)calloc(1, sizeof(*rjpeg->out_img)); return rjpeg; } diff --git a/libretro-common/include/formats/rjpeg.h b/libretro-common/include/formats/rjpeg.h index 3fa89e63aa..bc60b55ef5 100644 --- a/libretro-common/include/formats/rjpeg.h +++ b/libretro-common/include/formats/rjpeg.h @@ -34,13 +34,13 @@ RETRO_BEGIN_DECLS typedef struct rjpeg rjpeg_t; -int rjpeg_process_image(void *data, void **buf, +int rjpeg_process_image(rjpeg_t *rjpeg, void **buf, size_t size, unsigned *width, unsigned *height); bool rjpeg_image_load(uint8_t *buf, void *data, size_t size, unsigned a_shift, unsigned r_shift, unsigned g_shift, unsigned b_shift); -bool rjpeg_set_buf_ptr(rjpeg_t *rpng, void *data); +bool rjpeg_set_buf_ptr(rjpeg_t *rjpeg, void *data); void rjpeg_free(rjpeg_t *rjpeg); From a283923393ffb4a0f7a757678d3c6bf0859f1bd5 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 May 2016 10:10:23 +0200 Subject: [PATCH 474/498] Get rid of image->frame_count --- tasks/task_image.c | 2 -- tasks/tasks_internal.h | 1 - 2 files changed, 3 deletions(-) diff --git a/tasks/task_image.c b/tasks/task_image.c index 3a5277cafd..baf13b2b26 100644 --- a/tasks/task_image.c +++ b/tasks/task_image.c @@ -185,7 +185,6 @@ static int rarch_main_data_image_iterate_transfer(nbio_handle_t *nbio) goto error; } - nbio->image.frame_count++; return 0; error: @@ -200,7 +199,6 @@ static void rarch_task_image_load_free_internal(nbio_handle_t *nbio) image->handle = NULL; image->cb = NULL; - image->frame_count = 0; } static int cb_nbio_generic(nbio_handle_t *nbio, size_t *len) diff --git a/tasks/tasks_internal.h b/tasks/tasks_internal.h index c393fb1609..58ff581b86 100644 --- a/tasks/tasks_internal.h +++ b/tasks/tasks_internal.h @@ -65,7 +65,6 @@ typedef struct nbio_image_handle size_t size; unsigned processing_pos_increment; unsigned pos_increment; - uint64_t frame_count; int processing_final_state; unsigned status; } nbio_image_handle_t; From bdf4a173f24d9f6bbbdcc64f894584587b9a72f5 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 May 2016 10:10:54 +0200 Subject: [PATCH 475/498] Remove file transfer frame_count --- tasks/task_file_transfer.c | 2 -- tasks/tasks_internal.h | 1 - 2 files changed, 3 deletions(-) diff --git a/tasks/task_file_transfer.c b/tasks/task_file_transfer.c index 5b7c4ce5c5..cf13a6babc 100644 --- a/tasks/task_file_transfer.c +++ b/tasks/task_file_transfer.c @@ -44,7 +44,6 @@ static int rarch_main_data_nbio_iterate_transfer(nbio_handle_t *nbio) return -1; } - nbio->frame_count++; return 0; } @@ -109,6 +108,5 @@ task_finished: nbio_free(nbio->handle); nbio->handle = NULL; nbio->is_finished = false; - nbio->frame_count = 0; free(nbio); } diff --git a/tasks/tasks_internal.h b/tasks/tasks_internal.h index 58ff581b86..5f39d251fe 100644 --- a/tasks/tasks_internal.h +++ b/tasks/tasks_internal.h @@ -77,7 +77,6 @@ typedef struct nbio_handle transfer_cb_t cb; struct nbio_t *handle; unsigned pos_increment; - uint64_t frame_count; msg_queue_t *msg_queue; unsigned status; } nbio_handle_t; From 025c51e4c9514eab45d5bdf3bae46e4cc73ac727 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 May 2016 10:13:36 +0200 Subject: [PATCH 476/498] (task_image.c) Rename functions --- tasks/task_image.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/tasks/task_image.c b/tasks/task_image.c index baf13b2b26..4dacc10f72 100644 --- a/tasks/task_image.c +++ b/tasks/task_image.c @@ -68,7 +68,7 @@ static int cb_image_menu_upload_generic(void *data, size_t len) return 0; } -static int rarch_main_data_image_iterate_transfer_parse(nbio_handle_t *nbio) +static int task_image_iterate_transfer_parse(nbio_handle_t *nbio) { if (nbio->image.handle && nbio->image.cb) { @@ -93,7 +93,7 @@ static int cb_nbio_default(void *data, size_t len) return 0; } -static int rarch_main_data_image_process( +static int task_image_process( nbio_handle_t *nbio, unsigned *width, unsigned *height) @@ -118,7 +118,7 @@ static int cb_image_menu_generic(nbio_handle_t *nbio) if (!nbio) return -1; - switch (rarch_main_data_image_process(nbio, + switch (task_image_process(nbio, &width, &height)) { case IMAGE_PROCESS_ERROR: @@ -146,7 +146,7 @@ static int cb_image_menu_thumbnail(void *data, size_t len) return 0; } -static int rarch_main_data_image_iterate_process_transfer(nbio_handle_t *nbio) +static int task_image_iterate_process_transfer(nbio_handle_t *nbio) { unsigned i, width = 0, height = 0; int retval = 0; @@ -156,7 +156,7 @@ static int rarch_main_data_image_iterate_process_transfer(nbio_handle_t *nbio) for (i = 0; i < nbio->image.processing_pos_increment; i++) { - retval = rarch_main_data_image_process(nbio, + retval = task_image_process(nbio, &width, &height); if (retval != IMAGE_PROCESS_NEXT) break; @@ -169,7 +169,7 @@ static int rarch_main_data_image_iterate_process_transfer(nbio_handle_t *nbio) return -1; } -static int rarch_main_data_image_iterate_transfer(nbio_handle_t *nbio) +static int task_image_iterate_transfer(nbio_handle_t *nbio) { unsigned i; @@ -263,21 +263,21 @@ bool rarch_task_image_load_handler(retro_task_t *task) switch (image->status) { case IMAGE_STATUS_PROCESS_TRANSFER: - if (rarch_main_data_image_iterate_process_transfer(nbio) == -1) + if (task_image_iterate_process_transfer(nbio) == -1) image->status = IMAGE_STATUS_PROCESS_TRANSFER_PARSE; break; case IMAGE_STATUS_TRANSFER_PARSE: - rarch_main_data_image_iterate_transfer_parse(nbio); + task_image_iterate_transfer_parse(nbio); if (image->is_blocking_on_processing) image->status = IMAGE_STATUS_PROCESS_TRANSFER; break; case IMAGE_STATUS_TRANSFER: if (!image->is_blocking) - if (rarch_main_data_image_iterate_transfer(nbio) == -1) + if (task_image_iterate_transfer(nbio) == -1) image->status = IMAGE_STATUS_TRANSFER_PARSE; break; case IMAGE_STATUS_PROCESS_TRANSFER_PARSE: - rarch_main_data_image_iterate_transfer_parse(nbio); + task_image_iterate_transfer_parse(nbio); if (!image->is_finished) break; case IMAGE_STATUS_TRANSFER_PARSE_FREE: From 7c1938b6740dd823fa311adc627ae1126670f7b1 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 May 2016 10:19:53 +0200 Subject: [PATCH 477/498] Rename task functions --- tasks/task_database.c | 38 +++++++++++++++++++------------------- tasks/task_decompress.c | 26 +++++++++++++------------- tasks/task_file_transfer.c | 8 ++++---- tasks/task_http.c | 15 +++++++-------- 4 files changed, 43 insertions(+), 44 deletions(-) diff --git a/tasks/task_database.c b/tasks/task_database.c index 530602b374..73d7ce9052 100644 --- a/tasks/task_database.c +++ b/tasks/task_database.c @@ -88,7 +88,7 @@ static int zlib_compare_crc32(const char *name, const char *valid_exts, } #endif -static int database_info_iterate_start(database_info_handle_t *db, +static int task_database_iterate_start(database_info_handle_t *db, const char *name) { char msg[128] = {0}; @@ -196,7 +196,7 @@ static bool file_get_crc(database_state_handle_t *db_state, return 1; } -static int database_info_iterate_playlist( +static int task_database_iterate_playlist( database_state_handle_t *db_state, database_info_handle_t *db, const char *name) { @@ -254,7 +254,7 @@ static int database_info_list_iterate_end_no_match( return 0; } -static int database_info_iterate_next(database_info_handle_t *db) +static int task_database_iterate_next(database_info_handle_t *db) { db->list_ptr++; @@ -361,7 +361,7 @@ static int database_info_list_iterate_next( return 1; } -static int database_info_iterate_crc_lookup( +static int task_database_iterate_crc_lookup( database_state_handle_t *db_state, database_info_handle_t *db, const char *zip_entry) @@ -418,14 +418,14 @@ static int database_info_iterate_crc_lookup( return 0; } -static int database_info_iterate_playlist_zip( +static int task_database_iterate_playlist_zip( database_state_handle_t *db_state, database_info_handle_t *db, const char *name) { bool returnerr = true; #ifdef HAVE_ZLIB if (db_state->crc != 0) - return database_info_iterate_crc_lookup( + return task_database_iterate_crc_lookup( db_state, db, db_state->zip_name); if (file_archive_parse_file_iterate(&db->state, @@ -440,7 +440,7 @@ static int database_info_iterate_playlist_zip( return 1; } -static int database_info_iterate_serial_lookup( +static int task_database_iterate_serial_lookup( database_state_handle_t *db_state, database_info_handle_t *db, const char *name) { @@ -497,7 +497,7 @@ static int database_info_iterate_serial_lookup( return 0; } -static int database_info_iterate(database_state_handle_t *db_state, +static int task_database_iterate(database_state_handle_t *db_state, database_info_handle_t *db) { const char *name = db ? db->list->elems[db->list_ptr].data : NULL; @@ -511,13 +511,13 @@ static int database_info_iterate(database_state_handle_t *db_state, switch (db->type) { case DATABASE_TYPE_ITERATE: - return database_info_iterate_playlist(db_state, db, name); + return task_database_iterate_playlist(db_state, db, name); case DATABASE_TYPE_ITERATE_ZIP: - return database_info_iterate_playlist_zip(db_state, db, name); + return task_database_iterate_playlist_zip(db_state, db, name); case DATABASE_TYPE_SERIAL_LOOKUP: - return database_info_iterate_serial_lookup(db_state, db, name); + return task_database_iterate_serial_lookup(db_state, db, name); case DATABASE_TYPE_CRC_LOOKUP: - return database_info_iterate_crc_lookup(db_state, db, NULL); + return task_database_iterate_crc_lookup(db_state, db, NULL); case DATABASE_TYPE_NONE: default: break; @@ -526,7 +526,7 @@ static int database_info_iterate(database_state_handle_t *db_state, return 0; } -static void rarch_main_data_db_cleanup_state( +static void task_database_cleanup_state( database_state_handle_t *db_state) { if (!db_state) @@ -537,7 +537,7 @@ static void rarch_main_data_db_cleanup_state( db_state->buf = NULL; } -static void rarch_dbscan_task_handler(retro_task_t *task) +static void task_database_handler(retro_task_t *task) { db_handle_t *db = (db_handle_t*)task->state; database_info_handle_t *dbinfo = db->handle; @@ -557,20 +557,20 @@ static void rarch_dbscan_task_handler(retro_task_t *task) dbinfo->status = DATABASE_STATUS_ITERATE_START; break; case DATABASE_STATUS_ITERATE_START: - rarch_main_data_db_cleanup_state(dbstate); + task_database_cleanup_state(dbstate); dbstate->list_index = 0; dbstate->entry_index = 0; - database_info_iterate_start(dbinfo, name); + task_database_iterate_start(dbinfo, name); break; case DATABASE_STATUS_ITERATE: - if (database_info_iterate(&db->state, dbinfo) == 0) + if (task_database_iterate(&db->state, dbinfo) == 0) { dbinfo->status = DATABASE_STATUS_ITERATE_NEXT; dbinfo->type = DATABASE_TYPE_ITERATE; } break; case DATABASE_STATUS_ITERATE_NEXT: - if (database_info_iterate_next(dbinfo) == 0) + if (task_database_iterate_next(dbinfo) == 0) { dbinfo->status = DATABASE_STATUS_ITERATE_START; dbinfo->type = DATABASE_TYPE_ITERATE; @@ -615,7 +615,7 @@ bool rarch_task_push_dbscan(const char *fullpath, if (!t || !db) goto error; - t->handler = rarch_dbscan_task_handler; + t->handler = task_database_handler; t->state = db; t->callback = cb; diff --git a/tasks/task_decompress.c b/tasks/task_decompress.c index 104725c831..80b97ef0ff 100644 --- a/tasks/task_decompress.c +++ b/tasks/task_decompress.c @@ -131,7 +131,7 @@ error: return 0; } -static void rarch_task_decompress_handler_finished(retro_task_t *task, +static void task_decompress_handler_finished(retro_task_t *task, decompress_state_t *dec) { task->finished = true; @@ -158,7 +158,7 @@ static void rarch_task_decompress_handler_finished(retro_task_t *task, free(dec); } -static void rarch_task_decompress_handler(retro_task_t *task) +static void task_decompress_handler(retro_task_t *task) { bool retdec = false; decompress_state_t *dec = (decompress_state_t*)task->state; @@ -173,11 +173,11 @@ static void rarch_task_decompress_handler(retro_task_t *task) task->error = dec->callback_error; file_archive_parse_file_iterate_stop(&dec->zlib); - rarch_task_decompress_handler_finished(task, dec); + task_decompress_handler_finished(task, dec); } } -static void rarch_task_decompress_handler_target_file(retro_task_t *task) +static void task_decompress_handler_target_file(retro_task_t *task) { bool retdec; decompress_state_t *dec = (decompress_state_t*)task->state; @@ -192,11 +192,11 @@ static void rarch_task_decompress_handler_target_file(retro_task_t *task) task->error = dec->callback_error; file_archive_parse_file_iterate_stop(&dec->zlib); - rarch_task_decompress_handler_finished(task, dec); + task_decompress_handler_finished(task, dec); } } -static void rarch_task_decompress_handler_subdir(retro_task_t *task) +static void task_decompress_handler_subdir(retro_task_t *task) { bool retdec; decompress_state_t *dec = (decompress_state_t*)task->state; @@ -211,16 +211,16 @@ static void rarch_task_decompress_handler_subdir(retro_task_t *task) task->error = dec->callback_error; file_archive_parse_file_iterate_stop(&dec->zlib); - rarch_task_decompress_handler_finished(task, dec); + task_decompress_handler_finished(task, dec); } } -static bool rarch_task_decompress_finder( +static bool task_decompress_finder( retro_task_t *task, void *user_data) { decompress_state_t *dec = (decompress_state_t*)task->state; - if (task->handler != rarch_task_decompress_handler) + if (task->handler != task_decompress_handler) return false; return string_is_equal(dec->source_file, (const char*)user_data); @@ -231,7 +231,7 @@ bool rarch_task_check_decompress(const char *source_file) task_finder_data_t find_data; /* Prepare find parameters */ - find_data.func = rarch_task_decompress_finder; + find_data.func = task_decompress_finder; find_data.userdata = (void *)source_file; /* Return whether decompressing is in progress or not */ @@ -300,17 +300,17 @@ bool rarch_task_push_decompress( goto error; t->state = s; - t->handler = rarch_task_decompress_handler; + t->handler = task_decompress_handler; if (!string_is_empty(subdir)) { s->subdir = strdup(subdir); - t->handler = rarch_task_decompress_handler_subdir; + t->handler = task_decompress_handler_subdir; } else if (!string_is_empty(target_file)) { s->target_file = strdup(target_file); - t->handler = rarch_task_decompress_handler_target_file; + t->handler = task_decompress_handler_target_file; } t->callback = cb; diff --git a/tasks/task_file_transfer.c b/tasks/task_file_transfer.c index cf13a6babc..e46ab04624 100644 --- a/tasks/task_file_transfer.c +++ b/tasks/task_file_transfer.c @@ -26,7 +26,7 @@ #include "tasks_internal.h" #include "../verbosity.h" -static int rarch_main_data_nbio_iterate_transfer(nbio_handle_t *nbio) +static int task_file_transfer_iterate_transfer(nbio_handle_t *nbio) { size_t i; @@ -47,7 +47,7 @@ static int rarch_main_data_nbio_iterate_transfer(nbio_handle_t *nbio) return 0; } -static int rarch_main_data_nbio_iterate_parse(nbio_handle_t *nbio) +static int task_file_transfer_iterate_parse(nbio_handle_t *nbio) { if (!nbio) return -1; @@ -68,11 +68,11 @@ void rarch_task_file_load_handler(retro_task_t *task) switch (nbio->status) { case NBIO_STATUS_TRANSFER_PARSE: - rarch_main_data_nbio_iterate_parse(nbio); + task_file_transfer_iterate_parse(nbio); nbio->status = NBIO_STATUS_TRANSFER_PARSE_FREE; break; case NBIO_STATUS_TRANSFER: - if (rarch_main_data_nbio_iterate_transfer(nbio) == -1) + if (task_file_transfer_iterate_transfer(nbio) == -1) nbio->status = NBIO_STATUS_TRANSFER_PARSE; break; case NBIO_STATUS_TRANSFER_PARSE_FREE: diff --git a/tasks/task_http.c b/tasks/task_http.c index 64a7c05501..1b25f0b6d7 100644 --- a/tasks/task_http.c +++ b/tasks/task_http.c @@ -53,14 +53,14 @@ typedef struct http_handle bool error; } http_handle_t; -static int rarch_main_data_http_con_iterate_transfer(http_handle_t *http) +static int task_http_con_iterate_transfer(http_handle_t *http) { if (!net_http_connection_iterate(http->connection.handle)) return -1; return 0; } -static int rarch_main_data_http_conn_iterate_transfer_parse( +static int task_http_conn_iterate_transfer_parse( http_handle_t *http) { if (net_http_connection_done(http->connection.handle)) @@ -101,14 +101,14 @@ static int cb_http_conn_default(void *data_, size_t len) } /** - * rarch_main_data_http_iterate_transfer: + * task_http_iterate_transfer: * * Resumes HTTP transfer update. * * Returns: 0 when finished, -1 when we should continue * with the transfer on the next frame. **/ -static int rarch_main_data_http_iterate_transfer(retro_task_t *task) +static int task_http_iterate_transfer(retro_task_t *task) { http_handle_t *http = (http_handle_t*)task->state; size_t pos = 0, tot = 0; @@ -133,15 +133,15 @@ static void rarch_task_http_transfer_handler(retro_task_t *task) switch (http->status) { case HTTP_STATUS_CONNECTION_TRANSFER_PARSE: - rarch_main_data_http_conn_iterate_transfer_parse(http); + task_http_conn_iterate_transfer_parse(http); http->status = HTTP_STATUS_TRANSFER; break; case HTTP_STATUS_CONNECTION_TRANSFER: - if (!rarch_main_data_http_con_iterate_transfer(http)) + if (!task_http_con_iterate_transfer(http)) http->status = HTTP_STATUS_CONNECTION_TRANSFER_PARSE; break; case HTTP_STATUS_TRANSFER: - if (!rarch_main_data_http_iterate_transfer(task)) + if (!task_http_iterate_transfer(task)) goto task_finished; break; case HTTP_STATUS_TRANSFER_PARSE: @@ -311,4 +311,3 @@ task_retriever_info_t *http_task_get_transfer_list(void) task_queue_ctl(TASK_QUEUE_CTL_RETRIEVE, &retrieve_data); return retrieve_data.list; } - From fad7f8c1df758dba0dfadb8ddf9627dc16672186 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 May 2016 10:28:44 +0200 Subject: [PATCH 478/498] Cleanups --- tasks/task_http.c | 10 +++++----- tasks/task_image.c | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/tasks/task_http.c b/tasks/task_http.c index 1b25f0b6d7..b75ec77c93 100644 --- a/tasks/task_http.c +++ b/tasks/task_http.c @@ -124,8 +124,8 @@ static int task_http_iterate_transfer(retro_task_t *task) static void rarch_task_http_transfer_handler(retro_task_t *task) { - http_handle_t *http = (http_handle_t*)task->state; - http_transfer_data_t *data; + http_transfer_data_t *data = NULL; + http_handle_t *http = (http_handle_t*)task->state; if (task->cancelled) goto task_finished; @@ -196,7 +196,7 @@ task_finished: static bool rarch_task_http_finder(retro_task_t *task, void *user_data) { - http_handle_t *http; + http_handle_t *http = NULL; if (!task || (task->handler != rarch_task_http_transfer_handler)) return false; @@ -303,9 +303,9 @@ task_retriever_info_t *http_task_get_transfer_list(void) task_retriever_data_t retrieve_data; /* Fill retrieve data */ - retrieve_data.handler = rarch_task_http_transfer_handler; + retrieve_data.handler = rarch_task_http_transfer_handler; retrieve_data.element_size = sizeof(http_transfer_info_t); - retrieve_data.func = rarch_task_http_retriever; + retrieve_data.func = rarch_task_http_retriever; /* Build list of current HTTP transfers and return it */ task_queue_ctl(TASK_QUEUE_CTL_RETRIEVE, &retrieve_data); diff --git a/tasks/task_image.c b/tasks/task_image.c index 4dacc10f72..e9b3bf0ca5 100644 --- a/tasks/task_image.c +++ b/tasks/task_image.c @@ -44,8 +44,8 @@ enum image_status_enum static int cb_image_menu_upload_generic(void *data, size_t len) { - nbio_handle_t *nbio = (nbio_handle_t*)data; unsigned r_shift, g_shift, b_shift, a_shift; + nbio_handle_t *nbio = (nbio_handle_t*)data; if (!nbio) return -1; From 19eaa05040a7ef011ade955ab6916ac130ead64e Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 May 2016 10:55:22 +0200 Subject: [PATCH 479/498] (RJPEG) Cleanups --- libretro-common/formats/jpeg/rjpeg.c | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/libretro-common/formats/jpeg/rjpeg.c b/libretro-common/formats/jpeg/rjpeg.c index 5c643efdb6..94ee9816b3 100644 --- a/libretro-common/formats/jpeg/rjpeg.c +++ b/libretro-common/formats/jpeg/rjpeg.c @@ -68,7 +68,7 @@ typedef struct struct rjpeg { uint8_t *buff_data; - struct texture_image *out_img; + uint32_t *output_image; void *empty; }; @@ -2452,10 +2452,8 @@ int rjpeg_process_image(rjpeg_t *rjpeg, void **buf_data, size_t size, unsigned *width, unsigned *height) { int comp; - struct texture_image *out_img = (struct texture_image*)rjpeg->out_img; - uint8_t **buf = (uint8_t**)rjpeg->buff_data; - - out_img->pixels = (uint32_t*)rjpeg_load_from_memory(*buf, size, width, height, &comp, 4); + uint8_t **buf = (uint8_t**)buf_data; + rjpeg->output_image = (uint32_t*)rjpeg_load_from_memory(*buf, size, width, height, &comp, 4); return IMAGE_PROCESS_END; } @@ -2475,11 +2473,10 @@ bool rjpeg_image_load(uint8_t *buf, void *data, size_t size, if (!rjpeg_set_buf_ptr(rjpeg, &buf)) goto error; - rjpeg->out_img = out_img; - if (rjpeg_process_image(rjpeg, (void**)&buf, size, &width, &height) != IMAGE_PROCESS_END) goto error; + out_img->pixels = (uint32_t*)rjpeg->output_image; out_img->width = width; out_img->height = height; @@ -2518,6 +2515,5 @@ rjpeg_t *rjpeg_alloc(void) rjpeg_t *rjpeg = (rjpeg_t*)calloc(1, sizeof(*rjpeg)); if (!rjpeg) return NULL; - rjpeg->out_img = (struct texture_image*)calloc(1, sizeof(*rjpeg->out_img)); return rjpeg; } From 5a4b062b0d2ad1f28e2897e373174be98b183443 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 May 2016 11:10:59 +0200 Subject: [PATCH 480/498] (RJPEG) Remove rjpeg_test --- libretro-common/formats/jpeg/rjpeg.c | 26 +------------------------- 1 file changed, 1 insertion(+), 25 deletions(-) diff --git a/libretro-common/formats/jpeg/rjpeg.c b/libretro-common/formats/jpeg/rjpeg.c index 94ee9816b3..e34d16aad3 100644 --- a/libretro-common/formats/jpeg/rjpeg.c +++ b/libretro-common/formats/jpeg/rjpeg.c @@ -173,16 +173,6 @@ static void rjpeg__start_mem(rjpeg__context *s, const uint8_t *buffer, int len) s->img_buffer_end = (uint8_t *) buffer+len; } -static void rjpeg__rewind(rjpeg__context *s) -{ - /* conceptually rewind SHOULD rewind to the beginning of the stream, - * but we just rewind to the beginning of the initial buffer, because - * we only use it after doing 'test', which only ever looks at at most 92 bytes - */ - s->img_buffer = s->img_buffer_original; -} - -static int rjpeg__jpeg_test(rjpeg__context *s); static uint8_t *rjpeg__jpeg_load(rjpeg__context *s, unsigned *x, unsigned *y, int *comp, int req_comp); /* this is not threadsafe */ @@ -209,10 +199,7 @@ static int rjpeg__vertically_flip_on_load = 0; static unsigned char *rjpeg__load_main(rjpeg__context *s, unsigned *x, unsigned *y, int *comp, int req_comp) { - if (rjpeg__jpeg_test(s)) - return rjpeg__jpeg_load(s,x,y,comp,req_comp); - - return rjpeg__errpuc("unknown image type", "Image not of any known type, or corrupt"); + return rjpeg__jpeg_load(s,x,y,comp,req_comp); } static unsigned char *rjpeg__load_flip(rjpeg__context *s, unsigned *x, unsigned *y, int *comp, int req_comp) @@ -2419,17 +2406,6 @@ static unsigned char *rjpeg__jpeg_load(rjpeg__context *s, unsigned *x, unsigned return rjpeg_load_jpeg_image(&j, x,y,comp,req_comp); } -static int rjpeg__jpeg_test(rjpeg__context *s) -{ - int r; - rjpeg__jpeg j; - j.s = s; - rjpeg__setup_jpeg(&j); - r = rjpeg__decode_jpeg_header(&j, RJPEG_SCAN_TYPE); - rjpeg__rewind(s); - return r; -} - static INLINE void video_frame_convert_rgba_to_bgra( const void *src_data, void *dst_data, From e56abc03b30cf37fe41a9b514ccba40504f79446 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 May 2016 11:15:31 +0200 Subject: [PATCH 481/498] (rjpeg_process_image) Handle error --- libretro-common/formats/jpeg/rjpeg.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libretro-common/formats/jpeg/rjpeg.c b/libretro-common/formats/jpeg/rjpeg.c index e34d16aad3..976e7de7a2 100644 --- a/libretro-common/formats/jpeg/rjpeg.c +++ b/libretro-common/formats/jpeg/rjpeg.c @@ -2429,6 +2429,10 @@ int rjpeg_process_image(rjpeg_t *rjpeg, void **buf_data, { int comp; uint8_t **buf = (uint8_t**)buf_data; + + if (!rjpeg) + return IMAGE_PROCESS_ERROR; + rjpeg->output_image = (uint32_t*)rjpeg_load_from_memory(*buf, size, width, height, &comp, 4); return IMAGE_PROCESS_END; From 7a16cf88066805efa673447d339f53e904a909a7 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 May 2016 13:31:10 +0200 Subject: [PATCH 482/498] Revert "(RJPEG) Remove rjpeg_test" This reverts commit 5a4b062b0d2ad1f28e2897e373174be98b183443. --- libretro-common/formats/jpeg/rjpeg.c | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/libretro-common/formats/jpeg/rjpeg.c b/libretro-common/formats/jpeg/rjpeg.c index 976e7de7a2..6990f9b9ad 100644 --- a/libretro-common/formats/jpeg/rjpeg.c +++ b/libretro-common/formats/jpeg/rjpeg.c @@ -173,6 +173,16 @@ static void rjpeg__start_mem(rjpeg__context *s, const uint8_t *buffer, int len) s->img_buffer_end = (uint8_t *) buffer+len; } +static void rjpeg__rewind(rjpeg__context *s) +{ + /* conceptually rewind SHOULD rewind to the beginning of the stream, + * but we just rewind to the beginning of the initial buffer, because + * we only use it after doing 'test', which only ever looks at at most 92 bytes + */ + s->img_buffer = s->img_buffer_original; +} + +static int rjpeg__jpeg_test(rjpeg__context *s); static uint8_t *rjpeg__jpeg_load(rjpeg__context *s, unsigned *x, unsigned *y, int *comp, int req_comp); /* this is not threadsafe */ @@ -199,7 +209,10 @@ static int rjpeg__vertically_flip_on_load = 0; static unsigned char *rjpeg__load_main(rjpeg__context *s, unsigned *x, unsigned *y, int *comp, int req_comp) { - return rjpeg__jpeg_load(s,x,y,comp,req_comp); + if (rjpeg__jpeg_test(s)) + return rjpeg__jpeg_load(s,x,y,comp,req_comp); + + return rjpeg__errpuc("unknown image type", "Image not of any known type, or corrupt"); } static unsigned char *rjpeg__load_flip(rjpeg__context *s, unsigned *x, unsigned *y, int *comp, int req_comp) @@ -2406,6 +2419,17 @@ static unsigned char *rjpeg__jpeg_load(rjpeg__context *s, unsigned *x, unsigned return rjpeg_load_jpeg_image(&j, x,y,comp,req_comp); } +static int rjpeg__jpeg_test(rjpeg__context *s) +{ + int r; + rjpeg__jpeg j; + j.s = s; + rjpeg__setup_jpeg(&j); + r = rjpeg__decode_jpeg_header(&j, RJPEG_SCAN_TYPE); + rjpeg__rewind(s); + return r; +} + static INLINE void video_frame_convert_rgba_to_bgra( const void *src_data, void *dst_data, From acbc9116e3a9bb4afcc738eebe80403dfd69ef46 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 May 2016 15:00:44 +0200 Subject: [PATCH 483/498] Turn nbio_image_handle_t member image into pointer --- tasks/task_file_transfer.c | 4 +- tasks/task_image.c | 100 ++++++++++++++++++++++--------------- tasks/tasks_internal.h | 17 +------ 3 files changed, 65 insertions(+), 56 deletions(-) diff --git a/tasks/task_file_transfer.c b/tasks/task_file_transfer.c index e46ab04624..48142af6dc 100644 --- a/tasks/task_file_transfer.c +++ b/tasks/task_file_transfer.c @@ -81,7 +81,7 @@ void rarch_task_file_load_handler(retro_task_t *task) break; } - if (nbio->image.handle) + if (nbio->image) { if (!rarch_task_image_load_handler(task)) goto task_finished; @@ -102,7 +102,7 @@ void rarch_task_file_load_handler(retro_task_t *task) task_finished: task->finished = true; - if (nbio->image.handle != NULL) + if (nbio->image != NULL) rarch_task_image_load_free(task); nbio_free(nbio->handle); diff --git a/tasks/task_image.c b/tasks/task_image.c index e9b3bf0ca5..0ba0797167 100644 --- a/tasks/task_image.c +++ b/tasks/task_image.c @@ -42,6 +42,21 @@ enum image_status_enum IMAGE_STATUS_TRANSFER_PARSE_FREE }; +struct nbio_image_handle +{ + struct texture_image ti; + bool is_blocking; + bool is_blocking_on_processing; + bool is_finished; + transfer_cb_t cb; + void *handle; + size_t size; + unsigned processing_pos_increment; + unsigned pos_increment; + int processing_final_state; + unsigned status; +}; + static int cb_image_menu_upload_generic(void *data, size_t len) { unsigned r_shift, g_shift, b_shift, a_shift; @@ -50,19 +65,19 @@ static int cb_image_menu_upload_generic(void *data, size_t len) if (!nbio) return -1; - if (nbio->image.processing_final_state == IMAGE_PROCESS_ERROR || - nbio->image.processing_final_state == IMAGE_PROCESS_ERROR_END) + if (nbio->image->processing_final_state == IMAGE_PROCESS_ERROR || + nbio->image->processing_final_state == IMAGE_PROCESS_ERROR_END) return -1; video_texture_image_set_color_shifts(&r_shift, &g_shift, &b_shift, &a_shift); video_texture_image_color_convert(r_shift, g_shift, b_shift, - a_shift, &nbio->image.ti); + a_shift, &nbio->image->ti); - nbio->image.is_blocking_on_processing = false; - nbio->image.is_blocking = true; - nbio->image.is_finished = true; + nbio->image->is_blocking_on_processing = false; + nbio->image->is_blocking = true; + nbio->image->is_finished = true; nbio->is_finished = true; return 0; @@ -70,10 +85,10 @@ static int cb_image_menu_upload_generic(void *data, size_t len) static int task_image_iterate_transfer_parse(nbio_handle_t *nbio) { - if (nbio->image.handle && nbio->image.cb) + if (nbio->image->handle && nbio->image->cb) { size_t len = 0; - nbio->image.cb(nbio, len); + nbio->image->cb(nbio, len); } return 0; @@ -99,15 +114,15 @@ static int task_image_process( unsigned *height) { int retval = image_transfer_process( - nbio->image.handle, + nbio->image->handle, nbio->image_type, - &nbio->image.ti.pixels, nbio->image.size, width, height); + &nbio->image->ti.pixels, nbio->image->size, width, height); if (retval == IMAGE_PROCESS_ERROR) return IMAGE_PROCESS_ERROR; - nbio->image.ti.width = *width; - nbio->image.ti.height = *height; + nbio->image->ti.width = *width; + nbio->image->ti.height = *height; return retval; } @@ -128,8 +143,8 @@ static int cb_image_menu_generic(nbio_handle_t *nbio) break; } - nbio->image.is_blocking_on_processing = true; - nbio->image.is_finished = false; + nbio->image->is_blocking_on_processing = true; + nbio->image->is_finished = false; return 0; } @@ -141,7 +156,7 @@ static int cb_image_menu_thumbnail(void *data, size_t len) if (cb_image_menu_generic(nbio) != 0) return -1; - nbio->image.cb = &cb_image_menu_upload_generic; + nbio->image->cb = &cb_image_menu_upload_generic; return 0; } @@ -154,7 +169,7 @@ static int task_image_iterate_process_transfer(nbio_handle_t *nbio) if (!nbio) return -1; - for (i = 0; i < nbio->image.processing_pos_increment; i++) + for (i = 0; i < nbio->image->processing_pos_increment; i++) { retval = task_image_process(nbio, &width, &height); @@ -165,7 +180,7 @@ static int task_image_iterate_process_transfer(nbio_handle_t *nbio) if (retval == IMAGE_PROCESS_NEXT) return 0; - nbio->image.processing_final_state = retval; + nbio->image->processing_final_state = retval; return -1; } @@ -176,12 +191,12 @@ static int task_image_iterate_transfer(nbio_handle_t *nbio) if (!nbio) goto error; - if (nbio->image.is_finished) + if (nbio->image->is_finished) return 0; - for (i = 0; i < nbio->image.pos_increment; i++) + for (i = 0; i < nbio->image->pos_increment; i++) { - if (!image_transfer_iterate(nbio->image.handle, nbio->image_type)) + if (!image_transfer_iterate(nbio->image->handle, nbio->image_type)) goto error; } @@ -193,10 +208,16 @@ error: static void rarch_task_image_load_free_internal(nbio_handle_t *nbio) { - nbio_image_handle_t *image = nbio ? &nbio->image : NULL; + nbio_image_handle_t *image = nbio ? nbio->image : NULL; + + if (nbio->image) + free(nbio->image); + + nbio->image = NULL; image_transfer_free(image->handle, nbio->image_type); + image->handle = NULL; image->cb = NULL; } @@ -205,7 +226,7 @@ static int cb_nbio_generic(nbio_handle_t *nbio, size_t *len) { void *ptr = NULL; - if (!nbio->image.handle) + if (!nbio->image->handle) goto error; ptr = nbio_get_ptr(nbio->handle, len); @@ -213,17 +234,17 @@ static int cb_nbio_generic(nbio_handle_t *nbio, size_t *len) if (!ptr) goto error; - image_transfer_set_buffer_ptr(nbio->image.handle, nbio->image_type, ptr); + image_transfer_set_buffer_ptr(nbio->image->handle, nbio->image_type, ptr); - nbio->image.size = *len; - nbio->image.pos_increment = (*len / 2) ? (*len / 2) : 1; - nbio->image.processing_pos_increment = (*len / 4) ? (*len / 4) : 1; + nbio->image->size = *len; + nbio->image->pos_increment = (*len / 2) ? (*len / 2) : 1; + nbio->image->processing_pos_increment = (*len / 4) ? (*len / 4) : 1; - if (!image_transfer_start(nbio->image.handle, nbio->image_type)) + if (!image_transfer_start(nbio->image->handle, nbio->image_type)) goto error; - nbio->image.is_blocking = false; - nbio->image.is_finished = false; + nbio->image->is_blocking = false; + nbio->image->is_finished = false; nbio->is_finished = true; return 0; @@ -240,25 +261,25 @@ static int cb_nbio_image_menu_thumbnail(void *data, size_t len) if (!nbio || !data) return -1; - nbio->image.handle = image_transfer_new(nbio->image_type); - nbio->image.size = len; + nbio->image->handle = image_transfer_new(nbio->image_type); + nbio->image->size = len; - if (!nbio->image.handle) + if (!nbio->image->handle) goto error; - nbio->image.cb = &cb_image_menu_thumbnail; + nbio->image->cb = &cb_image_menu_thumbnail; return cb_nbio_generic(nbio, &len); error: - nbio->image.handle = 0; + nbio->image->handle = 0; return -1; } bool rarch_task_image_load_handler(retro_task_t *task) { nbio_handle_t *nbio = (nbio_handle_t*)task->state; - nbio_image_handle_t *image = nbio ? &nbio->image : NULL; + nbio_image_handle_t *image = nbio ? nbio->image : NULL; switch (image->status) { @@ -287,13 +308,13 @@ bool rarch_task_image_load_handler(retro_task_t *task) } if ( nbio->is_finished - && nbio->image.is_finished + && nbio->image->is_finished && !task->cancelled) { - task->task_data = malloc(sizeof(nbio->image.ti)); + task->task_data = malloc(sizeof(nbio->image->ti)); if (task->task_data) - memcpy(task->task_data, &nbio->image.ti, sizeof(nbio->image.ti)); + memcpy(task->task_data, &nbio->image->ti, sizeof(nbio->image->ti)); return false; } @@ -317,11 +338,12 @@ bool rarch_task_push_image_load(const char *fullpath, if (!nbio) goto error; + nbio->image = (struct nbio_image_handle*)calloc(1, sizeof(*nbio->image)); nbio->handle = handle; nbio->is_finished = false; nbio->cb = &cb_nbio_default; nbio->status = NBIO_STATUS_TRANSFER; - nbio->image.status = IMAGE_STATUS_TRANSFER; + nbio->image->status = IMAGE_STATUS_TRANSFER; if (strstr(fullpath, ".png")) nbio->image_type = IMAGE_TYPE_PNG; diff --git a/tasks/tasks_internal.h b/tasks/tasks_internal.h index 5f39d251fe..aab0274b32 100644 --- a/tasks/tasks_internal.h +++ b/tasks/tasks_internal.h @@ -54,25 +54,12 @@ typedef struct http_transfer_info } http_transfer_info_t; #endif -typedef struct nbio_image_handle -{ - struct texture_image ti; - bool is_blocking; - bool is_blocking_on_processing; - bool is_finished; - transfer_cb_t cb; - void *handle; - size_t size; - unsigned processing_pos_increment; - unsigned pos_increment; - int processing_final_state; - unsigned status; -} nbio_image_handle_t; +typedef struct nbio_image_handle nbio_image_handle_t; typedef struct nbio_handle { enum image_type_enum image_type; - nbio_image_handle_t image; + nbio_image_handle_t *image; bool is_finished; transfer_cb_t cb; struct nbio_t *handle; From 42adb48d9c139133721953b36b30c469ec536f63 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Fri, 13 May 2016 15:18:40 +0200 Subject: [PATCH 484/498] (task_image.c )Cleanups --- tasks/task_image.c | 88 ++++++++++++++++++++++++++-------------------- 1 file changed, 49 insertions(+), 39 deletions(-) diff --git a/tasks/task_image.c b/tasks/task_image.c index 0ba0797167..26231706ad 100644 --- a/tasks/task_image.c +++ b/tasks/task_image.c @@ -61,34 +61,37 @@ static int cb_image_menu_upload_generic(void *data, size_t len) { unsigned r_shift, g_shift, b_shift, a_shift; nbio_handle_t *nbio = (nbio_handle_t*)data; + nbio_image_handle_t *image = nbio ? (nbio_image_handle_t*)nbio->image : NULL; - if (!nbio) + if (!nbio || !image) return -1; - if (nbio->image->processing_final_state == IMAGE_PROCESS_ERROR || - nbio->image->processing_final_state == IMAGE_PROCESS_ERROR_END) + if (image->processing_final_state == IMAGE_PROCESS_ERROR || + image->processing_final_state == IMAGE_PROCESS_ERROR_END) return -1; video_texture_image_set_color_shifts(&r_shift, &g_shift, &b_shift, &a_shift); video_texture_image_color_convert(r_shift, g_shift, b_shift, - a_shift, &nbio->image->ti); + a_shift, &image->ti); - nbio->image->is_blocking_on_processing = false; - nbio->image->is_blocking = true; - nbio->image->is_finished = true; - nbio->is_finished = true; + image->is_blocking_on_processing = false; + image->is_blocking = true; + image->is_finished = true; + nbio->is_finished = true; return 0; } static int task_image_iterate_transfer_parse(nbio_handle_t *nbio) { - if (nbio->image->handle && nbio->image->cb) + nbio_image_handle_t *image = (nbio_image_handle_t*)nbio->image; + + if (image->handle && image->cb) { size_t len = 0; - nbio->image->cb(nbio, len); + image->cb(nbio, len); } return 0; @@ -113,16 +116,17 @@ static int task_image_process( unsigned *width, unsigned *height) { + nbio_image_handle_t *image = (nbio_image_handle_t*)nbio->image; int retval = image_transfer_process( - nbio->image->handle, + image->handle, nbio->image_type, - &nbio->image->ti.pixels, nbio->image->size, width, height); + &image->ti.pixels, image->size, width, height); if (retval == IMAGE_PROCESS_ERROR) return IMAGE_PROCESS_ERROR; - nbio->image->ti.width = *width; - nbio->image->ti.height = *height; + image->ti.width = *width; + image->ti.height = *height; return retval; } @@ -130,7 +134,8 @@ static int task_image_process( static int cb_image_menu_generic(nbio_handle_t *nbio) { unsigned width = 0, height = 0; - if (!nbio) + nbio_image_handle_t *image = nbio ? (nbio_image_handle_t*)nbio->image : NULL; + if (!nbio || !image) return -1; switch (task_image_process(nbio, @@ -143,8 +148,8 @@ static int cb_image_menu_generic(nbio_handle_t *nbio) break; } - nbio->image->is_blocking_on_processing = true; - nbio->image->is_finished = false; + image->is_blocking_on_processing = true; + image->is_finished = false; return 0; } @@ -152,11 +157,12 @@ static int cb_image_menu_generic(nbio_handle_t *nbio) static int cb_image_menu_thumbnail(void *data, size_t len) { nbio_handle_t *nbio = (nbio_handle_t*)data; + nbio_image_handle_t *image = nbio ? (nbio_image_handle_t*)nbio->image : NULL; if (cb_image_menu_generic(nbio) != 0) return -1; - nbio->image->cb = &cb_image_menu_upload_generic; + image->cb = &cb_image_menu_upload_generic; return 0; } @@ -165,11 +171,12 @@ static int task_image_iterate_process_transfer(nbio_handle_t *nbio) { unsigned i, width = 0, height = 0; int retval = 0; + nbio_image_handle_t *image = nbio ? (nbio_image_handle_t*)nbio->image : NULL; if (!nbio) return -1; - for (i = 0; i < nbio->image->processing_pos_increment; i++) + for (i = 0; i < image->processing_pos_increment; i++) { retval = task_image_process(nbio, &width, &height); @@ -180,23 +187,24 @@ static int task_image_iterate_process_transfer(nbio_handle_t *nbio) if (retval == IMAGE_PROCESS_NEXT) return 0; - nbio->image->processing_final_state = retval; + image->processing_final_state = retval; return -1; } static int task_image_iterate_transfer(nbio_handle_t *nbio) { unsigned i; + nbio_image_handle_t *image = nbio ? (nbio_image_handle_t*)nbio->image : NULL; - if (!nbio) + if (!nbio || !image) goto error; - if (nbio->image->is_finished) + if (image->is_finished) return 0; - for (i = 0; i < nbio->image->pos_increment; i++) + for (i = 0; i < image->pos_increment; i++) { - if (!image_transfer_iterate(nbio->image->handle, nbio->image_type)) + if (!image_transfer_iterate(image->handle, nbio->image_type)) goto error; } @@ -225,8 +233,9 @@ static void rarch_task_image_load_free_internal(nbio_handle_t *nbio) static int cb_nbio_generic(nbio_handle_t *nbio, size_t *len) { void *ptr = NULL; + nbio_image_handle_t *image = nbio ? nbio->image : NULL; - if (!nbio->image->handle) + if (!image || !image->handle) goto error; ptr = nbio_get_ptr(nbio->handle, len); @@ -234,18 +243,18 @@ static int cb_nbio_generic(nbio_handle_t *nbio, size_t *len) if (!ptr) goto error; - image_transfer_set_buffer_ptr(nbio->image->handle, nbio->image_type, ptr); + image_transfer_set_buffer_ptr(image->handle, nbio->image_type, ptr); - nbio->image->size = *len; - nbio->image->pos_increment = (*len / 2) ? (*len / 2) : 1; - nbio->image->processing_pos_increment = (*len / 4) ? (*len / 4) : 1; + image->size = *len; + image->pos_increment = (*len / 2) ? (*len / 2) : 1; + image->processing_pos_increment = (*len / 4) ? (*len / 4) : 1; - if (!image_transfer_start(nbio->image->handle, nbio->image_type)) + if (!image_transfer_start(image->handle, nbio->image_type)) goto error; - nbio->image->is_blocking = false; - nbio->image->is_finished = false; - nbio->is_finished = true; + image->is_blocking = false; + image->is_finished = false; + nbio->is_finished = true; return 0; @@ -257,22 +266,23 @@ error: static int cb_nbio_image_menu_thumbnail(void *data, size_t len) { nbio_handle_t *nbio = (nbio_handle_t*)data; + nbio_image_handle_t *image = nbio ? nbio->image : NULL; - if (!nbio || !data) + if (!nbio || !data || !image) return -1; - nbio->image->handle = image_transfer_new(nbio->image_type); - nbio->image->size = len; + image->handle = image_transfer_new(nbio->image_type); + image->size = len; - if (!nbio->image->handle) + if (!image->handle) goto error; - nbio->image->cb = &cb_image_menu_thumbnail; + image->cb = &cb_image_menu_thumbnail; return cb_nbio_generic(nbio, &len); error: - nbio->image->handle = 0; + image->handle = 0; return -1; } From f8e99403a481f11ba3003eae92805839c8f9f948 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 14 May 2016 00:48:40 +0200 Subject: [PATCH 485/498] Cleanups --- libretro-common/formats/png/test/rpng_test.c | 8 ++--- tasks/task_image.c | 31 ++++++++++++-------- 2 files changed, 23 insertions(+), 16 deletions(-) diff --git a/libretro-common/formats/png/test/rpng_test.c b/libretro-common/formats/png/test/rpng_test.c index 57d37df356..0cb86e8a19 100644 --- a/libretro-common/formats/png/test/rpng_test.c +++ b/libretro-common/formats/png/test/rpng_test.c @@ -71,13 +71,13 @@ static bool rpng_load_image_argb(const char *path, uint32_t **data, goto end; } - if (!rpng_nbio_load_image_argb_start(rpng)) + if (!rpng_start(rpng)) { ret = false; goto end; } - while (rpng_nbio_load_image_argb_iterate(rpng)); + while (rpng_iterate_image(rpng)); if (!rpng_is_valid(rpng)) { @@ -87,7 +87,7 @@ static bool rpng_load_image_argb(const char *path, uint32_t **data, do { - retval = rpng_nbio_load_image_argb_process(rpng, data, width, height); + retval = rpng_process_image(rpng, (void**)data, width, height); }while(retval == IMAGE_PROCESS_NEXT); if (retval == IMAGE_PROCESS_ERROR || retval == IMAGE_PROCESS_ERROR_END) @@ -97,7 +97,7 @@ end: if (handle) nbio_free(handle); if (rpng) - rpng_nbio_load_image_free(rpng); + rpng_free(rpng); rpng = NULL; if (!ret) free(*data); diff --git a/tasks/task_image.c b/tasks/task_image.c index 26231706ad..c588f3486e 100644 --- a/tasks/task_image.c +++ b/tasks/task_image.c @@ -218,14 +218,13 @@ static void rarch_task_image_load_free_internal(nbio_handle_t *nbio) { nbio_image_handle_t *image = nbio ? nbio->image : NULL; - if (nbio->image) - free(nbio->image); + if (image) + free(image); nbio->image = NULL; image_transfer_free(image->handle, nbio->image_type); - image->handle = NULL; image->cb = NULL; } @@ -318,13 +317,13 @@ bool rarch_task_image_load_handler(retro_task_t *task) } if ( nbio->is_finished - && nbio->image->is_finished + && image->is_finished && !task->cancelled) { - task->task_data = malloc(sizeof(nbio->image->ti)); + task->task_data = malloc(sizeof(image->ti)); if (task->task_data) - memcpy(task->task_data, &nbio->image->ti, sizeof(nbio->image->ti)); + memcpy(task->task_data, &image->ti, sizeof(image->ti)); return false; } @@ -335,10 +334,11 @@ bool rarch_task_image_load_handler(retro_task_t *task) bool rarch_task_push_image_load(const char *fullpath, const char *type, retro_task_callback_t cb, void *user_data) { - nbio_handle_t *nbio = NULL; - retro_task_t *t = NULL; - uint32_t cb_type_hash = djb2_calculate(type); - struct nbio_t *handle = nbio_open(fullpath, NBIO_READ); + nbio_handle_t *nbio = NULL; + retro_task_t *t = NULL; + uint32_t cb_type_hash = djb2_calculate(type); + struct nbio_t *handle = nbio_open(fullpath, NBIO_READ); + nbio_image_handle_t *image = NULL; if (!handle) goto error; @@ -348,12 +348,17 @@ bool rarch_task_push_image_load(const char *fullpath, if (!nbio) goto error; - nbio->image = (struct nbio_image_handle*)calloc(1, sizeof(*nbio->image)); + image = (nbio_image_handle_t*)calloc(1, sizeof(*image)); + + if (!image) + goto error; + + nbio->image = image; nbio->handle = handle; nbio->is_finished = false; nbio->cb = &cb_nbio_default; nbio->status = NBIO_STATUS_TRANSFER; - nbio->image->status = IMAGE_STATUS_TRANSFER; + image->status = IMAGE_STATUS_TRANSFER; if (strstr(fullpath, ".png")) nbio->image_type = IMAGE_TYPE_PNG; @@ -389,6 +394,8 @@ bool rarch_task_push_image_load(const char *fullpath, error: if (t) free(t); + if (nbio->image) + free(nbio->image); if (nbio) free(nbio); RARCH_ERR("[image load] Failed to open '%s': %s.\n", From 23f410c5fe8d74337ea15d025a43231600584447 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 14 May 2016 01:12:05 +0200 Subject: [PATCH 486/498] (RPNG) Fix test --- libretro-common/formats/png/test/rpng_test.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libretro-common/formats/png/test/rpng_test.c b/libretro-common/formats/png/test/rpng_test.c index 0cb86e8a19..7da75d108b 100644 --- a/libretro-common/formats/png/test/rpng_test.c +++ b/libretro-common/formats/png/test/rpng_test.c @@ -87,7 +87,8 @@ static bool rpng_load_image_argb(const char *path, uint32_t **data, do { - retval = rpng_process_image(rpng, (void**)data, width, height); + retval = rpng_process_image(rpng, + (void**)data, file_len, width, height); }while(retval == IMAGE_PROCESS_NEXT); if (retval == IMAGE_PROCESS_ERROR || retval == IMAGE_PROCESS_ERROR_END) From 3257ecdaef5205a73aff0f40dfbe4d6cc5c192b7 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 14 May 2016 01:27:09 +0200 Subject: [PATCH 487/498] (features_cpu.c) Move _WIN32 up in priority --- libretro-common/features/features_cpu.c | 34 +++++++++---------- .../include/features/features_cpu.h | 3 +- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/libretro-common/features/features_cpu.c b/libretro-common/features/features_cpu.c index f3671e92d8..42fb745a75 100644 --- a/libretro-common/features/features_cpu.c +++ b/libretro-common/features/features_cpu.c @@ -117,7 +117,23 @@ static int clock_gettime(int clk_ik, struct timespec *t) retro_perf_tick_t cpu_features_get_perf_counter(void) { retro_perf_tick_t time_ticks = 0; -#if defined(__linux__) || defined(__QNX__) || defined(__MACH__) +#if defined(_WIN32) + long tv_sec, tv_usec; + static const unsigned __int64 epoch = 11644473600000000Ui64; + FILETIME file_time; + SYSTEMTIME system_time; + ULARGE_INTEGER ularge; + + GetSystemTime(&system_time); + SystemTimeToFileTime(&system_time, &file_time); + ularge.LowPart = file_time.dwLowDateTime; + ularge.HighPart = file_time.dwHighDateTime; + + tv_sec = (long)((ularge.QuadPart - epoch) / 10000000L); + tv_usec = (long)(system_time.wMilliseconds * 1000); + + time_ticks = (1000000 * tv_sec + tv_usec); +#elif defined(__linux__) || defined(__QNX__) || defined(__MACH__) struct timespec tv; if (clock_gettime(CLOCK_MONOTONIC, &tv) == 0) time_ticks = (retro_perf_tick_t)tv.tv_sec * 1000000000 + @@ -143,22 +159,6 @@ retro_perf_tick_t cpu_features_get_perf_counter(void) struct timeval tv; gettimeofday(&tv,NULL); time_ticks = (1000000 * tv.tv_sec + tv.tv_usec); -#elif defined(_WIN32) - long tv_sec, tv_usec; - static const unsigned __int64 epoch = 11644473600000000Ui64; - FILETIME file_time; - SYSTEMTIME system_time; - ULARGE_INTEGER ularge; - - GetSystemTime(&system_time); - SystemTimeToFileTime(&system_time, &file_time); - ularge.LowPart = file_time.dwLowDateTime; - ularge.HighPart = file_time.dwHighDateTime; - - tv_sec = (long)((ularge.QuadPart - epoch) / 10000000L); - tv_usec = (long)(system_time.wMilliseconds * 1000); - - time_ticks = (1000000 * tv_sec + tv_usec); #endif return time_ticks; diff --git a/libretro-common/include/features/features_cpu.h b/libretro-common/include/features/features_cpu.h index 019c7f76a4..e7ebebb6ea 100644 --- a/libretro-common/include/features/features_cpu.h +++ b/libretro-common/include/features/features_cpu.h @@ -68,5 +68,4 @@ unsigned cpu_features_get_core_amount(void); RETRO_END_DECLS -#endif - +#endif \ No newline at end of file From 9e1276d76fcd8b3de34f6369ea6f02e26d7c85de Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 14 May 2016 01:32:05 +0200 Subject: [PATCH 488/498] (MSVC) Buildfixes --- libretro-common/features/features_cpu.c | 1 + tasks/task_file_transfer.c | 3 --- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/libretro-common/features/features_cpu.c b/libretro-common/features/features_cpu.c index 42fb745a75..b6e6afb1c4 100644 --- a/libretro-common/features/features_cpu.c +++ b/libretro-common/features/features_cpu.c @@ -32,6 +32,7 @@ #include #include #include +#include #if defined(_WIN32) && !defined(_XBOX) #include diff --git a/tasks/task_file_transfer.c b/tasks/task_file_transfer.c index 48142af6dc..4b98f083ce 100644 --- a/tasks/task_file_transfer.c +++ b/tasks/task_file_transfer.c @@ -102,9 +102,6 @@ void rarch_task_file_load_handler(retro_task_t *task) task_finished: task->finished = true; - if (nbio->image != NULL) - rarch_task_image_load_free(task); - nbio_free(nbio->handle); nbio->handle = NULL; nbio->is_finished = false; From d3f4be0bbcae5f25d9331b6f72a8043a44718f21 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 14 May 2016 02:54:56 +0200 Subject: [PATCH 489/498] (features_cpu.c) Fix mingw error --- libretro-common/features/features_cpu.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/libretro-common/features/features_cpu.c b/libretro-common/features/features_cpu.c index b6e6afb1c4..0d15f8766c 100644 --- a/libretro-common/features/features_cpu.c +++ b/libretro-common/features/features_cpu.c @@ -120,19 +120,18 @@ retro_perf_tick_t cpu_features_get_perf_counter(void) retro_perf_tick_t time_ticks = 0; #if defined(_WIN32) long tv_sec, tv_usec; - static const unsigned __int64 epoch = 11644473600000000Ui64; + static const unsigned __int64 epoch = 11644473600000000ULL; FILETIME file_time; SYSTEMTIME system_time; ULARGE_INTEGER ularge; GetSystemTime(&system_time); SystemTimeToFileTime(&system_time, &file_time); - ularge.LowPart = file_time.dwLowDateTime; + ularge.LowPart = file_time.dwLowDateTime; ularge.HighPart = file_time.dwHighDateTime; - tv_sec = (long)((ularge.QuadPart - epoch) / 10000000L); - tv_usec = (long)(system_time.wMilliseconds * 1000); - + tv_sec = (long)((ularge.QuadPart - epoch) / 10000000L); + tv_usec = (long)(system_time.wMilliseconds * 1000); time_ticks = (1000000 * tv_sec + tv_usec); #elif defined(__linux__) || defined(__QNX__) || defined(__MACH__) struct timespec tv; From cd0b925fa12df0e13ed97d239870c927186d9ece Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 14 May 2016 06:00:53 +0200 Subject: [PATCH 490/498] Try to see if this gets us past the crash --- tasks/task_image.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/tasks/task_image.c b/tasks/task_image.c index c588f3486e..6768b41433 100644 --- a/tasks/task_image.c +++ b/tasks/task_image.c @@ -394,10 +394,13 @@ bool rarch_task_push_image_load(const char *fullpath, error: if (t) free(t); - if (nbio->image) - free(nbio->image); if (nbio) + { + if (nbio->image) + free(nbio->image); free(nbio); + } + RARCH_ERR("[image load] Failed to open '%s': %s.\n", fullpath, strerror(errno)); return false; From 1e27312c251e439c4030173df050c8d94386c7ed Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 14 May 2016 13:35:50 +0200 Subject: [PATCH 491/498] Get rid of unused functions --- libretro-common/features/features_cpu.c | 46 ------------------------- 1 file changed, 46 deletions(-) diff --git a/libretro-common/features/features_cpu.c b/libretro-common/features/features_cpu.c index 0d15f8766c..0c1cc47b10 100644 --- a/libretro-common/features/features_cpu.c +++ b/libretro-common/features/features_cpu.c @@ -312,52 +312,6 @@ static unsigned char check_arm_cpu_feature(const char* feature) return status; } -static unsigned char get_arm_cpu_implementer(void) -{ - unsigned char implementer = 0; - FILE *fp = fopen("/proc/cpuinfo", "r"); - - if (fp) - { - char line[1024]; - - while (fgets(line , sizeof(line) , fp) != NULL) - { - if (strncmp(line, "CPU implementer\t: ", 18)) - continue; - - sscanf(line+18, "0x%02hhx", &implementer); - - break; - } - fclose(fp); - } - return implementer; -} - -static unsigned short get_arm_cpu_part(void) -{ - unsigned short part = 0; - FILE *fp = fopen("/proc/cpuinfo", "r"); - - if (fp) - { - char line[1024]; - - while (fgets(line , sizeof(line) , fp) != NULL) - { - if (strncmp(line, "CPU part\t: ", 11)) - continue; - - sscanf(line+11, "0x%03hx", &part); - - break; - } - fclose(fp); - } - return part; -} - #if !defined(_SC_NPROCESSORS_ONLN) /* Parse an decimal integer starting from 'input', but not going further * than 'limit'. Return the value into '*result'. From 8b9cabf41d8f13ab89812f148530107416a8ed4b Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 14 May 2016 13:37:07 +0200 Subject: [PATCH 492/498] Show VFPv3/VFPv4 --- retroarch.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/retroarch.c b/retroarch.c index f4c5fb3ba5..009e3454ae 100644 --- a/retroarch.c +++ b/retroarch.c @@ -1616,6 +1616,10 @@ int retroarch_get_capabilities(enum rarch_capabilities type, strlcat(s, "VFPU ", len); if (cpu & RETRO_SIMD_NEON) strlcat(s, "NEON ", len); + if (cpu & RETRO_SIMD_VFPV3) + strlcat(s, "VFPv3 ", len); + if (cpu & RETRO_SIMD_VFPV4) + strlcat(s, "VFPv4 ", len); if (cpu & RETRO_SIMD_PS) strlcat(s, "PS ", len); if (cpu & RETRO_SIMD_AES) From 2ea009d3018337f39411c78d169a21f74f2bef7c Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 14 May 2016 15:59:22 +0200 Subject: [PATCH 493/498] Check if power management file exists first before trying to access it --- frontend/drivers/platform_linux.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/frontend/drivers/platform_linux.c b/frontend/drivers/platform_linux.c index 3f48e38a7d..9a2a54025a 100644 --- a/frontend/drivers/platform_linux.c +++ b/frontend/drivers/platform_linux.c @@ -811,6 +811,8 @@ static void check_proc_acpi_sysfs_ac_adapter(const char * node, bool *have_ac) const char *base = proc_acpi_sysfs_ac_adapter_path; snprintf(path, sizeof(path), "%s/%s", base, "online"); + if (!path_file_exists(path)) + return; if (filestream_read_file(path, (void**)&buf, &length) != 1) return; From ca0634e16dd769f62193e27d15242ca0905a63d8 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 14 May 2016 16:01:29 +0200 Subject: [PATCH 494/498] Check if file exists for all power management routines --- frontend/drivers/platform_linux.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/frontend/drivers/platform_linux.c b/frontend/drivers/platform_linux.c index 9a2a54025a..04d7db3c01 100644 --- a/frontend/drivers/platform_linux.c +++ b/frontend/drivers/platform_linux.c @@ -626,6 +626,9 @@ static void check_proc_acpi_battery(const char * node, bool * have_battery, snprintf(path, sizeof(path), "%s/%s/%s", base, node, "state"); + if (!path_file_exists(path)) + goto end; + if (!filestream_read_file(path, (void**)&buf, &length)) goto end; @@ -751,6 +754,8 @@ static void check_proc_acpi_sysfs_battery(const char *node, return; snprintf(path, sizeof(path), "%s/%s/%s", base, node, "status"); + if (!path_file_exists(path)) + return; if (filestream_read_file(path, (void**)&buf, &length) != 1) return; @@ -784,6 +789,8 @@ static void check_proc_acpi_ac_adapter(const char * node, bool *have_ac) ssize_t length = 0; snprintf(path, sizeof(path), "%s/%s/%s", base, node, "state"); + if (!path_file_exists(path)) + return; if (filestream_read_file(path, (void**)&buf, &length) != 1) return; @@ -868,6 +875,8 @@ static bool frontend_linux_powerstate_check_apm( char *buf = NULL; char *str = NULL; + if (!path_file_exists(proc_apm_path)) + goto error; if (filestream_read_file(proc_apm_path, (void**)&buf, &length) != 1) goto error; From 4680d7059a9d79db93602edccbb31385752e2ea8 Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 14 May 2016 16:34:28 +0200 Subject: [PATCH 495/498] (platform_linux.c) Cleanups --- frontend/drivers/platform_linux.c | 55 +++++++++++++++++-------------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/frontend/drivers/platform_linux.c b/frontend/drivers/platform_linux.c index 04d7db3c01..c58810f587 100644 --- a/frontend/drivers/platform_linux.c +++ b/frontend/drivers/platform_linux.c @@ -48,9 +48,39 @@ #include "../frontend_driver.h" #include "../../defaults.h" #include "../../general.h" +#include "../../retroarch.h" #include "../../verbosity.h" #include "platform_linux.h" +#ifdef ANDROID +enum +{ + /* Internal SDCARD writable */ + INT_SD_WRITABLE = 1, + /* Internal SDCARD not writable but the private app dir is */ + INT_SD_APPDIR_WRITABLE, + /* Internal SDCARD not writable at all */ + INT_SD_NOT_WRITABLE +}; + +struct android_app *g_android; + +static pthread_key_t thread_key; + +static char screenshot_dir[PATH_MAX_LENGTH]; +static char downloads_dir[PATH_MAX_LENGTH]; +static char apk_dir[PATH_MAX_LENGTH]; +static char app_dir[PATH_MAX_LENGTH]; +static char int_sd_dir[PATH_MAX_LENGTH]; +static char int_sd_app_dir[PATH_MAX_LENGTH]; +#else +static const char *proc_apm_path = "/proc/apm"; +static const char *proc_acpi_battery_path = "/proc/acpi/battery"; +static const char *proc_acpi_sysfs_ac_adapter_path = "/sys/class/power_supply/ACAD"; +static const char *proc_acpi_sysfs_battery_path = "/sys/class/power_supply"; +static const char *proc_acpi_ac_adapter_path = "/proc/acpi/ac_adapter"; +#endif + #ifndef HAVE_DYNAMIC static enum frontend_fork linux_fork_mode = FRONTEND_FORK_NONE; #endif @@ -98,24 +128,6 @@ error: } #ifdef ANDROID -/* Internal SDCARD writable */ -#define INT_SD_WRITABLE 1 -/* Internal SDCARD not writable but the private app dir is */ -#define INT_SD_APPDIR_WRITABLE 2 -/* Internal SDCARD not writable at all */ -#define INT_SD_NOT_WRITABLE 3 - -struct android_app *g_android; -static pthread_key_t thread_key; - -char screenshot_dir[PATH_MAX_LENGTH]; -char downloads_dir[PATH_MAX_LENGTH]; -char apk_dir[PATH_MAX_LENGTH]; -char int_sd_dir[PATH_MAX_LENGTH]; -char app_dir[PATH_MAX_LENGTH]; -char int_sd_app_dir[PATH_MAX_LENGTH]; - - /* forward declaration */ bool android_run_events(void *data); @@ -550,12 +562,6 @@ static void frontend_android_shutdown(bool unused) } #else -static const char *proc_apm_path = "/proc/apm"; -static const char *proc_acpi_battery_path = "/proc/acpi/battery"; -static const char *proc_acpi_sysfs_ac_adapter_path= "/sys/class/power_supply/ACAD"; -static const char *proc_acpi_sysfs_battery_path= "/sys/class/power_supply"; -static const char *proc_acpi_ac_adapter_path = "/proc/acpi/ac_adapter"; - static bool make_proc_acpi_key_val(char **_ptr, char **_key, char **_val) { @@ -1813,7 +1819,6 @@ static int frontend_android_parse_drive_list(void *data) #endif #ifndef HAVE_DYNAMIC -#include "../../retroarch.h" static bool frontend_linux_set_fork(enum frontend_fork fork_mode) { From c1633a86954339dd2f521b5d5574b6d70d4aa11d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 14 May 2016 16:40:09 +0200 Subject: [PATCH 496/498] Add jpeg to retroarch_print_features --- retroarch.c | 1 + 1 file changed, 1 insertion(+) diff --git a/retroarch.c b/retroarch.c index 009e3454ae..d1e5fdc3a5 100644 --- a/retroarch.c +++ b/retroarch.c @@ -154,6 +154,7 @@ static void retroarch_print_features(void) _PSUPP(libxml2, "libxml2", "libxml2 XML parsing"); _PSUPP(sdl_image, "SDL_image", "SDL_image image loading"); _PSUPP(rpng, "rpng", "PNG image loading/encoding"); + _PSUPP(rpng, "rjpeg", "JPEG image loading"); _PSUPP(fbo, "FBO", "OpenGL render-to-texture (multi-pass shaders)"); _PSUPP(dynamic, "Dynamic", "Dynamic run-time loading of libretro library"); _PSUPP(ffmpeg, "FFmpeg", "On-the-fly recording of gameplay with libavcodec"); From 92b1398a79502d29bc836c927c16b035fc45ba8d Mon Sep 17 00:00:00 2001 From: twinaphex Date: Sat, 14 May 2016 16:49:29 +0200 Subject: [PATCH 497/498] Fix CXX_BUILD warnings --- cheevos.c | 4 ++-- menu/menu_setting.c | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cheevos.c b/cheevos.c index 672ad41f11..39262e2ab1 100644 --- a/cheevos.c +++ b/cheevos.c @@ -1651,7 +1651,7 @@ static int cheevos_deactivate__json_number(void *userdata, for (; cheevo < end; cheevo++) { - if (cheevo->id == id) + if (cheevo->id == (unsigned)id) { cheevo->active = 0; found = 1; @@ -1666,7 +1666,7 @@ static int cheevos_deactivate__json_number(void *userdata, for (; cheevo < end; cheevo++) { - if (cheevo->id == id) + if (cheevo->id == (unsigned)id) { cheevo->active = 0; break; diff --git a/menu/menu_setting.c b/menu/menu_setting.c index 0959b2ccc7..b43103c643 100644 --- a/menu/menu_setting.c +++ b/menu/menu_setting.c @@ -796,7 +796,7 @@ static int setting_string_action_right_audio_device(void *data, bool wraparound) audio_device_index++; /* Reset index if needed */ - if (audio_device_index == ptr->size) + if (audio_device_index == (signed)ptr->size) audio_device_index = 0; strlcpy(setting->value.target.string, ptr->elems[audio_device_index].data, setting->size); From 33e90031074e7ecd577ac11645eb233a02550a21 Mon Sep 17 00:00:00 2001 From: Alcaro Date: Sat, 14 May 2016 23:20:35 +0200 Subject: [PATCH 498/498] This is just noise. --- 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 0c1cc47b10..641b441238 100644 --- a/libretro-common/features/features_cpu.c +++ b/libretro-common/features/features_cpu.c @@ -591,7 +591,7 @@ uint64_t cpu_features_get(void) vendor_shuffle[2] = flags[2]; memcpy(vendor, vendor_shuffle, sizeof(vendor_shuffle)); - printf("[CPUID]: Vendor: %s\n", vendor); + /* printf("[CPUID]: Vendor: %s\n", vendor); */ vendor_is_intel = ( flags[1] == VENDOR_INTEL_b &&